@gamelearn/arcade-components 3.45.6 → 3.45.7
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.
|
@@ -359,7 +359,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
|
359
359
|
*/var gz,h0,Y_,s7,vg,vz,o7,zet=function(){return typeof window<"u"},ef={},dg=180/Math.PI,K_=Math.PI/180,E_=Math.atan2,yz=1e8,l7=/([A-Z])/g,Bet=/(left|right|width|margin|padding|x)/i,Fet=/[\s,\(]\S/,ud={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},GN=function(t,e){return e.set(e.t,e.p,Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},ket=function(t,e){return e.set(e.t,e.p,t===1?e.e:Math.round((e.s+e.c*t)*1e4)/1e4+e.u,e)},Iet=function(t,e){return e.set(e.t,e.p,t?Math.round((e.s+e.c*t)*1e4)/1e4+e.u:e.b,e)},Uet=function(t,e){var n=e.s+e.c*t;e.set(e.t,e.p,~~(n+(n<0?-.5:.5))+e.u,e)},IU=function(t,e){return e.set(e.t,e.p,t?e.e:e.b,e)},UU=function(t,e){return e.set(e.t,e.p,t!==1?e.b:e.e,e)},Het=function(t,e,n){return t.style[e]=n},Get=function(t,e,n){return t.style.setProperty(e,n)},Vet=function(t,e,n){return t._gsap[e]=n},Yet=function(t,e,n){return t._gsap.scaleX=t._gsap.scaleY=n},Ket=function(t,e,n,i,r){var o=t._gsap;o.scaleX=o.scaleY=n,o.renderTransform(r,o)},Xet=function(t,e,n,i,r){var o=t._gsap;o[e]=n,o.renderTransform(r,o)},Vi="transform",no=Vi+"Origin",qet=function u(t,e){var n=this,i=this.target,r=i.style,o=i._gsap;if(t in ef&&r){if(this.tfm=this.tfm||{},t!=="transform")t=ud[t]||t,~t.indexOf(",")?t.split(",").forEach(function(l){return n.tfm[l]=fh(i,l)}):this.tfm[t]=o.x?o[t]:fh(i,t),t===no&&(this.tfm.zOrigin=o.zOrigin);else return ud.transform.split(",").forEach(function(l){return u.call(n,l,e)});if(this.props.indexOf(Vi)>=0)return;o.svg&&(this.svgo=i.getAttribute("data-svg-origin"),this.props.push(no,e,"")),t=Vi}(r||e)&&this.props.push(t,e,r[t])},HU=function(t){t.translate&&(t.removeProperty("translate"),t.removeProperty("scale"),t.removeProperty("rotate"))},Qet=function(){var t=this.props,e=this.target,n=e.style,i=e._gsap,r,o;for(r=0;r<t.length;r+=3)t[r+1]?e[t[r]]=t[r+2]:t[r+2]?n[t[r]]=t[r+2]:n.removeProperty(t[r].substr(0,2)==="--"?t[r]:t[r].replace(l7,"-$1").toLowerCase());if(this.tfm){for(o in this.tfm)i[o]=this.tfm[o];i.svg&&(i.renderTransform(),e.setAttribute("data-svg-origin",this.svgo||"")),r=o7(),(!r||!r.isStart)&&!n[Vi]&&(HU(n),i.zOrigin&&n[no]&&(n[no]+=" "+i.zOrigin+"px",i.zOrigin=0,i.renderTransform()),i.uncache=1)}},GU=function(t,e){var n={target:t,props:[],revert:Qet,save:qet};return t._gsap||io.core.getCache(t),e&&e.split(",").forEach(function(i){return n.save(i)}),n},VU,VN=function(t,e){var n=h0.createElementNS?h0.createElementNS((e||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),t):h0.createElement(t);return n&&n.style?n:h0.createElement(t)},cd=function u(t,e,n){var i=getComputedStyle(t);return i[e]||i.getPropertyValue(e.replace(l7,"-$1").toLowerCase())||i.getPropertyValue(e)||!n&&u(t,n2(e)||e,1)||""},_z="O,Moz,ms,Ms,Webkit".split(","),n2=function(t,e,n){var i=e||vg,r=i.style,o=5;if(t in r&&!n)return t;for(t=t.charAt(0).toUpperCase()+t.substr(1);o--&&!(_z[o]+t in r););return o<0?null:(o===3?"ms":o>=0?_z[o]:"")+t},YN=function(){zet()&&window.document&&(gz=window,h0=gz.document,Y_=h0.documentElement,vg=VN("div")||{style:{}},VN("div"),Vi=n2(Vi),no=Vi+"Origin",vg.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",VU=!!n2("perspective"),o7=io.core.reverting,s7=1)},BM=function u(t){var e=VN("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),n=this.parentNode,i=this.nextSibling,r=this.style.cssText,o;if(Y_.appendChild(e),e.appendChild(this),this.style.display="block",t)try{o=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=u}catch{}else this._gsapBBox&&(o=this._gsapBBox());return n&&(i?n.insertBefore(this,i):n.appendChild(this)),Y_.removeChild(e),this.style.cssText=r,o},bz=function(t,e){for(var n=e.length;n--;)if(t.hasAttribute(e[n]))return t.getAttribute(e[n])},YU=function(t){var e;try{e=t.getBBox()}catch{e=BM.call(t,!0)}return e&&(e.width||e.height)||t.getBBox===BM||(e=BM.call(t,!0)),e&&!e.width&&!e.x&&!e.y?{x:+bz(t,["x","cx","x1"])||0,y:+bz(t,["y","cy","y1"])||0,width:0,height:0}:e},KU=function(t){return!!(t.getCTM&&(!t.parentNode||t.ownerSVGElement)&&YU(t))},ey=function(t,e){if(e){var n=t.style,i;e in ef&&e!==no&&(e=Vi),n.removeProperty?(i=e.substr(0,2),(i==="ms"||e.substr(0,6)==="webkit")&&(e="-"+e),n.removeProperty(i==="--"?e:e.replace(l7,"-$1").toLowerCase())):n.removeAttribute(e)}},f0=function(t,e,n,i,r,o){var l=new eo(t._pt,e,n,0,1,o?UU:IU);return t._pt=l,l.b=i,l.e=r,t._props.push(n),l},Sz={deg:1,rad:1,turn:1},Wet={grid:1,flex:1},x0=function u(t,e,n,i){var r=parseFloat(n)||0,o=(n+"").trim().substr((r+"").length)||"px",l=vg.style,c=Bet.test(e),d=t.tagName.toLowerCase()==="svg",f=(d?"client":"offset")+(c?"Width":"Height"),m=100,_=i==="px",g=i==="%",S,y,x,T;if(i===o||!r||Sz[i]||Sz[o])return r;if(o!=="px"&&!_&&(r=u(t,e,n,"px")),T=t.getCTM&&KU(t),(g||o==="%")&&(ef[e]||~e.indexOf("adius")))return S=T?t.getBBox()[c?"width":"height"]:t[f],va(g?r/S*m:r/100*S);if(l[c?"width":"height"]=m+(_?o:i),y=~e.indexOf("adius")||i==="em"&&t.appendChild&&!d?t:t.parentNode,T&&(y=(t.ownerSVGElement||{}).parentNode),(!y||y===h0||!y.appendChild)&&(y=h0.body),x=y._gsap,x&&g&&x.width&&c&&x.time===Zo.time&&!x.uncache)return va(r/x.width*m);if(g&&(e==="height"||e==="width")){var A=t.style[e];t.style[e]=m+i,S=t[f],A?t.style[e]=A:ey(t,e)}else(g||o==="%")&&!Wet[cd(y,"display")]&&(l.position=cd(t,"position")),y===t&&(l.position="static"),y.appendChild(vg),S=vg[f],y.removeChild(vg),l.position="absolute";return c&&g&&(x=Kv(y),x.time=Zo.time,x.width=y[f]),va(_?S*r/m:S&&r?m/S*r:0)},fh=function(t,e,n,i){var r;return s7||YN(),e in ud&&e!=="transform"&&(e=ud[e],~e.indexOf(",")&&(e=e.split(",")[0])),ef[e]&&e!=="transform"?(r=aT(t,i),r=e!=="transformOrigin"?r[e]:r.svg?r.origin:L5(cd(t,no))+" "+r.zOrigin+"px"):(r=t.style[e],(!r||r==="auto"||i||~(r+"").indexOf("calc("))&&(r=N5[e]&&N5[e](t,e,n)||cd(t,e)||lU(t,e)||(e==="opacity"?1:0))),n&&!~(r+"").trim().indexOf(" ")?x0(t,e,r,n)+n:r},Zet=function(t,e,n,i){if(!n||n==="none"){var r=n2(e,t,1),o=r&&cd(t,r,1);o&&o!==n?(e=r,n=o):e==="borderColor"&&(n=cd(t,"borderTopColor"))}var l=new eo(this._pt,t.style,e,0,1,BU),c=0,d=0,f,m,_,g,S,y,x,T,A,E,C,R;if(l.b=n,l.e=i,n+="",i+="",i==="auto"&&(y=t.style[e],t.style[e]=i,i=cd(t,e)||i,y?t.style[e]=y:ey(t,e)),f=[n,i],RU(f),n=f[0],i=f[1],_=n.match(j_)||[],R=i.match(j_)||[],R.length){for(;m=j_.exec(i);)x=m[0],A=i.substring(c,m.index),S?S=(S+1)%5:(A.substr(-5)==="rgba("||A.substr(-5)==="hsla(")&&(S=1),x!==(y=_[d++]||"")&&(g=parseFloat(y)||0,C=y.substr((g+"").length),x.charAt(1)==="="&&(x=V_(g,x)+C),T=parseFloat(x),E=x.substr((T+"").length),c=j_.lastIndex-E.length,E||(E=E||$o.units[e]||C,c===i.length&&(i+=E,l.e+=E)),C!==E&&(g=x0(t,e,y,E)||0),l._pt={_next:l._pt,p:A||d===1?A:",",s:g,c:T-g,m:S&&S<4||e==="zIndex"?Math.round:0});l.c=c<i.length?i.substring(c,i.length):""}else l.r=e==="display"&&i==="none"?UU:IU;return nU.test(i)&&(l.e=0),this._pt=l,l},xz={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},Jet=function(t){var e=t.split(" "),n=e[0],i=e[1]||"50%";return(n==="top"||n==="bottom"||i==="left"||i==="right")&&(t=n,n=i,i=t),e[0]=xz[n]||n,e[1]=xz[i]||i,e.join(" ")},$et=function(t,e){if(e.tween&&e.tween._time===e.tween._dur){var n=e.t,i=n.style,r=e.u,o=n._gsap,l,c,d;if(r==="all"||r===!0)i.cssText="",c=1;else for(r=r.split(","),d=r.length;--d>-1;)l=r[d],ef[l]&&(c=1,l=l==="transformOrigin"?no:Vi),ey(n,l);c&&(ey(n,Vi),o&&(o.svg&&n.removeAttribute("transform"),aT(n,1),o.uncache=1,HU(i)))}},N5={clearProps:function(t,e,n,i,r){if(r.data!=="isFromStart"){var o=t._pt=new eo(t._pt,e,n,0,0,$et);return o.u=i,o.pr=-10,o.tween=r,t._props.push(n),1}}},iT=[1,0,0,1,0,0],XU={},qU=function(t){return t==="matrix(1, 0, 0, 1, 0, 0)"||t==="none"||!t},Ez=function(t){var e=cd(t,Vi);return qU(e)?iT:e.substr(7).match(eU).map(va)},u7=function(t,e){var n=t._gsap||Kv(t),i=t.style,r=Ez(t),o,l,c,d;return n.svg&&t.getAttribute("transform")?(c=t.transform.baseVal.consolidate().matrix,r=[c.a,c.b,c.c,c.d,c.e,c.f],r.join(",")==="1,0,0,1,0,0"?iT:r):(r===iT&&!t.offsetParent&&t!==Y_&&!n.svg&&(c=i.display,i.display="block",o=t.parentNode,(!o||!t.offsetParent)&&(d=1,l=t.nextElementSibling,Y_.appendChild(t)),r=Ez(t),c?i.display=c:ey(t,"display"),d&&(l?o.insertBefore(t,l):o?o.appendChild(t):Y_.removeChild(t))),e&&r.length>6?[r[0],r[1],r[4],r[5],r[12],r[13]]:r)},KN=function(t,e,n,i,r,o){var l=t._gsap,c=r||u7(t,!0),d=l.xOrigin||0,f=l.yOrigin||0,m=l.xOffset||0,_=l.yOffset||0,g=c[0],S=c[1],y=c[2],x=c[3],T=c[4],A=c[5],E=e.split(" "),C=parseFloat(E[0])||0,R=parseFloat(E[1])||0,N,M,O,z;n?c!==iT&&(M=g*x-S*y)&&(O=C*(x/M)+R*(-y/M)+(y*A-x*T)/M,z=C*(-S/M)+R*(g/M)-(g*A-S*T)/M,C=O,R=z):(N=YU(t),C=N.x+(~E[0].indexOf("%")?C/100*N.width:C),R=N.y+(~(E[1]||E[0]).indexOf("%")?R/100*N.height:R)),i||i!==!1&&l.smooth?(T=C-d,A=R-f,l.xOffset=m+(T*g+A*y)-T,l.yOffset=_+(T*S+A*x)-A):l.xOffset=l.yOffset=0,l.xOrigin=C,l.yOrigin=R,l.smooth=!!i,l.origin=e,l.originIsAbsolute=!!n,t.style[no]="0px 0px",o&&(f0(o,l,"xOrigin",d,C),f0(o,l,"yOrigin",f,R),f0(o,l,"xOffset",m,l.xOffset),f0(o,l,"yOffset",_,l.yOffset)),t.setAttribute("data-svg-origin",C+" "+R)},aT=function(t,e){var n=t._gsap||new OU(t);if("x"in n&&!e&&!n.uncache)return n;var i=t.style,r=n.scaleX<0,o="px",l="deg",c=getComputedStyle(t),d=cd(t,no)||"0",f,m,_,g,S,y,x,T,A,E,C,R,N,M,O,z,L,k,I,H,Q,Z,X,$,nt,W,tt,rt,ut,st,ot,dt;return f=m=_=y=x=T=A=E=C=0,g=S=1,n.svg=!!(t.getCTM&&KU(t)),c.translate&&((c.translate!=="none"||c.scale!=="none"||c.rotate!=="none")&&(i[Vi]=(c.translate!=="none"?"translate3d("+(c.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(c.rotate!=="none"?"rotate("+c.rotate+") ":"")+(c.scale!=="none"?"scale("+c.scale.split(" ").join(",")+") ":"")+(c[Vi]!=="none"?c[Vi]:"")),i.scale=i.rotate=i.translate="none"),M=u7(t,n.svg),n.svg&&(n.uncache?(nt=t.getBBox(),d=n.xOrigin-nt.x+"px "+(n.yOrigin-nt.y)+"px",$=""):$=!e&&t.getAttribute("data-svg-origin"),KN(t,$||d,!!$||n.originIsAbsolute,n.smooth!==!1,M)),R=n.xOrigin||0,N=n.yOrigin||0,M!==iT&&(k=M[0],I=M[1],H=M[2],Q=M[3],f=Z=M[4],m=X=M[5],M.length===6?(g=Math.sqrt(k*k+I*I),S=Math.sqrt(Q*Q+H*H),y=k||I?E_(I,k)*dg:0,A=H||Q?E_(H,Q)*dg+y:0,A&&(S*=Math.abs(Math.cos(A*K_))),n.svg&&(f-=R-(R*k+N*H),m-=N-(R*I+N*Q))):(dt=M[6],st=M[7],tt=M[8],rt=M[9],ut=M[10],ot=M[11],f=M[12],m=M[13],_=M[14],O=E_(dt,ut),x=O*dg,O&&(z=Math.cos(-O),L=Math.sin(-O),$=Z*z+tt*L,nt=X*z+rt*L,W=dt*z+ut*L,tt=Z*-L+tt*z,rt=X*-L+rt*z,ut=dt*-L+ut*z,ot=st*-L+ot*z,Z=$,X=nt,dt=W),O=E_(-H,ut),T=O*dg,O&&(z=Math.cos(-O),L=Math.sin(-O),$=k*z-tt*L,nt=I*z-rt*L,W=H*z-ut*L,ot=Q*L+ot*z,k=$,I=nt,H=W),O=E_(I,k),y=O*dg,O&&(z=Math.cos(O),L=Math.sin(O),$=k*z+I*L,nt=Z*z+X*L,I=I*z-k*L,X=X*z-Z*L,k=$,Z=nt),x&&Math.abs(x)+Math.abs(y)>359.9&&(x=y=0,T=180-T),g=va(Math.sqrt(k*k+I*I+H*H)),S=va(Math.sqrt(X*X+dt*dt)),O=E_(Z,X),A=Math.abs(O)>2e-4?O*dg:0,C=ot?1/(ot<0?-ot:ot):0),n.svg&&($=t.getAttribute("transform"),n.forceCSS=t.setAttribute("transform","")||!qU(cd(t,Vi)),$&&t.setAttribute("transform",$))),Math.abs(A)>90&&Math.abs(A)<270&&(r?(g*=-1,A+=y<=0?180:-180,y+=y<=0?180:-180):(S*=-1,A+=A<=0?180:-180)),e=e||n.uncache,n.x=f-((n.xPercent=f&&(!e&&n.xPercent||(Math.round(t.offsetWidth/2)===Math.round(-f)?-50:0)))?t.offsetWidth*n.xPercent/100:0)+o,n.y=m-((n.yPercent=m&&(!e&&n.yPercent||(Math.round(t.offsetHeight/2)===Math.round(-m)?-50:0)))?t.offsetHeight*n.yPercent/100:0)+o,n.z=_+o,n.scaleX=va(g),n.scaleY=va(S),n.rotation=va(y)+l,n.rotationX=va(x)+l,n.rotationY=va(T)+l,n.skewX=A+l,n.skewY=E+l,n.transformPerspective=C+o,(n.zOrigin=parseFloat(d.split(" ")[2])||!e&&n.zOrigin||0)&&(i[no]=L5(d)),n.xOffset=n.yOffset=0,n.force3D=$o.force3D,n.renderTransform=n.svg?ent:VU?QU:tnt,n.uncache=0,n},L5=function(t){return(t=t.split(" "))[0]+" "+t[1]},FM=function(t,e,n){var i=ns(e);return va(parseFloat(e)+parseFloat(x0(t,"x",n+"px",i)))+i},tnt=function(t,e){e.z="0px",e.rotationY=e.rotationX="0deg",e.force3D=0,QU(t,e)},rg="0deg",uE="0px",sg=") ",QU=function(t,e){var n=e||this,i=n.xPercent,r=n.yPercent,o=n.x,l=n.y,c=n.z,d=n.rotation,f=n.rotationY,m=n.rotationX,_=n.skewX,g=n.skewY,S=n.scaleX,y=n.scaleY,x=n.transformPerspective,T=n.force3D,A=n.target,E=n.zOrigin,C="",R=T==="auto"&&t&&t!==1||T===!0;if(E&&(m!==rg||f!==rg)){var N=parseFloat(f)*K_,M=Math.sin(N),O=Math.cos(N),z;N=parseFloat(m)*K_,z=Math.cos(N),o=FM(A,o,M*z*-E),l=FM(A,l,-Math.sin(N)*-E),c=FM(A,c,O*z*-E+E)}x!==uE&&(C+="perspective("+x+sg),(i||r)&&(C+="translate("+i+"%, "+r+"%) "),(R||o!==uE||l!==uE||c!==uE)&&(C+=c!==uE||R?"translate3d("+o+", "+l+", "+c+") ":"translate("+o+", "+l+sg),d!==rg&&(C+="rotate("+d+sg),f!==rg&&(C+="rotateY("+f+sg),m!==rg&&(C+="rotateX("+m+sg),(_!==rg||g!==rg)&&(C+="skew("+_+", "+g+sg),(S!==1||y!==1)&&(C+="scale("+S+", "+y+sg),A.style[Vi]=C||"translate(0, 0)"},ent=function(t,e){var n=e||this,i=n.xPercent,r=n.yPercent,o=n.x,l=n.y,c=n.rotation,d=n.skewX,f=n.skewY,m=n.scaleX,_=n.scaleY,g=n.target,S=n.xOrigin,y=n.yOrigin,x=n.xOffset,T=n.yOffset,A=n.forceCSS,E=parseFloat(o),C=parseFloat(l),R,N,M,O,z;c=parseFloat(c),d=parseFloat(d),f=parseFloat(f),f&&(f=parseFloat(f),d+=f,c+=f),c||d?(c*=K_,d*=K_,R=Math.cos(c)*m,N=Math.sin(c)*m,M=Math.sin(c-d)*-_,O=Math.cos(c-d)*_,d&&(f*=K_,z=Math.tan(d-f),z=Math.sqrt(1+z*z),M*=z,O*=z,f&&(z=Math.tan(f),z=Math.sqrt(1+z*z),R*=z,N*=z)),R=va(R),N=va(N),M=va(M),O=va(O)):(R=m,O=_,N=M=0),(E&&!~(o+"").indexOf("px")||C&&!~(l+"").indexOf("px"))&&(E=x0(g,"x",o,"px"),C=x0(g,"y",l,"px")),(S||y||x||T)&&(E=va(E+S-(S*R+y*M)+x),C=va(C+y-(S*N+y*O)+T)),(i||r)&&(z=g.getBBox(),E=va(E+i/100*z.width),C=va(C+r/100*z.height)),z="matrix("+R+","+N+","+M+","+O+","+E+","+C+")",g.setAttribute("transform",z),A&&(g.style[Vi]=z)},nnt=function(t,e,n,i,r){var o=360,l=fr(r),c=parseFloat(r)*(l&&~r.indexOf("rad")?dg:1),d=c-i,f=i+d+"deg",m,_;return l&&(m=r.split("_")[1],m==="short"&&(d%=o,d!==d%(o/2)&&(d+=d<0?o:-o)),m==="cw"&&d<0?d=(d+o*yz)%o-~~(d/o)*o:m==="ccw"&&d>0&&(d=(d-o*yz)%o-~~(d/o)*o)),t._pt=_=new eo(t._pt,e,n,i,d,ket),_.e=f,_.u="deg",t._props.push(n),_},Tz=function(t,e){for(var n in e)t[n]=e[n];return t},int=function(t,e,n){var i=Tz({},n._gsap),r="perspective,force3D,transformOrigin,svgOrigin",o=n.style,l,c,d,f,m,_,g,S;i.svg?(d=n.getAttribute("transform"),n.setAttribute("transform",""),o[Vi]=e,l=aT(n,1),ey(n,Vi),n.setAttribute("transform",d)):(d=getComputedStyle(n)[Vi],o[Vi]=e,l=aT(n,1),o[Vi]=d);for(c in ef)d=i[c],f=l[c],d!==f&&r.indexOf(c)<0&&(g=ns(d),S=ns(f),m=g!==S?x0(n,c,d,S):parseFloat(d),_=parseFloat(f),t._pt=new eo(t._pt,l,c,m,_-m,GN),t._pt.u=S||0,t._props.push(c));Tz(l,i)};to("padding,margin,Width,Radius",function(u,t){var e="Top",n="Right",i="Bottom",r="Left",o=(t<3?[e,n,i,r]:[e+r,e+n,i+n,i+r]).map(function(l){return t<2?u+l:"border"+l+u});N5[t>1?"border"+u:u]=function(l,c,d,f,m){var _,g;if(arguments.length<4)return _=o.map(function(S){return fh(l,S,d)}),g=_.join(" "),g.split(_[0]).length===5?_[0]:g;_=(f+"").split(" "),g={},o.forEach(function(S,y){return g[S]=_[y]=_[y]||_[(y-1)/2|0]}),l.init(c,g,m)}});var WU={name:"css",register:YN,targetTest:function(t){return t.style&&t.nodeType},init:function(t,e,n,i,r){var o=this._props,l=t.style,c=n.vars.startAt,d,f,m,_,g,S,y,x,T,A,E,C,R,N,M,O;s7||YN(),this.styles=this.styles||GU(t),O=this.styles.props,this.tween=n;for(y in e)if(y!=="autoRound"&&(f=e[y],!(Qo[y]&&NU(y,e,n,i,t,r)))){if(g=typeof f,S=N5[y],g==="function"&&(f=f.call(n,i,t,r),g=typeof f),g==="string"&&~f.indexOf("random(")&&(f=tT(f)),S)S(this,t,y,f,n)&&(M=1);else if(y.substr(0,2)==="--")d=(getComputedStyle(t).getPropertyValue(y)+"").trim(),f+="",m0.lastIndex=0,m0.test(d)||(x=ns(d),T=ns(f)),T?x!==T&&(d=x0(t,y,d,T)+T):x&&(f+=x),this.add(l,"setProperty",d,f,i,r,0,0,y),o.push(y),O.push(y,0,l[y]);else if(g!=="undefined"){if(c&&y in c?(d=typeof c[y]=="function"?c[y].call(n,i,t,r):c[y],fr(d)&&~d.indexOf("random(")&&(d=tT(d)),ns(d+"")||d==="auto"||(d+=$o.units[y]||ns(fh(t,y))||""),(d+"").charAt(1)==="="&&(d=fh(t,y))):d=fh(t,y),_=parseFloat(d),A=g==="string"&&f.charAt(1)==="="&&f.substr(0,2),A&&(f=f.substr(2)),m=parseFloat(f),y in ud&&(y==="autoAlpha"&&(_===1&&fh(t,"visibility")==="hidden"&&m&&(_=0),O.push("visibility",0,l.visibility),f0(this,l,"visibility",_?"inherit":"hidden",m?"inherit":"hidden",!m)),y!=="scale"&&y!=="transform"&&(y=ud[y],~y.indexOf(",")&&(y=y.split(",")[0]))),E=y in ef,E){if(this.styles.save(y),C||(R=t._gsap,R.renderTransform&&!e.parseTransform||aT(t,e.parseTransform),N=e.smoothOrigin!==!1&&R.smooth,C=this._pt=new eo(this._pt,l,Vi,0,1,R.renderTransform,R,0,-1),C.dep=1),y==="scale")this._pt=new eo(this._pt,R,"scaleY",R.scaleY,(A?V_(R.scaleY,A+m):m)-R.scaleY||0,GN),this._pt.u=0,o.push("scaleY",y),y+="X";else if(y==="transformOrigin"){O.push(no,0,l[no]),f=Jet(f),R.svg?KN(t,f,0,N,0,this):(T=parseFloat(f.split(" ")[2])||0,T!==R.zOrigin&&f0(this,R,"zOrigin",R.zOrigin,T),f0(this,l,y,L5(d),L5(f)));continue}else if(y==="svgOrigin"){KN(t,f,1,N,0,this);continue}else if(y in XU){nnt(this,R,y,_,A?V_(_,A+f):f);continue}else if(y==="smoothOrigin"){f0(this,R,"smooth",R.smooth,f);continue}else if(y==="force3D"){R[y]=f;continue}else if(y==="transform"){int(this,f,t);continue}}else y in l||(y=n2(y)||y);if(E||(m||m===0)&&(_||_===0)&&!Fet.test(f)&&y in l)x=(d+"").substr((_+"").length),m||(m=0),T=ns(f)||(y in $o.units?$o.units[y]:x),x!==T&&(_=x0(t,y,d,T)),this._pt=new eo(this._pt,E?R:l,y,_,(A?V_(_,A+m):m)-_,!E&&(T==="px"||y==="zIndex")&&e.autoRound!==!1?Uet:GN),this._pt.u=T||0,x!==T&&T!=="%"&&(this._pt.b=d,this._pt.r=Iet);else if(y in l)Zet.call(this,t,y,d,A?A+f:f);else if(y in t)this.add(t,y,d||t[y],A?A+f:f,i,r);else if(y!=="parseTransform"){Z9(y,f);continue}E||(y in l?O.push(y,0,l[y]):O.push(y,1,d||t[y])),o.push(y)}}M&&FU(this)},render:function(t,e){if(e.tween._time||!o7())for(var n=e._pt;n;)n.r(t,n.d),n=n._next;else e.styles.revert()},get:fh,aliases:ud,getSetter:function(t,e,n){var i=ud[e];return i&&i.indexOf(",")<0&&(e=i),e in ef&&e!==no&&(t._gsap.x||fh(t,"x"))?n&&vz===n?e==="scale"?Yet:Vet:(vz=n||{})&&(e==="scale"?Ket:Xet):t.style&&!q9(t.style[e])?Het:~e.indexOf("-")?Get:a7(t,e)},core:{_removeProperty:ey,_getMatrix:u7}};io.utils.checkPrefix=n2;io.core.getStyleSaver=GU;(function(u,t,e,n){var i=to(u+","+t+","+e,function(r){ef[r]=1});to(t,function(r){$o.units[r]="deg",XU[r]=1}),ud[i[13]]=u+","+t,to(n,function(r){var o=r.split(":");ud[o[1]]=i[o[0]]})})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");to("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(u){$o.units[u]="px"});io.registerPlugin(WU);var ZU=io.registerPlugin(WU)||io;ZU.core.Tween;function ant({message:u,translate:t},e){const[n,i]=G.useState(!1),r=()=>{const o=u.avatar,l=o.lastIndexOf("/");return o.includes("/object/")?o.slice(0,l).concat("/mini-thumbnail.png"):o.includes("/character/")?o.slice(0,l).concat("/mini-face.png"):o};return G.useLayoutEffect(()=>{n||i(!0)},[n]),P.jsxs("div",{dir:"auto",ref:e,className:`
|
|
360
360
|
speech-bubble
|
|
361
361
|
${u.thinkful?"speech-bubble--italic":""}
|
|
362
|
-
`,children:[P.jsxs("div",{className:`speech-bubble__header ${u.thinkful?"speech-bubble__header--thinking":""}`,children:[u.thinkful?P.jsx("div",{className:"thinking-icon-wrap",children:P.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,u.avatar?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("img",{src:r(),alt:u.name})}):null,u.voiceOver?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("div",{className:"icon-narrator"})}):null,P.jsxs("div",{className:"speech-bubble__name",children:[P.jsx("span",{children:u.name}),u.thinkful?P.jsxs("span",{children:["[ ",t("emotion.thinking")," ]"]}):null]})]}),u.text?P.jsx("div",{className:"speech-bubble__text",children:Si(u.text)}):null]})}const rnt=G.forwardRef(ant);function snt({currentMessage:u,translate:t}){const e=document.querySelector(".screens--container");return P.jsx("group",{children:P.jsx(Oa.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:e?{current:e}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:P.jsx(rnt,{translate:t,message:u})})})}const Az=75,_R=1400,ont=2,XN=new ra.Raycaster,og=new ra.Object3D,lnt=70;XN.firstHitOnly=!0;function unt({keyboardControl:u,emitEvent:t,getEvent:e,lines:n,actors:i,edges:r,soundActions:o,zoomInActor:l,autoPlay:c,autoEnd:d,pause:f,progress:m}){var ze;const _=n.length-1<=(m==null?void 0:m.line)?n.length-1:(m==null?void 0:m.line)||0,[g,S]=G.useState(_),[y,x]=G.useState(!!c),[T,A]=G.useState(!1),[E,C]=G.useState(!1),R=g0.useThree(zt=>zt.scene),N=g0.useThree(zt=>zt.camera),{start:M,stop:O}=Tw(),z=G.useRef([]),L=G.useMemo(()=>N.clone(),[]),k=G.useRef({pos:[0,0,0],child:null}),I=n[g],H=n[g-1],Q=G.useRef(!1),Z=!!r,{voiceOver:X,decision:$}=I||{},nt=G.useRef({}),W=(ze=I==null?void 0:I.slots)==null?void 0:ze.find(zt=>zt.talking),tt=G.useRef(!1),{playAnimation:rt,stopSpeech:ut,startSpeech:st,getMachine:ot}=Fk();G.useRef();const dt=G.useRef({}),vt=Object.keys((I==null?void 0:I.audio)||{}).length,it=Object.keys((I==null?void 0:I.voice)||{}).length,ht=X||(I==null?void 0:I.type)==="conversationalNarration",lt=$||(I==null?void 0:I.type)==="conversationalDecision",xt=(I==null?void 0:I.type)==="conversationalCamera",yt=y&&!lt&&!xt,[pt,bt]=G.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Tt=G.useMemo(()=>{const zt=new Set;for(const Kt of n)if(Kt.slots)for(const Xt of Kt.slots)Xt.uid&&zt.add(Xt.uid);return Array.from(zt)},[n]),Ct=G.useCallback(zt=>e({type:"translate",payload:zt}),[e]),[kt,It]=G.useState([]),$t=G.useMemo(()=>kt[kt.length-1],[kt]),ie=G.useCallback(()=>{const zt=r.find(Xt=>Xt.fromId===$t)||r.find(Xt=>Xt.toId===$t),Kt=n.find(Xt=>Xt.id===(zt==null?void 0:zt.fromId));return!$t&&(m==null?void 0:m.line)>=0?{decision:!0}:Kt},[r,n,$t]),Te=G.useCallback(()=>{if(Z){const zt=n.filter(Kt=>!r.find(Xt=>Xt.toId===Kt.id));if(zt.length){const Kt=zt[0],Xt=n.indexOf(Kt);if(Xt>=0)return Xt}}return-1},[Z,n,r]),$e=G.useCallback(()=>{if(Z){const Kt=ie();return Kt==null?void 0:Kt.decision}const zt=n[g-1]?n[g-1]:{};return g>0&&(zt==null?void 0:zt.decision)},[I,Z,n,$t,r]),Ce=G.useCallback(()=>{if(Z){const Kt=ie();return(Kt==null?void 0:Kt.type)==="conversationalCamera"}const zt=n[g-1]?n[g-1]:{};return g>0&&(zt==null?void 0:zt.type)==="conversationalCamera"},[I,Z,n,$t,r]),xe=G.useCallback(zt=>{var Xt,Le;const Kt=i.find(De=>(De==null?void 0:De.uid)===(zt==null?void 0:zt.uid)?De:"");return((Le=(Xt=zt==null?void 0:zt.character)==null?void 0:Xt.resource)==null?void 0:Le.url)||(Kt==null?void 0:Kt.completeUrl)||""},[i]),xn=(zt=()=>{})=>{if(tt.current)tt.current&&(tt.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const Kt=k.current.child?k.current.pos:L.position.toArray();if(og.position.fromArray(Kt),k.current.parent){og.quaternion.equals(N.quaternion)||og.applyQuaternion(N.quaternion);const Xt=k.current.isLeft?-1:1,Le=ont*Xt;og.translateX(-10*Xt+Le),og.translateY(-2),og.translateZ(30)}ZU.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{tt.current=!0},onUpdate:()=>{z.current.length&&z.current.forEach(Xt=>{const{object:Le}=Xt;Le.material.visible=!0})},onComplete:()=>{zt(),XN.set(N.getWorldPosition(new ra.Vector3(0,0,0)),N.getWorldDirection(new ra.Vector3));const Xt=XN.intersectObjects(R.children,!0);z.current=Xt.filter(Le=>Le.distance<10),z.current.length&&z.current.forEach(Le=>{const{object:De}=Le;De.material.side=0}),tt.current=!1,Q.current&&t({type:"success"}),k.current.child||N.copy(L)},...og.position})}},fn=G.useCallback(()=>{k.current.child=null,k.current.parent=null,l&&xn()},[l]),Ft=()=>{Tt.forEach(zt=>{const Kt=ot(zt);if(!Kt)return;const Xt=Kt.getAction("tts");Xt&&Oa.ThreeUtils.setWeight(Xt,0),delete Kt.getRoot().userData._active,Kt.mix("idle",.25)})},ne=(zt,Kt,Xt,Le=!1)=>{var su,nl;const De=Kt.includes("seated");let gi=Kt;Le&&!De&&(gi+="-seated");const Nn=(su=zt.character)==null?void 0:su.resource.animations,Na=Xt?Xt.url:(nl=Nn[gi])==null?void 0:nl.url,pr=Xt&&Mz.includes(Xt.animationId),Lr=(dt.current[zt.uid]||0)+1;dt.current[zt.uid]=Lr,rt(zt.uid,Na,pr).then(md=>{if(md&&pr&&dt.current[zt.uid]===Lr){const il=ot(zt.uid);il&&il.mix("idle",.25)}})},fe=zt=>{if(!(W!=null&&W.uid)||!(W!=null&&W.emotion)||Q.current)return;const{emotion:Kt,uid:Xt,animation:Le}=W;gg(Xt,R)&&st(Xt,zt)},Lt=()=>{!(W!=null&&W.uid)||Q.current||ut(W==null?void 0:W.uid)},Yt=G.useCallback(()=>{Q.current=!0,bt({show:!1}),fn(),Ft(),l||t({type:"success"})},[N,t,fn,l]);G.useEffect(()=>()=>{nt.current={},Ft()},[]);const te=zt=>{bt({show:!1}),Ft(),S(zt),t({type:"notifyProgress",payload:{line:zt}})},je=G.useCallback((zt=!0)=>{const Kt=zt?["fromId","toId"]:["toId","fromId"],Xt=r.filter(gi=>gi[Kt[0]]===I.id),Le=Xt.length===1?Xt[0]:Xt.find(gi=>gi[Kt[1]]===$t);if(!(Le!=null&&Le[Kt[0]])){Yt();return}zt||It(kt.slice(0,kt.length-1));const De=n.findIndex(gi=>gi.id===Le[Kt[1]]);De>=0?te(De):Yt()},[I==null?void 0:I.id,t,r,Yt,n]),qe=G.useCallback((zt,Kt)=>{const Xt=[3,2,1][zt.id],De=r.filter(Nn=>Nn.fromId===(I==null?void 0:I.id)).find(Nn=>parseInt(Nn.fromPointIndex)===Xt),gi=n.findIndex(Nn=>Nn.id===(De==null?void 0:De.toId));gi>=0?(De==null?void 0:De.fromId)===(De==null?void 0:De.toId)?Kt():te(gi):Yt()},[I==null?void 0:I.id,r,Yt,n]),Gt=G.useCallback(()=>{if(nt.current={...W},C(!1),Lt(),Z)je(!1);else if(!$e()){const zt=g-1;bt({show:!1}),S(zt),t({type:"notifyProgress",payload:{line:zt}})}},[je,t,Z,H,g,W]),ee=G.useCallback(zt=>{if(Z){if(zt){const Kt=[3,2,1][zt.id],Le=r.filter(De=>De.fromId===I.id).find(De=>parseInt(De.fromPointIndex)===Kt);if(Le){const De=n.findIndex(gi=>gi.id===Le.toId);De>=0&&t({type:"notifyProgress",payload:{line:De}})}else t({type:"saveNode"})}}else if(g<n.length-1){const Kt=g+1;t({type:"notifyProgress",payload:{line:Kt}})}else t({type:"saveNode"})},[r,g,n,t,I==null?void 0:I.id,Z]),re=G.useCallback((zt,Kt)=>{if(nt.current={...W},C(!1),Lt(),Z)It([...kt,I.id]),zt?qe(zt,Kt):je();else if(g<n.length-1){const Xt=g+1;te(Xt)}else(d||lt||xt)&&Yt()},[t,I==null?void 0:I.id,Z,lt,xt,g,n.length,qe,je,Yt,W]),wn=()=>{x(!1),Gt()},oe=()=>Z?I&&I.type!=="conversationalDecision"&&!r.find(zt=>zt.fromId===I.id):g===n.length-1,pe=()=>{oe()?Yt():(x(!1),re())};G.useEffect(()=>{if(Z&&!T){const zt=m==null?void 0:m.line;if(zt>=0){A(!0),S(zt);return}const Kt=Te();Kt>=0&&(A(!0),S(Kt))}},[r,Z,n,T,Te]);const Mn=zt=>{if(nt.current.uid===zt.uid||k.current.parent===zt)return;const Kt=new ra.Object3D,Xt=zt.getObjectByName("Head_M");Xt.updateMatrixWorld(!0),Kt.applyMatrix4(Xt.matrixWorld),Kt.applyQuaternion(N.quaternion);const Le=l?2.5:2,De=l?1.2:1.5;Kt.translateY(Le),Kt.translateX(De);const gi=new ra.Vector3;gi.setFromMatrixPosition(Xt.matrixWorld);const Na=gi.project(N).x<0;k.current={pos:Kt.position.toArray(),child:Xt,parent:zt,isLeft:Na}},On=zt=>{t({type:"resetZIndexUIContainer",payload:zt})};G.useEffect(()=>{var zt;if(ht)fn(),bt({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${Ct("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:xe(W),show:!0});else if(!Q.current&&!lt&&!xt){const Kt=I==null?void 0:I.slots.filter(Xt=>Xt.uid&&!Xt.talking);if([...Kt.map(Xt=>Xt)||[]],Kt.forEach(Xt=>{const Le=gg(Xt.uid,R);if(Le){const{isSeated:De}=Le;ne(Xt,Xt.emotion,Xt.animation,De)}}),W){const Xt=gg(W.uid,R),Le=i.find(De=>De.uid===W.uid);Xt&&!Q.current?setTimeout(()=>{if(W.uid===Xt.uid){Mn(Xt);const{isSeated:De,userData:gi}=Xt,{emotion:Nn,animation:Na}=W;ne(W,Nn,Na,De);const pr=()=>{var Lr;bt({text:W.text,name:W.alias||((Lr=W.character)==null?void 0:Lr.name),inScene:!0,thinkful:W.emotion.includes("think"),avatar:xe(W),show:!0})};l?(tt.current=!1,xn(pr)):pr()}},150):(fn(),bt({text:W.text,name:W.alias||((zt=W.character)==null?void 0:zt.name)||(Le==null?void 0:Le.name),left:!1,top:W.text.length>lnt,inScene:!1,thinkful:W.emotion.includes("think"),avatar:xe(W),show:!0}))}else fn(),bt({show:!0})}},[i,I,l,R,Ct,xe,fn,lt,ht]);const qi=Hw(pt==null?void 0:pt.text),[jt]=ry({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:pt.show,text:qi,audio:I==null?void 0:I.audio,soundActions:o,getEvent:e,pauseTTS:f,onStart:(zt,Kt)=>{var Xt;(Xt=W==null?void 0:W.emotion)!=null&&Xt.includes("think")||fe(Kt.node)},onError:()=>{C(!0)},onFinish:()=>{Lt(),yt&&!f&&re()}});G.useEffect(()=>(jt(),()=>{jt()}),[g,jt]),G.useEffect(()=>{var zt;if(((I==null?void 0:I.audioType)==="none"||E)&&(pt!=null&&pt.show)&&!(W!=null&&W.emotion.includes("think"))){fe();const Kt=Az*(((zt=pt==null?void 0:pt.text)==null?void 0:zt.length)||0);setTimeout(()=>{Lt()},Kt<_R?_R:Kt)}},[E,I==null?void 0:I.audioType,Lt,fe,W==null?void 0:W.emotion,pt]),G.useEffect(()=>{var zt;if(yt&&pt.show&&((I==null?void 0:I.audioType)==="none"||E)&&!f){const Kt=Az*(((zt=pt==null?void 0:pt.text)==null?void 0:zt.length)||0);(!oe()||oe()&&d)&&M(re,Kt<_R?_R:Kt)}return()=>{O()}},[pt,re,M,d,O,I==null?void 0:I.audioType,yt,vt,it,E]);const Zt=G.useMemo(()=>Te()>=0&&kt.length===0&&Z||!Z&&g===0||$e()||Ce(),[g,$e,Ce,Te,kt]),he=u({disabled:lt||!pt.show,repeat:!1,forward:pe,rewind:Zt?null:wn});G.useEffect(()=>he(),[he]);const ye=document.querySelector(".screens--container");if(xt)return P.jsx(p9,{...I,emitEvent:t,success:!1,onFinish:re},`change-camera-${g}`);if(lt){const zt=I.id?n.filter(Xt=>Xt.decision).findIndex(Xt=>Xt.id===I.id)+1:n.filter(Xt=>Xt.decision).findIndex(Xt=>Xt===I)+1,Kt={...I.payload,decisionNumber:zt,inheritProps:{slots:[],disableBackground:!0},required:!Z,branched:Z,onAddPoints:ee,onFinish:re,emitEvent:t,getEvent:e,pause:f,soundActions:o,keyboardControl:u};return P.jsx(mN,{onMount:()=>{fn(),On(!0)},onUnMount:()=>{tt.current=!1,On(!1)},children:P.jsx(w9,{inScene:!0,...Kt})})}return P.jsxs(P.Fragment,{children:[pt.text?P.jsx(snt,{translate:Ct,currentMessage:pt}):null,P.jsx(Oa.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:ye?{current:ye}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:P.jsxs("div",{dir:Pe()?"rtl":"ltr",className:"dialog-component-controls",children:[P.jsx("button",{type:"button",onClick:wn,disabled:Zt||!pt.show,className:`gat--btn__round ${Zt||!pt.show?"disabled":""}`,"aria-label":Pe()?Ct("storylines.misc.forward"):Ct("storylines.misc.rewind"),children:P.jsx("span",{className:Pe()?"icon-next":"icon-back"})}),P.jsx("button",{type:"button",onClick:pe,disabled:!pt.show,className:`gat--btn__round
|
|
362
|
+
`,children:[P.jsxs("div",{className:`speech-bubble__header ${u.thinkful?"speech-bubble__header--thinking":""}`,children:[u.thinkful?P.jsx("div",{className:"thinking-icon-wrap",children:P.jsx("div",{className:"icon-bubble-thinkful-black"})}):null,u.avatar?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("img",{src:r(),alt:u.name})}):null,u.voiceOver?P.jsx("div",{className:"speech-bubble__avatar",children:P.jsx("div",{className:"icon-narrator"})}):null,P.jsxs("div",{className:"speech-bubble__name",children:[P.jsx("span",{children:u.name}),u.thinkful?P.jsxs("span",{children:["[ ",t("emotion.thinking")," ]"]}):null]})]}),u.text?P.jsx("div",{className:"speech-bubble__text",children:Si(u.text)}):null]})}const rnt=G.forwardRef(ant);function snt({currentMessage:u,translate:t}){const e=document.querySelector(".screens--container");return P.jsx("group",{children:P.jsx(Oa.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",onOcclude:()=>null,zIndexRange:[5,5],portal:e?{current:e}:void 0,style:{width:"100%",height:"100%",position:"static"},calculatePosition:()=>[0,0],children:P.jsx(rnt,{translate:t,message:u})})})}const Az=75,_R=1400,ont=2,XN=new ra.Raycaster,og=new ra.Object3D,lnt=70;XN.firstHitOnly=!0;function unt({keyboardControl:u,emitEvent:t,getEvent:e,lines:n,actors:i,edges:r,soundActions:o,zoomInActor:l,autoPlay:c,autoEnd:d,pause:f,progress:m}){var ze;const _=n.length-1<=(m==null?void 0:m.line)?n.length-1:(m==null?void 0:m.line)||0,[g,S]=G.useState(_),[y,x]=G.useState(!!c),[T,A]=G.useState(!1),[E,C]=G.useState(!1),R=g0.useThree(zt=>zt.scene),N=g0.useThree(zt=>zt.camera),{start:M,stop:O}=Tw(),z=G.useRef([]),L=G.useMemo(()=>N.clone(),[]),k=G.useRef({pos:[0,0,0],child:null}),I=n[g],H=n[g-1],Q=G.useRef(!1),Z=!!r,{voiceOver:X,decision:$}=I||{},nt=G.useRef({}),W=(ze=I==null?void 0:I.slots)==null?void 0:ze.find(zt=>zt.talking),tt=G.useRef(!1),{playAnimation:rt,stopSpeech:ut,startSpeech:st,getMachine:ot}=Fk();G.useRef();const dt=G.useRef({}),vt=Object.keys((I==null?void 0:I.audio)||{}).length,it=Object.keys((I==null?void 0:I.voice)||{}).length,ht=X||(I==null?void 0:I.type)==="conversationalNarration",lt=$||(I==null?void 0:I.type)==="conversationalDecision",xt=(I==null?void 0:I.type)==="conversationalCamera",yt=y&&!lt&&!xt,[pt,bt]=G.useState({text:"",name:"",inScene:!1,thinkful:!1,voiceOver:!1,avatar:"",show:!1}),Tt=G.useMemo(()=>{const zt=new Set;for(const Kt of n)if(Kt.slots)for(const Xt of Kt.slots)Xt.uid&&zt.add(Xt.uid);return Array.from(zt)},[n]),Ct=G.useCallback(zt=>e({type:"translate",payload:zt}),[e]),[kt,It]=G.useState([]),$t=G.useMemo(()=>kt[kt.length-1],[kt]),ie=G.useCallback(()=>{const zt=r.find(Xt=>Xt.fromId===$t)||r.find(Xt=>Xt.toId===$t),Kt=n.find(Xt=>Xt.id===(zt==null?void 0:zt.fromId));return!$t&&(m==null?void 0:m.line)>=0?{decision:!0}:Kt},[r,n,$t]),Te=G.useCallback(()=>{if(Z){const zt=n.filter(Kt=>!r.find(Xt=>Xt.toId===Kt.id));if(zt.length){const Kt=zt[0],Xt=n.indexOf(Kt);if(Xt>=0)return Xt}}return-1},[Z,n,r]),$e=G.useCallback(()=>{if(Z){const Kt=ie();return Kt==null?void 0:Kt.decision}const zt=n[g-1]?n[g-1]:{};return g>0&&(zt==null?void 0:zt.decision)},[I,Z,n,$t,r]),Ce=G.useCallback(()=>{if(Z){const Kt=ie();return(Kt==null?void 0:Kt.type)==="conversationalCamera"}const zt=n[g-1]?n[g-1]:{};return g>0&&(zt==null?void 0:zt.type)==="conversationalCamera"},[I,Z,n,$t,r]),xe=G.useCallback(zt=>{var Xt,Le;const Kt=i.find(De=>(De==null?void 0:De.uid)===(zt==null?void 0:zt.uid)?De:"");return((Le=(Xt=zt==null?void 0:zt.character)==null?void 0:Xt.resource)==null?void 0:Le.url)||(Kt==null?void 0:Kt.completeUrl)||""},[i]),xn=(zt=()=>{})=>{if(tt.current)tt.current&&(tt.current=!1);else{N.updateProjectionMatrix(),N.updateMatrixWorld(!0);const Kt=k.current.child?k.current.pos:L.position.toArray();if(og.position.fromArray(Kt),k.current.parent){og.quaternion.equals(N.quaternion)||og.applyQuaternion(N.quaternion);const Xt=k.current.isLeft?-1:1,Le=ont*Xt;og.translateX(-10*Xt+Le),og.translateY(-2),og.translateZ(30)}ZU.to(N.position,{duration:.9,ease:"power3.easeInOut",onStart:()=>{tt.current=!0},onUpdate:()=>{z.current.length&&z.current.forEach(Xt=>{const{object:Le}=Xt;Le.material.visible=!0})},onComplete:()=>{zt(),XN.set(N.getWorldPosition(new ra.Vector3(0,0,0)),N.getWorldDirection(new ra.Vector3));const Xt=XN.intersectObjects(R.children,!0);z.current=Xt.filter(Le=>Le.distance<10),z.current.length&&z.current.forEach(Le=>{const{object:De}=Le;De.material.side=0}),tt.current=!1,Q.current&&t({type:"success"}),k.current.child||N.copy(L)},...og.position})}},fn=G.useCallback(()=>{k.current.child=null,k.current.parent=null,l&&xn()},[l]),Ft=()=>{Tt.forEach(zt=>{const Kt=ot(zt);if(!Kt)return;const Xt=Kt.getAction("tts");Xt&&Oa.ThreeUtils.setWeight(Xt,0),delete Kt.getRoot().userData._active,Kt.mix("idle",.25)})},ne=(zt,Kt,Xt,Le=!1)=>{var su,nl;const De=Kt.includes("seated");let gi=Kt;Le&&!De&&(gi+="-seated");const Nn=(su=zt.character)==null?void 0:su.resource.animations,Na=Xt?Xt.url:(nl=Nn[gi])==null?void 0:nl.url,pr=Xt&&Mz.includes(Xt.animationId),Lr=(dt.current[zt.uid]||0)+1;dt.current[zt.uid]=Lr,rt(zt.uid,Na,pr).then(md=>{if(md&&pr&&dt.current[zt.uid]===Lr){const il=ot(zt.uid);il&&il.mix("idle",.25)}})},fe=zt=>{if(!(W!=null&&W.uid)||!(W!=null&&W.emotion)||Q.current)return;const{emotion:Kt,uid:Xt,animation:Le}=W;gg(Xt,R)&&st(Xt,zt)},Lt=()=>{!(W!=null&&W.uid)||Q.current||ut(W==null?void 0:W.uid)},Yt=G.useCallback(()=>{Q.current=!0,bt({show:!1}),fn(),Ft(),l||t({type:"success"})},[N,t,fn,l]);G.useEffect(()=>()=>{nt.current={},Ft()},[]);const te=zt=>{bt({show:!1}),Ft(),S(zt),t({type:"notifyProgress",payload:{line:zt}})},je=G.useCallback((zt=!0)=>{const Kt=zt?["fromId","toId"]:["toId","fromId"],Xt=r.filter(gi=>gi[Kt[0]]===I.id),Le=Xt.length===1?Xt[0]:Xt.find(gi=>gi[Kt[1]]===$t);if(!(Le!=null&&Le[Kt[0]])){Yt();return}zt||It(kt.slice(0,kt.length-1));const De=n.findIndex(gi=>gi.id===Le[Kt[1]]);De>=0?te(De):Yt()},[I==null?void 0:I.id,t,r,Yt,n]),qe=G.useCallback((zt,Kt)=>{const Xt=[3,2,1][zt.id],De=r.filter(Nn=>Nn.fromId===(I==null?void 0:I.id)).find(Nn=>parseInt(Nn.fromPointIndex)===Xt),gi=n.findIndex(Nn=>Nn.id===(De==null?void 0:De.toId));gi>=0?(De==null?void 0:De.fromId)===(De==null?void 0:De.toId)?Kt():te(gi):Yt()},[I==null?void 0:I.id,r,Yt,n]),Gt=G.useCallback(()=>{if(nt.current={...W},C(!1),Lt(),Z)je(!1);else if(!$e()){const zt=g-1;bt({show:!1}),S(zt),t({type:"notifyProgress",payload:{line:zt}})}},[je,t,Z,H,g,W]),ee=G.useCallback(zt=>{if(Z){if(zt){const Kt=[3,2,1][zt.id],Le=r.filter(De=>De.fromId===I.id).find(De=>parseInt(De.fromPointIndex)===Kt);if(Le){const De=n.findIndex(gi=>gi.id===Le.toId);De>=0&&t({type:"notifyProgress",payload:{line:De}})}else t({type:"saveNode"})}}else if(g<n.length-1){const Kt=g+1;t({type:"notifyProgress",payload:{line:Kt}})}else t({type:"saveNode"})},[r,g,n,t,I==null?void 0:I.id,Z]),re=G.useCallback((zt,Kt)=>{if(nt.current={...W},C(!1),Lt(),Z)It([...kt,I.id]),zt?qe(zt,Kt):je();else if(g<n.length-1){const Xt=g+1;te(Xt)}else(d||lt||xt)&&Yt()},[t,I==null?void 0:I.id,Z,lt,xt,g,n.length,qe,je,Yt,W]),wn=()=>{x(!1),Gt()},oe=()=>Z?I&&I.type!=="conversationalDecision"&&!r.find(zt=>zt.fromId===I.id):g===n.length-1,pe=()=>{oe()?Yt():(x(!1),re())};G.useEffect(()=>{if(Z&&!T){const zt=m==null?void 0:m.line;if(zt>=0){A(!0),S(zt);return}const Kt=Te();Kt>=0&&(A(!0),S(Kt))}},[r,Z,n,T,Te]);const Mn=zt=>{if(nt.current.uid===zt.uid||k.current.parent===zt)return;const Kt=new ra.Object3D,Xt=zt.getObjectByName("Head_M");Xt.updateMatrixWorld(!0),Kt.applyMatrix4(Xt.matrixWorld),Kt.applyQuaternion(N.quaternion);const Le=l?2.5:2,De=l?1.2:1.5;Kt.translateY(Le),Kt.translateX(De);const gi=new ra.Vector3;gi.setFromMatrixPosition(Xt.matrixWorld);const Na=gi.project(N).x<0;k.current={pos:Kt.position.toArray(),child:Xt,parent:zt,isLeft:Na}},On=zt=>{t({type:"resetZIndexUIContainer",payload:zt})};G.useEffect(()=>{var zt;if(ht)fn(),bt({text:I==null?void 0:I.text,name:(I==null?void 0:I.alias)||(I==null?void 0:I.name)||`[ ${Ct("storylines.misc.voiceOver")} ]`,inScene:!1,voiceOver:!0,thinkful:!1,top:!1,avatar:xe(W),show:!0});else if(!Q.current&&!lt&&!xt){const Kt=I==null?void 0:I.slots.filter(Xt=>Xt.uid&&!Xt.talking);if([...Kt.map(Xt=>Xt)||[]],Kt.forEach(Xt=>{const Le=gg(Xt.uid,R);if(Le){const{isSeated:De}=Le;ne(Xt,Xt.emotion,Xt.animation,De)}}),W){const Xt=gg(W.uid,R),Le=i.find(De=>De.uid===W.uid);Xt&&!Q.current?setTimeout(()=>{if(W.uid===Xt.uid){Mn(Xt);const{isSeated:De,userData:gi}=Xt,{emotion:Nn,animation:Na}=W;ne(W,Nn,Na,De);const pr=()=>{var Lr;bt({text:W.text,name:W.alias||((Lr=W.character)==null?void 0:Lr.name),inScene:!0,thinkful:W.emotion.includes("think"),avatar:xe(W),show:!0})};l?(tt.current=!1,xn(pr)):pr()}},150):(fn(),bt({text:W.text,name:W.alias||((zt=W.character)==null?void 0:zt.name)||(Le==null?void 0:Le.name),left:!1,top:W.text.length>lnt,inScene:!1,thinkful:W.emotion.includes("think"),avatar:xe(W),show:!0}))}else fn(),bt({show:!0})}},[i,I,l,R,Ct,xe,fn,lt,ht]);const qi=Hw(pt==null?void 0:pt.text),[jt]=ry({audioType:I==null?void 0:I.audioType,volume:I==null?void 0:I.audioVolume,voice:I==null?void 0:I.voice,started:pt.show,text:qi,audio:I==null?void 0:I.audio,soundActions:o,getEvent:e,pauseTTS:f,onStart:(zt,Kt)=>{var Xt;(Xt=W==null?void 0:W.emotion)!=null&&Xt.includes("think")||fe(Kt.node)},onError:()=>{C(!0)},onFinish:()=>{Lt(),yt&&!f&&re()}});G.useEffect(()=>(jt(),()=>{jt()}),[g,jt]),G.useEffect(()=>{var zt;if(((I==null?void 0:I.audioType)==="none"||E)&&(pt!=null&&pt.show)&&!(W!=null&&W.emotion.includes("think"))){fe();const Kt=Az*(((zt=pt==null?void 0:pt.text)==null?void 0:zt.length)||0);setTimeout(()=>{Lt()},Kt<_R?_R:Kt)}},[E,I==null?void 0:I.audioType,Lt,fe,W==null?void 0:W.emotion,pt]),G.useEffect(()=>{var zt;if(yt&&pt.show&&((I==null?void 0:I.audioType)==="none"||E)&&!f){const Kt=Az*(((zt=pt==null?void 0:pt.text)==null?void 0:zt.length)||0);(!oe()||oe()&&d)&&M(re,Kt<_R?_R:Kt)}return()=>{O()}},[pt,re,M,d,O,I==null?void 0:I.audioType,yt,vt,it,E]);const Zt=G.useMemo(()=>Te()>=0&&kt.length===0&&Z||!Z&&g===0||$e()||Ce(),[g,$e,Ce,Te,kt]),he=u({disabled:lt||!pt.show,repeat:!1,forward:pe,rewind:Zt?null:wn});G.useEffect(()=>he(),[he]);const ye=document.querySelector(".screens--container");if(xt)return P.jsx(p9,{...I,emitEvent:t,success:!1,onFinish:re},`change-camera-${g}`);if(lt){const zt=I.id?n.filter(Xt=>Xt.decision).findIndex(Xt=>Xt.id===I.id)+1:n.filter(Xt=>Xt.decision).findIndex(Xt=>Xt===I)+1,Kt={...I.payload,decisionNumber:zt,inheritProps:{slots:[],disableBackground:!0},required:!Z,branched:Z,onAddPoints:ee,onFinish:re,emitEvent:t,getEvent:e,pause:f,soundActions:o,keyboardControl:u};return P.jsx(mN,{onMount:()=>{fn(),On(!0)},onUnMount:()=>{tt.current=!1,oe()||On(!1)},children:P.jsx(w9,{inScene:!0,...Kt})})}return P.jsxs(P.Fragment,{children:[pt.text?P.jsx(snt,{translate:Ct,currentMessage:pt}):null,P.jsx(Oa.HtmlPro,{wrapperClass:"htmlpro-wrap-100-h",style:{width:"100%",height:"100%",position:"static"},portal:ye?{current:ye}:void 0,zIndexRange:[6,6],onOcclude:()=>{},calculatePosition:()=>[0,0],children:P.jsxs("div",{dir:Pe()?"rtl":"ltr",className:"dialog-component-controls",children:[P.jsx("button",{type:"button",onClick:wn,disabled:Zt||!pt.show,className:`gat--btn__round ${Zt||!pt.show?"disabled":""}`,"aria-label":Pe()?Ct("storylines.misc.forward"):Ct("storylines.misc.rewind"),children:P.jsx("span",{className:Pe()?"icon-next":"icon-back"})}),P.jsx("button",{type:"button",onClick:pe,disabled:!pt.show,className:`gat--btn__round
|
|
363
363
|
${pt.show?"":"disabled"}
|
|
364
364
|
${y&&oe()?"glowing-animation":""}`,"aria-label":Pe()?Ct("storylines.misc.rewind"):Ct("storylines.misc.forward"),children:P.jsx("span",{className:Pe()?"icon-back":"icon-next"})})]})})]})}const cnt=Oa.ProgressManager.request("AssetLoader").cache,dnt=new Oa.AssetLoader(void 0,cnt);function hnt({animation:u,loopTimes:t,onAnimationFinish:e,onAnimationSave:n,resource:i,makeDefault:r}){const[o,l]=G.useState(!1),c=g0.useThree(f=>f.scene),d=G.useRef(0);return G.useEffect(()=>{l(!1)},[i.uid,u==null?void 0:u.url]),G.useEffect(()=>{if(!o){const f=c.getObjectByProperty("uid",i.uid);if(f&&u&&u.url&&f.skeletonId===(u==null?void 0:u.skeletonId))if(r)n({uid:i.uid,animation:u==null?void 0:u.id,index:f.index}),e();else{const m=f.animator;m||console.error("[Animation]: Current Object ",i.uid," does not have an animator.");const _=()=>{const g=m==null?void 0:m.getAction(u.url);m.setTime(0),g.setLoop(ra.LoopRepeat,1/0),g.reset();function S(){d.current+=1,d.current>=t&&y()}function y(){m.mix("idle"),e(),m.removeEventListener("loop",S)}m.mix(u==null?void 0:u.url).then(x=>{x&&(d.current=1,d.current>=t?y():m.addEventListener("loop",S))}),l(!0)};m!=null&&m.getAction(u==null?void 0:u.url)?_():dnt.load(u==null?void 0:u.url,g=>{m.register(u==null?void 0:u.url,g.animations[0]),_()},void 0,g=>{console.error(`Asset loader failed with: ${u.url}`,g),e()})}else e()}},[c,u==null?void 0:u.url,t,o,i.uid,r,u,i,e,n]),null}function fnt({animations:u=[],enableInteraction:t,emitEvent:e}){const n=u.length,i=G.useRef(0),r=()=>{i.current+=1,i.current>=n&&t&&e({type:"success"})},o=l=>{e({type:"saveAnimation",payload:l})};return G.useEffect(()=>{i.current=0},[u]),G.useEffect(()=>{t||e({type:"success"})},[e,t]),u.map(({animation:l,...c},d)=>{var f;return P.jsx(hnt,{animation:l,...c,onAnimationFinish:r,onAnimationSave:o},(l==null?void 0:l.id)||((f=c.resource)==null?void 0:f.uid)||d)})}function pnt({text:u,error:t,handleClick:e}){return P.jsxs("div",{"data-testid":`${t?" pill--error":"pill--ok"}`,className:`email-pill ${t?" email-pill--error":""}`,children:[P.jsx("div",{children:u}),P.jsx("div",{className:"email-pill__delete",children:P.jsx("button",{type:"button",onClick:e,className:"icon-close unset-button","aria-label":"icon click"})})]})}function mnt({handleContinue:u,handleCancel:t,translate:e,text:n}){const[i,r]=G.useState([]),[o,l]=G.useState(0),[c,d]=G.useState(0),f=G.useRef(null),m=(y,x,T)=>{y.stopPropagation(),r(i.filter(A=>A!==i[T])),x.error&&l(o-1),x.isRepeat&&d(c-1)},_=()=>{f.current&&f.current.focus()},g=()=>{[" ",",",";","."].includes(f.current.value)&&(f.current.value="")},S=y=>{const x=f.current.value,T=["Space","Comma","Period","Enter"],A=["Space","Comma","Enter","Tab"];x===""&&(T.includes(y.code)||y.keyCode==="186"||y.key==="Enter"||y.key===" ")?y.preventDefault():f.current.value.length>1&&(A.includes(y.code)||y.type==="blur")&&(y.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(x)?i.find(C=>C.text===x)?(d(c+1),r([...i,{text:x,error:!0,isRepeat:!0}])):r([...i,{text:x}]):(r([...i,{text:x,error:!0}]),l(o+1)),f.current.value="")};return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"referrals-piece__body",children:[P.jsx("div",{className:"referrals-piece__title",children:e("puzzles.referrals.inviter.titleStep1")}),P.jsx("div",{className:"referrals-piece__subtitle",children:n}),P.jsxs("div",{className:"referrals-piece__form",children:[P.jsxs("div",{className:"referrals-piece__instructions",children:[P.jsx("div",{dir:"auto",children:e("puzzles.referrals.inviter.instructions")}),P.jsx("div",{dir:"auto",children:e("puzzles.referrals.inviter.limit")})]}),P.jsx("div",{className:"referrals-piece__faketextarea",onKeyUp:()=>{},role:"button",tabIndex:"-1",onClick:_,"aria-labelledby":"list of emails",children:P.jsxs("div",{className:"referrals-piece__scrollarea",id:"list of emails",children:[i&&i.map((y,x)=>P.jsx(pnt,{text:y.text,error:y.error,handleClick:T=>m(T,y,x),emailPillIndex:x},`${i.indexOf(y)}`)),i.length<=9?P.jsxs(P.Fragment,{children:[P.jsx("input",{id:"email",ref:f,className:"referrals-piece__inputemail",onChange:g,onKeyDown:S,onBlur:S,type:"email",autoComplete:"off"}),P.jsx("label",{className:"referrals-piece__emaillabel",htmlFor:"email",children:P.jsx("span",{children:e("puzzles.referrals.inviter.skipButton")})})]}):null]})}),P.jsxs("div",{dir:Pe()?"rtl":"auto",className:"referrals-piece__footervalidation",children:[P.jsxs("div",{className:"referrals-piece__errormessage",children:[P.jsx("div",{children:c>0?e("puzzles.referrals.inviter.errorEmailRepeat"):null}),P.jsx("div",{children:o>0?e("puzzles.referrals.inviter.errorMessage"):null})]}),P.jsxs("div",{className:"referrals-piece__counter","data-testid":"pillcounter",children:[i.length,"/10"]})]})]})]}),P.jsxs("div",{className:"referrals-piece__buttons",children:[P.jsx("button",{"data-testid":"cancelButton",className:"gat--btn gat--btn__secondary",type:"button",onClick:t,children:e("puzzles.referrals.inviter.skipButton")}),P.jsx("button",{className:`gat--btn gat--btn__primary ${c>0||o>0||i.length===0?" disabled":""}`,type:"button",disabled:o>0||i.length===0,onClick:()=>u(i),children:e("puzzles.referrals.inviter.inviteButton")})]})]})}function gnt({handleFinish:u,translate:t,valid:e,invalid:n}){const[i,r]=G.useState(!1),o=()=>{r(!i)},l=e.current===1?"invitationSend":"invitationsSend",c=n===1?"invitationNotSend":"invitationsNotSend";return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:"referrals-piece__body",dir:"auto",children:[P.jsx("div",{className:"referrals-piece__title",children:t("puzzles.referrals.inviter.titleStep2")}),P.jsxs("ul",{className:"referrals-piece__feedback",children:[e.current!==0&&P.jsxs("li",{children:[P.jsx("div",{className:"referrals-piece__feedbackicon icon-check-circle-black color--success"}),P.jsxs("div",{children:[P.jsx("strong",{children:e.current})," ",t(`puzzles.referrals.inviter.${l}`)]})]}),!!n.current&&P.jsxs("li",{children:[P.jsx("div",{className:"referrals-piece__feedbackicon icon-error-circle-black color--error"}),P.jsxs("div",{children:[P.jsx("strong",{children:n.current})," ",t(`puzzles.referrals.inviter.${c}`)]}),P.jsx("button",{className:"un-button",type:"button",onClick:o,children:t("puzzles.referrals.inviter.whyFail")})]})]}),i?P.jsxs("ul",{className:"referrals-piece__failsreasons",children:[P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons1")}),P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons2")}),P.jsx("li",{children:t("puzzles.referrals.inviter.failReasons3")})]}):null]}),P.jsx("div",{className:"referrals-piece__buttons",children:P.jsx("button",{className:"gat--btn gat--btn__primary",type:"button",onClick:u,children:t("puzzles.referrals.inviter.continueButton")})})]})}function vnt({emitEvent:u,getEvent:t,text:e,rewards:n,referrals:i}){const r=g=>t({type:"translate",payload:g}),[o,l]=G.useState("step1"),c=G.useRef(0),d=G.useRef(0),f=async g=>{const S=g.map(x=>x.text),y=await u({type:"sendReferrals",payload:S});c.current=y&&y.data?y.data.valid.length:0,d.current=S.length-c.current,l("step2")};if(!i)return u({type:"success"}),null;const m=()=>{u({type:"success"})},_=()=>{if(c.current){const g=n.map(S=>(S.points*=c.current,S));u({type:"addPoints",complex:!0,finish:!0,payload:g})}else u({type:"success"})};return P.jsx("div",{className:"referrals-piece",children:P.jsxs("div",{className:"referrals-piece__center",children:[o==="step1"&&P.jsx(mnt,{translate:r,handleContinue:f,handleCancel:m,text:e}),o==="step2"&&P.jsx(gnt,{translate:r,handleFinish:_,valid:c,invalid:d})]})})}function ynt({onPass:u}){return G.useEffect(()=>{const t=setTimeout(u,0);return()=>clearTimeout(t)},[u]),null}function _nt({itemResolver:u,consume:t,hasComplexNotResolvers:e,hasComplexResolvers:n,resolverObjects:i,feedback:r,emitEvent:o,getEvent:l,soundActions:c,keyboardControl:d,noEvaluation:f}){const[m]=c,[_,g]=G.useState(!1),[S,y]=G.useState(!1),[x,T]=G.useState(!1),A=M=>l({type:"translate",payload:M}),E=G.useCallback(()=>{o({type:"addPoints",complex:!0,finish:_.success,onFinish:()=>{_.success?o({type:"success"}):o({type:"closeScreen"})},payload:_.rewards})},[o,_]),C=G.useCallback(()=>{if(i.find(O=>O===u.uid)){let O;n?(O=r.resolvers.rights.find(z=>z.uidObject===u.uid),O||(O=r.resolvers.rights[0])):O=r.resolvers.rights[0],t&&o({type:"consumeItem",payload:{uid:u.uid,targetId:u.uid,name:u.name}}),g({...O,success:!0})}else{let O;e?(O=r.notResolvers.wrongs.find(z=>z.uidObject===u.uid),O||(O=r.notResolvers.wrongs[0])):O=r.notResolvers.wrongs[0],g({...O,success:!1})}},[i,u,n,t,r,o,e]),R=G.useCallback(()=>{if(i.find(O=>O===(u==null?void 0:u.uid))){let O;n?O=[...r.resolvers.rights.find(k=>k.uidObject===(u==null?void 0:u.uid)).rewards.filter(k=>k.type==="var")]:O=[...r.resolvers.rights[0].rewards.filter(L=>L.type==="var")],t&&o({type:"consumeItem",payload:{uid:u==null?void 0:u.uid,targetId:u==null?void 0:u.uid,name:u==null?void 0:u.name}}),T({varsPoints:[...O],success:!0})}else{let O;e?O=[...r.notResolvers.wrongs.find(k=>k.uidObject===(u==null?void 0:u.uid)).rewards.filter(k=>k.type==="var")]:O=[...r.notResolvers.wrongs[0].rewards.filter(L=>L.type==="var")],T({varsPoints:[...O],success:!1})}},[t,o,r.notResolvers.wrongs,r.resolvers.rights,e,n,u==null?void 0:u.name,u==null?void 0:u.uid,i]),N=G.useCallback(()=>{o({type:"addPoints",complex:!0,finish:x==null?void 0:x.success,onFinish:()=>{x!=null&&x.success?o({type:"success"}):o({type:"closeScreen"})},payload:x!=null&&x.varsPoints?x==null?void 0:x.varsPoints:[]}),y(!1)},[o,x==null?void 0:x.success,x==null?void 0:x.varsPoints]);return G.useEffect(()=>{u?f?R():C():o({type:"closeScreen"})},[C,R,o,u,f]),G.useEffect(()=>{x&&(x!=null&&x.success?y(!0):o({type:"closeScreen"}))},[o,x]),S?P.jsx(ynt,{onPass:N}):_?P.jsx(hd,{text:_.desc,success:_.success,playSound:m,translate:A,keyboardControl:d,functionOnClose:E}):null}function Cz({item:u,viewMode:t}){var e,n;return P.jsxs(P.Fragment,{children:[t==="text"&&P.jsx("div",{className:"match-item-text",children:Si(u==null?void 0:u.content)}),t==="card"&&P.jsx("div",{className:"match-item-image",children:P.jsxs("figure",{children:[((e=u==null?void 0:u.img)==null?void 0:e.url)&&P.jsx("img",{src:(n=u==null?void 0:u.img)==null?void 0:n.url,alt:u==null?void 0:u.imgName}),(u==null?void 0:u.content)&&P.jsx("figcaption",{children:Si(u==null?void 0:u.content)})]})})]})}function JU({translate:u,onClose:t,buttonLabel:e}){return P.jsx("div",{className:"timer-dialog",children:P.jsxs("div",{className:"timer-dialog__container",children:[P.jsx("div",{className:"timer-dialog__title",children:u("storylines.misc.ready")}),P.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:t,children:P.jsx("span",{children:u(`${e}`)})})]})})}function $U({topRight:u=!1,initialSeconds:t=10,isPaused:e,shouldStart:n,shouldReset:i,onTimeOver:r}){const[o,l]=G.useState(t),[c,d]=G.useState(!1),f=G.useRef();G.useEffect(()=>{i&&(l(t),d(!1))},[i,t]),G.useEffect(()=>{e&&d(!1)},[e]),G.useEffect(()=>{n&&d(!0)},[n]),G.useEffect(()=>(c&&o>0?f.current=setInterval(()=>{l(_=>_-1),o===1&&r()},1e3):o===0&&(clearInterval(f.current),d(!1)),()=>clearInterval(f.current)),[c,r,o]);const m=_=>{const g=Math.floor(_/60),S=_%60,y=String(g).padStart(2,"0"),x=String(S).padStart(2,"0");return`${y}:${x}`};return P.jsx("div",{className:["count-down",o<10&&"count-down--finalseconds",u&&"count-down--top-right"].filter(Boolean).join(" "),children:P.jsx("div",{children:m(o)})})}function bnt({emitEvent:u,soundActions:t=[()=>{},()=>{}],getEvent:e,info:n,specificFeedbacks:i,setResolveAction:r,nodeId:o,viewMode:l,title:c,sources:d,destinations:f,correctPairings:m,timer:_=0,keyboardControl:g,backgroundImage:S}){const y=Ft=>e({type:"translate",payload:Ft}),x=`match-puzzle_${o}`,[T,A]=G.useState([]),[E,C]=G.useState(null),[R,N]=G.useState(!1),[M,O]=G.useState(!1),[z,L]=G.useState(""),[k,I]=G.useState(!1),[H,Q]=G.useState([]),[Z]=t;ry({soundActions:t});const X=Ft=>{Z("click-ui");const ne=qe=>qe==null?void 0:qe.startsWith("source-item"),fe=qe=>qe==null?void 0:qe.startsWith("destination-item");if(Ft.id===E){C(null);return}const Lt=ne(Ft.id),Yt=ne(E),te=fe(Ft.id),je=fe(E);if(Lt&&je||te&&Yt){W(Ft);return}C(Ft.id)},$=Ft=>{let ne;return Ft.startsWith("destination-item")?ne={[E]:Ft}:ne={[Ft]:E},m.some(fe=>{const Lt=JSON.stringify(fe),Yt=JSON.stringify(ne);return Lt===Yt})},nt=(Ft,ne)=>{const fe=new Map(Ft.map(Lt=>[Lt.id,{...Lt}]));return ne.forEach(Lt=>{fe.has(Lt.id)?fe.get(Lt.id).points+=Lt.points:fe.set(Lt.id,{...Lt})}),Array.from(fe.values())},W=Ft=>{var ne,fe;if(Z("click-ui"),$(Ft.id)){const Lt=Ft.id.startsWith("source-item")?Ft.id:E,Yt=Ft.id.startsWith("destination-item")?Ft.id:E,te=[...T,{[Lt]:Yt}];if(A(te),i.specificCorrectFeedbacks){const je=i==null?void 0:i.correctFeedbacks.find(ee=>ee.id===`${Lt}-${Yt}`),qe=nt(H,je.rewards);Q([...qe]),tt(te)&&(Te(),I(!0)),je.desc&&(L(je==null?void 0:je.desc),O(!0),N(!0),Te());const Gt=tt(te);!je.desc&&Gt&&rt(qe)}else if(tt(te)&&(Te(),I(!0)),tt(te)){O(!0),n.solution.right.desc&&(Te(),L(n.solution.right.desc)),N(!0),I(!0);const qe=nt(H,n.solution.right.rewards);Q([...qe])}C(null)}else if(document.querySelector(`#${Ft.id}`).classList.add("match-button--error"),document.querySelector(`#${E}`).classList.add("match-button--error"),setTimeout(()=>{document.querySelector(`#${Ft.id}`).classList.remove("match-button--error"),document.querySelector(`#${E}`).classList.remove("match-button--error"),C(null)},1e3),i.specificWrongFeedbacks){const Lt=Ft.id.startsWith("destination-item")?Ft.id:E,Yt=i==null?void 0:i.wrongFeedbacks.find(je=>je.id===Lt),te=nt(H,Yt.rewards);Q([...te]),Yt!=null&&Yt.desc&&(L(Yt.desc),O(!1),N(!0),Te())}else{const Lt=nt(H,n.solution.wrong.rewards);Q([...Lt]),(fe=(ne=n.solution)==null?void 0:ne.wrong)!=null&&fe.desc&&(L(n.solution.wrong.desc),N(!0),Te())}},tt=Ft=>{if(m.length!==Ft.length)return!1;const ne=new Set(m.map(Lt=>JSON.stringify(Lt))),fe=new Set(Ft.map(Lt=>JSON.stringify(Lt)));for(const Lt of fe)if(!ne.has(Lt))return!1;return!0},rt=G.useCallback(Ft=>{Z("score");const ne=Ft?[...Ft]:[...H];u({type:"addPoints",complex:!0,finish:!0,payload:ne}),u({type:"passPuzzle"})},[H,u,Z]),ut=()=>{N(!1),O(!1),L(""),xt&&(Ce(),it(!0)),!xt&&!k&&$e(),k&&rt()},st=G.useMemo(()=>Object.assign({},...T),[T]),ot=(Ft,ne)=>st[Ft]===ne;G.useEffect(()=>{r(()=>{Z("score"),Te(),O(!0),L(n.solution.right.desc);const Ft=[...H,...n.resolve.rewards],ne=[...m];A(ne),setTimeout(()=>{O(!1),N(!1),u({type:"hidePuzzleButtons",payload:!1}),u({type:"puzzleAction",action:"resolve",payload:{element:x,rewards:Ft,finish:!0}})},5e3)})},[H,m,u,n.resolve.rewards,n.solution.right.desc,Z,x,r]);const dt=(Ft,ne)=>T.findIndex(fe=>{const Lt=Object.keys(fe)[0],Yt=Object.values(fe)[0];return Lt===Ft&&Yt===ne}),[vt,it]=G.useState(!0),[ht,lt]=G.useState("storylines.misc.start"),[xt,yt]=G.useState(!1),pt=()=>{lt("storylines.misc.retry"),it(!1),yt(!1),$e()},[bt,Tt]=G.useState(!1),[Ct,kt]=G.useState(!1),[It,$t]=G.useState(!1),ie=()=>{let Ft=nt(H,n.timerFeedback.rewards);if(i.specificCorrectFeedbacks){const ne=new Map(Ft.map(fe=>[fe.id,{...fe}]));T.forEach(fe=>{const Lt=Object.keys(fe)[0],Yt=fe[Lt],te=i.correctFeedbacks.find(je=>je.id===`${Lt}-${Yt}`);te!=null&&te.rewards&&te.rewards.forEach(je=>{if(ne.has(je.id)){const qe=ne.get(je.id);qe.points-=je.points,ne.set(je.id,qe)}})}),Ft=Array.from(ne.values())}Q(Ft),A([]),yt(!0),L(n.timerFeedback.desc),N(!0),Z("fail")},Te=()=>{Tt(!0),kt(!1),$t(!1)},$e=()=>{Tt(!1),kt(!0),$t(!1)},Ce=()=>{Tt(!1),kt(!1),$t(!0)},xe=G.useCallback(()=>{const Ft=document.querySelector('button[id^="source-item"]'),ne=document.querySelector('button[id^="destination-item"]'),fe=Ft.getBoundingClientRect().right,Yt=ne.getBoundingClientRect().left+6-fe;d.items.forEach((te,je)=>{if(te.matchDestinationId!==void 0&&te.matchDestinationId!==null){const qe=document.querySelector(`#${te.id}`),Gt=document.querySelector(`#${te.matchDestinationId}`),ee=qe.getBoundingClientRect().top,re=Gt.getBoundingClientRect().top,wn=re>ee,oe=Math.abs(re-ee),pe=Math.sqrt(Yt*Yt+oe*oe),Mn=qe.querySelector(".match-line__hipotenuse");Mn.style.setProperty("width",`${pe}px`);const On=Math.atan(oe/Yt),qi=wn?On*(180/Math.PI):-On*(180/Math.PI);Mn.style.setProperty("transform",`rotate(${qi}deg)`)}})},[d.items]);G.useEffect(()=>(xe(),window.addEventListener("resize",xe),()=>{window.removeEventListener("resize",xe)}),[xe]);const xn=G.useMemo(()=>{let Ft="";return Ft="match ",S!=null&&S.url&&(Ft+="match--with-custom-bg"),Ft},[S==null?void 0:S.url]),fn={backgroundImage:S!=null&&S.url?`url('${S.url}')`:""};return P.jsxs(P.Fragment,{children:[P.jsxs("div",{className:xn,style:fn,children:[(c||_>0)&&P.jsxs("header",{className:"match__header",children:[P.jsx("div",{}),c&&P.jsx("div",{className:"match__title","data-testid":"match__title",children:Si(c)}),_>0&&P.jsx($U,{topRight:!0,initialSeconds:_,isPaused:bt,shouldStart:Ct,shouldReset:It,onTimeOver:ie})]}),P.jsx("div",{className:"match__columns",children:P.jsxs("div",{className:"match__columns-scroll scroll-shadow-container",children:[P.jsxs("div",{className:"match__column-wrap",children:[d.title&&P.jsx("div",{className:"match__subtitle",children:Si(d.title)}),P.jsx("div",{className:"match__column",children:d.items.map(Ft=>P.jsxs("button",{id:Ft.id,"data-testid":Ft.id,className:["unset-button match-button",E===Ft.id&&"match-button--marked",ot(Ft.id,Ft.matchDestinationId)&&"match-button--success",dt(Ft.id,Ft.matchDestinationId)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${dt(Ft.id,Ft.matchDestinationId)+1})`},disabled:ot(Ft.id,Ft.matchDestinationId),type:"button",onClick:()=>X(Ft),children:[P.jsx(Cz,{item:Ft,viewMode:l}),P.jsx("div",{className:"icon-check-circle-black color--success"}),P.jsx("div",{className:"icon-error-circle-black color--error"}),P.jsx("div",{className:"match-line__hipotenuse"})]},Ft.id))})]}),P.jsxs("div",{className:"match__column-wrap",children:[f.title&&P.jsx("div",{className:"match__subtitle",children:Si(f.title)}),P.jsx("div",{className:"match__column",children:f.items.map(Ft=>P.jsxs("button",{id:Ft.id,"data-testid":Ft.id,className:["unset-button match-button",E===Ft.id&&"match-button--marked",ot(Ft.matchSourceId,Ft.id)&&"match-button--success",dt(Ft.matchSourceId,Ft.id)+1&&"match-button--matched"].filter(Boolean).join(" "),style:{"--matched-color":`var(--matched-color-${dt(Ft.matchSourceId,Ft.id)+1})`},disabled:ot(Ft.matchSourceId,Ft.id),type:"button",onClick:()=>X(Ft),children:[P.jsx(Cz,{item:Ft,viewMode:l}),P.jsx("div",{className:"icon-check-circle-black color--success"}),P.jsx("div",{className:"icon-error-circle-black color--error"})]},Ft.id))})]})]})})]}),_>0&&vt&&P.jsx(JU,{buttonLabel:ht,translate:y,onClose:pt}),R&&P.jsx(hd,{success:M,text:z,translate:y,timeExpired:xt,functionOnClose:ut,keyboardControl:g,delay:3e3})]})}function Snt({emitEvent:u,soundActions:t=[()=>{},()=>{}],getEvent:e,info:n,specificFeedbacks:i,setResolveAction:r,nodeId:o,destinationAreas:l,draggableItems:c,noDraggableItems:d,background:f,showDestinationAreas:m,timer:_,viewMode:g,keyboardControl:S}){var On,qi;const y=jt=>e({type:"translate",payload:jt}),x=`sort-puzzle_${o}`,[T,A]=G.useState(!1),[E,C]=G.useState(!1),[R,N]=G.useState(""),[M,O]=G.useState(!1),[z,L]=G.useState([]),[k]=t;ry({soundActions:t});const I=G.useRef({}),H=G.useRef({}),[Q,Z]=G.useState(!0),[X,$]=G.useState("storylines.misc.start"),[nt,W]=G.useState(!1),[tt,rt]=G.useState(!1),[ut,st]=G.useState(!1),[ot,dt]=G.useState(!1),vt=()=>{const jt=i.specificCorrectFeedbacks?[]:z,Zt=Te(jt,n.timerFeedback.rewards);g==="matchMode"&&Tt.current.forEach(he=>{he.acceptedItems=[]}),L(Zt),W(!0),xe(n.timerFeedback.desc,!1),k("fail")},it=G.useCallback(()=>{rt(!0),st(!1),dt(!1)},[]),ht=()=>{rt(!1),st(!0),dt(!1)},lt=()=>{rt(!1),st(!1),dt(!0)},xt=()=>{$("storylines.misc.retry"),Z(!1),W(!1),ht()},yt=(jt,Zt)=>{const he=zt=>zt.current.flatMap(Xt=>{const Le=Xt.acceptedItems;return Le||[]}).sort(),ye=he(jt),ze=he(Zt);return ye.length!==ze.length?!1:ye.join(",")===ze.join(",")},pt=G.useRef(0),bt=G.useRef([]),Tt=G.useRef([]);G.useEffect(()=>{g==="matchMode"&&!pt.current&&l.forEach(jt=>{pt.current+=1,bt.current.push({id:jt.id,acceptedItems:jt.acceptedItems}),Tt.current.push({id:jt.id,acceptedItems:[]})})},[l,g]);const Ct=G.useRef(null),kt=G.useRef(null),It=G.useCallback(()=>{const jt=Ct.current.clientHeight,Zt=kt.current.clientHeight;kt.current.style.transform=`scale(${jt/Zt})`},[]);G.useEffect(()=>(It(),window.addEventListener("resize",It),()=>{window.removeEventListener("resize",It)}),[It]);const $t=G.useRef([]),ie=G.useCallback(()=>{$t.current=Object.values(H.current).filter(Boolean).map(jt=>{const Zt=jt.getBoundingClientRect();return{id:jt.id,top:Zt.top,left:Zt.left,right:Zt.right,bottom:Zt.bottom}})},[]);G.useEffect(()=>(ie(),window.addEventListener("resize",ie),()=>{window.removeEventListener("resize",ie)}),[ie]);const Te=(jt,Zt)=>{const he=new Map(jt.map(ye=>[ye.id,{...ye}]));return Zt.forEach(ye=>{he.has(ye.id)?he.get(ye.id).points+=ye.points:he.set(ye.id,{...ye})}),Array.from(he.values())},$e=G.useCallback(jt=>{k("score");const Zt=jt?[...jt]:[...z];u({type:"addPoints",complex:!0,finish:!0,payload:Zt}),u({type:"passPuzzle"})},[z,u,k]),Ce=G.useCallback(()=>{N(""),C(!1),A(!1),u({type:"hidePuzzleButtons",payload:!1})},[u]),xe=G.useCallback((jt,Zt=!1)=>{jt&&N(jt),Zt&&C(!0),A(!0),u({type:"hidePuzzleButtons",payload:!0}),it()},[u,it]),xn=G.useCallback(()=>{n.solution.right.desc&&(it(),N(n.solution.right.desc));const jt=Te(z,n.solution.right.rewards);L([...jt]),xe(null,!0)},[z,n.solution.right.desc,n.solution.right.rewards,it,xe]),fn=G.useCallback((jt,Zt)=>{const he=i==null?void 0:i.correctFeedbacks.find(ze=>ze.id===jt.id),ye=Te(z,he.rewards);L([...ye]),he.desc&&xe(he.desc,!0),!he.desc&&Zt&&xe(null,!0)},[z,xe,i==null?void 0:i.correctFeedbacks]),Ft=G.useCallback(()=>{var Zt;const jt=Te(z,n.solution.wrong.rewards);L([...jt]),n.solution.wrong.desc&&xe((Zt=n.solution.wrong)==null?void 0:Zt.desc,!1)},[z,n.solution.wrong.desc,n.solution.wrong.rewards,xe]),ne=(jt,Zt)=>{setTimeout(()=>{Zt.classList.remove("sort-draggable-item--error"),Zt.classList.add("sort-draggable-item--resetting"),Zt.style.setProperty("transform",jt.transform),setTimeout(()=>Zt.classList.remove("sort-draggable-item--resetting"),1e3)},1e3)},fe=jt=>{if(jt==="none")return{x:0,y:0};const he=jt.replace("matrix(","").replace("matrix3d(","").replace(")","").split(", ");return he.length===6?{x:parseFloat(he[4]),y:parseFloat(he[5])}:he.length===16?{x:parseFloat(he[12]),y:parseFloat(he[13])}:{x:0,y:0}},Lt=G.useRef(),Yt=G.useRef(),te=G.useRef(),je=G.useRef(),qe=(jt,Zt)=>{Lt.current=Zt;const he=jt.currentTarget;he.classList.add("sort-draggable-item--dragging");const ye=jt.touches?jt.touches[0].clientX:jt.clientX,ze=jt.touches?jt.touches[0].clientY:jt.clientY;Yt.current=ye,te.current=ze;const zt=window.getComputedStyle(he).getPropertyValue("transform");je.current=fe(zt)},Gt=G.useCallback((jt,Zt)=>{if(Lt.current&&Lt.current===Zt){const he=Ct.current.clientHeight/kt.current.clientHeight,ye=I.current[Zt],ze=ye.getBoundingClientRect(),Kt=ye.parentElement.getBoundingClientRect(),Xt=(jt.touches?jt.touches[0].clientX:jt.clientX)-Yt.current,Le=(jt.touches?jt.touches[0].clientY:jt.clientY)-te.current,De=(Kt.width-ze.width)/he,gi=(Kt.height-ze.height)/he,Nn=Math.min(Math.max(je.current.x+Xt/he,0),De),Na=Math.min(Math.max(je.current.y+Le/he,0),gi);ye.style.transform=`translate(${Nn}px, ${Na}px)`}},[]),ee=(jt,Zt)=>{const ye=I.current[jt].getBoundingClientRect(),ze=$t.current.find(Kt=>Kt.id===Zt&&!(ye.left>=Kt.right||ye.right<=Kt.left||ye.top>=Kt.bottom||ye.bottom<=Kt.top)),zt=$t.current.find(Kt=>Kt.id!==Zt&&!(ye.left>=Kt.right||ye.right<=Kt.left||ye.top>=Kt.bottom||ye.bottom<=Kt.top));return ze?"correctArea":zt?"incorrectArea":"neutral"},re=G.useCallback(jt=>{if(Lt.current&&Lt.current===jt){k("click-ui");const Zt=I.current[jt],he=c.find(ye=>jt===ye.id);if(Yt.current=null,te.current=null,Zt.classList.remove("sort-draggable-item--dragging"),Lt.current=null,g!=="resolveMode"){const ye=ee(jt,he.destination.id);if(ye==="correctArea"){if(g==="anyItemResolver"){k("score"),it(),Zt.classList.add("sort-draggable-item--success");const ze=!0;O(ze),i.specificCorrectFeedbacks?fn(he,ze):xn()}if(g==="matchMode")if(k("score"),Zt.classList.add("sort-draggable-item--success"),Tt.current.find(zt=>zt.id===he.destination.id).acceptedItems.push(he.id),i.specificCorrectFeedbacks){const zt=yt(Tt,bt);zt&&O(!0),fn(he,zt)}else yt(Tt,bt)&&(O(!0),xn())}else if(ye==="incorrectArea"&&(g==="anyItemResolver"||g==="matchMode")){if(k("fail"),Zt.classList.add("sort-draggable-item--error"),i.specificWrongFeedbacks){const ze=i==null?void 0:i.wrongFeedbacks.find(Kt=>Kt.id===he.id),zt=Te(z,ze.rewards);L([...zt]),ze.desc&&xe(ze.desc,!1)}else Ft();ne(he,Zt)}}}},[z,c,xn,Ft,fn,it,k,xe,i.specificCorrectFeedbacks,i.specificWrongFeedbacks,i==null?void 0:i.wrongFeedbacks,g]),wn=()=>{let jt=!1;it(),c.forEach(Zt=>{const he=I.current[Zt.id];if(Zt.destination.id)ee(Zt.id,Zt.destination.id)!=="correctArea"?(jt=!0,he.classList.add("sort-draggable-item--error"),ne(Zt,he)):he.classList.add("sort-draggable-item--success");else{const ye=he.getBoundingClientRect();$t.current.find(zt=>!(ye.left>=zt.right||ye.right<=zt.left||ye.top>=zt.bottom||ye.bottom<=zt.top))&&(jt=!0,he.classList.add("sort-draggable-item--error"),ne(Zt,he))}}),jt?(k("fail"),Ft()):(k("score"),O(!0),xn())},oe=()=>{c.forEach(jt=>{const Zt=I.current[jt.id];Zt.classList.remove("sort-draggable-item--error"),Zt.classList.remove("sort-draggable-item--success"),Zt.classList.add("sort-draggable-item--resetting"),Zt.style.setProperty("transform",jt.transform),setTimeout(()=>Zt.classList.remove("sort-draggable-item--resetting"),1e3)})},pe=()=>{Ce(),nt&&(lt(),oe(),Z(!0)),!nt&&!M&&ht(),M&&$e()};G.useEffect(()=>{r(()=>{k("score"),it(),C(!0),N(n.solution.right.desc);const jt=[...z,...n.resolve.rewards];Ce(),u({type:"puzzleAction",action:"resolve",payload:{element:x,rewards:jt,finish:!0}})})},[z,u,n.resolve.rewards,n.solution.right.desc,it,k,x,Ce,r]),G.useEffect(()=>{if(!Ct.current||!kt.current)return;const jt=he=>Gt(he,Lt.current),Zt=()=>re(Lt.current);return document.addEventListener("mousemove",jt),document.addEventListener("mouseup",Zt),document.addEventListener("touchmove",jt,{passive:!1}),document.addEventListener("touchend",Zt),()=>{document.removeEventListener("mousemove",jt),document.removeEventListener("mouseup",Zt),document.removeEventListener("touchmove",jt),document.removeEventListener("touchend",Zt)}},[re,Gt]);const Mn={backgroundImage:(On=f==null?void 0:f.img)!=null&&On.url?`url('${(qi=f==null?void 0:f.img)==null?void 0:qi.url}')`:""};return P.jsxs("div",{ref:Ct,className:"sort-wrapper",children:[P.jsxs("div",{ref:kt,className:"sort-puzzle",style:Mn,children:[d.map(jt=>P.jsxs("div",{id:`${jt.id}`,className:"sort-no-draggable-item",style:{"--height":`${jt.heightInPercentage}%`,"--width":`${jt.widthInPercentage}%`,"--transform":`${jt.transform}`,"--backgroundColor":`${jt.backgroundColor}`,borderRadius:`${jt.borderRadius}`},children:[jt.imgId&&P.jsx("img",{src:jt.img.url,alt:jt.img.name}),jt.text&&Si(jt.text)]},jt.id)),l.map(jt=>P.jsx("div",{ref:Zt=>{H.current[jt.id]=Zt},id:jt.id,className:`sort-destination-area ${m?"sort-destination-area--revelable":""}`,style:{"--height":`${jt.heightInPercentage}%`,"--width":`${jt.widthInPercentage}%`,"--transform":`${jt.transform}`}},jt.id)),c.map(jt=>P.jsxs("div",{ref:Zt=>{I.current[jt.id]=Zt},id:`${jt.id}`,className:"sort-draggable-item",onMouseDown:Zt=>qe(Zt,jt.id),onTouchStart:Zt=>qe(Zt,jt.id),style:{"--height":`${jt.heightInPercentage}%`,"--width":`${jt.widthInPercentage}%`,"--transform":`${jt.transform}`,"--backgroundColor":`${jt.backgroundColor}`,borderRadius:`${jt.borderRadius}`},children:[jt.imgId&&P.jsx("img",{src:jt.img.url,alt:jt.img.name}),jt.text&&Si(jt.text)]},jt.id))]}),g==="resolveMode"&&P.jsx("button",{type:"button",onClick:()=>{wn()},className:"gat--btn gat--btn__primary sort-resolve-button",children:P.jsx("span",{children:y("storylines.misc.check")})}),_>0&&Q&&P.jsx(JU,{buttonLabel:X,translate:y,onClose:xt}),T&&P.jsx(hd,{success:E,text:R,translate:y,timeExpired:nt,functionOnClose:pe,keyboardControl:S}),_>0&&P.jsx($U,{topRight:!0,initialSeconds:_,isPaused:tt,shouldStart:ut,shouldReset:ot,onTimeOver:vt})]})}exports.AnimationComponent=fnt;exports.AutoEvaluationComponent=ktt;exports.CameraChangeContext=f9;exports.CameraChangeProvider=FY;exports.CardsSelectorPuzzleComponent=ltt;exports.CartelComponent=bX;exports.ChainedImageClickPuzzleComponent=O$;exports.ChangeCamera=p9;exports.ComicComponent=yX;exports.ConversationalComponent=pX;exports.ConversationalProComponent=nX;exports.CrackerPuzzleComponent=S$;exports.DecisionComponent=w9;exports.DialogComponent=unt;exports.DragItemPuzzleComponent=Ttt;exports.DragToSceneComponent=_nt;exports.FrameImageClickComponent=j$;exports.HackerPuzzleComponent=AX;exports.HangedPuzzleComponent=D$;exports.ImageClickPuzzleComponent=c$;exports.ImageComponent=fX;exports.InventoryItem=PH;exports.KeyboardPuzzleComponent=wX;exports.LecturesComponent=XK;exports.LoginPuzzleComponent=RX;exports.MatchPuzzleComponent=bnt;exports.NoticeComponent=RH;exports.PatternComponent=Itt;exports.PdfComponent=SY;exports.PdfVisor=v5;exports.ProgressRing=ZI;exports.ReferralComponent=vnt;exports.SortPuzzleComponent=Snt;exports.SurveyComponent=ztt;exports.TerminalPuzzleComponent=Ett;exports.TestComponent=Mtt;exports.TextClickPuzzleComponent=Utt;exports.UrlComponent=xY;exports.VideoComponent=BY;exports.VideoVisor=y5;exports.WebBuilderPuzzleComponent=ttt;exports.WriterPuzzleComponent=vtt;exports.useCameraChange=pk;
|
|
365
365
|
//# sourceMappingURL=arcade-components.cjs.map
|