@anker-in/headless-ui 1.1.94 → 1.1.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/biz-components/ProductLottery/index.js +1 -1
- package/dist/cjs/biz-components/ProductLottery/index.js.map +3 -3
- package/dist/cjs/biz-components/WheelLottery/index.js +1 -1
- package/dist/cjs/biz-components/WheelLottery/index.js.map +3 -3
- package/dist/esm/biz-components/ProductLottery/index.js +1 -1
- package/dist/esm/biz-components/ProductLottery/index.js.map +3 -3
- package/dist/esm/biz-components/WheelLottery/index.js +1 -1
- package/dist/esm/biz-components/WheelLottery/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var re=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var jt=(s,l)=>{for(var r in l)re(s,r,{get:l[r],enumerable:!0})},Yt=(s,l,r,_)=>{if(l&&typeof l=="object"||typeof l=="function")for(let f of Ut(l))!Ft.call(s,f)&&f!==r&&re(s,f,{get:()=>l[f],enumerable:!(_=Ht(l,f))||_.enumerable});return s};var Gt=s=>Yt(re({},"__esModule",{value:!0}),s);var Jt={};jt(Jt,{BaseModal:()=>Ge.BaseModal,ErrorModal:()=>je.ErrorModal,MyRewardsModal:()=>Fe.MyRewardsModal,ProductLottery:()=>ae,RulesModal:()=>Ue.RulesModal,ShareModal:()=>Ye.ShareModal,WinnerModal:()=>He.WinnerModal,default:()=>Kt});module.exports=Gt(Jt);var t=require("react/jsx-runtime"),e=require("react"),m=require("../../helpers/index.js"),Pe=require("./types.js"),ke=require("../LotteryShared/types.js"),z=require("../../components/grid.js"),Se=require("./MediaDrawArea.js"),Le=require("../LotteryShared/PrizePool.js"),We=require("../LotteryShared/ChanceMethods.js"),Re=require("../LotteryShared/WinnerModal.js"),Oe=require("../LotteryShared/RulesModal.js"),Ae=require("../LotteryShared/MyRewardsModal.js"),ne=require("../LotteryShared/ErrorModal.js"),ze=require("../LotteryShared/ShareModal.js"),Ie=require("../../shared/Styles.js"),h=require("../../shared/track.js"),De=require("../AiuiProvider/index.js"),$e=require("../../hooks/useExposure.js"),b=require("../../shared/trackUrlRef.js"),He=require("../LotteryShared/WinnerModal.js"),Ue=require("../LotteryShared/RulesModal.js"),Fe=require("../LotteryShared/MyRewardsModal.js"),je=require("../LotteryShared/ErrorModal.js"),Ye=require("../LotteryShared/ShareModal.js"),Ge=require("../LotteryShared/BaseModal.js");const Bt="image",c="lottery_banner",v="\u4EA7\u54C1\u62BD\u5956",T="copy",w="lottery_pop",E="image",ae=(0,e.forwardRef)(({prizes:s,media:l,theme:r,ctaButton:_,videoAutoPlay:f,videoMuted:Be,videoLoop:Ke,chanceMethods:se=ke.DEFAULT_CHANCE_METHODS,chanceTitle:Je=Pe.DEFAULT_CHANCE_TITLE,chanceSubtitle:Qe,chanceFooterNote:Xe,chanceMethodsText:I,mechanismType:U,inputConfig:p,inputPlaceholder:ie,inputSubmitText:le,inputType:pe,inputValidationErrorText:de,winnerTickerData:Ze=[],winningInfos:ce,winnerNameTemplate:Ve,prizesTitle:qe,onDrawStart:F,onDrawEnd:j,onDrawError:me,winnerModalConfig:fe,rulesModalConfig:et={},actionButtonConfig:u,myRewardsModalConfig:tt={},errorModalConfig:D={},shareModalConfig:C={},error:y,tryAgain:Y,userData:x,loginPrompt:ot,loginPromptText:rt="Please log in to participate",loginButtonText:Qt="Log In",noChances:nt,noChancesText:at="You have no chances left",onLoginRequired:N,onCopyCode:st,opportunitiesPrefix:ue,opportunitiesText:it=["Number of draws remaining today:"],dealsType:Xt,className:lt},pt)=>{const Zt=ot??rt??"Please log in to participate",dt=nt??at??"You have no chances left",xe=ue?[ue]:it??["Number of draws remaining today:"],ge=ie||le||pe||de?{...p??{},placeholder:ie??p?.placeholder??"Enter your order number",submitText:le??p?.submitText??"Spin and Win",inputType:pe??p?.inputType??"text",validationErrorText:de??p?.validationErrorText}:p,P=y?{title:y.title??D?.title,message:y.defaultMessage??D?.message,confirmText:y.confirmButton??D?.confirmText,exchangeFailedTitle:y.exchangeFailedTitle,exchangeFailedMessage:y.exchangeFailedMessage}:D,n={...ce,...fe,confirmText:fe?.confirmText??ce?.confirmButton},{rulesData:k,rulesText:G="Rules"}=et,ct=!!(u?.text&&u?.url),{rewardsData:B,myRewardsText:K="My Rewards",codeText:mt="CODE:",copyText:Te="COPY",copiedText:he="COPIED",prizeText:ft="Prize time:",emptyText:ut,copyError:xt,availableText:gt,usedStatusText:Tt,expiredText:ht,notFoundText:yt}=tt,Mt=I?.completedText,vt=I?.usedText,$=x?.isLoggedIn??!1,ye=x?.availableChances??0,Me=se.length>0||U==="input",ve=U==="input"&&!!p?.agreementNotice,we=$&&ye<=0&&x?.isChancesLoading!==!0,[S,J]=(0,e.useState)(!1),[d,Ee]=(0,e.useState)(null),[Q,L]=(0,e.useState)(!1),[X,W]=(0,e.useState)(!1),[Z,R]=(0,e.useState)(!1),[V,M]=(0,e.useState)(!1),[q,O]=(0,e.useState)(!1),[ee,A]=(0,e.useState)(!1),[be,H]=(0,e.useState)(""),[wt,Et]=(0,e.useState)(),[bt,_t]=(0,e.useState)(),[Ct,Nt]=(0,e.useState)(),[Pt,kt]=(0,e.useState)(),[St,Lt]=(0,e.useState)(),[a,Wt]=(0,e.useState)(),[te,Rt]=(0,e.useState)(!1),_e=(0,e.useRef)(null);(0,$e.useExposure)(_e,{componentType:Bt,componentName:c,componentTitle:v});const{trackingData:i,pageHandle:Ce}=(0,De.useAiuiContext)();(0,e.useEffect)(()=>{Q&&(0,h.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:w,component_title:"Winner"}})},[Q,i]),(0,e.useEffect)(()=>{q&&(0,h.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:w,component_title:"Better Luck Next Time"}})},[q,i]),(0,e.useEffect)(()=>{X&&(0,h.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:w,component_title:"Rules"}})},[X,i]),(0,e.useEffect)(()=>{Z&&(0,h.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:w,component_title:"My Rewards"}})},[Z,i]),(0,e.useEffect)(()=>{ee&&(0,h.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:w,component_title:"Share"}})},[ee,i]),(0,e.useEffect)(()=>{V&&(0,h.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:w,component_title:"Error"}})},[V,i]),(0,e.useImperativeHandle)(pt,()=>({showError:({message:o,title:g,confirmText:oe})=>{H(o),Et(g),_t(oe),M(!0)},hideError:()=>{M(!1)},showNoWin:o=>{Nt(o?.title),kt(o?.message),Lt(o?.confirmText),O(!0)},hideNoWin:()=>{O(!1)},showWinner:(o,g)=>{Ee(o),Wt(g),L(!0)},hideWinner:()=>{L(!1)},showRules:()=>{W(!0)},hideRules:()=>{W(!1)},showRewards:()=>{R(!0)},hideRewards:()=>{R(!1)},showShare:()=>{A(!0)},hideShare:()=>{A(!1)},hideAllModals:()=>{L(!1),W(!1),R(!1),M(!1),O(!1),A(!1)}}),[]);const Ne=(0,e.useCallback)(async()=>{if(!S){if(ve&&!te){H(p?.agreementWarningText||"Please agree to the terms before continuing"),M(!1);return}if(!x?.isLoggedIn){N?.();return}if(!(x.availableChances<=0)){J(!0);try{let o;F&&(o=await F());const g=s.find(oe=>oe.prizeKey===o)||s[0];Ee(g),J(!1),j?j(g):setTimeout(()=>{g.prizeKey==="try-again"?O(!0):L(!0)},300)}catch(o){J(!1),H(o.message||"An error occurred"),M(!0),me?.(o)}}}},[ve,p?.agreementWarningText,te,S,s,F,j,me,x,N]),Ot=(0,e.useCallback)(()=>{if(!$){N?.();return}Ne()},[Ne,$,N]),At=(0,e.useCallback)(()=>{L(!1)},[]),zt=(0,e.useCallback)(()=>{O(!1)},[]),It=Ct||Y?.title,Dt=Pt||Y?.message,$t=St||Y?.confirmText;return(0,t.jsxs)("div",{ref:_e,className:(0,m.cn)("product-lottery-container","w-full",r==="dark"?"aiui-dark":"",lt),children:[(0,t.jsxs)("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:[S&&"Drawing in progress...",d&&!S&&`Prize won: ${d.name}`]}),(0,t.jsxs)(z.Grid,{className:(0,m.cn)("product-lottery-main","tablet:mb-4 mb-3"),children:[(0,t.jsx)(z.GridItem,{span:Me?7:12,className:(0,m.cn)("media-section","relative flex w-full flex-1 items-center justify-center overflow-hidden","rounded-box","laptop:min-h-[288px] min-h-[240px]","lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]","desktop:aspect-w-[759] desktop:aspect-h-[384]","laptop:aspect-w-[516] laptop:aspect-h-[288]","l-tablet:col-span-12","l-tablet:mb-3",r==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsxs)("div",{className:(0,m.cn)("size-full px-[16px] pt-[16px]","lg-desktop:pb-[32px] lg-desktop:px-[32px]","desktop:pt-[24px] desktop:px-[24px]","laptop:pt-[16px] laptop:px-[16px]","tablet:px-[24px]","l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10","flex flex-col"),children:[(0,t.jsxs)("div",{className:"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3",children:[(0,t.jsx)("div",{children:(0,t.jsxs)("p",{className:"text-info-primary font-[700]",children:[xe?.[0],(0,t.jsx)("span",{className:"ml-1 text-[#FF6B35]",children:ye}),xe?.[1]||""]})}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[k&&k.length>0&&(0,t.jsx)("button",{onClick:o=>{o.preventDefault(),o.stopPropagation(),W(!0)},className:"cursor-pointer touch-manipulation",type:"button","data-headless-type-name":`${T}#${c}`,"data-headless-title-desc-button":`${v}##${G}`,children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:G})}),B&&(0,t.jsx)("button",{onClick:o=>{if(o.preventDefault(),o.stopPropagation(),!$){N?.();return}R(!0)},className:"cursor-pointer touch-manipulation whitespace-nowrap",type:"button","data-headless-type-name":`${T}#${c}`,"data-headless-title-desc-button":`${v}##${K}`,children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:K})}),ct&&(0,t.jsx)("a",{href:(0,b.trackUrlRef)(u?.url??"",(0,b.buildTrackingRef)(Ce??"",T,c)),className:"cursor-pointer touch-manipulation whitespace-nowrap",onClick:o=>{o.preventDefault(),o.stopPropagation(),u?.url&&(window.location.href=(0,b.trackUrlRef)(u.url,(0,b.buildTrackingRef)(Ce??"",T,c)))},"data-headless-type-name":`${T}#${c}`,"data-headless-title-desc-button":`${v}##${u?.text}`,children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:u?.text})})]})]}),(0,t.jsx)(Se.MediaDrawArea,{className:"min-h-0 w-full flex-1",theme:r,media:l,ctaButton:_,videoAutoPlay:f,videoMuted:Be,videoLoop:Ke,isDrawing:S,isDisabled:we,onClick:Ot,ctaTrackTypeName:`${T}#${c}`,ctaTrackTitleDescButton:`${v}##${_?.text??""}`}),we&&(0,t.jsx)("div",{className:(0,m.cn)("rounded-box absolute inset-0 z-20 flex items-center justify-center bg-black/60 backdrop-blur-sm","px-6 text-center"),children:(0,t.jsx)("div",{className:"flex flex-col items-center gap-4",children:(0,t.jsx)("p",{className:"lg-desktop:text-[24px] text-[18px] font-semibold text-white",children:dt})})})]})}),Me&&(0,t.jsx)(z.GridItem,{span:5,className:(0,m.cn)("info-section","rounded-box","relative flex flex-col overflow-hidden","lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]","desktop:aspect-w-[536] desktop:aspect-h-[384]","laptop:aspect-w-[364] laptop:aspect-h-[288]","l-tablet:min-h-[280px] laptop:max-h-[320px]","w-full","l-tablet:col-span-12",r==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsx)(We.ChanceMethods,{theme:r,userData:x,methods:se,title:Je,subtitle:Qe,footerNote:Xe,onOpenShareModal:()=>A(!0),chanceBadgeText:I?.chanceBadgeText,completedText:Mt,usedText:vt,loadingText:I?.loadingText,mechanismType:U,inputConfig:{...ge,submitTrackTypeName:`${T}#${c}`,submitTrackTitleDescButton:`${v}##${ge?.submitText??"Spin and Win"}`},isAgreementChecked:te,onAgreementCheckedChange:o=>{Rt(o),o&&H("")},agreementErrorText:be})})]}),(0,t.jsx)("div",{className:(0,m.cn)("product-lottery-footer","rounded-box","flex flex-col overflow-hidden",r==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsx)(Le.PrizePool,{theme:r,prizes:s,title:qe,winningInfos:Ze,winnerNameTemplate:Ve})}),(0,t.jsx)(Re.WinnerModal,{isOpen:Q,prize:d,title:a?.title||n.title,prizeTitle:a?.prizeTitle||n.prizeTitle,prizeImage:a?.prizeImage||n.prizeImage,prizeDescription:a?.prizeDescription||n.prizeDescription,winnerNote:a?.winnerNote??d?.winnerModalConfig?.winnerNote??n.winnerNote,learnMoreUrl:a?.learnMoreUrl||d?.winnerModalConfig?.learnMoreUrl||n.learnMoreUrl,learnMoreText:a?.learnMoreText||d?.winnerModalConfig?.learnMoreText||n.learnMoreText,couponCode:a?.couponCode||n.couponCode,expiresAt:a?.expiresAt||n.expiresAt,couponDiscount:a?.couponDiscount||n.couponDiscount,couponUnit:a?.couponUnit||n.couponUnit,confirmText:a?.confirmText||d?.winnerModalConfig?.confirmText||n.confirmText,confirmUrl:a?.confirmUrl||d?.winnerModalConfig?.confirmUrl||n.confirmUrl,copyText:a?.copyText||n.copyText||Te,copiedText:a?.copiedText||n.copiedText||he,onClose:At,theme:r}),k&&k.length>0&&(0,t.jsx)(Oe.RulesModal,{title:G,isOpen:X,onClose:()=>W(!1),rules:k,theme:r}),B&&(0,t.jsx)(Ae.MyRewardsModal,{isOpen:Z,onClose:()=>R(!1),rewards:B,onCopyCode:st,codeText:mt,copyText:Te,copiedText:he,prizeText:ft,emptyText:ut,copyError:xt,availableText:gt,usedStatusText:Tt,expiredText:ht,notFoundText:yt,theme:r,title:K}),(0,t.jsx)(ne.ErrorModal,{isOpen:V,onClose:()=>M(!1),title:wt||P?.title,message:be||P?.message,confirmText:bt||P?.confirmText,exchangeFailedTitle:P?.exchangeFailedTitle,exchangeFailedMessage:P?.exchangeFailedMessage,theme:r}),(0,t.jsx)(ne.ErrorModal,{isOpen:q,onClose:zt,title:It,message:Dt,confirmText:$t,theme:r}),(0,t.jsx)(ze.ShareModal,{isOpen:ee,onClose:()=>A(!1),title:C?.title,subtitle:C?.subtitle,note:C?.note,platforms:C?.platforms,onShareSuccess:C?.onShareSuccess,theme:r})]})});ae.displayName="ProductLottery";var Kt=(0,Ie.withLayout)(ae);
|
|
1
|
+
"use strict";"use client";var re=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Dt=Object.prototype.hasOwnProperty;var $t=(s,l)=>{for(var r in l)re(s,r,{get:l[r],enumerable:!0})},Ht=(s,l,r,P)=>{if(l&&typeof l=="object"||typeof l=="function")for(let m of It(l))!Dt.call(s,m)&&m!==r&&re(s,m,{get:()=>l[m],enumerable:!(P=zt(l,m))||P.enumerable});return s};var Ut=s=>Ht(re({},"__esModule",{value:!0}),s);var Gt={};$t(Gt,{BaseModal:()=>je.BaseModal,ErrorModal:()=>Ue.ErrorModal,MyRewardsModal:()=>He.MyRewardsModal,ProductLottery:()=>ae,RulesModal:()=>$e.RulesModal,ShareModal:()=>Fe.ShareModal,WinnerModal:()=>De.WinnerModal,default:()=>jt});module.exports=Ut(Gt);var t=require("react/jsx-runtime"),e=require("react"),g=require("../../helpers/index.js"),Ce=require("./types.js"),Ne=require("../LotteryShared/types.js"),z=require("../../components/grid.js"),be=require("./MediaDrawArea.js"),Se=require("../LotteryShared/PrizePool.js"),ke=require("../LotteryShared/ChanceMethods.js"),Le=require("../LotteryShared/WinnerModal.js"),We=require("../LotteryShared/RulesModal.js"),Re=require("../LotteryShared/MyRewardsModal.js"),ne=require("../LotteryShared/ErrorModal.js"),Ae=require("../LotteryShared/ShareModal.js"),Oe=require("../../shared/Styles.js"),T=require("../../shared/track.js"),ze=require("../AiuiProvider/index.js"),Ie=require("../../hooks/useExposure.js"),_=require("../../shared/trackUrlRef.js"),De=require("../LotteryShared/WinnerModal.js"),$e=require("../LotteryShared/RulesModal.js"),He=require("../LotteryShared/MyRewardsModal.js"),Ue=require("../LotteryShared/ErrorModal.js"),Fe=require("../LotteryShared/ShareModal.js"),je=require("../LotteryShared/BaseModal.js");const Ft="image",c="lottery_banner",w="\u4EA7\u54C1\u62BD\u5956",x="copy",v="lottery_pop",E="image",ae=(0,e.forwardRef)(({prizes:s,media:l,theme:r,ctaButton:P,videoAutoPlay:m,videoMuted:Ge,videoLoop:Be,chanceMethods:se=Ne.DEFAULT_CHANCE_METHODS,chanceTitle:Ye=Ce.DEFAULT_CHANCE_TITLE,chanceSubtitle:Ke,chanceFooterNote:Je,chanceMethodsText:I,mechanismType:H,inputConfig:p,inputPlaceholder:ie,inputSubmitText:le,inputType:pe,inputValidationErrorText:de,winnerTickerData:Qe=[],winningInfos:ce,winnerNameTemplate:Xe,prizesTitle:Ze,onDrawStart:U,onDrawEnd:F,onDrawError:me,winnerModalConfig:fe,rulesModalConfig:Ve={},actionButtonConfig:f,myRewardsModalConfig:qe={},errorModalConfig:D={},shareModalConfig:C={},error:h,tryAgain:j,userData:y,loginPrompt:et,loginPromptText:tt="Please log in to participate",loginButtonText:Bt="Log In",onLoginRequired:N,onCopyCode:ot,opportunitiesPrefix:ue,opportunitiesText:rt=["Number of draws remaining today:"],dealsType:Yt,className:nt},at)=>{const Kt=et??tt??"Please log in to participate",xe=ue?[ue]:rt??["Number of draws remaining today:"],ge=ie||le||pe||de?{...p??{},placeholder:ie??p?.placeholder??"Enter your order number",submitText:le??p?.submitText??"Spin and Win",inputType:pe??p?.inputType??"text",validationErrorText:de??p?.validationErrorText}:p,b=h?{title:h.title??D?.title,message:h.defaultMessage??D?.message,confirmText:h.confirmButton??D?.confirmText,exchangeFailedTitle:h.exchangeFailedTitle,exchangeFailedMessage:h.exchangeFailedMessage}:D,n={...ce,...fe,confirmText:fe?.confirmText??ce?.confirmButton},{rulesData:S,rulesText:G="Rules"}=Ve,st=!!(f?.text&&f?.url),{rewardsData:B,myRewardsText:Y="My Rewards",codeText:it="CODE:",copyText:Te="COPY",copiedText:he="COPIED",prizeText:lt="Prize time:",emptyText:pt,copyError:dt,availableText:ct,usedStatusText:mt,expiredText:ft,notFoundText:ut}=qe,xt=I?.completedText,gt=I?.usedText,K=y?.isLoggedIn??!1,Tt=y?.availableChances??0,ye=se.length>0||H==="input",Me=H==="input"&&!!p?.agreementNotice,[k,J]=(0,e.useState)(!1),[d,we]=(0,e.useState)(null),[Q,L]=(0,e.useState)(!1),[X,W]=(0,e.useState)(!1),[Z,R]=(0,e.useState)(!1),[V,M]=(0,e.useState)(!1),[q,A]=(0,e.useState)(!1),[ee,O]=(0,e.useState)(!1),[ve,$]=(0,e.useState)(""),[ht,yt]=(0,e.useState)(),[Mt,wt]=(0,e.useState)(),[vt,Et]=(0,e.useState)(),[_t,Pt]=(0,e.useState)(),[Ct,Nt]=(0,e.useState)(),[a,bt]=(0,e.useState)(),[te,St]=(0,e.useState)(!1),Ee=(0,e.useRef)(null);(0,Ie.useExposure)(Ee,{componentType:Ft,componentName:c,componentTitle:w});const{trackingData:i,pageHandle:_e}=(0,ze.useAiuiContext)();(0,e.useEffect)(()=>{Q&&(0,T.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:v,component_title:"Winner"}})},[Q,i]),(0,e.useEffect)(()=>{q&&(0,T.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:v,component_title:"Better Luck Next Time"}})},[q,i]),(0,e.useEffect)(()=>{X&&(0,T.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:v,component_title:"Rules"}})},[X,i]),(0,e.useEffect)(()=>{Z&&(0,T.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:v,component_title:"My Rewards"}})},[Z,i]),(0,e.useEffect)(()=>{ee&&(0,T.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:v,component_title:"Share"}})},[ee,i]),(0,e.useEffect)(()=>{V&&(0,T.gaTrack)({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:i?.pageGroup||"Home Page",component_type:E,component_name:v,component_title:"Error"}})},[V,i]),(0,e.useImperativeHandle)(at,()=>({showError:({message:o,title:u,confirmText:oe})=>{$(o),yt(u),wt(oe),M(!0)},hideError:()=>{M(!1)},showNoWin:o=>{Et(o?.title),Pt(o?.message),Nt(o?.confirmText),A(!0)},hideNoWin:()=>{A(!1)},showWinner:(o,u)=>{we(o),bt(u),L(!0)},hideWinner:()=>{L(!1)},showRules:()=>{W(!0)},hideRules:()=>{W(!1)},showRewards:()=>{R(!0)},hideRewards:()=>{R(!1)},showShare:()=>{O(!0)},hideShare:()=>{O(!1)},hideAllModals:()=>{L(!1),W(!1),R(!1),M(!1),A(!1),O(!1)}}),[]);const Pe=(0,e.useCallback)(async()=>{if(!k){if(Me&&!te){$(p?.agreementWarningText||"Please agree to the terms before continuing"),M(!1);return}if(!y?.isLoggedIn){N?.();return}if(!(y.availableChances<=0)){J(!0);try{let o;U&&(o=await U());const u=s.find(oe=>oe.prizeKey===o)||s[0];we(u),J(!1),F?F(u):setTimeout(()=>{u.prizeKey==="try-again"?A(!0):L(!0)},300)}catch(o){J(!1),$(o.message||"An error occurred"),M(!0),me?.(o)}}}},[Me,p?.agreementWarningText,te,k,s,U,F,me,y,N]),kt=(0,e.useCallback)(()=>{if(!K){N?.();return}Pe()},[Pe,K,N]),Lt=(0,e.useCallback)(()=>{L(!1)},[]),Wt=(0,e.useCallback)(()=>{A(!1)},[]),Rt=vt||j?.title,At=_t||j?.message,Ot=Ct||j?.confirmText;return(0,t.jsxs)("div",{ref:Ee,className:(0,g.cn)("product-lottery-container","w-full",r==="dark"?"aiui-dark":"",nt),children:[(0,t.jsxs)("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:[k&&"Drawing in progress...",d&&!k&&`Prize won: ${d.name}`]}),(0,t.jsxs)(z.Grid,{className:(0,g.cn)("product-lottery-main","tablet:mb-4 mb-3"),children:[(0,t.jsx)(z.GridItem,{span:ye?7:12,className:(0,g.cn)("media-section","relative flex w-full flex-1 items-center justify-center overflow-hidden","rounded-box","laptop:min-h-[288px] min-h-[240px]","lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]","desktop:aspect-w-[759] desktop:aspect-h-[384]","laptop:aspect-w-[516] laptop:aspect-h-[288]","l-tablet:col-span-12","l-tablet:mb-3",r==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsxs)("div",{className:(0,g.cn)("size-full px-[16px] pt-[16px]","lg-desktop:pb-[32px] lg-desktop:px-[32px]","desktop:pt-[24px] desktop:px-[24px]","laptop:pt-[16px] laptop:px-[16px]","tablet:px-[24px]","l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10","flex flex-col"),children:[(0,t.jsxs)("div",{className:"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3",children:[(0,t.jsx)("div",{children:(0,t.jsxs)("p",{className:"text-info-primary font-[700]",children:[xe?.[0],(0,t.jsx)("span",{className:"ml-1 text-[#FF6B35]",children:Tt}),xe?.[1]||""]})}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[S&&S.length>0&&(0,t.jsx)("button",{onClick:o=>{o.preventDefault(),o.stopPropagation(),W(!0)},className:"cursor-pointer touch-manipulation",type:"button","data-headless-type-name":`${x}#${c}`,"data-headless-title-desc-button":`${w}##${G}`,children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:G})}),B&&(0,t.jsx)("button",{onClick:o=>{if(o.preventDefault(),o.stopPropagation(),!K){N?.();return}R(!0)},className:"cursor-pointer touch-manipulation whitespace-nowrap",type:"button","data-headless-type-name":`${x}#${c}`,"data-headless-title-desc-button":`${w}##${Y}`,children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:Y})}),st&&(0,t.jsx)("a",{href:(0,_.trackUrlRef)(f?.url??"",(0,_.buildTrackingRef)(_e??"",x,c)),className:"cursor-pointer touch-manipulation whitespace-nowrap",onClick:o=>{o.preventDefault(),o.stopPropagation(),f?.url&&(window.location.href=(0,_.trackUrlRef)(f.url,(0,_.buildTrackingRef)(_e??"",x,c)))},"data-headless-type-name":`${x}#${c}`,"data-headless-title-desc-button":`${w}##${f?.text}`,children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:f?.text})})]})]}),(0,t.jsx)(be.MediaDrawArea,{className:"min-h-0 w-full flex-1",theme:r,media:l,ctaButton:P,videoAutoPlay:m,videoMuted:Ge,videoLoop:Be,isDrawing:k,onClick:kt,ctaTrackTypeName:`${x}#${c}`,ctaTrackTitleDescButton:`${w}##${P?.text??""}`})]})}),ye&&(0,t.jsx)(z.GridItem,{span:5,className:(0,g.cn)("info-section","rounded-box","relative flex flex-col overflow-hidden","lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]","desktop:aspect-w-[536] desktop:aspect-h-[384]","laptop:aspect-w-[364] laptop:aspect-h-[288]","l-tablet:min-h-[280px] laptop:max-h-[320px]","w-full","l-tablet:col-span-12",r==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsx)(ke.ChanceMethods,{theme:r,userData:y,methods:se,title:Ye,subtitle:Ke,footerNote:Je,onOpenShareModal:()=>O(!0),chanceBadgeText:I?.chanceBadgeText,completedText:xt,usedText:gt,loadingText:I?.loadingText,mechanismType:H,inputConfig:{...ge,submitTrackTypeName:`${x}#${c}`,submitTrackTitleDescButton:`${w}##${ge?.submitText??"Spin and Win"}`},isAgreementChecked:te,onAgreementCheckedChange:o=>{St(o),o&&$("")},agreementErrorText:ve})})]}),(0,t.jsx)("div",{className:(0,g.cn)("product-lottery-footer","rounded-box","flex flex-col overflow-hidden",r==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsx)(Se.PrizePool,{theme:r,prizes:s,title:Ze,winningInfos:Qe,winnerNameTemplate:Xe})}),(0,t.jsx)(Le.WinnerModal,{isOpen:Q,prize:d,title:a?.title||n.title,prizeTitle:a?.prizeTitle||n.prizeTitle,prizeImage:a?.prizeImage||n.prizeImage,prizeDescription:a?.prizeDescription||n.prizeDescription,winnerNote:a?.winnerNote??d?.winnerModalConfig?.winnerNote??n.winnerNote,learnMoreUrl:a?.learnMoreUrl||d?.winnerModalConfig?.learnMoreUrl||n.learnMoreUrl,learnMoreText:a?.learnMoreText||d?.winnerModalConfig?.learnMoreText||n.learnMoreText,couponCode:a?.couponCode||n.couponCode,expiresAt:a?.expiresAt||n.expiresAt,couponDiscount:a?.couponDiscount||n.couponDiscount,couponUnit:a?.couponUnit||n.couponUnit,confirmText:a?.confirmText||d?.winnerModalConfig?.confirmText||n.confirmText,confirmUrl:a?.confirmUrl||d?.winnerModalConfig?.confirmUrl||n.confirmUrl,copyText:a?.copyText||n.copyText||Te,copiedText:a?.copiedText||n.copiedText||he,onClose:Lt,theme:r}),S&&S.length>0&&(0,t.jsx)(We.RulesModal,{title:G,isOpen:X,onClose:()=>W(!1),rules:S,theme:r}),B&&(0,t.jsx)(Re.MyRewardsModal,{isOpen:Z,onClose:()=>R(!1),rewards:B,onCopyCode:ot,codeText:it,copyText:Te,copiedText:he,prizeText:lt,emptyText:pt,copyError:dt,availableText:ct,usedStatusText:mt,expiredText:ft,notFoundText:ut,theme:r,title:Y}),(0,t.jsx)(ne.ErrorModal,{isOpen:V,onClose:()=>M(!1),title:ht||b?.title,message:ve||b?.message,confirmText:Mt||b?.confirmText,exchangeFailedTitle:b?.exchangeFailedTitle,exchangeFailedMessage:b?.exchangeFailedMessage,theme:r}),(0,t.jsx)(ne.ErrorModal,{isOpen:q,onClose:Wt,title:Rt,message:At,confirmText:Ot,theme:r}),(0,t.jsx)(Ae.ShareModal,{isOpen:ee,onClose:()=>O(!1),title:C?.title,subtitle:C?.subtitle,note:C?.note,platforms:C?.platforms,onShareSuccess:C?.onShareSuccess,theme:r})]})});ae.displayName="ProductLottery";var jt=(0,Oe.withLayout)(ae);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/ProductLottery/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport { useState, useCallback, useImperativeHandle, forwardRef, useEffect, useRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_CHANCE_TITLE } from './types.js'\nimport { DEFAULT_CHANCE_METHODS } from '../LotteryShared/types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { MediaDrawArea } from './MediaDrawArea.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef, buildTrackingRef } from '../../shared/trackUrlRef.js'\n\nimport type { ProductLotteryProps, ProductLotteryHandle } from './types.js'\nimport type { Prize, WinnerModalConfig, ChanceInputConfig } from '../LotteryShared/types.js'\n\nconst LOTTERY_COMPONENT_TYPE = 'image'\nconst LOTTERY_COMPONENT_NAME = 'lottery_banner'\nconst LOTTERY_COMPONENT_TITLE = '\u4EA7\u54C1\u62BD\u5956'\nconst LOTTERY_CLICK_TYPE = 'copy'\nconst LOTTERY_MODAL_COMPONENT_NAME = 'lottery_pop'\nconst LOTTERY_MODAL_COMPONENT_TYPE = 'image'\n\nexport const ProductLottery = forwardRef<ProductLotteryHandle, ProductLotteryProps>(\n (\n {\n prizes,\n media,\n theme,\n ctaButton,\n videoAutoPlay,\n videoMuted,\n videoLoop,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_CHANCE_TITLE,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n inputPlaceholder,\n inputSubmitText,\n inputType,\n inputValidationErrorText,\n winnerTickerData = [],\n winningInfos,\n winnerNameTemplate,\n prizesTitle,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n winnerModalConfig,\n rulesModalConfig = {},\n actionButtonConfig,\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n error,\n tryAgain,\n userData,\n loginPrompt,\n loginPromptText = 'Please log in to participate',\n loginButtonText = 'Log In',\n noChances,\n noChancesText = 'You have no chances left',\n onLoginRequired,\n onCopyCode,\n opportunitiesPrefix,\n opportunitiesText = ['Number of draws remaining today:'],\n dealsType,\n className,\n },\n ref\n ) => {\n // \u2500\u2500 CMS field normalization \u2500\u2500\n // CMS-primary strategy: CMS fields take precedence over legacy backward-compat fields.\n // If a CMS field is provided, it overrides the corresponding legacy field.\n const resolvedLoginPrompt = loginPrompt ?? loginPromptText ?? 'Please log in to participate'\n const resolvedNoChances = noChances ?? noChancesText ?? 'You have no chances left'\n const resolvedOpportunitiesText: string[] = opportunitiesPrefix\n ? [opportunitiesPrefix]\n : (opportunitiesText ?? ['Number of draws remaining today:'])\n const resolvedInputConfig: ChanceInputConfig | undefined =\n inputPlaceholder || inputSubmitText || inputType || inputValidationErrorText\n ? {\n ...(inputConfig ?? {}),\n placeholder: inputPlaceholder ?? inputConfig?.placeholder ?? 'Enter your order number',\n submitText: inputSubmitText ?? inputConfig?.submitText ?? 'Spin and Win',\n inputType: inputType ?? inputConfig?.inputType ?? 'text',\n validationErrorText: inputValidationErrorText ?? inputConfig?.validationErrorText,\n }\n : inputConfig\n const resolvedErrorConfig = error\n ? {\n title: error.title ?? errorModalConfig?.title,\n message: error.defaultMessage ?? errorModalConfig?.message,\n confirmText: error.confirmButton ?? errorModalConfig?.confirmText,\n exchangeFailedTitle: error.exchangeFailedTitle,\n exchangeFailedMessage: error.exchangeFailedMessage,\n }\n : errorModalConfig\n const resolvedWinnerConfig: WinnerModalConfig = {\n ...winningInfos,\n ...winnerModalConfig,\n confirmText: winnerModalConfig?.confirmText ?? winningInfos?.confirmButton,\n }\n\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const shouldShowActionButton = Boolean(actionButtonConfig?.text && actionButtonConfig?.url)\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances ?? 0\n const hasRightPanel = chanceMethods.length > 0 || mechanismType === 'input'\n const hasAgreementNotice = mechanismType === 'input' && Boolean(inputConfig?.agreementNotice)\n const showNoChancesOverlay = isLoggedIn && availableChances <= 0 && userData?.isChancesLoading !== true\n\n // State\n const [isDrawing, setIsDrawing] = useState(false)\n const [winningPrize, setWinningPrize] = useState<Prize | null>(null)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const [isAgreementChecked, setIsAgreementChecked] = useState(false)\n\n // Exposure tracking\n const containerRef = useRef<HTMLDivElement>(null)\n useExposure(containerRef, {\n componentType: LOTTERY_COMPONENT_TYPE,\n componentName: LOTTERY_COMPONENT_NAME,\n componentTitle: LOTTERY_COMPONENT_TITLE,\n })\n\n // Tracking\n const { trackingData, pageHandle } = useAiuiContext()\n\n // Modal impression tracking \u2014 fires once per open\n useEffect(() => {\n if (!showWinnerModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Winner',\n },\n })\n }, [showWinnerModal, trackingData])\n\n useEffect(() => {\n if (!showNoWinModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Better Luck Next Time',\n },\n })\n }, [showNoWinModal, trackingData])\n\n useEffect(() => {\n if (!showRulesModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Rules',\n },\n })\n }, [showRulesModal, trackingData])\n\n useEffect(() => {\n if (!showRewardsModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'My Rewards',\n },\n })\n }, [showRewardsModal, trackingData])\n\n useEffect(() => {\n if (!showShareModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Share',\n },\n })\n }, [showShareModal, trackingData])\n\n useEffect(() => {\n if (!showErrorModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Error',\n },\n })\n }, [showErrorModal, trackingData])\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWinningPrize(prize)\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n const handleDrawStart = useCallback(async () => {\n if (isDrawing) return\n\n if (hasAgreementNotice && !isAgreementChecked) {\n setErrorMessage(inputConfig?.agreementWarningText || 'Please agree to the terms before continuing')\n setShowErrorModal(false)\n return\n }\n\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n if (userData.availableChances <= 0) {\n return\n }\n\n setIsDrawing(true)\n\n try {\n let prizeId: string | undefined\n\n if (onDrawStart) {\n prizeId = await onDrawStart()\n }\n\n const prize = prizes.find(p => p.prizeKey === prizeId) || prizes[0]\n setWinningPrize(prize)\n setIsDrawing(false)\n\n if (onDrawEnd) {\n onDrawEnd(prize)\n } else {\n setTimeout(() => {\n if (prize.prizeKey === 'try-again') {\n setShowNoWinModal(true)\n } else {\n setShowWinnerModal(true)\n }\n }, 300)\n }\n } catch (error) {\n setIsDrawing(false)\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n onDrawError?.(error as Error)\n }\n }, [\n hasAgreementNotice,\n inputConfig?.agreementWarningText,\n isAgreementChecked,\n isDrawing,\n prizes,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n userData,\n onLoginRequired,\n ])\n\n const handleDrawClick = useCallback(() => {\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n void handleDrawStart()\n }, [handleDrawStart, isLoggedIn, onLoginRequired])\n\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n }, [])\n\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n }, [])\n\n // \u2500\u2500 TryAgain / no-win modal normalization \u2500\u2500\n const resolvedTryAgainTitle = noWinTitle || tryAgain?.title\n const resolvedTryAgainMessage = noWinMessage || tryAgain?.message\n const resolvedTryAgainConfirmText = noWinConfirmText || tryAgain?.confirmText\n\n return (\n <div\n ref={containerRef}\n className={cn('product-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}\n >\n {/* ARIA Live Region */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {isDrawing && 'Drawing in progress...'}\n {winningPrize && !isDrawing && `Prize won: ${winningPrize.name}`}\n </div>\n\n {/* Main Content \u2014 Responsive Grid */}\n <Grid className={cn('product-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* Left: Media Draw Area */}\n <GridItem\n span={hasRightPanel ? 7 : 12}\n className={cn(\n 'media-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'size-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10',\n 'flex flex-col'\n )}\n >\n {/* Top bar: chances + rules/rewards links */}\n <div className=\"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3\">\n <div>\n <p className=\"text-info-primary font-[700]\">\n {resolvedOpportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {resolvedOpportunitiesText?.[1] || ''}\n </p>\n </div>\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n setShowRulesModal(true)\n }}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${rulesText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {rewardsData && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n setShowRewardsModal(true)\n }}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${myRewardsText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n {shouldShowActionButton && (\n <a\n href={trackUrlRef(\n actionButtonConfig?.url ?? '',\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (actionButtonConfig?.url) {\n window.location.href = trackUrlRef(\n actionButtonConfig.url,\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )\n }\n }}\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${actionButtonConfig?.text}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{actionButtonConfig?.text}</span>\n </a>\n )}\n </div>\n </div>\n\n {/* Media Draw Area */}\n <MediaDrawArea\n className=\"min-h-0 w-full flex-1\"\n theme={theme}\n media={media}\n ctaButton={ctaButton}\n videoAutoPlay={videoAutoPlay}\n videoMuted={videoMuted}\n videoLoop={videoLoop}\n isDrawing={isDrawing}\n isDisabled={showNoChancesOverlay}\n onClick={handleDrawClick}\n ctaTrackTypeName={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n ctaTrackTitleDescButton={`${LOTTERY_COMPONENT_TITLE}##${ctaButton?.text ?? ''}`}\n />\n\n {showNoChancesOverlay && (\n <div\n className={cn(\n 'rounded-box absolute inset-0 z-20 flex items-center justify-center bg-black/60 backdrop-blur-sm',\n 'px-6 text-center'\n )}\n >\n <div className=\"flex flex-col items-center gap-4\">\n <p className=\"lg-desktop:text-[24px] text-[18px] font-semibold text-white\">{resolvedNoChances}</p>\n </div>\n </div>\n )}\n </div>\n </GridItem>\n\n {/* Right: Chance Methods */}\n {hasRightPanel && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={{\n ...resolvedInputConfig,\n submitTrackTypeName: `${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`,\n submitTrackTitleDescButton: `${LOTTERY_COMPONENT_TITLE}##${resolvedInputConfig?.submitText ?? 'Spin and Win'}`,\n }}\n isAgreementChecked={isAgreementChecked}\n onAgreementCheckedChange={checked => {\n setIsAgreementChecked(checked)\n if (checked) {\n setErrorMessage('')\n }\n }}\n agreementErrorText={errorMessage}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* Footer: Prize Pool */}\n <div\n className={cn(\n 'product-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winnerTickerData}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* Winner Modal */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={winningPrize}\n title={externalWinnerConfig?.title || resolvedWinnerConfig.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || resolvedWinnerConfig.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || resolvedWinnerConfig.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || resolvedWinnerConfig.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n winningPrize?.winnerModalConfig?.winnerNote ??\n resolvedWinnerConfig.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n winningPrize?.winnerModalConfig?.learnMoreUrl ||\n resolvedWinnerConfig.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n winningPrize?.winnerModalConfig?.learnMoreText ||\n resolvedWinnerConfig.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || resolvedWinnerConfig.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || resolvedWinnerConfig.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || resolvedWinnerConfig.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || resolvedWinnerConfig.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n winningPrize?.winnerModalConfig?.confirmText ||\n resolvedWinnerConfig.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n winningPrize?.winnerModalConfig?.confirmUrl ||\n resolvedWinnerConfig.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || resolvedWinnerConfig.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || resolvedWinnerConfig.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules Modal */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards Modal */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* Error Modal */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || resolvedErrorConfig?.title}\n message={errorMessage || resolvedErrorConfig?.message}\n confirmText={errorConfirmText || resolvedErrorConfig?.confirmText}\n exchangeFailedTitle={resolvedErrorConfig?.exchangeFailedTitle}\n exchangeFailedMessage={resolvedErrorConfig?.exchangeFailedMessage}\n theme={theme}\n />\n\n {/* No-Win Modal */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={resolvedTryAgainTitle}\n message={resolvedTryAgainMessage}\n confirmText={resolvedTryAgainConfirmText}\n theme={theme}\n />\n\n {/* Share Modal */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\nProductLottery.displayName = 'ProductLottery'\n\nexport default withLayout(ProductLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n ProductLotteryProps,\n ProductLotteryHandle,\n MediaConfig,\n CtaButtonConfig,\n MediaDrawAreaProps,\n} from './types.js'\nexport type {\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from '../LotteryShared/types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
-
"mappings": "ocAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,iHAAAE,GAAA,qGAAAC,KAAA,eAAAC,GAAAJ,IAgZQ,IAAAK,EAAA,6BA9YRC,EAA0F,iBAC1FC,EAAmB,kCACnBC,GAAqC,sBACrCA,GAAuC,qCACvC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AUA,GAAkB,SAC5B,KAAMA,GAAkB,KACxB,UAAWA,GAAkB,UAC7B,eAAgBA,GAAkB,eAClC,MAAO5B,EACT,GACF,CAEJ,CACF,EAEA9B,GAAe,YAAc,iBAE7B,IAAOC,MAAQ,eAAWD,EAAc",
|
|
6
|
-
"names": ["ProductLottery_exports", "__export", "ProductLottery", "ProductLottery_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_helpers", "import_types", "import_grid", "import_MediaDrawArea", "import_PrizePool", "import_ChanceMethods", "import_WinnerModal", "import_RulesModal", "import_MyRewardsModal", "import_ErrorModal", "import_ShareModal", "import_Styles", "import_track", "import_AiuiProvider", "import_useExposure", "import_trackUrlRef", "import_BaseModal", "LOTTERY_COMPONENT_TYPE", "LOTTERY_COMPONENT_NAME", "LOTTERY_COMPONENT_TITLE", "LOTTERY_CLICK_TYPE", "LOTTERY_MODAL_COMPONENT_NAME", "LOTTERY_MODAL_COMPONENT_TYPE", "prizes", "media", "theme", "ctaButton", "videoAutoPlay", "videoMuted", "videoLoop", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "inputPlaceholder", "inputSubmitText", "inputType", "inputValidationErrorText", "winnerTickerData", "winningInfos", "winnerNameTemplate", "prizesTitle", "onDrawStart", "onDrawEnd", "onDrawError", "winnerModalConfig", "rulesModalConfig", "actionButtonConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "error", "tryAgain", "userData", "loginPrompt", "loginPromptText", "loginButtonText", "
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport { useState, useCallback, useImperativeHandle, forwardRef, useEffect, useRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_CHANCE_TITLE } from './types.js'\nimport { DEFAULT_CHANCE_METHODS } from '../LotteryShared/types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { MediaDrawArea } from './MediaDrawArea.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef, buildTrackingRef } from '../../shared/trackUrlRef.js'\n\nimport type { ProductLotteryProps, ProductLotteryHandle } from './types.js'\nimport type { Prize, WinnerModalConfig, ChanceInputConfig } from '../LotteryShared/types.js'\n\nconst LOTTERY_COMPONENT_TYPE = 'image'\nconst LOTTERY_COMPONENT_NAME = 'lottery_banner'\nconst LOTTERY_COMPONENT_TITLE = '\u4EA7\u54C1\u62BD\u5956'\nconst LOTTERY_CLICK_TYPE = 'copy'\nconst LOTTERY_MODAL_COMPONENT_NAME = 'lottery_pop'\nconst LOTTERY_MODAL_COMPONENT_TYPE = 'image'\n\nexport const ProductLottery = forwardRef<ProductLotteryHandle, ProductLotteryProps>(\n (\n {\n prizes,\n media,\n theme,\n ctaButton,\n videoAutoPlay,\n videoMuted,\n videoLoop,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_CHANCE_TITLE,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n inputPlaceholder,\n inputSubmitText,\n inputType,\n inputValidationErrorText,\n winnerTickerData = [],\n winningInfos,\n winnerNameTemplate,\n prizesTitle,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n winnerModalConfig,\n rulesModalConfig = {},\n actionButtonConfig,\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n error,\n tryAgain,\n userData,\n loginPrompt,\n loginPromptText = 'Please log in to participate',\n loginButtonText = 'Log In',\n onLoginRequired,\n onCopyCode,\n opportunitiesPrefix,\n opportunitiesText = ['Number of draws remaining today:'],\n dealsType,\n className,\n },\n ref\n ) => {\n // \u2500\u2500 CMS field normalization \u2500\u2500\n // CMS-primary strategy: CMS fields take precedence over legacy backward-compat fields.\n // If a CMS field is provided, it overrides the corresponding legacy field.\n const resolvedLoginPrompt = loginPrompt ?? loginPromptText ?? 'Please log in to participate'\n const resolvedOpportunitiesText: string[] = opportunitiesPrefix\n ? [opportunitiesPrefix]\n : (opportunitiesText ?? ['Number of draws remaining today:'])\n const resolvedInputConfig: ChanceInputConfig | undefined =\n inputPlaceholder || inputSubmitText || inputType || inputValidationErrorText\n ? {\n ...(inputConfig ?? {}),\n placeholder: inputPlaceholder ?? inputConfig?.placeholder ?? 'Enter your order number',\n submitText: inputSubmitText ?? inputConfig?.submitText ?? 'Spin and Win',\n inputType: inputType ?? inputConfig?.inputType ?? 'text',\n validationErrorText: inputValidationErrorText ?? inputConfig?.validationErrorText,\n }\n : inputConfig\n const resolvedErrorConfig = error\n ? {\n title: error.title ?? errorModalConfig?.title,\n message: error.defaultMessage ?? errorModalConfig?.message,\n confirmText: error.confirmButton ?? errorModalConfig?.confirmText,\n exchangeFailedTitle: error.exchangeFailedTitle,\n exchangeFailedMessage: error.exchangeFailedMessage,\n }\n : errorModalConfig\n const resolvedWinnerConfig: WinnerModalConfig = {\n ...winningInfos,\n ...winnerModalConfig,\n confirmText: winnerModalConfig?.confirmText ?? winningInfos?.confirmButton,\n }\n\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const shouldShowActionButton = Boolean(actionButtonConfig?.text && actionButtonConfig?.url)\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances ?? 0\n const hasRightPanel = chanceMethods.length > 0 || mechanismType === 'input'\n const hasAgreementNotice = mechanismType === 'input' && Boolean(inputConfig?.agreementNotice)\n\n // State\n const [isDrawing, setIsDrawing] = useState(false)\n const [winningPrize, setWinningPrize] = useState<Prize | null>(null)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const [isAgreementChecked, setIsAgreementChecked] = useState(false)\n\n // Exposure tracking\n const containerRef = useRef<HTMLDivElement>(null)\n useExposure(containerRef, {\n componentType: LOTTERY_COMPONENT_TYPE,\n componentName: LOTTERY_COMPONENT_NAME,\n componentTitle: LOTTERY_COMPONENT_TITLE,\n })\n\n // Tracking\n const { trackingData, pageHandle } = useAiuiContext()\n\n // Modal impression tracking \u2014 fires once per open\n useEffect(() => {\n if (!showWinnerModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Winner',\n },\n })\n }, [showWinnerModal, trackingData])\n\n useEffect(() => {\n if (!showNoWinModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Better Luck Next Time',\n },\n })\n }, [showNoWinModal, trackingData])\n\n useEffect(() => {\n if (!showRulesModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Rules',\n },\n })\n }, [showRulesModal, trackingData])\n\n useEffect(() => {\n if (!showRewardsModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'My Rewards',\n },\n })\n }, [showRewardsModal, trackingData])\n\n useEffect(() => {\n if (!showShareModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Share',\n },\n })\n }, [showShareModal, trackingData])\n\n useEffect(() => {\n if (!showErrorModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Error',\n },\n })\n }, [showErrorModal, trackingData])\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWinningPrize(prize)\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n const handleDrawStart = useCallback(async () => {\n if (isDrawing) return\n\n if (hasAgreementNotice && !isAgreementChecked) {\n setErrorMessage(inputConfig?.agreementWarningText || 'Please agree to the terms before continuing')\n setShowErrorModal(false)\n return\n }\n\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n if (userData.availableChances <= 0) {\n return\n }\n\n setIsDrawing(true)\n\n try {\n let prizeId: string | undefined\n\n if (onDrawStart) {\n prizeId = await onDrawStart()\n }\n\n const prize = prizes.find(p => p.prizeKey === prizeId) || prizes[0]\n setWinningPrize(prize)\n setIsDrawing(false)\n\n if (onDrawEnd) {\n onDrawEnd(prize)\n } else {\n setTimeout(() => {\n if (prize.prizeKey === 'try-again') {\n setShowNoWinModal(true)\n } else {\n setShowWinnerModal(true)\n }\n }, 300)\n }\n } catch (error) {\n setIsDrawing(false)\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n onDrawError?.(error as Error)\n }\n }, [\n hasAgreementNotice,\n inputConfig?.agreementWarningText,\n isAgreementChecked,\n isDrawing,\n prizes,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n userData,\n onLoginRequired,\n ])\n\n const handleDrawClick = useCallback(() => {\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n void handleDrawStart()\n }, [handleDrawStart, isLoggedIn, onLoginRequired])\n\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n }, [])\n\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n }, [])\n\n // \u2500\u2500 TryAgain / no-win modal normalization \u2500\u2500\n const resolvedTryAgainTitle = noWinTitle || tryAgain?.title\n const resolvedTryAgainMessage = noWinMessage || tryAgain?.message\n const resolvedTryAgainConfirmText = noWinConfirmText || tryAgain?.confirmText\n\n return (\n <div\n ref={containerRef}\n className={cn('product-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}\n >\n {/* ARIA Live Region */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {isDrawing && 'Drawing in progress...'}\n {winningPrize && !isDrawing && `Prize won: ${winningPrize.name}`}\n </div>\n\n {/* Main Content \u2014 Responsive Grid */}\n <Grid className={cn('product-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* Left: Media Draw Area */}\n <GridItem\n span={hasRightPanel ? 7 : 12}\n className={cn(\n 'media-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'size-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10',\n 'flex flex-col'\n )}\n >\n {/* Top bar: chances + rules/rewards links */}\n <div className=\"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3\">\n <div>\n <p className=\"text-info-primary font-[700]\">\n {resolvedOpportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {resolvedOpportunitiesText?.[1] || ''}\n </p>\n </div>\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n setShowRulesModal(true)\n }}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${rulesText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {rewardsData && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n setShowRewardsModal(true)\n }}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${myRewardsText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n {shouldShowActionButton && (\n <a\n href={trackUrlRef(\n actionButtonConfig?.url ?? '',\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (actionButtonConfig?.url) {\n window.location.href = trackUrlRef(\n actionButtonConfig.url,\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )\n }\n }}\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${actionButtonConfig?.text}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{actionButtonConfig?.text}</span>\n </a>\n )}\n </div>\n </div>\n\n {/* Media Draw Area */}\n <MediaDrawArea\n className=\"min-h-0 w-full flex-1\"\n theme={theme}\n media={media}\n ctaButton={ctaButton}\n videoAutoPlay={videoAutoPlay}\n videoMuted={videoMuted}\n videoLoop={videoLoop}\n isDrawing={isDrawing}\n onClick={handleDrawClick}\n ctaTrackTypeName={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n ctaTrackTitleDescButton={`${LOTTERY_COMPONENT_TITLE}##${ctaButton?.text ?? ''}`}\n />\n </div>\n </GridItem>\n\n {/* Right: Chance Methods */}\n {hasRightPanel && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={{\n ...resolvedInputConfig,\n submitTrackTypeName: `${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`,\n submitTrackTitleDescButton: `${LOTTERY_COMPONENT_TITLE}##${resolvedInputConfig?.submitText ?? 'Spin and Win'}`,\n }}\n isAgreementChecked={isAgreementChecked}\n onAgreementCheckedChange={checked => {\n setIsAgreementChecked(checked)\n if (checked) {\n setErrorMessage('')\n }\n }}\n agreementErrorText={errorMessage}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* Footer: Prize Pool */}\n <div\n className={cn(\n 'product-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winnerTickerData}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* Winner Modal */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={winningPrize}\n title={externalWinnerConfig?.title || resolvedWinnerConfig.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || resolvedWinnerConfig.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || resolvedWinnerConfig.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || resolvedWinnerConfig.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n winningPrize?.winnerModalConfig?.winnerNote ??\n resolvedWinnerConfig.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n winningPrize?.winnerModalConfig?.learnMoreUrl ||\n resolvedWinnerConfig.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n winningPrize?.winnerModalConfig?.learnMoreText ||\n resolvedWinnerConfig.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || resolvedWinnerConfig.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || resolvedWinnerConfig.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || resolvedWinnerConfig.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || resolvedWinnerConfig.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n winningPrize?.winnerModalConfig?.confirmText ||\n resolvedWinnerConfig.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n winningPrize?.winnerModalConfig?.confirmUrl ||\n resolvedWinnerConfig.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || resolvedWinnerConfig.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || resolvedWinnerConfig.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules Modal */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards Modal */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* Error Modal */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || resolvedErrorConfig?.title}\n message={errorMessage || resolvedErrorConfig?.message}\n confirmText={errorConfirmText || resolvedErrorConfig?.confirmText}\n exchangeFailedTitle={resolvedErrorConfig?.exchangeFailedTitle}\n exchangeFailedMessage={resolvedErrorConfig?.exchangeFailedMessage}\n theme={theme}\n />\n\n {/* No-Win Modal */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={resolvedTryAgainTitle}\n message={resolvedTryAgainMessage}\n confirmText={resolvedTryAgainConfirmText}\n theme={theme}\n />\n\n {/* Share Modal */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\nProductLottery.displayName = 'ProductLottery'\n\nexport default withLayout(ProductLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n ProductLotteryProps,\n ProductLotteryHandle,\n MediaConfig,\n CtaButtonConfig,\n MediaDrawAreaProps,\n} from './types.js'\nexport type {\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from '../LotteryShared/types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
+
"mappings": "ocAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,iHAAAE,GAAA,qGAAAC,KAAA,eAAAC,GAAAJ,IA4YQ,IAAAK,EAAA,6BA1YRC,EAA0F,iBAC1FC,EAAmB,kCACnBC,GAAqC,sBACrCA,GAAuC,qCACvCC,EAA+B,oCAC/BC,GAA8B,8BAC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B1B,GAAc,mBAAmB,YACjCxB,EAAqB,WAEvB,SAAUkD,GAAsB,UAAYlD,EAAqB,UAAYO,GAC7E,WAAY2C,GAAsB,YAAclD,EAAqB,YAAcQ,GACnF,QAAS0D,GACT,MAAOhH,EACT,EAGC+C,GAAaA,EAAU,OAAS,MAC/B,OAAC,eACC,MAAOC,EACP,OAAQ0B,EACR,QAAS,IAAMC,EAAkB,EAAK,EACtC,MAAO5B,EACP,MAAO/C,EACT,EAIDkD,MACC,OAAC,mBACC,OAAQ0B,EACR,QAAS,IAAMC,EAAoB,EAAK,EACxC,QAAS3B,EACT,WAAYd,GACZ,SAAUgB,GACV,SAAUC,GACV,WAAYC,GACZ,UAAWC,GACX,UAAWC,GACX,UAAWC,GACX,cAAeC,GACf,eAAgBC,GAChB,YAAaC,GACb,aAAcC,GACd,MAAO7D,EACP,MAAOmD,EACT,KAIF,OAAC,eACC,OAAQ2B,EACR,QAAS,IAAMC,EAAkB,EAAK,EACtC,MAAOO,IAAczC,GAAqB,MAC1C,QAASuC,IAAgBvC,GAAqB,QAC9C,YAAa2C,IAAoB3C,GAAqB,YACtD,oBAAqBA,GAAqB,oBAC1C,sBAAuBA,GAAqB,sBAC5C,MAAO7C,EACT,KAGA,OAAC,eACC,OAAQgF,EACR,QAASiC,GACT,MAAOC,GACP,QAASC,GACT,YAAaC,GACb,MAAOpH,EACT,KAGA,OAAC,eACC,OAAQkF,GACR,QAAS,IAAMC,EAAkB,EAAK,EACtC,MAAOvD,GAAkB,MACzB,SAAUA,GAAkB,SAC5B,KAAMA,GAAkB,KACxB,UAAWA,GAAkB,UAC7B,eAAgBA,GAAkB,eAClC,MAAO5B,EACT,GACF,CAEJ,CACF,EAEA9B,GAAe,YAAc,iBAE7B,IAAOC,MAAQ,eAAWD,EAAc",
|
|
6
|
+
"names": ["ProductLottery_exports", "__export", "ProductLottery", "ProductLottery_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_helpers", "import_types", "import_grid", "import_MediaDrawArea", "import_PrizePool", "import_ChanceMethods", "import_WinnerModal", "import_RulesModal", "import_MyRewardsModal", "import_ErrorModal", "import_ShareModal", "import_Styles", "import_track", "import_AiuiProvider", "import_useExposure", "import_trackUrlRef", "import_BaseModal", "LOTTERY_COMPONENT_TYPE", "LOTTERY_COMPONENT_NAME", "LOTTERY_COMPONENT_TITLE", "LOTTERY_CLICK_TYPE", "LOTTERY_MODAL_COMPONENT_NAME", "LOTTERY_MODAL_COMPONENT_TYPE", "prizes", "media", "theme", "ctaButton", "videoAutoPlay", "videoMuted", "videoLoop", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "inputPlaceholder", "inputSubmitText", "inputType", "inputValidationErrorText", "winnerTickerData", "winningInfos", "winnerNameTemplate", "prizesTitle", "onDrawStart", "onDrawEnd", "onDrawError", "winnerModalConfig", "rulesModalConfig", "actionButtonConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "error", "tryAgain", "userData", "loginPrompt", "loginPromptText", "loginButtonText", "onLoginRequired", "onCopyCode", "opportunitiesPrefix", "opportunitiesText", "dealsType", "className", "ref", "resolvedLoginPrompt", "resolvedOpportunitiesText", "resolvedInputConfig", "resolvedErrorConfig", "resolvedWinnerConfig", "rulesData", "rulesText", "shouldShowActionButton", "rewardsData", "myRewardsText", "codeText", "copyText", "copiedText", "prizeText", "emptyText", "copyError", "availableText", "usedStatusText", "expiredText", "notFoundText", "completedText", "usedText", "isLoggedIn", "availableChances", "hasRightPanel", "hasAgreementNotice", "isDrawing", "setIsDrawing", "winningPrize", "setWinningPrize", "showWinnerModal", "setShowWinnerModal", "showRulesModal", "setShowRulesModal", "showRewardsModal", "setShowRewardsModal", "showErrorModal", "setShowErrorModal", "showNoWinModal", "setShowNoWinModal", "showShareModal", "setShowShareModal", "errorMessage", "setErrorMessage", "errorTitle", "setErrorTitle", "errorConfirmText", "setErrorConfirmText", "noWinTitle", "setNoWinTitle", "noWinMessage", "setNoWinMessage", "noWinConfirmText", "setNoWinConfirmText", "externalWinnerConfig", "setExternalWinnerConfig", "isAgreementChecked", "setIsAgreementChecked", "containerRef", "trackingData", "pageHandle", "message", "title", "confirmText", "config", "prize", "handleDrawStart", "prizeId", "p", "handleDrawClick", "handleCloseWinnerModal", "handleCloseNoWinModal", "resolvedTryAgainTitle", "resolvedTryAgainMessage", "resolvedTryAgainConfirmText", "e", "checked"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var D=Object.defineProperty;var ft=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames;var xt=Object.prototype.hasOwnProperty;var ht=(n,o)=>{for(var d in o)D(n,d,{get:o[d],enumerable:!0})},wt=(n,o,d,w)=>{if(o&&typeof o=="object"||typeof o=="function")for(let u of ut(o))!xt.call(n,u)&&u!==d&&D(n,u,{get:()=>o[u],enumerable:!(w=ft(o,u))||w.enumerable});return n};var gt=n=>wt(D({},"__esModule",{value:!0}),n);var Tt={};ht(Tt,{BaseModal:()=>me.BaseModal,ErrorModal:()=>de.ErrorModal,MyRewardsModal:()=>pe.MyRewardsModal,RulesModal:()=>le.RulesModal,ShareModal:()=>ce.ShareModal,WheelLottery:()=>B,WinnerModal:()=>ae.WinnerModal,default:()=>yt});module.exports=gt(Tt);var e=require("react/jsx-runtime"),t=require("react"),p=require("../../helpers/index.js"),x=require("./types.js"),v=require("../../components/grid.js"),q=require("./Wheel.js"),ee=require("../LotteryShared/PrizePool.js"),te=require("../LotteryShared/ChanceMethods.js"),oe=require("../LotteryShared/WinnerModal.js"),re=require("../LotteryShared/RulesModal.js"),ne=require("../LotteryShared/MyRewardsModal.js"),F=require("../LotteryShared/ErrorModal.js"),se=require("../LotteryShared/ShareModal.js"),ie=require("../../shared/Styles.js"),ae=require("../LotteryShared/WinnerModal.js"),le=require("../LotteryShared/RulesModal.js"),pe=require("../LotteryShared/MyRewardsModal.js"),de=require("../LotteryShared/ErrorModal.js"),ce=require("../LotteryShared/ShareModal.js"),me=require("../LotteryShared/BaseModal.js");const B=(0,t.forwardRef)(({prizes:n,theme:o,winningPrizeId:d,spinDuration:w=x.DEFAULT_WHEEL_CONFIG.spinDuration,wheelBackgroundImage:u,pointerImage:fe,chanceMethods:O=x.DEFAULT_CHANCE_METHODS,chanceTitle:ue=x.DEFAULT_WHEEL_CONFIG.chanceTitle,chanceSubtitle:xe,chanceFooterNote:he,chanceMethodsText:C,mechanismType:we,inputConfig:ge,winningInfos:ye=[],winnerNameTemplate:Te,prizesTitle:be,onSpinStart:I,onSpinEnd:R,onSpinError:U,winnerModalConfig:i,rulesModalConfig:Me={},myRewardsModalConfig:Se={},errorModalConfig:h={},shareModalConfig:g={},userData:c,loginPromptText:We="Please log in to participate",loginButtonText:Pe="Log In",noChancesText:bt="You have no chances left",onLoginRequired:y,onCopyCode:Ne,opportunitiesText:j=["Number of draws remaining today:"],className:ze},Ee)=>{const{rulesData:T,rulesText:G="Rules"}=Me,{rewardsData:L,myRewardsText:H="My Rewards",codeText:ve="CODE:",copyText:_="COPY",copiedText:K="COPIED",prizeText:Ce="Prize time:",emptyText:ke,copyError:Ie,availableText:Re,usedStatusText:Le,expiredText:Ae,notFoundText:De}=Se,Fe=C?.completedText,Be=C?.usedText,b=c?.isLoggedIn??!1,$=c?.availableChances||0,Y=!1,Oe=b&&$<=0,[s,m]=(0,t.useState)(x.INITIAL_WHEEL_STATE),[Ue,M]=(0,t.useState)(!1),[je,S]=(0,t.useState)(!1),[Ge,W]=(0,t.useState)(!1),[He,P]=(0,t.useState)(!1),[_e,N]=(0,t.useState)(!1),[Ke,z]=(0,t.useState)(!1),[$e,V]=(0,t.useState)(""),[Ye,Ve]=(0,t.useState)(),[Je,Qe]=(0,t.useState)(),[Xe,Ze]=(0,t.useState)(),[qe,et]=(0,t.useState)(),[tt,ot]=(0,t.useState)(),[a,rt]=(0,t.useState)(),k=(0,t.useRef)(null);(0,t.useImperativeHandle)(Ee,()=>({showError:({message:r,title:l,confirmText:E})=>{V(r),Ve(l),Qe(E),P(!0)},hideError:()=>{P(!1)},showNoWin:r=>{Ze(r?.title),et(r?.message),ot(r?.confirmText),N(!0)},hideNoWin:()=>{N(!1)},showWinner:(r,l)=>{m(E=>({...E,winningPrize:r})),rt(l),M(!0)},hideWinner:()=>{M(!1)},showRules:()=>{S(!0)},hideRules:()=>{S(!1)},showRewards:()=>{W(!0)},hideRewards:()=>{W(!1)},showShare:()=>{z(!0)},hideShare:()=>{z(!1)},hideAllModals:()=>{M(!1),S(!1),W(!1),P(!1),N(!1),z(!1)}}),[]),(0,t.useEffect)(()=>{},[n,d]),(0,t.useEffect)(()=>()=>{k.current!==null&&cancelAnimationFrame(k.current)},[]);const J=(0,t.useCallback)(async()=>{if(!s.isSpinning){if(!c?.isLoggedIn){y?.();return}if(!(c.availableChances<=0)){m(r=>({...r,isSpinning:!0,isButtonDisabled:!0}));try{let r=d;I&&(r=await I());const l=n.find(f=>f.prizeKey===r)||n[0],E=n.findIndex(f=>f.prizeKey===l.prizeKey),at=360/n.length,lt=E*at,Q=3*360+(360-lt);await new Promise(f=>setTimeout(f,1500)),m(f=>({...f,isFinished:!0,currentRotation:0}));const pt=Date.now(),X=()=>{const dt=Date.now()-pt,Z=Math.min(dt/w,1),ct=1-Math.pow(1-Z,3),mt=Q*ct;m(A=>({...A,currentRotation:mt})),Z<1?k.current=requestAnimationFrame(X):(m(A=>({...A,isSpinning:!1,isButtonDisabled:!0,winningPrize:l,currentRotation:Q})),R?R?.(l):setTimeout(()=>{l.prizeKey==="try-again"?N(!0):M(!0)},500))};k.current=requestAnimationFrame(X)}catch(r){m(l=>({...l,isSpinning:!1,isButtonDisabled:!1})),V(r.message||"An error occurred"),P(!0),U?.(r),console.error("\u62BD\u5956\u63A5\u53E3\u8C03\u7528\u5931\u8D25:",r)}}}},[s.isSpinning,n,d,w,I,R,U,c,y]),nt=(0,t.useCallback)(()=>{if(b){J();return}y?.()},[J,b,y]),st=(0,t.useCallback)(()=>{M(!1),m(r=>({...r,isButtonDisabled:!1,isFinished:!1}))},[]),it=(0,t.useCallback)(()=>{N(!1),m(r=>({...r,isButtonDisabled:!1,isFinished:!1}))},[]);return(0,e.jsxs)("div",{className:(0,p.cn)("wheel-lottery-container","w-full",o==="dark"?"aiui-dark":"",ze),children:[(0,e.jsxs)("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:[s.isSpinning&&"\u62BD\u5956\u8FDB\u884C\u4E2D...",s.winningPrize&&!s.isSpinning&&`\u5DF2\u4E2D\u5956: ${s.winningPrize.name}`]}),(0,e.jsxs)(v.Grid,{className:(0,p.cn)("wheel-lottery-main","tablet:mb-4 mb-3"),children:[(0,e.jsx)(v.GridItem,{span:7,className:(0,p.cn)("wheel-section","relative flex w-full flex-1 items-center justify-center overflow-hidden","rounded-box","laptop:min-h-[288px] min-h-[240px]","lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]","desktop:aspect-w-[759] desktop:aspect-h-[384]","laptop:aspect-w-[516] laptop:aspect-h-[288]","l-tablet:col-span-12","l-tablet:mb-3",o==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,e.jsxs)("div",{className:(0,p.cn)("w-full px-[16px] pt-[16px]","lg-desktop:pb-[32px] lg-desktop:px-[32px]","desktop:pt-[24px] desktop:px-[24px]","laptop:pt-[16px] laptop:px-[16px]","tablet:px-[24px]","l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10"),children:[(0,e.jsxs)("div",{className:"tablet:max-h-[24px] relative z-10 mb-2 flex max-h-[40px] w-full flex-wrap items-center justify-between gap-3",children:[(0,e.jsx)("div",{children:b&&(0,e.jsxs)("p",{className:"text-info-primary font-[700]",children:[j?.[0],(0,e.jsx)("span",{className:"ml-1 text-[#FF6B35]",children:$}),j?.[1]||""]})}),(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[T&&T.length>0&&(0,e.jsx)("button",{onClick:()=>S(!0),className:"cursor-pointer touch-manipulation",type:"button",children:(0,e.jsx)("span",{className:"text-info-primary font-[700] underline",children:G})}),c?.isLoggedIn&&L&&(0,e.jsx)("button",{onClick:()=>W(!0),className:"cursor-pointer touch-manipulation whitespace-nowrap",type:"button",children:(0,e.jsx)("span",{className:"text-info-primary font-[700] underline",children:H})})]})]}),(0,e.jsx)(q.Wheel,{theme:o,prizes:n,rotation:s.currentRotation,isSpinning:s.isSpinning,isFinished:s.isFinished,isButtonDisabled:s.isButtonDisabled||!b||Oe,userData:c,onGoClick:nt,wheelBackgroundImage:u,pointerImage:fe}),Y&&(0,e.jsx)("div",{className:(0,p.cn)("rounded-box absolute inset-0 z-20 flex items-center justify-center bg-black/60 backdrop-blur-sm","px-6 text-center"),children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,e.jsx)("p",{className:"lg-desktop:text-[24px] text-[18px] font-semibold text-white",children:We}),Y&&(0,e.jsx)("button",{type:"button",onClick:y,className:(0,p.cn)("rounded-full bg-white px-6 py-2 text-[14px] font-semibold text-[#1D1D1F]","transition-transform hover:scale-105 active:scale-95"),children:Pe})]})})]})}),O.length>0&&(0,e.jsx)(v.GridItem,{span:5,className:(0,p.cn)("info-section","rounded-box","relative flex flex-col overflow-hidden","lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]","desktop:aspect-w-[536] desktop:aspect-h-[384]","laptop:aspect-w-[364] laptop:aspect-h-[288]","l-tablet:min-h-[280px] laptop:max-h-[320px]","w-full","l-tablet:col-span-12",o==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,e.jsx)(te.ChanceMethods,{theme:o,userData:c,methods:O,title:ue,subtitle:xe,footerNote:he,onOpenShareModal:()=>z(!0),chanceBadgeText:C?.chanceBadgeText,completedText:Fe,usedText:Be,loadingText:C?.loadingText,mechanismType:we,inputConfig:ge})})]}),(0,e.jsx)("div",{className:(0,p.cn)("wheel-lottery-footer","rounded-box","flex flex-col overflow-hidden",o==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,e.jsx)(ee.PrizePool,{theme:o,prizes:n,title:be,winningInfos:ye,winnerNameTemplate:Te})}),(0,e.jsx)(oe.WinnerModal,{isOpen:Ue,prize:s.winningPrize,title:a?.title||i?.title,prizeTitle:a?.prizeTitle||i?.prizeTitle,prizeImage:a?.prizeImage||i?.prizeImage,prizeDescription:a?.prizeDescription||i?.prizeDescription,winnerNote:a?.winnerNote??s.winningPrize?.winnerModalConfig?.winnerNote??i?.winnerNote,learnMoreUrl:a?.learnMoreUrl||s.winningPrize?.winnerModalConfig?.learnMoreUrl||i?.learnMoreUrl,learnMoreText:a?.learnMoreText||s.winningPrize?.winnerModalConfig?.learnMoreText||i?.learnMoreText,couponCode:a?.couponCode||i?.couponCode,expiresAt:a?.expiresAt||i?.expiresAt,couponDiscount:a?.couponDiscount||i?.couponDiscount,couponUnit:a?.couponUnit||i?.couponUnit,confirmText:a?.confirmText||s.winningPrize?.winnerModalConfig?.confirmText||i?.confirmText,confirmUrl:a?.confirmUrl||s.winningPrize?.winnerModalConfig?.confirmUrl||i?.confirmUrl,copyText:a?.copyText||i?.copyText||_,copiedText:a?.copiedText||i?.copiedText||K,onClose:st,theme:o}),T&&T.length>0&&(0,e.jsx)(re.RulesModal,{title:G,isOpen:je,onClose:()=>S(!1),rules:T,theme:o}),L&&(0,e.jsx)(ne.MyRewardsModal,{isOpen:Ge,onClose:()=>W(!1),rewards:L,onCopyCode:Ne,codeText:ve,copyText:_,copiedText:K,prizeText:Ce,emptyText:ke,copyError:Ie,availableText:Re,usedStatusText:Le,expiredText:Ae,notFoundText:De,theme:o,title:H}),(0,e.jsx)(F.ErrorModal,{isOpen:He,onClose:()=>P(!1),title:Ye||h?.title,message:$e||h?.message,confirmText:Je||h?.confirmText,theme:o}),(0,e.jsx)(F.ErrorModal,{isOpen:_e,onClose:it,title:Xe||h?.title,message:qe||h?.message,confirmText:tt||h?.confirmText,theme:o}),(0,e.jsx)(se.ShareModal,{isOpen:Ke,onClose:()=>z(!1),title:g?.title,subtitle:g?.subtitle,note:g?.note,platforms:g?.platforms,onShareSuccess:g?.onShareSuccess,theme:o})]})});B.displayName="WheelLottery";var yt=(0,ie.withLayout)(B);
|
|
1
|
+
"use strict";"use client";var D=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var ft=(n,o)=>{for(var p in o)D(n,p,{get:o[p],enumerable:!0})},ut=(n,o,p,w)=>{if(o&&typeof o=="object"||typeof o=="function")for(let f of ct(o))!mt.call(n,f)&&f!==p&&D(n,f,{get:()=>o[f],enumerable:!(w=dt(o,f))||w.enumerable});return n};var xt=n=>ut(D({},"__esModule",{value:!0}),n);var wt={};ft(wt,{BaseModal:()=>ce.BaseModal,ErrorModal:()=>pe.ErrorModal,MyRewardsModal:()=>le.MyRewardsModal,RulesModal:()=>ae.RulesModal,ShareModal:()=>de.ShareModal,WheelLottery:()=>B,WinnerModal:()=>ie.WinnerModal,default:()=>ht});module.exports=xt(wt);var t=require("react/jsx-runtime"),e=require("react"),u=require("../../helpers/index.js"),x=require("./types.js"),N=require("../../components/grid.js"),Z=require("./Wheel.js"),q=require("../LotteryShared/PrizePool.js"),ee=require("../LotteryShared/ChanceMethods.js"),te=require("../LotteryShared/WinnerModal.js"),oe=require("../LotteryShared/RulesModal.js"),re=require("../LotteryShared/MyRewardsModal.js"),F=require("../LotteryShared/ErrorModal.js"),ne=require("../LotteryShared/ShareModal.js"),se=require("../../shared/Styles.js"),ie=require("../LotteryShared/WinnerModal.js"),ae=require("../LotteryShared/RulesModal.js"),le=require("../LotteryShared/MyRewardsModal.js"),pe=require("../LotteryShared/ErrorModal.js"),de=require("../LotteryShared/ShareModal.js"),ce=require("../LotteryShared/BaseModal.js");const B=(0,e.forwardRef)(({prizes:n,theme:o,winningPrizeId:p,spinDuration:w=x.DEFAULT_WHEEL_CONFIG.spinDuration,wheelBackgroundImage:f,pointerImage:me,chanceMethods:U=x.DEFAULT_CHANCE_METHODS,chanceTitle:fe=x.DEFAULT_WHEEL_CONFIG.chanceTitle,chanceSubtitle:ue,chanceFooterNote:xe,chanceMethodsText:v,mechanismType:he,inputConfig:we,winningInfos:ge=[],winnerNameTemplate:ye,prizesTitle:Te,onSpinStart:I,onSpinEnd:k,onSpinError:O,winnerModalConfig:i,rulesModalConfig:be={},myRewardsModalConfig:Me={},errorModalConfig:h={},shareModalConfig:g={},userData:d,onLoginRequired:C,onCopyCode:Se,opportunitiesText:j=["Number of draws remaining today:"],className:We},Pe)=>{const{rulesData:y,rulesText:G="Rules"}=be,{rewardsData:L,myRewardsText:H="My Rewards",codeText:ze="CODE:",copyText:_="COPY",copiedText:K="COPIED",prizeText:Ee="Prize time:",emptyText:Ne,copyError:ve,availableText:Ce,usedStatusText:Re,expiredText:Ie,notFoundText:ke}=Me,Le=v?.completedText,Ae=v?.usedText,T=d?.isLoggedIn??!1,$=d?.availableChances??0,De=T&&$<=0,[s,c]=(0,e.useState)(x.INITIAL_WHEEL_STATE),[Fe,b]=(0,e.useState)(!1),[Be,M]=(0,e.useState)(!1),[Ue,S]=(0,e.useState)(!1),[Oe,W]=(0,e.useState)(!1),[je,P]=(0,e.useState)(!1),[Ge,z]=(0,e.useState)(!1),[He,V]=(0,e.useState)(""),[_e,Ke]=(0,e.useState)(),[$e,Ve]=(0,e.useState)(),[Ye,Je]=(0,e.useState)(),[Qe,Xe]=(0,e.useState)(),[Ze,qe]=(0,e.useState)(),[a,et]=(0,e.useState)(),R=(0,e.useRef)(null);(0,e.useImperativeHandle)(Pe,()=>({showError:({message:r,title:l,confirmText:E})=>{V(r),Ke(l),Ve(E),W(!0)},hideError:()=>{W(!1)},showNoWin:r=>{Je(r?.title),Xe(r?.message),qe(r?.confirmText),P(!0)},hideNoWin:()=>{P(!1)},showWinner:(r,l)=>{c(E=>({...E,winningPrize:r})),et(l),b(!0)},hideWinner:()=>{b(!1)},showRules:()=>{M(!0)},hideRules:()=>{M(!1)},showRewards:()=>{S(!0)},hideRewards:()=>{S(!1)},showShare:()=>{z(!0)},hideShare:()=>{z(!1)},hideAllModals:()=>{b(!1),M(!1),S(!1),W(!1),P(!1),z(!1)}}),[]),(0,e.useEffect)(()=>{},[n,p]),(0,e.useEffect)(()=>()=>{R.current!==null&&cancelAnimationFrame(R.current)},[]);const Y=(0,e.useCallback)(async()=>{if(!s.isSpinning){if(!d?.isLoggedIn){C?.();return}if(!(d.availableChances<=0)){c(r=>({...r,isSpinning:!0,isButtonDisabled:!0}));try{let r=p;I&&(r=await I());const l=n.find(m=>m.prizeKey===r)||n[0],E=n.findIndex(m=>m.prizeKey===l.prizeKey),nt=360/n.length,st=E*nt,J=3*360+(360-st);await new Promise(m=>setTimeout(m,1500)),c(m=>({...m,isFinished:!0,currentRotation:0}));const it=Date.now(),Q=()=>{const at=Date.now()-it,X=Math.min(at/w,1),lt=1-Math.pow(1-X,3),pt=J*lt;c(A=>({...A,currentRotation:pt})),X<1?R.current=requestAnimationFrame(Q):(c(A=>({...A,isSpinning:!1,isButtonDisabled:!0,winningPrize:l,currentRotation:J})),k?k?.(l):setTimeout(()=>{l.prizeKey==="try-again"?P(!0):b(!0)},500))};R.current=requestAnimationFrame(Q)}catch(r){c(l=>({...l,isSpinning:!1,isButtonDisabled:!1})),V(r.message||"An error occurred"),W(!0),O?.(r),console.error("\u62BD\u5956\u63A5\u53E3\u8C03\u7528\u5931\u8D25:",r)}}}},[s.isSpinning,n,p,w,I,k,O,d,C]),tt=(0,e.useCallback)(()=>{if(T){Y();return}C?.()},[Y,T,C]),ot=(0,e.useCallback)(()=>{b(!1),c(r=>({...r,isButtonDisabled:!1,isFinished:!1}))},[]),rt=(0,e.useCallback)(()=>{P(!1),c(r=>({...r,isButtonDisabled:!1,isFinished:!1}))},[]);return(0,t.jsxs)("div",{className:(0,u.cn)("wheel-lottery-container","w-full",o==="dark"?"aiui-dark":"",We),children:[(0,t.jsxs)("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:[s.isSpinning&&"\u62BD\u5956\u8FDB\u884C\u4E2D...",s.winningPrize&&!s.isSpinning&&`\u5DF2\u4E2D\u5956: ${s.winningPrize.name}`]}),(0,t.jsxs)(N.Grid,{className:(0,u.cn)("wheel-lottery-main","tablet:mb-4 mb-3"),children:[(0,t.jsx)(N.GridItem,{span:7,className:(0,u.cn)("wheel-section","relative flex w-full flex-1 items-center justify-center overflow-hidden","rounded-box","laptop:min-h-[288px] min-h-[240px]","lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]","desktop:aspect-w-[759] desktop:aspect-h-[384]","laptop:aspect-w-[516] laptop:aspect-h-[288]","l-tablet:col-span-12","l-tablet:mb-3",o==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsxs)("div",{className:(0,u.cn)("w-full px-[16px] pt-[16px]","lg-desktop:pb-[32px] lg-desktop:px-[32px]","desktop:pt-[24px] desktop:px-[24px]","laptop:pt-[16px] laptop:px-[16px]","tablet:px-[24px]","l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10"),children:[(0,t.jsxs)("div",{className:"tablet:max-h-[24px] relative z-10 mb-2 flex max-h-[40px] w-full flex-wrap items-center justify-between gap-3",children:[(0,t.jsx)("div",{children:T&&(0,t.jsxs)("p",{className:"text-info-primary font-[700]",children:[j?.[0],(0,t.jsx)("span",{className:"ml-1 text-[#FF6B35]",children:$}),j?.[1]||""]})}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[y&&y.length>0&&(0,t.jsx)("button",{onClick:()=>M(!0),className:"cursor-pointer touch-manipulation",type:"button",children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:G})}),d?.isLoggedIn&&L&&(0,t.jsx)("button",{onClick:()=>S(!0),className:"cursor-pointer touch-manipulation whitespace-nowrap",type:"button",children:(0,t.jsx)("span",{className:"text-info-primary font-[700] underline",children:H})})]})]}),(0,t.jsx)(Z.Wheel,{theme:o,prizes:n,rotation:s.currentRotation,isSpinning:s.isSpinning,isFinished:s.isFinished,isButtonDisabled:s.isButtonDisabled||!T||De,userData:d,onGoClick:tt,wheelBackgroundImage:f,pointerImage:me})]})}),U.length>0&&(0,t.jsx)(N.GridItem,{span:5,className:(0,u.cn)("info-section","rounded-box","relative flex flex-col overflow-hidden","lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]","desktop:aspect-w-[536] desktop:aspect-h-[384]","laptop:aspect-w-[364] laptop:aspect-h-[288]","l-tablet:min-h-[280px] laptop:max-h-[320px]","w-full","l-tablet:col-span-12",o==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsx)(ee.ChanceMethods,{theme:o,userData:d,methods:U,title:fe,subtitle:ue,footerNote:xe,onOpenShareModal:()=>z(!0),chanceBadgeText:v?.chanceBadgeText,completedText:Le,usedText:Ae,loadingText:v?.loadingText,mechanismType:he,inputConfig:we})})]}),(0,t.jsx)("div",{className:(0,u.cn)("wheel-lottery-footer","rounded-box","flex flex-col overflow-hidden",o==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:(0,t.jsx)(q.PrizePool,{theme:o,prizes:n,title:Te,winningInfos:ge,winnerNameTemplate:ye})}),(0,t.jsx)(te.WinnerModal,{isOpen:Fe,prize:s.winningPrize,title:a?.title||i?.title,prizeTitle:a?.prizeTitle||i?.prizeTitle,prizeImage:a?.prizeImage||i?.prizeImage,prizeDescription:a?.prizeDescription||i?.prizeDescription,winnerNote:a?.winnerNote??s.winningPrize?.winnerModalConfig?.winnerNote??i?.winnerNote,learnMoreUrl:a?.learnMoreUrl||s.winningPrize?.winnerModalConfig?.learnMoreUrl||i?.learnMoreUrl,learnMoreText:a?.learnMoreText||s.winningPrize?.winnerModalConfig?.learnMoreText||i?.learnMoreText,couponCode:a?.couponCode||i?.couponCode,expiresAt:a?.expiresAt||i?.expiresAt,couponDiscount:a?.couponDiscount||i?.couponDiscount,couponUnit:a?.couponUnit||i?.couponUnit,confirmText:a?.confirmText||s.winningPrize?.winnerModalConfig?.confirmText||i?.confirmText,confirmUrl:a?.confirmUrl||s.winningPrize?.winnerModalConfig?.confirmUrl||i?.confirmUrl,copyText:a?.copyText||i?.copyText||_,copiedText:a?.copiedText||i?.copiedText||K,onClose:ot,theme:o}),y&&y.length>0&&(0,t.jsx)(oe.RulesModal,{title:G,isOpen:Be,onClose:()=>M(!1),rules:y,theme:o}),L&&(0,t.jsx)(re.MyRewardsModal,{isOpen:Ue,onClose:()=>S(!1),rewards:L,onCopyCode:Se,codeText:ze,copyText:_,copiedText:K,prizeText:Ee,emptyText:Ne,copyError:ve,availableText:Ce,usedStatusText:Re,expiredText:Ie,notFoundText:ke,theme:o,title:H}),(0,t.jsx)(F.ErrorModal,{isOpen:Oe,onClose:()=>W(!1),title:_e||h?.title,message:He||h?.message,confirmText:$e||h?.confirmText,theme:o}),(0,t.jsx)(F.ErrorModal,{isOpen:je,onClose:rt,title:Ye||h?.title,message:Qe||h?.message,confirmText:Ze||h?.confirmText,theme:o}),(0,t.jsx)(ne.ShareModal,{isOpen:Ge,onClose:()=>z(!1),title:g?.title,subtitle:g?.subtitle,note:g?.note,platforms:g?.platforms,onShareSuccess:g?.onShareSuccess,theme:o})]})});B.displayName="WheelLottery";var ht=(0,se.withLayout)(B);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/WheelLottery/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WheelLottery - \u5927\u8F6C\u76D8\u62BD\u5956\u7EC4\u4EF6\n *\n * \u7528\u4E8E\u8425\u9500\u6D3B\u52A8\u7684\u4EA4\u4E92\u5F0F\u62BD\u5956\u8F6C\u76D8\uFF0C\u652F\u6301\u591A\u54C1\u724C\u4E3B\u9898\u548C\u54CD\u5E94\u5F0F\u5E03\u5C40\u3002\n *\n * @module WheelLottery\n * @date 2025-12-17\n */\n\n'use client'\n\nimport { useState, useCallback, useRef, useEffect, useImperativeHandle, forwardRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_WHEEL_CONFIG, DEFAULT_CHANCE_METHODS, INITIAL_WHEEL_STATE } from './types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { Wheel } from './Wheel.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\n\nimport type { WheelLotteryProps, WheelState, WheelLotteryHandle, WinnerModalConfig } from './types.js'\n\n// ============================================================================\n// \u4E3B\u7EC4\u4EF6\n// ============================================================================\n\n/**\n * WheelLottery \u7EC4\u4EF6\n *\n * @example\n * ```tsx\n * // \u57FA\u7840\u4F7F\u7528\n * <WheelLottery\n * prizes={prizes}\n * winningPrizeId=\"prize-003\"\n * onSpinEnd={(prize) => alert(`You won ${prize.name}`)}\n * />\n *\n * // \u4F7F\u7528 ref \u63A7\u5236\u5F39\u7A97\n * const lotteryRef = useRef<WheelLotteryHandle>(null)\n *\n * <WheelLottery ref={lotteryRef} prizes={prizes} />\n *\n * // \u5916\u90E8\u89E6\u53D1\u5F39\u7A97\n * lotteryRef.current?.showError({\n * title: 'Error',\n * message: 'Something went wrong'\n * })\n * ```\n */\nexport const WheelLottery = forwardRef<WheelLotteryHandle, WheelLotteryProps>(\n (\n {\n prizes,\n theme,\n winningPrizeId,\n spinDuration = DEFAULT_WHEEL_CONFIG.spinDuration,\n wheelBackgroundImage,\n pointerImage,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_WHEEL_CONFIG.chanceTitle,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n winningInfos = [],\n winnerNameTemplate,\n prizesTitle,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n winnerModalConfig,\n rulesModalConfig = {},\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n userData,\n loginPromptText = 'Please log in to participate',\n loginButtonText = 'Log In',\n noChancesText = 'You have no chances left',\n onLoginRequired,\n onCopyCode,\n opportunitiesText = ['Number of draws remaining today:'],\n className,\n },\n ref\n ) => {\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances || 0\n const showLoginOverlay = false\n const isNoChancesState = isLoggedIn && availableChances <= 0\n // ==========================================================================\n // State \u7BA1\u7406\n // ==========================================================================\n\n const [wheelState, setWheelState] = useState<WheelState>(INITIAL_WHEEL_STATE)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const animationRef = useRef<number | null>(null)\n\n // ==========================================================================\n // Imperative Handle - \u66B4\u9732\u65B9\u6CD5\u7ED9\u7236\u7EC4\u4EF6\n // ==========================================================================\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWheelState(prev => ({ ...prev, winningPrize: prize }))\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n // ==========================================================================\n // Props \u9A8C\u8BC1\uFF08\u5F00\u53D1\u73AF\u5883\uFF09\n // ==========================================================================\n\n useEffect(() => {\n if (process.env.NODE_ENV === 'development' && prizes) {\n if (prizes.length !== 8) {\n console.warn(\n `WheelLottery expects exactly 8 prizes, got ${prizes.length}. The component may not render correctly.`\n )\n }\n\n if (winningPrizeId && !prizes.find(p => p.prizeKey === winningPrizeId)) {\n console.warn(`WheelLottery: winningPrizeId \"${winningPrizeId}\" not found in prizes array.`)\n }\n }\n }, [prizes, winningPrizeId])\n\n // ==========================================================================\n // \u6E05\u7406\u52A8\u753B\n // ==========================================================================\n\n useEffect(() => {\n return () => {\n // \u7EC4\u4EF6\u5378\u8F7D\u65F6\u53D6\u6D88\u52A8\u753B\u5E27\n if (animationRef.current !== null) {\n cancelAnimationFrame(animationRef.current)\n }\n }\n }, [])\n\n // ==========================================================================\n // \u62BD\u5956\u903B\u8F91\n // ==========================================================================\n\n /**\n * \u5F00\u59CB\u62BD\u5956 - \u652F\u6301\u5F02\u6B65\u63A5\u53E3\u8C03\u7528\n * \u5229\u7528\u521D\u59CB\u6162\u901F\u65CB\u8F6C\uFF0C\u70B9\u51FB\u540E\u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF0C\u63A5\u53E3\u8FD4\u56DE\u540E\u51CF\u901F\u505C\u6B62\n */\n const handleSpinStart = useCallback(async () => {\n if (wheelState.isSpinning) return\n\n // \u68C0\u67E5\u7528\u6237\u662F\u5426\u5DF2\u767B\u5F55\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n // \u2705 \u6B21\u6570\u4E3A 0 \u65F6\uFF0C\u6309\u94AE\u5DF2\u88AB\u7981\u7528\uFF0C\u8FD9\u91CC\u4E0D\u9700\u8981\u989D\u5916\u68C0\u67E5\n // \u9632\u5FA1\u6027\u7F16\u7A0B\uFF1A\u5982\u679C\u4ECD\u7136\u89E6\u53D1\uFF0C\u76F4\u63A5\u8FD4\u56DE\n if (userData.availableChances <= 0) {\n return\n }\n\n // \u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF08\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u4F1A\u81EA\u52A8\u53D8\u4E3A\u5FEB\u901F\u65CB\u8F6C\uFF09\n setWheelState(prev => ({\n ...prev,\n isSpinning: true,\n isButtonDisabled: true,\n }))\n\n try {\n // \u8C03\u7528\u5916\u90E8\u63A5\u53E3\u83B7\u53D6\u4E2D\u5956\u7ED3\u679C\n let finalWinningPrizeId = winningPrizeId\n\n if (onSpinStart) {\n // \u7B49\u5F85\u63A5\u53E3\u8FD4\u56DE\u4E2D\u5956 ID\uFF08\u63A5\u53E3\u65F6\u95F4\u4E0D\u56FA\u5B9A\uFF0C1-30s\uFF09\n // \u5728\u6B64\u671F\u95F4\uFF0C\u8F6C\u76D8\u4F1A\u4FDD\u6301\u5FEB\u901F\u65CB\u8F6C\uFF08\u7531 CSS \u52A8\u753B\u63A7\u5236\uFF09\n finalWinningPrizeId = await onSpinStart()\n }\n\n // \u786E\u5B9A\u4E2D\u5956\u5956\u54C1\n const winningPrize = prizes.find(p => p.prizeKey === finalWinningPrizeId) || prizes[0]\n const winningIndex = prizes.findIndex(p => p.prizeKey === winningPrize.prizeKey)\n\n // \u8BA1\u7B97\u76EE\u6807\u89D2\u5EA6\n const degreesPerPrize = 360 / prizes.length\n const basePrizeAngle = winningIndex * degreesPerPrize\n // \u81F3\u5C11\u65CB\u8F6C 3 \u5708\uFF081080\u5EA6\uFF09+ \u76EE\u6807\u89D2\u5EA6\n const minRotations = 3\n const targetAngle = minRotations * 360 + (360 - basePrizeAngle)\n\n // \u63A5\u53E3\u8FD4\u56DE\u540E\uFF0C\u7B49\u5F85 1.5s \u518D\u5F00\u59CB\u505C\u6B62\u52A8\u753B\n await new Promise(resolve => setTimeout(resolve, 1500))\n\n // \u7ACB\u5373\u8FDB\u5165\u51CF\u901F\u72B6\u6001\uFF0C\u505C\u6B62 CSS \u5FAA\u73AF\u52A8\u753B\n setWheelState(prev => ({\n ...prev,\n isFinished: true,\n currentRotation: 0, // \u4ECE 0 \u5EA6\u5F00\u59CB\u51CF\u901F\u52A8\u753B\n }))\n\n // \u5F00\u59CB\u505C\u6B62\u65CB\u8F6C\u52A8\u753B\n const startTime = Date.now()\n\n const animate = () => {\n const now = Date.now()\n const elapsed = now - startTime\n const progress = Math.min(elapsed / spinDuration, 1)\n\n // \u5E94\u7528 ease-out \u7F13\u52A8\u51FD\u6570\n const eased = 1 - Math.pow(1 - progress, 3)\n\n // \u8BA1\u7B97\u5F53\u524D\u65CB\u8F6C\u89D2\u5EA6\n const currentRotation = targetAngle * eased\n\n // \u66F4\u65B0\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n currentRotation,\n }))\n\n // \u7EE7\u7EED\u52A8\u753B\u6216\u7ED3\u675F\n if (progress < 1) {\n animationRef.current = requestAnimationFrame(animate)\n } else {\n // \u52A8\u753B\u7ED3\u675F - \u4FDD\u6301\u6309\u94AE\u7981\u7528\u72B6\u6001,\u76F4\u5230\u5F39\u7A97\u5173\u95ED\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: true,\n winningPrize,\n currentRotation: targetAngle,\n }))\n\n // \u5EF6\u8FDF\u663E\u793A\u5F39\u7A97\uFF08500ms\u540E\uFF09\n if (onSpinEnd) {\n onSpinEnd?.(winningPrize)\n } else {\n setTimeout(() => {\n // \u68C0\u67E5\u662F\u5426\u672A\u4E2D\u5956\uFF08try-again\uFF09\n if (winningPrize.prizeKey === 'try-again') {\n // \u672A\u4E2D\u5956\uFF0C\u663E\u793A ErrorModal\n setShowNoWinModal(true)\n } else {\n // \u4E2D\u5956\uFF0C\u663E\u793A WinnerModal\n setShowWinnerModal(true)\n }\n }, 500)\n }\n }\n }\n\n // \u542F\u52A8\u505C\u6B62\u52A8\u753B\n animationRef.current = requestAnimationFrame(animate)\n } catch (error) {\n // \u63A5\u53E3\u62A5\u9519\uFF0C\u6062\u590D\u5230\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: false,\n }))\n\n // \u663E\u793A\u9519\u8BEF\u5F39\u7A97\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n\n // \u89E6\u53D1\u9519\u8BEF\u56DE\u8C03\n onSpinError?.(error as Error)\n\n console.error('\u62BD\u5956\u63A5\u53E3\u8C03\u7528\u5931\u8D25:', error)\n }\n }, [\n wheelState.isSpinning,\n prizes,\n winningPrizeId,\n spinDuration,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n userData,\n onLoginRequired,\n ])\n\n const handleWheelGoClick = useCallback(() => {\n if (isLoggedIn) {\n void handleSpinStart()\n return\n }\n\n onLoginRequired?.()\n }, [handleSpinStart, isLoggedIn, onLoginRequired])\n\n // ==========================================================================\n // \u5F39\u7A97\u5173\u95ED\u5904\u7406\n // ==========================================================================\n\n /**\n * \u5173\u95ED\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n /**\n * \u5173\u95ED\u672A\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n // ==========================================================================\n // \u6E32\u67D3\n // ==========================================================================\n\n return (\n <div className={cn('wheel-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}>\n {/* ARIA Live Region - \u5C4F\u5E55\u9605\u8BFB\u5668\u72B6\u6001\u64AD\u62A5 */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {wheelState.isSpinning && '\u62BD\u5956\u8FDB\u884C\u4E2D...'}\n {wheelState.winningPrize && !wheelState.isSpinning && `\u5DF2\u4E2D\u5956: ${wheelState.winningPrize.name}`}\n </div>\n\n {/* \u4E3B\u5185\u5BB9\u533A - \u54CD\u5E94\u5F0F\u4E24\u680F/\u5355\u680F\u5E03\u5C40 */}\n <Grid className={cn('wheel-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* \u5DE6\u4FA7\uFF1A\u8F6C\u76D8\u533A\u57DF */}\n <GridItem\n span={7}\n className={cn(\n 'wheel-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n // \u79FB\u52A8\u7AEF\uFF08<=1024px\uFF09\u4F7F\u7528min-h\uFF0C\u684C\u9762\u7AEF\u4F7F\u7528aspect ratio\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n // \u79FB\u52A8\u7AEF\u5E95\u90E8\u95F4\u8DDD\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'w-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n // \u79FB\u52A8\u7AEF(<=1024px)\u65F6\u4F7F\u7528\u7EDD\u5BF9\u5B9A\u4F4D\u8986\u76D6\u5728\u8F6C\u76D8\u80CC\u666F\u4E0A\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10'\n )}\n >\n {/* \u9876\u90E8\u4FE1\u606F\u680F\uFF1A\u5DE6\u4FA7\u673A\u4F1A\u8FDB\u5EA6\uFF0C\u53F3\u4FA7\u94FE\u63A5 */}\n <div className=\"tablet:max-h-[24px] relative z-10 mb-2 flex max-h-[40px] w-full flex-wrap items-center justify-between gap-3\">\n {/* \u5DE6\u4FA7\uFF1A\u673A\u4F1A\u5C55\u793A - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n <div>\n {isLoggedIn && (\n <p className=\"text-info-primary font-[700]\">\n {opportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {opportunitiesText?.[1] || ''}\n </p>\n )}\n </div>\n {/* \u53F3\u4FA7\uFF1ARules \u548C My Rewards \u6309\u94AE */}\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={() => setShowRulesModal(true)}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {/* My Rewards \u6309\u94AE - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n {userData?.isLoggedIn && rewardsData && (\n <button\n onClick={() => setShowRewardsModal(true)}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n </div>\n </div>\n {/* \u8F6C\u76D8\u7EC4\u4EF6 */}\n <Wheel\n theme={theme}\n prizes={prizes}\n rotation={wheelState.currentRotation}\n isSpinning={wheelState.isSpinning}\n isFinished={wheelState.isFinished}\n isButtonDisabled={wheelState.isButtonDisabled || !isLoggedIn || isNoChancesState}\n userData={userData}\n onGoClick={handleWheelGoClick}\n wheelBackgroundImage={wheelBackgroundImage}\n pointerImage={pointerImage}\n />\n\n {showLoginOverlay && (\n <div\n className={cn(\n 'rounded-box absolute inset-0 z-20 flex items-center justify-center bg-black/60 backdrop-blur-sm',\n 'px-6 text-center'\n )}\n >\n <div className=\"flex flex-col items-center gap-4\">\n <p className=\"lg-desktop:text-[24px] text-[18px] font-semibold text-white\">{loginPromptText}</p>\n {showLoginOverlay && (\n <button\n type=\"button\"\n onClick={onLoginRequired}\n className={cn(\n 'rounded-full bg-white px-6 py-2 text-[14px] font-semibold text-[#1D1D1F]',\n 'transition-transform hover:scale-105 active:scale-95'\n )}\n >\n {loginButtonText}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n </GridItem>\n\n {/* \u53F3\u4FA7\uFF1A\u83B7\u53D6\u673A\u4F1A\u533A\u57DF */}\n {chanceMethods.length > 0 && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n // \u79FB\u52A8\u7AEF\u4F7F\u7528min-h\u800C\u4E0D\u662Fmax-h\uFF0C\u786E\u4FDD\u5185\u5BB9\u5B8C\u6574\u663E\u793A\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={inputConfig}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* \u5E95\u90E8\u533A\u57DF\uFF1A\u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355) */}\n <div\n className={cn(\n 'wheel-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n {/* \u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355\u81EA\u52A8\u6EDA\u52A8) */}\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winningInfos}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* \u4E2D\u5956\u5F39\u7A97 */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={wheelState.winningPrize}\n title={externalWinnerConfig?.title || winnerModalConfig?.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || winnerModalConfig?.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || winnerModalConfig?.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || winnerModalConfig?.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n wheelState.winningPrize?.winnerModalConfig?.winnerNote ??\n winnerModalConfig?.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreUrl ||\n winnerModalConfig?.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreText ||\n winnerModalConfig?.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || winnerModalConfig?.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || winnerModalConfig?.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || winnerModalConfig?.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || winnerModalConfig?.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n wheelState.winningPrize?.winnerModalConfig?.confirmText ||\n winnerModalConfig?.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n wheelState.winningPrize?.winnerModalConfig?.confirmUrl ||\n winnerModalConfig?.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || winnerModalConfig?.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || winnerModalConfig?.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules \u5F39\u7A97 */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards \u5F39\u7A97 */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* \u9519\u8BEF\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || errorModalConfig?.title}\n message={errorMessage || errorModalConfig?.message}\n confirmText={errorConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u672A\u4E2D\u5956\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={noWinTitle || errorModalConfig?.title}\n message={noWinMessage || errorModalConfig?.message}\n confirmText={noWinConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u5206\u4EAB\u5F39\u7A97 */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\n// \u8BBE\u7F6E displayName \u7528\u4E8E\u8C03\u8BD5\nWheelLottery.displayName = 'WheelLottery'\n\n// ============================================================================\n// \u5BFC\u51FA\n// ============================================================================\n\nexport default withLayout(WheelLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n WheelLotteryProps,\n WheelLotteryHandle,\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n WheelProps,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from './types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
-
"mappings": "gcAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,yKAAAE,EAAA,2CAAAC,KAAA,eAAAC,GAAAJ,
|
|
6
|
-
"names": ["WheelLottery_exports", "__export", "WheelLottery", "WheelLottery_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_helpers", "import_types", "import_grid", "import_Wheel", "import_PrizePool", "import_ChanceMethods", "import_WinnerModal", "import_RulesModal", "import_MyRewardsModal", "import_ErrorModal", "import_ShareModal", "import_Styles", "import_BaseModal", "prizes", "theme", "winningPrizeId", "spinDuration", "wheelBackgroundImage", "pointerImage", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "winningInfos", "winnerNameTemplate", "prizesTitle", "onSpinStart", "onSpinEnd", "onSpinError", "winnerModalConfig", "rulesModalConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "userData", "
|
|
4
|
+
"sourcesContent": ["/**\n * WheelLottery - \u5927\u8F6C\u76D8\u62BD\u5956\u7EC4\u4EF6\n *\n * \u7528\u4E8E\u8425\u9500\u6D3B\u52A8\u7684\u4EA4\u4E92\u5F0F\u62BD\u5956\u8F6C\u76D8\uFF0C\u652F\u6301\u591A\u54C1\u724C\u4E3B\u9898\u548C\u54CD\u5E94\u5F0F\u5E03\u5C40\u3002\n *\n * @module WheelLottery\n * @date 2025-12-17\n */\n\n'use client'\n\nimport { useState, useCallback, useRef, useEffect, useImperativeHandle, forwardRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_WHEEL_CONFIG, DEFAULT_CHANCE_METHODS, INITIAL_WHEEL_STATE } from './types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { Wheel } from './Wheel.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\n\nimport type { WheelLotteryProps, WheelState, WheelLotteryHandle, WinnerModalConfig } from './types.js'\n\n// ============================================================================\n// \u4E3B\u7EC4\u4EF6\n// ============================================================================\n\n/**\n * WheelLottery \u7EC4\u4EF6\n *\n * @example\n * ```tsx\n * // \u57FA\u7840\u4F7F\u7528\n * <WheelLottery\n * prizes={prizes}\n * winningPrizeId=\"prize-003\"\n * onSpinEnd={(prize) => alert(`You won ${prize.name}`)}\n * />\n *\n * // \u4F7F\u7528 ref \u63A7\u5236\u5F39\u7A97\n * const lotteryRef = useRef<WheelLotteryHandle>(null)\n *\n * <WheelLottery ref={lotteryRef} prizes={prizes} />\n *\n * // \u5916\u90E8\u89E6\u53D1\u5F39\u7A97\n * lotteryRef.current?.showError({\n * title: 'Error',\n * message: 'Something went wrong'\n * })\n * ```\n */\nexport const WheelLottery = forwardRef<WheelLotteryHandle, WheelLotteryProps>(\n (\n {\n prizes,\n theme,\n winningPrizeId,\n spinDuration = DEFAULT_WHEEL_CONFIG.spinDuration,\n wheelBackgroundImage,\n pointerImage,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_WHEEL_CONFIG.chanceTitle,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n winningInfos = [],\n winnerNameTemplate,\n prizesTitle,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n winnerModalConfig,\n rulesModalConfig = {},\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n userData,\n onLoginRequired,\n onCopyCode,\n opportunitiesText = ['Number of draws remaining today:'],\n className,\n },\n ref\n ) => {\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances ?? 0\n const isNoChancesState = isLoggedIn && availableChances <= 0\n // ==========================================================================\n // State \u7BA1\u7406\n // ==========================================================================\n\n const [wheelState, setWheelState] = useState<WheelState>(INITIAL_WHEEL_STATE)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const animationRef = useRef<number | null>(null)\n\n // ==========================================================================\n // Imperative Handle - \u66B4\u9732\u65B9\u6CD5\u7ED9\u7236\u7EC4\u4EF6\n // ==========================================================================\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWheelState(prev => ({ ...prev, winningPrize: prize }))\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n // ==========================================================================\n // Props \u9A8C\u8BC1\uFF08\u5F00\u53D1\u73AF\u5883\uFF09\n // ==========================================================================\n\n useEffect(() => {\n if (process.env.NODE_ENV === 'development' && prizes) {\n if (prizes.length !== 8) {\n console.warn(\n `WheelLottery expects exactly 8 prizes, got ${prizes.length}. The component may not render correctly.`\n )\n }\n\n if (winningPrizeId && !prizes.find(p => p.prizeKey === winningPrizeId)) {\n console.warn(`WheelLottery: winningPrizeId \"${winningPrizeId}\" not found in prizes array.`)\n }\n }\n }, [prizes, winningPrizeId])\n\n // ==========================================================================\n // \u6E05\u7406\u52A8\u753B\n // ==========================================================================\n\n useEffect(() => {\n return () => {\n // \u7EC4\u4EF6\u5378\u8F7D\u65F6\u53D6\u6D88\u52A8\u753B\u5E27\n if (animationRef.current !== null) {\n cancelAnimationFrame(animationRef.current)\n }\n }\n }, [])\n\n // ==========================================================================\n // \u62BD\u5956\u903B\u8F91\n // ==========================================================================\n\n /**\n * \u5F00\u59CB\u62BD\u5956 - \u652F\u6301\u5F02\u6B65\u63A5\u53E3\u8C03\u7528\n * \u5229\u7528\u521D\u59CB\u6162\u901F\u65CB\u8F6C\uFF0C\u70B9\u51FB\u540E\u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF0C\u63A5\u53E3\u8FD4\u56DE\u540E\u51CF\u901F\u505C\u6B62\n */\n const handleSpinStart = useCallback(async () => {\n if (wheelState.isSpinning) return\n\n // \u68C0\u67E5\u7528\u6237\u662F\u5426\u5DF2\u767B\u5F55\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n // \u2705 \u6B21\u6570\u4E3A 0 \u65F6\uFF0C\u6309\u94AE\u5DF2\u88AB\u7981\u7528\uFF0C\u8FD9\u91CC\u4E0D\u9700\u8981\u989D\u5916\u68C0\u67E5\n // \u9632\u5FA1\u6027\u7F16\u7A0B\uFF1A\u5982\u679C\u4ECD\u7136\u89E6\u53D1\uFF0C\u76F4\u63A5\u8FD4\u56DE\n if (userData.availableChances <= 0) {\n return\n }\n\n // \u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF08\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u4F1A\u81EA\u52A8\u53D8\u4E3A\u5FEB\u901F\u65CB\u8F6C\uFF09\n setWheelState(prev => ({\n ...prev,\n isSpinning: true,\n isButtonDisabled: true,\n }))\n\n try {\n // \u8C03\u7528\u5916\u90E8\u63A5\u53E3\u83B7\u53D6\u4E2D\u5956\u7ED3\u679C\n let finalWinningPrizeId = winningPrizeId\n\n if (onSpinStart) {\n // \u7B49\u5F85\u63A5\u53E3\u8FD4\u56DE\u4E2D\u5956 ID\uFF08\u63A5\u53E3\u65F6\u95F4\u4E0D\u56FA\u5B9A\uFF0C1-30s\uFF09\n // \u5728\u6B64\u671F\u95F4\uFF0C\u8F6C\u76D8\u4F1A\u4FDD\u6301\u5FEB\u901F\u65CB\u8F6C\uFF08\u7531 CSS \u52A8\u753B\u63A7\u5236\uFF09\n finalWinningPrizeId = await onSpinStart()\n }\n\n // \u786E\u5B9A\u4E2D\u5956\u5956\u54C1\n const winningPrize = prizes.find(p => p.prizeKey === finalWinningPrizeId) || prizes[0]\n const winningIndex = prizes.findIndex(p => p.prizeKey === winningPrize.prizeKey)\n\n // \u8BA1\u7B97\u76EE\u6807\u89D2\u5EA6\n const degreesPerPrize = 360 / prizes.length\n const basePrizeAngle = winningIndex * degreesPerPrize\n // \u81F3\u5C11\u65CB\u8F6C 3 \u5708\uFF081080\u5EA6\uFF09+ \u76EE\u6807\u89D2\u5EA6\n const minRotations = 3\n const targetAngle = minRotations * 360 + (360 - basePrizeAngle)\n\n // \u63A5\u53E3\u8FD4\u56DE\u540E\uFF0C\u7B49\u5F85 1.5s \u518D\u5F00\u59CB\u505C\u6B62\u52A8\u753B\n await new Promise(resolve => setTimeout(resolve, 1500))\n\n // \u7ACB\u5373\u8FDB\u5165\u51CF\u901F\u72B6\u6001\uFF0C\u505C\u6B62 CSS \u5FAA\u73AF\u52A8\u753B\n setWheelState(prev => ({\n ...prev,\n isFinished: true,\n currentRotation: 0, // \u4ECE 0 \u5EA6\u5F00\u59CB\u51CF\u901F\u52A8\u753B\n }))\n\n // \u5F00\u59CB\u505C\u6B62\u65CB\u8F6C\u52A8\u753B\n const startTime = Date.now()\n\n const animate = () => {\n const now = Date.now()\n const elapsed = now - startTime\n const progress = Math.min(elapsed / spinDuration, 1)\n\n // \u5E94\u7528 ease-out \u7F13\u52A8\u51FD\u6570\n const eased = 1 - Math.pow(1 - progress, 3)\n\n // \u8BA1\u7B97\u5F53\u524D\u65CB\u8F6C\u89D2\u5EA6\n const currentRotation = targetAngle * eased\n\n // \u66F4\u65B0\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n currentRotation,\n }))\n\n // \u7EE7\u7EED\u52A8\u753B\u6216\u7ED3\u675F\n if (progress < 1) {\n animationRef.current = requestAnimationFrame(animate)\n } else {\n // \u52A8\u753B\u7ED3\u675F - \u4FDD\u6301\u6309\u94AE\u7981\u7528\u72B6\u6001,\u76F4\u5230\u5F39\u7A97\u5173\u95ED\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: true,\n winningPrize,\n currentRotation: targetAngle,\n }))\n\n // \u5EF6\u8FDF\u663E\u793A\u5F39\u7A97\uFF08500ms\u540E\uFF09\n if (onSpinEnd) {\n onSpinEnd?.(winningPrize)\n } else {\n setTimeout(() => {\n // \u68C0\u67E5\u662F\u5426\u672A\u4E2D\u5956\uFF08try-again\uFF09\n if (winningPrize.prizeKey === 'try-again') {\n // \u672A\u4E2D\u5956\uFF0C\u663E\u793A ErrorModal\n setShowNoWinModal(true)\n } else {\n // \u4E2D\u5956\uFF0C\u663E\u793A WinnerModal\n setShowWinnerModal(true)\n }\n }, 500)\n }\n }\n }\n\n // \u542F\u52A8\u505C\u6B62\u52A8\u753B\n animationRef.current = requestAnimationFrame(animate)\n } catch (error) {\n // \u63A5\u53E3\u62A5\u9519\uFF0C\u6062\u590D\u5230\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: false,\n }))\n\n // \u663E\u793A\u9519\u8BEF\u5F39\u7A97\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n\n // \u89E6\u53D1\u9519\u8BEF\u56DE\u8C03\n onSpinError?.(error as Error)\n\n console.error('\u62BD\u5956\u63A5\u53E3\u8C03\u7528\u5931\u8D25:', error)\n }\n }, [\n wheelState.isSpinning,\n prizes,\n winningPrizeId,\n spinDuration,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n userData,\n onLoginRequired,\n ])\n\n const handleWheelGoClick = useCallback(() => {\n if (isLoggedIn) {\n void handleSpinStart()\n return\n }\n\n onLoginRequired?.()\n }, [handleSpinStart, isLoggedIn, onLoginRequired])\n\n // ==========================================================================\n // \u5F39\u7A97\u5173\u95ED\u5904\u7406\n // ==========================================================================\n\n /**\n * \u5173\u95ED\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n /**\n * \u5173\u95ED\u672A\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n // ==========================================================================\n // \u6E32\u67D3\n // ==========================================================================\n\n return (\n <div className={cn('wheel-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}>\n {/* ARIA Live Region - \u5C4F\u5E55\u9605\u8BFB\u5668\u72B6\u6001\u64AD\u62A5 */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {wheelState.isSpinning && '\u62BD\u5956\u8FDB\u884C\u4E2D...'}\n {wheelState.winningPrize && !wheelState.isSpinning && `\u5DF2\u4E2D\u5956: ${wheelState.winningPrize.name}`}\n </div>\n\n {/* \u4E3B\u5185\u5BB9\u533A - \u54CD\u5E94\u5F0F\u4E24\u680F/\u5355\u680F\u5E03\u5C40 */}\n <Grid className={cn('wheel-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* \u5DE6\u4FA7\uFF1A\u8F6C\u76D8\u533A\u57DF */}\n <GridItem\n span={7}\n className={cn(\n 'wheel-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n // \u79FB\u52A8\u7AEF\uFF08<=1024px\uFF09\u4F7F\u7528min-h\uFF0C\u684C\u9762\u7AEF\u4F7F\u7528aspect ratio\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n // \u79FB\u52A8\u7AEF\u5E95\u90E8\u95F4\u8DDD\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'w-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n // \u79FB\u52A8\u7AEF(<=1024px)\u65F6\u4F7F\u7528\u7EDD\u5BF9\u5B9A\u4F4D\u8986\u76D6\u5728\u8F6C\u76D8\u80CC\u666F\u4E0A\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10'\n )}\n >\n {/* \u9876\u90E8\u4FE1\u606F\u680F\uFF1A\u5DE6\u4FA7\u673A\u4F1A\u8FDB\u5EA6\uFF0C\u53F3\u4FA7\u94FE\u63A5 */}\n <div className=\"tablet:max-h-[24px] relative z-10 mb-2 flex max-h-[40px] w-full flex-wrap items-center justify-between gap-3\">\n {/* \u5DE6\u4FA7\uFF1A\u673A\u4F1A\u5C55\u793A - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n <div>\n {isLoggedIn && (\n <p className=\"text-info-primary font-[700]\">\n {opportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {opportunitiesText?.[1] || ''}\n </p>\n )}\n </div>\n {/* \u53F3\u4FA7\uFF1ARules \u548C My Rewards \u6309\u94AE */}\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={() => setShowRulesModal(true)}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {/* My Rewards \u6309\u94AE - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n {userData?.isLoggedIn && rewardsData && (\n <button\n onClick={() => setShowRewardsModal(true)}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n </div>\n </div>\n {/* \u8F6C\u76D8\u7EC4\u4EF6 */}\n <Wheel\n theme={theme}\n prizes={prizes}\n rotation={wheelState.currentRotation}\n isSpinning={wheelState.isSpinning}\n isFinished={wheelState.isFinished}\n isButtonDisabled={wheelState.isButtonDisabled || !isLoggedIn || isNoChancesState}\n userData={userData}\n onGoClick={handleWheelGoClick}\n wheelBackgroundImage={wheelBackgroundImage}\n pointerImage={pointerImage}\n />\n </div>\n </GridItem>\n\n {/* \u53F3\u4FA7\uFF1A\u83B7\u53D6\u673A\u4F1A\u533A\u57DF */}\n {chanceMethods.length > 0 && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n // \u79FB\u52A8\u7AEF\u4F7F\u7528min-h\u800C\u4E0D\u662Fmax-h\uFF0C\u786E\u4FDD\u5185\u5BB9\u5B8C\u6574\u663E\u793A\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={inputConfig}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* \u5E95\u90E8\u533A\u57DF\uFF1A\u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355) */}\n <div\n className={cn(\n 'wheel-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n {/* \u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355\u81EA\u52A8\u6EDA\u52A8) */}\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winningInfos}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* \u4E2D\u5956\u5F39\u7A97 */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={wheelState.winningPrize}\n title={externalWinnerConfig?.title || winnerModalConfig?.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || winnerModalConfig?.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || winnerModalConfig?.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || winnerModalConfig?.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n wheelState.winningPrize?.winnerModalConfig?.winnerNote ??\n winnerModalConfig?.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreUrl ||\n winnerModalConfig?.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreText ||\n winnerModalConfig?.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || winnerModalConfig?.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || winnerModalConfig?.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || winnerModalConfig?.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || winnerModalConfig?.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n wheelState.winningPrize?.winnerModalConfig?.confirmText ||\n winnerModalConfig?.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n wheelState.winningPrize?.winnerModalConfig?.confirmUrl ||\n winnerModalConfig?.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || winnerModalConfig?.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || winnerModalConfig?.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules \u5F39\u7A97 */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards \u5F39\u7A97 */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* \u9519\u8BEF\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || errorModalConfig?.title}\n message={errorMessage || errorModalConfig?.message}\n confirmText={errorConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u672A\u4E2D\u5956\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={noWinTitle || errorModalConfig?.title}\n message={noWinMessage || errorModalConfig?.message}\n confirmText={noWinConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u5206\u4EAB\u5F39\u7A97 */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\n// \u8BBE\u7F6E displayName \u7528\u4E8E\u8C03\u8BD5\nWheelLottery.displayName = 'WheelLottery'\n\n// ============================================================================\n// \u5BFC\u51FA\n// ============================================================================\n\nexport default withLayout(WheelLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n WheelLotteryProps,\n WheelLotteryHandle,\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n WheelProps,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from './types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
+
"mappings": "gcAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,yKAAAE,EAAA,2CAAAC,KAAA,eAAAC,GAAAJ,IA6ZQ,IAAAK,EAAA,6BAlZRC,EAA0F,iBAC1FC,EAAmB,kCACnBC,EAAkF,sBAClFC,EAA+B,oCAC/BC,EAAsB,sBACtBC,EAA0B,yCAC1BC,GAA8B,6CAC9BC,GAA4B,2CAC5BC,GAA2B,0CAC3BC,GAA+B,8CAC/BC,EAA2B,0CAC3BC,GAA2B,0CAC3BC,GAA2B,kCA6oB3BL,GAA4B,2CAC5BC,GAA2B,0CAC3BC,GAA+B,8CAC/BC,GAA2B,0CAC3BC,GAA2B,0CAC3BE,GAA0B,yCAlnBnB,MAAMjB,KAAe,cAC1B,CACE,CACE,OAAAkB,EACA,MAAAC,EACA,eAAAC,EACA,aAAAC,EAAe,uBAAqB,aACpC,qBAAAC,EACA,aAAAC,GACA,cAAAC,EAAgB,yBAChB,YAAAC,GAAc,uBAAqB,YACnC,eAAAC,GACA,iBAAAC,GACA,kBAAAC,EACA,cAAAC,GACA,YAAAC,GAC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,eAAgBC,GAChB,YAAaC,GACb,aAAcC,GACd,MAAO1C,EACP,MAAOgC,EACT,KAIF,OAAC,cACC,OAAQwB,GACR,QAAS,IAAMC,EAAkB,EAAK,EACtC,MAAOO,IAAc3C,GAAkB,MACvC,QAASyC,IAAgBzC,GAAkB,QAC3C,YAAa6C,IAAoB7C,GAAkB,YACnD,MAAOrB,EACT,KAGA,OAAC,cACC,OAAQ0D,GACR,QAAS2C,GACT,MAAOjC,IAAc/C,GAAkB,MACvC,QAASiD,IAAgBjD,GAAkB,QAC3C,YAAamD,IAAoBnD,GAAkB,YACnD,MAAOrB,EACT,KAGA,OAAC,eACC,OAAQ4D,GACR,QAAS,IAAMC,EAAkB,EAAK,EACtC,MAAOvC,GAAkB,MACzB,SAAUA,GAAkB,SAC5B,KAAMA,GAAkB,KACxB,UAAWA,GAAkB,UAC7B,eAAgBA,GAAkB,eAClC,MAAOtB,EACT,GACF,CAEJ,CACF,EAGAnB,EAAa,YAAc,eAM3B,IAAOC,MAAQ,eAAWD,CAAY",
|
|
6
|
+
"names": ["WheelLottery_exports", "__export", "WheelLottery", "WheelLottery_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_helpers", "import_types", "import_grid", "import_Wheel", "import_PrizePool", "import_ChanceMethods", "import_WinnerModal", "import_RulesModal", "import_MyRewardsModal", "import_ErrorModal", "import_ShareModal", "import_Styles", "import_BaseModal", "prizes", "theme", "winningPrizeId", "spinDuration", "wheelBackgroundImage", "pointerImage", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "winningInfos", "winnerNameTemplate", "prizesTitle", "onSpinStart", "onSpinEnd", "onSpinError", "winnerModalConfig", "rulesModalConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "userData", "onLoginRequired", "onCopyCode", "opportunitiesText", "className", "ref", "rulesData", "rulesText", "rewardsData", "myRewardsText", "codeText", "copyText", "copiedText", "prizeText", "emptyText", "copyError", "availableText", "usedStatusText", "expiredText", "notFoundText", "completedText", "usedText", "isLoggedIn", "availableChances", "isNoChancesState", "wheelState", "setWheelState", "showWinnerModal", "setShowWinnerModal", "showRulesModal", "setShowRulesModal", "showRewardsModal", "setShowRewardsModal", "showErrorModal", "setShowErrorModal", "showNoWinModal", "setShowNoWinModal", "showShareModal", "setShowShareModal", "errorMessage", "setErrorMessage", "errorTitle", "setErrorTitle", "errorConfirmText", "setErrorConfirmText", "noWinTitle", "setNoWinTitle", "noWinMessage", "setNoWinMessage", "noWinConfirmText", "setNoWinConfirmText", "externalWinnerConfig", "setExternalWinnerConfig", "animationRef", "message", "title", "confirmText", "config", "prize", "prev", "handleSpinStart", "finalWinningPrizeId", "winningPrize", "p", "winningIndex", "degreesPerPrize", "basePrizeAngle", "targetAngle", "resolve", "startTime", "animate", "elapsed", "progress", "eased", "currentRotation", "error", "handleWheelGoClick", "handleCloseWinnerModal", "handleCloseNoWinModal"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as x}from"react/jsx-runtime";import{useState as o,useCallback as D,useImperativeHandle as _t,forwardRef as Ct,useEffect as h,useRef as Nt}from"react";import{cn as f}from"../../helpers/index.js";import{DEFAULT_CHANCE_TITLE as Pt}from"./types.js";import{DEFAULT_CHANCE_METHODS as kt}from"../LotteryShared/types.js";import{Grid as St,GridItem as be}from"../../components/grid.js";import{MediaDrawArea as Lt}from"./MediaDrawArea.js";import{PrizePool as Wt}from"../LotteryShared/PrizePool.js";import{ChanceMethods as Rt}from"../LotteryShared/ChanceMethods.js";import{WinnerModal as Ot}from"../LotteryShared/WinnerModal.js";import{RulesModal as At}from"../LotteryShared/RulesModal.js";import{MyRewardsModal as zt}from"../LotteryShared/MyRewardsModal.js";import{ErrorModal as _e}from"../LotteryShared/ErrorModal.js";import{ShareModal as It}from"../LotteryShared/ShareModal.js";import{withLayout as Dt}from"../../shared/Styles.js";import{gaTrack as y}from"../../shared/track.js";import{useAiuiContext as $t}from"../AiuiProvider/index.js";import{useExposure as Ht}from"../../hooks/useExposure.js";import{trackUrlRef as Ce,buildTrackingRef as Ne}from"../../shared/trackUrlRef.js";const Ut="image",p="lottery_banner",M="\u4EA7\u54C1\u62BD\u5956",u="copy",v="lottery_pop",w="image",Pe=Ct(({prizes:R,media:ke,theme:a,ctaButton:te,videoAutoPlay:Se,videoMuted:Le,videoLoop:We,chanceMethods:oe=kt,chanceTitle:Re=Pt,chanceSubtitle:Oe,chanceFooterNote:Ae,chanceMethodsText:O,mechanismType:$,inputConfig:i,inputPlaceholder:re,inputSubmitText:ne,inputType:ae,inputValidationErrorText:se,winnerTickerData:ze=[],winningInfos:ie,winnerNameTemplate:Ie,prizesTitle:De,onDrawStart:H,onDrawEnd:U,onDrawError:le,winnerModalConfig:pe,rulesModalConfig:$e={},actionButtonConfig:d,myRewardsModalConfig:He={},errorModalConfig:A={},shareModalConfig:E={},error:g,tryAgain:F,userData:c,loginPrompt:Ue,loginPromptText:Fe="Please log in to participate",loginButtonText:Ft="Log In",noChances:je,noChancesText:Ye="You have no chances left",onLoginRequired:b,onCopyCode:Ge,opportunitiesPrefix:de,opportunitiesText:Be=["Number of draws remaining today:"],dealsType:jt,className:Ke},Je)=>{const Yt=Ue??Fe??"Please log in to participate",Qe=je??Ye??"You have no chances left",ce=de?[de]:Be??["Number of draws remaining today:"],me=re||ne||ae||se?{...i??{},placeholder:re??i?.placeholder??"Enter your order number",submitText:ne??i?.submitText??"Spin and Win",inputType:ae??i?.inputType??"text",validationErrorText:se??i?.validationErrorText}:i,_=g?{title:g.title??A?.title,message:g.defaultMessage??A?.message,confirmText:g.confirmButton??A?.confirmText,exchangeFailedTitle:g.exchangeFailedTitle,exchangeFailedMessage:g.exchangeFailedMessage}:A,r={...ie,...pe,confirmText:pe?.confirmText??ie?.confirmButton},{rulesData:C,rulesText:j="Rules"}=$e,Xe=!!(d?.text&&d?.url),{rewardsData:Y,myRewardsText:G="My Rewards",codeText:Ze="CODE:",copyText:fe="COPY",copiedText:ue="COPIED",prizeText:Ve="Prize time:",emptyText:qe,copyError:et,availableText:tt,usedStatusText:ot,expiredText:rt,notFoundText:nt}=He,at=O?.completedText,st=O?.usedText,z=c?.isLoggedIn??!1,xe=c?.availableChances??0,ge=oe.length>0||$==="input",Te=$==="input"&&!!i?.agreementNotice,he=z&&xe<=0&&c?.isChancesLoading!==!0,[N,B]=o(!1),[l,ye]=o(null),[K,P]=o(!1),[J,k]=o(!1),[Q,S]=o(!1),[X,T]=o(!1),[Z,L]=o(!1),[V,W]=o(!1),[Me,I]=o(""),[it,lt]=o(),[pt,dt]=o(),[ct,mt]=o(),[ft,ut]=o(),[xt,gt]=o(),[n,Tt]=o(),[q,ht]=o(!1),ve=Nt(null);Ht(ve,{componentType:Ut,componentName:p,componentTitle:M});const{trackingData:s,pageHandle:we}=$t();h(()=>{K&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:w,component_name:v,component_title:"Winner"}})},[K,s]),h(()=>{Z&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:w,component_name:v,component_title:"Better Luck Next Time"}})},[Z,s]),h(()=>{J&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:w,component_name:v,component_title:"Rules"}})},[J,s]),h(()=>{Q&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:w,component_name:v,component_title:"My Rewards"}})},[Q,s]),h(()=>{V&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:w,component_name:v,component_title:"Share"}})},[V,s]),h(()=>{X&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:w,component_name:v,component_title:"Error"}})},[X,s]),_t(Je,()=>({showError:({message:e,title:m,confirmText:ee})=>{I(e),lt(m),dt(ee),T(!0)},hideError:()=>{T(!1)},showNoWin:e=>{mt(e?.title),ut(e?.message),gt(e?.confirmText),L(!0)},hideNoWin:()=>{L(!1)},showWinner:(e,m)=>{ye(e),Tt(m),P(!0)},hideWinner:()=>{P(!1)},showRules:()=>{k(!0)},hideRules:()=>{k(!1)},showRewards:()=>{S(!0)},hideRewards:()=>{S(!1)},showShare:()=>{W(!0)},hideShare:()=>{W(!1)},hideAllModals:()=>{P(!1),k(!1),S(!1),T(!1),L(!1),W(!1)}}),[]);const Ee=D(async()=>{if(!N){if(Te&&!q){I(i?.agreementWarningText||"Please agree to the terms before continuing"),T(!1);return}if(!c?.isLoggedIn){b?.();return}if(!(c.availableChances<=0)){B(!0);try{let e;H&&(e=await H());const m=R.find(ee=>ee.prizeKey===e)||R[0];ye(m),B(!1),U?U(m):setTimeout(()=>{m.prizeKey==="try-again"?L(!0):P(!0)},300)}catch(e){B(!1),I(e.message||"An error occurred"),T(!0),le?.(e)}}}},[Te,i?.agreementWarningText,q,N,R,H,U,le,c,b]),yt=D(()=>{if(!z){b?.();return}Ee()},[Ee,z,b]),Mt=D(()=>{P(!1)},[]),vt=D(()=>{L(!1)},[]),wt=ct||F?.title,Et=ft||F?.message,bt=xt||F?.confirmText;return x("div",{ref:ve,className:f("product-lottery-container","w-full",a==="dark"?"aiui-dark":"",Ke),children:[x("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:[N&&"Drawing in progress...",l&&!N&&`Prize won: ${l.name}`]}),x(St,{className:f("product-lottery-main","tablet:mb-4 mb-3"),children:[t(be,{span:ge?7:12,className:f("media-section","relative flex w-full flex-1 items-center justify-center overflow-hidden","rounded-box","laptop:min-h-[288px] min-h-[240px]","lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]","desktop:aspect-w-[759] desktop:aspect-h-[384]","laptop:aspect-w-[516] laptop:aspect-h-[288]","l-tablet:col-span-12","l-tablet:mb-3",a==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:x("div",{className:f("size-full px-[16px] pt-[16px]","lg-desktop:pb-[32px] lg-desktop:px-[32px]","desktop:pt-[24px] desktop:px-[24px]","laptop:pt-[16px] laptop:px-[16px]","tablet:px-[24px]","l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10","flex flex-col"),children:[x("div",{className:"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3",children:[t("div",{children:x("p",{className:"text-info-primary font-[700]",children:[ce?.[0],t("span",{className:"ml-1 text-[#FF6B35]",children:xe}),ce?.[1]||""]})}),x("div",{className:"flex items-center gap-4",children:[C&&C.length>0&&t("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),k(!0)},className:"cursor-pointer touch-manipulation",type:"button","data-headless-type-name":`${u}#${p}`,"data-headless-title-desc-button":`${M}##${j}`,children:t("span",{className:"text-info-primary font-[700] underline",children:j})}),Y&&t("button",{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!z){b?.();return}S(!0)},className:"cursor-pointer touch-manipulation whitespace-nowrap",type:"button","data-headless-type-name":`${u}#${p}`,"data-headless-title-desc-button":`${M}##${G}`,children:t("span",{className:"text-info-primary font-[700] underline",children:G})}),Xe&&t("a",{href:Ce(d?.url??"",Ne(we??"",u,p)),className:"cursor-pointer touch-manipulation whitespace-nowrap",onClick:e=>{e.preventDefault(),e.stopPropagation(),d?.url&&(window.location.href=Ce(d.url,Ne(we??"",u,p)))},"data-headless-type-name":`${u}#${p}`,"data-headless-title-desc-button":`${M}##${d?.text}`,children:t("span",{className:"text-info-primary font-[700] underline",children:d?.text})})]})]}),t(Lt,{className:"min-h-0 w-full flex-1",theme:a,media:ke,ctaButton:te,videoAutoPlay:Se,videoMuted:Le,videoLoop:We,isDrawing:N,isDisabled:he,onClick:yt,ctaTrackTypeName:`${u}#${p}`,ctaTrackTitleDescButton:`${M}##${te?.text??""}`}),he&&t("div",{className:f("rounded-box absolute inset-0 z-20 flex items-center justify-center bg-black/60 backdrop-blur-sm","px-6 text-center"),children:t("div",{className:"flex flex-col items-center gap-4",children:t("p",{className:"lg-desktop:text-[24px] text-[18px] font-semibold text-white",children:Qe})})})]})}),ge&&t(be,{span:5,className:f("info-section","rounded-box","relative flex flex-col overflow-hidden","lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]","desktop:aspect-w-[536] desktop:aspect-h-[384]","laptop:aspect-w-[364] laptop:aspect-h-[288]","l-tablet:min-h-[280px] laptop:max-h-[320px]","w-full","l-tablet:col-span-12",a==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:t(Rt,{theme:a,userData:c,methods:oe,title:Re,subtitle:Oe,footerNote:Ae,onOpenShareModal:()=>W(!0),chanceBadgeText:O?.chanceBadgeText,completedText:at,usedText:st,loadingText:O?.loadingText,mechanismType:$,inputConfig:{...me,submitTrackTypeName:`${u}#${p}`,submitTrackTitleDescButton:`${M}##${me?.submitText??"Spin and Win"}`},isAgreementChecked:q,onAgreementCheckedChange:e=>{ht(e),e&&I("")},agreementErrorText:Me})})]}),t("div",{className:f("product-lottery-footer","rounded-box","flex flex-col overflow-hidden",a==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:t(Wt,{theme:a,prizes:R,title:De,winningInfos:ze,winnerNameTemplate:Ie})}),t(Ot,{isOpen:K,prize:l,title:n?.title||r.title,prizeTitle:n?.prizeTitle||r.prizeTitle,prizeImage:n?.prizeImage||r.prizeImage,prizeDescription:n?.prizeDescription||r.prizeDescription,winnerNote:n?.winnerNote??l?.winnerModalConfig?.winnerNote??r.winnerNote,learnMoreUrl:n?.learnMoreUrl||l?.winnerModalConfig?.learnMoreUrl||r.learnMoreUrl,learnMoreText:n?.learnMoreText||l?.winnerModalConfig?.learnMoreText||r.learnMoreText,couponCode:n?.couponCode||r.couponCode,expiresAt:n?.expiresAt||r.expiresAt,couponDiscount:n?.couponDiscount||r.couponDiscount,couponUnit:n?.couponUnit||r.couponUnit,confirmText:n?.confirmText||l?.winnerModalConfig?.confirmText||r.confirmText,confirmUrl:n?.confirmUrl||l?.winnerModalConfig?.confirmUrl||r.confirmUrl,copyText:n?.copyText||r.copyText||fe,copiedText:n?.copiedText||r.copiedText||ue,onClose:Mt,theme:a}),C&&C.length>0&&t(At,{title:j,isOpen:J,onClose:()=>k(!1),rules:C,theme:a}),Y&&t(zt,{isOpen:Q,onClose:()=>S(!1),rewards:Y,onCopyCode:Ge,codeText:Ze,copyText:fe,copiedText:ue,prizeText:Ve,emptyText:qe,copyError:et,availableText:tt,usedStatusText:ot,expiredText:rt,notFoundText:nt,theme:a,title:G}),t(_e,{isOpen:X,onClose:()=>T(!1),title:it||_?.title,message:Me||_?.message,confirmText:pt||_?.confirmText,exchangeFailedTitle:_?.exchangeFailedTitle,exchangeFailedMessage:_?.exchangeFailedMessage,theme:a}),t(_e,{isOpen:Z,onClose:vt,title:wt,message:Et,confirmText:bt,theme:a}),t(It,{isOpen:V,onClose:()=>W(!1),title:E?.title,subtitle:E?.subtitle,note:E?.note,platforms:E?.platforms,onShareSuccess:E?.onShareSuccess,theme:a})]})});Pe.displayName="ProductLottery";var po=Dt(Pe);import{WinnerModal as fo}from"../LotteryShared/WinnerModal.js";import{RulesModal as xo}from"../LotteryShared/RulesModal.js";import{MyRewardsModal as To}from"../LotteryShared/MyRewardsModal.js";import{ErrorModal as yo}from"../LotteryShared/ErrorModal.js";import{ShareModal as vo}from"../LotteryShared/ShareModal.js";import{BaseModal as Eo}from"../LotteryShared/BaseModal.js";export{Eo as BaseModal,yo as ErrorModal,To as MyRewardsModal,Pe as ProductLottery,xo as RulesModal,vo as ShareModal,fo as WinnerModal,po as default};
|
|
1
|
+
"use client";import{jsx as t,jsxs as f}from"react/jsx-runtime";import{useState as o,useCallback as I,useImperativeHandle as wt,forwardRef as vt,useEffect as T,useRef as Et}from"react";import{cn as h}from"../../helpers/index.js";import{DEFAULT_CHANCE_TITLE as _t}from"./types.js";import{DEFAULT_CHANCE_METHODS as Pt}from"../LotteryShared/types.js";import{Grid as Ct,GridItem as ve}from"../../components/grid.js";import{MediaDrawArea as Nt}from"./MediaDrawArea.js";import{PrizePool as bt}from"../LotteryShared/PrizePool.js";import{ChanceMethods as St}from"../LotteryShared/ChanceMethods.js";import{WinnerModal as kt}from"../LotteryShared/WinnerModal.js";import{RulesModal as Lt}from"../LotteryShared/RulesModal.js";import{MyRewardsModal as Wt}from"../LotteryShared/MyRewardsModal.js";import{ErrorModal as Ee}from"../LotteryShared/ErrorModal.js";import{ShareModal as Rt}from"../LotteryShared/ShareModal.js";import{withLayout as At}from"../../shared/Styles.js";import{gaTrack as y}from"../../shared/track.js";import{useAiuiContext as Ot}from"../AiuiProvider/index.js";import{useExposure as zt}from"../../hooks/useExposure.js";import{trackUrlRef as _e,buildTrackingRef as Pe}from"../../shared/trackUrlRef.js";const It="image",p="lottery_banner",M="\u4EA7\u54C1\u62BD\u5956",m="copy",w="lottery_pop",v="image",Ce=vt(({prizes:R,media:Ne,theme:a,ctaButton:te,videoAutoPlay:be,videoMuted:Se,videoLoop:ke,chanceMethods:oe=Pt,chanceTitle:Le=_t,chanceSubtitle:We,chanceFooterNote:Re,chanceMethodsText:A,mechanismType:D,inputConfig:i,inputPlaceholder:re,inputSubmitText:ne,inputType:ae,inputValidationErrorText:se,winnerTickerData:Ae=[],winningInfos:ie,winnerNameTemplate:Oe,prizesTitle:ze,onDrawStart:$,onDrawEnd:H,onDrawError:le,winnerModalConfig:pe,rulesModalConfig:Ie={},actionButtonConfig:d,myRewardsModalConfig:De={},errorModalConfig:O={},shareModalConfig:E={},error:u,tryAgain:U,userData:x,loginPrompt:$e,loginPromptText:He="Please log in to participate",loginButtonText:Dt="Log In",onLoginRequired:_,onCopyCode:Ue,opportunitiesPrefix:de,opportunitiesText:Fe=["Number of draws remaining today:"],dealsType:$t,className:je},Ge)=>{const Ht=$e??He??"Please log in to participate",ce=de?[de]:Fe??["Number of draws remaining today:"],me=re||ne||ae||se?{...i??{},placeholder:re??i?.placeholder??"Enter your order number",submitText:ne??i?.submitText??"Spin and Win",inputType:ae??i?.inputType??"text",validationErrorText:se??i?.validationErrorText}:i,P=u?{title:u.title??O?.title,message:u.defaultMessage??O?.message,confirmText:u.confirmButton??O?.confirmText,exchangeFailedTitle:u.exchangeFailedTitle,exchangeFailedMessage:u.exchangeFailedMessage}:O,r={...ie,...pe,confirmText:pe?.confirmText??ie?.confirmButton},{rulesData:C,rulesText:F="Rules"}=Ie,Be=!!(d?.text&&d?.url),{rewardsData:j,myRewardsText:G="My Rewards",codeText:Ye="CODE:",copyText:fe="COPY",copiedText:ue="COPIED",prizeText:Ke="Prize time:",emptyText:Je,copyError:Qe,availableText:Xe,usedStatusText:Ze,expiredText:Ve,notFoundText:qe}=De,et=A?.completedText,tt=A?.usedText,B=x?.isLoggedIn??!1,ot=x?.availableChances??0,xe=oe.length>0||D==="input",ge=D==="input"&&!!i?.agreementNotice,[N,Y]=o(!1),[l,Te]=o(null),[K,b]=o(!1),[J,S]=o(!1),[Q,k]=o(!1),[X,g]=o(!1),[Z,L]=o(!1),[V,W]=o(!1),[he,z]=o(""),[rt,nt]=o(),[at,st]=o(),[it,lt]=o(),[pt,dt]=o(),[ct,mt]=o(),[n,ft]=o(),[q,ut]=o(!1),ye=Et(null);zt(ye,{componentType:It,componentName:p,componentTitle:M});const{trackingData:s,pageHandle:Me}=Ot();T(()=>{K&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:v,component_name:w,component_title:"Winner"}})},[K,s]),T(()=>{Z&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:v,component_name:w,component_title:"Better Luck Next Time"}})},[Z,s]),T(()=>{J&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:v,component_name:w,component_title:"Rules"}})},[J,s]),T(()=>{Q&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:v,component_name:w,component_title:"My Rewards"}})},[Q,s]),T(()=>{V&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:v,component_name:w,component_title:"Share"}})},[V,s]),T(()=>{X&&y({event:"ga4Event",event_name:"component_impression",event_parameters:{page_group:s?.pageGroup||"Home Page",component_type:v,component_name:w,component_title:"Error"}})},[X,s]),wt(Ge,()=>({showError:({message:e,title:c,confirmText:ee})=>{z(e),nt(c),st(ee),g(!0)},hideError:()=>{g(!1)},showNoWin:e=>{lt(e?.title),dt(e?.message),mt(e?.confirmText),L(!0)},hideNoWin:()=>{L(!1)},showWinner:(e,c)=>{Te(e),ft(c),b(!0)},hideWinner:()=>{b(!1)},showRules:()=>{S(!0)},hideRules:()=>{S(!1)},showRewards:()=>{k(!0)},hideRewards:()=>{k(!1)},showShare:()=>{W(!0)},hideShare:()=>{W(!1)},hideAllModals:()=>{b(!1),S(!1),k(!1),g(!1),L(!1),W(!1)}}),[]);const we=I(async()=>{if(!N){if(ge&&!q){z(i?.agreementWarningText||"Please agree to the terms before continuing"),g(!1);return}if(!x?.isLoggedIn){_?.();return}if(!(x.availableChances<=0)){Y(!0);try{let e;$&&(e=await $());const c=R.find(ee=>ee.prizeKey===e)||R[0];Te(c),Y(!1),H?H(c):setTimeout(()=>{c.prizeKey==="try-again"?L(!0):b(!0)},300)}catch(e){Y(!1),z(e.message||"An error occurred"),g(!0),le?.(e)}}}},[ge,i?.agreementWarningText,q,N,R,$,H,le,x,_]),xt=I(()=>{if(!B){_?.();return}we()},[we,B,_]),gt=I(()=>{b(!1)},[]),Tt=I(()=>{L(!1)},[]),ht=it||U?.title,yt=pt||U?.message,Mt=ct||U?.confirmText;return f("div",{ref:ye,className:h("product-lottery-container","w-full",a==="dark"?"aiui-dark":"",je),children:[f("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:[N&&"Drawing in progress...",l&&!N&&`Prize won: ${l.name}`]}),f(Ct,{className:h("product-lottery-main","tablet:mb-4 mb-3"),children:[t(ve,{span:xe?7:12,className:h("media-section","relative flex w-full flex-1 items-center justify-center overflow-hidden","rounded-box","laptop:min-h-[288px] min-h-[240px]","lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]","desktop:aspect-w-[759] desktop:aspect-h-[384]","laptop:aspect-w-[516] laptop:aspect-h-[288]","l-tablet:col-span-12","l-tablet:mb-3",a==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:f("div",{className:h("size-full px-[16px] pt-[16px]","lg-desktop:pb-[32px] lg-desktop:px-[32px]","desktop:pt-[24px] desktop:px-[24px]","laptop:pt-[16px] laptop:px-[16px]","tablet:px-[24px]","l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10","flex flex-col"),children:[f("div",{className:"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3",children:[t("div",{children:f("p",{className:"text-info-primary font-[700]",children:[ce?.[0],t("span",{className:"ml-1 text-[#FF6B35]",children:ot}),ce?.[1]||""]})}),f("div",{className:"flex items-center gap-4",children:[C&&C.length>0&&t("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),S(!0)},className:"cursor-pointer touch-manipulation",type:"button","data-headless-type-name":`${m}#${p}`,"data-headless-title-desc-button":`${M}##${F}`,children:t("span",{className:"text-info-primary font-[700] underline",children:F})}),j&&t("button",{onClick:e=>{if(e.preventDefault(),e.stopPropagation(),!B){_?.();return}k(!0)},className:"cursor-pointer touch-manipulation whitespace-nowrap",type:"button","data-headless-type-name":`${m}#${p}`,"data-headless-title-desc-button":`${M}##${G}`,children:t("span",{className:"text-info-primary font-[700] underline",children:G})}),Be&&t("a",{href:_e(d?.url??"",Pe(Me??"",m,p)),className:"cursor-pointer touch-manipulation whitespace-nowrap",onClick:e=>{e.preventDefault(),e.stopPropagation(),d?.url&&(window.location.href=_e(d.url,Pe(Me??"",m,p)))},"data-headless-type-name":`${m}#${p}`,"data-headless-title-desc-button":`${M}##${d?.text}`,children:t("span",{className:"text-info-primary font-[700] underline",children:d?.text})})]})]}),t(Nt,{className:"min-h-0 w-full flex-1",theme:a,media:Ne,ctaButton:te,videoAutoPlay:be,videoMuted:Se,videoLoop:ke,isDrawing:N,onClick:xt,ctaTrackTypeName:`${m}#${p}`,ctaTrackTitleDescButton:`${M}##${te?.text??""}`})]})}),xe&&t(ve,{span:5,className:h("info-section","rounded-box","relative flex flex-col overflow-hidden","lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]","desktop:aspect-w-[536] desktop:aspect-h-[384]","laptop:aspect-w-[364] laptop:aspect-h-[288]","l-tablet:min-h-[280px] laptop:max-h-[320px]","w-full","l-tablet:col-span-12",a==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:t(St,{theme:a,userData:x,methods:oe,title:Le,subtitle:We,footerNote:Re,onOpenShareModal:()=>W(!0),chanceBadgeText:A?.chanceBadgeText,completedText:et,usedText:tt,loadingText:A?.loadingText,mechanismType:D,inputConfig:{...me,submitTrackTypeName:`${m}#${p}`,submitTrackTitleDescButton:`${M}##${me?.submitText??"Spin and Win"}`},isAgreementChecked:q,onAgreementCheckedChange:e=>{ut(e),e&&z("")},agreementErrorText:he})})]}),t("div",{className:h("product-lottery-footer","rounded-box","flex flex-col overflow-hidden",a==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:t(bt,{theme:a,prizes:R,title:ze,winningInfos:Ae,winnerNameTemplate:Oe})}),t(kt,{isOpen:K,prize:l,title:n?.title||r.title,prizeTitle:n?.prizeTitle||r.prizeTitle,prizeImage:n?.prizeImage||r.prizeImage,prizeDescription:n?.prizeDescription||r.prizeDescription,winnerNote:n?.winnerNote??l?.winnerModalConfig?.winnerNote??r.winnerNote,learnMoreUrl:n?.learnMoreUrl||l?.winnerModalConfig?.learnMoreUrl||r.learnMoreUrl,learnMoreText:n?.learnMoreText||l?.winnerModalConfig?.learnMoreText||r.learnMoreText,couponCode:n?.couponCode||r.couponCode,expiresAt:n?.expiresAt||r.expiresAt,couponDiscount:n?.couponDiscount||r.couponDiscount,couponUnit:n?.couponUnit||r.couponUnit,confirmText:n?.confirmText||l?.winnerModalConfig?.confirmText||r.confirmText,confirmUrl:n?.confirmUrl||l?.winnerModalConfig?.confirmUrl||r.confirmUrl,copyText:n?.copyText||r.copyText||fe,copiedText:n?.copiedText||r.copiedText||ue,onClose:gt,theme:a}),C&&C.length>0&&t(Lt,{title:F,isOpen:J,onClose:()=>S(!1),rules:C,theme:a}),j&&t(Wt,{isOpen:Q,onClose:()=>k(!1),rewards:j,onCopyCode:Ue,codeText:Ye,copyText:fe,copiedText:ue,prizeText:Ke,emptyText:Je,copyError:Qe,availableText:Xe,usedStatusText:Ze,expiredText:Ve,notFoundText:qe,theme:a,title:G}),t(Ee,{isOpen:X,onClose:()=>g(!1),title:rt||P?.title,message:he||P?.message,confirmText:at||P?.confirmText,exchangeFailedTitle:P?.exchangeFailedTitle,exchangeFailedMessage:P?.exchangeFailedMessage,theme:a}),t(Ee,{isOpen:Z,onClose:Tt,title:ht,message:yt,confirmText:Mt,theme:a}),t(Rt,{isOpen:V,onClose:()=>W(!1),title:E?.title,subtitle:E?.subtitle,note:E?.note,platforms:E?.platforms,onShareSuccess:E?.onShareSuccess,theme:a})]})});Ce.displayName="ProductLottery";var ao=At(Ce);import{WinnerModal as lo}from"../LotteryShared/WinnerModal.js";import{RulesModal as co}from"../LotteryShared/RulesModal.js";import{MyRewardsModal as fo}from"../LotteryShared/MyRewardsModal.js";import{ErrorModal as xo}from"../LotteryShared/ErrorModal.js";import{ShareModal as To}from"../LotteryShared/ShareModal.js";import{BaseModal as yo}from"../LotteryShared/BaseModal.js";export{yo as BaseModal,xo as ErrorModal,fo as MyRewardsModal,Ce as ProductLottery,co as RulesModal,To as ShareModal,lo as WinnerModal,ao as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/ProductLottery/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport { useState, useCallback, useImperativeHandle, forwardRef, useEffect, useRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_CHANCE_TITLE } from './types.js'\nimport { DEFAULT_CHANCE_METHODS } from '../LotteryShared/types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { MediaDrawArea } from './MediaDrawArea.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef, buildTrackingRef } from '../../shared/trackUrlRef.js'\n\nimport type { ProductLotteryProps, ProductLotteryHandle } from './types.js'\nimport type { Prize, WinnerModalConfig, ChanceInputConfig } from '../LotteryShared/types.js'\n\nconst LOTTERY_COMPONENT_TYPE = 'image'\nconst LOTTERY_COMPONENT_NAME = 'lottery_banner'\nconst LOTTERY_COMPONENT_TITLE = '\u4EA7\u54C1\u62BD\u5956'\nconst LOTTERY_CLICK_TYPE = 'copy'\nconst LOTTERY_MODAL_COMPONENT_NAME = 'lottery_pop'\nconst LOTTERY_MODAL_COMPONENT_TYPE = 'image'\n\nexport const ProductLottery = forwardRef<ProductLotteryHandle, ProductLotteryProps>(\n (\n {\n prizes,\n media,\n theme,\n ctaButton,\n videoAutoPlay,\n videoMuted,\n videoLoop,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_CHANCE_TITLE,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n inputPlaceholder,\n inputSubmitText,\n inputType,\n inputValidationErrorText,\n winnerTickerData = [],\n winningInfos,\n winnerNameTemplate,\n prizesTitle,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n winnerModalConfig,\n rulesModalConfig = {},\n actionButtonConfig,\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n error,\n tryAgain,\n userData,\n loginPrompt,\n loginPromptText = 'Please log in to participate',\n loginButtonText = 'Log In',\n noChances,\n noChancesText = 'You have no chances left',\n onLoginRequired,\n onCopyCode,\n opportunitiesPrefix,\n opportunitiesText = ['Number of draws remaining today:'],\n dealsType,\n className,\n },\n ref\n ) => {\n // \u2500\u2500 CMS field normalization \u2500\u2500\n // CMS-primary strategy: CMS fields take precedence over legacy backward-compat fields.\n // If a CMS field is provided, it overrides the corresponding legacy field.\n const resolvedLoginPrompt = loginPrompt ?? loginPromptText ?? 'Please log in to participate'\n const resolvedNoChances = noChances ?? noChancesText ?? 'You have no chances left'\n const resolvedOpportunitiesText: string[] = opportunitiesPrefix\n ? [opportunitiesPrefix]\n : (opportunitiesText ?? ['Number of draws remaining today:'])\n const resolvedInputConfig: ChanceInputConfig | undefined =\n inputPlaceholder || inputSubmitText || inputType || inputValidationErrorText\n ? {\n ...(inputConfig ?? {}),\n placeholder: inputPlaceholder ?? inputConfig?.placeholder ?? 'Enter your order number',\n submitText: inputSubmitText ?? inputConfig?.submitText ?? 'Spin and Win',\n inputType: inputType ?? inputConfig?.inputType ?? 'text',\n validationErrorText: inputValidationErrorText ?? inputConfig?.validationErrorText,\n }\n : inputConfig\n const resolvedErrorConfig = error\n ? {\n title: error.title ?? errorModalConfig?.title,\n message: error.defaultMessage ?? errorModalConfig?.message,\n confirmText: error.confirmButton ?? errorModalConfig?.confirmText,\n exchangeFailedTitle: error.exchangeFailedTitle,\n exchangeFailedMessage: error.exchangeFailedMessage,\n }\n : errorModalConfig\n const resolvedWinnerConfig: WinnerModalConfig = {\n ...winningInfos,\n ...winnerModalConfig,\n confirmText: winnerModalConfig?.confirmText ?? winningInfos?.confirmButton,\n }\n\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const shouldShowActionButton = Boolean(actionButtonConfig?.text && actionButtonConfig?.url)\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances ?? 0\n const hasRightPanel = chanceMethods.length > 0 || mechanismType === 'input'\n const hasAgreementNotice = mechanismType === 'input' && Boolean(inputConfig?.agreementNotice)\n const showNoChancesOverlay = isLoggedIn && availableChances <= 0 && userData?.isChancesLoading !== true\n\n // State\n const [isDrawing, setIsDrawing] = useState(false)\n const [winningPrize, setWinningPrize] = useState<Prize | null>(null)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const [isAgreementChecked, setIsAgreementChecked] = useState(false)\n\n // Exposure tracking\n const containerRef = useRef<HTMLDivElement>(null)\n useExposure(containerRef, {\n componentType: LOTTERY_COMPONENT_TYPE,\n componentName: LOTTERY_COMPONENT_NAME,\n componentTitle: LOTTERY_COMPONENT_TITLE,\n })\n\n // Tracking\n const { trackingData, pageHandle } = useAiuiContext()\n\n // Modal impression tracking \u2014 fires once per open\n useEffect(() => {\n if (!showWinnerModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Winner',\n },\n })\n }, [showWinnerModal, trackingData])\n\n useEffect(() => {\n if (!showNoWinModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Better Luck Next Time',\n },\n })\n }, [showNoWinModal, trackingData])\n\n useEffect(() => {\n if (!showRulesModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Rules',\n },\n })\n }, [showRulesModal, trackingData])\n\n useEffect(() => {\n if (!showRewardsModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'My Rewards',\n },\n })\n }, [showRewardsModal, trackingData])\n\n useEffect(() => {\n if (!showShareModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Share',\n },\n })\n }, [showShareModal, trackingData])\n\n useEffect(() => {\n if (!showErrorModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Error',\n },\n })\n }, [showErrorModal, trackingData])\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWinningPrize(prize)\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n const handleDrawStart = useCallback(async () => {\n if (isDrawing) return\n\n if (hasAgreementNotice && !isAgreementChecked) {\n setErrorMessage(inputConfig?.agreementWarningText || 'Please agree to the terms before continuing')\n setShowErrorModal(false)\n return\n }\n\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n if (userData.availableChances <= 0) {\n return\n }\n\n setIsDrawing(true)\n\n try {\n let prizeId: string | undefined\n\n if (onDrawStart) {\n prizeId = await onDrawStart()\n }\n\n const prize = prizes.find(p => p.prizeKey === prizeId) || prizes[0]\n setWinningPrize(prize)\n setIsDrawing(false)\n\n if (onDrawEnd) {\n onDrawEnd(prize)\n } else {\n setTimeout(() => {\n if (prize.prizeKey === 'try-again') {\n setShowNoWinModal(true)\n } else {\n setShowWinnerModal(true)\n }\n }, 300)\n }\n } catch (error) {\n setIsDrawing(false)\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n onDrawError?.(error as Error)\n }\n }, [\n hasAgreementNotice,\n inputConfig?.agreementWarningText,\n isAgreementChecked,\n isDrawing,\n prizes,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n userData,\n onLoginRequired,\n ])\n\n const handleDrawClick = useCallback(() => {\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n void handleDrawStart()\n }, [handleDrawStart, isLoggedIn, onLoginRequired])\n\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n }, [])\n\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n }, [])\n\n // \u2500\u2500 TryAgain / no-win modal normalization \u2500\u2500\n const resolvedTryAgainTitle = noWinTitle || tryAgain?.title\n const resolvedTryAgainMessage = noWinMessage || tryAgain?.message\n const resolvedTryAgainConfirmText = noWinConfirmText || tryAgain?.confirmText\n\n return (\n <div\n ref={containerRef}\n className={cn('product-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}\n >\n {/* ARIA Live Region */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {isDrawing && 'Drawing in progress...'}\n {winningPrize && !isDrawing && `Prize won: ${winningPrize.name}`}\n </div>\n\n {/* Main Content \u2014 Responsive Grid */}\n <Grid className={cn('product-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* Left: Media Draw Area */}\n <GridItem\n span={hasRightPanel ? 7 : 12}\n className={cn(\n 'media-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'size-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10',\n 'flex flex-col'\n )}\n >\n {/* Top bar: chances + rules/rewards links */}\n <div className=\"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3\">\n <div>\n <p className=\"text-info-primary font-[700]\">\n {resolvedOpportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {resolvedOpportunitiesText?.[1] || ''}\n </p>\n </div>\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n setShowRulesModal(true)\n }}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${rulesText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {rewardsData && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n setShowRewardsModal(true)\n }}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${myRewardsText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n {shouldShowActionButton && (\n <a\n href={trackUrlRef(\n actionButtonConfig?.url ?? '',\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (actionButtonConfig?.url) {\n window.location.href = trackUrlRef(\n actionButtonConfig.url,\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )\n }\n }}\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${actionButtonConfig?.text}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{actionButtonConfig?.text}</span>\n </a>\n )}\n </div>\n </div>\n\n {/* Media Draw Area */}\n <MediaDrawArea\n className=\"min-h-0 w-full flex-1\"\n theme={theme}\n media={media}\n ctaButton={ctaButton}\n videoAutoPlay={videoAutoPlay}\n videoMuted={videoMuted}\n videoLoop={videoLoop}\n isDrawing={isDrawing}\n isDisabled={showNoChancesOverlay}\n onClick={handleDrawClick}\n ctaTrackTypeName={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n ctaTrackTitleDescButton={`${LOTTERY_COMPONENT_TITLE}##${ctaButton?.text ?? ''}`}\n />\n\n {showNoChancesOverlay && (\n <div\n className={cn(\n 'rounded-box absolute inset-0 z-20 flex items-center justify-center bg-black/60 backdrop-blur-sm',\n 'px-6 text-center'\n )}\n >\n <div className=\"flex flex-col items-center gap-4\">\n <p className=\"lg-desktop:text-[24px] text-[18px] font-semibold text-white\">{resolvedNoChances}</p>\n </div>\n </div>\n )}\n </div>\n </GridItem>\n\n {/* Right: Chance Methods */}\n {hasRightPanel && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={{\n ...resolvedInputConfig,\n submitTrackTypeName: `${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`,\n submitTrackTitleDescButton: `${LOTTERY_COMPONENT_TITLE}##${resolvedInputConfig?.submitText ?? 'Spin and Win'}`,\n }}\n isAgreementChecked={isAgreementChecked}\n onAgreementCheckedChange={checked => {\n setIsAgreementChecked(checked)\n if (checked) {\n setErrorMessage('')\n }\n }}\n agreementErrorText={errorMessage}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* Footer: Prize Pool */}\n <div\n className={cn(\n 'product-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winnerTickerData}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* Winner Modal */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={winningPrize}\n title={externalWinnerConfig?.title || resolvedWinnerConfig.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || resolvedWinnerConfig.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || resolvedWinnerConfig.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || resolvedWinnerConfig.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n winningPrize?.winnerModalConfig?.winnerNote ??\n resolvedWinnerConfig.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n winningPrize?.winnerModalConfig?.learnMoreUrl ||\n resolvedWinnerConfig.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n winningPrize?.winnerModalConfig?.learnMoreText ||\n resolvedWinnerConfig.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || resolvedWinnerConfig.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || resolvedWinnerConfig.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || resolvedWinnerConfig.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || resolvedWinnerConfig.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n winningPrize?.winnerModalConfig?.confirmText ||\n resolvedWinnerConfig.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n winningPrize?.winnerModalConfig?.confirmUrl ||\n resolvedWinnerConfig.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || resolvedWinnerConfig.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || resolvedWinnerConfig.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules Modal */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards Modal */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* Error Modal */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || resolvedErrorConfig?.title}\n message={errorMessage || resolvedErrorConfig?.message}\n confirmText={errorConfirmText || resolvedErrorConfig?.confirmText}\n exchangeFailedTitle={resolvedErrorConfig?.exchangeFailedTitle}\n exchangeFailedMessage={resolvedErrorConfig?.exchangeFailedMessage}\n theme={theme}\n />\n\n {/* No-Win Modal */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={resolvedTryAgainTitle}\n message={resolvedTryAgainMessage}\n confirmText={resolvedTryAgainConfirmText}\n theme={theme}\n />\n\n {/* Share Modal */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\nProductLottery.displayName = 'ProductLottery'\n\nexport default withLayout(ProductLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n ProductLotteryProps,\n ProductLotteryHandle,\n MediaConfig,\n CtaButtonConfig,\n MediaDrawAreaProps,\n} from './types.js'\nexport type {\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from '../LotteryShared/types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
-
"mappings": "aAgZQ,OAuCY,OAAAA,EAvCZ,QAAAC,MAAA,oBA9YR,OAAS,YAAAC,EAAU,eAAAC,EAAa,uBAAAC,GAAqB,cAAAC,GAAY,aAAAC,EAAW,UAAAC,OAAc,QAC1F,OAAS,MAAAC,MAAU,yBACnB,OAAS,wBAAAC,OAA4B,aACrC,OAAS,0BAAAC,OAA8B,4BACvC,OAAS,QAAAC,GAAM,YAAAC,OAAgB,2BAC/B,OAAS,iBAAAC,OAAqB,qBAC9B,OAAS,aAAAC,OAAiB,gCAC1B,OAAS,iBAAAC,OAAqB,oCAC9B,OAAS,eAAAC,OAAmB,kCAC5B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,kBAAAC,OAAsB,qCAC/B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,cAAAC,OAAkB,yBAC3B,OAAS,WAAAC,MAAe,wBACxB,OAAS,kBAAAC,OAAsB,2BAC/B,OAAS,eAAAC,OAAmB,6BAC5B,OAAS,eAAAC,GAAa,oBAAAC,OAAwB,8BAK9C,MAAMC,GAAyB,QACzBC,EAAyB,iBACzBC,EAA0B,2BAC1BC,EAAqB,OACrBC,EAA+B,cAC/BC,EAA+B,QAExBC,GAAiB5B,GAC5B,CACE,CACE,OAAA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E7B,IAAO6H,GAAQzI,GAAWY,EAAc,EACxC,OAAS,eAAAjB,OAAmB,kCAC5B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,kBAAAC,OAAsB,qCAC/B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,aAAA2I,OAAiB",
|
|
6
|
-
"names": ["jsx", "jsxs", "useState", "useCallback", "useImperativeHandle", "forwardRef", "useEffect", "useRef", "cn", "DEFAULT_CHANCE_TITLE", "DEFAULT_CHANCE_METHODS", "Grid", "GridItem", "MediaDrawArea", "PrizePool", "ChanceMethods", "WinnerModal", "RulesModal", "MyRewardsModal", "ErrorModal", "ShareModal", "withLayout", "gaTrack", "useAiuiContext", "useExposure", "trackUrlRef", "buildTrackingRef", "LOTTERY_COMPONENT_TYPE", "LOTTERY_COMPONENT_NAME", "LOTTERY_COMPONENT_TITLE", "LOTTERY_CLICK_TYPE", "LOTTERY_MODAL_COMPONENT_NAME", "LOTTERY_MODAL_COMPONENT_TYPE", "ProductLottery", "prizes", "media", "theme", "ctaButton", "videoAutoPlay", "videoMuted", "videoLoop", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "inputPlaceholder", "inputSubmitText", "inputType", "inputValidationErrorText", "winnerTickerData", "winningInfos", "winnerNameTemplate", "prizesTitle", "onDrawStart", "onDrawEnd", "onDrawError", "winnerModalConfig", "rulesModalConfig", "actionButtonConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "error", "tryAgain", "userData", "loginPrompt", "loginPromptText", "loginButtonText", "
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport { useState, useCallback, useImperativeHandle, forwardRef, useEffect, useRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_CHANCE_TITLE } from './types.js'\nimport { DEFAULT_CHANCE_METHODS } from '../LotteryShared/types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { MediaDrawArea } from './MediaDrawArea.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\nimport { gaTrack } from '../../shared/track.js'\nimport { useAiuiContext } from '../AiuiProvider/index.js'\nimport { useExposure } from '../../hooks/useExposure.js'\nimport { trackUrlRef, buildTrackingRef } from '../../shared/trackUrlRef.js'\n\nimport type { ProductLotteryProps, ProductLotteryHandle } from './types.js'\nimport type { Prize, WinnerModalConfig, ChanceInputConfig } from '../LotteryShared/types.js'\n\nconst LOTTERY_COMPONENT_TYPE = 'image'\nconst LOTTERY_COMPONENT_NAME = 'lottery_banner'\nconst LOTTERY_COMPONENT_TITLE = '\u4EA7\u54C1\u62BD\u5956'\nconst LOTTERY_CLICK_TYPE = 'copy'\nconst LOTTERY_MODAL_COMPONENT_NAME = 'lottery_pop'\nconst LOTTERY_MODAL_COMPONENT_TYPE = 'image'\n\nexport const ProductLottery = forwardRef<ProductLotteryHandle, ProductLotteryProps>(\n (\n {\n prizes,\n media,\n theme,\n ctaButton,\n videoAutoPlay,\n videoMuted,\n videoLoop,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_CHANCE_TITLE,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n inputPlaceholder,\n inputSubmitText,\n inputType,\n inputValidationErrorText,\n winnerTickerData = [],\n winningInfos,\n winnerNameTemplate,\n prizesTitle,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n winnerModalConfig,\n rulesModalConfig = {},\n actionButtonConfig,\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n error,\n tryAgain,\n userData,\n loginPrompt,\n loginPromptText = 'Please log in to participate',\n loginButtonText = 'Log In',\n onLoginRequired,\n onCopyCode,\n opportunitiesPrefix,\n opportunitiesText = ['Number of draws remaining today:'],\n dealsType,\n className,\n },\n ref\n ) => {\n // \u2500\u2500 CMS field normalization \u2500\u2500\n // CMS-primary strategy: CMS fields take precedence over legacy backward-compat fields.\n // If a CMS field is provided, it overrides the corresponding legacy field.\n const resolvedLoginPrompt = loginPrompt ?? loginPromptText ?? 'Please log in to participate'\n const resolvedOpportunitiesText: string[] = opportunitiesPrefix\n ? [opportunitiesPrefix]\n : (opportunitiesText ?? ['Number of draws remaining today:'])\n const resolvedInputConfig: ChanceInputConfig | undefined =\n inputPlaceholder || inputSubmitText || inputType || inputValidationErrorText\n ? {\n ...(inputConfig ?? {}),\n placeholder: inputPlaceholder ?? inputConfig?.placeholder ?? 'Enter your order number',\n submitText: inputSubmitText ?? inputConfig?.submitText ?? 'Spin and Win',\n inputType: inputType ?? inputConfig?.inputType ?? 'text',\n validationErrorText: inputValidationErrorText ?? inputConfig?.validationErrorText,\n }\n : inputConfig\n const resolvedErrorConfig = error\n ? {\n title: error.title ?? errorModalConfig?.title,\n message: error.defaultMessage ?? errorModalConfig?.message,\n confirmText: error.confirmButton ?? errorModalConfig?.confirmText,\n exchangeFailedTitle: error.exchangeFailedTitle,\n exchangeFailedMessage: error.exchangeFailedMessage,\n }\n : errorModalConfig\n const resolvedWinnerConfig: WinnerModalConfig = {\n ...winningInfos,\n ...winnerModalConfig,\n confirmText: winnerModalConfig?.confirmText ?? winningInfos?.confirmButton,\n }\n\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const shouldShowActionButton = Boolean(actionButtonConfig?.text && actionButtonConfig?.url)\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances ?? 0\n const hasRightPanel = chanceMethods.length > 0 || mechanismType === 'input'\n const hasAgreementNotice = mechanismType === 'input' && Boolean(inputConfig?.agreementNotice)\n\n // State\n const [isDrawing, setIsDrawing] = useState(false)\n const [winningPrize, setWinningPrize] = useState<Prize | null>(null)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const [isAgreementChecked, setIsAgreementChecked] = useState(false)\n\n // Exposure tracking\n const containerRef = useRef<HTMLDivElement>(null)\n useExposure(containerRef, {\n componentType: LOTTERY_COMPONENT_TYPE,\n componentName: LOTTERY_COMPONENT_NAME,\n componentTitle: LOTTERY_COMPONENT_TITLE,\n })\n\n // Tracking\n const { trackingData, pageHandle } = useAiuiContext()\n\n // Modal impression tracking \u2014 fires once per open\n useEffect(() => {\n if (!showWinnerModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Winner',\n },\n })\n }, [showWinnerModal, trackingData])\n\n useEffect(() => {\n if (!showNoWinModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Better Luck Next Time',\n },\n })\n }, [showNoWinModal, trackingData])\n\n useEffect(() => {\n if (!showRulesModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Rules',\n },\n })\n }, [showRulesModal, trackingData])\n\n useEffect(() => {\n if (!showRewardsModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'My Rewards',\n },\n })\n }, [showRewardsModal, trackingData])\n\n useEffect(() => {\n if (!showShareModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Share',\n },\n })\n }, [showShareModal, trackingData])\n\n useEffect(() => {\n if (!showErrorModal) return\n gaTrack({\n event: 'ga4Event',\n event_name: 'component_impression',\n event_parameters: {\n page_group: trackingData?.pageGroup || 'Home Page',\n component_type: LOTTERY_MODAL_COMPONENT_TYPE,\n component_name: LOTTERY_MODAL_COMPONENT_NAME,\n component_title: 'Error',\n },\n })\n }, [showErrorModal, trackingData])\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWinningPrize(prize)\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n const handleDrawStart = useCallback(async () => {\n if (isDrawing) return\n\n if (hasAgreementNotice && !isAgreementChecked) {\n setErrorMessage(inputConfig?.agreementWarningText || 'Please agree to the terms before continuing')\n setShowErrorModal(false)\n return\n }\n\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n if (userData.availableChances <= 0) {\n return\n }\n\n setIsDrawing(true)\n\n try {\n let prizeId: string | undefined\n\n if (onDrawStart) {\n prizeId = await onDrawStart()\n }\n\n const prize = prizes.find(p => p.prizeKey === prizeId) || prizes[0]\n setWinningPrize(prize)\n setIsDrawing(false)\n\n if (onDrawEnd) {\n onDrawEnd(prize)\n } else {\n setTimeout(() => {\n if (prize.prizeKey === 'try-again') {\n setShowNoWinModal(true)\n } else {\n setShowWinnerModal(true)\n }\n }, 300)\n }\n } catch (error) {\n setIsDrawing(false)\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n onDrawError?.(error as Error)\n }\n }, [\n hasAgreementNotice,\n inputConfig?.agreementWarningText,\n isAgreementChecked,\n isDrawing,\n prizes,\n onDrawStart,\n onDrawEnd,\n onDrawError,\n userData,\n onLoginRequired,\n ])\n\n const handleDrawClick = useCallback(() => {\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n void handleDrawStart()\n }, [handleDrawStart, isLoggedIn, onLoginRequired])\n\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n }, [])\n\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n }, [])\n\n // \u2500\u2500 TryAgain / no-win modal normalization \u2500\u2500\n const resolvedTryAgainTitle = noWinTitle || tryAgain?.title\n const resolvedTryAgainMessage = noWinMessage || tryAgain?.message\n const resolvedTryAgainConfirmText = noWinConfirmText || tryAgain?.confirmText\n\n return (\n <div\n ref={containerRef}\n className={cn('product-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}\n >\n {/* ARIA Live Region */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {isDrawing && 'Drawing in progress...'}\n {winningPrize && !isDrawing && `Prize won: ${winningPrize.name}`}\n </div>\n\n {/* Main Content \u2014 Responsive Grid */}\n <Grid className={cn('product-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* Left: Media Draw Area */}\n <GridItem\n span={hasRightPanel ? 7 : 12}\n className={cn(\n 'media-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'size-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10',\n 'flex flex-col'\n )}\n >\n {/* Top bar: chances + rules/rewards links */}\n <div className=\"relative z-30 mb-2 flex max-h-[24px] w-full flex-wrap items-center justify-between gap-3\">\n <div>\n <p className=\"text-info-primary font-[700]\">\n {resolvedOpportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {resolvedOpportunitiesText?.[1] || ''}\n </p>\n </div>\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n setShowRulesModal(true)\n }}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${rulesText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {rewardsData && (\n <button\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (!isLoggedIn) {\n onLoginRequired?.()\n return\n }\n setShowRewardsModal(true)\n }}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${myRewardsText}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n {shouldShowActionButton && (\n <a\n href={trackUrlRef(\n actionButtonConfig?.url ?? '',\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n onClick={e => {\n e.preventDefault()\n e.stopPropagation()\n if (actionButtonConfig?.url) {\n window.location.href = trackUrlRef(\n actionButtonConfig.url,\n buildTrackingRef(pageHandle ?? '', LOTTERY_CLICK_TYPE, LOTTERY_COMPONENT_NAME)\n )\n }\n }}\n data-headless-type-name={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n data-headless-title-desc-button={`${LOTTERY_COMPONENT_TITLE}##${actionButtonConfig?.text}`}\n >\n <span className=\"text-info-primary font-[700] underline\">{actionButtonConfig?.text}</span>\n </a>\n )}\n </div>\n </div>\n\n {/* Media Draw Area */}\n <MediaDrawArea\n className=\"min-h-0 w-full flex-1\"\n theme={theme}\n media={media}\n ctaButton={ctaButton}\n videoAutoPlay={videoAutoPlay}\n videoMuted={videoMuted}\n videoLoop={videoLoop}\n isDrawing={isDrawing}\n onClick={handleDrawClick}\n ctaTrackTypeName={`${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`}\n ctaTrackTitleDescButton={`${LOTTERY_COMPONENT_TITLE}##${ctaButton?.text ?? ''}`}\n />\n </div>\n </GridItem>\n\n {/* Right: Chance Methods */}\n {hasRightPanel && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={{\n ...resolvedInputConfig,\n submitTrackTypeName: `${LOTTERY_CLICK_TYPE}#${LOTTERY_COMPONENT_NAME}`,\n submitTrackTitleDescButton: `${LOTTERY_COMPONENT_TITLE}##${resolvedInputConfig?.submitText ?? 'Spin and Win'}`,\n }}\n isAgreementChecked={isAgreementChecked}\n onAgreementCheckedChange={checked => {\n setIsAgreementChecked(checked)\n if (checked) {\n setErrorMessage('')\n }\n }}\n agreementErrorText={errorMessage}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* Footer: Prize Pool */}\n <div\n className={cn(\n 'product-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winnerTickerData}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* Winner Modal */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={winningPrize}\n title={externalWinnerConfig?.title || resolvedWinnerConfig.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || resolvedWinnerConfig.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || resolvedWinnerConfig.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || resolvedWinnerConfig.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n winningPrize?.winnerModalConfig?.winnerNote ??\n resolvedWinnerConfig.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n winningPrize?.winnerModalConfig?.learnMoreUrl ||\n resolvedWinnerConfig.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n winningPrize?.winnerModalConfig?.learnMoreText ||\n resolvedWinnerConfig.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || resolvedWinnerConfig.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || resolvedWinnerConfig.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || resolvedWinnerConfig.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || resolvedWinnerConfig.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n winningPrize?.winnerModalConfig?.confirmText ||\n resolvedWinnerConfig.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n winningPrize?.winnerModalConfig?.confirmUrl ||\n resolvedWinnerConfig.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || resolvedWinnerConfig.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || resolvedWinnerConfig.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules Modal */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards Modal */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* Error Modal */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || resolvedErrorConfig?.title}\n message={errorMessage || resolvedErrorConfig?.message}\n confirmText={errorConfirmText || resolvedErrorConfig?.confirmText}\n exchangeFailedTitle={resolvedErrorConfig?.exchangeFailedTitle}\n exchangeFailedMessage={resolvedErrorConfig?.exchangeFailedMessage}\n theme={theme}\n />\n\n {/* No-Win Modal */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={resolvedTryAgainTitle}\n message={resolvedTryAgainMessage}\n confirmText={resolvedTryAgainConfirmText}\n theme={theme}\n />\n\n {/* Share Modal */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\nProductLottery.displayName = 'ProductLottery'\n\nexport default withLayout(ProductLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n ProductLotteryProps,\n ProductLotteryHandle,\n MediaConfig,\n CtaButtonConfig,\n MediaDrawAreaProps,\n} from './types.js'\nexport type {\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from '../LotteryShared/types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
+
"mappings": "aA4YQ,OAuCY,OAAAA,EAvCZ,QAAAC,MAAA,oBA1YR,OAAS,YAAAC,EAAU,eAAAC,EAAa,uBAAAC,GAAqB,cAAAC,GAAY,aAAAC,EAAW,UAAAC,OAAc,QAC1F,OAAS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,GAAqB,sBAC5C,MAAO7C,EACT,EAGApC,EAACmB,GAAA,CACC,OAAQiG,EACR,QAASiC,GACT,MAAOC,GACP,QAASC,GACT,YAAaC,GACb,MAAOpH,EACT,EAGApC,EAACoB,GAAA,CACC,OAAQkG,EACR,QAAS,IAAMC,EAAkB,EAAK,EACtC,MAAOvD,GAAkB,MACzB,SAAUA,GAAkB,SAC5B,KAAMA,GAAkB,KACxB,UAAWA,GAAkB,UAC7B,eAAgBA,GAAkB,eAClC,MAAO5B,EACT,GACF,CAEJ,CACF,EAEAH,GAAe,YAAc,iBAE7B,IAAOyH,GAAQrI,GAAWY,EAAc,EACxC,OAAS,eAAAjB,OAAmB,kCAC5B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,kBAAAC,OAAsB,qCAC/B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,aAAAuI,OAAiB",
|
|
6
|
+
"names": ["jsx", "jsxs", "useState", "useCallback", "useImperativeHandle", "forwardRef", "useEffect", "useRef", "cn", "DEFAULT_CHANCE_TITLE", "DEFAULT_CHANCE_METHODS", "Grid", "GridItem", "MediaDrawArea", "PrizePool", "ChanceMethods", "WinnerModal", "RulesModal", "MyRewardsModal", "ErrorModal", "ShareModal", "withLayout", "gaTrack", "useAiuiContext", "useExposure", "trackUrlRef", "buildTrackingRef", "LOTTERY_COMPONENT_TYPE", "LOTTERY_COMPONENT_NAME", "LOTTERY_COMPONENT_TITLE", "LOTTERY_CLICK_TYPE", "LOTTERY_MODAL_COMPONENT_NAME", "LOTTERY_MODAL_COMPONENT_TYPE", "ProductLottery", "prizes", "media", "theme", "ctaButton", "videoAutoPlay", "videoMuted", "videoLoop", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "inputPlaceholder", "inputSubmitText", "inputType", "inputValidationErrorText", "winnerTickerData", "winningInfos", "winnerNameTemplate", "prizesTitle", "onDrawStart", "onDrawEnd", "onDrawError", "winnerModalConfig", "rulesModalConfig", "actionButtonConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "error", "tryAgain", "userData", "loginPrompt", "loginPromptText", "loginButtonText", "onLoginRequired", "onCopyCode", "opportunitiesPrefix", "opportunitiesText", "dealsType", "className", "ref", "resolvedLoginPrompt", "resolvedOpportunitiesText", "resolvedInputConfig", "resolvedErrorConfig", "resolvedWinnerConfig", "rulesData", "rulesText", "shouldShowActionButton", "rewardsData", "myRewardsText", "codeText", "copyText", "copiedText", "prizeText", "emptyText", "copyError", "availableText", "usedStatusText", "expiredText", "notFoundText", "completedText", "usedText", "isLoggedIn", "availableChances", "hasRightPanel", "hasAgreementNotice", "isDrawing", "setIsDrawing", "winningPrize", "setWinningPrize", "showWinnerModal", "setShowWinnerModal", "showRulesModal", "setShowRulesModal", "showRewardsModal", "setShowRewardsModal", "showErrorModal", "setShowErrorModal", "showNoWinModal", "setShowNoWinModal", "showShareModal", "setShowShareModal", "errorMessage", "setErrorMessage", "errorTitle", "setErrorTitle", "errorConfirmText", "setErrorConfirmText", "noWinTitle", "setNoWinTitle", "noWinMessage", "setNoWinMessage", "noWinConfirmText", "setNoWinConfirmText", "externalWinnerConfig", "setExternalWinnerConfig", "isAgreementChecked", "setIsAgreementChecked", "containerRef", "trackingData", "pageHandle", "message", "title", "confirmText", "config", "prize", "handleDrawStart", "prizeId", "p", "handleDrawClick", "handleCloseWinnerModal", "handleCloseNoWinModal", "resolvedTryAgainTitle", "resolvedTryAgainMessage", "resolvedTryAgainConfirmText", "checked", "ProductLottery_default", "BaseModal"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as
|
|
1
|
+
"use client";import{jsx as t,jsxs as m}from"react/jsx-runtime";import{useState as s,useCallback as N,useRef as Ze,useEffect as Y,useImperativeHandle as qe,forwardRef as et}from"react";import{cn as u}from"../../helpers/index.js";import{DEFAULT_WHEEL_CONFIG as J,DEFAULT_CHANCE_METHODS as tt,INITIAL_WHEEL_STATE as ot}from"./types.js";import{Grid as rt,GridItem as Q}from"../../components/grid.js";import{Wheel as nt}from"./Wheel.js";import{PrizePool as st}from"../LotteryShared/PrizePool.js";import{ChanceMethods as it}from"../LotteryShared/ChanceMethods.js";import{WinnerModal as at}from"../LotteryShared/WinnerModal.js";import{RulesModal as lt}from"../LotteryShared/RulesModal.js";import{MyRewardsModal as pt}from"../LotteryShared/MyRewardsModal.js";import{ErrorModal as X}from"../LotteryShared/ErrorModal.js";import{ShareModal as dt}from"../LotteryShared/ShareModal.js";import{withLayout as ct}from"../../shared/Styles.js";const Z=et(({prizes:l,theme:i,winningPrizeId:v,spinDuration:L=J.spinDuration,wheelBackgroundImage:q,pointerImage:ee,chanceMethods:A=tt,chanceTitle:te=J.chanceTitle,chanceSubtitle:oe,chanceFooterNote:re,chanceMethodsText:P,mechanismType:ne,inputConfig:se,winningInfos:ie=[],winnerNameTemplate:ae,prizesTitle:le,onSpinStart:C,onSpinEnd:R,onSpinError:D,winnerModalConfig:r,rulesModalConfig:pe={},myRewardsModalConfig:de={},errorModalConfig:f={},shareModalConfig:x={},userData:p,onLoginRequired:z,onCopyCode:ce,opportunitiesText:F=["Number of draws remaining today:"],className:me},fe)=>{const{rulesData:h,rulesText:B="Rules"}=pe,{rewardsData:I,myRewardsText:U="My Rewards",codeText:ue="CODE:",copyText:O="COPY",copiedText:j="COPIED",prizeText:xe="Prize time:",emptyText:he,copyError:we,availableText:ge,usedStatusText:ye,expiredText:Te,notFoundText:be}=de,Me=P?.completedText,Se=P?.usedText,w=p?.isLoggedIn??!1,G=p?.availableChances??0,We=w&&G<=0,[o,d]=s(ot),[Pe,g]=s(!1),[ze,y]=s(!1),[Ee,T]=s(!1),[Ne,b]=s(!1),[ve,M]=s(!1),[Ce,S]=s(!1),[Re,H]=s(""),[Ie,ke]=s(),[Le,Ae]=s(),[De,Fe]=s(),[Be,Ue]=s(),[Oe,je]=s(),[n,Ge]=s(),E=Ze(null);qe(fe,()=>({showError:({message:e,title:a,confirmText:W})=>{H(e),ke(a),Ae(W),b(!0)},hideError:()=>{b(!1)},showNoWin:e=>{Fe(e?.title),Ue(e?.message),je(e?.confirmText),M(!0)},hideNoWin:()=>{M(!1)},showWinner:(e,a)=>{d(W=>({...W,winningPrize:e})),Ge(a),g(!0)},hideWinner:()=>{g(!1)},showRules:()=>{y(!0)},hideRules:()=>{y(!1)},showRewards:()=>{T(!0)},hideRewards:()=>{T(!1)},showShare:()=>{S(!0)},hideShare:()=>{S(!1)},hideAllModals:()=>{g(!1),y(!1),T(!1),b(!1),M(!1),S(!1)}}),[]),Y(()=>{},[l,v]),Y(()=>()=>{E.current!==null&&cancelAnimationFrame(E.current)},[]);const _=N(async()=>{if(!o.isSpinning){if(!p?.isLoggedIn){z?.();return}if(!(p.availableChances<=0)){d(e=>({...e,isSpinning:!0,isButtonDisabled:!0}));try{let e=v;C&&(e=await C());const a=l.find(c=>c.prizeKey===e)||l[0],W=l.findIndex(c=>c.prizeKey===a.prizeKey),$e=360/l.length,Ve=W*$e,K=3*360+(360-Ve);await new Promise(c=>setTimeout(c,1500)),d(c=>({...c,isFinished:!0,currentRotation:0}));const Ye=Date.now(),$=()=>{const Je=Date.now()-Ye,V=Math.min(Je/L,1),Qe=1-Math.pow(1-V,3),Xe=K*Qe;d(k=>({...k,currentRotation:Xe})),V<1?E.current=requestAnimationFrame($):(d(k=>({...k,isSpinning:!1,isButtonDisabled:!0,winningPrize:a,currentRotation:K})),R?R?.(a):setTimeout(()=>{a.prizeKey==="try-again"?M(!0):g(!0)},500))};E.current=requestAnimationFrame($)}catch(e){d(a=>({...a,isSpinning:!1,isButtonDisabled:!1})),H(e.message||"An error occurred"),b(!0),D?.(e),console.error("\u62BD\u5956\u63A5\u53E3\u8C03\u7528\u5931\u8D25:",e)}}}},[o.isSpinning,l,v,L,C,R,D,p,z]),He=N(()=>{if(w){_();return}z?.()},[_,w,z]),_e=N(()=>{g(!1),d(e=>({...e,isButtonDisabled:!1,isFinished:!1}))},[]),Ke=N(()=>{M(!1),d(e=>({...e,isButtonDisabled:!1,isFinished:!1}))},[]);return m("div",{className:u("wheel-lottery-container","w-full",i==="dark"?"aiui-dark":"",me),children:[m("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:[o.isSpinning&&"\u62BD\u5956\u8FDB\u884C\u4E2D...",o.winningPrize&&!o.isSpinning&&`\u5DF2\u4E2D\u5956: ${o.winningPrize.name}`]}),m(rt,{className:u("wheel-lottery-main","tablet:mb-4 mb-3"),children:[t(Q,{span:7,className:u("wheel-section","relative flex w-full flex-1 items-center justify-center overflow-hidden","rounded-box","laptop:min-h-[288px] min-h-[240px]","lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]","desktop:aspect-w-[759] desktop:aspect-h-[384]","laptop:aspect-w-[516] laptop:aspect-h-[288]","l-tablet:col-span-12","l-tablet:mb-3",i==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:m("div",{className:u("w-full px-[16px] pt-[16px]","lg-desktop:pb-[32px] lg-desktop:px-[32px]","desktop:pt-[24px] desktop:px-[24px]","laptop:pt-[16px] laptop:px-[16px]","tablet:px-[24px]","l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10"),children:[m("div",{className:"tablet:max-h-[24px] relative z-10 mb-2 flex max-h-[40px] w-full flex-wrap items-center justify-between gap-3",children:[t("div",{children:w&&m("p",{className:"text-info-primary font-[700]",children:[F?.[0],t("span",{className:"ml-1 text-[#FF6B35]",children:G}),F?.[1]||""]})}),m("div",{className:"flex items-center gap-4",children:[h&&h.length>0&&t("button",{onClick:()=>y(!0),className:"cursor-pointer touch-manipulation",type:"button",children:t("span",{className:"text-info-primary font-[700] underline",children:B})}),p?.isLoggedIn&&I&&t("button",{onClick:()=>T(!0),className:"cursor-pointer touch-manipulation whitespace-nowrap",type:"button",children:t("span",{className:"text-info-primary font-[700] underline",children:U})})]})]}),t(nt,{theme:i,prizes:l,rotation:o.currentRotation,isSpinning:o.isSpinning,isFinished:o.isFinished,isButtonDisabled:o.isButtonDisabled||!w||We,userData:p,onGoClick:He,wheelBackgroundImage:q,pointerImage:ee})]})}),A.length>0&&t(Q,{span:5,className:u("info-section","rounded-box","relative flex flex-col overflow-hidden","lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]","desktop:aspect-w-[536] desktop:aspect-h-[384]","laptop:aspect-w-[364] laptop:aspect-h-[288]","l-tablet:min-h-[280px] laptop:max-h-[320px]","w-full","l-tablet:col-span-12",i==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:t(it,{theme:i,userData:p,methods:A,title:te,subtitle:oe,footerNote:re,onOpenShareModal:()=>S(!0),chanceBadgeText:P?.chanceBadgeText,completedText:Me,usedText:Se,loadingText:P?.loadingText,mechanismType:ne,inputConfig:se})})]}),t("div",{className:u("wheel-lottery-footer","rounded-box","flex flex-col overflow-hidden",i==="dark"?"bg-[#1E2024]":"bg-[#EAEAEC]"),children:t(st,{theme:i,prizes:l,title:le,winningInfos:ie,winnerNameTemplate:ae})}),t(at,{isOpen:Pe,prize:o.winningPrize,title:n?.title||r?.title,prizeTitle:n?.prizeTitle||r?.prizeTitle,prizeImage:n?.prizeImage||r?.prizeImage,prizeDescription:n?.prizeDescription||r?.prizeDescription,winnerNote:n?.winnerNote??o.winningPrize?.winnerModalConfig?.winnerNote??r?.winnerNote,learnMoreUrl:n?.learnMoreUrl||o.winningPrize?.winnerModalConfig?.learnMoreUrl||r?.learnMoreUrl,learnMoreText:n?.learnMoreText||o.winningPrize?.winnerModalConfig?.learnMoreText||r?.learnMoreText,couponCode:n?.couponCode||r?.couponCode,expiresAt:n?.expiresAt||r?.expiresAt,couponDiscount:n?.couponDiscount||r?.couponDiscount,couponUnit:n?.couponUnit||r?.couponUnit,confirmText:n?.confirmText||o.winningPrize?.winnerModalConfig?.confirmText||r?.confirmText,confirmUrl:n?.confirmUrl||o.winningPrize?.winnerModalConfig?.confirmUrl||r?.confirmUrl,copyText:n?.copyText||r?.copyText||O,copiedText:n?.copiedText||r?.copiedText||j,onClose:_e,theme:i}),h&&h.length>0&&t(lt,{title:B,isOpen:ze,onClose:()=>y(!1),rules:h,theme:i}),I&&t(pt,{isOpen:Ee,onClose:()=>T(!1),rewards:I,onCopyCode:ce,codeText:ue,copyText:O,copiedText:j,prizeText:xe,emptyText:he,copyError:we,availableText:ge,usedStatusText:ye,expiredText:Te,notFoundText:be,theme:i,title:U}),t(X,{isOpen:Ne,onClose:()=>b(!1),title:Ie||f?.title,message:Re||f?.message,confirmText:Le||f?.confirmText,theme:i}),t(X,{isOpen:ve,onClose:Ke,title:De||f?.title,message:Be||f?.message,confirmText:Oe||f?.confirmText,theme:i}),t(dt,{isOpen:Ce,onClose:()=>S(!1),title:x?.title,subtitle:x?.subtitle,note:x?.note,platforms:x?.platforms,onShareSuccess:x?.onShareSuccess,theme:i})]})});Z.displayName="WheelLottery";var zt=ct(Z);import{WinnerModal as vt}from"../LotteryShared/WinnerModal.js";import{RulesModal as Rt}from"../LotteryShared/RulesModal.js";import{MyRewardsModal as kt}from"../LotteryShared/MyRewardsModal.js";import{ErrorModal as At}from"../LotteryShared/ErrorModal.js";import{ShareModal as Ft}from"../LotteryShared/ShareModal.js";import{BaseModal as Ut}from"../LotteryShared/BaseModal.js";export{Ut as BaseModal,At as ErrorModal,kt as MyRewardsModal,Rt as RulesModal,Ft as ShareModal,Z as WheelLottery,vt as WinnerModal,zt as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/biz-components/WheelLottery/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WheelLottery - \u5927\u8F6C\u76D8\u62BD\u5956\u7EC4\u4EF6\n *\n * \u7528\u4E8E\u8425\u9500\u6D3B\u52A8\u7684\u4EA4\u4E92\u5F0F\u62BD\u5956\u8F6C\u76D8\uFF0C\u652F\u6301\u591A\u54C1\u724C\u4E3B\u9898\u548C\u54CD\u5E94\u5F0F\u5E03\u5C40\u3002\n *\n * @module WheelLottery\n * @date 2025-12-17\n */\n\n'use client'\n\nimport { useState, useCallback, useRef, useEffect, useImperativeHandle, forwardRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_WHEEL_CONFIG, DEFAULT_CHANCE_METHODS, INITIAL_WHEEL_STATE } from './types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { Wheel } from './Wheel.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\n\nimport type { WheelLotteryProps, WheelState, WheelLotteryHandle, WinnerModalConfig } from './types.js'\n\n// ============================================================================\n// \u4E3B\u7EC4\u4EF6\n// ============================================================================\n\n/**\n * WheelLottery \u7EC4\u4EF6\n *\n * @example\n * ```tsx\n * // \u57FA\u7840\u4F7F\u7528\n * <WheelLottery\n * prizes={prizes}\n * winningPrizeId=\"prize-003\"\n * onSpinEnd={(prize) => alert(`You won ${prize.name}`)}\n * />\n *\n * // \u4F7F\u7528 ref \u63A7\u5236\u5F39\u7A97\n * const lotteryRef = useRef<WheelLotteryHandle>(null)\n *\n * <WheelLottery ref={lotteryRef} prizes={prizes} />\n *\n * // \u5916\u90E8\u89E6\u53D1\u5F39\u7A97\n * lotteryRef.current?.showError({\n * title: 'Error',\n * message: 'Something went wrong'\n * })\n * ```\n */\nexport const WheelLottery = forwardRef<WheelLotteryHandle, WheelLotteryProps>(\n (\n {\n prizes,\n theme,\n winningPrizeId,\n spinDuration = DEFAULT_WHEEL_CONFIG.spinDuration,\n wheelBackgroundImage,\n pointerImage,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_WHEEL_CONFIG.chanceTitle,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n winningInfos = [],\n winnerNameTemplate,\n prizesTitle,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n winnerModalConfig,\n rulesModalConfig = {},\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n userData,\n loginPromptText = 'Please log in to participate',\n loginButtonText = 'Log In',\n noChancesText = 'You have no chances left',\n onLoginRequired,\n onCopyCode,\n opportunitiesText = ['Number of draws remaining today:'],\n className,\n },\n ref\n ) => {\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances || 0\n const showLoginOverlay = false\n const isNoChancesState = isLoggedIn && availableChances <= 0\n // ==========================================================================\n // State \u7BA1\u7406\n // ==========================================================================\n\n const [wheelState, setWheelState] = useState<WheelState>(INITIAL_WHEEL_STATE)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const animationRef = useRef<number | null>(null)\n\n // ==========================================================================\n // Imperative Handle - \u66B4\u9732\u65B9\u6CD5\u7ED9\u7236\u7EC4\u4EF6\n // ==========================================================================\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWheelState(prev => ({ ...prev, winningPrize: prize }))\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n // ==========================================================================\n // Props \u9A8C\u8BC1\uFF08\u5F00\u53D1\u73AF\u5883\uFF09\n // ==========================================================================\n\n useEffect(() => {\n if (process.env.NODE_ENV === 'development' && prizes) {\n if (prizes.length !== 8) {\n console.warn(\n `WheelLottery expects exactly 8 prizes, got ${prizes.length}. The component may not render correctly.`\n )\n }\n\n if (winningPrizeId && !prizes.find(p => p.prizeKey === winningPrizeId)) {\n console.warn(`WheelLottery: winningPrizeId \"${winningPrizeId}\" not found in prizes array.`)\n }\n }\n }, [prizes, winningPrizeId])\n\n // ==========================================================================\n // \u6E05\u7406\u52A8\u753B\n // ==========================================================================\n\n useEffect(() => {\n return () => {\n // \u7EC4\u4EF6\u5378\u8F7D\u65F6\u53D6\u6D88\u52A8\u753B\u5E27\n if (animationRef.current !== null) {\n cancelAnimationFrame(animationRef.current)\n }\n }\n }, [])\n\n // ==========================================================================\n // \u62BD\u5956\u903B\u8F91\n // ==========================================================================\n\n /**\n * \u5F00\u59CB\u62BD\u5956 - \u652F\u6301\u5F02\u6B65\u63A5\u53E3\u8C03\u7528\n * \u5229\u7528\u521D\u59CB\u6162\u901F\u65CB\u8F6C\uFF0C\u70B9\u51FB\u540E\u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF0C\u63A5\u53E3\u8FD4\u56DE\u540E\u51CF\u901F\u505C\u6B62\n */\n const handleSpinStart = useCallback(async () => {\n if (wheelState.isSpinning) return\n\n // \u68C0\u67E5\u7528\u6237\u662F\u5426\u5DF2\u767B\u5F55\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n // \u2705 \u6B21\u6570\u4E3A 0 \u65F6\uFF0C\u6309\u94AE\u5DF2\u88AB\u7981\u7528\uFF0C\u8FD9\u91CC\u4E0D\u9700\u8981\u989D\u5916\u68C0\u67E5\n // \u9632\u5FA1\u6027\u7F16\u7A0B\uFF1A\u5982\u679C\u4ECD\u7136\u89E6\u53D1\uFF0C\u76F4\u63A5\u8FD4\u56DE\n if (userData.availableChances <= 0) {\n return\n }\n\n // \u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF08\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u4F1A\u81EA\u52A8\u53D8\u4E3A\u5FEB\u901F\u65CB\u8F6C\uFF09\n setWheelState(prev => ({\n ...prev,\n isSpinning: true,\n isButtonDisabled: true,\n }))\n\n try {\n // \u8C03\u7528\u5916\u90E8\u63A5\u53E3\u83B7\u53D6\u4E2D\u5956\u7ED3\u679C\n let finalWinningPrizeId = winningPrizeId\n\n if (onSpinStart) {\n // \u7B49\u5F85\u63A5\u53E3\u8FD4\u56DE\u4E2D\u5956 ID\uFF08\u63A5\u53E3\u65F6\u95F4\u4E0D\u56FA\u5B9A\uFF0C1-30s\uFF09\n // \u5728\u6B64\u671F\u95F4\uFF0C\u8F6C\u76D8\u4F1A\u4FDD\u6301\u5FEB\u901F\u65CB\u8F6C\uFF08\u7531 CSS \u52A8\u753B\u63A7\u5236\uFF09\n finalWinningPrizeId = await onSpinStart()\n }\n\n // \u786E\u5B9A\u4E2D\u5956\u5956\u54C1\n const winningPrize = prizes.find(p => p.prizeKey === finalWinningPrizeId) || prizes[0]\n const winningIndex = prizes.findIndex(p => p.prizeKey === winningPrize.prizeKey)\n\n // \u8BA1\u7B97\u76EE\u6807\u89D2\u5EA6\n const degreesPerPrize = 360 / prizes.length\n const basePrizeAngle = winningIndex * degreesPerPrize\n // \u81F3\u5C11\u65CB\u8F6C 3 \u5708\uFF081080\u5EA6\uFF09+ \u76EE\u6807\u89D2\u5EA6\n const minRotations = 3\n const targetAngle = minRotations * 360 + (360 - basePrizeAngle)\n\n // \u63A5\u53E3\u8FD4\u56DE\u540E\uFF0C\u7B49\u5F85 1.5s \u518D\u5F00\u59CB\u505C\u6B62\u52A8\u753B\n await new Promise(resolve => setTimeout(resolve, 1500))\n\n // \u7ACB\u5373\u8FDB\u5165\u51CF\u901F\u72B6\u6001\uFF0C\u505C\u6B62 CSS \u5FAA\u73AF\u52A8\u753B\n setWheelState(prev => ({\n ...prev,\n isFinished: true,\n currentRotation: 0, // \u4ECE 0 \u5EA6\u5F00\u59CB\u51CF\u901F\u52A8\u753B\n }))\n\n // \u5F00\u59CB\u505C\u6B62\u65CB\u8F6C\u52A8\u753B\n const startTime = Date.now()\n\n const animate = () => {\n const now = Date.now()\n const elapsed = now - startTime\n const progress = Math.min(elapsed / spinDuration, 1)\n\n // \u5E94\u7528 ease-out \u7F13\u52A8\u51FD\u6570\n const eased = 1 - Math.pow(1 - progress, 3)\n\n // \u8BA1\u7B97\u5F53\u524D\u65CB\u8F6C\u89D2\u5EA6\n const currentRotation = targetAngle * eased\n\n // \u66F4\u65B0\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n currentRotation,\n }))\n\n // \u7EE7\u7EED\u52A8\u753B\u6216\u7ED3\u675F\n if (progress < 1) {\n animationRef.current = requestAnimationFrame(animate)\n } else {\n // \u52A8\u753B\u7ED3\u675F - \u4FDD\u6301\u6309\u94AE\u7981\u7528\u72B6\u6001,\u76F4\u5230\u5F39\u7A97\u5173\u95ED\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: true,\n winningPrize,\n currentRotation: targetAngle,\n }))\n\n // \u5EF6\u8FDF\u663E\u793A\u5F39\u7A97\uFF08500ms\u540E\uFF09\n if (onSpinEnd) {\n onSpinEnd?.(winningPrize)\n } else {\n setTimeout(() => {\n // \u68C0\u67E5\u662F\u5426\u672A\u4E2D\u5956\uFF08try-again\uFF09\n if (winningPrize.prizeKey === 'try-again') {\n // \u672A\u4E2D\u5956\uFF0C\u663E\u793A ErrorModal\n setShowNoWinModal(true)\n } else {\n // \u4E2D\u5956\uFF0C\u663E\u793A WinnerModal\n setShowWinnerModal(true)\n }\n }, 500)\n }\n }\n }\n\n // \u542F\u52A8\u505C\u6B62\u52A8\u753B\n animationRef.current = requestAnimationFrame(animate)\n } catch (error) {\n // \u63A5\u53E3\u62A5\u9519\uFF0C\u6062\u590D\u5230\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: false,\n }))\n\n // \u663E\u793A\u9519\u8BEF\u5F39\u7A97\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n\n // \u89E6\u53D1\u9519\u8BEF\u56DE\u8C03\n onSpinError?.(error as Error)\n\n console.error('\u62BD\u5956\u63A5\u53E3\u8C03\u7528\u5931\u8D25:', error)\n }\n }, [\n wheelState.isSpinning,\n prizes,\n winningPrizeId,\n spinDuration,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n userData,\n onLoginRequired,\n ])\n\n const handleWheelGoClick = useCallback(() => {\n if (isLoggedIn) {\n void handleSpinStart()\n return\n }\n\n onLoginRequired?.()\n }, [handleSpinStart, isLoggedIn, onLoginRequired])\n\n // ==========================================================================\n // \u5F39\u7A97\u5173\u95ED\u5904\u7406\n // ==========================================================================\n\n /**\n * \u5173\u95ED\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n /**\n * \u5173\u95ED\u672A\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n // ==========================================================================\n // \u6E32\u67D3\n // ==========================================================================\n\n return (\n <div className={cn('wheel-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}>\n {/* ARIA Live Region - \u5C4F\u5E55\u9605\u8BFB\u5668\u72B6\u6001\u64AD\u62A5 */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {wheelState.isSpinning && '\u62BD\u5956\u8FDB\u884C\u4E2D...'}\n {wheelState.winningPrize && !wheelState.isSpinning && `\u5DF2\u4E2D\u5956: ${wheelState.winningPrize.name}`}\n </div>\n\n {/* \u4E3B\u5185\u5BB9\u533A - \u54CD\u5E94\u5F0F\u4E24\u680F/\u5355\u680F\u5E03\u5C40 */}\n <Grid className={cn('wheel-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* \u5DE6\u4FA7\uFF1A\u8F6C\u76D8\u533A\u57DF */}\n <GridItem\n span={7}\n className={cn(\n 'wheel-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n // \u79FB\u52A8\u7AEF\uFF08<=1024px\uFF09\u4F7F\u7528min-h\uFF0C\u684C\u9762\u7AEF\u4F7F\u7528aspect ratio\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n // \u79FB\u52A8\u7AEF\u5E95\u90E8\u95F4\u8DDD\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'w-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n // \u79FB\u52A8\u7AEF(<=1024px)\u65F6\u4F7F\u7528\u7EDD\u5BF9\u5B9A\u4F4D\u8986\u76D6\u5728\u8F6C\u76D8\u80CC\u666F\u4E0A\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10'\n )}\n >\n {/* \u9876\u90E8\u4FE1\u606F\u680F\uFF1A\u5DE6\u4FA7\u673A\u4F1A\u8FDB\u5EA6\uFF0C\u53F3\u4FA7\u94FE\u63A5 */}\n <div className=\"tablet:max-h-[24px] relative z-10 mb-2 flex max-h-[40px] w-full flex-wrap items-center justify-between gap-3\">\n {/* \u5DE6\u4FA7\uFF1A\u673A\u4F1A\u5C55\u793A - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n <div>\n {isLoggedIn && (\n <p className=\"text-info-primary font-[700]\">\n {opportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {opportunitiesText?.[1] || ''}\n </p>\n )}\n </div>\n {/* \u53F3\u4FA7\uFF1ARules \u548C My Rewards \u6309\u94AE */}\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={() => setShowRulesModal(true)}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {/* My Rewards \u6309\u94AE - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n {userData?.isLoggedIn && rewardsData && (\n <button\n onClick={() => setShowRewardsModal(true)}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n </div>\n </div>\n {/* \u8F6C\u76D8\u7EC4\u4EF6 */}\n <Wheel\n theme={theme}\n prizes={prizes}\n rotation={wheelState.currentRotation}\n isSpinning={wheelState.isSpinning}\n isFinished={wheelState.isFinished}\n isButtonDisabled={wheelState.isButtonDisabled || !isLoggedIn || isNoChancesState}\n userData={userData}\n onGoClick={handleWheelGoClick}\n wheelBackgroundImage={wheelBackgroundImage}\n pointerImage={pointerImage}\n />\n\n {showLoginOverlay && (\n <div\n className={cn(\n 'rounded-box absolute inset-0 z-20 flex items-center justify-center bg-black/60 backdrop-blur-sm',\n 'px-6 text-center'\n )}\n >\n <div className=\"flex flex-col items-center gap-4\">\n <p className=\"lg-desktop:text-[24px] text-[18px] font-semibold text-white\">{loginPromptText}</p>\n {showLoginOverlay && (\n <button\n type=\"button\"\n onClick={onLoginRequired}\n className={cn(\n 'rounded-full bg-white px-6 py-2 text-[14px] font-semibold text-[#1D1D1F]',\n 'transition-transform hover:scale-105 active:scale-95'\n )}\n >\n {loginButtonText}\n </button>\n )}\n </div>\n </div>\n )}\n </div>\n </GridItem>\n\n {/* \u53F3\u4FA7\uFF1A\u83B7\u53D6\u673A\u4F1A\u533A\u57DF */}\n {chanceMethods.length > 0 && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n // \u79FB\u52A8\u7AEF\u4F7F\u7528min-h\u800C\u4E0D\u662Fmax-h\uFF0C\u786E\u4FDD\u5185\u5BB9\u5B8C\u6574\u663E\u793A\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={inputConfig}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* \u5E95\u90E8\u533A\u57DF\uFF1A\u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355) */}\n <div\n className={cn(\n 'wheel-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n {/* \u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355\u81EA\u52A8\u6EDA\u52A8) */}\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winningInfos}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* \u4E2D\u5956\u5F39\u7A97 */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={wheelState.winningPrize}\n title={externalWinnerConfig?.title || winnerModalConfig?.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || winnerModalConfig?.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || winnerModalConfig?.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || winnerModalConfig?.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n wheelState.winningPrize?.winnerModalConfig?.winnerNote ??\n winnerModalConfig?.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreUrl ||\n winnerModalConfig?.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreText ||\n winnerModalConfig?.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || winnerModalConfig?.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || winnerModalConfig?.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || winnerModalConfig?.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || winnerModalConfig?.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n wheelState.winningPrize?.winnerModalConfig?.confirmText ||\n winnerModalConfig?.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n wheelState.winningPrize?.winnerModalConfig?.confirmUrl ||\n winnerModalConfig?.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || winnerModalConfig?.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || winnerModalConfig?.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules \u5F39\u7A97 */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards \u5F39\u7A97 */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* \u9519\u8BEF\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || errorModalConfig?.title}\n message={errorMessage || errorModalConfig?.message}\n confirmText={errorConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u672A\u4E2D\u5956\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={noWinTitle || errorModalConfig?.title}\n message={noWinMessage || errorModalConfig?.message}\n confirmText={noWinConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u5206\u4EAB\u5F39\u7A97 */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\n// \u8BBE\u7F6E displayName \u7528\u4E8E\u8C03\u8BD5\nWheelLottery.displayName = 'WheelLottery'\n\n// ============================================================================\n// \u5BFC\u51FA\n// ============================================================================\n\nexport default withLayout(WheelLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n WheelLotteryProps,\n WheelLotteryHandle,\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n WheelProps,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from './types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "useState", "useCallback", "useRef", "useEffect", "useImperativeHandle", "forwardRef", "cn", "DEFAULT_WHEEL_CONFIG", "DEFAULT_CHANCE_METHODS", "INITIAL_WHEEL_STATE", "Grid", "GridItem", "Wheel", "PrizePool", "ChanceMethods", "WinnerModal", "RulesModal", "MyRewardsModal", "ErrorModal", "ShareModal", "withLayout", "WheelLottery", "prizes", "theme", "winningPrizeId", "spinDuration", "wheelBackgroundImage", "pointerImage", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "winningInfos", "winnerNameTemplate", "prizesTitle", "onSpinStart", "onSpinEnd", "onSpinError", "winnerModalConfig", "rulesModalConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "userData", "
|
|
4
|
+
"sourcesContent": ["/**\n * WheelLottery - \u5927\u8F6C\u76D8\u62BD\u5956\u7EC4\u4EF6\n *\n * \u7528\u4E8E\u8425\u9500\u6D3B\u52A8\u7684\u4EA4\u4E92\u5F0F\u62BD\u5956\u8F6C\u76D8\uFF0C\u652F\u6301\u591A\u54C1\u724C\u4E3B\u9898\u548C\u54CD\u5E94\u5F0F\u5E03\u5C40\u3002\n *\n * @module WheelLottery\n * @date 2025-12-17\n */\n\n'use client'\n\nimport { useState, useCallback, useRef, useEffect, useImperativeHandle, forwardRef } from 'react'\nimport { cn } from '../../helpers/index.js'\nimport { DEFAULT_WHEEL_CONFIG, DEFAULT_CHANCE_METHODS, INITIAL_WHEEL_STATE } from './types.js'\nimport { Grid, GridItem } from '../../components/grid.js'\nimport { Wheel } from './Wheel.js'\nimport { PrizePool } from '../LotteryShared/PrizePool.js'\nimport { ChanceMethods } from '../LotteryShared/ChanceMethods.js'\nimport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nimport { RulesModal } from '../LotteryShared/RulesModal.js'\nimport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nimport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nimport { ShareModal } from '../LotteryShared/ShareModal.js'\nimport { withLayout } from '../../shared/Styles.js'\n\nimport type { WheelLotteryProps, WheelState, WheelLotteryHandle, WinnerModalConfig } from './types.js'\n\n// ============================================================================\n// \u4E3B\u7EC4\u4EF6\n// ============================================================================\n\n/**\n * WheelLottery \u7EC4\u4EF6\n *\n * @example\n * ```tsx\n * // \u57FA\u7840\u4F7F\u7528\n * <WheelLottery\n * prizes={prizes}\n * winningPrizeId=\"prize-003\"\n * onSpinEnd={(prize) => alert(`You won ${prize.name}`)}\n * />\n *\n * // \u4F7F\u7528 ref \u63A7\u5236\u5F39\u7A97\n * const lotteryRef = useRef<WheelLotteryHandle>(null)\n *\n * <WheelLottery ref={lotteryRef} prizes={prizes} />\n *\n * // \u5916\u90E8\u89E6\u53D1\u5F39\u7A97\n * lotteryRef.current?.showError({\n * title: 'Error',\n * message: 'Something went wrong'\n * })\n * ```\n */\nexport const WheelLottery = forwardRef<WheelLotteryHandle, WheelLotteryProps>(\n (\n {\n prizes,\n theme,\n winningPrizeId,\n spinDuration = DEFAULT_WHEEL_CONFIG.spinDuration,\n wheelBackgroundImage,\n pointerImage,\n chanceMethods = DEFAULT_CHANCE_METHODS,\n chanceTitle = DEFAULT_WHEEL_CONFIG.chanceTitle,\n chanceSubtitle,\n chanceFooterNote,\n chanceMethodsText,\n mechanismType,\n inputConfig,\n winningInfos = [],\n winnerNameTemplate,\n prizesTitle,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n winnerModalConfig,\n rulesModalConfig = {},\n myRewardsModalConfig = {},\n errorModalConfig = {},\n shareModalConfig = {},\n userData,\n onLoginRequired,\n onCopyCode,\n opportunitiesText = ['Number of draws remaining today:'],\n className,\n },\n ref\n ) => {\n const { rulesData, rulesText = 'Rules' } = rulesModalConfig\n const {\n rewardsData,\n myRewardsText = 'My Rewards',\n codeText = 'CODE:',\n copyText = 'COPY',\n copiedText = 'COPIED',\n prizeText = 'Prize time:',\n emptyText,\n copyError,\n availableText,\n usedStatusText,\n expiredText,\n notFoundText,\n } = myRewardsModalConfig\n const completedText = chanceMethodsText?.completedText\n const usedText = chanceMethodsText?.usedText\n const isLoggedIn = userData?.isLoggedIn ?? false\n const availableChances = userData?.availableChances ?? 0\n const isNoChancesState = isLoggedIn && availableChances <= 0\n // ==========================================================================\n // State \u7BA1\u7406\n // ==========================================================================\n\n const [wheelState, setWheelState] = useState<WheelState>(INITIAL_WHEEL_STATE)\n const [showWinnerModal, setShowWinnerModal] = useState(false)\n const [showRulesModal, setShowRulesModal] = useState(false)\n const [showRewardsModal, setShowRewardsModal] = useState(false)\n const [showErrorModal, setShowErrorModal] = useState(false)\n const [showNoWinModal, setShowNoWinModal] = useState(false)\n const [showShareModal, setShowShareModal] = useState(false)\n const [errorMessage, setErrorMessage] = useState('')\n const [errorTitle, setErrorTitle] = useState<string | undefined>()\n const [errorConfirmText, setErrorConfirmText] = useState<string | undefined>()\n const [noWinTitle, setNoWinTitle] = useState<string | undefined>()\n const [noWinMessage, setNoWinMessage] = useState<string | undefined>()\n const [noWinConfirmText, setNoWinConfirmText] = useState<string | undefined>()\n const [externalWinnerConfig, setExternalWinnerConfig] = useState<Partial<WinnerModalConfig> | undefined>()\n const animationRef = useRef<number | null>(null)\n\n // ==========================================================================\n // Imperative Handle - \u66B4\u9732\u65B9\u6CD5\u7ED9\u7236\u7EC4\u4EF6\n // ==========================================================================\n\n useImperativeHandle(\n ref,\n () => ({\n showError: ({ message, title, confirmText }) => {\n setErrorMessage(message)\n setErrorTitle(title)\n setErrorConfirmText(confirmText)\n setShowErrorModal(true)\n },\n hideError: () => {\n setShowErrorModal(false)\n },\n showNoWin: config => {\n setNoWinTitle(config?.title)\n setNoWinMessage(config?.message)\n setNoWinConfirmText(config?.confirmText)\n setShowNoWinModal(true)\n },\n hideNoWin: () => {\n setShowNoWinModal(false)\n },\n showWinner: (prize, config) => {\n setWheelState(prev => ({ ...prev, winningPrize: prize }))\n setExternalWinnerConfig(config)\n setShowWinnerModal(true)\n },\n hideWinner: () => {\n setShowWinnerModal(false)\n },\n showRules: () => {\n setShowRulesModal(true)\n },\n hideRules: () => {\n setShowRulesModal(false)\n },\n showRewards: () => {\n setShowRewardsModal(true)\n },\n hideRewards: () => {\n setShowRewardsModal(false)\n },\n showShare: () => {\n setShowShareModal(true)\n },\n hideShare: () => {\n setShowShareModal(false)\n },\n hideAllModals: () => {\n setShowWinnerModal(false)\n setShowRulesModal(false)\n setShowRewardsModal(false)\n setShowErrorModal(false)\n setShowNoWinModal(false)\n setShowShareModal(false)\n },\n }),\n []\n )\n\n // ==========================================================================\n // Props \u9A8C\u8BC1\uFF08\u5F00\u53D1\u73AF\u5883\uFF09\n // ==========================================================================\n\n useEffect(() => {\n if (process.env.NODE_ENV === 'development' && prizes) {\n if (prizes.length !== 8) {\n console.warn(\n `WheelLottery expects exactly 8 prizes, got ${prizes.length}. The component may not render correctly.`\n )\n }\n\n if (winningPrizeId && !prizes.find(p => p.prizeKey === winningPrizeId)) {\n console.warn(`WheelLottery: winningPrizeId \"${winningPrizeId}\" not found in prizes array.`)\n }\n }\n }, [prizes, winningPrizeId])\n\n // ==========================================================================\n // \u6E05\u7406\u52A8\u753B\n // ==========================================================================\n\n useEffect(() => {\n return () => {\n // \u7EC4\u4EF6\u5378\u8F7D\u65F6\u53D6\u6D88\u52A8\u753B\u5E27\n if (animationRef.current !== null) {\n cancelAnimationFrame(animationRef.current)\n }\n }\n }, [])\n\n // ==========================================================================\n // \u62BD\u5956\u903B\u8F91\n // ==========================================================================\n\n /**\n * \u5F00\u59CB\u62BD\u5956 - \u652F\u6301\u5F02\u6B65\u63A5\u53E3\u8C03\u7528\n * \u5229\u7528\u521D\u59CB\u6162\u901F\u65CB\u8F6C\uFF0C\u70B9\u51FB\u540E\u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF0C\u63A5\u53E3\u8FD4\u56DE\u540E\u51CF\u901F\u505C\u6B62\n */\n const handleSpinStart = useCallback(async () => {\n if (wheelState.isSpinning) return\n\n // \u68C0\u67E5\u7528\u6237\u662F\u5426\u5DF2\u767B\u5F55\n if (!userData?.isLoggedIn) {\n onLoginRequired?.()\n return\n }\n\n // \u2705 \u6B21\u6570\u4E3A 0 \u65F6\uFF0C\u6309\u94AE\u5DF2\u88AB\u7981\u7528\uFF0C\u8FD9\u91CC\u4E0D\u9700\u8981\u989D\u5916\u68C0\u67E5\n // \u9632\u5FA1\u6027\u7F16\u7A0B\uFF1A\u5982\u679C\u4ECD\u7136\u89E6\u53D1\uFF0C\u76F4\u63A5\u8FD4\u56DE\n if (userData.availableChances <= 0) {\n return\n }\n\n // \u8FDB\u5165\u5FEB\u901F\u65CB\u8F6C\u72B6\u6001\uFF08\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u4F1A\u81EA\u52A8\u53D8\u4E3A\u5FEB\u901F\u65CB\u8F6C\uFF09\n setWheelState(prev => ({\n ...prev,\n isSpinning: true,\n isButtonDisabled: true,\n }))\n\n try {\n // \u8C03\u7528\u5916\u90E8\u63A5\u53E3\u83B7\u53D6\u4E2D\u5956\u7ED3\u679C\n let finalWinningPrizeId = winningPrizeId\n\n if (onSpinStart) {\n // \u7B49\u5F85\u63A5\u53E3\u8FD4\u56DE\u4E2D\u5956 ID\uFF08\u63A5\u53E3\u65F6\u95F4\u4E0D\u56FA\u5B9A\uFF0C1-30s\uFF09\n // \u5728\u6B64\u671F\u95F4\uFF0C\u8F6C\u76D8\u4F1A\u4FDD\u6301\u5FEB\u901F\u65CB\u8F6C\uFF08\u7531 CSS \u52A8\u753B\u63A7\u5236\uFF09\n finalWinningPrizeId = await onSpinStart()\n }\n\n // \u786E\u5B9A\u4E2D\u5956\u5956\u54C1\n const winningPrize = prizes.find(p => p.prizeKey === finalWinningPrizeId) || prizes[0]\n const winningIndex = prizes.findIndex(p => p.prizeKey === winningPrize.prizeKey)\n\n // \u8BA1\u7B97\u76EE\u6807\u89D2\u5EA6\n const degreesPerPrize = 360 / prizes.length\n const basePrizeAngle = winningIndex * degreesPerPrize\n // \u81F3\u5C11\u65CB\u8F6C 3 \u5708\uFF081080\u5EA6\uFF09+ \u76EE\u6807\u89D2\u5EA6\n const minRotations = 3\n const targetAngle = minRotations * 360 + (360 - basePrizeAngle)\n\n // \u63A5\u53E3\u8FD4\u56DE\u540E\uFF0C\u7B49\u5F85 1.5s \u518D\u5F00\u59CB\u505C\u6B62\u52A8\u753B\n await new Promise(resolve => setTimeout(resolve, 1500))\n\n // \u7ACB\u5373\u8FDB\u5165\u51CF\u901F\u72B6\u6001\uFF0C\u505C\u6B62 CSS \u5FAA\u73AF\u52A8\u753B\n setWheelState(prev => ({\n ...prev,\n isFinished: true,\n currentRotation: 0, // \u4ECE 0 \u5EA6\u5F00\u59CB\u51CF\u901F\u52A8\u753B\n }))\n\n // \u5F00\u59CB\u505C\u6B62\u65CB\u8F6C\u52A8\u753B\n const startTime = Date.now()\n\n const animate = () => {\n const now = Date.now()\n const elapsed = now - startTime\n const progress = Math.min(elapsed / spinDuration, 1)\n\n // \u5E94\u7528 ease-out \u7F13\u52A8\u51FD\u6570\n const eased = 1 - Math.pow(1 - progress, 3)\n\n // \u8BA1\u7B97\u5F53\u524D\u65CB\u8F6C\u89D2\u5EA6\n const currentRotation = targetAngle * eased\n\n // \u66F4\u65B0\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n currentRotation,\n }))\n\n // \u7EE7\u7EED\u52A8\u753B\u6216\u7ED3\u675F\n if (progress < 1) {\n animationRef.current = requestAnimationFrame(animate)\n } else {\n // \u52A8\u753B\u7ED3\u675F - \u4FDD\u6301\u6309\u94AE\u7981\u7528\u72B6\u6001,\u76F4\u5230\u5F39\u7A97\u5173\u95ED\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: true,\n winningPrize,\n currentRotation: targetAngle,\n }))\n\n // \u5EF6\u8FDF\u663E\u793A\u5F39\u7A97\uFF08500ms\u540E\uFF09\n if (onSpinEnd) {\n onSpinEnd?.(winningPrize)\n } else {\n setTimeout(() => {\n // \u68C0\u67E5\u662F\u5426\u672A\u4E2D\u5956\uFF08try-again\uFF09\n if (winningPrize.prizeKey === 'try-again') {\n // \u672A\u4E2D\u5956\uFF0C\u663E\u793A ErrorModal\n setShowNoWinModal(true)\n } else {\n // \u4E2D\u5956\uFF0C\u663E\u793A WinnerModal\n setShowWinnerModal(true)\n }\n }, 500)\n }\n }\n }\n\n // \u542F\u52A8\u505C\u6B62\u52A8\u753B\n animationRef.current = requestAnimationFrame(animate)\n } catch (error) {\n // \u63A5\u53E3\u62A5\u9519\uFF0C\u6062\u590D\u5230\u521D\u59CB\u6162\u901F\u65CB\u8F6C\u72B6\u6001\n setWheelState(prev => ({\n ...prev,\n isSpinning: false,\n isButtonDisabled: false,\n }))\n\n // \u663E\u793A\u9519\u8BEF\u5F39\u7A97\n setErrorMessage((error as Error).message || 'An error occurred')\n setShowErrorModal(true)\n\n // \u89E6\u53D1\u9519\u8BEF\u56DE\u8C03\n onSpinError?.(error as Error)\n\n console.error('\u62BD\u5956\u63A5\u53E3\u8C03\u7528\u5931\u8D25:', error)\n }\n }, [\n wheelState.isSpinning,\n prizes,\n winningPrizeId,\n spinDuration,\n onSpinStart,\n onSpinEnd,\n onSpinError,\n userData,\n onLoginRequired,\n ])\n\n const handleWheelGoClick = useCallback(() => {\n if (isLoggedIn) {\n void handleSpinStart()\n return\n }\n\n onLoginRequired?.()\n }, [handleSpinStart, isLoggedIn, onLoginRequired])\n\n // ==========================================================================\n // \u5F39\u7A97\u5173\u95ED\u5904\u7406\n // ==========================================================================\n\n /**\n * \u5173\u95ED\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseWinnerModal = useCallback(() => {\n setShowWinnerModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n /**\n * \u5173\u95ED\u672A\u4E2D\u5956\u5F39\u7A97\u5E76\u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001\n */\n const handleCloseNoWinModal = useCallback(() => {\n setShowNoWinModal(false)\n // \u91CD\u7F6E\u8F6C\u76D8\u72B6\u6001,\u5141\u8BB8\u4E0B\u6B21\u62BD\u5956\n setWheelState(prev => ({\n ...prev,\n isButtonDisabled: false,\n isFinished: false, // \u91CD\u7F6E\u4E3A\u672A\u5B8C\u6210,\u6062\u590D\u521D\u59CB\u65CB\u8F6C\u52A8\u753B\n }))\n }, [])\n\n // ==========================================================================\n // \u6E32\u67D3\n // ==========================================================================\n\n return (\n <div className={cn('wheel-lottery-container', 'w-full', theme === 'dark' ? 'aiui-dark' : '', className)}>\n {/* ARIA Live Region - \u5C4F\u5E55\u9605\u8BFB\u5668\u72B6\u6001\u64AD\u62A5 */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n {wheelState.isSpinning && '\u62BD\u5956\u8FDB\u884C\u4E2D...'}\n {wheelState.winningPrize && !wheelState.isSpinning && `\u5DF2\u4E2D\u5956: ${wheelState.winningPrize.name}`}\n </div>\n\n {/* \u4E3B\u5185\u5BB9\u533A - \u54CD\u5E94\u5F0F\u4E24\u680F/\u5355\u680F\u5E03\u5C40 */}\n <Grid className={cn('wheel-lottery-main', 'tablet:mb-4 mb-3')}>\n {/* \u5DE6\u4FA7\uFF1A\u8F6C\u76D8\u533A\u57DF */}\n <GridItem\n span={7}\n className={cn(\n 'wheel-section',\n 'relative flex w-full flex-1 items-center justify-center overflow-hidden',\n 'rounded-box',\n // \u79FB\u52A8\u7AEF\uFF08<=1024px\uFF09\u4F7F\u7528min-h\uFF0C\u684C\u9762\u7AEF\u4F7F\u7528aspect ratio\n 'laptop:min-h-[288px] min-h-[240px]',\n 'lg-desktop:aspect-w-[964] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[759] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[516] laptop:aspect-h-[288]',\n 'l-tablet:col-span-12',\n // \u79FB\u52A8\u7AEF\u5E95\u90E8\u95F4\u8DDD\n 'l-tablet:mb-3',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <div\n className={cn(\n 'w-full px-[16px] pt-[16px]',\n 'lg-desktop:pb-[32px] lg-desktop:px-[32px]',\n 'desktop:pt-[24px] desktop:px-[24px]',\n 'laptop:pt-[16px] laptop:px-[16px]',\n 'tablet:px-[24px]',\n // \u79FB\u52A8\u7AEF(<=1024px)\u65F6\u4F7F\u7528\u7EDD\u5BF9\u5B9A\u4F4D\u8986\u76D6\u5728\u8F6C\u76D8\u80CC\u666F\u4E0A\n 'l-tablet:absolute l-tablet:top-0 l-tablet:inset-x-0 l-tablet:z-10'\n )}\n >\n {/* \u9876\u90E8\u4FE1\u606F\u680F\uFF1A\u5DE6\u4FA7\u673A\u4F1A\u8FDB\u5EA6\uFF0C\u53F3\u4FA7\u94FE\u63A5 */}\n <div className=\"tablet:max-h-[24px] relative z-10 mb-2 flex max-h-[40px] w-full flex-wrap items-center justify-between gap-3\">\n {/* \u5DE6\u4FA7\uFF1A\u673A\u4F1A\u5C55\u793A - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n <div>\n {isLoggedIn && (\n <p className=\"text-info-primary font-[700]\">\n {opportunitiesText?.[0]}\n <span className=\"ml-1 text-[#FF6B35]\">{availableChances}</span>\n {opportunitiesText?.[1] || ''}\n </p>\n )}\n </div>\n {/* \u53F3\u4FA7\uFF1ARules \u548C My Rewards \u6309\u94AE */}\n <div className=\"flex items-center gap-4\">\n {rulesData && rulesData.length > 0 && (\n <button\n onClick={() => setShowRulesModal(true)}\n className=\"cursor-pointer touch-manipulation\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{rulesText}</span>\n </button>\n )}\n {/* My Rewards \u6309\u94AE - \u4EC5\u767B\u5F55\u65F6\u663E\u793A */}\n {userData?.isLoggedIn && rewardsData && (\n <button\n onClick={() => setShowRewardsModal(true)}\n className=\"cursor-pointer touch-manipulation whitespace-nowrap\"\n type=\"button\"\n >\n <span className=\"text-info-primary font-[700] underline\">{myRewardsText}</span>\n </button>\n )}\n </div>\n </div>\n {/* \u8F6C\u76D8\u7EC4\u4EF6 */}\n <Wheel\n theme={theme}\n prizes={prizes}\n rotation={wheelState.currentRotation}\n isSpinning={wheelState.isSpinning}\n isFinished={wheelState.isFinished}\n isButtonDisabled={wheelState.isButtonDisabled || !isLoggedIn || isNoChancesState}\n userData={userData}\n onGoClick={handleWheelGoClick}\n wheelBackgroundImage={wheelBackgroundImage}\n pointerImage={pointerImage}\n />\n </div>\n </GridItem>\n\n {/* \u53F3\u4FA7\uFF1A\u83B7\u53D6\u673A\u4F1A\u533A\u57DF */}\n {chanceMethods.length > 0 && (\n <GridItem\n span={5}\n className={cn(\n 'info-section',\n 'rounded-box',\n 'relative flex flex-col overflow-hidden',\n 'lg-desktop:aspect-w-[684] lg-desktop:aspect-h-[480]',\n 'desktop:aspect-w-[536] desktop:aspect-h-[384]',\n 'laptop:aspect-w-[364] laptop:aspect-h-[288]',\n // \u79FB\u52A8\u7AEF\u4F7F\u7528min-h\u800C\u4E0D\u662Fmax-h\uFF0C\u786E\u4FDD\u5185\u5BB9\u5B8C\u6574\u663E\u793A\n 'l-tablet:min-h-[280px] laptop:max-h-[320px]',\n 'w-full',\n 'l-tablet:col-span-12',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n <ChanceMethods\n theme={theme}\n userData={userData}\n methods={chanceMethods}\n title={chanceTitle}\n subtitle={chanceSubtitle}\n footerNote={chanceFooterNote}\n onOpenShareModal={() => setShowShareModal(true)}\n chanceBadgeText={chanceMethodsText?.chanceBadgeText}\n completedText={completedText}\n usedText={usedText}\n loadingText={chanceMethodsText?.loadingText}\n mechanismType={mechanismType}\n inputConfig={inputConfig}\n />\n </GridItem>\n )}\n </Grid>\n\n {/* \u5E95\u90E8\u533A\u57DF\uFF1A\u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355) */}\n <div\n className={cn(\n 'wheel-lottery-footer',\n 'rounded-box',\n 'flex flex-col overflow-hidden',\n theme === 'dark' ? 'bg-[#1E2024]' : 'bg-[#EAEAEC]'\n )}\n >\n {/* \u5956\u54C1\u6C60(\u5305\u542B\u4E2D\u5956\u4EBA\u540D\u5355\u81EA\u52A8\u6EDA\u52A8) */}\n <PrizePool\n theme={theme}\n prizes={prizes}\n title={prizesTitle}\n winningInfos={winningInfos}\n winnerNameTemplate={winnerNameTemplate}\n />\n </div>\n\n {/* \u4E2D\u5956\u5F39\u7A97 */}\n <WinnerModal\n isOpen={showWinnerModal}\n prize={wheelState.winningPrize}\n title={externalWinnerConfig?.title || winnerModalConfig?.title}\n prizeTitle={externalWinnerConfig?.prizeTitle || winnerModalConfig?.prizeTitle}\n prizeImage={externalWinnerConfig?.prizeImage || winnerModalConfig?.prizeImage}\n prizeDescription={externalWinnerConfig?.prizeDescription || winnerModalConfig?.prizeDescription}\n winnerNote={\n externalWinnerConfig?.winnerNote ??\n wheelState.winningPrize?.winnerModalConfig?.winnerNote ??\n winnerModalConfig?.winnerNote\n }\n learnMoreUrl={\n externalWinnerConfig?.learnMoreUrl ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreUrl ||\n winnerModalConfig?.learnMoreUrl\n }\n learnMoreText={\n externalWinnerConfig?.learnMoreText ||\n wheelState.winningPrize?.winnerModalConfig?.learnMoreText ||\n winnerModalConfig?.learnMoreText\n }\n couponCode={externalWinnerConfig?.couponCode || winnerModalConfig?.couponCode}\n expiresAt={externalWinnerConfig?.expiresAt || winnerModalConfig?.expiresAt}\n couponDiscount={externalWinnerConfig?.couponDiscount || winnerModalConfig?.couponDiscount}\n couponUnit={externalWinnerConfig?.couponUnit || winnerModalConfig?.couponUnit}\n confirmText={\n externalWinnerConfig?.confirmText ||\n wheelState.winningPrize?.winnerModalConfig?.confirmText ||\n winnerModalConfig?.confirmText\n }\n confirmUrl={\n externalWinnerConfig?.confirmUrl ||\n wheelState.winningPrize?.winnerModalConfig?.confirmUrl ||\n winnerModalConfig?.confirmUrl\n }\n copyText={externalWinnerConfig?.copyText || winnerModalConfig?.copyText || copyText}\n copiedText={externalWinnerConfig?.copiedText || winnerModalConfig?.copiedText || copiedText}\n onClose={handleCloseWinnerModal}\n theme={theme}\n />\n\n {/* Rules \u5F39\u7A97 */}\n {rulesData && rulesData.length > 0 && (\n <RulesModal\n title={rulesText}\n isOpen={showRulesModal}\n onClose={() => setShowRulesModal(false)}\n rules={rulesData}\n theme={theme}\n />\n )}\n\n {/* My Rewards \u5F39\u7A97 */}\n {rewardsData && (\n <MyRewardsModal\n isOpen={showRewardsModal}\n onClose={() => setShowRewardsModal(false)}\n rewards={rewardsData}\n onCopyCode={onCopyCode}\n codeText={codeText}\n copyText={copyText}\n copiedText={copiedText}\n prizeText={prizeText}\n emptyText={emptyText}\n copyError={copyError}\n availableText={availableText}\n usedStatusText={usedStatusText}\n expiredText={expiredText}\n notFoundText={notFoundText}\n theme={theme}\n title={myRewardsText}\n />\n )}\n\n {/* \u9519\u8BEF\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showErrorModal}\n onClose={() => setShowErrorModal(false)}\n title={errorTitle || errorModalConfig?.title}\n message={errorMessage || errorModalConfig?.message}\n confirmText={errorConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u672A\u4E2D\u5956\u5F39\u7A97 */}\n <ErrorModal\n isOpen={showNoWinModal}\n onClose={handleCloseNoWinModal}\n title={noWinTitle || errorModalConfig?.title}\n message={noWinMessage || errorModalConfig?.message}\n confirmText={noWinConfirmText || errorModalConfig?.confirmText}\n theme={theme}\n />\n\n {/* \u5206\u4EAB\u5F39\u7A97 */}\n <ShareModal\n isOpen={showShareModal}\n onClose={() => setShowShareModal(false)}\n title={shareModalConfig?.title}\n subtitle={shareModalConfig?.subtitle}\n note={shareModalConfig?.note}\n platforms={shareModalConfig?.platforms}\n onShareSuccess={shareModalConfig?.onShareSuccess}\n theme={theme}\n />\n </div>\n )\n }\n)\n\n// \u8BBE\u7F6E displayName \u7528\u4E8E\u8C03\u8BD5\nWheelLottery.displayName = 'WheelLottery'\n\n// ============================================================================\n// \u5BFC\u51FA\n// ============================================================================\n\nexport default withLayout(WheelLottery)\nexport { WinnerModal } from '../LotteryShared/WinnerModal.js'\nexport { RulesModal } from '../LotteryShared/RulesModal.js'\nexport { MyRewardsModal } from '../LotteryShared/MyRewardsModal.js'\nexport { ErrorModal } from '../LotteryShared/ErrorModal.js'\nexport { ShareModal } from '../LotteryShared/ShareModal.js'\nexport { BaseModal } from '../LotteryShared/BaseModal.js'\nexport type {\n WheelLotteryProps,\n WheelLotteryHandle,\n Prize,\n ChanceMethod,\n ChanceMethodStatus,\n WinningInfo,\n WheelProps,\n PrizePoolProps,\n ChanceMethodsProps,\n WinnerModalProps,\n WinnerModalConfig,\n UserData,\n ShareModalConfig,\n SocialPlatform,\n SharePlatformConfig,\n} from './types.js'\nexport type { RulesModalProps, RuleItem } from '../LotteryShared/RulesModal.js'\nexport type { MyRewardsModalProps, Reward, RewardStatus } from '../LotteryShared/MyRewardsModal.js'\nexport type { ErrorModalProps } from '../LotteryShared/ErrorModal.js'\nexport type { ShareModalProps } from '../LotteryShared/ShareModal.js'\nexport type { BaseModalProps } from '../LotteryShared/BaseModal.js'\nexport type { ContainerProps } from '../../shared/Styles.js'\n"],
|
|
5
|
+
"mappings": "aA6ZQ,OA2Cc,OAAAA,EA3Cd,QAAAC,MAAA,oBAlZR,OAAS,YAAAC,EAAU,eAAAC,EAAa,UAAAC,GAAQ,aAAAC,EAAW,uBAAAC,GAAqB,cAAAC,OAAkB,QAC1F,OAAS,MAAAC,MAAU,yBACnB,OAAS,wBAAAC,EAAsB,0BAAAC,GAAwB,uBAAAC,OAA2B,aAClF,OAAS,QAAAC,GAAM,YAAAC,MAAgB,2BAC/B,OAAS,SAAAC,OAAa,aACtB,OAAS,aAAAC,OAAiB,gCAC1B,OAAS,iBAAAC,OAAqB,oCAC9B,OAAS,eAAAC,OAAmB,kCAC5B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,kBAAAC,OAAsB,qCAC/B,OAAS,cAAAC,MAAkB,iCAC3B,OAAS,cAAAC,OAAkB,iCAC3B,OAAS,cAAAC,OAAkB,yBAgCpB,MAAMC,EAAehB,GAC1B,CACE,CACE,OAA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AAAC,OAAkB,iCAC3B,OAAS,aAAA2G,OAAiB",
|
|
6
|
+
"names": ["jsx", "jsxs", "useState", "useCallback", "useRef", "useEffect", "useImperativeHandle", "forwardRef", "cn", "DEFAULT_WHEEL_CONFIG", "DEFAULT_CHANCE_METHODS", "INITIAL_WHEEL_STATE", "Grid", "GridItem", "Wheel", "PrizePool", "ChanceMethods", "WinnerModal", "RulesModal", "MyRewardsModal", "ErrorModal", "ShareModal", "withLayout", "WheelLottery", "prizes", "theme", "winningPrizeId", "spinDuration", "wheelBackgroundImage", "pointerImage", "chanceMethods", "chanceTitle", "chanceSubtitle", "chanceFooterNote", "chanceMethodsText", "mechanismType", "inputConfig", "winningInfos", "winnerNameTemplate", "prizesTitle", "onSpinStart", "onSpinEnd", "onSpinError", "winnerModalConfig", "rulesModalConfig", "myRewardsModalConfig", "errorModalConfig", "shareModalConfig", "userData", "onLoginRequired", "onCopyCode", "opportunitiesText", "className", "ref", "rulesData", "rulesText", "rewardsData", "myRewardsText", "codeText", "copyText", "copiedText", "prizeText", "emptyText", "copyError", "availableText", "usedStatusText", "expiredText", "notFoundText", "completedText", "usedText", "isLoggedIn", "availableChances", "isNoChancesState", "wheelState", "setWheelState", "showWinnerModal", "setShowWinnerModal", "showRulesModal", "setShowRulesModal", "showRewardsModal", "setShowRewardsModal", "showErrorModal", "setShowErrorModal", "showNoWinModal", "setShowNoWinModal", "showShareModal", "setShowShareModal", "errorMessage", "setErrorMessage", "errorTitle", "setErrorTitle", "errorConfirmText", "setErrorConfirmText", "noWinTitle", "setNoWinTitle", "noWinMessage", "setNoWinMessage", "noWinConfirmText", "setNoWinConfirmText", "externalWinnerConfig", "setExternalWinnerConfig", "animationRef", "message", "title", "confirmText", "config", "prize", "prev", "handleSpinStart", "finalWinningPrizeId", "winningPrize", "p", "winningIndex", "degreesPerPrize", "basePrizeAngle", "targetAngle", "resolve", "startTime", "animate", "elapsed", "progress", "eased", "currentRotation", "error", "handleWheelGoClick", "handleCloseWinnerModal", "handleCloseNoWinModal", "WheelLottery_default", "BaseModal"]
|
|
7
7
|
}
|