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

lucky-canvas

Package Overview
Dependencies
Maintainers
2
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.6.4 to 1.6.5

2

dist/index.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])},t(e,i)};function e(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");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},i.apply(this,arguments)};function n(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(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(a,s)}h((n=n.apply(t,e||[])).next())}))}function r(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}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,s])}}}function o(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});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}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},h=function(t){if("string"!=typeof t)return!1;if("transparent"===(t=t.toLocaleLowerCase().trim()))return!1;if(/^rgba/.test(t)){var e=/([^\s,]+)\)$/.exec(t);if(0===(null===(i=e)?0:"object"==typeof i?NaN:"number"==typeof i?i:"string"==typeof i?"%"===i[i.length-1]?Number(i.slice(0,-1))/100:Number(i):NaN))return!1}var i;return!0},u=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},c=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],a=t.measureText("...").width,s=0;s<e.length;s++){r+=e[s];var h=t.measureText(r).width,u=i(o);if(n===o.length+1&&(h+=a),u<0)return o;if(h>u&&(o.push(r.slice(0,-1)),r=e[s]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},l=function(t){return Math.PI/180*t},f=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=Math.min(o,a),u=Math.PI;s>h/2&&(s=h/2),t.beginPath(),t.moveTo(n+s,r),t.lineTo(n+s,r),t.lineTo(n+o-s,r),t.arc(n+o-s,r+s,s,-u/2,0),t.lineTo(n+o,r+a-s),t.arc(n+o-s,r+a-s,s,0,u/2),t.lineTo(n+s,r+a),t.arc(n+s,r+a-s,s,u/2,u),t.lineTo(n,r+s),t.arc(n+s,r+s,s,u,-u/2),t.closePath()},d=function(t,e,i,n,r,o){var a=document.createElement("canvas"),s=a.getContext("2d"),h=t.width,u=t.height;a.width=h,a.height=u;var c=h/n;return f(s,e*c,i*c,n*c,r*c,o*c),s.clip(),s.drawImage(t,0,0,h,u),a},p=function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var a=n.getImageData(0,0,r,o),s=a.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),a=[],s=0,h=-i;h<=i;h++)for(var u=-i;u<=i;u++){var c=o*Math.exp(-(h*h+u*u)/r);a.push(c),s+=c}for(var l=0;l<a.length;l++)a[l]/=s;return a}(e);return s.length,h.length,console.log(a),n.putImageData(a,0,0),i},g=function(){function t(){this.subs=[]}return t.prototype.addSub=function(t){this.subs.includes(t)||this.subs.push(t)},t.prototype.notify=function(){this.subs.forEach((function(t){t.update()}))},t}(),v="__proto__"in{};function m(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var w=Array.prototype,y=Object.create(w);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){y[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=w[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var b=function(){function t(t){this.dep=new g,m(t,"__luckyOb__",this),Array.isArray(t)&&(v?t.__proto__=y:Object.getOwnPropertyNames(y).forEach((function(e){m(t,e,y[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){x(t,e,t[e])}))},t}();function z(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new b(t)}function x(t,e,i){var n=new g,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,a=r&&r.set;o&&!a||2!==arguments.length||(i=t[e]);var s=z(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return g.target&&(n.addSub(g.target),s&&s.dep.addSub(g.target)),e},set:function(e){e!==i&&(i=e,o&&!a||(a?a.call(t,e):i=e,s=z(e),n.notify()))}})}}var C=0,I=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=C++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){g.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){a(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),g.target=null,t},t.prototype.update=function(){var t=this.get(),e=this.value;this.value=t,this.cb.call(this.$lucky,t,e)},t}(),k=function(){function t(t,e){var i=this;this.version="1.6.4",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.6.4"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){this.resize(),this.boxWidth&&this.boxHeight||console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.setDpr=function(){var t=this.config;t.dpr||(window?window.dpr=t.dpr=window.devicePixelRatio||1:t.dpr||console.error(t,"未传入 dpr 可能会导致绘制异常"))},t.prototype.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],a=r[1];i&&(i.width=o,i.height=a,i.style.width=o+"px",i.style.height=a+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},t.setTimeout=window.setTimeout,t.setInterval=window.setInterval,t.clearTimeout=window.clearTimeout,void(t.clearInterval=window.clearInterval);if(t.rAF)this.rAF=t.rAF;else if(t.setTimeout){var e=t.setTimeout;this.rAF=function(t){return e(t,16.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var a=new Image;a.onload=function(){return r(a)},a.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},a.src=t}))},t.prototype.drawImage=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n,r=this,a=r.config,s=r.ctx;if(["WEB","MP-WX"].includes(a.flag))n=t;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(a.flag))return console.error("意料之外的 flag, 该平台尚未兼容!");n=t.path}return s.drawImage.apply(s,o([n],e))},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){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var a=i.config.unitFunc;return a?a(n,r):n})))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return d.apply(void 0,o([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var a=n.getImageData(0,0,r,o),s=a.data,h=s.length,u=0;u<h;u+=4){var c=s[u+3];0!==c&&(s[u+3]=c*e/100)}n.putImageData(a,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return p(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&x(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,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new I(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),S={easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e}},T={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sin(t/n*(Math.PI/2))+e}},O={easeIn:function(t,e,i,n){return t>=n&&(t=n),0==t?e:i*Math.pow(2,10*(t/n-1))+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),t==n?e+i:i*(1-Math.pow(2,-10*t/n))+e}},$={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sqrt(1-(t=t/n-1)*t)+e}},P=Object.freeze({__proto__:null,quad:S,cubic:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t+1)+e}},quart:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*((t=t/n-1)*t*t*t-1)+e}},quint:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t*t*t+1)+e}},sine:T,expo:O,circ:$}),W=function(t){function o(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(o,t),o.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},o.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},o.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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)},o.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return i({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return i({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},o.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},o.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},o.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},o.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},o.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if(s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]),n.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(n,t)),u[i][e][o]=t,r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},o.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)]},o.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,a=n._defaultConfig,u=n._defaultStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(t,e,n){return h(e.background)&&(o.beginPath(),o.fillStyle=e.background,o.arc(0,0,t,0,2*Math.PI,!1),o.fill()),e.imgs&&e.imgs.forEach((function(e,r){var a=i.ImageCache.blocks;if(a&&a[n]){var s=a[n][r];if(s){var h=i.computedWidthAndHeight(s,e,2*t,2*t),u=h[0],c=h[1],f=[i.getOffsetX(u),i.getHeight(e.top,2*t)-t],d=f[0],p=f[1];o.save(),e.rotate&&o.rotate(l(i.rotateDeg)),i.drawImage(s,d,p,u,c),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=l(this.prizeDeg);var f=l(this.rotateDeg-90+this.prizeDeg/2+a.offsetDegree),d=function(t){return i.getOffsetX(o.measureText(t).width)},p=function(t,e,n){var r=t.lineHeight||u.lineHeight||t.fontSize||u.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=f+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,g=t.background||u.background;h(g)&&(o.fillStyle=g,function(t,e,i,n,r,o){t.beginPath();var a=l(90/Math.PI/i*o),s=l(90/Math.PI/e*o),h=n+a,u=r-a,c=n+s,f=r-s;t.arc(0,0,i,h,u,!1),t.arc(0,0,e,f,c,!0),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(a.gutter)),o.fill());var v=Math.cos(n)*i.prizeRadius,m=Math.sin(n)*i.prizeRadius;o.translate(v,m),o.rotate(n+l(90)),t.imgs&&t.imgs.forEach((function(t,n){var o=i.ImageCache.prizes;if(o&&o[e]){var a=o[e][n];if(a){var s=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,r)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,n=t.fontWeight||u.fontWeight,h=i.getLength(t.fontSize||u.fontSize),l=t.fontStyle||u.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:u.wordWrap,g=t.lengthLimit||u.lengthLimit,v=t.lineClamp||u.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var m=String(t.text);(f?c(o,s(m),(function(e){var n=2*((i.prizeRadius-p(t,r,e.length))*Math.tan(i.prizeRadian/2))-i.getLength(a.gutter);return i.getWidth(g,n)}),v):m.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,d(e),p(t,r,i))}))})),o.rotate(l(360)-n-l(90)),o.translate(-v,-m)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var o=i.ImageCache.buttons;if(o&&o[e]){var a=o[e][r];if(a){var s=i.computedWidthAndHeight(a,t,2*n,2*n),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,n)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,r=t.fontWeight||u.fontWeight,a=i.getLength(t.fontSize||u.fontSize),s=t.fontStyle||u.fontStyle;o.fillStyle=e,o.font=r+" "+(a>>0)+"px "+s,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,d(e),p(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},o.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},o.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.rotateDeg=0,this.draw()):this.prizeFlag=t%this.prizes.length},o.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,a=e._defaultConfig;if(-1!==n){var s=Date.now()-this.startTime;if(s>=a.accelerationTime&&void 0!==n){this.FPS=s/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=(Math.random()*r-r/2)*this.getLength(a.stopRange),u=0;++u;){var c=360*u-n*r-o-a.offsetDegree+h-r/2;if(P[a.speedFunction].easeOut(this.FPS,this.stopDeg,c,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=c;break}}return this.slowDown()}this.rotateDeg=(o+P[a.speedFunction].easeIn(s,0,a.speed,a.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},o.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopDeg,a=e.endDeg,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>=s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.rotateDeg=P[s.speedFunction].easeOut(h,o,a,s.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},o.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},o.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},o.prototype.getOffsetX=function(t){return-t/2},o.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},o}(k),_=function(t){function l(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(l,t),l.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},l.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},l.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,"buttons",t.buttons||[]),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)},l.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:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return i({background:"#ffce98",shadow:""},t.activeStyle)}))},l.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("rows",(function(){return t.init()})),this.$watch("cols",(function(){return t.init()})),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("activeStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},l.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},l.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},l.prototype.handleClick=function(t){var e=this,i=this.ctx;o(o([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),a=o[0],s=o[1],h=o[2],u=o[3];i.beginPath(),i.rect(a,s,h,u),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},l.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if("buttons"===t&&!n.buttons.length&&n.button&&(s=n.button),s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]);var c=[n.loadImg(h.src,h),h.activeSrc&&n.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(c).then((function(t){var a=t[0],s=t[1],c=h.formatter;"function"==typeof c&&(a=c.call(n,a),s&&(s=c.call(n,s))),u[i][e][o]={defaultImg:a,activeImg:s},r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},l.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)]},l.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,u=n.ctx,l=n._defaultConfig,d=n._defaultStyle,p=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,u),u.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=o(o([],this.prizes),this.buttons),this.button&&this.cells.push(this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(t,e){var n=t.x,r=t.y,o=t.w,s=t.h,c=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var h={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var u in h)h[u]=Object.prototype.hasOwnProperty.call(t,u)&&a(t[u],"string","number")?~~String(t[u]).replace(/px/g,""):h[u];return[n,r,o,s]}(e),l=c[0],p=c[1],g=c[2],v=c[3],m=e.borderRadius?i.getLength(e.borderRadius):0,w=e.background||d.background;return h(w)&&(u.fillStyle=i.handleBackground(n,r,o,s,w),f(u,n,r,o,s,m),u.fill()),{x:n+g,y:r+l,w:o-g-v,h:s-l-p}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),this.cellWidth=(this.prizeArea.w-l.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-l.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(t,e){var n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),o=n[0],a=n[1],l=n[2],g=n[3],v=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(v=e===i.currIndex%i.prizes.length>>0);var m=v?p.background:t.background||d.background;if(h(m)){var w=(v?p.shadow:t.shadow||d.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===w.length&&(u.shadowColor=w[3],u.shadowOffsetX=w[0]*r.dpr,u.shadowOffsetY=w[1]*r.dpr,u.shadowBlur=w[2],w[0]>0?l-=w[0]:(l+=w[0],o-=w[0]),w[1]>0?g-=w[1]:(g+=w[1],a-=w[1])),u.fillStyle=i.handleBackground(o,a,l,g,m);var y=i.getLength(t.borderRadius?t.borderRadius:d.borderRadius);f(u,o,a,l,g,y),u.fill(),u.shadowColor="rgba(0, 0, 0, 0)",u.shadowOffsetX=0,u.shadowOffsetY=0,u.shadowBlur=0}var b="prizes";e>=i.prizes.length&&(b="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var s=i.ImageCache[b];if(s[e]){var h=s[e][r];if(h){var u=v&&h.activeImg||h.defaultImg;if(u){var c=i.computedWidthAndHeight(u,n,t),l=c[0],f=c[1],d=[o+i.getOffsetX(l,t.col),a+i.getHeight(n.top,t.row)],p=d[0],g=d[1];i.drawImage(u,p,g,l,f)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=v&&p.fontStyle?p.fontStyle:e.fontStyle||d.fontStyle,r=v&&p.fontWeight?p.fontWeight:e.fontWeight||d.fontWeight,h=v&&p.fontSize?i.getLength(p.fontSize):i.getLength(e.fontSize||d.fontSize),l=v&&p.lineHeight?p.lineHeight:e.lineHeight||d.lineHeight||e.fontSize||d.fontSize,f=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:d.wordWrap,g=e.lengthLimit||d.lengthLimit,m=e.lineClamp||d.lineClamp;u.font=r+" "+(h>>0)+"px "+n,u.fillStyle=v&&p.fontColor?p.fontColor:e.fontColor||d.fontColor;var w=[],y=String(e.text);if(f){var b=i.getWidth(g,t.col);w=c(u,s(y),(function(){return b}),m)}else w=y.split("\n");w.forEach((function(n,r){u.fillText(n,o+i.getOffsetX(u.measureText(n).width,t.col),a+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,u)},l.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var a=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),s=a.shift(),h=[0,0,0,0];if(s.includes("deg")){var u=function(t){return Math.tan(t/180*Math.PI)};(s=s.slice(0,-3)%360)>=0&&s<45?h=[e,i+r,e+n,i+r-n*u(s-0)]:s>=45&&s<90?h=[e,i+r,e+n-r*u(s-45),i]:s>=90&&s<135?h=[e+n,i+r,e+n-r*u(s-90),i]:s>=135&&s<180?h=[e+n,i+r,e,i+n*u(s-135)]:s>=180&&s<225?h=[e+n,i,e,i+n*u(s-180)]:s>=225&&s<270?h=[e+n,i,e+r*u(s-225),i+r]:s>=270&&s<315?h=[e,i,e+r*u(s-270),i+r]:s>=315&&s<360&&(h=[e,i,e+n,i+r-n*u(s-315)])}else s.includes("top")?h=[e,i+r,e,i]:s.includes("bottom")?h=[e,i,e,i+r]:s.includes("left")?h=[e+n,i,e,i]:s.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return a.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)}(o,t,e,i,n,r)),r},l.prototype.play=function(){var t=this.config.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},l.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.currIndex=0,this.draw()):this.prizeFlag=t%this.prizes.length},l.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,a=e.startTime,s=e._defaultConfig;if(-1!==o){var h=Date.now()-a;if(h>=s.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var u=0;++u;){var c=r.length*u+o-(n>>0);if(S.easeOut(this.FPS,this.stopIndex,c,s.decelerationTime)-this.stopIndex>s.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+S.easeIn(h,.1,s.speed,s.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},l.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopIndex,a=e.endIndex,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.currIndex=S.easeOut(h,o,a,s.decelerationTime)%n.length,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},l.prototype.walk=function(){var t=this,e=this.config,i=e.setInterval;(0,e.clearInterval)(this.timer),this.timer=i((function(){t.currIndex+=1,t.draw()}),1300)},l.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],a=void 0===o?1:o,s=this.cellWidth,h=this.cellHeight,u=this._defaultConfig.gutter,c=[this.prizeArea.x+(s+u)*e,this.prizeArea.y+(h+u)*i];return r&&a&&c.push(s*r+u*(r-1),h*a+u*(a-1)),c},l.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},l.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},l.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},l.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr,e/i.dpr]},l}(k);exports.LuckyGrid=_,exports.LuckyWheel=W;
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])},t(e,i)};function e(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");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},i.apply(this,arguments)};function n(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(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(a,s)}h((n=n.apply(t,e||[])).next())}))}function r(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}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,s])}}}function o(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});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}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},h=function(t){if("string"!=typeof t)return!1;if("transparent"===(t=t.toLocaleLowerCase().trim()))return!1;if(/^rgba/.test(t)){var e=/([^\s,]+)\)$/.exec(t);if(0===(null===(i=e)?0:"object"==typeof i?NaN:"number"==typeof i?i:"string"==typeof i?"%"===i[i.length-1]?Number(i.slice(0,-1))/100:Number(i):NaN))return!1}var i;return!0},u=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},c=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],a=t.measureText("...").width,s=0;s<e.length;s++){r+=e[s];var h=t.measureText(r).width,u=i(o);if(n===o.length+1&&(h+=a),u<0)return o;if(h>u&&(o.push(r.slice(0,-1)),r=e[s]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},l=function(t){return Math.PI/180*t},f=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},d=function(t,e){var i=-t/e;return[i,-i*t+e]},p=function(t,e,i,n,r,o){var a;if(void 0===o&&(o=!0),Math.abs(r-n).toFixed(8)>=l(180).toFixed(8)){var s=(r+n)/2;return o?(p(t,e,i,n,s,o),p(t,e,i,s,r,o)):(p(t,e,i,s,r,o),p(t,e,i,n,s,o)),!1}o||(n=(a=[r,n])[0],r=a[1]);var h=f(n,i),u=h[0],c=h[1],g=f(r,i),v=g[0],m=g[1],w=d(u,c),y=w[0],b=w[1],x=d(v,m),z=x[0],C=x[1],I=(C-b)/(y-z),k=(z*b-y*C)/(z-y);isNaN(I)&&(Math.abs(u)===+i.toFixed(8)&&(I=u),Math.abs(v)===+i.toFixed(8)&&(I=v)),y===1/0||y===-1/0?k=z*I+C:z!==1/0&&z!==-1/0||(k=y*I+b),e.lineTo(u,c),t.indexOf("MP")>0?e.quadraticCurveTo(I,k,v,m):e.arcTo(I,k,v,m,i)},g=function(t,e,i,n,r,o,a,s){i||(i=a);var h=l(90/Math.PI/n*a),u=l(90/Math.PI/i*a),c=r+h,d=o-h,g=r+u,v=o-u;e.beginPath(),e.fillStyle=s,e.moveTo.apply(e,f(c,n)),p(t,e,n,c,d,!0),v>g?p(t,e,i,g,v,!1):e.lineTo.apply(e,f((r+o)/2,a/2/Math.abs(Math.sin((r-o)/2)))),e.closePath(),e.fill()},v=function(t,e,i,n,r,o){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),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)},m=function(t,e,i,n,r,o,a){t.fillStyle=a,v(t,e,i,n,r,o),t.closePath(),t.fill()},w=function(t,e,i,n,r,o){var a=document.createElement("canvas"),s=a.getContext("2d"),h=t.width,u=t.height;a.width=h,a.height=u;var c=h/n;return v(s,e*c,i*c,n*c,r*c,o*c),s.clip(),s.drawImage(t,0,0,h,u),a},y=function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var a=n.getImageData(0,0,r,o),s=a.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),a=[],s=0,h=-i;h<=i;h++)for(var u=-i;u<=i;u++){var c=o*Math.exp(-(h*h+u*u)/r);a.push(c),s+=c}for(var l=0;l<a.length;l++)a[l]/=s;return a}(e);return s.length,h.length,console.log(a),n.putImageData(a,0,0),i},b=function(){function t(){this.subs=[]}return t.prototype.addSub=function(t){this.subs.includes(t)||this.subs.push(t)},t.prototype.notify=function(){this.subs.forEach((function(t){t.update()}))},t}(),x="__proto__"in{};function z(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var C=Array.prototype,I=Object.create(C);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){I[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=C[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var k=function(){function t(t){this.dep=new b,z(t,"__luckyOb__",this),Array.isArray(t)&&(x?t.__proto__=I:Object.getOwnPropertyNames(I).forEach((function(e){z(t,e,I[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){T(t,e,t[e])}))},t}();function S(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new k(t)}function T(t,e,i){var n=new b,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,a=r&&r.set;o&&!a||2!==arguments.length||(i=t[e]);var s=S(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return b.target&&(n.addSub(b.target),s&&s.dep.addSub(b.target)),e},set:function(e){e!==i&&(i=e,o&&!a||(a?a.call(t,e):i=e,s=S(e),n.notify()))}})}}var O=0,P=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=O++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){b.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){a(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),b.target=null,t},t.prototype.update=function(){var t=this.get(),e=this.value;this.value=t,this.cb.call(this.$lucky,t,e)},t}(),$=function(){function t(t,e){var i=this;this.version="1.6.3",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.6.3"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){this.resize(),this.boxWidth&&this.boxHeight||console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.setDpr=function(){var t=this.config;t.dpr||(window?window.dpr=t.dpr=window.devicePixelRatio||1:t.dpr||console.error(t,"未传入 dpr 可能会导致绘制异常"))},t.prototype.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],a=r[1];i&&(i.width=o,i.height=a,i.style.width=o+"px",i.style.height=a+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},t.setTimeout=window.setTimeout,t.setInterval=window.setInterval,t.clearTimeout=window.clearTimeout,void(t.clearInterval=window.clearInterval);if(t.rAF)this.rAF=t.rAF;else if(t.setTimeout){var e=t.setTimeout;this.rAF=function(t){return e(t,16.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var a=new Image;a.onload=function(){return r(a)},a.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},a.src=t}))},t.prototype.drawImage=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n,r=this,a=r.config,s=r.ctx;if(["WEB","MP-WX"].includes(a.flag))n=t;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(a.flag))return console.error("意料之外的 flag, 该平台尚未兼容!");n=t.path}return s.drawImage.apply(s,o([n],e))},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){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var a=i.config.unitFunc;return a?a(n,r):n})))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return w.apply(void 0,o([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var a=n.getImageData(0,0,r,o),s=a.data,h=s.length,u=0;u<h;u+=4){var c=s[u+3];0!==c&&(s[u+3]=c*e/100)}n.putImageData(a,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return y(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&T(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,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new P(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),W={easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e}},_={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sin(t/n*(Math.PI/2))+e}},E={easeIn:function(t,e,i,n){return t>=n&&(t=n),0==t?e:i*Math.pow(2,10*(t/n-1))+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),t==n?e+i:i*(1-Math.pow(2,-10*t/n))+e}},R={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sqrt(1-(t=t/n-1)*t)+e}},D=Object.freeze({__proto__:null,quad:W,cubic:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t+1)+e}},quart:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*((t=t/n-1)*t*t*t-1)+e}},quint:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t*t*t+1)+e}},sine:_,expo:E,circ:R}),F=function(t){function o(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(o,t),o.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},o.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},o.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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)},o.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return i({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return i({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},o.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},o.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},o.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},o.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},o.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if(s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]),n.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(n,t)),u[i][e][o]=t,r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},o.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)]},o.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,a=n._defaultConfig,u=n._defaultStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(t,e,n){return h(e.background)&&(o.beginPath(),o.fillStyle=e.background,o.arc(0,0,t,0,2*Math.PI,!1),o.fill()),e.imgs&&e.imgs.forEach((function(e,r){var a=i.ImageCache.blocks;if(a&&a[n]){var s=a[n][r];if(s){var h=i.computedWidthAndHeight(s,e,2*t,2*t),u=h[0],c=h[1],f=[i.getOffsetX(u),i.getHeight(e.top,2*t)-t],d=f[0],p=f[1];o.save(),e.rotate&&o.rotate(l(i.rotateDeg)),i.drawImage(s,d,p,u,c),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=l(this.prizeDeg);var f=l(this.rotateDeg-90+this.prizeDeg/2+a.offsetDegree),d=function(t){return i.getOffsetX(o.measureText(t).width)},p=function(t,e,n){var r=t.lineHeight||u.lineHeight||t.fontSize||u.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=f+e*i.prizeRadian,v=i.prizeRadius-i.maxBtnRadius,m=t.background||u.background;h(m)&&function(t,e,i,n,r,o,a,s){a?g(t,e,i,n,r,o,a,s):(e.beginPath(),e.fillStyle=s,e.moveTo(0,0),e.arc(0,0,n,r,o,!1),e.closePath(),e.fill())}(r.flag,o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(a.gutter),m);var w=Math.cos(n)*i.prizeRadius,y=Math.sin(n)*i.prizeRadius;o.translate(w,y),o.rotate(n+l(90)),t.imgs&&t.imgs.forEach((function(t,n){var r=i.ImageCache.prizes;if(r&&r[e]){var o=r[e][n];if(o){var a=i.computedWidthAndHeight(o,t,i.prizeRadian*i.prizeRadius,v),s=a[0],h=a[1],u=[i.getOffsetX(s),i.getHeight(t.top,v)],c=u[0],l=u[1];i.drawImage(o,c,l,s,h)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,n=t.fontWeight||u.fontWeight,r=i.getLength(t.fontSize||u.fontSize),h=t.fontStyle||u.fontStyle,l=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:u.wordWrap,f=t.lengthLimit||u.lengthLimit,g=t.lineClamp||u.lineClamp;o.fillStyle=e,o.font=n+" "+(r>>0)+"px "+h;var m=String(t.text);(l?c(o,s(m),(function(e){var n=2*((i.prizeRadius-p(t,v,e.length))*Math.tan(i.prizeRadian/2))-i.getLength(a.gutter);return i.getWidth(f,n)}),g):m.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,d(e),p(t,v,i))}))})),o.rotate(l(360)-n-l(90)),o.translate(-w,-y)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var o=i.ImageCache.buttons;if(o&&o[e]){var a=o[e][r];if(a){var s=i.computedWidthAndHeight(a,t,2*n,2*n),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,n)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,r=t.fontWeight||u.fontWeight,a=i.getLength(t.fontSize||u.fontSize),s=t.fontStyle||u.fontStyle;o.fillStyle=e,o.font=r+" "+(a>>0)+"px "+s,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,d(e),p(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},o.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},o.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.rotateDeg=0,this.draw()):this.prizeFlag=t%this.prizes.length},o.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,a=e._defaultConfig;if(-1!==n){var s=Date.now()-this.startTime;if(s>=a.accelerationTime&&void 0!==n){this.FPS=s/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=(Math.random()*r-r/2)*this.getLength(a.stopRange),u=0;++u;){var c=360*u-n*r-o-a.offsetDegree+h-r/2;if(D[a.speedFunction].easeOut(this.FPS,this.stopDeg,c,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=c;break}}return this.slowDown()}this.rotateDeg=(o+D[a.speedFunction].easeIn(s,0,a.speed,a.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},o.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopDeg,a=e.endDeg,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>=s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.rotateDeg=D[s.speedFunction].easeOut(h,o,a,s.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},o.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},o.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},o.prototype.getOffsetX=function(t){return-t/2},o.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},o}($),H=function(t){function l(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(l,t),l.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},l.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},l.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,"buttons",t.buttons||[]),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)},l.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:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return i({background:"#ffce98",shadow:""},t.activeStyle)}))},l.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("rows",(function(){return t.init()})),this.$watch("cols",(function(){return t.init()})),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("activeStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},l.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},l.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},l.prototype.handleClick=function(t){var e=this,i=this.ctx;o(o([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),a=o[0],s=o[1],h=o[2],u=o[3];i.beginPath(),i.rect(a,s,h,u),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},l.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if("buttons"===t&&!n.buttons.length&&n.button&&(s=n.button),s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]);var c=[n.loadImg(h.src,h),h.activeSrc&&n.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(c).then((function(t){var a=t[0],s=t[1],c=h.formatter;"function"==typeof c&&(a=c.call(n,a),s&&(s=c.call(n,s))),u[i][e][o]={defaultImg:a,activeImg:s},r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},l.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)]},l.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,u=n.ctx,l=n._defaultConfig,f=n._defaultStyle,d=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,u),u.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=o(o([],this.prizes),this.buttons),this.button&&this.cells.push(this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(t,e){var n=t.x,r=t.y,o=t.w,s=t.h,c=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var h={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var u in h)h[u]=Object.prototype.hasOwnProperty.call(t,u)&&a(t[u],"string","number")?~~String(t[u]).replace(/px/g,""):h[u];return[n,r,o,s]}(e),l=c[0],d=c[1],p=c[2],g=c[3],v=e.borderRadius?i.getLength(e.borderRadius):0,w=e.background||f.background;return h(w)&&m(u,n,r,o,s,v,i.handleBackground(n,r,o,s,w)),{x:n+p,y:r+l,w:o-p-g,h:s-l-d}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),this.cellWidth=(this.prizeArea.w-l.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-l.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(t,e){var n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),o=n[0],a=n[1],l=n[2],p=n[3],g=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(g=e===i.currIndex%i.prizes.length>>0);var v=g?d.background:t.background||f.background;if(h(v)){var w=(g?d.shadow:t.shadow||f.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===w.length&&(u.shadowColor=w[3],u.shadowOffsetX=w[0]*r.dpr,u.shadowOffsetY=w[1]*r.dpr,u.shadowBlur=w[2],w[0]>0?l-=w[0]:(l+=w[0],o-=w[0]),w[1]>0?p-=w[1]:(p+=w[1],a-=w[1])),m(u,o,a,l,p,i.getLength(t.borderRadius?t.borderRadius:f.borderRadius),i.handleBackground(o,a,l,p,v)),u.shadowColor="rgba(0, 0, 0, 0)",u.shadowOffsetX=0,u.shadowOffsetY=0,u.shadowBlur=0}var y="prizes";e>=i.prizes.length&&(y="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var s=i.ImageCache[y];if(s[e]){var h=s[e][r];if(h){var u=g&&h.activeImg||h.defaultImg;if(u){var c=i.computedWidthAndHeight(u,n,t),l=c[0],f=c[1],d=[o+i.getOffsetX(l,t.col),a+i.getHeight(n.top,t.row)],p=d[0],v=d[1];i.drawImage(u,p,v,l,f)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=g&&d.fontStyle?d.fontStyle:e.fontStyle||f.fontStyle,r=g&&d.fontWeight?d.fontWeight:e.fontWeight||f.fontWeight,h=g&&d.fontSize?i.getLength(d.fontSize):i.getLength(e.fontSize||f.fontSize),l=g&&d.lineHeight?d.lineHeight:e.lineHeight||f.lineHeight||e.fontSize||f.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:f.wordWrap,v=e.lengthLimit||f.lengthLimit,m=e.lineClamp||f.lineClamp;u.font=r+" "+(h>>0)+"px "+n,u.fillStyle=g&&d.fontColor?d.fontColor:e.fontColor||f.fontColor;var w=[],y=String(e.text);if(p){var b=i.getWidth(v,t.col);w=c(u,s(y),(function(){return b}),m)}else w=y.split("\n");w.forEach((function(n,r){u.fillText(n,o+i.getOffsetX(u.measureText(n).width,t.col),a+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,u)},l.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var a=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),s=a.shift(),h=[0,0,0,0];if(s.includes("deg")){var u=function(t){return Math.tan(t/180*Math.PI)};(s=s.slice(0,-3)%360)>=0&&s<45?h=[e,i+r,e+n,i+r-n*u(s-0)]:s>=45&&s<90?h=[e,i+r,e+n-r*u(s-45),i]:s>=90&&s<135?h=[e+n,i+r,e+n-r*u(s-90),i]:s>=135&&s<180?h=[e+n,i+r,e,i+n*u(s-135)]:s>=180&&s<225?h=[e+n,i,e,i+n*u(s-180)]:s>=225&&s<270?h=[e+n,i,e+r*u(s-225),i+r]:s>=270&&s<315?h=[e,i,e+r*u(s-270),i+r]:s>=315&&s<360&&(h=[e,i,e+n,i+r-n*u(s-315)])}else s.includes("top")?h=[e,i+r,e,i]:s.includes("bottom")?h=[e,i,e,i+r]:s.includes("left")?h=[e+n,i,e,i]:s.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return a.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)}(o,t,e,i,n,r)),r},l.prototype.play=function(){var t=this.config.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},l.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.currIndex=0,this.draw()):this.prizeFlag=t%this.prizes.length},l.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,a=e.startTime,s=e._defaultConfig;if(-1!==o){var h=Date.now()-a;if(h>=s.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var u=0;++u;){var c=r.length*u+o-(n>>0);if(W.easeOut(this.FPS,this.stopIndex,c,s.decelerationTime)-this.stopIndex>s.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+W.easeIn(h,.1,s.speed,s.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},l.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopIndex,a=e.endIndex,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.currIndex=W.easeOut(h,o,a,s.decelerationTime)%n.length,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},l.prototype.walk=function(){var t=this,e=this.config,i=e.setInterval;(0,e.clearInterval)(this.timer),this.timer=i((function(){t.currIndex+=1,t.draw()}),1300)},l.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],a=void 0===o?1:o,s=this.cellWidth,h=this.cellHeight,u=this._defaultConfig.gutter,c=[this.prizeArea.x+(s+u)*e,this.prizeArea.y+(h+u)*i];return r&&a&&c.push(s*r+u*(r-1),h*a+u*(a-1)),c},l.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},l.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},l.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},l.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr,e/i.dpr]},l}($);exports.LuckyGrid=H,exports.LuckyWheel=F;

