Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lucky-canvas

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lucky-canvas - npm Package Compare versions

Comparing version 1.1.8 to 1.2.0

2

dist/lucky-canvas.cjs.min.js

@@ -16,2 +16,2 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});

***************************************************************************** */
var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return(i=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function n(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function r(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function o(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var s=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},a=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},h=function(){function t(t){this.global={},this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.setTimeout=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).flag||(t.flag="WEB"),0===t.flag.indexOf("UNI-")?this.global=uni:"MINI-WX"===t.flag&&(this.global=wx),t.el&&(t.divElement=document.querySelector(t.el));var e=0,i=0;t.divElement&&(e=t.divElement.offsetWidth,i=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width=this.getLength(t.width)||e,t.height=this.getLength(t.height)||i,t.divElement&&(t.divElement.style.width=t.width+"px",t.divElement.style.height=t.height+"px"),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height&&(this.resetArrayProto(),this.initWindowFunction())}return t.prototype.setDpr=function(){window?window.dpr=this.dpr=1.3*(window.devicePixelRatio||2):this.dpr=this.config.dpr},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){if(window)return this.rAF=window.requestAnimationFrame,this.setInterval=window.setInterval,void(this.clearInterval=window.clearInterval);if(this.config.rAF)this.rAF=this.config.rAF;else if(this.config.setTimeout){var t=this.config.setTimeout;this.rAF=function(e){return t(e,16)}}else this.rAF=function(t){return setTimeout(t,16)}},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.canvasElement,o=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&(r.width=e.width*n,r.height=e.height*n,r.style.width=r.width+"px",r.style.height=r.height+"px",r.style.transform="scale("+1/n+") translate(\n "+-o(r.width)+"%, "+-o(r.height)+"%\n )",i.scale(n,n))},t.prototype.loadImg=function(t,e){var i=this;return new Promise((function(n){if("WEB"===i.config.flag){var r=new Image;r.src=t,r.onload=function(){return n(r)}}else if(["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(i.config.flag)){if(/^data:image\/([a-z]+);base64,/.test(t))return void(e.$resolve=n);i.global.getImageInfo({src:t,success:function(t){return n(t)},fail:function(){return console.error("API `getImageInfo` 加载图片失败",t)}})}}))},t.prototype.getLength=function(t){return s(t,"number")?t:s(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?750/e.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?e.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,o([this],Array.from(arguments)))}}))},t}(),l=function(t){return Math.PI/180*t},c=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},f=function(t,e){var i=-t/e;return[i,-i*t+e]},u=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=l(180).toFixed(8)){var s=(n+i)/2;return r?(u(t,e,i,s,r),u(t,e,s,n,r)):(u(t,e,s,n,r),u(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=c(i,e),h=a[0],d=a[1],g=c(n,e),p=g[0],m=g[1],v=f(h,d),y=v[0],w=v[1],b=f(p,m),I=b[0],z=b[1],x=(z-w)/(y-I),S=(I*w-y*z)/(I-y);isNaN(x)&&(Math.abs(h)===+e.toFixed(8)&&(x=h),Math.abs(p)===+e.toFixed(8)&&(x=p)),y===1/0||y===-1/0?S=I*x+z:I!==1/0&&I!==-1/0||(S=y*x+w),t.lineTo(h,d),t.quadraticCurveTo(x,S,p,m)},d=function(t,e,i,n,r,o,s){e||(e=o);var a=l(90/Math.PI/i*o),h=l(90/Math.PI/e*o),f=n+a,d=r-a,g=n+h,p=r-h;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,c(f,i)),u(t,i,f,d,!0),p>g?u(t,e,g,p,!1):t.lineTo.apply(t,c((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()},g=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.quadraticCurveTo(e+n,i,e+n,i+o),t.lineTo(e+n,i+r-o),t.quadraticCurveTo(e+n,i+r,e+n-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath(),t.fill()},p=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},m=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},v=function(t){function h(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return e(h,t),h.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},h.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return i({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return i({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},h.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(o(new Array(t.prizes.length).fill(void 0),n))}))},h.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,"WEB"===i.flag&&n.translate(this.Radius,this.Radius);var r=function(){e.draw(),e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},o=0,a=0;s(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){a++,e.loadAndCacheImg(i,n,(function(){o++,a===o&&r.call(e)}))}))}))),a||r.call(this)},h.prototype.loadAndCacheImg=function(t,e,i){return n(this,void 0,void 0,(function(){var n,o,s,a,h,l,c;return r(this,(function(r){switch(r.label){case 0:return n=t<this.prizes.length,o=n?"prizes":"buttons",s=n?"prizeImgs":"btnImgs",t=n?t:t-this.prizes.length,(a=this[o][t])&&a.imgs?(h=a.imgs[e])?(this[s][t]||(this[s][t]=[]),l=this[s][t],c=e,[4,this.loadImg(h.src,h)]):[2]:[2];case 1:return l[c]=r.sent(),i.call(this),[2]}}))}))},h.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},h.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle;0===i.flag.indexOf("UNI-")&&n.translate(this.Radius,this.Radius),n.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,i){return n.beginPath(),n.fillStyle=i.background,n.arc(0,0,e,0,2*Math.PI,!1),n.fill(),e-t.getLength(i.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=l(this.prizeDeg);var s=l(-90+this.rotateDeg+r.offsetDegree),h=function(e){return t.getOffsetX(n.measureText(e).width)},c=function(e,i,n){var r=e.lineHeight||o.lineHeight||e.fontSize||o.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(r)};n.save(),this.prizes.forEach((function(e,i){var f=s+i*t.prizeRadian,u=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){o?d(t,e,i,n,r,o,s):(t.beginPath(),t.fillStyle=s,t.moveTo(0,0),t.arc(0,0,i,n,r,!1),t.closePath(),t.fill())}(n,t.maxBtnRadius,t.prizeRadius,f-t.prizeRadian/2,f+t.prizeRadian/2,t.getLength(r.gutter),e.background||o.background);var g=Math.cos(f)*t.prizeRadius,p=Math.sin(f)*t.prizeRadius;n.translate(g,p),n.rotate(f+l(90)),e.imgs&&e.imgs.forEach((function(e,r){if(t.prizeImgs[i]){var o=t.prizeImgs[i][r];if(o){var s,a=t.computedWidthAndHeight(o,e,t.prizeRadian*t.prizeRadius,u),h=a[0],l=a[1],c=[t.getOffsetX(h),t.getHeight(e.top,u)],f=c[0],d=c[1];"WEB"===t.config.flag?s=o:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(s=o.path),n.drawImage(s,f,d,h,l)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,l=t.getLength(e.fontSize||o.fontSize),f=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+l+"px "+f;var d=[],g=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:o.wordWrap){g=a(g);for(var p="",m=0;m<g.length;m++){p+=g[m];var v=n.measureText(p).width,y=(t.prizeRadius-c(e,u,d.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(r.gutter);v>t.getWidth(e.lengthLimit||o.lengthLimit,y)&&(d.push(p.slice(0,-1)),p=g[m])}p&&d.push(p),d.length||d.push(g)}else d=g.split("\n");d.filter((function(t){return!!t})).forEach((function(t,i){n.fillText(t,h(t),c(e,u,i))}))})),n.rotate(l(360)-f-l(90)),n.translate(-g,-p)})),n.restore(),this.buttons.forEach((function(e,i){var r=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,r),n.beginPath(),n.fillStyle=e.background||"#fff",n.arc(0,0,r,0,2*Math.PI,!1),n.fill(),e.pointer&&(n.beginPath(),n.fillStyle=e.background||"#fff",n.moveTo(-r,0),n.lineTo(r,0),n.lineTo(0,2*-r),n.closePath(),n.fill()),e.imgs&&e.imgs.forEach((function(o,s){if(t.btnImgs[i]){var a=t.btnImgs[i][s];if(a){var h,l=t.computedWidthAndHeight(a,o,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=l[0],f=l[1],u=[t.getOffsetX(c),t.getHeight(o.top,r)],d=u[0],g=u[1];"WEB"===t.config.flag?h=a:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(h=a.path),n.drawImage(h,d,g,c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,a=t.getLength(e.fontSize||o.fontSize),l=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+a+"px "+l,String(e.text).split("\n").forEach((function(t,i){n.fillText(t,h(t),c(e,r,i))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},h.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},h.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},h.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,s=e._defaultConfig,a=Date.now()-this.startTime;if(a>=s.accelerationTime&&void 0!==n){this.FPS=a/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=0;++h;){var l=360*h-n*r-o-s.offsetDegree;if(m(this.FPS,this.stopDeg,l,s.decelerationTime)-this.stopDeg>s.speed){this.endDeg=l;break}}return this.slowDown()}this.rotateDeg=(o+p(a,0,s.speed,s.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))},h.prototype.slowDown=function(){var t,e=this,n=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopDeg,a=e.endDeg,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>=h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,i({},r.find((function(t,e){return e===o})))));this.rotateDeg=m(l,s,a,h.decelerationTime)%360,this.draw(),n(this.slowDown.bind(this))},h.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),s(t,"number")?t:s(t,"string")?this.changeUnits(t,e):0},h.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),s(t,"number")?t:s(t,"string")?this.changeUnits(t,e):0},h.prototype.getOffsetX=function(t){return-t/2},h}(h),y=function(t){function h(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return e(h,t),h.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},h.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=i({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return i({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return i({background:"#ffce98",shadow:""},t.activeStyle)}))},h.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},h.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,o=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){e.draw(),e.demo&&e.walk(),o&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([o.x,o.y,o.col||1,o.row||1]),s=n[0],a=n[1],h=n[2],l=n[3];r.beginPath(),r.rect(s,a,h,l),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,l=0;s(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){l++,e.loadAndCacheImg(i,n,(function(){h++,l===h&&a.call(e)}))}))}))),l||a.call(this)},h.prototype.loadAndCacheImg=function(t,e,i){return n(this,void 0,void 0,(function(){var n,o,s,a,h,l;return r(this,(function(r){switch(r.label){case 0:return(n=this.cells[t])&&n.imgs?(o=n.imgs[e],this.cellImgs[t]||(this.cellImgs[t]=[]),s=this.cellImgs[t],a=e,l={},[4,this.loadImg(o.src,o)]):[2];case 1:return s[a]=(l.defaultImg=r.sent(),l),o.hasOwnProperty("activeSrc")?[4,this.loadImg(o.activeSrc,o)]:[3,3];case 2:h=r.sent(),this.cellImgs[t][e].activeImg=h,r.label=3;case 3:return i.call(this),[2]}}))}))},h.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},h.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,h=e._defaultStyle,l=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=o(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,o=e.y,a=e.w,h=e.h,l=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,o=0;switch(e.length){case 1:i=n=r=o=e[0];break;case 2:i=n=e[0],r=o=e[1];break;case 3:i=e[0],r=o=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],o=e[3]}var a={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:o};for(var h in a)a[h]=t.hasOwnProperty(h)&&s(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[i,n,r,o]}(i).map((function(t){return~~t})),c=l[0],f=l[1],u=l[2],d=l[3],p=i.borderRadius?t.getLength(i.borderRadius):0;return g(n,r,o,a,h,p,t.handleBackground(r,o,a,h,i.background)),{x:r+u,y:o+c,w:a-u-d,h:h-c-f}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-r.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-r.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),o=r[0],s=r[1],c=r[2],f=r[3],u=i===t.currIndex%t.prizes.length>>0,d=(u?l.shadow:e.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(n.shadowColor=d[3],n.shadowOffsetX=d[0]*t.dpr,n.shadowOffsetY=d[1]*t.dpr,n.shadowBlur=d[2],d[0]>0?c-=d[0]:(c+=d[0],o-=d[0]),d[1]>0?f-=d[1]:(f+=d[1],s-=d[1])),g(n,o,s,c,f,t.getLength(e.borderRadius?e.borderRadius:h.borderRadius),t.handleBackground(o,s,c,f,e.background,u)),n.shadowColor="rgba(0, 0, 0, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,a){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][a];if(!h)return!1;var l,c=u&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),d=f[0],g=f[1],p=[o+t.getOffsetX(d,e.col),s+t.getHeight(r.top,e.row)],m=p[0],v=p[1];"WEB"===t.config.flag?l=c:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(l=c.path),n.drawImage(l,m,v,d,g)})),e.fonts&&e.fonts.forEach((function(i){var r=u&&l.fontStyle?l.fontStyle:i.fontStyle||h.fontStyle,c=u&&l.fontWeight?l.fontWeight:i.fontWeight||h.fontWeight,f=u&&l.fontSize?t.getLength(l.fontSize):t.getLength(i.fontSize||h.fontSize),d=u&&l.lineHeight?l.lineHeight:i.lineHeight||h.lineHeight||i.fontSize||h.fontSize;n.font=c+" "+f+"px "+r,n.fillStyle=u&&l.fontColor?l.fontColor:i.fontColor||h.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:h.wordWrap){p=a(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||h.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,a){n.fillText(r,o+t.getOffsetX(n.measureText(r).width,e.col),s+t.getHeight(i.top,e.row)+(a+1)*t.getLength(d))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},h.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,l=s._activeStyle;return(r=o?l.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var l=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*l(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*l(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*l(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*l(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*l(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*l(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*l(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*l(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),c)}(a,t,e,i,n,r)),r},h.prototype.play=function(){var t=this.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},h.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},h.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,s=e.startTime,a=e._defaultConfig,h=Date.now()-s;if(h>=a.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var l=0;++l;){var c=r.length*l+o-(n>>0);if(m(this.FPS,this.stopIndex,c,a.decelerationTime)-this.stopIndex>a.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+p(h,.1,a.speed,a.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))},h.prototype.slowDown=function(){var t,e=this,n=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopIndex,a=e.endIndex,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,i({},r.find((function(t,e){return e===o})))));this.currIndex=m(l,s,a,h.decelerationTime)%r.length,this.draw(),n(this.slowDown.bind(this))},h.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},h.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},h.prototype.getWidth=function(t,e){return void 0===e&&(e=1),s(t,"number")?t:s(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},h.prototype.getHeight=function(t,e){return void 0===e&&(e=1),s(t,"number")?t:s(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},h.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},h}(h);exports.LuckyGrid=y,exports.LuckyWheel=v;
var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return(i=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function n(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function r(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function o(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var s=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},a=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},h=function(){function t(t){this.global={},this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.setTimeout=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).flag||(t.flag="WEB"),0===t.flag.indexOf("UNI-")?this.global=uni:"MINI-WX"===t.flag&&(this.global=wx),t.el&&(t.divElement=document.querySelector(t.el));var e=0,i=0;t.divElement&&(e=t.divElement.offsetWidth,i=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width=this.getLength(t.width)||e,t.height=this.getLength(t.height)||i,t.divElement&&(t.divElement.style.width=t.width+"px",t.divElement.style.height=t.height+"px"),t.canvasElement&&(t.canvasElement.setAttribute("package","lucky-canvas@1.2.0"),t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height?(this.resetArrayProto(),this.initWindowFunction()):console.error("无法获取到 CanvasContext2D 或宽高")}return t.prototype.setDpr=function(){window?window.dpr=this.dpr=1.3*(window.devicePixelRatio||2):this.dpr=this.config.dpr},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){if(window)return this.rAF=window.requestAnimationFrame,this.setInterval=window.setInterval,void(this.clearInterval=window.clearInterval);if(this.config.rAF)this.rAF=this.config.rAF;else if(this.config.setTimeout){var t=this.config.setTimeout;this.rAF=function(e){return t(e,16)}}else this.rAF=function(t){return setTimeout(t,16)}},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.canvasElement,o=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&(r.width=e.width*n,r.height=e.height*n,r.style.width=r.width+"px",r.style.height=r.height+"px",r.style.transform="scale("+1/n+") translate(\n "+-o(r.width)+"%, "+-o(r.height)+"%\n )",i.scale(n,n))},t.prototype.loadImg=function(t,e){var i=this;return new Promise((function(n){if("WEB"===i.config.flag){var r=new Image;r.src=t,r.onload=function(){return n(r)}}else if(["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(i.config.flag)){if(/^data:image\/([a-z]+);base64,/.test(t))return void(e.$resolve=n);i.global.getImageInfo({src:t,success:function(t){return n(t)},fail:function(){return console.error("API `getImageInfo` 加载图片失败",t)}})}}))},t.prototype.getLength=function(t){return s(t,"number")?t:s(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?750/e.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?e.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,o([this],Array.from(arguments)))}}))},t}(),c=function(t){return Math.PI/180*t},l=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},f=function(t,e){var i=-t/e;return[i,-i*t+e]},u=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=c(180).toFixed(8)){var s=(n+i)/2;return r?(u(t,e,i,s,r),u(t,e,s,n,r)):(u(t,e,s,n,r),u(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=l(i,e),h=a[0],d=a[1],g=l(n,e),p=g[0],m=g[1],v=f(h,d),y=v[0],w=v[1],b=f(p,m),I=b[0],z=b[1],x=(z-w)/(y-I),S=(I*w-y*z)/(I-y);isNaN(x)&&(Math.abs(h)===+e.toFixed(8)&&(x=h),Math.abs(p)===+e.toFixed(8)&&(x=p)),y===1/0||y===-1/0?S=I*x+z:I!==1/0&&I!==-1/0||(S=y*x+w),t.lineTo(h,d),t.quadraticCurveTo(x,S,p,m)},d=function(t,e,i,n,r,o,s){e||(e=o);var a=c(90/Math.PI/i*o),h=c(90/Math.PI/e*o),f=n+a,d=r-a,g=n+h,p=r-h;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,l(f,i)),u(t,i,f,d,!0),p>g?u(t,e,g,p,!1):t.lineTo.apply(t,l((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()},g=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.quadraticCurveTo(e+n,i,e+n,i+o),t.lineTo(e+n,i+r-o),t.quadraticCurveTo(e+n,i+r,e+n-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath(),t.fill()},p=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},m=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},v=function(t){function h(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return e(h,t),h.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},h.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return i({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return i({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},h.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(o(new Array(t.prizes.length).fill(void 0),n))}))},h.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,"WEB"===i.flag&&n.translate(this.Radius,this.Radius);var r=function(){e.draw(),e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},o=0,a=0;s(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){a++,e.loadAndCacheImg(i,n,(function(){o++,a===o&&r.call(e)}))}))}))),a||r.call(this)},h.prototype.loadAndCacheImg=function(t,e,i){return n(this,void 0,void 0,(function(){var n,o,s,a,h,c,l;return r(this,(function(r){switch(r.label){case 0:return n=t<this.prizes.length,o=n?"prizes":"buttons",s=n?"prizeImgs":"btnImgs",t=n?t:t-this.prizes.length,(a=this[o][t])&&a.imgs?(h=a.imgs[e])?(this[s][t]||(this[s][t]=[]),c=this[s][t],l=e,[4,this.loadImg(h.src,h)]):[2]:[2];case 1:return c[l]=r.sent(),i.call(this),[2]}}))}))},h.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},h.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle;0===i.flag.indexOf("UNI-")&&n.translate(this.Radius,this.Radius),n.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,i){return n.beginPath(),n.fillStyle=i.background,n.arc(0,0,e,0,2*Math.PI,!1),n.fill(),e-t.getLength(i.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=c(this.prizeDeg);var s=c(-90+this.rotateDeg+r.offsetDegree),h=function(e){return t.getOffsetX(n.measureText(e).width)},l=function(e,i,n){var r=e.lineHeight||o.lineHeight||e.fontSize||o.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(r)};n.save(),this.prizes.forEach((function(e,i){var f=s+i*t.prizeRadian,u=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){o?d(t,e,i,n,r,o,s):(t.beginPath(),t.fillStyle=s,t.moveTo(0,0),t.arc(0,0,i,n,r,!1),t.closePath(),t.fill())}(n,t.maxBtnRadius,t.prizeRadius,f-t.prizeRadian/2,f+t.prizeRadian/2,t.getLength(r.gutter),e.background||o.background);var g=Math.cos(f)*t.prizeRadius,p=Math.sin(f)*t.prizeRadius;n.translate(g,p),n.rotate(f+c(90)),e.imgs&&e.imgs.forEach((function(e,r){if(t.prizeImgs[i]){var o=t.prizeImgs[i][r];if(o){var s,a=t.computedWidthAndHeight(o,e,t.prizeRadian*t.prizeRadius,u),h=a[0],c=a[1],l=[t.getOffsetX(h),t.getHeight(e.top,u)],f=l[0],d=l[1];"WEB"===t.config.flag?s=o:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(s=o.path),n.drawImage(s,f,d,h,c)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,c=t.getLength(e.fontSize||o.fontSize),f=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+c+"px "+f;var d=[],g=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:o.wordWrap){g=a(g);for(var p="",m=0;m<g.length;m++){p+=g[m];var v=n.measureText(p).width,y=(t.prizeRadius-l(e,u,d.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(r.gutter);v>t.getWidth(e.lengthLimit||o.lengthLimit,y)&&(d.push(p.slice(0,-1)),p=g[m])}p&&d.push(p),d.length||d.push(g)}else d=g.split("\n");d.filter((function(t){return!!t})).forEach((function(t,i){n.fillText(t,h(t),l(e,u,i))}))})),n.rotate(c(360)-f-c(90)),n.translate(-g,-p)})),n.restore(),this.buttons.forEach((function(e,i){var r=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,r),n.beginPath(),n.fillStyle=e.background||"#fff",n.arc(0,0,r,0,2*Math.PI,!1),n.fill(),e.pointer&&(n.beginPath(),n.fillStyle=e.background||"#fff",n.moveTo(-r,0),n.lineTo(r,0),n.lineTo(0,2*-r),n.closePath(),n.fill()),e.imgs&&e.imgs.forEach((function(o,s){if(t.btnImgs[i]){var a=t.btnImgs[i][s];if(a){var h,c=t.computedWidthAndHeight(a,o,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),l=c[0],f=c[1],u=[t.getOffsetX(l),t.getHeight(o.top,r)],d=u[0],g=u[1];"WEB"===t.config.flag?h=a:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(h=a.path),n.drawImage(h,d,g,l,f)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,a=t.getLength(e.fontSize||o.fontSize),c=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+a+"px "+c,String(e.text).split("\n").forEach((function(t,i){n.fillText(t,h(t),l(e,r,i))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},h.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},h.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},h.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,s=e._defaultConfig,a=Date.now()-this.startTime;if(a>=s.accelerationTime&&void 0!==n){this.FPS=a/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=0;++h;){var c=360*h-n*r-o-s.offsetDegree;if(m(this.FPS,this.stopDeg,c,s.decelerationTime)-this.stopDeg>s.speed){this.endDeg=c;break}}return this.slowDown()}this.rotateDeg=(o+p(a,0,s.speed,s.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))},h.prototype.slowDown=function(){var t,e=this,n=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopDeg,a=e.endDeg,h=e._defaultConfig,c=Date.now()-this.endTime;if(c>=h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,i({},r.find((function(t,e){return e===o})))));this.rotateDeg=m(c,s,a,h.decelerationTime)%360,this.draw(),n(this.slowDown.bind(this))},h.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),s(t,"number")?t:s(t,"string")?this.changeUnits(t,e):0},h.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),s(t,"number")?t:s(t,"string")?this.changeUnits(t,e):0},h.prototype.getOffsetX=function(t){return-t/2},h}(h),y=function(t){function h(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return e(h,t),h.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},h.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=i({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return i({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return i({background:"#ffce98",shadow:""},t.activeStyle)}))},h.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},h.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,o=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){e.draw(),e.demo&&e.walk(),o&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([o.x,o.y,o.col||1,o.row||1]),s=n[0],a=n[1],h=n[2],c=n[3];r.beginPath(),r.rect(s,a,h,c),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,c=0;s(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){c++,e.loadAndCacheImg(i,n,(function(){h++,c===h&&a.call(e)}))}))}))),c||a.call(this)},h.prototype.loadAndCacheImg=function(t,e,i){return n(this,void 0,void 0,(function(){var n,o,s,a,h,c;return r(this,(function(r){switch(r.label){case 0:return(n=this.cells[t])&&n.imgs?(o=n.imgs[e],this.cellImgs[t]||(this.cellImgs[t]=[]),s=this.cellImgs[t],a=e,c={},[4,this.loadImg(o.src,o)]):[2];case 1:return s[a]=(c.defaultImg=r.sent(),c),o.hasOwnProperty("activeSrc")?[4,this.loadImg(o.activeSrc,o)]:[3,3];case 2:h=r.sent(),this.cellImgs[t][e].activeImg=h,r.label=3;case 3:return i.call(this),[2]}}))}))},h.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},h.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,h=e._defaultStyle,c=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=o(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,o=e.y,a=e.w,h=e.h,c=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,o=0;switch(e.length){case 1:i=n=r=o=e[0];break;case 2:i=n=e[0],r=o=e[1];break;case 3:i=e[0],r=o=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],o=e[3]}var a={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:o};for(var h in a)a[h]=t.hasOwnProperty(h)&&s(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[i,n,r,o]}(i).map((function(t){return~~t})),l=c[0],f=c[1],u=c[2],d=c[3],p=i.borderRadius?t.getLength(i.borderRadius):0;return g(n,r,o,a,h,p,t.handleBackground(r,o,a,h,i.background)),{x:r+u,y:o+l,w:a-u-d,h:h-l-f}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-r.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-r.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),o=r[0],s=r[1],l=r[2],f=r[3],u=i===t.currIndex%t.prizes.length>>0,d=(u?c.shadow:e.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(n.shadowColor=d[3],n.shadowOffsetX=d[0]*t.dpr,n.shadowOffsetY=d[1]*t.dpr,n.shadowBlur=d[2],d[0]>0?l-=d[0]:(l+=d[0],o-=d[0]),d[1]>0?f-=d[1]:(f+=d[1],s-=d[1])),g(n,o,s,l,f,t.getLength(e.borderRadius?e.borderRadius:h.borderRadius),t.handleBackground(o,s,l,f,e.background,u)),n.shadowColor="rgba(0, 0, 0, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,a){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][a];if(!h)return!1;var c,l=u&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(l,r,e),d=f[0],g=f[1],p=[o+t.getOffsetX(d,e.col),s+t.getHeight(r.top,e.row)],m=p[0],v=p[1];"WEB"===t.config.flag?c=l:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(c=l.path),n.drawImage(c,m,v,d,g)})),e.fonts&&e.fonts.forEach((function(i){var r=u&&c.fontStyle?c.fontStyle:i.fontStyle||h.fontStyle,l=u&&c.fontWeight?c.fontWeight:i.fontWeight||h.fontWeight,f=u&&c.fontSize?t.getLength(c.fontSize):t.getLength(i.fontSize||h.fontSize),d=u&&c.lineHeight?c.lineHeight:i.lineHeight||h.lineHeight||i.fontSize||h.fontSize;n.font=l+" "+f+"px "+r,n.fillStyle=u&&c.fontColor?c.fontColor:i.fontColor||h.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:h.wordWrap){p=a(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||h.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,a){n.fillText(r,o+t.getOffsetX(n.measureText(r).width,e.col),s+t.getHeight(i.top,e.row)+(a+1)*t.getLength(d))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},h.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,c=s._activeStyle;return(r=o?c.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var l=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),l)}(a,t,e,i,n,r)),r},h.prototype.play=function(){var t=this.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},h.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},h.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,s=e.startTime,a=e._defaultConfig,h=Date.now()-s;if(h>=a.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var c=0;++c;){var l=r.length*c+o-(n>>0);if(m(this.FPS,this.stopIndex,l,a.decelerationTime)-this.stopIndex>a.speed){this.endIndex=l;break}}return this.slowDown()}this.currIndex=(n+p(h,.1,a.speed,a.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))},h.prototype.slowDown=function(){var t,e=this,n=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopIndex,a=e.endIndex,h=e._defaultConfig,c=Date.now()-this.endTime;if(c>h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,i({},r.find((function(t,e){return e===o})))));this.currIndex=m(c,s,a,h.decelerationTime)%r.length,this.draw(),n(this.slowDown.bind(this))},h.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},h.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},h.prototype.getWidth=function(t,e){return void 0===e&&(e=1),s(t,"number")?t:s(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},h.prototype.getHeight=function(t,e){return void 0===e&&(e=1),s(t,"number")?t:s(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},h.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},h}(h);exports.LuckyGrid=y,exports.LuckyWheel=v;

@@ -15,2 +15,2 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LuckyCanvas={})}(this,(function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function o(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function s(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var a=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},h=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},l=function(){function t(t){this.global={},this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.setTimeout=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).flag||(t.flag="WEB"),0===t.flag.indexOf("UNI-")?this.global=uni:"MINI-WX"===t.flag&&(this.global=wx),t.el&&(t.divElement=document.querySelector(t.el));var e=0,i=0;t.divElement&&(e=t.divElement.offsetWidth,i=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width=this.getLength(t.width)||e,t.height=this.getLength(t.height)||i,t.divElement&&(t.divElement.style.width=t.width+"px",t.divElement.style.height=t.height+"px"),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height&&(this.resetArrayProto(),this.initWindowFunction())}return t.prototype.setDpr=function(){window?window.dpr=this.dpr=1.3*(window.devicePixelRatio||2):this.dpr=this.config.dpr},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){if(window)return this.rAF=window.requestAnimationFrame,this.setInterval=window.setInterval,void(this.clearInterval=window.clearInterval);if(this.config.rAF)this.rAF=this.config.rAF;else if(this.config.setTimeout){var t=this.config.setTimeout;this.rAF=function(e){return t(e,16)}}else this.rAF=function(t){return setTimeout(t,16)}},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.canvasElement,o=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&(r.width=e.width*n,r.height=e.height*n,r.style.width=r.width+"px",r.style.height=r.height+"px",r.style.transform="scale("+1/n+") translate(\n "+-o(r.width)+"%, "+-o(r.height)+"%\n )",i.scale(n,n))},t.prototype.loadImg=function(t,e){var i=this;return new Promise((function(n){if("WEB"===i.config.flag){var r=new Image;r.src=t,r.onload=function(){return n(r)}}else if(["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(i.config.flag)){if(/^data:image\/([a-z]+);base64,/.test(t))return void(e.$resolve=n);i.global.getImageInfo({src:t,success:function(t){return n(t)},fail:function(){return console.error("API `getImageInfo` 加载图片失败",t)}})}}))},t.prototype.getLength=function(t){return a(t,"number")?t:a(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?750/e.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?e.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,s([this],Array.from(arguments)))}}))},t}(),c=function(t){return Math.PI/180*t},f=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},u=function(t,e){var i=-t/e;return[i,-i*t+e]},d=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=c(180).toFixed(8)){var s=(n+i)/2;return r?(d(t,e,i,s,r),d(t,e,s,n,r)):(d(t,e,s,n,r),d(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=f(i,e),h=a[0],l=a[1],g=f(n,e),p=g[0],m=g[1],v=u(h,l),y=v[0],w=v[1],b=u(p,m),I=b[0],z=b[1],x=(z-w)/(y-I),S=(I*w-y*z)/(I-y);isNaN(x)&&(Math.abs(h)===+e.toFixed(8)&&(x=h),Math.abs(p)===+e.toFixed(8)&&(x=p)),y===1/0||y===-1/0?S=I*x+z:I!==1/0&&I!==-1/0||(S=y*x+w),t.lineTo(h,l),t.quadraticCurveTo(x,S,p,m)},g=function(t,e,i,n,r,o,s){e||(e=o);var a=c(90/Math.PI/i*o),h=c(90/Math.PI/e*o),l=n+a,u=r-a,g=n+h,p=r-h;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,f(l,i)),d(t,i,l,u,!0),p>g?d(t,e,g,p,!1):t.lineTo.apply(t,f((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()},p=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.quadraticCurveTo(e+n,i,e+n,i+o),t.lineTo(e+n,i+r-o),t.quadraticCurveTo(e+n,i+r,e+n-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath(),t.fill()},m=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},v=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},y=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(s(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,"WEB"===i.flag&&n.translate(this.Radius,this.Radius);var r=function(){e.draw(),e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},o=0,s=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){s++,e.loadAndCacheImg(i,n,(function(){o++,s===o&&r.call(e)}))}))}))),s||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l,c;return o(this,(function(o){switch(o.label){case 0:return n=t<this.prizes.length,r=n?"prizes":"buttons",s=n?"prizeImgs":"btnImgs",t=n?t:t-this.prizes.length,(a=this[r][t])&&a.imgs?(h=a.imgs[e])?(this[s][t]||(this[s][t]=[]),l=this[s][t],c=e,[4,this.loadImg(h.src,h)]):[2]:[2];case 1:return l[c]=o.sent(),i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle;0===i.flag.indexOf("UNI-")&&n.translate(this.Radius,this.Radius),n.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,i){return n.beginPath(),n.fillStyle=i.background,n.arc(0,0,e,0,2*Math.PI,!1),n.fill(),e-t.getLength(i.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=c(this.prizeDeg);var s=c(-90+this.rotateDeg+r.offsetDegree),a=function(e){return t.getOffsetX(n.measureText(e).width)},l=function(e,i,n){var r=e.lineHeight||o.lineHeight||e.fontSize||o.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(r)};n.save(),this.prizes.forEach((function(e,i){var f=s+i*t.prizeRadian,u=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){o?g(t,e,i,n,r,o,s):(t.beginPath(),t.fillStyle=s,t.moveTo(0,0),t.arc(0,0,i,n,r,!1),t.closePath(),t.fill())}(n,t.maxBtnRadius,t.prizeRadius,f-t.prizeRadian/2,f+t.prizeRadian/2,t.getLength(r.gutter),e.background||o.background);var d=Math.cos(f)*t.prizeRadius,p=Math.sin(f)*t.prizeRadius;n.translate(d,p),n.rotate(f+c(90)),e.imgs&&e.imgs.forEach((function(e,r){if(t.prizeImgs[i]){var o=t.prizeImgs[i][r];if(o){var s,a=t.computedWidthAndHeight(o,e,t.prizeRadian*t.prizeRadius,u),h=a[0],l=a[1],c=[t.getOffsetX(h),t.getHeight(e.top,u)],f=c[0],d=c[1];"WEB"===t.config.flag?s=o:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(s=o.path),n.drawImage(s,f,d,h,l)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,c=t.getLength(e.fontSize||o.fontSize),f=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+c+"px "+f;var d=[],g=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:o.wordWrap){g=h(g);for(var p="",m=0;m<g.length;m++){p+=g[m];var v=n.measureText(p).width,y=(t.prizeRadius-l(e,u,d.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(r.gutter);v>t.getWidth(e.lengthLimit||o.lengthLimit,y)&&(d.push(p.slice(0,-1)),p=g[m])}p&&d.push(p),d.length||d.push(g)}else d=g.split("\n");d.filter((function(t){return!!t})).forEach((function(t,i){n.fillText(t,a(t),l(e,u,i))}))})),n.rotate(c(360)-f-c(90)),n.translate(-d,-p)})),n.restore(),this.buttons.forEach((function(e,i){var r=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,r),n.beginPath(),n.fillStyle=e.background||"#fff",n.arc(0,0,r,0,2*Math.PI,!1),n.fill(),e.pointer&&(n.beginPath(),n.fillStyle=e.background||"#fff",n.moveTo(-r,0),n.lineTo(r,0),n.lineTo(0,2*-r),n.closePath(),n.fill()),e.imgs&&e.imgs.forEach((function(o,s){if(t.btnImgs[i]){var a=t.btnImgs[i][s];if(a){var h,l=t.computedWidthAndHeight(a,o,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=l[0],f=l[1],u=[t.getOffsetX(c),t.getHeight(o.top,r)],d=u[0],g=u[1];"WEB"===t.config.flag?h=a:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(h=a.path),n.drawImage(h,d,g,c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,h=t.getLength(e.fontSize||o.fontSize),c=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,i){n.fillText(t,a(t),l(e,r,i))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,s=e._defaultConfig,a=Date.now()-this.startTime;if(a>=s.accelerationTime&&void 0!==n){this.FPS=a/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=0;++h;){var l=360*h-n*r-o-s.offsetDegree;if(v(this.FPS,this.stopDeg,l,s.decelerationTime)-this.stopDeg>s.speed){this.endDeg=l;break}}return this.slowDown()}this.rotateDeg=(o+m(a,0,s.speed,s.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopDeg,a=e.endDeg,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>=h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.rotateDeg=v(l,s,a,h.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(l),w=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,o=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var s=function(){e.draw(),e.demo&&e.walk(),o&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([o.x,o.y,o.col||1,o.row||1]),s=n[0],a=n[1],h=n[2],l=n[3];r.beginPath(),r.rect(s,a,h,l),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,l=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){l++,e.loadAndCacheImg(i,n,(function(){h++,l===h&&s.call(e)}))}))}))),l||s.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l;return o(this,(function(o){switch(o.label){case 0:return(n=this.cells[t])&&n.imgs?(r=n.imgs[e],this.cellImgs[t]||(this.cellImgs[t]=[]),s=this.cellImgs[t],a=e,l={},[4,this.loadImg(r.src,r)]):[2];case 1:return s[a]=(l.defaultImg=o.sent(),l),r.hasOwnProperty("activeSrc")?[4,this.loadImg(r.activeSrc,r)]:[3,3];case 2:h=o.sent(),this.cellImgs[t][e].activeImg=h,o.label=3;case 3:return i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle,l=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=s(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,o=e.y,s=e.w,h=e.h,l=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,o=0;switch(e.length){case 1:i=n=r=o=e[0];break;case 2:i=n=e[0],r=o=e[1];break;case 3:i=e[0],r=o=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],o=e[3]}var s={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:o};for(var h in s)s[h]=t.hasOwnProperty(h)&&a(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):s[h];return[i,n,r,o]}(i).map((function(t){return~~t})),c=l[0],f=l[1],u=l[2],d=l[3],g=i.borderRadius?t.getLength(i.borderRadius):0;return p(n,r,o,s,h,g,t.handleBackground(r,o,s,h,i.background)),{x:r+u,y:o+c,w:s-u-d,h:h-c-f}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-r.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-r.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),s=r[0],a=r[1],c=r[2],f=r[3],u=i===t.currIndex%t.prizes.length>>0,d=(u?l.shadow:e.shadow||o.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(n.shadowColor=d[3],n.shadowOffsetX=d[0]*t.dpr,n.shadowOffsetY=d[1]*t.dpr,n.shadowBlur=d[2],d[0]>0?c-=d[0]:(c+=d[0],s-=d[0]),d[1]>0?f-=d[1]:(f+=d[1],a-=d[1])),p(n,s,a,c,f,t.getLength(e.borderRadius?e.borderRadius:o.borderRadius),t.handleBackground(s,a,c,f,e.background,u)),n.shadowColor="rgba(0, 0, 0, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,o){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][o];if(!h)return!1;var l,c=u&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),d=f[0],g=f[1],p=[s+t.getOffsetX(d,e.col),a+t.getHeight(r.top,e.row)],m=p[0],v=p[1];"WEB"===t.config.flag?l=c:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(l=c.path),n.drawImage(l,m,v,d,g)})),e.fonts&&e.fonts.forEach((function(i){var r=u&&l.fontStyle?l.fontStyle:i.fontStyle||o.fontStyle,c=u&&l.fontWeight?l.fontWeight:i.fontWeight||o.fontWeight,f=u&&l.fontSize?t.getLength(l.fontSize):t.getLength(i.fontSize||o.fontSize),d=u&&l.lineHeight?l.lineHeight:i.lineHeight||o.lineHeight||i.fontSize||o.fontSize;n.font=c+" "+f+"px "+r,n.fillStyle=u&&l.fontColor?l.fontColor:i.fontColor||o.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:o.wordWrap){p=h(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||o.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,o){n.fillText(r,s+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(o+1)*t.getLength(d))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,l=s._activeStyle;return(r=o?l.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var l=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*l(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*l(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*l(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*l(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*l(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*l(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*l(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*l(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),c)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,s=e.startTime,a=e._defaultConfig,h=Date.now()-s;if(h>=a.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var l=0;++l;){var c=r.length*l+o-(n>>0);if(v(this.FPS,this.stopIndex,c,a.decelerationTime)-this.stopIndex>a.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+m(h,.1,a.speed,a.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopIndex,a=e.endIndex,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.currIndex=v(l,s,a,h.decelerationTime)%r.length,this.draw(),i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(l);t.LuckyGrid=w,t.LuckyWheel=y,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function o(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function s(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var a=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},h=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},l=function(){function t(t){this.global={},this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.setTimeout=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).flag||(t.flag="WEB"),0===t.flag.indexOf("UNI-")?this.global=uni:"MINI-WX"===t.flag&&(this.global=wx),t.el&&(t.divElement=document.querySelector(t.el));var e=0,i=0;t.divElement&&(e=t.divElement.offsetWidth,i=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width=this.getLength(t.width)||e,t.height=this.getLength(t.height)||i,t.divElement&&(t.divElement.style.width=t.width+"px",t.divElement.style.height=t.height+"px"),t.canvasElement&&(t.canvasElement.setAttribute("package","lucky-canvas@1.2.0"),t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height?(this.resetArrayProto(),this.initWindowFunction()):console.error("无法获取到 CanvasContext2D 或宽高")}return t.prototype.setDpr=function(){window?window.dpr=this.dpr=1.3*(window.devicePixelRatio||2):this.dpr=this.config.dpr},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){if(window)return this.rAF=window.requestAnimationFrame,this.setInterval=window.setInterval,void(this.clearInterval=window.clearInterval);if(this.config.rAF)this.rAF=this.config.rAF;else if(this.config.setTimeout){var t=this.config.setTimeout;this.rAF=function(e){return t(e,16)}}else this.rAF=function(t){return setTimeout(t,16)}},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.canvasElement,o=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&(r.width=e.width*n,r.height=e.height*n,r.style.width=r.width+"px",r.style.height=r.height+"px",r.style.transform="scale("+1/n+") translate(\n "+-o(r.width)+"%, "+-o(r.height)+"%\n )",i.scale(n,n))},t.prototype.loadImg=function(t,e){var i=this;return new Promise((function(n){if("WEB"===i.config.flag){var r=new Image;r.src=t,r.onload=function(){return n(r)}}else if(["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(i.config.flag)){if(/^data:image\/([a-z]+);base64,/.test(t))return void(e.$resolve=n);i.global.getImageInfo({src:t,success:function(t){return n(t)},fail:function(){return console.error("API `getImageInfo` 加载图片失败",t)}})}}))},t.prototype.getLength=function(t){return a(t,"number")?t:a(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?750/e.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?e.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,s([this],Array.from(arguments)))}}))},t}(),c=function(t){return Math.PI/180*t},f=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},u=function(t,e){var i=-t/e;return[i,-i*t+e]},d=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=c(180).toFixed(8)){var s=(n+i)/2;return r?(d(t,e,i,s,r),d(t,e,s,n,r)):(d(t,e,s,n,r),d(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=f(i,e),h=a[0],l=a[1],g=f(n,e),p=g[0],m=g[1],v=u(h,l),y=v[0],w=v[1],b=u(p,m),I=b[0],z=b[1],x=(z-w)/(y-I),S=(I*w-y*z)/(I-y);isNaN(x)&&(Math.abs(h)===+e.toFixed(8)&&(x=h),Math.abs(p)===+e.toFixed(8)&&(x=p)),y===1/0||y===-1/0?S=I*x+z:I!==1/0&&I!==-1/0||(S=y*x+w),t.lineTo(h,l),t.quadraticCurveTo(x,S,p,m)},g=function(t,e,i,n,r,o,s){e||(e=o);var a=c(90/Math.PI/i*o),h=c(90/Math.PI/e*o),l=n+a,u=r-a,g=n+h,p=r-h;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,f(l,i)),d(t,i,l,u,!0),p>g?d(t,e,g,p,!1):t.lineTo.apply(t,f((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()},p=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.quadraticCurveTo(e+n,i,e+n,i+o),t.lineTo(e+n,i+r-o),t.quadraticCurveTo(e+n,i+r,e+n-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath(),t.fill()},m=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},v=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},y=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(s(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,"WEB"===i.flag&&n.translate(this.Radius,this.Radius);var r=function(){e.draw(),e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},o=0,s=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){s++,e.loadAndCacheImg(i,n,(function(){o++,s===o&&r.call(e)}))}))}))),s||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l,c;return o(this,(function(o){switch(o.label){case 0:return n=t<this.prizes.length,r=n?"prizes":"buttons",s=n?"prizeImgs":"btnImgs",t=n?t:t-this.prizes.length,(a=this[r][t])&&a.imgs?(h=a.imgs[e])?(this[s][t]||(this[s][t]=[]),l=this[s][t],c=e,[4,this.loadImg(h.src,h)]):[2]:[2];case 1:return l[c]=o.sent(),i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle;0===i.flag.indexOf("UNI-")&&n.translate(this.Radius,this.Radius),n.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,i){return n.beginPath(),n.fillStyle=i.background,n.arc(0,0,e,0,2*Math.PI,!1),n.fill(),e-t.getLength(i.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=c(this.prizeDeg);var s=c(-90+this.rotateDeg+r.offsetDegree),a=function(e){return t.getOffsetX(n.measureText(e).width)},l=function(e,i,n){var r=e.lineHeight||o.lineHeight||e.fontSize||o.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(r)};n.save(),this.prizes.forEach((function(e,i){var f=s+i*t.prizeRadian,u=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){o?g(t,e,i,n,r,o,s):(t.beginPath(),t.fillStyle=s,t.moveTo(0,0),t.arc(0,0,i,n,r,!1),t.closePath(),t.fill())}(n,t.maxBtnRadius,t.prizeRadius,f-t.prizeRadian/2,f+t.prizeRadian/2,t.getLength(r.gutter),e.background||o.background);var d=Math.cos(f)*t.prizeRadius,p=Math.sin(f)*t.prizeRadius;n.translate(d,p),n.rotate(f+c(90)),e.imgs&&e.imgs.forEach((function(e,r){if(t.prizeImgs[i]){var o=t.prizeImgs[i][r];if(o){var s,a=t.computedWidthAndHeight(o,e,t.prizeRadian*t.prizeRadius,u),h=a[0],l=a[1],c=[t.getOffsetX(h),t.getHeight(e.top,u)],f=c[0],d=c[1];"WEB"===t.config.flag?s=o:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(s=o.path),n.drawImage(s,f,d,h,l)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,c=t.getLength(e.fontSize||o.fontSize),f=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+c+"px "+f;var d=[],g=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:o.wordWrap){g=h(g);for(var p="",m=0;m<g.length;m++){p+=g[m];var v=n.measureText(p).width,y=(t.prizeRadius-l(e,u,d.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(r.gutter);v>t.getWidth(e.lengthLimit||o.lengthLimit,y)&&(d.push(p.slice(0,-1)),p=g[m])}p&&d.push(p),d.length||d.push(g)}else d=g.split("\n");d.filter((function(t){return!!t})).forEach((function(t,i){n.fillText(t,a(t),l(e,u,i))}))})),n.rotate(c(360)-f-c(90)),n.translate(-d,-p)})),n.restore(),this.buttons.forEach((function(e,i){var r=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,r),n.beginPath(),n.fillStyle=e.background||"#fff",n.arc(0,0,r,0,2*Math.PI,!1),n.fill(),e.pointer&&(n.beginPath(),n.fillStyle=e.background||"#fff",n.moveTo(-r,0),n.lineTo(r,0),n.lineTo(0,2*-r),n.closePath(),n.fill()),e.imgs&&e.imgs.forEach((function(o,s){if(t.btnImgs[i]){var a=t.btnImgs[i][s];if(a){var h,l=t.computedWidthAndHeight(a,o,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=l[0],f=l[1],u=[t.getOffsetX(c),t.getHeight(o.top,r)],d=u[0],g=u[1];"WEB"===t.config.flag?h=a:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(h=a.path),n.drawImage(h,d,g,c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,h=t.getLength(e.fontSize||o.fontSize),c=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,i){n.fillText(t,a(t),l(e,r,i))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,s=e._defaultConfig,a=Date.now()-this.startTime;if(a>=s.accelerationTime&&void 0!==n){this.FPS=a/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=0;++h;){var l=360*h-n*r-o-s.offsetDegree;if(v(this.FPS,this.stopDeg,l,s.decelerationTime)-this.stopDeg>s.speed){this.endDeg=l;break}}return this.slowDown()}this.rotateDeg=(o+m(a,0,s.speed,s.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopDeg,a=e.endDeg,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>=h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.rotateDeg=v(l,s,a,h.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(l),w=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,o=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var s=function(){e.draw(),e.demo&&e.walk(),o&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([o.x,o.y,o.col||1,o.row||1]),s=n[0],a=n[1],h=n[2],l=n[3];r.beginPath(),r.rect(s,a,h,l),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,l=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){l++,e.loadAndCacheImg(i,n,(function(){h++,l===h&&s.call(e)}))}))}))),l||s.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l;return o(this,(function(o){switch(o.label){case 0:return(n=this.cells[t])&&n.imgs?(r=n.imgs[e],this.cellImgs[t]||(this.cellImgs[t]=[]),s=this.cellImgs[t],a=e,l={},[4,this.loadImg(r.src,r)]):[2];case 1:return s[a]=(l.defaultImg=o.sent(),l),r.hasOwnProperty("activeSrc")?[4,this.loadImg(r.activeSrc,r)]:[3,3];case 2:h=o.sent(),this.cellImgs[t][e].activeImg=h,o.label=3;case 3:return i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle,l=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=s(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,o=e.y,s=e.w,h=e.h,l=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,o=0;switch(e.length){case 1:i=n=r=o=e[0];break;case 2:i=n=e[0],r=o=e[1];break;case 3:i=e[0],r=o=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],o=e[3]}var s={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:o};for(var h in s)s[h]=t.hasOwnProperty(h)&&a(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):s[h];return[i,n,r,o]}(i).map((function(t){return~~t})),c=l[0],f=l[1],u=l[2],d=l[3],g=i.borderRadius?t.getLength(i.borderRadius):0;return p(n,r,o,s,h,g,t.handleBackground(r,o,s,h,i.background)),{x:r+u,y:o+c,w:s-u-d,h:h-c-f}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-r.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-r.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),s=r[0],a=r[1],c=r[2],f=r[3],u=i===t.currIndex%t.prizes.length>>0,d=(u?l.shadow:e.shadow||o.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(n.shadowColor=d[3],n.shadowOffsetX=d[0]*t.dpr,n.shadowOffsetY=d[1]*t.dpr,n.shadowBlur=d[2],d[0]>0?c-=d[0]:(c+=d[0],s-=d[0]),d[1]>0?f-=d[1]:(f+=d[1],a-=d[1])),p(n,s,a,c,f,t.getLength(e.borderRadius?e.borderRadius:o.borderRadius),t.handleBackground(s,a,c,f,e.background,u)),n.shadowColor="rgba(0, 0, 0, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,o){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][o];if(!h)return!1;var l,c=u&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),d=f[0],g=f[1],p=[s+t.getOffsetX(d,e.col),a+t.getHeight(r.top,e.row)],m=p[0],v=p[1];"WEB"===t.config.flag?l=c:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(l=c.path),n.drawImage(l,m,v,d,g)})),e.fonts&&e.fonts.forEach((function(i){var r=u&&l.fontStyle?l.fontStyle:i.fontStyle||o.fontStyle,c=u&&l.fontWeight?l.fontWeight:i.fontWeight||o.fontWeight,f=u&&l.fontSize?t.getLength(l.fontSize):t.getLength(i.fontSize||o.fontSize),d=u&&l.lineHeight?l.lineHeight:i.lineHeight||o.lineHeight||i.fontSize||o.fontSize;n.font=c+" "+f+"px "+r,n.fillStyle=u&&l.fontColor?l.fontColor:i.fontColor||o.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:o.wordWrap){p=h(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||o.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,o){n.fillText(r,s+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(o+1)*t.getLength(d))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,l=s._activeStyle;return(r=o?l.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var l=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*l(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*l(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*l(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*l(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*l(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*l(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*l(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*l(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),c)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,s=e.startTime,a=e._defaultConfig,h=Date.now()-s;if(h>=a.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var l=0;++l;){var c=r.length*l+o-(n>>0);if(v(this.FPS,this.stopIndex,c,a.decelerationTime)-this.stopIndex>a.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+m(h,.1,a.speed,a.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopIndex,a=e.endIndex,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.currIndex=v(l,s,a,h.decelerationTime)%r.length,this.draw(),i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(l);t.LuckyGrid=w,t.LuckyWheel=y,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "lucky-canvas",
"version": "1.1.8",
"version": "1.2.0",
"description": "一个基于原生 js 的(大转盘抽奖 / 九宫格抽奖)插件",

@@ -11,2 +11,3 @@ "main": "index.js",

"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^10.0.0",

@@ -28,7 +29,21 @@ "@rollup/plugin-typescript": "^6.1.0",

},
"keywords": ["vue3抽奖", "大转盘抽奖", "九宫格抽奖", "抽奖插件", "js抽奖", "移动端抽奖", "canvas抽奖"],
"keywords": [
"vue3抽奖",
"大转盘抽奖",
"九宫格抽奖",
"抽奖插件",
"js抽奖",
"移动端抽奖",
"canvas抽奖"
],
"author": "ldq <ldq404@qq.com>",
"license": "BSD-3-Clause",
"files": ["package.json", "LICENSE", "dist", "index.js", "umd.min.js"],
"files": [
"package.json",
"LICENSE",
"dist",
"index.js",
"umd.min.js"
],
"homepage": "https://100px.net"
}

@@ -15,2 +15,2 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LuckyCanvas={})}(this,(function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function o(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function s(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var a=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},h=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},l=function(){function t(t){this.global={},this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.setTimeout=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).flag||(t.flag="WEB"),0===t.flag.indexOf("UNI-")?this.global=uni:"MINI-WX"===t.flag&&(this.global=wx),t.el&&(t.divElement=document.querySelector(t.el));var e=0,i=0;t.divElement&&(e=t.divElement.offsetWidth,i=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width=this.getLength(t.width)||e,t.height=this.getLength(t.height)||i,t.divElement&&(t.divElement.style.width=t.width+"px",t.divElement.style.height=t.height+"px"),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height&&(this.resetArrayProto(),this.initWindowFunction())}return t.prototype.setDpr=function(){window?window.dpr=this.dpr=1.3*(window.devicePixelRatio||2):this.dpr=this.config.dpr},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){if(window)return this.rAF=window.requestAnimationFrame,this.setInterval=window.setInterval,void(this.clearInterval=window.clearInterval);if(this.config.rAF)this.rAF=this.config.rAF;else if(this.config.setTimeout){var t=this.config.setTimeout;this.rAF=function(e){return t(e,16)}}else this.rAF=function(t){return setTimeout(t,16)}},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.canvasElement,o=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&(r.width=e.width*n,r.height=e.height*n,r.style.width=r.width+"px",r.style.height=r.height+"px",r.style.transform="scale("+1/n+") translate(\n "+-o(r.width)+"%, "+-o(r.height)+"%\n )",i.scale(n,n))},t.prototype.loadImg=function(t,e){var i=this;return new Promise((function(n){if("WEB"===i.config.flag){var r=new Image;r.src=t,r.onload=function(){return n(r)}}else if(["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(i.config.flag)){if(/^data:image\/([a-z]+);base64,/.test(t))return void(e.$resolve=n);i.global.getImageInfo({src:t,success:function(t){return n(t)},fail:function(){return console.error("API `getImageInfo` 加载图片失败",t)}})}}))},t.prototype.getLength=function(t){return a(t,"number")?t:a(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?750/e.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?e.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,s([this],Array.from(arguments)))}}))},t}(),c=function(t){return Math.PI/180*t},f=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},u=function(t,e){var i=-t/e;return[i,-i*t+e]},d=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=c(180).toFixed(8)){var s=(n+i)/2;return r?(d(t,e,i,s,r),d(t,e,s,n,r)):(d(t,e,s,n,r),d(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=f(i,e),h=a[0],l=a[1],g=f(n,e),p=g[0],m=g[1],v=u(h,l),y=v[0],w=v[1],b=u(p,m),I=b[0],z=b[1],x=(z-w)/(y-I),S=(I*w-y*z)/(I-y);isNaN(x)&&(Math.abs(h)===+e.toFixed(8)&&(x=h),Math.abs(p)===+e.toFixed(8)&&(x=p)),y===1/0||y===-1/0?S=I*x+z:I!==1/0&&I!==-1/0||(S=y*x+w),t.lineTo(h,l),t.quadraticCurveTo(x,S,p,m)},g=function(t,e,i,n,r,o,s){e||(e=o);var a=c(90/Math.PI/i*o),h=c(90/Math.PI/e*o),l=n+a,u=r-a,g=n+h,p=r-h;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,f(l,i)),d(t,i,l,u,!0),p>g?d(t,e,g,p,!1):t.lineTo.apply(t,f((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()},p=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.quadraticCurveTo(e+n,i,e+n,i+o),t.lineTo(e+n,i+r-o),t.quadraticCurveTo(e+n,i+r,e+n-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath(),t.fill()},m=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},v=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},y=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(s(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,"WEB"===i.flag&&n.translate(this.Radius,this.Radius);var r=function(){e.draw(),e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},o=0,s=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){s++,e.loadAndCacheImg(i,n,(function(){o++,s===o&&r.call(e)}))}))}))),s||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l,c;return o(this,(function(o){switch(o.label){case 0:return n=t<this.prizes.length,r=n?"prizes":"buttons",s=n?"prizeImgs":"btnImgs",t=n?t:t-this.prizes.length,(a=this[r][t])&&a.imgs?(h=a.imgs[e])?(this[s][t]||(this[s][t]=[]),l=this[s][t],c=e,[4,this.loadImg(h.src,h)]):[2]:[2];case 1:return l[c]=o.sent(),i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle;0===i.flag.indexOf("UNI-")&&n.translate(this.Radius,this.Radius),n.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,i){return n.beginPath(),n.fillStyle=i.background,n.arc(0,0,e,0,2*Math.PI,!1),n.fill(),e-t.getLength(i.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=c(this.prizeDeg);var s=c(-90+this.rotateDeg+r.offsetDegree),a=function(e){return t.getOffsetX(n.measureText(e).width)},l=function(e,i,n){var r=e.lineHeight||o.lineHeight||e.fontSize||o.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(r)};n.save(),this.prizes.forEach((function(e,i){var f=s+i*t.prizeRadian,u=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){o?g(t,e,i,n,r,o,s):(t.beginPath(),t.fillStyle=s,t.moveTo(0,0),t.arc(0,0,i,n,r,!1),t.closePath(),t.fill())}(n,t.maxBtnRadius,t.prizeRadius,f-t.prizeRadian/2,f+t.prizeRadian/2,t.getLength(r.gutter),e.background||o.background);var d=Math.cos(f)*t.prizeRadius,p=Math.sin(f)*t.prizeRadius;n.translate(d,p),n.rotate(f+c(90)),e.imgs&&e.imgs.forEach((function(e,r){if(t.prizeImgs[i]){var o=t.prizeImgs[i][r];if(o){var s,a=t.computedWidthAndHeight(o,e,t.prizeRadian*t.prizeRadius,u),h=a[0],l=a[1],c=[t.getOffsetX(h),t.getHeight(e.top,u)],f=c[0],d=c[1];"WEB"===t.config.flag?s=o:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(s=o.path),n.drawImage(s,f,d,h,l)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,c=t.getLength(e.fontSize||o.fontSize),f=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+c+"px "+f;var d=[],g=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:o.wordWrap){g=h(g);for(var p="",m=0;m<g.length;m++){p+=g[m];var v=n.measureText(p).width,y=(t.prizeRadius-l(e,u,d.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(r.gutter);v>t.getWidth(e.lengthLimit||o.lengthLimit,y)&&(d.push(p.slice(0,-1)),p=g[m])}p&&d.push(p),d.length||d.push(g)}else d=g.split("\n");d.filter((function(t){return!!t})).forEach((function(t,i){n.fillText(t,a(t),l(e,u,i))}))})),n.rotate(c(360)-f-c(90)),n.translate(-d,-p)})),n.restore(),this.buttons.forEach((function(e,i){var r=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,r),n.beginPath(),n.fillStyle=e.background||"#fff",n.arc(0,0,r,0,2*Math.PI,!1),n.fill(),e.pointer&&(n.beginPath(),n.fillStyle=e.background||"#fff",n.moveTo(-r,0),n.lineTo(r,0),n.lineTo(0,2*-r),n.closePath(),n.fill()),e.imgs&&e.imgs.forEach((function(o,s){if(t.btnImgs[i]){var a=t.btnImgs[i][s];if(a){var h,l=t.computedWidthAndHeight(a,o,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=l[0],f=l[1],u=[t.getOffsetX(c),t.getHeight(o.top,r)],d=u[0],g=u[1];"WEB"===t.config.flag?h=a:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(h=a.path),n.drawImage(h,d,g,c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,h=t.getLength(e.fontSize||o.fontSize),c=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,i){n.fillText(t,a(t),l(e,r,i))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,s=e._defaultConfig,a=Date.now()-this.startTime;if(a>=s.accelerationTime&&void 0!==n){this.FPS=a/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=0;++h;){var l=360*h-n*r-o-s.offsetDegree;if(v(this.FPS,this.stopDeg,l,s.decelerationTime)-this.stopDeg>s.speed){this.endDeg=l;break}}return this.slowDown()}this.rotateDeg=(o+m(a,0,s.speed,s.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopDeg,a=e.endDeg,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>=h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.rotateDeg=v(l,s,a,h.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(l),w=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,o=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var s=function(){e.draw(),e.demo&&e.walk(),o&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([o.x,o.y,o.col||1,o.row||1]),s=n[0],a=n[1],h=n[2],l=n[3];r.beginPath(),r.rect(s,a,h,l),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,l=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){l++,e.loadAndCacheImg(i,n,(function(){h++,l===h&&s.call(e)}))}))}))),l||s.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l;return o(this,(function(o){switch(o.label){case 0:return(n=this.cells[t])&&n.imgs?(r=n.imgs[e],this.cellImgs[t]||(this.cellImgs[t]=[]),s=this.cellImgs[t],a=e,l={},[4,this.loadImg(r.src,r)]):[2];case 1:return s[a]=(l.defaultImg=o.sent(),l),r.hasOwnProperty("activeSrc")?[4,this.loadImg(r.activeSrc,r)]:[3,3];case 2:h=o.sent(),this.cellImgs[t][e].activeImg=h,o.label=3;case 3:return i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle,l=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=s(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,o=e.y,s=e.w,h=e.h,l=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,o=0;switch(e.length){case 1:i=n=r=o=e[0];break;case 2:i=n=e[0],r=o=e[1];break;case 3:i=e[0],r=o=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],o=e[3]}var s={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:o};for(var h in s)s[h]=t.hasOwnProperty(h)&&a(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):s[h];return[i,n,r,o]}(i).map((function(t){return~~t})),c=l[0],f=l[1],u=l[2],d=l[3],g=i.borderRadius?t.getLength(i.borderRadius):0;return p(n,r,o,s,h,g,t.handleBackground(r,o,s,h,i.background)),{x:r+u,y:o+c,w:s-u-d,h:h-c-f}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-r.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-r.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),s=r[0],a=r[1],c=r[2],f=r[3],u=i===t.currIndex%t.prizes.length>>0,d=(u?l.shadow:e.shadow||o.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(n.shadowColor=d[3],n.shadowOffsetX=d[0]*t.dpr,n.shadowOffsetY=d[1]*t.dpr,n.shadowBlur=d[2],d[0]>0?c-=d[0]:(c+=d[0],s-=d[0]),d[1]>0?f-=d[1]:(f+=d[1],a-=d[1])),p(n,s,a,c,f,t.getLength(e.borderRadius?e.borderRadius:o.borderRadius),t.handleBackground(s,a,c,f,e.background,u)),n.shadowColor="rgba(0, 0, 0, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,o){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][o];if(!h)return!1;var l,c=u&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),d=f[0],g=f[1],p=[s+t.getOffsetX(d,e.col),a+t.getHeight(r.top,e.row)],m=p[0],v=p[1];"WEB"===t.config.flag?l=c:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(l=c.path),n.drawImage(l,m,v,d,g)})),e.fonts&&e.fonts.forEach((function(i){var r=u&&l.fontStyle?l.fontStyle:i.fontStyle||o.fontStyle,c=u&&l.fontWeight?l.fontWeight:i.fontWeight||o.fontWeight,f=u&&l.fontSize?t.getLength(l.fontSize):t.getLength(i.fontSize||o.fontSize),d=u&&l.lineHeight?l.lineHeight:i.lineHeight||o.lineHeight||i.fontSize||o.fontSize;n.font=c+" "+f+"px "+r,n.fillStyle=u&&l.fontColor?l.fontColor:i.fontColor||o.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:o.wordWrap){p=h(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||o.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,o){n.fillText(r,s+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(o+1)*t.getLength(d))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,l=s._activeStyle;return(r=o?l.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var l=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*l(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*l(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*l(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*l(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*l(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*l(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*l(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*l(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),c)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,s=e.startTime,a=e._defaultConfig,h=Date.now()-s;if(h>=a.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var l=0;++l;){var c=r.length*l+o-(n>>0);if(v(this.FPS,this.stopIndex,c,a.decelerationTime)-this.stopIndex>a.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+m(h,.1,a.speed,a.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopIndex,a=e.endIndex,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.currIndex=v(l,s,a,h.decelerationTime)%r.length,this.draw(),i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(l);t.LuckyGrid=w,t.LuckyWheel=y,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))}function o(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function s(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var a=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},h=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},l=function(){function t(t){this.global={},this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.setTimeout=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).flag||(t.flag="WEB"),0===t.flag.indexOf("UNI-")?this.global=uni:"MINI-WX"===t.flag&&(this.global=wx),t.el&&(t.divElement=document.querySelector(t.el));var e=0,i=0;t.divElement&&(e=t.divElement.offsetWidth,i=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width=this.getLength(t.width)||e,t.height=this.getLength(t.height)||i,t.divElement&&(t.divElement.style.width=t.width+"px",t.divElement.style.height=t.height+"px"),t.canvasElement&&(t.canvasElement.setAttribute("package","lucky-canvas@1.2.0"),t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height?(this.resetArrayProto(),this.initWindowFunction()):console.error("无法获取到 CanvasContext2D 或宽高")}return t.prototype.setDpr=function(){window?window.dpr=this.dpr=1.3*(window.devicePixelRatio||2):this.dpr=this.config.dpr},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){if(window)return this.rAF=window.requestAnimationFrame,this.setInterval=window.setInterval,void(this.clearInterval=window.clearInterval);if(this.config.rAF)this.rAF=this.config.rAF;else if(this.config.setTimeout){var t=this.config.setTimeout;this.rAF=function(e){return t(e,16)}}else this.rAF=function(t){return setTimeout(t,16)}},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.canvasElement,o=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&(r.width=e.width*n,r.height=e.height*n,r.style.width=r.width+"px",r.style.height=r.height+"px",r.style.transform="scale("+1/n+") translate(\n "+-o(r.width)+"%, "+-o(r.height)+"%\n )",i.scale(n,n))},t.prototype.loadImg=function(t,e){var i=this;return new Promise((function(n){if("WEB"===i.config.flag){var r=new Image;r.src=t,r.onload=function(){return n(r)}}else if(["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(i.config.flag)){if(/^data:image\/([a-z]+);base64,/.test(t))return void(e.$resolve=n);i.global.getImageInfo({src:t,success:function(t){return n(t)},fail:function(){return console.error("API `getImageInfo` 加载图片失败",t)}})}}))},t.prototype.getLength=function(t){return a(t,"number")?t:a(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?750/e.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){var e=this.global;return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),e?e.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,s([this],Array.from(arguments)))}}))},t}(),c=function(t){return Math.PI/180*t},f=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},u=function(t,e){var i=-t/e;return[i,-i*t+e]},d=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=c(180).toFixed(8)){var s=(n+i)/2;return r?(d(t,e,i,s,r),d(t,e,s,n,r)):(d(t,e,s,n,r),d(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=f(i,e),h=a[0],l=a[1],g=f(n,e),p=g[0],m=g[1],v=u(h,l),y=v[0],w=v[1],b=u(p,m),I=b[0],z=b[1],x=(z-w)/(y-I),S=(I*w-y*z)/(I-y);isNaN(x)&&(Math.abs(h)===+e.toFixed(8)&&(x=h),Math.abs(p)===+e.toFixed(8)&&(x=p)),y===1/0||y===-1/0?S=I*x+z:I!==1/0&&I!==-1/0||(S=y*x+w),t.lineTo(h,l),t.quadraticCurveTo(x,S,p,m)},g=function(t,e,i,n,r,o,s){e||(e=o);var a=c(90/Math.PI/i*o),h=c(90/Math.PI/e*o),l=n+a,u=r-a,g=n+h,p=r-h;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,f(l,i)),d(t,i,l,u,!0),p>g?d(t,e,g,p,!1):t.lineTo.apply(t,f((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()},p=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.quadraticCurveTo(e+n,i,e+n,i+o),t.lineTo(e+n,i+r-o),t.quadraticCurveTo(e+n,i+r,e+n-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath(),t.fill()},m=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},v=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},y=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(s(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,"WEB"===i.flag&&n.translate(this.Radius,this.Radius);var r=function(){e.draw(),e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},o=0,s=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){s++,e.loadAndCacheImg(i,n,(function(){o++,s===o&&r.call(e)}))}))}))),s||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l,c;return o(this,(function(o){switch(o.label){case 0:return n=t<this.prizes.length,r=n?"prizes":"buttons",s=n?"prizeImgs":"btnImgs",t=n?t:t-this.prizes.length,(a=this[r][t])&&a.imgs?(h=a.imgs[e])?(this[s][t]||(this[s][t]=[]),l=this[s][t],c=e,[4,this.loadImg(h.src,h)]):[2]:[2];case 1:return l[c]=o.sent(),i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle;0===i.flag.indexOf("UNI-")&&n.translate(this.Radius,this.Radius),n.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,i){return n.beginPath(),n.fillStyle=i.background,n.arc(0,0,e,0,2*Math.PI,!1),n.fill(),e-t.getLength(i.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=c(this.prizeDeg);var s=c(-90+this.rotateDeg+r.offsetDegree),a=function(e){return t.getOffsetX(n.measureText(e).width)},l=function(e,i,n){var r=e.lineHeight||o.lineHeight||e.fontSize||o.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(r)};n.save(),this.prizes.forEach((function(e,i){var f=s+i*t.prizeRadian,u=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){o?g(t,e,i,n,r,o,s):(t.beginPath(),t.fillStyle=s,t.moveTo(0,0),t.arc(0,0,i,n,r,!1),t.closePath(),t.fill())}(n,t.maxBtnRadius,t.prizeRadius,f-t.prizeRadian/2,f+t.prizeRadian/2,t.getLength(r.gutter),e.background||o.background);var d=Math.cos(f)*t.prizeRadius,p=Math.sin(f)*t.prizeRadius;n.translate(d,p),n.rotate(f+c(90)),e.imgs&&e.imgs.forEach((function(e,r){if(t.prizeImgs[i]){var o=t.prizeImgs[i][r];if(o){var s,a=t.computedWidthAndHeight(o,e,t.prizeRadian*t.prizeRadius,u),h=a[0],l=a[1],c=[t.getOffsetX(h),t.getHeight(e.top,u)],f=c[0],d=c[1];"WEB"===t.config.flag?s=o:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(s=o.path),n.drawImage(s,f,d,h,l)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,c=t.getLength(e.fontSize||o.fontSize),f=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+c+"px "+f;var d=[],g=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:o.wordWrap){g=h(g);for(var p="",m=0;m<g.length;m++){p+=g[m];var v=n.measureText(p).width,y=(t.prizeRadius-l(e,u,d.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(r.gutter);v>t.getWidth(e.lengthLimit||o.lengthLimit,y)&&(d.push(p.slice(0,-1)),p=g[m])}p&&d.push(p),d.length||d.push(g)}else d=g.split("\n");d.filter((function(t){return!!t})).forEach((function(t,i){n.fillText(t,a(t),l(e,u,i))}))})),n.rotate(c(360)-f-c(90)),n.translate(-d,-p)})),n.restore(),this.buttons.forEach((function(e,i){var r=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,r),n.beginPath(),n.fillStyle=e.background||"#fff",n.arc(0,0,r,0,2*Math.PI,!1),n.fill(),e.pointer&&(n.beginPath(),n.fillStyle=e.background||"#fff",n.moveTo(-r,0),n.lineTo(r,0),n.lineTo(0,2*-r),n.closePath(),n.fill()),e.imgs&&e.imgs.forEach((function(o,s){if(t.btnImgs[i]){var a=t.btnImgs[i][s];if(a){var h,l=t.computedWidthAndHeight(a,o,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=l[0],f=l[1],u=[t.getOffsetX(c),t.getHeight(o.top,r)],d=u[0],g=u[1];"WEB"===t.config.flag?h=a:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(h=a.path),n.drawImage(h,d,g,c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var i=e.fontColor||o.fontColor,s=e.fontWeight||o.fontWeight,h=t.getLength(e.fontSize||o.fontSize),c=e.fontStyle||o.fontStyle;n.fillStyle=i,n.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,i){n.fillText(t,a(t),l(e,r,i))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,s=e._defaultConfig,a=Date.now()-this.startTime;if(a>=s.accelerationTime&&void 0!==n){this.FPS=a/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=0;++h;){var l=360*h-n*r-o-s.offsetDegree;if(v(this.FPS,this.stopDeg,l,s.decelerationTime)-this.stopDeg>s.speed){this.endDeg=l;break}}return this.slowDown()}this.rotateDeg=(o+m(a,0,s.speed,s.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopDeg,a=e.endDeg,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>=h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.rotateDeg=v(l,s,a,h.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(l),w=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,o=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var s=function(){e.draw(),e.demo&&e.walk(),o&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([o.x,o.y,o.col||1,o.row||1]),s=n[0],a=n[1],h=n[2],l=n[3];r.beginPath(),r.rect(s,a,h,l),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,l=0;a(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){l++,e.loadAndCacheImg(i,n,(function(){h++,l===h&&s.call(e)}))}))}))),l||s.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){return r(this,void 0,void 0,(function(){var n,r,s,a,h,l;return o(this,(function(o){switch(o.label){case 0:return(n=this.cells[t])&&n.imgs?(r=n.imgs[e],this.cellImgs[t]||(this.cellImgs[t]=[]),s=this.cellImgs[t],a=e,l={},[4,this.loadImg(r.src,r)]):[2];case 1:return s[a]=(l.defaultImg=o.sent(),l),r.hasOwnProperty("activeSrc")?[4,this.loadImg(r.activeSrc,r)]:[3,3];case 2:h=o.sent(),this.cellImgs[t][e].activeImg=h,o.label=3;case 3:return i.call(this),[2]}}))}))},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,r=e._defaultConfig,o=e._defaultStyle,l=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=s(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,o=e.y,s=e.w,h=e.h,l=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,o=0;switch(e.length){case 1:i=n=r=o=e[0];break;case 2:i=n=e[0],r=o=e[1];break;case 3:i=e[0],r=o=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],o=e[3]}var s={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:o};for(var h in s)s[h]=t.hasOwnProperty(h)&&a(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):s[h];return[i,n,r,o]}(i).map((function(t){return~~t})),c=l[0],f=l[1],u=l[2],d=l[3],g=i.borderRadius?t.getLength(i.borderRadius):0;return p(n,r,o,s,h,g,t.handleBackground(r,o,s,h,i.background)),{x:r+u,y:o+c,w:s-u-d,h:h-c-f}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-r.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-r.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),s=r[0],a=r[1],c=r[2],f=r[3],u=i===t.currIndex%t.prizes.length>>0,d=(u?l.shadow:e.shadow||o.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===d.length&&(n.shadowColor=d[3],n.shadowOffsetX=d[0]*t.dpr,n.shadowOffsetY=d[1]*t.dpr,n.shadowBlur=d[2],d[0]>0?c-=d[0]:(c+=d[0],s-=d[0]),d[1]>0?f-=d[1]:(f+=d[1],a-=d[1])),p(n,s,a,c,f,t.getLength(e.borderRadius?e.borderRadius:o.borderRadius),t.handleBackground(s,a,c,f,e.background,u)),n.shadowColor="rgba(0, 0, 0, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,o){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][o];if(!h)return!1;var l,c=u&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),d=f[0],g=f[1],p=[s+t.getOffsetX(d,e.col),a+t.getHeight(r.top,e.row)],m=p[0],v=p[1];"WEB"===t.config.flag?l=c:["MINI-WX","UNI-H5","UNI-MINI-WX"].includes(t.config.flag)&&(l=c.path),n.drawImage(l,m,v,d,g)})),e.fonts&&e.fonts.forEach((function(i){var r=u&&l.fontStyle?l.fontStyle:i.fontStyle||o.fontStyle,c=u&&l.fontWeight?l.fontWeight:i.fontWeight||o.fontWeight,f=u&&l.fontSize?t.getLength(l.fontSize):t.getLength(i.fontSize||o.fontSize),d=u&&l.lineHeight?l.lineHeight:i.lineHeight||o.lineHeight||i.fontSize||o.fontSize;n.font=c+" "+f+"px "+r,n.fillStyle=u&&l.fontColor?l.fontColor:i.fontColor||o.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:o.wordWrap){p=h(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||o.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,o){n.fillText(r,s+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(o+1)*t.getLength(d))}))}))})),0===this.config.flag.indexOf("UNI-")&&n.draw()},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,l=s._activeStyle;return(r=o?l.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var l=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*l(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*l(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*l(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*l(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*l(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*l(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*l(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*l(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),c)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,s=e.startTime,a=e._defaultConfig,h=Date.now()-s;if(h>=a.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var l=0;++l;){var c=r.length*l+o-(n>>0);if(v(this.FPS,this.stopIndex,c,a.decelerationTime)-this.stopIndex>a.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+m(h,.1,a.speed,a.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.prizes,o=e.prizeFlag,s=e.stopIndex,a=e.endIndex,h=e._defaultConfig,l=Date.now()-this.endTime;if(l>h.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n({},r.find((function(t,e){return e===o})))));this.currIndex=v(l,s,a,h.decelerationTime)%r.length,this.draw(),i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),a(t,"number")?t:a(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(l);t.LuckyGrid=w,t.LuckyWheel=y,Object.defineProperty(t,"__esModule",{value:!0})}));

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc