1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[705],{42864:function(e,t,n){n.d(t,{Z:function(){return o}});var i=n(52676),r=(n(75271),n(82187)),s=n.n(r);function o(e){var t=e.className,n=void 0===t?"":t,r=e.as,o=void 0===r?"":r,c=e.href,a=void 0===c?"":c,u=e.children;return"a"===o?(0,i.jsx)("a",{role:"button",href:a,className:s()("lucky-button-comps",n),children:u}):(0,i.jsx)("button",{role:"button",className:s()("lucky-button-comps",n),children:u})}},31705:function(e,t,n){n.r(t),n.d(t,{default:function(){return x}});var i=n(91499),r=n.n(i),s=n(52676),o=n(75271),c=n(19339),a=n(42864);function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l={w:320,h:320,segments:[],padding:24,speed:20,accelerationTime:2500,decelerationTime:2500},h=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=l,this.images=[],this.ctx=null,this.ctxR=0,this.centerX=150,this.centerY=150,this.segsLen=0,this.step=0,this.prizeIndex=void 0,this.startTime=0,this.endTime=0,this.initDeg=0,this.angleCurrent=0,this.rotateDeg=0,this.prizeDeg=0,this.endDeg=0,this.linearDeg=0,this.config=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"===typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),i.forEach((function(t){u(e,t,n[t])}))}return e}({},l,t),this.segsLen=this.config.segments.length,this.resetConfig(),this.initCanvas()}var t=e.prototype;return t.resetConfig=function(){this.initDeg=-360/this.segsLen*2,this.angleCurrent=this.initDeg-22.5,this.startTime=0,this.endTime=0,this.prizeIndex=void 0,this.prizeDeg=0,this.endDeg=0,this.linearDeg=0},t.initCanvas=function(){var e=this.config,t=e.selector,n=e.w,i=e.h,r=document.querySelector(t);if(!r)throw new Error("canvas element no exist");var s=window.devicePixelRatio||1;r.width=n*s,r.height=i*s,r.style.width="".concat(n,"px"),r.style.height="".concat(i,"px"),this.ctx=r.getContext("2d"),this.ctx.setTransform(s,0,0,s,0,0),this.centerX=n/2,this.centerY=i/2,this.ctxR=n/2,this.draw(),this.initLoadImage()},t.initLoadImage=function(){var e=this,t=this.config.segments.map((function(e){return e.imgId}));this.images=t.map((function(e){return document.getElementById(e)}));var n=Array.from(new Set(t)).map((function(e){return document.getElementById(e)})).map((function(e){return new Promise((function(t,n){e.onload=function(){t()},e.onerror=function(){n("image unloded error")},e.complete&&t()}))}));Promise.allSettled(n).then((function(){return e.draw()})).catch((function(e){return console.log(e)}))},t.clear=function(){var e;null===(e=this.ctx)||void 0===e||e.clearRect(0,0,1e3,1e3)},t.draw=function(){this.clear(),this.drawWheel()},t.drawWheel=function(){for(var e=this.angleCurrent,t=1;t<=this.segsLen;t++){var n=360/this.segsLen+e;this.drawSegment(t-1,e,n),e=n}},t.drawSegment=function(e,t,n){var i=this.config.segments[e],r=this.config.padding,s=this.ctx,o=i.desc,c=i.color,a=i.bgColor;s.save(),s.beginPath(),s.moveTo(this.centerX,this.centerY),s.arc(this.centerX,this.centerY,this.ctxR,f(t),f(n),!1),s.closePath(),s.fillStyle=a,s.fill(),s.save(),s.translate(this.centerX,this.centerY),s.rotate(f(n)),s.fillStyle=c,s.font='700 16px Roboto,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue","Noto Sans","Liberation Sans",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"';var u=s.measureText(o).width;s.fillText(o,this.centerX-u-r,-10),this.images.length&&s.drawImage(this.images[e],this.centerX-24-r,-50),s.restore()},t.play=function(){0===this.step&&(this.resetConfig(),this.startTime=Date.now(),this.step=1,this.run())},t.stop=function(e){this.endTime=Date.now(),this.prizeIndex=e,this.prizeDeg=360-e*(360/this.segsLen)+this.initDeg,this.step=3},t.run=function(){var e=this,t=this.step,n=this.prizeIndex,i=this.config,r=i.accelerationTime,s=i.decelerationTime,o=i.speed,c=i.onFinished;if(0===this.step)return this.rafId&&cancelAnimationFrame(this.rafId),void(null===c||void 0===c||c(n));var a=Date.now()-this.startTime,u=this.angleCurrent;if(1===t||a<r){var l=Math.round(d.easeIn(a,1,o,r));l>=o&&(this.step=2),u+=l}else if(2===t)u+=o,void 0!==n&&n>=0&&(this.step=3);else if(3===t){var h=Date.now()-this.endTime;this.endDeg=this.endDeg||this.prizeDeg+(360-u%360+u)+720,this.linearDeg=this.linearDeg||u,u=Math.round(d.easeOut(h,this.linearDeg,this.endDeg-this.linearDeg-22.5,s)),h>=s&&(this.step=0)}else console.warn("occured error");this.angleCurrent=u,this.draw(),this.rafId=window.requestAnimationFrame((function(){e.run()}))},e}(),d={easeIn:function(e,t,n,i){return n*(e/=i)*e+t},easeOut:function(e,t,n,i){return-n*(e/=i)*(e-2)+t}};function f(e){return Math.PI/180*e}var g=n(32282),m=n(76492);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function v(e,t,n,i,r,s,o){try{var c=e[s](o),a=c.value}catch(u){return void n(u)}c.done?t(a):Promise.resolve(a).then(i,r)}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){return function(e){if(Array.isArray(e))return p(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"===typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}
1var w={thankyou:{id:"",desc:"Thank you",bgColor:"#fff",color:"#1D6BE1",imgId:"lucky"},free_item:{id:"",desc:"FREE GIFT",bgColor:"#00A5EB",color:"#FFF",imgId:"gift"},flat:{id:"",desc:"",bgColor:"#00A5EB",color:"#FFF",imgId:"sub"},percentage:{id:"",desc:"",bgColor:"#00A5EB",color:"#FFF",imgId:"discount"}},x=function(e){var t=e.spinList,n=e.user,i=e.onSuccess,u=(0,o.useState)(!1),l=u[0],d=u[1],f=(0,o.useRef)(null),p=(0,o.useRef)([]);(0,o.useEffect)((function(){var e=[];t.forEach((function(t){var n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"===typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),i.forEach((function(t){y(e,t,n[t])}))}return e}({},w[t.type]);"percentage"===t.type&&(n.desc="".concat(t.percentage_off,"% OFF")),"flat"===t.type&&(n.desc="$".concat(t.amount_off," OFF")),n.id=t.id,e.push(n),e.push(w.thankyou)})),p.current=b(e).concat(b(e)),f.current=new h({selector:"#lucky-wheel",segments:p.current,onFinished:function(){console.log("finished"),setTimeout((function(){i()}),2e3)}})}),[]);var x=function(){var e,t=(e=r().mark((function e(){var t,n,i,s,o,c,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!l){e.next=2;break}return e.abrupt("return");case 2:return d(!0),f.current.play(),t=(0,m.Wz)("uuid"),e.prev=5,e.next=9,(0,g.$)(t);case 9:s=e.sent,o=null===(n=s.data)||void 0===n?void 0:n.coupon_id,-1===(c=null===(i=p.current)||void 0===i?void 0:i.findIndex((function(e){return e.id==o})))&&(c=null===(a=p.current)||void 0===a?void 0:a.findIndex((function(e){return!e.id}))),setTimeout((function(){f.current.stop(c)}),3500),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(5),console.log(e.t0);case 19:case"end":return e.stop()}}),e,null,[[5,16]])})),function(){var t=this,n=arguments;return new Promise((function(i,r){var s=e.apply(t,n);function o(e){v(s,i,r,o,c,"next",e)}function c(e){v(s,i,r,o,c,"throw",e)}o(void 0)}))});return function(){return t.apply(this,arguments)}}();return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"lucky-spin-wrap",children:[(0,s.jsx)("h1",{className:"title",children:"Spin & Win"}),(0,s.jsxs)("p",{className:"desc",children:["Hi ",null===n||void 0===n?void 0:n.first_name,", try your luck and get a surprise gift on your next order."]}),(0,s.jsx)("div",{className:"try-lucky-btn",onClick:function(){return x()},children:(0,s.jsxs)(a.Z,{className:"ru-w-full",children:[(0,s.jsx)(c.Loading,{loading:l}),(0,s.jsx)("span",{className:"luckbtn-tips",children:"\ud83e\udd1e Try My Luck"})]})}),(0,s.jsxs)("div",{className:"lucky-box",children:[(0,s.jsx)("div",{className:"lucky-base",children:(0,s.jsx)("img",{src:"/assets/img/lucky/lucky-base.png",alt:""})}),(0,s.jsxs)("div",{id:"my-lucky",className:"lucky-canvas",children:[(0,s.jsx)("canvas",{id:"lucky-wheel"}),(0,s.jsx)("div",{className:"lucky-btn",children:(0,s.jsx)("img",{className:"arrow",src:"/assets/img/lucky/arrow.png",alt:""})})]})]}),(0,s.jsxs)("div",{style:{display:"none"},children:[(0,s.jsx)("img",{id:"gift",src:"/assets/img/lucky/gift.svg",alt:""}),(0,s.jsx)("img",{id:"sub",src:"/assets/img/lucky/sub.svg",alt:""}),(0,s.jsx)("img",{id:"lucky",src:"/assets/img/lucky/lucky.svg",alt:""}),(0,s.jsx)("img",{id:"discount",src:"/assets/img/lucky/discount.svg",alt:""})]})]})})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.