@@ -15,2 +15,2 @@ /*! *****************************************************************************

***************************************************************************** */
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])},t(e,i)};function e(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");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},i.apply(this,arguments)};function n(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(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(a,s)}h((n=n.apply(t,e||[])).next())}))}function r(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}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,s])}}}function o(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});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}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},h=function(t){if("string"!=typeof t)return!1;if("transparent"===(t=t.toLocaleLowerCase().trim()))return!1;if(/^rgba/.test(t)){var e=/([^\s,]+)\)$/.exec(t);if(0===(null===(i=e)?0:"object"==typeof i?NaN:"number"==typeof i?i:"string"==typeof i?"%"===i[i.length-1]?Number(i.slice(0,-1))/100:Number(i):NaN))return!1}var i;return!0},u=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},c=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],a=t.measureText("...").width,s=0;s<e.length;s++){r+=e[s];var h=t.measureText(r).width,u=i(o);if(n===o.length+1&&(h+=a),u<0)return o;if(h>u&&(o.push(r.slice(0,-1)),r=e[s]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},l=function(t){return Math.PI/180*t},f=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=Math.min(o,a),u=Math.PI;s>h/2&&(s=h/2),t.beginPath(),t.moveTo(n+s,r),t.lineTo(n+s,r),t.lineTo(n+o-s,r),t.arc(n+o-s,r+s,s,-u/2,0),t.lineTo(n+o,r+a-s),t.arc(n+o-s,r+a-s,s,0,u/2),t.lineTo(n+s,r+a),t.arc(n+s,r+a-s,s,u/2,u),t.lineTo(n,r+s),t.arc(n+s,r+s,s,u,-u/2),t.closePath()},d=function(t,e,i,n,r,o){var a=document.createElement("canvas"),s=a.getContext("2d"),h=t.width,u=t.height;a.width=h,a.height=u;var c=h/n;return f(s,e*c,i*c,n*c,r*c,o*c),s.clip(),s.drawImage(t,0,0,h,u),a},p=function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var a=n.getImageData(0,0,r,o),s=a.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),a=[],s=0,h=-i;h<=i;h++)for(var u=-i;u<=i;u++){var c=o*Math.exp(-(h*h+u*u)/r);a.push(c),s+=c}for(var l=0;l<a.length;l++)a[l]/=s;return a}(e);return s.length,h.length,console.log(a),n.putImageData(a,0,0),i},g=function(){function t(){this.subs=[]}return t.prototype.addSub=function(t){this.subs.includes(t)||this.subs.push(t)},t.prototype.notify=function(){this.subs.forEach((function(t){t.update()}))},t}(),v="__proto__"in{};function m(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var w=Array.prototype,y=Object.create(w);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){y[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=w[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var b=function(){function t(t){this.dep=new g,m(t,"__luckyOb__",this),Array.isArray(t)&&(v?t.__proto__=y:Object.getOwnPropertyNames(y).forEach((function(e){m(t,e,y[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){x(t,e,t[e])}))},t}();function z(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new b(t)}function x(t,e,i){var n=new g,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,a=r&&r.set;o&&!a||2!==arguments.length||(i=t[e]);var s=z(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return g.target&&(n.addSub(g.target),s&&s.dep.addSub(g.target)),e},set:function(e){e!==i&&(i=e,o&&!a||(a?a.call(t,e):i=e,s=z(e),n.notify()))}})}}var C=0,I=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=C++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){g.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){a(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),g.target=null,t},t.prototype.update=function(){var t=this.get(),e=this.value;this.value=t,this.cb.call(this.$lucky,t,e)},t}(),k=function(){function t(t,e){var i=this;this.version="1.6.4",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.6.4"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){this.resize(),this.boxWidth&&this.boxHeight||console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.setDpr=function(){var t=this.config;t.dpr||(window?window.dpr=t.dpr=window.devicePixelRatio||1:t.dpr||console.error(t,"未传入 dpr 可能会导致绘制异常"))},t.prototype.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],a=r[1];i&&(i.width=o,i.height=a,i.style.width=o+"px",i.style.height=a+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},t.setTimeout=window.setTimeout,t.setInterval=window.setInterval,t.clearTimeout=window.clearTimeout,void(t.clearInterval=window.clearInterval);if(t.rAF)this.rAF=t.rAF;else if(t.setTimeout){var e=t.setTimeout;this.rAF=function(t){return e(t,16.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var a=new Image;a.onload=function(){return r(a)},a.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},a.src=t}))},t.prototype.drawImage=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n,r=this,a=r.config,s=r.ctx;if(["WEB","MP-WX"].includes(a.flag))n=t;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(a.flag))return console.error("意料之外的 flag, 该平台尚未兼容!");n=t.path}return s.drawImage.apply(s,o([n],e))},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){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var a=i.config.unitFunc;return a?a(n,r):n})))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return d.apply(void 0,o([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var a=n.getImageData(0,0,r,o),s=a.data,h=s.length,u=0;u<h;u+=4){var c=s[u+3];0!==c&&(s[u+3]=c*e/100)}n.putImageData(a,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return p(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&x(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,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new I(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),S={easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e}},T={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sin(t/n*(Math.PI/2))+e}},$={easeIn:function(t,e,i,n){return t>=n&&(t=n),0==t?e:i*Math.pow(2,10*(t/n-1))+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),t==n?e+i:i*(1-Math.pow(2,-10*t/n))+e}},O={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sqrt(1-(t=t/n-1)*t)+e}},P=Object.freeze({__proto__:null,quad:S,cubic:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t+1)+e}},quart:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*((t=t/n-1)*t*t*t-1)+e}},quint:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t*t*t+1)+e}},sine:T,expo:$,circ:O}),W=function(t){function o(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(o,t),o.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},o.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},o.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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)},o.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return i({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return i({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},o.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},o.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},o.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},o.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},o.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if(s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]),n.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(n,t)),u[i][e][o]=t,r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},o.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)]},o.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,a=n._defaultConfig,u=n._defaultStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(t,e,n){return h(e.background)&&(o.beginPath(),o.fillStyle=e.background,o.arc(0,0,t,0,2*Math.PI,!1),o.fill()),e.imgs&&e.imgs.forEach((function(e,r){var a=i.ImageCache.blocks;if(a&&a[n]){var s=a[n][r];if(s){var h=i.computedWidthAndHeight(s,e,2*t,2*t),u=h[0],c=h[1],f=[i.getOffsetX(u),i.getHeight(e.top,2*t)-t],d=f[0],p=f[1];o.save(),e.rotate&&o.rotate(l(i.rotateDeg)),i.drawImage(s,d,p,u,c),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=l(this.prizeDeg);var f=l(this.rotateDeg-90+this.prizeDeg/2+a.offsetDegree),d=function(t){return i.getOffsetX(o.measureText(t).width)},p=function(t,e,n){var r=t.lineHeight||u.lineHeight||t.fontSize||u.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=f+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,g=t.background||u.background;h(g)&&(o.fillStyle=g,function(t,e,i,n,r,o){t.beginPath();var a=l(90/Math.PI/i*o),s=l(90/Math.PI/e*o),h=n+a,u=r-a,c=n+s,f=r-s;t.arc(0,0,i,h,u,!1),t.arc(0,0,e,f,c,!0),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(a.gutter)),o.fill());var v=Math.cos(n)*i.prizeRadius,m=Math.sin(n)*i.prizeRadius;o.translate(v,m),o.rotate(n+l(90)),t.imgs&&t.imgs.forEach((function(t,n){var o=i.ImageCache.prizes;if(o&&o[e]){var a=o[e][n];if(a){var s=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,r)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,n=t.fontWeight||u.fontWeight,h=i.getLength(t.fontSize||u.fontSize),l=t.fontStyle||u.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:u.wordWrap,g=t.lengthLimit||u.lengthLimit,v=t.lineClamp||u.lineClamp;o.fillStyle=e,o.font=n+" "+(h>>0)+"px "+l;var m=String(t.text);(f?c(o,s(m),(function(e){var n=2*((i.prizeRadius-p(t,r,e.length))*Math.tan(i.prizeRadian/2))-i.getLength(a.gutter);return i.getWidth(g,n)}),v):m.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,d(e),p(t,r,i))}))})),o.rotate(l(360)-n-l(90)),o.translate(-v,-m)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var o=i.ImageCache.buttons;if(o&&o[e]){var a=o[e][r];if(a){var s=i.computedWidthAndHeight(a,t,2*n,2*n),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,n)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,r=t.fontWeight||u.fontWeight,a=i.getLength(t.fontSize||u.fontSize),s=t.fontStyle||u.fontStyle;o.fillStyle=e,o.font=r+" "+(a>>0)+"px "+s,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,d(e),p(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},o.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},o.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.rotateDeg=0,this.draw()):this.prizeFlag=t%this.prizes.length},o.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,a=e._defaultConfig;if(-1!==n){var s=Date.now()-this.startTime;if(s>=a.accelerationTime&&void 0!==n){this.FPS=s/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=(Math.random()*r-r/2)*this.getLength(a.stopRange),u=0;++u;){var c=360*u-n*r-o-a.offsetDegree+h-r/2;if(P[a.speedFunction].easeOut(this.FPS,this.stopDeg,c,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=c;break}}return this.slowDown()}this.rotateDeg=(o+P[a.speedFunction].easeIn(s,0,a.speed,a.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},o.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopDeg,a=e.endDeg,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>=s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.rotateDeg=P[s.speedFunction].easeOut(h,o,a,s.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},o.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},o.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},o.prototype.getOffsetX=function(t){return-t/2},o.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},o}(k),E=function(t){function l(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(l,t),l.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},l.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},l.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,"buttons",t.buttons||[]),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)},l.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:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return i({background:"#ffce98",shadow:""},t.activeStyle)}))},l.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("rows",(function(){return t.init()})),this.$watch("cols",(function(){return t.init()})),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("activeStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},l.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},l.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},l.prototype.handleClick=function(t){var e=this,i=this.ctx;o(o([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),a=o[0],s=o[1],h=o[2],u=o[3];i.beginPath(),i.rect(a,s,h,u),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},l.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if("buttons"===t&&!n.buttons.length&&n.button&&(s=n.button),s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]);var c=[n.loadImg(h.src,h),h.activeSrc&&n.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(c).then((function(t){var a=t[0],s=t[1],c=h.formatter;"function"==typeof c&&(a=c.call(n,a),s&&(s=c.call(n,s))),u[i][e][o]={defaultImg:a,activeImg:s},r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},l.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)]},l.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,u=n.ctx,l=n._defaultConfig,d=n._defaultStyle,p=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,u),u.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=o(o([],this.prizes),this.buttons),this.button&&this.cells.push(this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(t,e){var n=t.x,r=t.y,o=t.w,s=t.h,c=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var h={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var u in h)h[u]=Object.prototype.hasOwnProperty.call(t,u)&&a(t[u],"string","number")?~~String(t[u]).replace(/px/g,""):h[u];return[n,r,o,s]}(e),l=c[0],p=c[1],g=c[2],v=c[3],m=e.borderRadius?i.getLength(e.borderRadius):0,w=e.background||d.background;return h(w)&&(u.fillStyle=i.handleBackground(n,r,o,s,w),f(u,n,r,o,s,m),u.fill()),{x:n+g,y:r+l,w:o-g-v,h:s-l-p}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),this.cellWidth=(this.prizeArea.w-l.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-l.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(t,e){var n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),o=n[0],a=n[1],l=n[2],g=n[3],v=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(v=e===i.currIndex%i.prizes.length>>0);var m=v?p.background:t.background||d.background;if(h(m)){var w=(v?p.shadow:t.shadow||d.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===w.length&&(u.shadowColor=w[3],u.shadowOffsetX=w[0]*r.dpr,u.shadowOffsetY=w[1]*r.dpr,u.shadowBlur=w[2],w[0]>0?l-=w[0]:(l+=w[0],o-=w[0]),w[1]>0?g-=w[1]:(g+=w[1],a-=w[1])),u.fillStyle=i.handleBackground(o,a,l,g,m);var y=i.getLength(t.borderRadius?t.borderRadius:d.borderRadius);f(u,o,a,l,g,y),u.fill(),u.shadowColor="rgba(0, 0, 0, 0)",u.shadowOffsetX=0,u.shadowOffsetY=0,u.shadowBlur=0}var b="prizes";e>=i.prizes.length&&(b="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var s=i.ImageCache[b];if(s[e]){var h=s[e][r];if(h){var u=v&&h.activeImg||h.defaultImg;if(u){var c=i.computedWidthAndHeight(u,n,t),l=c[0],f=c[1],d=[o+i.getOffsetX(l,t.col),a+i.getHeight(n.top,t.row)],p=d[0],g=d[1];i.drawImage(u,p,g,l,f)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=v&&p.fontStyle?p.fontStyle:e.fontStyle||d.fontStyle,r=v&&p.fontWeight?p.fontWeight:e.fontWeight||d.fontWeight,h=v&&p.fontSize?i.getLength(p.fontSize):i.getLength(e.fontSize||d.fontSize),l=v&&p.lineHeight?p.lineHeight:e.lineHeight||d.lineHeight||e.fontSize||d.fontSize,f=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:d.wordWrap,g=e.lengthLimit||d.lengthLimit,m=e.lineClamp||d.lineClamp;u.font=r+" "+(h>>0)+"px "+n,u.fillStyle=v&&p.fontColor?p.fontColor:e.fontColor||d.fontColor;var w=[],y=String(e.text);if(f){var b=i.getWidth(g,t.col);w=c(u,s(y),(function(){return b}),m)}else w=y.split("\n");w.forEach((function(n,r){u.fillText(n,o+i.getOffsetX(u.measureText(n).width,t.col),a+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,u)},l.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var a=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),s=a.shift(),h=[0,0,0,0];if(s.includes("deg")){var u=function(t){return Math.tan(t/180*Math.PI)};(s=s.slice(0,-3)%360)>=0&&s<45?h=[e,i+r,e+n,i+r-n*u(s-0)]:s>=45&&s<90?h=[e,i+r,e+n-r*u(s-45),i]:s>=90&&s<135?h=[e+n,i+r,e+n-r*u(s-90),i]:s>=135&&s<180?h=[e+n,i+r,e,i+n*u(s-135)]:s>=180&&s<225?h=[e+n,i,e,i+n*u(s-180)]:s>=225&&s<270?h=[e+n,i,e+r*u(s-225),i+r]:s>=270&&s<315?h=[e,i,e+r*u(s-270),i+r]:s>=315&&s<360&&(h=[e,i,e+n,i+r-n*u(s-315)])}else s.includes("top")?h=[e,i+r,e,i]:s.includes("bottom")?h=[e,i,e,i+r]:s.includes("left")?h=[e+n,i,e,i]:s.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return a.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)}(o,t,e,i,n,r)),r},l.prototype.play=function(){var t=this.config.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},l.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.currIndex=0,this.draw()):this.prizeFlag=t%this.prizes.length},l.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,a=e.startTime,s=e._defaultConfig;if(-1!==o){var h=Date.now()-a;if(h>=s.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var u=0;++u;){var c=r.length*u+o-(n>>0);if(S.easeOut(this.FPS,this.stopIndex,c,s.decelerationTime)-this.stopIndex>s.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+S.easeIn(h,.1,s.speed,s.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},l.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopIndex,a=e.endIndex,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.currIndex=S.easeOut(h,o,a,s.decelerationTime)%n.length,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},l.prototype.walk=function(){var t=this,e=this.config,i=e.setInterval;(0,e.clearInterval)(this.timer),this.timer=i((function(){t.currIndex+=1,t.draw()}),1300)},l.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],a=void 0===o?1:o,s=this.cellWidth,h=this.cellHeight,u=this._defaultConfig.gutter,c=[this.prizeArea.x+(s+u)*e,this.prizeArea.y+(h+u)*i];return r&&a&&c.push(s*r+u*(r-1),h*a+u*(a-1)),c},l.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},l.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},l.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},l.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr,e/i.dpr]},l}(k);export{E as LuckyGrid,W as LuckyWheel};
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])},t(e,i)};function e(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");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},i.apply(this,arguments)};function n(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(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(a,s)}h((n=n.apply(t,e||[])).next())}))}function r(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}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,s])}}}function o(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});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}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},h=function(t){if("string"!=typeof t)return!1;if("transparent"===(t=t.toLocaleLowerCase().trim()))return!1;if(/^rgba/.test(t)){var e=/([^\s,]+)\)$/.exec(t);if(0===(null===(i=e)?0:"object"==typeof i?NaN:"number"==typeof i?i:"string"==typeof i?"%"===i[i.length-1]?Number(i.slice(0,-1))/100:Number(i):NaN))return!1}var i;return!0},u=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},c=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],a=t.measureText("...").width,s=0;s<e.length;s++){r+=e[s];var h=t.measureText(r).width,u=i(o);if(n===o.length+1&&(h+=a),u<0)return o;if(h>u&&(o.push(r.slice(0,-1)),r=e[s]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},l=function(t){return Math.PI/180*t},f=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},d=function(t,e){var i=-t/e;return[i,-i*t+e]},p=function(t,e,i,n,r,o){var a;if(void 0===o&&(o=!0),Math.abs(r-n).toFixed(8)>=l(180).toFixed(8)){var s=(r+n)/2;return o?(p(t,e,i,n,s,o),p(t,e,i,s,r,o)):(p(t,e,i,s,r,o),p(t,e,i,n,s,o)),!1}o||(n=(a=[r,n])[0],r=a[1]);var h=f(n,i),u=h[0],c=h[1],g=f(r,i),v=g[0],m=g[1],w=d(u,c),y=w[0],b=w[1],x=d(v,m),z=x[0],C=x[1],I=(C-b)/(y-z),k=(z*b-y*C)/(z-y);isNaN(I)&&(Math.abs(u)===+i.toFixed(8)&&(I=u),Math.abs(v)===+i.toFixed(8)&&(I=v)),y===1/0||y===-1/0?k=z*I+C:z!==1/0&&z!==-1/0||(k=y*I+b),e.lineTo(u,c),t.indexOf("MP")>0?e.quadraticCurveTo(I,k,v,m):e.arcTo(I,k,v,m,i)},g=function(t,e,i,n,r,o,a,s){i||(i=a);var h=l(90/Math.PI/n*a),u=l(90/Math.PI/i*a),c=r+h,d=o-h,g=r+u,v=o-u;e.beginPath(),e.fillStyle=s,e.moveTo.apply(e,f(c,n)),p(t,e,n,c,d,!0),v>g?p(t,e,i,g,v,!1):e.lineTo.apply(e,f((r+o)/2,a/2/Math.abs(Math.sin((r-o)/2)))),e.closePath(),e.fill()},v=function(t,e,i,n,r,o){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),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)},m=function(t,e,i,n,r,o,a){t.fillStyle=a,v(t,e,i,n,r,o),t.closePath(),t.fill()},w=function(t,e,i,n,r,o){var a=document.createElement("canvas"),s=a.getContext("2d"),h=t.width,u=t.height;a.width=h,a.height=u;var c=h/n;return v(s,e*c,i*c,n*c,r*c,o*c),s.clip(),s.drawImage(t,0,0,h,u),a},y=function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var a=n.getImageData(0,0,r,o),s=a.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),a=[],s=0,h=-i;h<=i;h++)for(var u=-i;u<=i;u++){var c=o*Math.exp(-(h*h+u*u)/r);a.push(c),s+=c}for(var l=0;l<a.length;l++)a[l]/=s;return a}(e);return s.length,h.length,console.log(a),n.putImageData(a,0,0),i},b=function(){function t(){this.subs=[]}return t.prototype.addSub=function(t){this.subs.includes(t)||this.subs.push(t)},t.prototype.notify=function(){this.subs.forEach((function(t){t.update()}))},t}(),x="__proto__"in{};function z(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var C=Array.prototype,I=Object.create(C);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){I[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=C[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var k=function(){function t(t){this.dep=new b,z(t,"__luckyOb__",this),Array.isArray(t)&&(x?t.__proto__=I:Object.getOwnPropertyNames(I).forEach((function(e){z(t,e,I[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){T(t,e,t[e])}))},t}();function S(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new k(t)}function T(t,e,i){var n=new b,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,a=r&&r.set;o&&!a||2!==arguments.length||(i=t[e]);var s=S(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return b.target&&(n.addSub(b.target),s&&s.dep.addSub(b.target)),e},set:function(e){e!==i&&(i=e,o&&!a||(a?a.call(t,e):i=e,s=S(e),n.notify()))}})}}var O=0,P=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=O++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){b.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){a(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),b.target=null,t},t.prototype.update=function(){var t=this.get(),e=this.value;this.value=t,this.cb.call(this.$lucky,t,e)},t}(),$=function(){function t(t,e){var i=this;this.version="1.6.3",this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.6.3"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){this.resize(),this.boxWidth&&this.boxHeight||console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.setDpr=function(){var t=this.config;t.dpr||(window?window.dpr=t.dpr=window.devicePixelRatio||1:t.dpr||console.error(t,"未传入 dpr 可能会导致绘制异常"))},t.prototype.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],a=r[1];i&&(i.width=o,i.height=a,i.style.width=o+"px",i.style.height=a+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},t.setTimeout=window.setTimeout,t.setInterval=window.setInterval,t.clearTimeout=window.clearTimeout,void(t.clearInterval=window.clearInterval);if(t.rAF)this.rAF=t.rAF;else if(t.setTimeout){var e=t.setTimeout;this.rAF=function(t){return e(t,16.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var a=new Image;a.onload=function(){return r(a)},a.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},a.src=t}))},t.prototype.drawImage=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n,r=this,a=r.config,s=r.ctx;if(["WEB","MP-WX"].includes(a.flag))n=t;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(a.flag))return console.error("意料之外的 flag, 该平台尚未兼容!");n=t.path}return s.drawImage.apply(s,o([n],e))},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){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var a=i.config.unitFunc;return a?a(n,r):n})))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return w.apply(void 0,o([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var a=n.getImageData(0,0,r,o),s=a.data,h=s.length,u=0;u<h;u+=4){var c=s[u+3];0!==c&&(s[u+3]=c*e/100)}n.putImageData(a,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return y(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&T(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,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new P(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),W={easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e}},E={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sin(t/n*(Math.PI/2))+e}},R={easeIn:function(t,e,i,n){return t>=n&&(t=n),0==t?e:i*Math.pow(2,10*(t/n-1))+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),t==n?e+i:i*(1-Math.pow(2,-10*t/n))+e}},_={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sqrt(1-(t=t/n-1)*t)+e}},D=Object.freeze({__proto__:null,quad:W,cubic:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t+1)+e}},quart:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*((t=t/n-1)*t*t*t-1)+e}},quint:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t*t*t+1)+e}},sine:E,expo:R,circ:_}),F=function(t){function o(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(o,t),o.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},o.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},o.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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)},o.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return i({gutter:"0px",offsetDegree:0,speed:20,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return i({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},o.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},o.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},o.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},o.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},o.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if(s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]),n.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(n,t)),u[i][e][o]=t,r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},o.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)]},o.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,o=n.ctx,a=n._defaultConfig,u=n._defaultStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(t,e,n){return h(e.background)&&(o.beginPath(),o.fillStyle=e.background,o.arc(0,0,t,0,2*Math.PI,!1),o.fill()),e.imgs&&e.imgs.forEach((function(e,r){var a=i.ImageCache.blocks;if(a&&a[n]){var s=a[n][r];if(s){var h=i.computedWidthAndHeight(s,e,2*t,2*t),u=h[0],c=h[1],f=[i.getOffsetX(u),i.getHeight(e.top,2*t)-t],d=f[0],p=f[1];o.save(),e.rotate&&o.rotate(l(i.rotateDeg)),i.drawImage(s,d,p,u,c),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=l(this.prizeDeg);var f=l(this.rotateDeg-90+this.prizeDeg/2+a.offsetDegree),d=function(t){return i.getOffsetX(o.measureText(t).width)},p=function(t,e,n){var r=t.lineHeight||u.lineHeight||t.fontSize||u.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=f+e*i.prizeRadian,v=i.prizeRadius-i.maxBtnRadius,m=t.background||u.background;h(m)&&function(t,e,i,n,r,o,a,s){a?g(t,e,i,n,r,o,a,s):(e.beginPath(),e.fillStyle=s,e.moveTo(0,0),e.arc(0,0,n,r,o,!1),e.closePath(),e.fill())}(r.flag,o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(a.gutter),m);var w=Math.cos(n)*i.prizeRadius,y=Math.sin(n)*i.prizeRadius;o.translate(w,y),o.rotate(n+l(90)),t.imgs&&t.imgs.forEach((function(t,n){var r=i.ImageCache.prizes;if(r&&r[e]){var o=r[e][n];if(o){var a=i.computedWidthAndHeight(o,t,i.prizeRadian*i.prizeRadius,v),s=a[0],h=a[1],u=[i.getOffsetX(s),i.getHeight(t.top,v)],c=u[0],l=u[1];i.drawImage(o,c,l,s,h)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,n=t.fontWeight||u.fontWeight,r=i.getLength(t.fontSize||u.fontSize),h=t.fontStyle||u.fontStyle,l=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:u.wordWrap,f=t.lengthLimit||u.lengthLimit,g=t.lineClamp||u.lineClamp;o.fillStyle=e,o.font=n+" "+(r>>0)+"px "+h;var m=String(t.text);(l?c(o,s(m),(function(e){var n=2*((i.prizeRadius-p(t,v,e.length))*Math.tan(i.prizeRadian/2))-i.getLength(a.gutter);return i.getWidth(f,n)}),g):m.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,d(e),p(t,v,i))}))})),o.rotate(l(360)-n-l(90)),o.translate(-w,-y)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&h(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var o=i.ImageCache.buttons;if(o&&o[e]){var a=o[e][r];if(a){var s=i.computedWidthAndHeight(a,t,2*n,2*n),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,n)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||u.fontColor,r=t.fontWeight||u.fontWeight,a=i.getLength(t.fontSize||u.fontSize),s=t.fontStyle||u.fontStyle;o.fillStyle=e,o.font=r+" "+(a>>0)+"px "+s,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,d(e),p(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},o.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},o.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.rotateDeg=0,this.draw()):this.prizeFlag=t%this.prizes.length},o.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.prizeFlag,r=e.prizeDeg,o=e.rotateDeg,a=e._defaultConfig;if(-1!==n){var s=Date.now()-this.startTime;if(s>=a.accelerationTime&&void 0!==n){this.FPS=s/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=(Math.random()*r-r/2)*this.getLength(a.stopRange),u=0;++u;){var c=360*u-n*r-o-a.offsetDegree+h-r/2;if(D[a.speedFunction].easeOut(this.FPS,this.stopDeg,c,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=c;break}}return this.slowDown()}this.rotateDeg=(o+D[a.speedFunction].easeIn(s,0,a.speed,a.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},o.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopDeg,a=e.endDeg,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>=s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.rotateDeg=D[s.speedFunction].easeOut(h,o,a,s.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},o.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},o.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),a(t,"number")?t:a(t,"string")?this.changeUnits(t,e):0},o.prototype.getOffsetX=function(t){return-t/2},o.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},o}($),H=function(t){function l(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return e(l,t),l.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},l.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},l.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,"buttons",t.buttons||[]),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)},l.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:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return i({background:"#ffce98",shadow:""},t.activeStyle)}))},l.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("rows",(function(){return t.init()})),this.$watch("cols",(function(){return t.init()})),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("activeStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},l.prototype.init=function(){var t,e;return n(this,void 0,void 0,(function(){var i;return r(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},l.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},l.prototype.handleClick=function(t){var e=this,i=this.ctx;o(o([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),a=o[0],s=o[1],h=o[2],u=o[3];i.beginPath(),i.rect(a,s,h,u),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},l.prototype.loadAndCacheImg=function(t,e,i,o){return n(this,void 0,void 0,(function(){var n=this;return r(this,(function(r){return[2,new Promise((function(r,a){var s=n[t][e];if("buttons"===t&&!n.buttons.length&&n.button&&(s=n.button),s&&s.imgs){var h=s.imgs[o];if(h){var u=n.ImageCache;u[i][e]||(u[i][e]=[]);var c=[n.loadImg(h.src,h),h.activeSrc&&n.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(c).then((function(t){var a=t[0],s=t[1],c=h.formatter;"function"==typeof c&&(a=c.call(n,a),s&&(s=c.call(n,s))),u[i][e][o]={defaultImg:a,activeImg:s},r()})).catch((function(i){console.error(t+"["+e+"].imgs["+o+"] "+i),a()}))}}}))]}))}))},l.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)]},l.prototype.draw=function(){var t,e,i=this,n=this,r=n.config,u=n.ctx,l=n._defaultConfig,f=n._defaultStyle,d=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,u),u.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=o(o([],this.prizes),this.buttons),this.button&&this.cells.push(this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(t,e){var n=t.x,r=t.y,o=t.w,s=t.h,c=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,s=0;switch(i.length){case 1:n=r=o=s=i[0];break;case 2:n=r=i[0],o=s=i[1];break;case 3:n=i[0],o=s=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],s=i[3]}var h={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:s};for(var u in h)h[u]=Object.prototype.hasOwnProperty.call(t,u)&&a(t[u],"string","number")?~~String(t[u]).replace(/px/g,""):h[u];return[n,r,o,s]}(e),l=c[0],d=c[1],p=c[2],g=c[3],v=e.borderRadius?i.getLength(e.borderRadius):0,w=e.background||f.background;return h(w)&&m(u,n,r,o,s,v,i.handleBackground(n,r,o,s,w)),{x:n+p,y:r+l,w:o-p-g,h:s-l-d}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),this.cellWidth=(this.prizeArea.w-l.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-l.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(t,e){var n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),o=n[0],a=n[1],l=n[2],p=n[3],g=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(g=e===i.currIndex%i.prizes.length>>0);var v=g?d.background:t.background||f.background;if(h(v)){var w=(g?d.shadow:t.shadow||f.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===w.length&&(u.shadowColor=w[3],u.shadowOffsetX=w[0]*r.dpr,u.shadowOffsetY=w[1]*r.dpr,u.shadowBlur=w[2],w[0]>0?l-=w[0]:(l+=w[0],o-=w[0]),w[1]>0?p-=w[1]:(p+=w[1],a-=w[1])),m(u,o,a,l,p,i.getLength(t.borderRadius?t.borderRadius:f.borderRadius),i.handleBackground(o,a,l,p,v)),u.shadowColor="rgba(0, 0, 0, 0)",u.shadowOffsetX=0,u.shadowOffsetY=0,u.shadowBlur=0}var y="prizes";e>=i.prizes.length&&(y="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var s=i.ImageCache[y];if(s[e]){var h=s[e][r];if(h){var u=g&&h.activeImg||h.defaultImg;if(u){var c=i.computedWidthAndHeight(u,n,t),l=c[0],f=c[1],d=[o+i.getOffsetX(l,t.col),a+i.getHeight(n.top,t.row)],p=d[0],v=d[1];i.drawImage(u,p,v,l,f)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=g&&d.fontStyle?d.fontStyle:e.fontStyle||f.fontStyle,r=g&&d.fontWeight?d.fontWeight:e.fontWeight||f.fontWeight,h=g&&d.fontSize?i.getLength(d.fontSize):i.getLength(e.fontSize||f.fontSize),l=g&&d.lineHeight?d.lineHeight:e.lineHeight||f.lineHeight||e.fontSize||f.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:f.wordWrap,v=e.lengthLimit||f.lengthLimit,m=e.lineClamp||f.lineClamp;u.font=r+" "+(h>>0)+"px "+n,u.fillStyle=g&&d.fontColor?d.fontColor:e.fontColor||f.fontColor;var w=[],y=String(e.text);if(p){var b=i.getWidth(v,t.col);w=c(u,s(y),(function(){return b}),m)}else w=y.split("\n");w.forEach((function(n,r){u.fillText(n,o+i.getOffsetX(u.measureText(n).width,t.col),a+i.getHeight(e.top,t.row)+(r+1)*i.getLength(l))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,u)},l.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var a=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),s=a.shift(),h=[0,0,0,0];if(s.includes("deg")){var u=function(t){return Math.tan(t/180*Math.PI)};(s=s.slice(0,-3)%360)>=0&&s<45?h=[e,i+r,e+n,i+r-n*u(s-0)]:s>=45&&s<90?h=[e,i+r,e+n-r*u(s-45),i]:s>=90&&s<135?h=[e+n,i+r,e+n-r*u(s-90),i]:s>=135&&s<180?h=[e+n,i+r,e,i+n*u(s-135)]:s>=180&&s<225?h=[e+n,i,e,i+n*u(s-180)]:s>=225&&s<270?h=[e+n,i,e+r*u(s-225),i+r]:s>=270&&s<315?h=[e,i,e+r*u(s-270),i+r]:s>=315&&s<360&&(h=[e,i,e+n,i+r-n*u(s-315)])}else s.includes("top")?h=[e,i+r,e,i]:s.includes("bottom")?h=[e,i,e,i+r]:s.includes("left")?h=[e+n,i,e,i]:s.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return a.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)}(o,t,e,i,n,r)),r},l.prototype.play=function(){var t=this.config.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},l.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=u(e)}t<0?(this.prizeFlag=-1,this.currIndex=0,this.draw()):this.prizeFlag=t%this.prizes.length},l.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.currIndex,r=e.prizes,o=e.prizeFlag,a=e.startTime,s=e._defaultConfig;if(-1!==o){var h=Date.now()-a;if(h>=s.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var u=0;++u;){var c=r.length*u+o-(n>>0);if(W.easeOut(this.FPS,this.stopIndex,c,s.decelerationTime)-this.stopIndex>s.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+W.easeIn(h,.1,s.speed,s.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},l.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopIndex,a=e.endIndex,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.currIndex=W.easeOut(h,o,a,s.decelerationTime)%n.length,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},l.prototype.walk=function(){var t=this,e=this.config,i=e.setInterval;(0,e.clearInterval)(this.timer),this.timer=i((function(){t.currIndex+=1,t.draw()}),1300)},l.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],a=void 0===o?1:o,s=this.cellWidth,h=this.cellHeight,u=this._defaultConfig.gutter,c=[this.prizeArea.x+(s+u)*e,this.prizeArea.y+(h+u)*i];return r&&a&&c.push(s*r+u*(r-1),h*a+u*(a-1)),c},l.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},l.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},l.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},l.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr,e/i.dpr]},l}($);export{H as LuckyGrid,F as LuckyWheel};

