@gamelearn/arcade-components 3.31.2 → 3.31.3

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.
@@ -271,5 +271,5 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
271
271
  ${l.thinkful?"speech-bubble--italic":""}
272
272
  `,children:[jsxRuntimeExports.jsxs("div",{className:`speech-bubble__header ${l.thinkful?"speech-bubble__header--thinking":""}`,children:[l.thinkful?jsxRuntimeExports.jsx("div",{className:"thinking-icon-wrap",children:jsxRuntimeExports.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,l.avatar?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("img",{src:o(),alt:l.name})}):null,l.voiceOver?jsxRuntimeExports.jsx("div",{className:"speech-bubble__avatar",children:jsxRuntimeExports.jsx("div",{className:"icon-narrator"})}):null,jsxRuntimeExports.jsxs("div",{className:"speech-bubble__name",children:[jsxRuntimeExports.jsx("span",{children:l.name}),l.thinkful?jsxRuntimeExports.jsxs("span",{children:["[ ",e("emotion.thinking")," ]"]}):null]})]}),l.text?jsxRuntimeExports.jsx("div",{className:"speech-bubble__text",children:HTMLReactParser$1(l.text)}):null]})}const SpeechBubbleComponent$1=React$2.forwardRef(SpeechBubbleComponent);function BubbleWrapper({currentMessage:l,translate:e}){const n=document.querySelector(".screens--container");return jsxRuntimeExports.jsx("group",{children:jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:n?{current:n}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsx(SpeechBubbleComponent$1,{translate:e,message:l})})})}const cache={},loader=new GLTFLoader,MIX_TIME=.1;function useStateMachine(l){const e=fiber.useThree(p=>p.scene),n=React$2.useMemo(()=>{var _;const p={};for(const T of l)if(T.slots)for(const x of T.slots){if(!x.uid)continue;const S=(_=x.character)==null?void 0:_.resource.animations;S&&(p[x.uid]||(p[x.uid]=Object.keys(S).reduce((g,v)=>(g[v]=S[v].url,g),{})))}return p},[l]),t=React$2.useMemo(()=>{const p=new Set;for(const _ of l)if(_.slots)for(const T of _.slots)T.uid&&p.add(T.uid);return Array.from(p)},[l]),a=async(p,_)=>{if(p&&!cache[p]){const{animations:T}=await loader.loadAsync(p);T[0].name=_,cache[p]=T[0]}},o=async p=>{const _=n[p],T=_.talking,x=_["talking-short"];await Promise.all([a(x,"talking-short"),a(T,"talking")])},d=()=>{t.forEach(p=>{u(p,"idle")})},h=()=>{t.forEach(p=>{const _=e.getObjectByProperty("uid",p);_&&(delete _.userData._active,u(p,"idle"))})},f=async(p,_,T=!1)=>{const x=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!x)return new Promise(g=>g(!1));const S=x.userData.animator;if(_){const g=n[p],v=g["talking-short"]||g.talking;let b=cache[v],R=_,y=cache[_];if(!y){const{animations:w}=await loader.loadAsync(_);y=cache[_]=w[0]}if(T&&v!==_&&(b?(y=mixWithTalkingClip(b,y),R+="_talking"):o(p).then(()=>{b=cache[v],y=mixWithTalkingClip(b,y),R+="_talking"})),!x.userData._active||x.userData._active!==R){x.userData._active=R;const w=S.register(R,y);return new Promise(C=>{S.mix(R,MIX_TIME).then(N=>C(N?w:!1))})}}return new Promise(g=>g(!1))},u=async(p,_)=>{const T=getCurrentVisible(p,e);if(cache[p]||(cache[p]={}),!T)return new Promise(S=>S(!1));const x=T.userData.animator;if(_==="idle")return x.mix("idle",MIX_TIME),x.getAction("idle");{const S=n[p],g=_.split("_")[0],v=S[g],b=_.includes("talking");if(v){const R=`${v}_${b?"talking":"silent"}_${p}`;let y=cache[R];if(!y){let w=cache[v];if(!w){const{animations:C}=await loader.loadAsync(v);w=cache[v]=C[0]}if(b&&_!=="talking"){const C=S["talking-short"]||S.talking,N=cache[C];N?y=mixWithTalkingClip(N,w):y=w.clone()}else y=w.clone();cache[R]=y}if(!T.userData._active||T.userData._active!==_){T.userData._active=_;const w=x.register(_,y);return new Promise(C=>{x.mix(_,MIX_TIME).then(N=>C(N?w:!1))})}}}return new Promise(S=>S(!1))};return{startAnimation:u,startAnimationUrl:f,preloadTalking:o,resetActives:d,unmountActives:h}}const characterMs=75,minMs=1400,headSize=2,raycast=new three.Raycaster,animationTarget=new three.Object3D,maxCharacterToSwitch=70;raycast.firstHitOnly=!0;function DialogComponent({keyboardControl:l,emitEvent:e,getEvent:n,lines:t,actors:a,edges:o,soundActions:d,zoomInActor:h,autoPlay:f,autoEnd:u,pause:p,progress:_}){var qt;const T=t.length-1<=(_==null?void 0:_.line)?t.length-1:(_==null?void 0:_.line)||0,[x,S]=React$2.useState(T),[g,v]=React$2.useState(!!f),[b,R]=React$2.useState(!1),[y,w]=React$2.useState(!1),C=fiber.useThree(ke=>ke.scene),N=fiber.useThree(ke=>ke.camera),{start:D,stop:P}=useTimeout(),k=React$2.useRef([]),F=React$2.useMemo(()=>N.clone(),[]),M=React$2.useRef({pos:[0,0,0],child:null}),j=t[x],$=t[x-1],B=React$2.useRef(!1),X=!!o,{voiceOver:re,decision:ae}=j||{},ee=React$2.useRef({}),K=(qt=j==null?void 0:j.slots)==null?void 0:qt.find(ke=>ke.talking),ne=React$2.useRef(!1),{startAnimation:ue,startAnimationUrl:pe,resetActives:J,preloadTalking:H,unmountActives:W}=useStateMachine(t),V=React$2.useRef(),z=Object.keys((j==null?void 0:j.audio)||{}).length,Y=Object.keys((j==null?void 0:j.voice)||{}).length,ie=re||(j==null?void 0:j.type)==="conversationalNarration",le=ae||(j==null?void 0:j.type)==="conversationalDecision",fe=(j==null?void 0:j.type)==="conversationalCamera",ce=g&&!le&&!fe,[ge,Se]=React$2.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1});fiber.useFrame(()=>{var ke;(ke=mt.current)!=null&&ke.node&&(mt.current.node.weights.sil>.8?Xe():St())});const Te=React$2.useMemo(()=>t.reduce((ke,pt)=>(pt.slots&&pt.slots.filter(_e=>_e.uid).forEach(_e=>{ke.includes(_e.uid)||ke.push(_e.uid)}),ke),[]),[t]),Fe=React$2.useCallback(ke=>n({type:"translate",payload:ke}),[n]),[Ne,Qe]=React$2.useState([]),st=React$2.useMemo(()=>Ne[Ne.length-1],[Ne]),Ze=React$2.useCallback(()=>{const ke=o.find(ot=>ot.fromId===st)||o.find(ot=>ot.toId===st),pt=t.find(ot=>ot.id===(ke==null?void 0:ke.fromId));return!st&&(_==null?void 0:_.line)>=0?{decision:!0}:pt},[o,t,st]),yt=React$2.useCallback(()=>{if(X){const ke=t.filter(pt=>!o.find(ot=>ot.toId===pt.id));if(ke.length){const pt=ke[0],ot=t.indexOf(pt);if(ot>=0)return ot}}return-1},[X,t,o]),Ve=React$2.useCallback(()=>{if(X){const pt=Ze();return pt==null?void 0:pt.decision}const ke=t[x-1]?t[x-1]:{};return x>0&&(ke==null?void 0:ke.decision)},[j,X,t,st,o]),Me=React$2.useCallback(()=>{if(X){const pt=Ze();return(pt==null?void 0:pt.type)==="conversationalCamera"}const ke=t[x-1]?t[x-1]:{};return x>0&&(ke==null?void 0:ke.type)==="conversationalCamera"},[j,X,t,st,o]),Le=React$2.useCallback(ke=>{var ot,_e;const pt=a.find(te=>(te==null?void 0:te.uid)===(ke==null?void 0:ke.uid)?te:"");return((_e=(ot=ke==null?void 0:ke.character)==null?void 0:ot.resource)==null?void 0:_e.url)||(pt==null?void 0:pt.completeUrl)||""},[a]),Ke=(ke=()=>{})=>{if(ne.current)ne.current&&(ne.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const pt=M.current.child?M.current.pos:F.position.toArray();if(animationTarget.position.fromArray(pt),M.current.parent){animationTarget.quaternion.equals(N.quaternion)||animationTarget.applyQuaternion(N.quaternion);const ot=M.current.isLeft?-1:1,_e=headSize*ot;animationTarget.translateX(-10*ot+_e),animationTarget.translateY(-2),animationTarget.translateZ(30)}gsapWithCSS.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{ne.current=!0},onUpdate:()=>{k.current.length&&k.current.forEach(ot=>{const{object:_e}=ot;_e.material.visible=!0})},onComplete:()=>{ke(),raycast.set(N.getWorldPosition(new three.Vector3(0,0,0)),N.getWorldDirection(new three.Vector3));const ot=raycast.intersectObjects(C.children,!0);k.current=ot.filter(_e=>_e.distance<10),k.current.length&&k.current.forEach(_e=>{const{object:te}=_e;te.material.side=0}),ne.current=!1,B.current&&e({type:"success"}),M.current.child||N.copy(F)},...animationTarget.position})}},Oe=React$2.useCallback(()=>{M.current.child=null,M.current.parent=null,h&&Ke()},[h]),qe=(ke,pt,ot,_e=!1)=>{const te=pt.includes("seated");if(ot)pe(ke,ot.url,pt.includes("talking")).then(me=>{if(me&&BASIC_ACTIONS_TYPES_WHITELIST.includes(ot.animationId))if(B.current)ue(ke,"idle");else{const Ee=V.current===ke?"neutral_talking":"neutral";ue(ke,Ee)}});else{const me=_e&&!te?`${pt}-seated`:pt;ue(ke,me)}},St=()=>{if(!K.uid||!(K!=null&&K.emotion)||B.current)return;const{emotion:ke,uid:pt,animation:ot}=K,_e=getCurrentVisible(pt,C);if(_e){const{isSeated:te}=_e;H(pt).then(()=>{qe(pt,te&&!ke.includes("seated")?`${ke}-seated_talking`:`${ke}_talking`,ot,te),ot&&BASIC_ACTIONS_TYPES_WHITELIST.includes(ot.animationId)&&(V.current=pt)}).catch(me=>{console.error(me)})}},Xe=()=>{if(!(K!=null&&K.uid)||B.current)return;const{emotion:ke,uid:pt,animation:ot}=K,_e=getCurrentVisible(pt,C);if(_e){delete _e.userData._active;const{isSeated:te}=_e;V.current===pt?(qe(pt,"neutral",null,te),V.current=null):qe(pt,ke,ot,te)}},lt=React$2.useCallback(()=>{B.current=!0,Se({show:!1}),Oe(),J(),h||e({type:"success"})},[N,e,Oe,h]);React$2.useEffect(()=>()=>{ee.current={},W()},[]);const $e=ke=>{Se({show:!1}),S(ke),e({type:"notifyProgress",payload:{line:ke}})},rt=React$2.useCallback((ke=!0)=>{const pt=ke?["fromId","toId"]:["toId","fromId"],ot=o.filter(me=>me[pt[0]]===j.id),_e=ot.length===1?ot[0]:ot.find(me=>me[pt[1]]===st);if(!(_e!=null&&_e[pt[0]])){lt();return}ke||Qe(Ne.slice(0,Ne.length-1));const te=t.findIndex(me=>me.id===_e[pt[1]]);te>=0?$e(te):lt()},[j==null?void 0:j.id,e,o,lt,t]),ft=React$2.useCallback((ke,pt)=>{const ot=[3,2,1][ke.id],te=o.filter(Ee=>Ee.fromId===(j==null?void 0:j.id)).find(Ee=>parseInt(Ee.fromPointIndex)===ot),me=t.findIndex(Ee=>Ee.id===(te==null?void 0:te.toId));me>=0?(te==null?void 0:te.fromId)===(te==null?void 0:te.toId)?pt():$e(me):lt()},[j==null?void 0:j.id,o,lt,t]),Ge=React$2.useCallback(()=>{if(ee.current={...K},w(!1),Xe(),X)rt(!1);else if(!Ve()){const ke=x-1;Se({show:!1}),S(ke),e({type:"notifyProgress",payload:{line:ke}})}},[rt,e,X,$,x,K]),De=React$2.useCallback(ke=>{if(X){if(ke){const pt=[3,2,1][ke.id],_e=o.filter(te=>te.fromId===j.id).find(te=>parseInt(te.fromPointIndex)===pt);if(_e){const te=t.findIndex(me=>me.id===_e.toId);te>=0&&e({type:"notifyProgress",payload:{line:te}})}else e({type:"saveNode"})}}else if(x<t.length-1){const pt=x+1;e({type:"notifyProgress",payload:{line:pt}})}else e({type:"saveNode"})},[o,x,t,e,j==null?void 0:j.id,X]),Re=React$2.useCallback((ke,pt)=>{if(ee.current={...K},w(!1),Xe(),X)Qe([...Ne,j.id]),ke?ft(ke,pt):rt();else if(x<t.length-1){const ot=x+1;$e(ot)}else(u||le||fe)&&lt()},[e,j==null?void 0:j.id,X,le,fe,x,t.length,ft,rt,lt,K]),ye=()=>{v(!1),Ge()},Pe=()=>X?j&&j.type!=="conversationalDecision"&&!o.find(ke=>ke.fromId===j.id):x===t.length-1,Ye=()=>{Pe()?lt():(v(!1),Re())};React$2.useEffect(()=>{if(X&&!b){const ke=_==null?void 0:_.line;if(ke>=0){R(!0),S(ke);return}const pt=yt();pt>=0&&(R(!0),S(pt))}},[o,X,t,b,yt]);const Ft=ke=>{if(ee.current.uid===ke.uid||M.current.parent===ke)return;const pt=new three.Object3D,ot=ke.getObjectByName("Head_M");ot.updateMatrixWorld(!0),pt.applyMatrix4(ot.matrixWorld),pt.applyQuaternion(N.quaternion);const _e=h?2.5:2,te=h?1.2:1.5;pt.translateY(_e),pt.translateX(te);const me=new three.Vector3;me.setFromMatrixPosition(ot.matrixWorld);const we=me.project(N).x<0;M.current={pos:pt.position.toArray(),child:ot,parent:ke,isLeft:we}},Pt=ke=>{e({type:"resetZIndexUIContainer",payload:ke})};React$2.useEffect(()=>{var ke;if(ie)Oe(),Se({text:j==null?void 0:j.text,name:(j==null?void 0:j.alias)||(j==null?void 0:j.name)||`[ ${Fe("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:Le(K),show:!0});else if(!B.current&&!le&&!fe){const pt=j==null?void 0:j.slots.filter(te=>te.uid&&!te.talking),ot=[...pt.map(te=>te.uid)||[],K==null?void 0:K.uid];if(Te.filter(te=>!ot.includes(te)).forEach(te=>{ue(te,"idle")}),pt.forEach(te=>{const me=getCurrentVisible(te.uid,C);if(me){const{isSeated:Ee}=me;qe(te.uid,te.emotion,te.animation,Ee)}}),K){const te=getCurrentVisible(K.uid,C),me=a.find(Ee=>Ee.uid===K.uid);te&&!B.current?setTimeout(()=>{var Ee,we;if(K.uid===te.uid){Ft(te);const{isSeated:de,userData:be}=te,{emotion:Be,animation:tt}=K;!((Ee=be._active)!=null&&Ee.includes("talking"))&&!((we=be._active)!=null&&we.includes(Be))&&qe(K.uid,Be,tt,de);const ht=()=>{var At;Se({text:K.text,name:K.alias||((At=K.character)==null?void 0:At.name),inScene:!0,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0})};h?(ne.current=!1,Ke(ht)):ht()}},150):(Oe(),Se({text:K.text,name:K.alias||((ke=K.character)==null?void 0:ke.name)||(me==null?void 0:me.name),left:!1,top:K.text.length>maxCharacterToSwitch,inScene:!1,thinkful:K.emotion.includes("think"),avatar:Le(K),show:!0}))}else Oe(),Se({show:!0})}},[a,j,h,C,Fe,Le,Oe,le,ie,Te]);const Ie=cleanTextOfHtmlTags(ge==null?void 0:ge.text),[mt,Ct]=useEkho({audioType:j==null?void 0:j.audioType,volume:j==null?void 0:j.audioVolume,voice:j==null?void 0:j.voice,started:ge.show,text:Ie,audio:j==null?void 0:j.audio,soundActions:d,getEvent:n,pauseTTS:p,onError:()=>{w(!0)},onFinish:()=>{Xe(),ce&&!p&&Re()}});React$2.useEffect(()=>(Ct(),()=>{Ct()}),[x,Ct]),React$2.useEffect(()=>{var ke;if(((j==null?void 0:j.audioType)==="none"||y)&&(ge!=null&&ge.show)&&!(K!=null&&K.emotion.includes("think"))){St();const pt=characterMs*(((ke=ge==null?void 0:ge.text)==null?void 0:ke.length)||0);setTimeout(()=>{Xe()},pt<minMs?minMs:pt)}},[y,j==null?void 0:j.audioType,Xe,St,K==null?void 0:K.emotion,ge]),React$2.useEffect(()=>{var ke;if(ce&&ge.show&&((j==null?void 0:j.audioType)==="none"||y)&&!p){const pt=characterMs*(((ke=ge==null?void 0:ge.text)==null?void 0:ke.length)||0);(!Pe()||Pe()&&u)&&D(Re,pt<minMs?minMs:pt)}return()=>{P()}},[ge,Re,D,u,P,j==null?void 0:j.audioType,ce,z,Y,y]);const at=React$2.useMemo(()=>yt()>=0&&Ne.length===0&&X||!X&&x===0||Ve()||Me(),[x,Ve,Me,yt,Ne]),wt=l({disabled:le||!ge.show,repeat:!1,forward:Ye,rewind:at?null:ye});React$2.useEffect(()=>wt(),[wt]);const Nt=document.querySelector(".screens--container");if(fe)return jsxRuntimeExports.jsx(ChangeCamera,{...j,emitEvent:e,success:!1,onFinish:Re},`change-camera-${x}`);if(le){const ke=j.id?t.filter(ot=>ot.decision).findIndex(ot=>ot.id===j.id)+1:t.filter(ot=>ot.decision).findIndex(ot=>ot===j)+1,pt={...j.payload,decisionNumber:ke,inheritProps:{slots:[],disableBackground:!0},required:!X,branched:X,onAddPoints:De,onFinish:Re,emitEvent:e,getEvent:n,pause:p,soundActions:d,keyboardControl:l};return jsxRuntimeExports.jsx(HtmlWrap,{onMount:()=>{Oe(),Pt(!0)},onUnMount:()=>{ne.current=!1,Pt(!1)},children:jsxRuntimeExports.jsx(DecisionComponent,{inScene:!0,...pt})})}return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[ge.text?jsxRuntimeExports.jsx(BubbleWrapper,{translate:Fe,currentMessage:ge}):null,jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:Nt?{current:Nt}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"ltr",className:"dialog-component-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:ye,disabled:at||!ge.show,className:`gat--btn__round ${at||!ge.show?"disabled":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.forward"):Fe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{type:"button",onClick:Ye,disabled:!ge.show,className:`gat--btn__round
273
273
  ${ge.show?"":"disabled"}
274
- ${g&&Pe()?"glowing-animation":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.rewind"):Fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}const activeCache=arcadeThreeCore.ProgressManager.request("AssetLoader").cache,assetLoader=new arcadeThreeCore.AssetLoader(void 0,activeCache);function Animation({animation:l,loopTimes:e,onAnimationFinish:n,onAnimationSave:t,resource:a,makeDefault:o}){const[d,h]=React$2.useState(!1),f=fiber.useThree(p=>p.scene),u=React$2.useRef(1);return React$2.useEffect(()=>{h(!1)},[a.uid,l==null?void 0:l.url]),React$2.useEffect(()=>{if(!d){const p=f.getObjectByProperty("uid",a.uid);if(p&&l&&l.url&&p.skeletonId===(l==null?void 0:l.skeletonId))if(o)t({uid:a.uid,animation:l==null?void 0:l.id,index:p.index}),n();else{const _=p.userData.animator,T=()=>{_.getAction(l.url).setLoop(three.LoopRepeat,1/0),u.current=1;function S(){u.current>=e&&(_.mix("idle"),n(),_.removeEventListener("loop",S)),u.current+=1}_.mix(l==null?void 0:l.url).then(g=>{g&&_.addEventListener("loop",S)}),h(!0)};_.getAction(l==null?void 0:l.url)?T():assetLoader.load(l==null?void 0:l.url,x=>{_.register(l==null?void 0:l.url,x.animations[0]),T()},void 0,x=>{console.error(`Asset loader failed with: ${l.url}`,x),n()})}else n()}},[f,l==null?void 0:l.url,e,d,a.uid,o,l,a,n,t]),null}function MultipleAnimation({animations:l=[],enableInteraction:e,emitEvent:n}){const t=l.length,a=React$2.useRef(0),o=()=>{a.current+=1,a.current>=t&&e&&n({type:"success"})},d=h=>{n({type:"saveAnimation",payload:h})};return React$2.useEffect(()=>{a.current=0},[l]),React$2.useEffect(()=>{e||n({type:"success"})},[n,e]),l.map(({animation:h,...f},u)=>{var p;return jsxRuntimeExports.jsx(Animation,{animation:h,...f,onAnimationFinish:o,onAnimationSave:d},(h==null?void 0:h.id)||((p=f.resource)==null?void 0:p.uid)||u)})}function EmailPill({text:l,error:e,handleClick:n}){return jsxRuntimeExports.jsxs("div",{"data-testid":`${e?" pill--error":"pill--ok"}`,className:`email-pill ${e?" email-pill--error":""}`,children:[jsxRuntimeExports.jsx("div",{children:l}),jsxRuntimeExports.jsx("div",{className:"email-pill__delete",children:jsxRuntimeExports.jsx("button",{type:"button",onClick:n,className:"icon-close unset-button","aria-label":"icon click"})})]})}function StepOne({handleContinue:l,handleCancel:e,translate:n,text:t}){const[a,o]=React$2.useState([]),[d,h]=React$2.useState(0),[f,u]=React$2.useState(0),p=React$2.useRef(null),_=(g,v,b)=>{g.stopPropagation(),o(a.filter(R=>R!==a[b])),v.error&&h(d-1),v.isRepeat&&u(f-1)},T=()=>{p.current&&p.current.focus()},x=()=>{[" ",",",";","."].includes(p.current.value)&&(p.current.value="")},S=g=>{const v=p.current.value,b=["Space","Comma","Period","Enter"],R=["Space","Comma","Enter","Tab"];v===""&&(b.includes(g.code)||g.keyCode==="186"||g.key==="Enter"||g.key===" ")?g.preventDefault():p.current.value.length>1&&(R.includes(g.code)||g.type==="blur")&&(g.preventDefault(),/[A-Za-z0-9._%+-]{3,}@[A-Za-z0-9_+-]{2,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})/.test(v)?a.find(w=>w.text===v)?(u(f+1),o([...a,{text:v,error:!0,isRepeat:!0}])):o([...a,{text:v}]):(o([...a,{text:v,error:!0}]),h(d+1)),p.current.value="")};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:n("puzzles.referrals.inviter.titleStep1")}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__subtitle",children:t}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__form",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__instructions",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.instructions")}),jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.limit")})]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:T,"aria-labelledby":"list of emails",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[a&&a.map((g,v)=>jsxRuntimeExports.jsx(EmailPill,{text:g.text,error:g.error,handleClick:b=>_(b,g,v),emailPillIndex:v},`${a.indexOf(g)}`)),a.length<=9?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("input",{id:"email",ref:p,className:"referrals-piece__inputemail",onChange:x,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:n("puzzles.referrals.inviter.skipButton")})})]}):null]})}),jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__errormessage",children:[jsxRuntimeExports.jsx("div",{children:f>0?n("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:d>0?n("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[a.length,"/10"]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:e,children:n("puzzles.referrals.inviter.skipButton")}),jsxRuntimeExports.jsx("button",{className:`gat--btn gat--btn__primary ${f>0||d>0||a.length===0?" disabled":""}`,type:"button",disabled:d>0||a.length===0,onClick:()=>l(a),children:n("puzzles.referrals.inviter.inviteButton")})]})]})}function StepTwo({handleFinish:l,translate:e,valid:n,invalid:t}){const[a,o]=React$2.useState(!1),d=()=>{o(!a)},h=n.current===1?"invitationSend":"invitationsSend",f=t===1?"invitationNotSend":"invitationsNotSend";return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep2")}),jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__feedback",children:[n.current!==0&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:n.current})," ",e(`puzzles.referrals.inviter.${h}`)]})]}),!!t.current&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:t.current})," ",e(`puzzles.referrals.inviter.${f}`)]}),jsxRuntimeExports.jsx("button",{className:"un-button",type:"button",onClick:d,children:e("puzzles.referrals.inviter.whyFail")})]})]}),a?jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__failsreasons",children:[jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons1")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons2")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons3")})]}):null]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__buttons",children:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:l,children:e("puzzles.referrals.inviter.continueButton")})})]})}function ReferralComponent({emitEvent:l,getEvent:e,text:n,rewards:t,referrals:a}){const o=x=>e({type:"translate",payload:x}),[d,h]=React$2.useState("step1"),f=React$2.useRef(0),u=React$2.useRef(0),p=async x=>{const S=x.map(v=>v.text),g=await l({type:"sendReferrals",payload:S});f.current=g&&g.data?g.data.valid.length:0,u.current=S.length-f.current,h("step2")};if(!a)return l({type:"success"}),null;const _=()=>{l({type:"success"})},T=()=>{if(f.current){const x=t.map(S=>(S.points*=f.current,S));l({type:"addPoints",complex:!0,finish:!0,payload:x})}else l({type:"success"})};return jsxRuntimeExports.jsx("div",{className:"referrals-piece",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__center",children:[d==="step1"&&jsxRuntimeExports.jsx(StepOne,{translate:o,handleContinue:p,handleCancel:_,text:n}),d==="step2"&&jsxRuntimeExports.jsx(StepTwo,{translate:o,handleFinish:T,valid:f,invalid:u})]})})}function PseudoNoEvaluationEvent({onPass:l}){return React$2.useEffect(()=>{const e=setTimeout(l,0);return()=>clearTimeout(e)},[l]),null}function DragToSceneComponent({itemResolver:l,consume:e,hasComplexNotResolvers:n,hasComplexResolvers:t,resolverObjects:a,feedback:o,emitEvent:d,getEvent:h,soundActions:f,keyboardControl:u,noEvaluation:p}){const[_]=f,[T,x]=React$2.useState(!1),[S,g]=React$2.useState(!1),[v,b]=React$2.useState(!1),R=D=>h({type:"translate",payload:D}),y=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:T.success,onFinish:()=>{T.success?d({type:"success"}):d({type:"closeScreen"})},payload:T.rewards})},[d,T]),w=React$2.useCallback(()=>{if(a.find(P=>P===l.uid)){let P;t?(P=o.resolvers.rights.find(k=>k.uidObject===l.uid),P||(P=o.resolvers.rights[0])):P=o.resolvers.rights[0],e&&d({type:"consumeItem",payload:{uid:l.uid,targetId:l.uid,name:l.name}}),x({...P,success:!0})}else{let P;n?(P=o.notResolvers.wrongs.find(k=>k.uidObject===l.uid),P||(P=o.notResolvers.wrongs[0])):P=o.notResolvers.wrongs[0],x({...P,success:!1})}},[a,l,t,e,o,d,n]),C=React$2.useCallback(()=>{if(a.find(P=>P===(l==null?void 0:l.uid))){let P;t?P=[...o.resolvers.rights.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.resolvers.rights[0].rewards.filter(F=>F.type==="var")],e&&d({type:"consumeItem",payload:{uid:l==null?void 0:l.uid,targetId:l==null?void 0:l.uid,name:l==null?void 0:l.name}}),b({varsPoints:[...P],success:!0})}else{let P;n?P=[...o.notResolvers.wrongs.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.notResolvers.wrongs[0].rewards.filter(F=>F.type==="var")],b({varsPoints:[...P],success:!1})}},[e,d,o.notResolvers.wrongs,o.resolvers.rights,n,t,l==null?void 0:l.name,l==null?void 0:l.uid,a]),N=React$2.useCallback(()=>{g(!1),d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]})},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v!=null&&v.success&&g(!0)},[v]),S?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:N}):T?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:T.desc,success:T.success,playSound:_,hasTimeout:!T.desc,delay:2e3,translate:R,keyboardControl:u,functionOnClose:y}):null}function MatchItem({item:l,viewMode:e}){var n,t;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e==="text"&&jsxRuntimeExports.jsx("div",{className:"match-item-text",children:HTMLReactParser$1(l==null?void 0:l.content)}),e==="card"&&jsxRuntimeExports.jsx("div",{className:"match-item-image",children:jsxRuntimeExports.jsxs("figure",{children:[((n=l==null?void 0:l.img)==null?void 0:n.url)&&jsxRuntimeExports.jsx("img",{src:(t=l==null?void 0:l.img)==null?void 0:t.url,alt:l==null?void 0:l.imgName}),(l==null?void 0:l.content)&&jsxRuntimeExports.jsx("figcaption",{children:HTMLReactParser$1(l==null?void 0:l.content)})]})})]})}function CountDownDialog({translate:l,onClose:e,buttonLabel:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:l("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:e,children:jsxRuntimeExports.jsx("span",{children:l(`${n}`)})})]})})}function CountdownTimer({initialSeconds:l=10,isPaused:e,shouldStart:n,shouldReset:t,onTimeOver:a}){const[o,d]=React$2.useState(l),[h,f]=React$2.useState(!1),u=React$2.useRef();React$2.useEffect(()=>{t&&(d(l),f(!1))},[t,l]),React$2.useEffect(()=>{e&&f(!1)},[e]),React$2.useEffect(()=>{n&&f(!0)},[n]),React$2.useEffect(()=>(h&&o>0?u.current=setInterval(()=>{d(_=>_-1),o===1&&a()},1e3):o===0&&(clearInterval(u.current),f(!1)),()=>clearInterval(u.current)),[h,a,o]);const p=_=>{const T=Math.floor(_/60),x=_%60,S=String(T).padStart(2,"0"),g=String(x).padStart(2,"0");return`${S}:${g}`};return jsxRuntimeExports.jsx("div",{className:`count-down ${o<10&&"count-down--finalseconds"}`,children:jsxRuntimeExports.jsx("div",{children:p(o)})})}function MatchPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:a,setResolveAction:o,nodeId:d,viewMode:h,title:f,sources:u,destinations:p,correctPairings:_,timer:T=0,keyboardControl:x,backgroundImage:S}){const g=Oe=>n({type:"translate",payload:Oe}),v=`match-puzzle_${d}`,[b,R]=React$2.useState([]),[y,w]=React$2.useState(null),[C,N]=React$2.useState(!1),[D,P]=React$2.useState(!1),[k,F]=React$2.useState(""),[M,j]=React$2.useState(!1),[$,B]=React$2.useState([]),[X]=e;useEkho({soundActions:e});const re=Oe=>{X("click-ui");const qe=ft=>ft==null?void 0:ft.startsWith("source-item"),St=ft=>ft==null?void 0:ft.startsWith("destination-item");if(Oe.id===y){w(null);return}const Xe=qe(Oe.id),lt=qe(y),$e=St(Oe.id),rt=St(y);if(Xe&&rt||$e&&lt){K(Oe);return}w(Oe.id)},ae=Oe=>{let qe;return Oe.startsWith("destination-item")?qe={[y]:Oe}:qe={[Oe]:y},_.some(St=>{const Xe=JSON.stringify(St),lt=JSON.stringify(qe);return Xe===lt})},ee=(Oe,qe)=>{const St=new Map(Oe.map(Xe=>[Xe.id,{...Xe}]));return qe.forEach(Xe=>{St.has(Xe.id)?St.get(Xe.id).points+=Xe.points:St.set(Xe.id,{...Xe})}),Array.from(St.values())},K=Oe=>{var qe,St;if(X("click-ui"),ae(Oe.id)){const Xe=Oe.id.startsWith("source-item")?Oe.id:y,lt=Oe.id.startsWith("destination-item")?Oe.id:y,$e=[...b,{[Xe]:lt}];if(R($e),a.specificCorrectFeedbacks){const rt=a==null?void 0:a.correctFeedbacks.find(De=>De.id===`${Xe}-${lt}`),ft=ee($,rt.rewards);B([...ft]),ne($e)&&(Ze(),j(!0)),rt.desc&&(F(rt==null?void 0:rt.desc),P(!0),N(!0),Ze());const Ge=ne($e);!rt.desc&&Ge&&ue(ft)}else if(ne($e)&&(Ze(),j(!0)),ne($e)){P(!0),t.solution.right.desc&&(Ze(),F(t.solution.right.desc)),N(!0),j(!0);const ft=ee($,t.solution.right.rewards);B([...ft]),t.solution.right.desc===""&&setTimeout(()=>{ue(ft)},3e3)}w(null)}else if(document.querySelector(`#${Oe.id}`).classList.add("match-button--error"),document.querySelector(`#${y}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${Oe.id}`).classList.remove("match-button--error"),document.querySelector(`#${y}`).classList.remove("match-button--error"),w(null)},1e3),a.specificWrongFeedbacks){const Xe=Oe.id.startsWith("destination-item")?Oe.id:y,lt=a==null?void 0:a.wrongFeedbacks.find(rt=>rt.id===Xe),$e=ee($,lt.rewards);B([...$e]),lt!=null&&lt.desc&&(F(lt.desc),P(!1),N(!0),Ze())}else{const Xe=ee($,t.solution.wrong.rewards);B([...Xe]),(St=(qe=t.solution)==null?void 0:qe.wrong)!=null&&St.desc&&(F(t.solution.wrong.desc),N(!0),Ze())}},ne=Oe=>{if(_.length!==Oe.length)return!1;const qe=new Set(_.map(Xe=>JSON.stringify(Xe))),St=new Set(Oe.map(Xe=>JSON.stringify(Xe)));for(const Xe of St)if(!qe.has(Xe))return!1;return!0},ue=Oe=>{X("score");const qe=Oe?[...Oe]:[...$];l({type:"addPoints",complex:!0,finish:!0,payload:qe}),l({type:"passPuzzle"})},pe=()=>{N(!1),P(!1),F(""),le&&(Ve(),z(!0)),!le&&!M&&yt(),M&&ue()},J=React$2.useMemo(()=>Object.assign({},...b),[b]),H=(Oe,qe)=>J[Oe]===qe;React$2.useEffect(()=>{o(()=>{X("score"),Ze(),P(!0),F(t.solution.right.desc);const Oe=[...$,...t.resolve.rewards],qe=[..._];R(qe),setTimeout(()=>{P(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:Oe,finish:!0}})},5e3)})},[$,_,l,t.resolve.rewards,t.solution.right.desc,X,v,o]);const W=(Oe,qe)=>b.findIndex(St=>{const Xe=Object.keys(St)[0],lt=Object.values(St)[0];return Xe===Oe&&lt===qe}),[V,z]=React$2.useState(!0),[Y,ie]=React$2.useState("storylines.misc.start"),[le,fe]=React$2.useState(!1),ce=()=>{ie("storylines.misc.retry"),z(!1),fe(!1),yt()},[ge,Se]=React$2.useState(!1),[Te,Fe]=React$2.useState(!1),[Ne,Qe]=React$2.useState(!1),st=()=>{let Oe=ee($,t.timerFeedback.rewards);if(a.specificCorrectFeedbacks){const qe=new Map(Oe.map(St=>[St.id,{...St}]));b.forEach(St=>{const Xe=Object.keys(St)[0],lt=St[Xe],$e=a.correctFeedbacks.find(rt=>rt.id===`${Xe}-${lt}`);$e!=null&&$e.rewards&&$e.rewards.forEach(rt=>{if(qe.has(rt.id)){const ft=qe.get(rt.id);ft.points-=rt.points,qe.set(rt.id,ft)}})}),Oe=Array.from(qe.values())}B(Oe),R([]),fe(!0),F(t.timerFeedback.desc),N(!0)},Ze=()=>{Se(!0),Fe(!1),Qe(!1)},yt=()=>{Se(!1),Fe(!0),Qe(!1)},Ve=()=>{Se(!1),Fe(!1),Qe(!0)},Me=React$2.useCallback(()=>{const Oe=document.querySelector('button[id^="source-item"]'),qe=document.querySelector('button[id^="destination-item"]'),St=Oe.getBoundingClientRect().right,lt=qe.getBoundingClientRect().left+6-St;u.items.forEach(($e,rt)=>{if($e.matchDestinationId!==void 0&&$e.matchDestinationId!==null){const ft=document.querySelector(`#${$e.id}`),Ge=document.querySelector(`#${$e.matchDestinationId}`),De=ft.getBoundingClientRect().top,Re=Ge.getBoundingClientRect().top,ye=Re>De,Pe=Math.abs(Re-De),Ye=Math.sqrt(lt*lt+Pe*Pe),Ft=ft.querySelector(".match-line__hipotenuse");Ft.style.setProperty("width",`${Ye}px`);const Pt=Math.atan(Pe/lt),Ie=ye?Pt*(180/Math.PI):-Pt*(180/Math.PI);Ft.style.setProperty("transform",`rotate(${Ie}deg)`)}})},[u.items]);React$2.useEffect(()=>(Me(),window.addEventListener("resize",Me),()=>{window.removeEventListener("resize",Me)}),[Me]);const Le=React$2.useMemo(()=>{let Oe="";return Oe="match ",S!=null&&S.url&&(Oe+="match--with-custom-bg"),Oe},[S==null?void 0:S.url]),Ke={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:Le,style:Ke,children:[(f||T>0)&&jsxRuntimeExports.jsxs("header",{className:"match__header",children:[jsxRuntimeExports.jsx("div",{}),f&&jsxRuntimeExports.jsx("div",{className:"match__title","data-testid":"match__title",children:HTMLReactParser$1(f)}),T>0&&jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:T,isPaused:ge,shouldStart:Te,shouldReset:Ne,onTimeOver:st})]}),jsxRuntimeExports.jsx("div",{className:"match__columns",children:jsxRuntimeExports.jsxs("div",{className:"match__columns-scroll",children:[jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[u.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(u.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:u.items.map(Oe=>jsxRuntimeExports.jsxs("button",{id:Oe.id,"data-testid":Oe.id,className:["unset-button match-button",y===Oe.id&&"match-button--marked",H(Oe.id,Oe.matchDestinationId)&&"match-button--success",W(Oe.id,Oe.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(Oe.id,Oe.matchDestinationId)+1})`},disabled:H(Oe.id,Oe.matchDestinationId),type:"button",onClick:()=>re(Oe),children:[jsxRuntimeExports.jsx(MatchItem,{item:Oe,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"match-line__hipotenuse"})]},Oe.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(p.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map(Oe=>jsxRuntimeExports.jsxs("button",{id:Oe.id,"data-testid":Oe.id,className:["unset-button match-button",y===Oe.id&&"match-button--marked",H(Oe.matchSourceId,Oe.id)&&"match-button--success",W(Oe.matchSourceId,Oe.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(Oe.matchSourceId,Oe.id)+1})`},disabled:H(Oe.matchSourceId,Oe.id),type:"button",onClick:()=>re(Oe),children:[jsxRuntimeExports.jsx(MatchItem,{item:Oe,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},Oe.id))})]})]})})]}),T>0&&V&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:Y,translate:g,onClose:ce}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:D,text:k,hasTimeout:!k,translate:g,timeExpired:le,functionOnClose:pe,keyboardControl:x})]})}exports.AnimationComponent=MultipleAnimation;exports.AutoEvaluationComponent=AutoEvaluation;exports.CardsSelectorPuzzleComponent=CardsSelectorPuzzleComponent;exports.CartelComponent=CartelComponent;exports.ChainedImageClickPuzzleComponent=ChainedImageClickPuzzleComponent;exports.ChangeCamera=ChangeCamera;exports.ComicComponent=ComicComponent;exports.ConversationalComponent=ConversationalComponent;exports.ConversationalProComponent=ConversationalProComponent;exports.CrackerPuzzleComponent=CrackerPuzzleComponent;exports.DecisionComponent=DecisionComponent;exports.DialogComponent=DialogComponent;exports.DragItemPuzzleComponent=DragItemPuzzleComponent;exports.DragToSceneComponent=DragToSceneComponent;exports.FrameImageClickComponent=FrameImageClickComponent;exports.HackerPuzzleComponent=HackerPuzzleComponent;exports.HangedPuzzleComponent=HangedPuzzleComponent;exports.ImageClickPuzzleComponent=ImageClickPuzzleComponent;exports.ImageComponent=ImageComponent;exports.InventoryItem=InventoryItem;exports.KeyboardPuzzleComponent=KeyboardPuzzleComponent;exports.LecturesComponent=LecturesComponent;exports.LoginPuzzleComponent=LoginPuzzleComponent;exports.MatchPuzzleComponent=MatchPuzzleComponent;exports.NoticeComponent=NoticeComponent;exports.PatternComponent=PatternComponent;exports.PdfComponent=PdfComponent;exports.PdfVisor=PdfVisor;exports.ReferralComponent=ReferralComponent;exports.SurveyComponent=SurveyComponent;exports.TerminalPuzzleComponent=TerminalPuzzleComponent;exports.TestComponent=TestComponent;exports.TextClickPuzzleComponent=TextClickPuzzleComponent;exports.UrlComponent=UrlComponent;exports.VideoComponent=VideoComponent;exports.VideoVisor=VideoVisor;exports.WebBuilderPuzzleComponent=WebBuilderPuzzleComponent;exports.WriterPuzzleComponent=WriterPuzzleComponent;
274
+ ${g&&Pe()?"glowing-animation":""}`,"aria-label":LangIsRtl()?Fe("storylines.misc.rewind"):Fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})}const activeCache=arcadeThreeCore.ProgressManager.request("AssetLoader").cache,assetLoader=new arcadeThreeCore.AssetLoader(void 0,activeCache);function Animation({animation:l,loopTimes:e,onAnimationFinish:n,onAnimationSave:t,resource:a,makeDefault:o}){const[d,h]=React$2.useState(!1),f=fiber.useThree(p=>p.scene),u=React$2.useRef(1);return React$2.useEffect(()=>{h(!1)},[a.uid,l==null?void 0:l.url]),React$2.useEffect(()=>{if(!d){const p=f.getObjectByProperty("uid",a.uid);if(p&&l&&l.url&&p.skeletonId===(l==null?void 0:l.skeletonId))if(o)t({uid:a.uid,animation:l==null?void 0:l.id,index:p.index}),n();else{const _=p.userData.animator,T=()=>{_.getAction(l.url).setLoop(three.LoopRepeat,1/0),u.current=1;function S(){u.current>=e&&(_.mix("idle"),n(),_.removeEventListener("loop",S)),u.current+=1}_.mix(l==null?void 0:l.url).then(g=>{g&&_.addEventListener("loop",S)}),h(!0)};_.getAction(l==null?void 0:l.url)?T():assetLoader.load(l==null?void 0:l.url,x=>{_.register(l==null?void 0:l.url,x.animations[0]),T()},void 0,x=>{console.error(`Asset loader failed with: ${l.url}`,x),n()})}else n()}},[f,l==null?void 0:l.url,e,d,a.uid,o,l,a,n,t]),null}function MultipleAnimation({animations:l=[],enableInteraction:e,emitEvent:n}){const t=l.length,a=React$2.useRef(0),o=()=>{a.current+=1,a.current>=t&&e&&n({type:"success"})},d=h=>{n({type:"saveAnimation",payload:h})};return React$2.useEffect(()=>{a.current=0},[l]),React$2.useEffect(()=>{e||n({type:"success"})},[n,e]),l.map(({animation:h,...f},u)=>{var p;return jsxRuntimeExports.jsx(Animation,{animation:h,...f,onAnimationFinish:o,onAnimationSave:d},(h==null?void 0:h.id)||((p=f.resource)==null?void 0:p.uid)||u)})}function EmailPill({text:l,error:e,handleClick:n}){return jsxRuntimeExports.jsxs("div",{"data-testid":`${e?" pill--error":"pill--ok"}`,className:`email-pill ${e?" email-pill--error":""}`,children:[jsxRuntimeExports.jsx("div",{children:l}),jsxRuntimeExports.jsx("div",{className:"email-pill__delete",children:jsxRuntimeExports.jsx("button",{type:"button",onClick:n,className:"icon-close unset-button","aria-label":"icon click"})})]})}function StepOne({handleContinue:l,handleCancel:e,translate:n,text:t}){const[a,o]=React$2.useState([]),[d,h]=React$2.useState(0),[f,u]=React$2.useState(0),p=React$2.useRef(null),_=(g,v,b)=>{g.stopPropagation(),o(a.filter(R=>R!==a[b])),v.error&&h(d-1),v.isRepeat&&u(f-1)},T=()=>{p.current&&p.current.focus()},x=()=>{[" ",",",";","."].includes(p.current.value)&&(p.current.value="")},S=g=>{const v=p.current.value,b=["Space","Comma","Period","Enter"],R=["Space","Comma","Enter","Tab"];v===""&&(b.includes(g.code)||g.keyCode==="186"||g.key==="Enter"||g.key===" ")?g.preventDefault():p.current.value.length>1&&(R.includes(g.code)||g.type==="blur")&&(g.preventDefault(),/[A-Za-z0-9._%+-]{3,}@[A-Za-z0-9_+-]{2,}([.]{1}[a-zA-Z]{2,}|[.]{1}[a-zA-Z]{2,}[.]{1}[a-zA-Z]{2,})/.test(v)?a.find(w=>w.text===v)?(u(f+1),o([...a,{text:v,error:!0,isRepeat:!0}])):o([...a,{text:v}]):(o([...a,{text:v,error:!0}]),h(d+1)),p.current.value="")};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:n("puzzles.referrals.inviter.titleStep1")}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__subtitle",children:t}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__form",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__instructions",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.instructions")}),jsxRuntimeExports.jsx("div",{dir:"auto",children:n("puzzles.referrals.inviter.limit")})]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:T,"aria-labelledby":"list of emails",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[a&&a.map((g,v)=>jsxRuntimeExports.jsx(EmailPill,{text:g.text,error:g.error,handleClick:b=>_(b,g,v),emailPillIndex:v},`${a.indexOf(g)}`)),a.length<=9?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("input",{id:"email",ref:p,className:"referrals-piece__inputemail",onChange:x,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),jsxRuntimeExports.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:jsxRuntimeExports.jsx("span",{children:n("puzzles.referrals.inviter.skipButton")})})]}):null]})}),jsxRuntimeExports.jsxs("div",{dir:LangIsRtl()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__errormessage",children:[jsxRuntimeExports.jsx("div",{children:f>0?n("puzzles.referrals.inviter.errorEmailRepeat"):null}),jsxRuntimeExports.jsx("div",{children:d>0?n("puzzles.referrals.inviter.errorMessage"):null})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[a.length,"/10"]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"referrals-piece__buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:e,children:n("puzzles.referrals.inviter.skipButton")}),jsxRuntimeExports.jsx("button",{className:`gat--btn gat--btn__primary ${f>0||d>0||a.length===0?" disabled":""}`,type:"button",disabled:d>0||a.length===0,onClick:()=>l(a),children:n("puzzles.referrals.inviter.inviteButton")})]})]})}function StepTwo({handleFinish:l,translate:e,valid:n,invalid:t}){const[a,o]=React$2.useState(!1),d=()=>{o(!a)},h=n.current===1?"invitationSend":"invitationsSend",f=t===1?"invitationNotSend":"invitationsNotSend";return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep2")}),jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__feedback",children:[n.current!==0&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:n.current})," ",e(`puzzles.referrals.inviter.${h}`)]})]}),!!t.current&&jsxRuntimeExports.jsxs("li",{children:[jsxRuntimeExports.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("strong",{children:t.current})," ",e(`puzzles.referrals.inviter.${f}`)]}),jsxRuntimeExports.jsx("button",{className:"un-button",type:"button",onClick:d,children:e("puzzles.referrals.inviter.whyFail")})]})]}),a?jsxRuntimeExports.jsxs("ul",{className:"referrals-piece__failsreasons",children:[jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons1")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons2")}),jsxRuntimeExports.jsx("li",{children:e("puzzles.referrals.inviter.failReasons3")})]}):null]}),jsxRuntimeExports.jsx("div",{className:"referrals-piece__buttons",children:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:l,children:e("puzzles.referrals.inviter.continueButton")})})]})}function ReferralComponent({emitEvent:l,getEvent:e,text:n,rewards:t,referrals:a}){const o=x=>e({type:"translate",payload:x}),[d,h]=React$2.useState("step1"),f=React$2.useRef(0),u=React$2.useRef(0),p=async x=>{const S=x.map(v=>v.text),g=await l({type:"sendReferrals",payload:S});f.current=g&&g.data?g.data.valid.length:0,u.current=S.length-f.current,h("step2")};if(!a)return l({type:"success"}),null;const _=()=>{l({type:"success"})},T=()=>{if(f.current){const x=t.map(S=>(S.points*=f.current,S));l({type:"addPoints",complex:!0,finish:!0,payload:x})}else l({type:"success"})};return jsxRuntimeExports.jsx("div",{className:"referrals-piece",children:jsxRuntimeExports.jsxs("div",{className:"referrals-piece__center",children:[d==="step1"&&jsxRuntimeExports.jsx(StepOne,{translate:o,handleContinue:p,handleCancel:_,text:n}),d==="step2"&&jsxRuntimeExports.jsx(StepTwo,{translate:o,handleFinish:T,valid:f,invalid:u})]})})}function PseudoNoEvaluationEvent({onPass:l}){return React$2.useEffect(()=>{const e=setTimeout(l,0);return()=>clearTimeout(e)},[l]),null}function DragToSceneComponent({itemResolver:l,consume:e,hasComplexNotResolvers:n,hasComplexResolvers:t,resolverObjects:a,feedback:o,emitEvent:d,getEvent:h,soundActions:f,keyboardControl:u,noEvaluation:p}){const[_]=f,[T,x]=React$2.useState(!1),[S,g]=React$2.useState(!1),[v,b]=React$2.useState(!1),R=D=>h({type:"translate",payload:D}),y=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:T.success,onFinish:()=>{T.success?d({type:"success"}):d({type:"closeScreen"})},payload:T.rewards})},[d,T]),w=React$2.useCallback(()=>{if(a.find(P=>P===l.uid)){let P;t?(P=o.resolvers.rights.find(k=>k.uidObject===l.uid),P||(P=o.resolvers.rights[0])):P=o.resolvers.rights[0],e&&d({type:"consumeItem",payload:{uid:l.uid,targetId:l.uid,name:l.name}}),x({...P,success:!0})}else{let P;n?(P=o.notResolvers.wrongs.find(k=>k.uidObject===l.uid),P||(P=o.notResolvers.wrongs[0])):P=o.notResolvers.wrongs[0],x({...P,success:!1})}},[a,l,t,e,o,d,n]),C=React$2.useCallback(()=>{if(a.find(P=>P===(l==null?void 0:l.uid))){let P;t?P=[...o.resolvers.rights.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.resolvers.rights[0].rewards.filter(F=>F.type==="var")],e&&d({type:"consumeItem",payload:{uid:l==null?void 0:l.uid,targetId:l==null?void 0:l.uid,name:l==null?void 0:l.name}}),b({varsPoints:[...P],success:!0})}else{let P;n?P=[...o.notResolvers.wrongs.find(M=>M.uidObject===(l==null?void 0:l.uid)).rewards.filter(M=>M.type==="var")]:P=[...o.notResolvers.wrongs[0].rewards.filter(F=>F.type==="var")],b({varsPoints:[...P],success:!1})}},[e,d,o.notResolvers.wrongs,o.resolvers.rights,n,t,l==null?void 0:l.name,l==null?void 0:l.uid,a]),N=React$2.useCallback(()=>{d({type:"addPoints",complex:!0,finish:v==null?void 0:v.success,onFinish:()=>{v!=null&&v.success?d({type:"success"}):d({type:"closeScreen"})},payload:v!=null&&v.varsPoints?v==null?void 0:v.varsPoints:[]}),g(!1)},[d,v==null?void 0:v.success,v==null?void 0:v.varsPoints]);return React$2.useEffect(()=>{l?p?C():w():d({type:"closeScreen"})},[w,C,d,l,p]),React$2.useEffect(()=>{v&&(v!=null&&v.success?g(!0):d({type:"closeScreen"}))},[d,v]),S?jsxRuntimeExports.jsx(PseudoNoEvaluationEvent,{onPass:N}):T?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:T.desc,success:T.success,playSound:_,hasTimeout:!T.desc,delay:2e3,translate:R,keyboardControl:u,functionOnClose:y}):null}function MatchItem({item:l,viewMode:e}){var n,t;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e==="text"&&jsxRuntimeExports.jsx("div",{className:"match-item-text",children:HTMLReactParser$1(l==null?void 0:l.content)}),e==="card"&&jsxRuntimeExports.jsx("div",{className:"match-item-image",children:jsxRuntimeExports.jsxs("figure",{children:[((n=l==null?void 0:l.img)==null?void 0:n.url)&&jsxRuntimeExports.jsx("img",{src:(t=l==null?void 0:l.img)==null?void 0:t.url,alt:l==null?void 0:l.imgName}),(l==null?void 0:l.content)&&jsxRuntimeExports.jsx("figcaption",{children:HTMLReactParser$1(l==null?void 0:l.content)})]})})]})}function CountDownDialog({translate:l,onClose:e,buttonLabel:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:l("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:e,children:jsxRuntimeExports.jsx("span",{children:l(`${n}`)})})]})})}function CountdownTimer({initialSeconds:l=10,isPaused:e,shouldStart:n,shouldReset:t,onTimeOver:a}){const[o,d]=React$2.useState(l),[h,f]=React$2.useState(!1),u=React$2.useRef();React$2.useEffect(()=>{t&&(d(l),f(!1))},[t,l]),React$2.useEffect(()=>{e&&f(!1)},[e]),React$2.useEffect(()=>{n&&f(!0)},[n]),React$2.useEffect(()=>(h&&o>0?u.current=setInterval(()=>{d(_=>_-1),o===1&&a()},1e3):o===0&&(clearInterval(u.current),f(!1)),()=>clearInterval(u.current)),[h,a,o]);const p=_=>{const T=Math.floor(_/60),x=_%60,S=String(T).padStart(2,"0"),g=String(x).padStart(2,"0");return`${S}:${g}`};return jsxRuntimeExports.jsx("div",{className:`count-down ${o<10&&"count-down--finalseconds"}`,children:jsxRuntimeExports.jsx("div",{children:p(o)})})}function MatchPuzzleComponent({emitEvent:l,soundActions:e=[()=>{},()=>{}],getEvent:n,info:t,specificFeedbacks:a,setResolveAction:o,nodeId:d,viewMode:h,title:f,sources:u,destinations:p,correctPairings:_,timer:T=0,keyboardControl:x,backgroundImage:S}){const g=Oe=>n({type:"translate",payload:Oe}),v=`match-puzzle_${d}`,[b,R]=React$2.useState([]),[y,w]=React$2.useState(null),[C,N]=React$2.useState(!1),[D,P]=React$2.useState(!1),[k,F]=React$2.useState(""),[M,j]=React$2.useState(!1),[$,B]=React$2.useState([]),[X]=e;useEkho({soundActions:e});const re=Oe=>{X("click-ui");const qe=ft=>ft==null?void 0:ft.startsWith("source-item"),St=ft=>ft==null?void 0:ft.startsWith("destination-item");if(Oe.id===y){w(null);return}const Xe=qe(Oe.id),lt=qe(y),$e=St(Oe.id),rt=St(y);if(Xe&&rt||$e&&lt){K(Oe);return}w(Oe.id)},ae=Oe=>{let qe;return Oe.startsWith("destination-item")?qe={[y]:Oe}:qe={[Oe]:y},_.some(St=>{const Xe=JSON.stringify(St),lt=JSON.stringify(qe);return Xe===lt})},ee=(Oe,qe)=>{const St=new Map(Oe.map(Xe=>[Xe.id,{...Xe}]));return qe.forEach(Xe=>{St.has(Xe.id)?St.get(Xe.id).points+=Xe.points:St.set(Xe.id,{...Xe})}),Array.from(St.values())},K=Oe=>{var qe,St;if(X("click-ui"),ae(Oe.id)){const Xe=Oe.id.startsWith("source-item")?Oe.id:y,lt=Oe.id.startsWith("destination-item")?Oe.id:y,$e=[...b,{[Xe]:lt}];if(R($e),a.specificCorrectFeedbacks){const rt=a==null?void 0:a.correctFeedbacks.find(De=>De.id===`${Xe}-${lt}`),ft=ee($,rt.rewards);B([...ft]),ne($e)&&(Ze(),j(!0)),rt.desc&&(F(rt==null?void 0:rt.desc),P(!0),N(!0),Ze());const Ge=ne($e);!rt.desc&&Ge&&ue(ft)}else if(ne($e)&&(Ze(),j(!0)),ne($e)){P(!0),t.solution.right.desc&&(Ze(),F(t.solution.right.desc)),N(!0),j(!0);const ft=ee($,t.solution.right.rewards);B([...ft]),t.solution.right.desc===""&&setTimeout(()=>{ue(ft)},3e3)}w(null)}else if(document.querySelector(`#${Oe.id}`).classList.add("match-button--error"),document.querySelector(`#${y}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${Oe.id}`).classList.remove("match-button--error"),document.querySelector(`#${y}`).classList.remove("match-button--error"),w(null)},1e3),a.specificWrongFeedbacks){const Xe=Oe.id.startsWith("destination-item")?Oe.id:y,lt=a==null?void 0:a.wrongFeedbacks.find(rt=>rt.id===Xe),$e=ee($,lt.rewards);B([...$e]),lt!=null&&lt.desc&&(F(lt.desc),P(!1),N(!0),Ze())}else{const Xe=ee($,t.solution.wrong.rewards);B([...Xe]),(St=(qe=t.solution)==null?void 0:qe.wrong)!=null&&St.desc&&(F(t.solution.wrong.desc),N(!0),Ze())}},ne=Oe=>{if(_.length!==Oe.length)return!1;const qe=new Set(_.map(Xe=>JSON.stringify(Xe))),St=new Set(Oe.map(Xe=>JSON.stringify(Xe)));for(const Xe of St)if(!qe.has(Xe))return!1;return!0},ue=Oe=>{X("score");const qe=Oe?[...Oe]:[...$];l({type:"addPoints",complex:!0,finish:!0,payload:qe}),l({type:"passPuzzle"})},pe=()=>{N(!1),P(!1),F(""),le&&(Ve(),z(!0)),!le&&!M&&yt(),M&&ue()},J=React$2.useMemo(()=>Object.assign({},...b),[b]),H=(Oe,qe)=>J[Oe]===qe;React$2.useEffect(()=>{o(()=>{X("score"),Ze(),P(!0),F(t.solution.right.desc);const Oe=[...$,...t.resolve.rewards],qe=[..._];R(qe),setTimeout(()=>{P(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:Oe,finish:!0}})},5e3)})},[$,_,l,t.resolve.rewards,t.solution.right.desc,X,v,o]);const W=(Oe,qe)=>b.findIndex(St=>{const Xe=Object.keys(St)[0],lt=Object.values(St)[0];return Xe===Oe&&lt===qe}),[V,z]=React$2.useState(!0),[Y,ie]=React$2.useState("storylines.misc.start"),[le,fe]=React$2.useState(!1),ce=()=>{ie("storylines.misc.retry"),z(!1),fe(!1),yt()},[ge,Se]=React$2.useState(!1),[Te,Fe]=React$2.useState(!1),[Ne,Qe]=React$2.useState(!1),st=()=>{let Oe=ee($,t.timerFeedback.rewards);if(a.specificCorrectFeedbacks){const qe=new Map(Oe.map(St=>[St.id,{...St}]));b.forEach(St=>{const Xe=Object.keys(St)[0],lt=St[Xe],$e=a.correctFeedbacks.find(rt=>rt.id===`${Xe}-${lt}`);$e!=null&&$e.rewards&&$e.rewards.forEach(rt=>{if(qe.has(rt.id)){const ft=qe.get(rt.id);ft.points-=rt.points,qe.set(rt.id,ft)}})}),Oe=Array.from(qe.values())}B(Oe),R([]),fe(!0),F(t.timerFeedback.desc),N(!0)},Ze=()=>{Se(!0),Fe(!1),Qe(!1)},yt=()=>{Se(!1),Fe(!0),Qe(!1)},Ve=()=>{Se(!1),Fe(!1),Qe(!0)},Me=React$2.useCallback(()=>{const Oe=document.querySelector('button[id^="source-item"]'),qe=document.querySelector('button[id^="destination-item"]'),St=Oe.getBoundingClientRect().right,lt=qe.getBoundingClientRect().left+6-St;u.items.forEach(($e,rt)=>{if($e.matchDestinationId!==void 0&&$e.matchDestinationId!==null){const ft=document.querySelector(`#${$e.id}`),Ge=document.querySelector(`#${$e.matchDestinationId}`),De=ft.getBoundingClientRect().top,Re=Ge.getBoundingClientRect().top,ye=Re>De,Pe=Math.abs(Re-De),Ye=Math.sqrt(lt*lt+Pe*Pe),Ft=ft.querySelector(".match-line__hipotenuse");Ft.style.setProperty("width",`${Ye}px`);const Pt=Math.atan(Pe/lt),Ie=ye?Pt*(180/Math.PI):-Pt*(180/Math.PI);Ft.style.setProperty("transform",`rotate(${Ie}deg)`)}})},[u.items]);React$2.useEffect(()=>(Me(),window.addEventListener("resize",Me),()=>{window.removeEventListener("resize",Me)}),[Me]);const Le=React$2.useMemo(()=>{let Oe="";return Oe="match ",S!=null&&S.url&&(Oe+="match--with-custom-bg"),Oe},[S==null?void 0:S.url]),Ke={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:Le,style:Ke,children:[(f||T>0)&&jsxRuntimeExports.jsxs("header",{className:"match__header",children:[jsxRuntimeExports.jsx("div",{}),f&&jsxRuntimeExports.jsx("div",{className:"match__title","data-testid":"match__title",children:HTMLReactParser$1(f)}),T>0&&jsxRuntimeExports.jsx(CountdownTimer,{initialSeconds:T,isPaused:ge,shouldStart:Te,shouldReset:Ne,onTimeOver:st})]}),jsxRuntimeExports.jsx("div",{className:"match__columns",children:jsxRuntimeExports.jsxs("div",{className:"match__columns-scroll",children:[jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[u.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(u.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:u.items.map(Oe=>jsxRuntimeExports.jsxs("button",{id:Oe.id,"data-testid":Oe.id,className:["unset-button match-button",y===Oe.id&&"match-button--marked",H(Oe.id,Oe.matchDestinationId)&&"match-button--success",W(Oe.id,Oe.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(Oe.id,Oe.matchDestinationId)+1})`},disabled:H(Oe.id,Oe.matchDestinationId),type:"button",onClick:()=>re(Oe),children:[jsxRuntimeExports.jsx(MatchItem,{item:Oe,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"match-line__hipotenuse"})]},Oe.id))})]}),jsxRuntimeExports.jsxs("div",{className:"match__column-wrap",children:[p.title&&jsxRuntimeExports.jsx("div",{className:"match__subtitle",children:HTMLReactParser$1(p.title)}),jsxRuntimeExports.jsx("div",{className:"match__column",children:p.items.map(Oe=>jsxRuntimeExports.jsxs("button",{id:Oe.id,"data-testid":Oe.id,className:["unset-button match-button",y===Oe.id&&"match-button--marked",H(Oe.matchSourceId,Oe.id)&&"match-button--success",W(Oe.matchSourceId,Oe.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${W(Oe.matchSourceId,Oe.id)+1})`},disabled:H(Oe.matchSourceId,Oe.id),type:"button",onClick:()=>re(Oe),children:[jsxRuntimeExports.jsx(MatchItem,{item:Oe,viewMode:h}),jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black color--success"}),jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black color--error"})]},Oe.id))})]})]})})]}),T>0&&V&&jsxRuntimeExports.jsx(CountDownDialog,{buttonLabel:Y,translate:g,onClose:ce}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:D,text:k,hasTimeout:!k,translate:g,timeExpired:le,functionOnClose:pe,keyboardControl:x})]})}exports.AnimationComponent=MultipleAnimation;exports.AutoEvaluationComponent=AutoEvaluation;exports.CardsSelectorPuzzleComponent=CardsSelectorPuzzleComponent;exports.CartelComponent=CartelComponent;exports.ChainedImageClickPuzzleComponent=ChainedImageClickPuzzleComponent;exports.ChangeCamera=ChangeCamera;exports.ComicComponent=ComicComponent;exports.ConversationalComponent=ConversationalComponent;exports.ConversationalProComponent=ConversationalProComponent;exports.CrackerPuzzleComponent=CrackerPuzzleComponent;exports.DecisionComponent=DecisionComponent;exports.DialogComponent=DialogComponent;exports.DragItemPuzzleComponent=DragItemPuzzleComponent;exports.DragToSceneComponent=DragToSceneComponent;exports.FrameImageClickComponent=FrameImageClickComponent;exports.HackerPuzzleComponent=HackerPuzzleComponent;exports.HangedPuzzleComponent=HangedPuzzleComponent;exports.ImageClickPuzzleComponent=ImageClickPuzzleComponent;exports.ImageComponent=ImageComponent;exports.InventoryItem=InventoryItem;exports.KeyboardPuzzleComponent=KeyboardPuzzleComponent;exports.LecturesComponent=LecturesComponent;exports.LoginPuzzleComponent=LoginPuzzleComponent;exports.MatchPuzzleComponent=MatchPuzzleComponent;exports.NoticeComponent=NoticeComponent;exports.PatternComponent=PatternComponent;exports.PdfComponent=PdfComponent;exports.PdfVisor=PdfVisor;exports.ReferralComponent=ReferralComponent;exports.SurveyComponent=SurveyComponent;exports.TerminalPuzzleComponent=TerminalPuzzleComponent;exports.TestComponent=TestComponent;exports.TextClickPuzzleComponent=TextClickPuzzleComponent;exports.UrlComponent=UrlComponent;exports.VideoComponent=VideoComponent;exports.VideoVisor=VideoVisor;exports.WebBuilderPuzzleComponent=WebBuilderPuzzleComponent;exports.WriterPuzzleComponent=WriterPuzzleComponent;
275
275
  //# sourceMappingURL=arcade-components.cjs.map