@@ -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])},e(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");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},n.apply(this,arguments)};function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(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(a,s)}h((n=n.apply(t,e||[])).next())}))}function o(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}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,s])}}}function a(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});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}))},h=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},u=function(t){if("string"!=typeof t)return!1;if("transparent"===(t=t.toLocaleLowerCase().trim()))return!1;if(/^rgba/.test(t)){var e=/([^\s,]+)\)$/.exec(t);if(0===(null===(i=e)?0:"object"==typeof i?NaN:"number"==typeof i?i:"string"==typeof i?"%"===i[i.length-1]?Number(i.slice(0,-1))/100:Number(i):NaN))return!1}var i;return!0},c=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},l=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],a=t.measureText("...").width,s=0;s<e.length;s++){r+=e[s];var h=t.measureText(r).width,u=i(o);if(n===o.length+1&&(h+=a),u<0)return o;if(h>u&&(o.push(r.slice(0,-1)),r=e[s]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},f=function(t){return Math.PI/180*t},d=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=e[0],r=e[1],o=e[2],a=e[3],s=e[4],h=Math.min(o,a),u=Math.PI;s>h/2&&(s=h/2),t.beginPath(),t.moveTo(n+s,r),t.lineTo(n+s,r),t.lineTo(n+o-s,r),t.arc(n+o-s,r+s,s,-u/2,0),t.lineTo(n+o,r+a-s),t.arc(n+o-s,r+a-s,s,0,u/2),t.lineTo(n+s,r+a),t.arc(n+s,r+a-s,s,u/2,u),t.lineTo(n,r+s),t.arc(n+s,r+s,s,u,-u/2),t.closePath()},p=function(t,e,i,n,r,o){var a=document.createElement("canvas"),s=a.getContext("2d"),h=t.width,u=t.height;a.width=h,a.height=u;var c=h/n;return d(s,e*c,i*c,n*c,r*c,o*c),s.clip(),s.drawImage(t,0,0,h,u),a},g=function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var a=n.getImageData(0,0,r,o),s=a.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),a=[],s=0,h=-i;h<=i;h++)for(var u=-i;u<=i;u++){var c=o*Math.exp(-(h*h+u*u)/r);a.push(c),s+=c}for(var l=0;l<a.length;l++)a[l]/=s;return a}(e);return s.length,h.length,console.log(a),n.putImageData(a,0,0),i},v="1.6.4",m=function(){function t(){this.subs=[]}return t.prototype.addSub=function(t){this.subs.includes(t)||this.subs.push(t)},t.prototype.notify=function(){this.subs.forEach((function(t){t.update()}))},t}(),w="__proto__"in{};function y(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var b=Array.prototype,z=Object.create(b);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){z[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=b[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var x=function(){function t(t){this.dep=new m,y(t,"__luckyOb__",this),Array.isArray(t)&&(w?t.__proto__=z:Object.getOwnPropertyNames(z).forEach((function(e){y(t,e,z[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){I(t,e,t[e])}))},t}();function C(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new x(t)}function I(t,e,i){var n=new m,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,a=r&&r.set;o&&!a||2!==arguments.length||(i=t[e]);var s=C(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return m.target&&(n.addSub(m.target),s&&s.dep.addSub(m.target)),e},set:function(e){e!==i&&(i=e,o&&!a||(a?a.call(t,e):i=e,s=C(e),n.notify()))}})}}var k=0,S=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=k++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){m.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){s(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),m.target=null,t},t.prototype.update=function(){var t=this.get(),e=this.value;this.value=t,this.cb.call(this.$lucky,t,e)},t}(),T=function(){function t(t,e){var i=this;this.version=v,this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.6.4"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){this.resize(),this.boxWidth&&this.boxHeight||console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.setDpr=function(){var t=this.config;t.dpr||(window?window.dpr=t.dpr=window.devicePixelRatio||1:t.dpr||console.error(t,"未传入 dpr 可能会导致绘制异常"))},t.prototype.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],a=r[1];i&&(i.width=o,i.height=a,i.style.width=o+"px",i.style.height=a+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},t.setTimeout=window.setTimeout,t.setInterval=window.setInterval,t.clearTimeout=window.clearTimeout,void(t.clearInterval=window.clearInterval);if(t.rAF)this.rAF=t.rAF;else if(t.setTimeout){var e=t.setTimeout;this.rAF=function(t){return e(t,16.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var a=new Image;a.onload=function(){return r(a)},a.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},a.src=t}))},t.prototype.drawImage=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n,r=this,o=r.config,s=r.ctx;if(["WEB","MP-WX"].includes(o.flag))n=t;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(o.flag))return console.error("意料之外的 flag, 该平台尚未兼容!");n=t.path}return s.drawImage.apply(s,a([n],e))},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){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var a=i.config.unitFunc;return a?a(n,r):n})))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return p.apply(void 0,a([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var a=n.getImageData(0,0,r,o),s=a.data,h=s.length,u=0;u<h;u+=4){var c=s[u+3];0!==c&&(s[u+3]=c*e/100)}n.putImageData(a,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return g(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&I(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,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new S(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),O={easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e}},$={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sin(t/n*(Math.PI/2))+e}},P={easeIn:function(t,e,i,n){return t>=n&&(t=n),0==t?e:i*Math.pow(2,10*(t/n-1))+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),t==n?e+i:i*(1-Math.pow(2,-10*t/n))+e}},W={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sqrt(1-(t=t/n-1)*t)+e}},_=Object.freeze({__proto__:null,quad:O,cubic:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t+1)+e}},quart:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*((t=t/n-1)*t*t*t-1)+e}},quint:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t*t*t+1)+e}},sine:$,expo:P,circ:W}),E=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return i(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return r(this,void 0,void 0,(function(){var i;return o(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return r(this,void 0,void 0,(function(){var r=this;return o(this,(function(o){return[2,new Promise((function(o,a){var s=r[t][e];if(s&&s.imgs){var h=s.imgs[n];if(h){var u=r.ImageCache;u[i][e]||(u[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),u[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),a()}))}}}))]}))}))},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,e,i=this,n=this,r=n.config,o=n.ctx,a=n._defaultConfig,s=n._defaultStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(t,e,n){return u(e.background)&&(o.beginPath(),o.fillStyle=e.background,o.arc(0,0,t,0,2*Math.PI,!1),o.fill()),e.imgs&&e.imgs.forEach((function(e,r){var a=i.ImageCache.blocks;if(a&&a[n]){var s=a[n][r];if(s){var h=i.computedWidthAndHeight(s,e,2*t,2*t),u=h[0],c=h[1],l=[i.getOffsetX(u),i.getHeight(e.top,2*t)-t],d=l[0],p=l[1];o.save(),e.rotate&&o.rotate(f(i.rotateDeg)),i.drawImage(s,d,p,u,c),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=f(this.prizeDeg);var c=f(this.rotateDeg-90+this.prizeDeg/2+a.offsetDegree),d=function(t){return i.getOffsetX(o.measureText(t).width)},p=function(t,e,n){var r=t.lineHeight||s.lineHeight||t.fontSize||s.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=c+e*i.prizeRadian,r=i.prizeRadius-i.maxBtnRadius,g=t.background||s.background;u(g)&&(o.fillStyle=g,function(t,e,i,n,r,o){t.beginPath();var a=f(90/Math.PI/i*o),s=f(90/Math.PI/e*o),h=n+a,u=r-a,c=n+s,l=r-s;t.arc(0,0,i,h,u,!1),t.arc(0,0,e,l,c,!0),t.closePath()}(o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(a.gutter)),o.fill());var v=Math.cos(n)*i.prizeRadius,m=Math.sin(n)*i.prizeRadius;o.translate(v,m),o.rotate(n+f(90)),t.imgs&&t.imgs.forEach((function(t,n){var o=i.ImageCache.prizes;if(o&&o[e]){var a=o[e][n];if(a){var s=i.computedWidthAndHeight(a,t,i.prizeRadian*i.prizeRadius,r),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,r)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||s.fontColor,n=t.fontWeight||s.fontWeight,u=i.getLength(t.fontSize||s.fontSize),c=t.fontStyle||s.fontStyle,f=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:s.wordWrap,g=t.lengthLimit||s.lengthLimit,v=t.lineClamp||s.lineClamp;o.fillStyle=e,o.font=n+" "+(u>>0)+"px "+c;var m=String(t.text);(f?l(o,h(m),(function(e){var n=2*((i.prizeRadius-p(t,r,e.length))*Math.tan(i.prizeRadian/2))-i.getLength(a.gutter);return i.getWidth(g,n)}),v):m.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,d(e),p(t,r,i))}))})),o.rotate(f(360)-n-f(90)),o.translate(-v,-m)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),u(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&u(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var o=i.ImageCache.buttons;if(o&&o[e]){var a=o[e][r];if(a){var s=i.computedWidthAndHeight(a,t,2*n,2*n),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,n)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||s.fontColor,r=t.fontWeight||s.fontWeight,a=i.getLength(t.fontSize||s.fontSize),h=t.fontStyle||s.fontStyle;o.fillStyle=e,o.font=r+" "+(a>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,d(e),p(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=c(e)}t<0?(this.prizeFlag=-1,this.rotateDeg=0,this.draw()):this.prizeFlag=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,a=e._defaultConfig;if(-1!==n){var s=Date.now()-this.startTime;if(s>=a.accelerationTime&&void 0!==n){this.FPS=s/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=(Math.random()*r-r/2)*this.getLength(a.stopRange),u=0;++u;){var c=360*u-n*r-o-a.offsetDegree+h-r/2;if(_[a.speedFunction].easeOut(this.FPS,this.stopDeg,c,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=c;break}}return this.slowDown()}this.rotateDeg=(o+_[a.speedFunction].easeIn(s,0,a.speed,a.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopDeg,a=e.endDeg,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>=s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.rotateDeg=_[s.speedFunction].easeOut(h,o,a,s.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},e.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},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),s(t,"number")?t:s(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(T),R=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return i(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,"buttons",t.buttons||[]),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:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",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("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("rows",(function(){return t.init()})),this.$watch("cols",(function(){return t.init()})),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("activeStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return r(this,void 0,void 0,(function(){var i;return o(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;a(a([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),a=o[0],s=o[1],h=o[2],u=o[3];i.beginPath(),i.rect(a,s,h,u),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return r(this,void 0,void 0,(function(){var r=this;return o(this,(function(o){return[2,new Promise((function(o,a){var s=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(s=r.button),s&&s.imgs){var h=s.imgs[n];if(h){var u=r.ImageCache;u[i][e]||(u[i][e]=[]);var c=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(c).then((function(t){var a=t[0],s=t[1],c=h.formatter;"function"==typeof c&&(a=c.call(r,a),s&&(s=c.call(r,s))),u[i][e][n]={defaultImg:a,activeImg:s},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),a()}))}}}))]}))}))},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,e,i=this,n=this,r=n.config,o=n.ctx,c=n._defaultConfig,f=n._defaultStyle,p=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=a(a([],this.prizes),this.buttons),this.button&&this.cells.push(this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(t,e){var n=t.x,r=t.y,a=t.w,h=t.h,c=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,a=0;switch(i.length){case 1:n=r=o=a=i[0];break;case 2:n=r=i[0],o=a=i[1];break;case 3:n=i[0],o=a=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],a=i[3]}var h={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:a};for(var u in h)h[u]=Object.prototype.hasOwnProperty.call(t,u)&&s(t[u],"string","number")?~~String(t[u]).replace(/px/g,""):h[u];return[n,r,o,a]}(e),l=c[0],p=c[1],g=c[2],v=c[3],m=e.borderRadius?i.getLength(e.borderRadius):0,w=e.background||f.background;return u(w)&&(o.fillStyle=i.handleBackground(n,r,a,h,w),d(o,n,r,a,h,m),o.fill()),{x:n+g,y:r+l,w:a-g-v,h:h-l-p}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),this.cellWidth=(this.prizeArea.w-c.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-c.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(t,e){var n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),a=n[0],s=n[1],c=n[2],g=n[3],v=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(v=e===i.currIndex%i.prizes.length>>0);var m=v?p.background:t.background||f.background;if(u(m)){var w=(v?p.shadow:t.shadow||f.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===w.length&&(o.shadowColor=w[3],o.shadowOffsetX=w[0]*r.dpr,o.shadowOffsetY=w[1]*r.dpr,o.shadowBlur=w[2],w[0]>0?c-=w[0]:(c+=w[0],a-=w[0]),w[1]>0?g-=w[1]:(g+=w[1],s-=w[1])),o.fillStyle=i.handleBackground(a,s,c,g,m);var y=i.getLength(t.borderRadius?t.borderRadius:f.borderRadius);d(o,a,s,c,g,y),o.fill(),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var b="prizes";e>=i.prizes.length&&(b="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var o=i.ImageCache[b];if(o[e]){var h=o[e][r];if(h){var u=v&&h.activeImg||h.defaultImg;if(u){var c=i.computedWidthAndHeight(u,n,t),l=c[0],f=c[1],d=[a+i.getOffsetX(l,t.col),s+i.getHeight(n.top,t.row)],p=d[0],g=d[1];i.drawImage(u,p,g,l,f)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=v&&p.fontStyle?p.fontStyle:e.fontStyle||f.fontStyle,r=v&&p.fontWeight?p.fontWeight:e.fontWeight||f.fontWeight,u=v&&p.fontSize?i.getLength(p.fontSize):i.getLength(e.fontSize||f.fontSize),c=v&&p.lineHeight?p.lineHeight:e.lineHeight||f.lineHeight||e.fontSize||f.fontSize,d=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:f.wordWrap,g=e.lengthLimit||f.lengthLimit,m=e.lineClamp||f.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=v&&p.fontColor?p.fontColor:e.fontColor||f.fontColor;var w=[],y=String(e.text);if(d){var b=i.getWidth(g,t.col);w=l(o,h(y),(function(){return b}),m)}else w=y.split("\n");w.forEach((function(n,r){o.fillText(n,a+i.getOffsetX(o.measureText(n).width,t.col),s+i.getHeight(e.top,t.row)+(r+1)*i.getLength(c))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var a=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),s=a.shift(),h=[0,0,0,0];if(s.includes("deg")){var u=function(t){return Math.tan(t/180*Math.PI)};(s=s.slice(0,-3)%360)>=0&&s<45?h=[e,i+r,e+n,i+r-n*u(s-0)]:s>=45&&s<90?h=[e,i+r,e+n-r*u(s-45),i]:s>=90&&s<135?h=[e+n,i+r,e+n-r*u(s-90),i]:s>=135&&s<180?h=[e+n,i+r,e,i+n*u(s-135)]:s>=180&&s<225?h=[e+n,i,e,i+n*u(s-180)]:s>=225&&s<270?h=[e+n,i,e+r*u(s-225),i+r]:s>=270&&s<315?h=[e,i,e+r*u(s-270),i+r]:s>=315&&s<360&&(h=[e,i,e+n,i+r-n*u(s-315)])}else s.includes("top")?h=[e,i+r,e,i]:s.includes("bottom")?h=[e,i,e,i+r]:s.includes("left")?h=[e+n,i,e,i]:s.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return a.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)}(o,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.config.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=c(e)}t<0?(this.prizeFlag=-1,this.currIndex=0,this.draw()):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,a=e.startTime,s=e._defaultConfig;if(-1!==o){var h=Date.now()-a;if(h>=s.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var u=0;++u;){var c=r.length*u+o-(n>>0);if(O.easeOut(this.FPS,this.stopIndex,c,s.decelerationTime)-this.stopIndex>s.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+O.easeIn(h,.1,s.speed,s.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopIndex,a=e.endIndex,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.currIndex=O.easeOut(h,o,a,s.decelerationTime)%n.length,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},e.prototype.walk=function(){var t=this,e=this.config,i=e.setInterval;(0,e.clearInterval)(this.timer),this.timer=i((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],a=void 0===o?1:o,s=this.cellWidth,h=this.cellHeight,u=this._defaultConfig.gutter,c=[this.prizeArea.x+(s+u)*e,this.prizeArea.y+(h+u)*i];return r&&a&&c.push(s*r+u*(r-1),h*a+u*(a-1)),c},e.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},e.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},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr,e/i.dpr]},e}(T);t.LuckyGrid=R,t.LuckyWheel=E,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])},e(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");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},n.apply(this,arguments)};function r(t,e,i,n){return new(i||(i=Promise))((function(r,o){function a(t){try{h(n.next(t))}catch(t){o(t)}}function s(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(a,s)}h((n=n.apply(t,e||[])).next())}))}function o(t,e){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}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,s])}}}function a(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t}String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var o=e[r];if(t.call(n,o,r,e))return o;r++}}});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}))},h=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},u=function(t){if("string"!=typeof t)return!1;if("transparent"===(t=t.toLocaleLowerCase().trim()))return!1;if(/^rgba/.test(t)){var e=/([^\s,]+)\)$/.exec(t);if(0===(null===(i=e)?0:"object"==typeof i?NaN:"number"==typeof i?i:"string"==typeof i?"%"===i[i.length-1]?Number(i.slice(0,-1))/100:Number(i):NaN))return!1}var i;return!0},c=function(t){var e=[],i=t.map((function(t){return Number(t)})).reduce((function(t,i){if(i>0){var n=t+i;return e.push(n),n}return e.push(NaN),t}),0),n=Math.random()*i;return e.findIndex((function(t){return n<=t}))},l=function(t,e,i,n){void 0===n&&(n=1/0),n<=0&&(n=1/0);for(var r="",o=[],a=t.measureText("...").width,s=0;s<e.length;s++){r+=e[s];var h=t.measureText(r).width,u=i(o);if(n===o.length+1&&(h+=a),u<0)return o;if(h>u&&(o.push(r.slice(0,-1)),r=e[s]),n===o.length)return o[o.length-1]+="...",o}return r&&o.push(r),o.length||o.push(e),o},f=function(t){return Math.PI/180*t},d=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},p=function(t,e){var i=-t/e;return[i,-i*t+e]},g=function(t,e,i,n,r,o){var a;if(void 0===o&&(o=!0),Math.abs(r-n).toFixed(8)>=f(180).toFixed(8)){var s=(r+n)/2;return o?(g(t,e,i,n,s,o),g(t,e,i,s,r,o)):(g(t,e,i,s,r,o),g(t,e,i,n,s,o)),!1}o||(n=(a=[r,n])[0],r=a[1]);var h=d(n,i),u=h[0],c=h[1],l=d(r,i),v=l[0],m=l[1],w=p(u,c),y=w[0],b=w[1],x=p(v,m),z=x[0],C=x[1],I=(C-b)/(y-z),k=(z*b-y*C)/(z-y);isNaN(I)&&(Math.abs(u)===+i.toFixed(8)&&(I=u),Math.abs(v)===+i.toFixed(8)&&(I=v)),y===1/0||y===-1/0?k=z*I+C:z!==1/0&&z!==-1/0||(k=y*I+b),e.lineTo(u,c),t.indexOf("MP")>0?e.quadraticCurveTo(I,k,v,m):e.arcTo(I,k,v,m,i)},v=function(t,e,i,n,r,o,a,s){i||(i=a);var h=f(90/Math.PI/n*a),u=f(90/Math.PI/i*a),c=r+h,l=o-h,p=r+u,v=o-u;e.beginPath(),e.fillStyle=s,e.moveTo.apply(e,d(c,n)),g(t,e,n,c,l,!0),v>p?g(t,e,i,p,v,!1):e.lineTo.apply(e,d((r+o)/2,a/2/Math.abs(Math.sin((r-o)/2)))),e.closePath(),e.fill()},m=function(t,e,i,n,r,o){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),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)},w=function(t,e,i,n,r,o,a){t.fillStyle=a,m(t,e,i,n,r,o),t.closePath(),t.fill()},y=function(t,e,i,n,r,o){var a=document.createElement("canvas"),s=a.getContext("2d"),h=t.width,u=t.height;a.width=h,a.height=u;var c=h/n;return m(s,e*c,i*c,n*c,r*c,o*c),s.clip(),s.drawImage(t,0,0,h,u),a},b=function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;i.width=r,i.height=o,n.drawImage(t,0,0,r,o);var a=n.getImageData(0,0,r,o),s=a.data,h=function(t,e){e=e||t/3;for(var i=Math.ceil(t),n=e*e,r=2*n,o=1/(2*Math.PI*n),a=[],s=0,h=-i;h<=i;h++)for(var u=-i;u<=i;u++){var c=o*Math.exp(-(h*h+u*u)/r);a.push(c),s+=c}for(var l=0;l<a.length;l++)a[l]/=s;return a}(e);return s.length,h.length,console.log(a),n.putImageData(a,0,0),i},x="1.6.3",z=function(){function t(){this.subs=[]}return t.prototype.addSub=function(t){this.subs.includes(t)||this.subs.push(t)},t.prototype.notify=function(){this.subs.forEach((function(t){t.update()}))},t}(),C="__proto__"in{};function I(t,e,i,n){Object.defineProperty(t,e,{value:i,enumerable:!!n,writable:!0,configurable:!0})}var k=Array.prototype,S=Object.create(k);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(t){S[t]=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=k[t].apply(this,e),r=this.__luckyOb__;return["push","unshift","splice"].includes(t)&&r.walk(this),r.dep.notify(),n}}));var T=function(){function t(t){this.dep=new z,I(t,"__luckyOb__",this),Array.isArray(t)&&(C?t.__proto__=S:Object.getOwnPropertyNames(S).forEach((function(e){I(t,e,S[e])}))),this.walk(t)}return t.prototype.walk=function(t){Object.keys(t).forEach((function(e){P(t,e,t[e])}))},t}();function O(t){if(t&&"object"==typeof t)return"__luckyOb__"in t?t.__luckyOb__:new T(t)}function P(t,e,i){var n=new z,r=Object.getOwnPropertyDescriptor(t,e);if(!r||!1!==r.configurable){var o=r&&r.get,a=r&&r.set;o&&!a||2!==arguments.length||(i=t[e]);var s=O(i);Object.defineProperty(t,e,{get:function(){var e=o?o.call(t):i;return z.target&&(n.addSub(z.target),s&&s.dep.addSub(z.target)),e},set:function(e){e!==i&&(i=e,o&&!a||(a?a.call(t,e):i=e,s=O(e),n.notify()))}})}}var $=0,W=function(){function t(t,e,i,n){void 0===n&&(n={}),this.id=$++,this.$lucky=t,this.expr=e,this.deep=!!n.deep,this.getter="function"==typeof e?e:function(t){t+=".";for(var e=[],i="",n=0;n<t.length;n++){var r=t[n];if(/\[|\./.test(r))e.push(i),i="";else{if(/\W/.test(r))continue;i+=r}}return function(t){return e.reduce((function(t,e){return t[e]}),t)}}(e),this.cb=i,this.value=this.get()}return t.prototype.get=function(){z.target=this;var t=this.getter.call(this.$lucky,this.$lucky);return this.deep&&function(t){var e=function(t){s(t,"array","object")&&Object.keys(t).forEach((function(i){var n=t[i];e(n)}))};e(t)}(t),z.target=null,t},t.prototype.update=function(){var t=this.get(),e=this.value;this.value=t,this.cb.call(this.$lucky,t,e)},t}(),_=function(){function t(t,e){var i=this;this.version=x,this.htmlFontSize=16,this.rAF=function(){},this.boxWidth=0,this.boxHeight=0,"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),t=t,this.config=t,this.data=e,t.flag||(t.flag="WEB"),t.el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d"),t.canvasElement.setAttribute("package","lucky-canvas@1.6.3"),t.canvasElement.addEventListener("click",(function(t){return i.handleClick(t)}))),this.ctx=t.ctx,this.initWindowFunction(),this.config.ctx||console.error("无法获取到 CanvasContext2D"),window&&window.addEventListener("resize",function(t,e){void 0===e&&(e=300);var i=null;return function(){for(var n=this,r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];i||(i=setTimeout((function(){t.apply(n,r),clearTimeout(i),i=null}),e))}}((function(){return i.resize()}),300)),window&&window.MutationObserver&&new window.MutationObserver((function(){i.resize()})).observe(document.documentElement,{attributes:!0})}return t.prototype.resize=function(){var t,e;null===(e=(t=this.config).beforeResize)||void 0===e||e.call(t),this.setHTMLFontSize(),this.setDpr(),this.resetWidthAndHeight(),this.zoomCanvas()},t.prototype.initLucky=function(){this.resize(),this.boxWidth&&this.boxHeight||console.error("无法获取到宽度或高度")},t.prototype.handleClick=function(t){},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.setDpr=function(){var t=this.config;t.dpr||(window?window.dpr=t.dpr=window.devicePixelRatio||1:t.dpr||console.error(t,"未传入 dpr 可能会导致绘制异常"))},t.prototype.resetWidthAndHeight=function(){var t=this.config,e=this.data,i=0,n=0;t.divElement&&(i=t.divElement.offsetWidth,n=t.divElement.offsetHeight),this.boxWidth=this.getLength(e.width||t.width)||i,this.boxHeight=this.getLength(e.height||t.height)||n,t.divElement&&(t.divElement.style.overflow="hidden",t.divElement.style.width=this.boxWidth+"px",t.divElement.style.height=this.boxHeight+"px")},t.prototype.zoomCanvas=function(){var t=this.config,e=this.ctx,i=t.canvasElement,n=t.dpr,r=[this.boxWidth*n,this.boxHeight*n],o=r[0],a=r[1];i&&(i.width=o,i.height=a,i.style.width=o+"px",i.style.height=a+"px",i.style["transform-origin"]="left top",i.style.transform="scale("+1/n+")",e.scale(n,n))},t.prototype.initWindowFunction=function(){var t=this.config;if(window)return this.rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},t.setTimeout=window.setTimeout,t.setInterval=window.setInterval,t.clearTimeout=window.clearTimeout,void(t.clearInterval=window.clearInterval);if(t.rAF)this.rAF=t.rAF;else if(t.setTimeout){var e=t.setTimeout;this.rAF=function(t){return e(t,16.7)}}else this.rAF=function(t){return setTimeout(t,16.7)}},t.prototype.loadImg=function(t,e,i){var n=this;return void 0===i&&(i="$resolve"),new Promise((function(r,o){if(t||o("=> '"+e.src+"' 不能为空或不合法"),"WEB"!==n.config.flag)return e[i]=r,void(e.$reject=o);var a=new Image;a.onload=function(){return r(a)},a.onerror=function(){return o("=> '"+e.src+"' 图片加载失败")},a.src=t}))},t.prototype.drawImage=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n,r=this,o=r.config,s=r.ctx;if(["WEB","MP-WX"].includes(o.flag))n=t;else{if(!["UNI-H5","UNI-MP","TARO-H5","TARO-MP"].includes(o.flag))return console.error("意料之外的 flag, 该平台尚未兼容!");n=t.path}return s.drawImage.apply(s,a([n],e))},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){var o={"%":function(t){return t*(e/100)},px:function(t){return 1*t},rem:function(t){return t*i.htmlFontSize},vw:function(t){return t/100*window.innerWidth}}[r];if(o)return o(n);var a=i.config.unitFunc;return a?a(n,r):n})))},t.prototype.$clip=function(t){for(var e=this,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=i.map((function(t){return e.getLength(t)}));return y.apply(void 0,a([t],r))},t.prototype.$opacity=function(t,e){return function(t,e){var i=document.createElement("canvas"),n=i.getContext("2d"),r=t.width,o=t.height;if(i.width=r,i.height=o,"string"==typeof n.filter)n.filter="opacity("+e+"%)",n.drawImage(t,0,0,r,o);else{n.drawImage(t,0,0,r,o);for(var a=n.getImageData(0,0,r,o),s=a.data,h=s.length,u=0;u<h;u+=4){var c=s[u+3];0!==c&&(s[u+3]=c*e/100)}n.putImageData(a,0,0)}return i}(t,this.getLength(e))},t.prototype.$blur=function(t,e){return b(t,this.getLength(e))},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&P(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,i){void 0===i&&(i={}),"object"==typeof e&&(e=(i=e).handler);var n=new W(this,t,e,i);return i.immediate&&e.call(this,n.value),function(){}},t}(),E={easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e}},R={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*Math.cos(t/n*(Math.PI/2))+i+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sin(t/n*(Math.PI/2))+e}},D={easeIn:function(t,e,i,n){return t>=n&&(t=n),0==t?e:i*Math.pow(2,10*(t/n-1))+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),t==n?e+i:i*(1-Math.pow(2,-10*t/n))+e}},F={easeIn:function(t,e,i,n){return t>=n&&(t=n),-i*(Math.sqrt(1-(t/=n)*t)-1)+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*Math.sqrt(1-(t=t/n-1)*t)+e}},H=Object.freeze({__proto__:null,quad:E,cubic:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t+1)+e}},quart:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),-i*((t=t/n-1)*t*t*t-1)+e}},quint:{easeIn:function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t*t*t*t+e},easeOut:function(t,e,i,n){return t>=n&&(t=n),i*((t=t/n-1)*t*t*t*t+1)+e}},sine:R,expo:D,circ:F}),L=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r._defaultConfig={},r._defaultStyle={},r.Radius=0,r.prizeRadius=0,r.prizeDeg=0,r.prizeRadian=0,r.rotateDeg=0,r.maxBtnRadius=0,r.startTime=0,r.endTime=0,r.stopDeg=0,r.endDeg=0,r.FPS=16.6,r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return i(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.Radius=Math.min(this.boxWidth,this.boxHeight)/2,this.ctx.translate(this.Radius,this.Radius),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.Radius=0,this.prizeRadius=0,this.prizeDeg=0,this.prizeRadian=0,this.rotateDeg=0,this.maxBtnRadius=0,this.startTime=0,this.endTime=0,this.stopDeg=0,this.endDeg=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,speedFunction:"quad",accelerationTime:2500,decelerationTime:2500,stopRange:0},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return r(this,void 0,void 0,(function(){var i;return o(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:t.buttons.map((function(t){return t.imgs}))};Object.keys(i).forEach((function(n){var r=i[n],o=[];r&&r.forEach((function(e,i){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(n,i,n,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e,i=this.ctx;i.beginPath(),i.arc(0,0,this.maxBtnRadius,0,2*Math.PI,!1),i.isPointInPath(t.offsetX,t.offsetY)&&(this.startTime||null===(e=this.startCallback)||void 0===e||e.call(this,t))},e.prototype.loadAndCacheImg=function(t,e,i,n){return r(this,void 0,void 0,(function(){var r=this;return o(this,(function(o){return[2,new Promise((function(o,a){var s=r[t][e];if(s&&s.imgs){var h=s.imgs[n];if(h){var u=r.ImageCache;u[i][e]||(u[i][e]=[]),r.loadImg(h.src,h).then((function(t){"function"==typeof h.formatter&&(t=h.formatter.call(r,t)),u[i][e][n]=t,o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),a()}))}}}))]}))}))},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,e,i=this,n=this,r=n.config,o=n.ctx,a=n._defaultConfig,s=n._defaultStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(t,e,n){return u(e.background)&&(o.beginPath(),o.fillStyle=e.background,o.arc(0,0,t,0,2*Math.PI,!1),o.fill()),e.imgs&&e.imgs.forEach((function(e,r){var a=i.ImageCache.blocks;if(a&&a[n]){var s=a[n][r];if(s){var h=i.computedWidthAndHeight(s,e,2*t,2*t),u=h[0],c=h[1],l=[i.getOffsetX(u),i.getHeight(e.top,2*t)-t],d=l[0],p=l[1];o.save(),e.rotate&&o.rotate(f(i.rotateDeg)),i.drawImage(s,d,p,u,c),o.restore()}}})),t-i.getLength(e.padding&&e.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=f(this.prizeDeg);var c=f(this.rotateDeg-90+this.prizeDeg/2+a.offsetDegree),d=function(t){return i.getOffsetX(o.measureText(t).width)},p=function(t,e,n){var r=t.lineHeight||s.lineHeight||t.fontSize||s.fontSize;return i.getHeight(t.top,e)+(n+1)*i.getLength(r)};o.save(),this.prizes.forEach((function(t,e){var n=c+e*i.prizeRadian,g=i.prizeRadius-i.maxBtnRadius,m=t.background||s.background;u(m)&&function(t,e,i,n,r,o,a,s){a?v(t,e,i,n,r,o,a,s):(e.beginPath(),e.fillStyle=s,e.moveTo(0,0),e.arc(0,0,n,r,o,!1),e.closePath(),e.fill())}(r.flag,o,i.maxBtnRadius,i.prizeRadius,n-i.prizeRadian/2,n+i.prizeRadian/2,i.getLength(a.gutter),m);var w=Math.cos(n)*i.prizeRadius,y=Math.sin(n)*i.prizeRadius;o.translate(w,y),o.rotate(n+f(90)),t.imgs&&t.imgs.forEach((function(t,n){var r=i.ImageCache.prizes;if(r&&r[e]){var o=r[e][n];if(o){var a=i.computedWidthAndHeight(o,t,i.prizeRadian*i.prizeRadius,g),s=a[0],h=a[1],u=[i.getOffsetX(s),i.getHeight(t.top,g)],c=u[0],l=u[1];i.drawImage(o,c,l,s,h)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||s.fontColor,n=t.fontWeight||s.fontWeight,r=i.getLength(t.fontSize||s.fontSize),u=t.fontStyle||s.fontStyle,c=Object.prototype.hasOwnProperty.call(t,"wordWrap")?t.wordWrap:s.wordWrap,f=t.lengthLimit||s.lengthLimit,v=t.lineClamp||s.lineClamp;o.fillStyle=e,o.font=n+" "+(r>>0)+"px "+u;var m=String(t.text);(c?l(o,h(m),(function(e){var n=2*((i.prizeRadius-p(t,g,e.length))*Math.tan(i.prizeRadian/2))-i.getLength(a.gutter);return i.getWidth(f,n)}),v):m.split("\n")).filter((function(t){return!!t})).forEach((function(e,i){o.fillText(e,d(e),p(t,g,i))}))})),o.rotate(f(360)-n-f(90)),o.translate(-w,-y)})),o.restore(),this.buttons.forEach((function(t,e){var n=i.getHeight(t.radius);i.maxBtnRadius=Math.max(i.maxBtnRadius,n),u(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.arc(0,0,n,0,2*Math.PI,!1),o.fill()),t.pointer&&u(t.background)&&(o.beginPath(),o.fillStyle=t.background,o.moveTo(-n,0),o.lineTo(n,0),o.lineTo(0,2*-n),o.closePath(),o.fill()),t.imgs&&t.imgs.forEach((function(t,r){var o=i.ImageCache.buttons;if(o&&o[e]){var a=o[e][r];if(a){var s=i.computedWidthAndHeight(a,t,2*n,2*n),h=s[0],u=s[1],c=[i.getOffsetX(h),i.getHeight(t.top,n)],l=c[0],f=c[1];i.drawImage(a,l,f,h,u)}}})),t.fonts&&t.fonts.forEach((function(t){var e=t.fontColor||s.fontColor,r=t.fontWeight||s.fontWeight,a=i.getLength(t.fontSize||s.fontSize),h=t.fontStyle||s.fontStyle;o.fillStyle=e,o.font=r+" "+(a>>0)+"px "+h,String(t.text).split("\n").forEach((function(e,i){o.fillText(e,d(e),p(t,n,i))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.play=function(){this.startTime||(this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=c(e)}t<0?(this.prizeFlag=-1,this.rotateDeg=0,this.draw()):this.prizeFlag=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,a=e._defaultConfig;if(-1!==n){var s=Date.now()-this.startTime;if(s>=a.accelerationTime&&void 0!==n){this.FPS=s/t,this.endTime=Date.now(),this.stopDeg=o;for(var h=(Math.random()*r-r/2)*this.getLength(a.stopRange),u=0;++u;){var c=360*u-n*r-o-a.offsetDegree+h-r/2;if(H[a.speedFunction].easeOut(this.FPS,this.stopDeg,c,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=c;break}}return this.slowDown()}this.rotateDeg=(o+H[a.speedFunction].easeIn(s,0,a.speed,a.accelerationTime))%360,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopDeg,a=e.endDeg,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>=s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.rotateDeg=H[s.speedFunction].easeOut(h,o,a,s.decelerationTime)%360,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},e.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},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),s(t,"number")?t:s(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr-this.Radius,e/i.dpr-this.Radius]},e}(_),M=function(t){function e(e,i){var n,r=t.call(this,e,{width:i.width,height:i.height})||this;return r.rows=3,r.cols=3,r.blocks=[],r.prizes=[],r.buttons=[],r.defaultConfig={},r.defaultStyle={},r.activeStyle={},r._defaultConfig={},r._defaultStyle={},r._activeStyle={},r.cellWidth=0,r.cellHeight=0,r.startTime=0,r.endTime=0,r.currIndex=0,r.stopIndex=0,r.endIndex=0,r.demo=!1,r.timer=0,r.FPS=16.6,r.prizeFlag=-1,r.cells=[],r.ImageCache={blocks:[],prizes:[],buttons:[]},r.initData(i),r.initWatch(),r.initComputed(),null===(n=e.beforeCreate)||void 0===n||n.call(r),r.init(),r}return i(e,t),e.prototype.resize=function(){var e,i;t.prototype.resize.call(this),this.draw(),null===(i=(e=this.config).afterResize)||void 0===i||i.call(e)},e.prototype.initLucky=function(){this.cellWidth=0,this.cellHeight=0,this.startTime=0,this.endTime=0,this.currIndex=0,this.stopIndex=0,this.endIndex=0,this.demo=!1,this.timer=0,this.FPS=16.6,this.prizeFlag=-1,t.prototype.initLucky.call(this)},e.prototype.initData=function(t){this.$set(this,"width",t.width||"300px"),this.$set(this,"height",t.height||"300px"),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,"buttons",t.buttons||[]),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:"sans-serif",fontWeight:"400",background:"rgba(0,0,0,0)",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("width",(function(e){t.data.width=e,t.resize()})),this.$watch("height",(function(e){t.data.height=e,t.resize()})),this.$watch("blocks",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("prizes",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("buttons",(function(e){t.initImageCache()}),{deep:!0}),this.$watch("rows",(function(){return t.init()})),this.$watch("cols",(function(){return t.init()})),this.$watch("defaultConfig",(function(){return t.draw()}),{deep:!0}),this.$watch("defaultStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("activeStyle",(function(){return t.draw()}),{deep:!0}),this.$watch("startCallback",(function(){return t.init()})),this.$watch("endCallback",(function(){return t.init()}))},e.prototype.init=function(){var t,e;return r(this,void 0,void 0,(function(){var i;return o(this,(function(n){switch(n.label){case 0:return this.initLucky(),i=this.config,null===(t=i.beforeInit)||void 0===t||t.call(this),this.draw(),[4,this.initImageCache()];case 1:return n.sent(),null===(e=i.afterInit)||void 0===e||e.call(this),[2]}}))}))},e.prototype.initImageCache=function(){var t=this;return new Promise((function(e){var i=t.buttons.map((function(t){return t.imgs}));t.button&&i.push(t.button.imgs);var n={blocks:t.blocks.map((function(t){return t.imgs})),prizes:t.prizes.map((function(t){return t.imgs})),buttons:i};Object.keys(n).forEach((function(i){var r=n[i],o=[];r&&r.forEach((function(e,n){e&&e.forEach((function(e,r){o.push(t.loadAndCacheImg(i,n,i,r))}))})),Promise.all(o).then((function(){t.draw(),e()}))}))}))},e.prototype.handleClick=function(t){var e=this,i=this.ctx;a(a([],this.buttons),[this.button]).forEach((function(n){var r;if(n){var o=e.getGeometricProperty([n.x,n.y,n.col||1,n.row||1]),a=o[0],s=o[1],h=o[2],u=o[3];i.beginPath(),i.rect(a,s,h,u),i.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||("function"==typeof n.callback&&n.callback.call(e,n),null===(r=e.startCallback)||void 0===r||r.call(e,t,n)))}}))},e.prototype.loadAndCacheImg=function(t,e,i,n){return r(this,void 0,void 0,(function(){var r=this;return o(this,(function(o){return[2,new Promise((function(o,a){var s=r[t][e];if("buttons"===t&&!r.buttons.length&&r.button&&(s=r.button),s&&s.imgs){var h=s.imgs[n];if(h){var u=r.ImageCache;u[i][e]||(u[i][e]=[]);var c=[r.loadImg(h.src,h),h.activeSrc&&r.loadImg(h.activeSrc,h,"$activeResolve")];Promise.all(c).then((function(t){var a=t[0],s=t[1],c=h.formatter;"function"==typeof c&&(a=c.call(r,a),s&&(s=c.call(r,s))),u[i][e][n]={defaultImg:a,activeImg:s},o()})).catch((function(i){console.error(t+"["+e+"].imgs["+n+"] "+i),a()}))}}}))]}))}))},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,e,i=this,n=this,r=n.config,o=n.ctx,c=n._defaultConfig,f=n._defaultStyle,d=n._activeStyle;null===(t=r.beforeDraw)||void 0===t||t.call(this,o),o.clearRect(0,0,this.boxWidth,this.boxHeight),this.cells=a(a([],this.prizes),this.buttons),this.button&&this.cells.push(this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(t,e){var n=t.x,r=t.y,a=t.w,h=t.h,c=function(t){var e,i=(null===(e=t.padding)||void 0===e?void 0:e.replace(/px/g,"").split(" ").map((function(t){return~~t})))||[0],n=0,r=0,o=0,a=0;switch(i.length){case 1:n=r=o=a=i[0];break;case 2:n=r=i[0],o=a=i[1];break;case 3:n=i[0],o=a=i[1],r=i[2];break;default:n=i[0],r=i[1],o=i[2],a=i[3]}var h={paddingTop:n,paddingBottom:r,paddingLeft:o,paddingRight:a};for(var u in h)h[u]=Object.prototype.hasOwnProperty.call(t,u)&&s(t[u],"string","number")?~~String(t[u]).replace(/px/g,""):h[u];return[n,r,o,a]}(e),l=c[0],d=c[1],p=c[2],g=c[3],v=e.borderRadius?i.getLength(e.borderRadius):0,m=e.background||f.background;return u(m)&&w(o,n,r,a,h,v,i.handleBackground(n,r,a,h,m)),{x:n+p,y:r+l,w:a-p-g,h:h-l-d}}),{x:0,y:0,w:this.boxWidth,h:this.boxHeight}),this.cellWidth=(this.prizeArea.w-c.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-c.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(t,e){var n=i.getGeometricProperty([t.x,t.y,t.col,t.row]),a=n[0],s=n[1],c=n[2],p=n[3],g=!1;(void 0===i.prizeFlag||i.prizeFlag>-1)&&(g=e===i.currIndex%i.prizes.length>>0);var v=g?d.background:t.background||f.background;if(u(v)){var m=(g?d.shadow:t.shadow||f.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===m.length&&(o.shadowColor=m[3],o.shadowOffsetX=m[0]*r.dpr,o.shadowOffsetY=m[1]*r.dpr,o.shadowBlur=m[2],m[0]>0?c-=m[0]:(c+=m[0],a-=m[0]),m[1]>0?p-=m[1]:(p+=m[1],s-=m[1])),w(o,a,s,c,p,i.getLength(t.borderRadius?t.borderRadius:f.borderRadius),i.handleBackground(a,s,c,p,v)),o.shadowColor="rgba(0, 0, 0, 0)",o.shadowOffsetX=0,o.shadowOffsetY=0,o.shadowBlur=0}var y="prizes";e>=i.prizes.length&&(y="buttons",e-=i.prizes.length),t.imgs&&t.imgs.forEach((function(n,r){var o=i.ImageCache[y];if(o[e]){var h=o[e][r];if(h){var u=g&&h.activeImg||h.defaultImg;if(u){var c=i.computedWidthAndHeight(u,n,t),l=c[0],f=c[1],d=[a+i.getOffsetX(l,t.col),s+i.getHeight(n.top,t.row)],p=d[0],v=d[1];i.drawImage(u,p,v,l,f)}}}})),t.fonts&&t.fonts.forEach((function(e){var n=g&&d.fontStyle?d.fontStyle:e.fontStyle||f.fontStyle,r=g&&d.fontWeight?d.fontWeight:e.fontWeight||f.fontWeight,u=g&&d.fontSize?i.getLength(d.fontSize):i.getLength(e.fontSize||f.fontSize),c=g&&d.lineHeight?d.lineHeight:e.lineHeight||f.lineHeight||e.fontSize||f.fontSize,p=Object.prototype.hasOwnProperty.call(e,"wordWrap")?e.wordWrap:f.wordWrap,v=e.lengthLimit||f.lengthLimit,m=e.lineClamp||f.lineClamp;o.font=r+" "+(u>>0)+"px "+n,o.fillStyle=g&&d.fontColor?d.fontColor:e.fontColor||f.fontColor;var w=[],y=String(e.text);if(p){var b=i.getWidth(v,t.col);w=l(o,h(y),(function(){return b}),m)}else w=y.split("\n");w.forEach((function(n,r){o.fillText(n,a+i.getOffsetX(o.measureText(n).width,t.col),s+i.getHeight(e.top,t.row)+(r+1)*i.getLength(c))}))}))})),null===(e=r.afterDraw)||void 0===e||e.call(this,o)},e.prototype.handleBackground=function(t,e,i,n,r){var o=this.ctx;return r.includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var a=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),s=a.shift(),h=[0,0,0,0];if(s.includes("deg")){var u=function(t){return Math.tan(t/180*Math.PI)};(s=s.slice(0,-3)%360)>=0&&s<45?h=[e,i+r,e+n,i+r-n*u(s-0)]:s>=45&&s<90?h=[e,i+r,e+n-r*u(s-45),i]:s>=90&&s<135?h=[e+n,i+r,e+n-r*u(s-90),i]:s>=135&&s<180?h=[e+n,i+r,e,i+n*u(s-135)]:s>=180&&s<225?h=[e+n,i,e,i+n*u(s-180)]:s>=225&&s<270?h=[e+n,i,e+r*u(s-225),i+r]:s>=270&&s<315?h=[e,i,e+r*u(s-270),i+r]:s>=315&&s<360&&(h=[e,i,e+n,i+r-n*u(s-315)])}else s.includes("top")?h=[e,i+r,e,i]:s.includes("bottom")?h=[e,i,e,i+r]:s.includes("left")?h=[e+n,i,e,i]:s.includes("right")&&(h=[e,i,e+n,i]);var c=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return a.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)}(o,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.config.clearInterval;this.startTime||(t(this.timer),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){if(!t&&0!==t){var e=this.prizes.map((function(t){return t.range}));t=c(e)}t<0?(this.prizeFlag=-1,this.currIndex=0,this.draw()):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,a=e.startTime,s=e._defaultConfig;if(-1!==o){var h=Date.now()-a;if(h>=s.accelerationTime&&void 0!==o){this.FPS=h/t,this.endTime=Date.now(),this.stopIndex=n;for(var u=0;++u;){var c=r.length*u+o-(n>>0);if(E.easeOut(this.FPS,this.stopIndex,c,s.decelerationTime)-this.stopIndex>s.speed){this.endIndex=c;break}}return this.slowDown()}this.currIndex=(n+E.easeIn(h,.1,s.speed,s.accelerationTime))%r.length,this.draw(),i(this.run.bind(this,t+1))}else this.startTime=0},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,n=e.prizes,r=e.prizeFlag,o=e.stopIndex,a=e.endIndex,s=e._defaultConfig;if(-1!==r){var h=Date.now()-this.endTime;if(h>s.decelerationTime)return this.startTime=0,void(null===(t=this.endCallback)||void 0===t||t.call(this,n.find((function(t,e){return e===r}))||{}));this.currIndex=E.easeOut(h,o,a,s.decelerationTime)%n.length,this.draw(),i(this.slowDown.bind(this))}else this.startTime=0},e.prototype.walk=function(){var t=this,e=this.config,i=e.setInterval;(0,e.clearInterval)(this.timer),this.timer=i((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=void 0===n?1:n,o=t[3],a=void 0===o?1:o,s=this.cellWidth,h=this.cellHeight,u=this._defaultConfig.gutter,c=[this.prizeArea.x+(s+u)*e,this.prizeArea.y+(h+u)*i];return r&&a&&c.push(s*r+u*(r-1),h*a+u*(a-1)),c},e.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},e.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},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e.prototype.conversionAxis=function(t,e){var i=this.config;return[t/i.dpr,e/i.dpr]},e}(_);t.LuckyGrid=M,t.LuckyWheel=L,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "lucky-canvas",
"version": "1.6.4",
"version": "1.6.5",
"description": "一个基于原生 js 的(大转盘抽奖 / 九宫格抽奖)插件",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs",

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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