@gamelearn/arcade-components 3.2.3 → 3.2.4
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.
|
@@ -249,7 +249,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/256
|
|
|
249
249
|
`,Z_INDEX_WARNING=`ReactKonva: You are using "zIndex" attribute for a Konva node.
|
|
250
250
|
react-konva may get confused with ordering. Just define correct order of elements in your render function of a component.
|
|
251
251
|
For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
252
|
-
`,EMPTY_PROPS={};function applyNodeProps(o,e,r=EMPTY_PROPS){if(!zIndexWarningShowed&&"zIndex"in e&&(console.warn(Z_INDEX_WARNING),zIndexWarningShowed=!0),!dragWarningShowed&&e.draggable){var t=e.x!==void 0||e.y!==void 0,n=e.onDragEnd||e.onDragMove;t&&!n&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var a in r)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",l=r[a]!==e[a];if(u&&l){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),o.off(f,r[a])}var c=!e.hasOwnProperty(a);c&&o.setAttr(a,void 0)}var h=e._useStrictMode,y={},E=!1;const p={};for(var a in e)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",_=r[a]!==e[a];if(u&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(p[f]=e[a])}!u&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,y[a]=e[a])}E&&(o.setAttrs(y),updatePicture(o));for(var f in p)o.on(f+EVENTS_NAMESPACE,p[f])}function updatePicture(o){if(!Global.Konva.autoDrawEnabled){var e=o.getLayer()||o.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(o,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}o.add(e),updatePicture(o)}function createInstance(o,e,r){let t=Konva[o];t||(console.error(`Konva has no node with the type ${o}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${o}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),t=Konva.Group);const n={},a={};for(var u in e){var l=u.slice(0,2)==="on";l?a[u]=e[u]:n[u]=e[u]}const f=new t(n);return applyNodeProps(f,a),f}function createTextInstance(o,e,r){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${o}"`)}function finalizeInitialChildren(o,e,r){return!1}function getPublicInstance(o){return o}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(o,e,r,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(o){}function shouldDeprioritizeSubtree(o,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(o,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function appendChildToContainer(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function insertBefore(o,e,r){e._remove(),o.add(e),e.setZIndex(r.getZIndex()),updatePicture(o)}function insertInContainerBefore(o,e,r){insertBefore(o,e,r)}function removeChild(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function removeChildFromContainer(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function commitTextUpdate(o,e,r){console.error(`Text components are not yet supported in ReactKonva. You text is: "${r}"`)}function commitMount(o,e,r){}function commitUpdate(o,e,r,t,n){applyNodeProps(o,n,t)}function hideInstance(o){o.hide(),updatePicture(o)}function hideTextInstance(o){}function unhideInstance(o,e){(e.visible==null||e.visible)&&o.show()}function unhideTextInstance(o,e){}function clearContainer(o){}function detachDeletedInstance(){}const getCurrentEventPriority=()=>constantsExports.DefaultEventPriority,HostConfig=Object.freeze(Object.defineProperty({__proto__:null,appendChild,appendChildToContainer,appendInitialChild,cancelTimeout,clearContainer,commitMount,commitTextUpdate,commitUpdate,createInstance,createTextInstance,detachDeletedInstance,finalizeInitialChildren,getChildHostContext,getCurrentEventPriority,getPublicInstance,getRootHostContext,hideInstance,hideTextInstance,idlePriority:schedulerExports.unstable_IdlePriority,insertBefore,insertInContainerBefore,isPrimaryRenderer,noTimeout,now:schedulerExports.unstable_now,prepareForCommit,preparePortalMount,prepareUpdate,removeChild,removeChildFromContainer,resetAfterCommit,resetTextContent,run:schedulerExports.unstable_runWithPriority,scheduleTimeout,shouldDeprioritizeSubtree,shouldSetTextContent,supportsMutation,unhideInstance,unhideTextInstance,warnsIfNotActing},Symbol.toStringTag,{value:"Module"}));var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,r)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,__spreadValues=(o,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(o,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(o,r,e[r]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e));function traverseFiber(o,e,r){if(!o)return;if(r(o)===!0)return o;let t=e?o.return:o.child;for(;t;){const n=traverseFiber(t,e,r);if(n)return n;t=e?null:t.sibling}}function wrapContext(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const FiberContext=wrapContext(React__namespace.createContext(null));class FiberProvider extends React__namespace.Component{render(){return React__namespace.createElement(FiberContext.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner,ReactCurrentDispatcher}=React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function useFiber(){const o=React__namespace.useContext(FiberContext);if(o===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=React__namespace.useId();return React__namespace.useMemo(()=>{for(const t of[ReactCurrentOwner==null?void 0:ReactCurrentOwner.current,o,o==null?void 0:o.alternate]){if(!t)continue;const n=traverseFiber(t,!1,a=>{let u=a.memoizedState;for(;u;){if(u.memoizedState===e)return!0;u=u.next}});if(n)return n}},[o,e])}function useContextMap(){var o,e;const r=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let n=r;for(;n;){const a=(o=n.type)==null?void 0:o._context;a&&a!==FiberContext&&!t.has(a)&&t.set(a,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(a))),n=n.return}return t}function useContextBridge(){const o=useContextMap();return React__namespace.useMemo(()=>Array.from(o.keys()).reduce((e,r)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(r.Provider,__spreadProps(__spreadValues({},t),{value:o.get(r)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[o])}function usePrevious(o){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=o}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=o=>{const e=React$2.useRef(),r=React$2.useRef(),t=React$2.useRef(),n=usePrevious(o),a=useContextBridge(),u=l=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(l):f.current=l)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),u(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(u(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{u(r.current),applyNodeProps(r.current,o,n),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current,null)}),React$2.createElement("div",{ref:e,id:o.id,accessKey:o.accessKey,className:o.className,role:o.role,style:o.style,tabIndex:o.tabIndex,title:o.title})},Layer="Layer",Group="Group",Rect="Rect",Line="Line",Image$2="Image",Text="Text",KonvaRenderer=ReactFiberReconciler(HostConfig);KonvaRenderer.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:React$2.version,rendererPackageName:"react-konva"});const Stage=React$2.forwardRef((o,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...o,forwardedRef:e})));var client={},m=require$$0;if(process.env.NODE_ENV==="production")client.createRoot=m.createRoot,client.hydrateRoot=m.hydrateRoot;else{var i=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;client.createRoot=function(o,e){i.usingClientEntryPoint=!0;try{return m.createRoot(o,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(o,e,r){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(o,e,r)}finally{i.usingClientEntryPoint=!1}}}var __rest=globalThis&&globalThis.__rest||function(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(o);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(r[t[n]]=o[t[n]]);return r};const needForceStyle=o=>{const e=window.getComputedStyle(o).position;return!(e==="absolute"||e==="relative")};function useEvent(o=()=>{}){const e=React$2.useRef(o);return e.current=o,React$2.useCallback((...r)=>e.current.apply(null,r),[])}const Html=({children:o,groupProps:e,divProps:r,transform:t,transformFunc:n})=>{const a=React$2.useRef(null);React$2.useRef();const[u]=React$2.useState(()=>document.createElement("div")),l=React$2.useMemo(()=>client.createRoot(u),[u]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),u.style.position="absolute",u.style.zIndex="10",u.style.top="0px",u.style.left="0px",u.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,u.style.transformOrigin="top left"}else u.style.position="",u.style.zIndex="",u.style.top="",u.style.left="",u.style.transform="",u.style.transformOrigin="";const h=r||{},{style:y}=h,E=__rest(h,["style"]);Object.assign(u.style,y),Object.assign(u,E)});return React$2.useLayoutEffect(()=>{var h;const y=a.current;if(!y)return;const E=(h=y.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(u),f&&needForceStyle(E)&&(E.style.position="relative"),y.on("absoluteTransformChange",c),c(),()=>{var p;y.off("absoluteTransformChange",c),(p=u.parentNode)===null||p===void 0||p.removeChild(u)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{l.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{l.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:a},e))};function Area({area:o,finished:e,isClicked:r,isBad:t,hasHighlights:n,completed:a,onClick:u,onClickOutside:l}){const f=React$2.useRef(),[c,h]=React$2.useState(),y=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",p=DeviceDetection(),_=()=>{var S,A,T;n&&!a&&!r&&((S=f.current)==null||S.setAttr("fill","rgba(130, 134, 142, 0.4)"),(A=f.current)==null||A.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(T=f.current)==null||T.to({duration:.25,opacity:1}))},g=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,T;a&&!e&&(t?(T=f.current)==null||T.to({duration:.25,opacity:0}):((S=f.current)==null||S.to({duration:.25,opacity:1}),(A=f.current)==null||A.globalCompositeOperation("destination-out")))},[a,e,t]);const x=()=>{var S,A;a||(t?l(o):u(o),(S=f.current)==null||S.setAttr("fill",y),(A=f.current)==null||A.setAttr("stroke",E))},C=o.scaleX?o.scaleX:1,R=o.scaleY?o.scaleY:1;return React$2.useLayoutEffect(()=>{const S=f.current.getStage();S.on("stage-loaded",()=>{const A=f.current.getClientRect({relativeTo:f.current.getParent()});h({x:A.x+A.width/2,y:A.y+A.height/2}),S.batchDraw()})},[o]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[c?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...c},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:o.id})}):null,jsxRuntimeExports.jsx(Line,{name:o.id,ref:f,onFocus:()=>_(),onMouseOver:()=>_(),onMouseLeave:g,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:C,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":y,stroke:e||r?E:"",strokeWidth:p?10:4,opacity:e||r?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[o,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function r(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),o};function KonvaMapper({areas:o,badAreas:e,imageUrl:r,completed:t,onClick:n,onClickOutside:a,hasHighlights:u,clickedZones:l}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),[g,x]=React$2.useState(new window.Image),[C,R]=useWindowSize(),S=e.find(w=>w.id==="AllArea")||!1,A=e.filter(w=>w.id!=="AllArea");React$2.useEffect(()=>{_.current&&c.current&&t&&(_.current.to({duration:.25,opacity:.5}),c.current.setAttr("visible",!0))},[t]);const T=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{g.src=r,g.addEventListener("load",()=>{if(f.current){const w={x:C/2,y:R/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(C/g.width,R/g.height),y:Math.min(C/g.width,R/g.height)}};y.current&&y.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),p.current&&p.current.setAttrs(w),f.current.batchDraw(),x(g),f.current.fire("stage-loaded")}})},[g,R,r,C]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:C,height:R,onClick:T,onTouchEnd:T,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:p,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:C,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:y,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:l.some(O=>O.index===w.index)},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:h,visible:!1,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0,finished:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:c,visible:!1,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,finished:!0},w.name+"_"+P))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:o,translate:e,onInit:r}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:e(o?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:o}){const e=Math.floor(o/60),r=o%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${o<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",r<10?`0${Math.floor(r)}`:Math.floor(r)]})})}const defaultImg="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function ImageReview(){return jsxRuntimeExports.jsx("div",{className:"puzzle--image__preview",children:jsxRuntimeExports.jsx("img",{alt:"img",src:"https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg"})})}function ImageClickWrapperComponent(o){var ye,Oe;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:u,image:l,areas:f,badAreas:c,hasClickOrder:h,timer:y,hasClickOnce:E,hasHighlights:p,hasImageReview:_,defaultCompleted:g,className:x,emitFinish:C,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:T,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[G,V]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,z]=React$2.useState(!1),[U,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[B,X]=React$2.useState(!0),[Q,J]=React$2.useState(!1),ne=React$2.useRef(null),se=React$2.useRef(null),ee=React$2.useRef(null),ie=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),de=React$2.useRef(null),ce=React$2.useRef(null),Se=React$2.useRef(null),[ke,Ne]=React$2.useState(y),We=Ge=>S?S(Ge):r({type:"translate",payload:Ge}),[Ke]=e,{solution:Qe}=u,pt=l.img.url||defaultImg,vt=f.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),ct=c.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),mt=React$2.useCallback(()=>{if(!B){const Ge=setInterval(()=>{Ne(nt=>nt>1?nt-1:0)},1e3);Se.current=Ge}},[B]),Vt=React$2.useCallback((Ge,nt)=>{C?C(Ge,nt):r({type:"addPoints",payload:Ge})},[r,C]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(g)},[g]);const kt=React$2.useCallback(()=>{clearInterval(ee.current)},[]),Ie=React$2.useCallback(()=>{clearInterval(Se.current)},[]),et=React$2.useCallback(Ge=>{oe.current=Date.now(),ie.current?(de.current=ie.current-oe.current,kt()):(de.current=oe.current-(oe.current-Ge*1e3),kt())},[kt]),at=React$2.useCallback(()=>{I(()=>{var Ge,nt;return{show:!0,success:!1,text:(Ge=u==null?void 0:u.timerFeedback)!=null&&Ge.desc?u.timerFeedback.desc:"",rewards:(nt=u==null?void 0:u.timerFeedback)==null?void 0:nt.rewards}}),J(!0),Ie(),kt()},[Ie,kt,(ye=u.timerFeedback)==null?void 0:ye.desc,(Oe=u.timerFeedback)==null?void 0:Oe.rewards]),Kt=React$2.useCallback(()=>{clearInterval(ee.current),ee.current=setInterval(()=>{se.current=Date.now(),se.current>ie.current&&at()},250)},[at]);React$2.useEffect(()=>{var Ge;if((f.length===G.length||E&&G.length>0)&&!W){Z(!0);const nt=G[G.length-1],je=A==null?void 0:A.correctFeedbacks.find(Ee=>Ee.id===nt.id);(!((Ge=A==null?void 0:A.correctFeedbacks)!=null&&Ge.length)||A!=null&&A.correctFeedbacks.some(Ee=>!Ee.desc)||E)&&(I(Ee=>({...Ee,show:!0,success:!0,text:je?je.desc:u.solution.right.desc,rewards:je?je.rewards:u.solution.right.rewards})),y&&(Ie(),et()))}},[G,f.length,A,E,W,u.solution.right,et,y,Ie]),React$2.useEffect(()=>{a(Ge=>{y&&(Ie(),X(!1),U.show?I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]})):kt()),Z(!0),z(!0),setTimeout(()=>{R?R(Ge):Ge()},4e3)})},[a,R,Ke,y,U.show,kt,Ie]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const Xe=(Ge,nt=!1)=>{var je,Ee;if(!W){const{rewards:Be,desc:qe}=Qe.wrong;let He=qe,ht=Be;const $t=(je=A==null?void 0:A.wrongFeedbacks)==null?void 0:je.find(Lt=>Lt.id===Ge.id);$t&&(He=$t.desc,ht=$t.rewards),h&&(V([]),nt&&(Ee=u==null?void 0:u.orderFeedback)!=null&&Ee.desc&&(He=u.orderFeedback.desc,ht=u.orderFeedback.rewards)),y&&(Ie(),et()),I(Lt=>({...Lt,show:!0,success:!1,text:He,rewards:ht})),Ke("fail")}},it=React$2.useCallback(()=>{fe.current=Date.now();const Ge=fe.current+de.current;se.current=null,ie.current=Ge,(y||Q)&&(U.success?f.length===G.length||E&&G.length>0?Ie():(Ne(de.current*.001),mt(),Kt()):(V([]),X(!0),w())),Vt(U.rewards,U.success),Ke("click-ui"),I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]}))},[y,Q,Vt,U.rewards,U.success,Ke,f.length,G.length,E,w,Ie,mt,Kt]),pe=Ge=>{var nt,je;if(!G.some(Ee=>Ee.index===Ge.index)&&!U.show&&!W){Ke("click-ui");let Ee=Qe.right.desc,{rewards:Be}=Qe.right;const qe=[...G,Ge];if(h&&Ge.index===G.length||!h){if(y&&et(ke),t(),(nt=A==null?void 0:A.correctFeedbacks)!=null&&nt.length){const He=(je=A.correctFeedbacks)==null?void 0:je.find(ht=>ht.id===Ge.id);He&&(Ee=He.desc,Be=He.rewards),!Ee&&f.length>qe.length&&!E?Vt(Be,!0):Ee&&!E&&(I(ht=>({...ht,show:!0,success:!0,text:Ee,rewards:Be})),y&&Ie())}V(qe)}else Xe(Ge,!0)}},ge=React$2.useCallback(()=>{Ie(),Ne(y),mt(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),ie.current=ne.current+y*1e3,Kt()},[Ie,y,mt,P,Kt,k]);return React$2.useEffect(()=>{y&&T>0&&!ce.current&&(P&&Object.keys(O).length&&O[T-1]?(X(!0),ce.current=!0):X(!1))},[g,P,O,T,y]),React$2.useEffect(()=>{y&&ke===0&&at()},[ke,at,y]),React$2.useEffect(()=>{y&&(D?(Ie(),et()):mt())},[Ie,Kt,D,et,mt,y]),jsxRuntimeExports.jsxs("div",{className:x,children:[U.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ke,text:U.text,success:U.success,translate:We,hasTimeout:!U.text,delay:y?1e3:2e3,functionOnClose:it,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&G.length?[G[0]]:vt,badAreas:ct,clickedZones:G,onClick:pe,onClickOutside:Xe,hasHighlights:p,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,y&&B?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[T-1],translate:We,onInit:ge}):null,y?jsxRuntimeExports.jsx(CountDown,{time:ke}):null]})}ImageClickWrapperComponent.defaultProps={info:{instructions:"",resolve:{},solution:{},hint:{},title:""},badAreas:[],className:"puzzle--image__click",hasClickOrder:!1,hasClickOnce:!1,hasHighlights:!1,hasImageReview:!1,defaultCompleted:!1,hideContinue:!1,emitAreaClick:()=>{},handleClick:()=>{}};function ImageClickPuzzleComponent(o){const e=(r,t)=>{t?(o.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:r}),o.emitEvent({type:"passPuzzle"})):(o.emitEvent({type:"addPoints",payload:r,finish:!1}),o.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...o,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(o,e)=>Math.max(Math.abs(o[0]-e[0]),Math.abs(o[1]-e[1])),generatePasswordPositions=(o,e,r,t)=>{const n=[],a=o;for(const u of e.toLowerCase()){const l=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[l][f].value=u,n.push({char:u,position:[l,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let u=0;u<r;u+=1)switch(t.reduce((f,c)=>{const h=[a,u],y=getDistance(c.position,h);return y<f?y:f},9999)){case 0:n[a][u].hiddenColor=GREEN;break;case 1:n[a][u].hiddenColor=ORANGE;break;case 2:n[a][u].hiddenColor=RED;break}return n},resetColors=(o,e,r)=>{const t=r;for(let n=0;n<o;n+=1)for(let a=0;a<e;a+=1)t[n][a].color="",t[n][a].hiddenColor=RED;return t},repaintGridPassword=(o,e,r,t)=>{const n=resetColors(r,t,o),[a,u]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,u)},prepareAcceptedChars=(o,e)=>e.split("").filter(r=>!o.includes(r)).join(""),generateBasicGrid=(o,e,r)=>{const t=[];for(let n=0;n<o;n+=1){const a=[];for(let u=0;u<e;u+=1){const l={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(l)}t.push(a)}return t},makeSomeNoise=({numberOfColumns:o,numberOfRows:e,password:r})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",n=prepareAcceptedChars(r,t),a=generateBasicGrid(e,o,n),[u,l]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(u,e,o,l)};function DrawItem({item:o,rowIndex:e,columnIndex:r,setCursorPosition:t,cursorPosition:n}){const a=Math.abs(e-n[0])<3&&Math.abs(r-n[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${a?o.hiddenColor:o.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,r])},onFocus:()=>{t([e,r])},children:o.value})}DrawItem.defaultProps={setCursorPosition:()=>{}};DrawItem.propTypes={item:PropTypes.shape({color:PropTypes.string,hiddenColor:PropTypes.string,value:PropTypes.string}).isRequired,rowIndex:PropTypes.number.isRequired,columnIndex:PropTypes.number.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired,setCursorPosition:PropTypes.func};function DrawRow({row:o,rowIndex:e,setCursorPosition:r,cursorPosition:t}){return o.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:o.map((n,a)=>jsxRuntimeExports.jsx(DrawItem,{item:n,rowIndex:e,columnIndex:a,setCursorPosition:r,cursorPosition:t},a))}):null}DrawRow.defaultProps={row:[]};DrawRow.propTypes={row:PropTypes.arrayOf(PropTypes.shape({})),rowIndex:PropTypes.number.isRequired,setCursorPosition:PropTypes.func.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired};function DrawGrid({grid:o,cursorPosition:e,setCursorPosition:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:o.map((t,n)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:n,cursorPosition:e,setCursorPosition:r},n))})}DrawGrid.defaultProps={setCursorPosition:()=>{}};const VELOCITY_MAP={slow:2,fast:5,fastest:10},DIFFICULTY_MAP={easy:{visibleRows:"auto",visibleColumns:40,totalRows:25},medium:{visibleRows:"auto",visibleColumns:40,totalRows:40},hard:{visibleRows:"auto",visibleColumns:40,totalRows:80}};function CrackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,velocity:t,password:n,disableExit:a,difficulty:u,setResolveAction:l}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),y=React$2.useRef(),{solution:E}=r,[p,_]=React$2.useState(n.toLowerCase()),[g,x]=React$2.useState(),[C,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([0,0]),P=c("puzzle.cracker.crackedPassword"),O=r.solution.right.desc&&r.solution.right.desc!==""?r.solution.right.desc:"",k=c("puzzle.cracker.congratulations"),[D,F]=React$2.useState([[]]),{visibleRows:G,visibleColumns:V}=DIFFICULTY_MAP[u];let W=G==="auto"?Math.ceil(window.innerHeight*.025):G;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{l(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[l,f]);const Z=()=>{f("click-ui");const{rewards:X}=E.right;o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},q=()=>n.toLowerCase().split("").map((Q,J)=>({char:Q,index:J,used:!1})),z=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),U=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(y.current!==void 0){const Q=X-y.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(U),I=0)}y.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:V,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const B=()=>{if(D.length<=1)return;const[X,Q]=T,J=D[X][Q];if(J.hiddenColor===GREEN){const ne=g.filter(se=>se.char===J.value.toLowerCase()&&se.used===!1)[0];if(ne){const{index:se}=ne;f("score");const ee=g;ee[se].used=!0,x(ee);const ie=[...C];ie[se]=J.value;const oe=z(ee);_(oe);const fe=repaintGridPassword(D,oe,W,V);F(fe),R(ie)}}p<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||B()},[T]),jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__container",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__header",children:[jsxRuntimeExports.jsx("span",{className:"title",children:"Dcoder.exe"}),jsxRuntimeExports.jsx("div",{className:"puzzle--pieces",children:C.map((X,Q)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:X&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${Q}`,children:X})},`${X+Q}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:S?[[]]:D,cursorPosition:T,setCursorPosition:w}),S&&P&&k&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,cursor:{hideWhenDone:!0},className:"puzzle--cracker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),jsxRuntimeExports.jsxs("span",{children:[`${P} ${n.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),O!==""&&jsxRuntimeExports.jsx("span",{children:O})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:Z,children:c("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(o,e)=>{let r=!1;return e==="or"&&(r=o===""||o===" "||o===","||o==="."||o==="/"),e==="and"&&(r=o&&o!==" "&&o!==","&&o!=="."&&o!==""&&o!=="/"),r},sortChar=(o,e)=>o.char>e.char?1:o.char<e.char?-1:0,analyzeChars=o=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let r=0;r<o.length;r+=1){const t=o[r].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(o[r])&&(e.anyArabic=!0)}return e},makeChar=o=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let n="";return o.anyWestern&&(n+=r),o.anyNumber&&(n+=t),o.anyArabic&&(n+=e),n.charAt(Math.floor(Math.random()*n.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:o,flickerPosition:e,show:r=!1,showCorrectSolution:t})=>{const n=[];let a=0;return o.forEach(u=>{n[a]||(n[a]=[]),n[a]=[...n[a],u],u.char===" "&&(a+=1),t||(u.positionInitial=u.index)}),n.map((u,l)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${l}`,children:r?u.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):u.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${u[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${u+l}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:o,emitEvent:e,disableExit:r,question:t,image:n,info:a,answer:u,hintUsed:l,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[y]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[p,_]=React$2.useState(0),[g,x]=React$2.useState(!1),[C,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,G]=React$2.useState([]),[V,W]=React$2.useState(!1),Z=u.toUpperCase().split(""),q=Z.filter(de=>restrictCharacters(de,"and")),z=de=>e({type:"translate",payload:de}),U=React$2.useCallback(()=>{const de=q.map(ke=>({char:ke}));let ce=[];const Se=analyzeChars(q);for(;ce.length<MAX_EXTRA_LETTERS;){const ke=makeChar(Se);ce=[...ce,{char:ke}]}return[...de,...ce]},[q]),I=u.toUpperCase().split("").map((de,ce)=>restrictCharacters(de,"or")?{index:ce,letter:de,char:de,fixed:!0}:{index:ce,letter:de,char:""}),$=React$2.useCallback(()=>{let de=U();for(;de.length>MAX_POOL_LETTERS;){const ce=Math.trunc(Math.random()*(de.length-1))+1,Se=de[ce],ke=I.find((Ne,We)=>Se.char===Ne.letter&&!I[We].fixed);ke&&(de.splice(ce,1),I[ke.index]={...ke,char:ke.letter,fixed:!0})}l&&(de=[],I.forEach(({letter:ce})=>{ce!==" "&&de.push({char:ce})})),w(I),R(de)},[I,l,U]),B=(de,ce)=>C.map((ke,Ne)=>Ne===ce?{...ke,deleted:!0}:{...ke}),X=(de,ce,Se)=>{const ke=ce.map((We,Ke)=>Se.find(pt=>pt.poolIndex===Ke)?{char:We.char}:We);R(ke),w(de);const Ne=de.find(We=>We.char==="");_(Ne.index)},Q=(de,ce)=>{y("click-ui");let Se=!1;const ke=T.map(Ke=>!Ke.char&&!Se?(Se=!0,{...Ke,char:de,poolIndex:ce}):Ke),Ne=B(de,ce),We=ke.filter(Ke=>Ke.char).length;R(Ne),w(ke),J(),We===T.length&&ie(ke,Ne)},J=()=>{var de;if(g){const ce=T.find(Se=>Se.index!==p&&Se.letter!==" "&&Se.char===""&&Se.poolIndex===!1);ce&&_(ce.index)}else{const ce=T.find(Se=>Se.char==="");_(ce.index+1),((de=T[ce.index+1])==null?void 0:de.letter)===" "&&_(ce.index+2)}},ne=()=>{y("click-ui");const de=T.map((ce,Se)=>T[T.length-1-Se]).find(ce=>ce.char&&!ce.fixed);if(de){const ce=T.map(Ne=>Ne.index===de.index?{...de,char:""}:Ne);let Se=!1;const ke=C.map((Ne,We)=>We===de.poolIndex&&(Ne.deleted||!Se)?(Se=!0,{char:Ne.char}):Ne);R(ke),w(ce),_(de.index)}},se=()=>{r(!0),O("");const de=[...F,...a.solution.right.rewards];y("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:de}),e({type:"passPuzzle"})},ee=()=>{y("fail"),e({type:"hidePuzzleButtons",payload:!1}),G([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},ie=(de,ce)=>{let Se=[];D(!0);const ke=de.map((We,Ke)=>Z[Ke]===We.char?{...We,fixed:!0}:(Se=[...Se,We],{...We,poolIndex:!1,char:""})),Ne=ke.filter(We=>We.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Ne===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{se()},2e3)):(O("failed"),X(ke,ce,Se),a.solution.wrong.desc===""&&setTimeout(()=>{ee()},2e3))},oe=()=>{if(P==="success")se();else{ee();const de=T.find(ce=>ce.char==="");_(de.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(de=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),de()},2e3)}),c(de=>{const ce=[];I.forEach(({letter:Se})=>{Se!==" "&&ce.push({char:Se})}),R(ce),de()})},[$,S,u,f,e,F,a.resolve.rewards,I,c]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${E}")`},children:[P?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:z,functionOnClose:oe,keyboardControl:h}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--hanged__content",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__controls",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__header",children:t}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${P}`,"data-testid":`${P}`,children:V?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,answer:u.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,flickerPosition:p,answer:T})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[C.sort((de,ce)=>sortChar(de,ce)).map((de,ce)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${de.char}`,type:"button",onClick:()=>{!de.deleted&&!P&&!k&&(Q(de.char,ce),y("click-ui"))},className:`puzzle--hanged__keyboard--item ${de.deleted||k?"disabled":""}`,children:de.char},`${de+ce}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":z("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${k?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})]})})]})}HangedPuzzleComponent.defaultProps={question:"",answer:"",image:{},hintBought:!1,info:{description:"",instructions:"",resolve:{},solution:{},hintBought:{}}};function CurrentImageClickPuzzle({list:o,description:e,nodeId:r,setInfo:t,emitEvent:n,disableExit:a,setResolveAction:u,soundActions:l,setSelected:f,selected:c,pause:h,loadPuzzleStatus:y,index:E,setIndex:p,slidesCompleted:_,setSlidesCompleted:g,keyboardControl:x,totalCorrects:C}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),T=`chained-image-click-puzzle_${E}_${r}`,[w]=l,P=Z=>{R.current=[...R.current,...Z]},O=React$2.useCallback(Z=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...Z]}),n({type:"passPuzzle"})},[w,n]),k=o[E],{info:D,specificFeedbacks:F}=k;D.description=e,React$2.useEffect(()=>{S.current=0,A.current=0},[E]);const G=React$2.useCallback((Z,q=!1)=>{var U;let z={..._};if(q){if((U=F==null?void 0:F.correctFeedbacks)!=null&&U.length&&!k.hasClickOnce)S.current+=1;else{let I=c;A.current&&(I-=A.current),S.current=k.areas.length,f(I+S.current)}S.current===k.areas.length&&(E+1>=o.length?O(Z):p(E+1),z={...z,[E]:!0},g(z)),P(Z)}else n({type:"addPoints",payload:Z,finish:!1}),n({type:"failPuzzle"}),k.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&k.hasClickOrder&&!c&&f(0)},[_,F,k.hasClickOnce,k.areas.length,k.hasClickOrder,c,f,E,o.length,g,O,p,n]),V=()=>{E>=o.length-1&&f(C),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:T,rewards:D.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...D,hintId:T})},[D,T,t]),React$2.useEffect(()=>{y&&E!==o.length-1&&G([],!0)},[E,o.length,y,G]);const W=()=>{const Z=k.hasClickOnce?k.areas.length:1;A.current+=Z,f(c+Z)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...k,puzzle:{name:T,component:"chained-image-click-puzzle"},specificFeedbacks:F,emitFinish:G,emitError:P,emitResolve:V,isLast:E+1===o.length,defaultCompleted:_[E]||!!y,hideContinue:E+1!==o.length,handleClick:W,emitEvent:n,disableExit:a,soundActions:l,setResolveAction:u,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:u,showFrames:l,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[y,E]=React$2.useState(0),[p,_]=React$2.useState(0),[g,x]=React$2.useState({}),C=`chained-image-click-puzzle_${p}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:C}),[r,C]),S=n.reduce((T,w)=>T+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:u,setInfo:e,setSelected:E,selected:y,index:p,setIndex:_,slidesCompleted:g,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[l?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[y," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:u,setFramesCompleted:l,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:y,description:E,translateFromParent:p,setInfo:_,emitEvent:g,nodeId:x,setSelected:C,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:T,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:G}){var J;const[V]=c,W=o[e],{info:Z,specificFeedbacks:q}=W;Z.description=E;const z=React$2.useRef(0),U=React$2.useRef(0),I=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...Z,hintId:I})},[_,Z,I]),React$2.useEffect(()=>{O&&(U.current=0,z.current=0,C(0),k(!1))},[O,k,C]),React$2.useEffect(()=>{U.current=0,z.current=0},[e]);const $=React$2.useCallback((ne,se=!1)=>{var ie;let ee={...t};if(se){if((ie=q==null?void 0:q.correctFeedbacks)!=null&&ie.length&&!W.hasClickOnce)U.current+=1;else{let oe=R;z.current&&(oe-=z.current),U.current=W.areas.length,w[0]&&Object.entries(t).length===0?C(U.current):C(oe+U.current)}U.current===W.areas.length&&(e+1>=o.length&&n(ne),ee={...ee,[e]:!0},l(ee),u(e+1>o.length-1?0:e+1)),a(ne)}else g({type:"addPoints",payload:ne,finish:!1}),g({type:"failPuzzle"}),W.hasClickOrder&&(C(R-U.current),U.current=0)},[t,(J=q==null?void 0:q.correctFeedbacks)==null?void 0:J.length,W.hasClickOnce,W.areas.length,W.hasClickOrder,a,R,w,C,e,o.length,l,u,n,g]),B=React$2.useCallback(()=>{e>=o.length-1&&C(G),V("score"),g({type:"hidePuzzleButtons",payload:!1}),T(ne=>({...ne,[e]:!0})),g({type:"puzzleAction",action:"resolve",payload:{element:I,rewards:Z.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,V,g,T,I,Z.resolve.rewards,C,G]),X=React$2.useCallback(()=>{l({}),U.current=0,z.current=0,S()},[S,l]);React$2.useEffect(()=>{f&&e!==o.length-1&&$([],!0)},[t,e,o.length,f,$]);const Q=()=>{const ne=W.hasClickOnce?W.areas.length:1;z.current+=ne,C(R+ne)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...W,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:q,emitFinish:$,emitResolve:B,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:y,translateFromParent:p,emitEvent:g,slideNumber:e,handleClick:Q,emitResetPuzzle:X,firstTryForFrame:A,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,pause:D,keyboardControl:F},e)}function Tooltip({emitEvent:o}){const e=r=>o({type:"translate",payload:r});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:o,total:e,tooltip:r,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[r?jsxRuntimeExports.jsx(Tooltip,{emitEvent:t}):null,jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__info--frames",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[o," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:o,nodeId:e,list:r,description:t,showFrames:n,soundActions:a,disableExit:u,setResolveAction:l,setInfo:f,pause:c,keyboardControl:h}){const[y,E]=React$2.useState({}),p=React$2.useRef([]),[_,g]=React$2.useState(0),[x,C]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[T,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((B,X)=>B+X.areas.length,0),G=B=>{p.current=[...p.current,...B]},V=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:V}),[o,V]),Z=React$2.useCallback(B=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...p.current,...B]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),p.current=[],S(0),g(0),C({}),w(!0),D(!0)},[]),z=B=>o({type:"translate",payload:B}),U=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:G,accRewards:p,setSelected:S,selected:R,setIndex:g,setFramesCompleted:C,loadPuzzleStatus:W,soundActions:a,setResolveAction:l,disableExit:u,translateFromParent:z,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:y,emitOpenPopupCounterInfo:()=>{_===0&&w(!1)},pause:c,keyboardControl:h,totalCorrects:F};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...$}),jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__content",children:[jsxRuntimeExports.jsx("div",{className:"puzzle-frame__controls",children:jsxRuntimeExports.jsx("div",{className:"puzzle-frame__progress",children:jsxRuntimeExports.jsx("div",{style:{width:`${R/F*100}%`},className:"puzzle-frame__progress--handle"})})}),n?jsxRuntimeExports.jsx("button",{disabled:T,"aria-hidden":T,type:"button",className:"puzzle-frame__info",onClick:U,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!T,emitEvent:o})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:o,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${o} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:o,children:jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"})})}EditButton.defaultProps={action:()=>{},className:""};const path="https://min.gamelearn.io/css-resources/gamelearn/resources/",imagesOptions=[{name:"webbuilder.imageOptions.image1",src:"Amor.jpg"},{name:"webbuilder.imageOptions.image2",src:"Bancorp.svg"},{name:"webbuilder.imageOptions.image3",src:"Amanda.jpg"},{name:"webbuilder.imageOptions.image4",src:"keyboard.jpg"},{name:"webbuilder.imageOptions.image5",src:"Melanie.jpg"},{name:"webbuilder.imageOptions.image6",src:"Sharon.jpg"},{name:"webbuilder.imageOptions.image7",src:"Bankex.svg"},{name:"webbuilder.imageOptions.image8",src:"Futbol.jpg"},{name:"webbuilder.imageOptions.image9",src:"GBL.svg"},{name:"webbuilder.imageOptions.image10",src:"Fooder.jpg"},{name:"webbuilder.imageOptions.image11",src:"Corporate.jpg"},{name:"webbuilder.imageOptions.image12",src:"Bank of Zamunda.svg"},{name:"webbuilder.imageOptions.image13",src:"mindfullness.jpg"},{name:"webbuilder.imageOptions.image14",src:"Nature.jpg"},{name:"webbuilder.imageOptions.image15",src:"Shopper.jpg"},{name:"webbuilder.imageOptions.image16",src:"Lab.jpg"}],colorOptions=["#c66a46","#3c9dc0","#6236ff","#21254f"],colorOptions2=["#39b7b9","#25a1d4","#f5a623","#080269"],titleOptions=[{title:"webbuilder.bank.titleOptions.title1.text",desc:"webbuilder.bank.titleOptions.title1.description"},{title:"webbuilder.bank.titleOptions.title2.text",desc:"webbuilder.bank.titleOptions.title2.description"},{title:"webbuilder.bank.titleOptions.title3.text",desc:"webbuilder.bank.titleOptions.title3.description"},{title:"webbuilder.bank.titleOptions.title4.text",desc:"webbuilder.bank.titleOptions.title4.description"},{title:"webbuilder.bank.titleOptions.title5.text",desc:"webbuilder.bank.titleOptions.title5.description"}],bankProps={backgroundImage:imagesOptions[10].src,backgroundLogo:imagesOptions[11].src,backgroundColor:"#21254f",btnColor:"#25a1d4"},BankTemplate={header:{color:bankProps.backgroundColor,logo:bankProps.backgroundLogo},body:{bankTitle:titleOptions[0].title,bankDesc:titleOptions[0].desc,bgImage:bankProps.backgroundImage,btnColor:bankProps.btnColor}};function BankHeader({showingReference:o,usingTemplate:e,openPopup:r,onSave:t,header:n,translate:a}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o?jsxRuntimeExports.jsx("div",{className:"bank--edit__logo",children:jsxRuntimeExports.jsx("img",{src:path+e.header.logo,alt:"",title:""})}):jsxRuntimeExports.jsxs("div",{className:"bank--edit__logo",children:[n.logo?jsxRuntimeExports.jsx("img",{src:path+n.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:u=>t({logo:u})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.mortgage")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupColorComponent",{colors:colorOptions,onSave:u=>t({color:u})})})]})]})}BankHeader.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};BankHeader.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookHeader({showingReference:o,usingTemplate:e,header:r,translate:t}){const n=o?e.header.userImage:r.userImage,a=o?e.header.username:r.username;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__logo",children:jsxRuntimeExports.jsx("span",{className:"icon-fb-logo"})}),jsxRuntimeExports.jsxs("span",{className:"facebook--header__user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__user--circle",style:{backgroundImage:`url(${path+n})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(a||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(o){const{isFacebook:e,header:r,showingReference:t,usingTemplate:n}=o,a=t?n.header.color:r.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${a}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...o}):jsxRuntimeExports.jsx(BankHeader,{...o})})})}WebBuilderHeader.defaultProps={isFacebook:!1,showingReference:!1,usingTemplate:{},header:{}};WebBuilderHeader.propTypes={isFacebook:PropTypes.bool,showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),header:PropTypes.shape({})};const facebookProps={backgroundImage:imagesOptions[12].src,backgroundUser:imagesOptions[5].src},userOptions=["webbuilder.userOptions.user1","webbuilder.userOptions.user2","webbuilder.userOptions.user3"],workOptions=["webbuilder.workOptions.work1","webbuilder.workOptions.work2","webbuilder.workOptions.work3"],studiesOptions=["webbuilder.studiesOptions.study1","webbuilder.studiesOptions.study2","webbuilder.studiesOptions.study3"],mailOptions=["webbuilder.mailOptions.mail1","webbuilder.mailOptions.mail2","webbuilder.mailOptions.mail3"],homeOptions=["webbuilder.homeOptions.home1","webbuilder.homeOptions.home2","webbuilder.homeOptions.home3"],FacebookTemplate={header:{username:userOptions[1],userImage:facebookProps.backgroundUser,bgImage:facebookProps.backgroundImage},body:{work:workOptions[2],home:homeOptions[1],studies:studiesOptions[0],mail:mailOptions[0]}};function WebBuilderFront({showingReference:o,usingTemplate:e,header:r,onSave:t,translate:n,openPopup:a}){const u=o?e.header.userImage:r.userImage,l=o?e.header.username:r.username,f=o?e.header.bgImage:r.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+u})`},children:o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({userImage:c})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:n(l||"webbuilder.facebook.header.userName")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:userOptions,onSave:c=>t({username:c})})}})]}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({bgImage:c})})}})]})}WebBuilderFront.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};WebBuilderFront.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.work:r.work,l=o?e.body.studies:r.studies,f=o?e.body.home:r.home,c=o?e.body.mail:r.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${u||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(u||"webbuilder.facebook.body.work")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:workOptions,onSave:h=>t({work:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${l||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(l||"webbuilder.facebook.body.studies")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:studiesOptions,onSave:h=>t({studies:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(f||"webbuilder.facebook.body.home")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:homeOptions,onSave:h=>t({home:h})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${c||o?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(c||"webbuilder.facebook.body.email")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:mailOptions,onSave:h=>t({mail:h})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),a("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),a("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),a("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),a("webbuilder.facebook.body.facebookEvent")]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--thinking",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--textarea",children:[jsxRuntimeExports.jsx("div",{className:"facebook--textarea__circle"}),jsxRuntimeExports.jsx("div",{className:"facebook--textarea__placeholder",children:a("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.bgImage:r.bgImage,l=o?e.body.btnColor:r.btnColor,f=a(o?e.body.bankTitle:"webbuilder.bank.body.image.title"),c=a(o?e.body.bankDesc:"webbuilder.bank.body.image.description");return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"bank--image__front",style:{backgroundImage:`url(${path+u})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:r.bankTitle&&!o?a(r.bankTitle):f}),jsxRuntimeExports.jsx("span",{children:r.bankDesc&&!o?a(r.bankDesc):c}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:titleOptions,onSave:h=>t({bankTitle:h.title,bankDesc:h.desc})})}}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{n("PopupImageComponent",{images:imagesOptions,onSave:h=>t({bgImage:h})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:a("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.current")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.new")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.confirm")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"bank--form__btn",style:{backgroundColor:`${l}`},children:a("webbuilder.save")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupColorComponent",{colors:colorOptions2,onSave:h=>t({btnColor:h})})}})]})]})})]})}function WebBuilderBody(o){const{isFacebook:e}=o;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...o}):jsxRuntimeExports.jsx(BankBody,{...o})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:o,backActive:e,action:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:r,children:o(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:o,displayButton:e,clickAction:r,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:o,action:r,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:o,success:e,showButton:r,translate:t}){const n=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),a=t(e?"webbuilder.feedback.success":"webbuilder.feedback.fail");return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`puzzle--webBuilder__feedback bottom ${e?"success":"failed"}`,style:e?{zIndex:"11"}:{},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"title",children:n}),jsxRuntimeExports.jsx("div",{className:"description",children:a})]}),r?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:o,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:o,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:o,children:jsxRuntimeExports.jsxs("div",{className:"gat--btn gat--btn__primary",children:[jsxRuntimeExports.jsx("span",{className:"icon-download-cloud"}),e("webbuilder.publish")]})})}PublishButton.defaultProps={onPublish:()=>{}};function PopupColorComponent({colors:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=u===null;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__colors",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--title",children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.colorSelect.title")})}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--items",children:o.map(c=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${u===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>l(c),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${c}`}})},c+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}PopupColorComponent.defaultProps={closingAction:()=>{},onSave:()=>{},colors:{}};PopupColorComponent.propTypes={closingAction:PropTypes.func,onSave:PropTypes.func,colors:PropTypes.arrayOf(PropTypes.string)};function PopupImageComponent({images:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=!u;return jsxRuntimeExports.jsx("div",{className:"folder-popup",children:jsxRuntimeExports.jsxs("div",{className:"folder-popup__content",children:[jsxRuntimeExports.jsxs("div",{className:"folder-popup__header",children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__title",children:[jsxRuntimeExports.jsx("span",{className:"folder-popup__icon-header icon-fb-search"}),jsxRuntimeExports.jsx("span",{children:t("webbuilder.imageSelect.title")})]}),jsxRuntimeExports.jsx("button",{onClick:r,className:"folder-popup__close",type:"button",children:jsxRuntimeExports.jsx("span",{className:"icon-close-fit"})})]}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__body",children:[jsxRuntimeExports.jsx("div",{className:"folder-popup__scroll",children:jsxRuntimeExports.jsx("ul",{className:"folder-popup__list",children:o.map(c=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>l(c),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:c.src,src:path+c.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:c.src,children:c.src})]},c.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:o,translate:e}){return o instanceof Object?e(o.title.toString()):jsxRuntimeExports.jsx("span",{children:e(o||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:o,onSave:e,options:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(""),f=u==="",[c,h]=React$2.useState(!1),y=c?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",E=()=>{h(!c)};return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__select",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__select--label",children:jsxRuntimeExports.jsx("div",{dir:"auto",children:t("webbuilder.textSelect.title")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:y,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:u,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(p=>p instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:[jsxRuntimeExports.jsx("span",{children:t(p.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(p.desc)})]},p.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:t(p)},p))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:o,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,disabled:f,onClick:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}const POPUPS=Object.freeze(Object.defineProperty({__proto__:null,PopupColorComponent,PopupImageComponent,PopupTextComponent},Symbol.toStringTag,{value:"Module"})),defaultHeader={username:null,logo:null,userImage:null,bgImage:null,color:""},defaultBody={bankTitle:null,color:"",btnColor:"",work:null,home:null,mail:null,studies:null,bgImage:null};function PopupComponent({type:o,close:e,translate:r,soundActions:t,...n}){const a=POPUPS[o];return a?jsxRuntimeExports.jsx(a,{type:o,...n,closingAction:e,translate:r,soundActions:t}):null}function DisplayingFeedback({feed:o,resolved:e,translate:r,onNext:t}){return o==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:r}):o==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:r}):null}function WebBuilderPuzzleComponent({type:o,info:e,emitEvent:r,setResolveAction:t,soundActions:n,disableExit:a,keyboardControl:u}){const[l,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(!1),[p,_]=React$2.useState(!1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[T,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,G=Q=>r({type:"translate",payload:Q}),V=()=>{w({type:"",props:{}})},W=(Q,J={})=>{w({type:Q,props:J})},Z=()=>{if(e.solution){const{rewards:Q}=e.solution.right,{rewards:J}=e.solution.wrong;F(y?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:y?J:Q}),r({type:"passPuzzle"})}};u(null,C==="success"?Z:null,C==="success"?Z:null);const q=(Q,J)=>{const ne=Object.keys(Q),se={existing:0,equal:0};return ne.forEach(ee=>{J[ee]!==null&&J[ee]!==""&&(se.existing+=1),Q[ee]===J[ee]&&(se.equal+=1)}),se},z=(Q,J)=>{const ne=Object.keys(A.header).length,se=Object.keys(A.body).length,ee=q(A.header,Q),ie=q(A.body,J),oe=ie.existing+ee.existing===ne+se,fe=ie.equal+ee.equal===ne+se;return{exist:oe,equal:fe}},U=()=>{F("click-ui");const{exist:Q,equal:J}=z(P,k);r({type:"hidePuzzleButtons",payload:!0}),Q&&!J?(g&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):Q&&J&&(g&&(a(!1),x(!1)),_(!0),R("success"))},I=Q=>{if(Object.keys(Q).length>0){const J={...P,...Q};O(J),V();const{exist:ne}=z(J,k);x(!!ne)}},$=Q=>{if(Object.keys(Q).length>0){const J={...k,...Q};D(J),V();const{exist:ne}=z(P,J);x(!!ne)}};React$2.useEffect(()=>{t(Q=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),Q()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const B={showingReference:l||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:G},X=()=>{C==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):C==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:T.type,...T,close:V,soundActions:n,translate:G}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:l,displayButton:!c&&!p,translate:G,clickAction:()=>{F("click-ui"),f(!l)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...B,header:P,onSave:I}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...B,header:P,onSave:I}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...B,body:k,onSave:$})]}),!g&&!l?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:C,onNext:X,resolved:c,translate:G}):null,g&&!l?jsxRuntimeExports.jsx(PublishButton,{onPublish:U,translate:G}):null]})}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),u=()=>{const _=(o.img||{}).url;return jsxRuntimeExports.jsx("img",{src:_,alt:""})},l=()=>o.text?jsxRuntimeExports.jsx("div",{className:`card-selector-item__textbox ${o.img?"":"card-selector-item__textbox--noimage"}`,children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__text",children:jsxRuntimeExports.jsx("span",{children:o.text||"_"})})}):null,f=()=>!!(r&&!o.correct||!r),c=()=>jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedback card-selector-item__feedback--error",children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black"})})}),h=()=>o.order?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:o.order})}):null,y=()=>jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[h(),jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black"})})]}),E=()=>!a()&&r&&o.correct&&!n?y():!a()&&r?c():null;return jsxRuntimeExports.jsxs("button",{type:"button",order:o.order,onClick:()=>{!a()&&f()&&e(t)},className:`unset-button card-selector-item ${a()?"card-selector-item--empty":""}`,"aria-label":o.text?o.text:null,children:[u(),l(),E()]})}Card.defaultProps={handleClick:()=>{},documentsDict:{},card:{},flipped:!1,wrongOrder:!1,cardIndex:0};Card.propTypes={wrongOrder:PropTypes.bool,handleClick:PropTypes.func,cardIndex:PropTypes.number,flipped:PropTypes.bool,documentsDict:PropTypes.shape({}),card:PropTypes.shape({correct:PropTypes.bool,order:PropTypes.number,text:PropTypes.string,imgId:PropTypes.string,status:PropTypes.string})};function Board({cards:o,currentOrder:e,setCurrentOrder:r,handleError:t,feedbackIsShown:n,resolvePuzzle:a,soundActions:u,onFinish:l,handleSuccess:f,resolveWithAnyCard:c}){const[h,y]=React$2.useState(Array(o.length).fill(!1)),[E,p]=React$2.useState(Array(o.length).fill(!1)),[_,g]=React$2.useState(0),[x,C]=React$2.useState(!1),[R]=u,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,T=React$2.useCallback(()=>{y(Array(o.length).fill(!1)),p(Array(o.length).fill(!1)),g(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{T()},1e3)};function P(F){const G=Array.from(h);G[F]=F,y(G)}const O=React$2.useCallback(()=>{const F=[];o.forEach((G,V)=>{G.correct===!0&&F.push(V)}),y(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(l(),C(!0),g(0))},[_,l,S,c]);const k=F=>{P(F),f(o[F].id||null),g(_+1)},D=F=>{var G,V;if(!x&&!n)if(R("click-ui"),o[F].correct&&!A)k(F);else if(A)if(o[F].order===e)r(e+1),k(F);else{if(o[F].order!==e){const W=Array.from(E);W[F]=F,p(W),t(((G=o[F])==null?void 0:G.id)||null,o[F].correct),w()}P(F)}else t(((V=o[F])==null?void 0:V.id)||null),w(),P(F)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,G)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(G),flipped:h.includes(G),wrongOrder:E.includes(G),cardIndex:G},`cardPuzzle ${o.indexOf(F)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:o,info:e,cards:r,resolveWithAnyCard:t,specificFeedbacks:n,disableExit:a,setResolveAction:u,soundActions:l,backgroundImage:f,nodeId:c,keyboardControl:h}){var $,B;const[y,E]=React$2.useState(!1),[p,_]=React$2.useState(1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(!1),[k,D]=React$2.useState(""),[F]=l,G=X=>o({type:"translate",payload:X}),V=`cards-selector-puzzle_${c}`,W=React$2.useCallback(X=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},[o]),Z=React$2.useCallback(()=>{var ne,se;o({type:"hidePuzzleButtons",payload:!0}),x(!0);const{rewards:X}=((ne=e==null?void 0:e.solution)==null?void 0:ne.right)||{},Q=((se=n==null?void 0:n.correctFeedbacks)==null?void 0:se.map(ee=>ee.rewards).flat())||[],J=[...T,...X,...Q];F("score"),W(J)},[T,W,o,($=e==null?void 0:e.solution)==null?void 0:$.right,F,n==null?void 0:n.correctFeedbacks]),q=()=>{E(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&D(e.solution.right.desc),A(!0)},z=()=>{g||y?Z():(x(!1),a(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1})),D("")},U=X=>{if(R(!0),n!=null&&n.specificCorrectFeedbacks){const Q=n.correctFeedbacks.find(J=>J.id===X);Q!=null&&Q.desc&&(D(Q.desc),A(!0))}F("score"),o({type:"hidePuzzleButtons",payload:!0})},I=(X,Q=!1)=>{var J,ne;if(R(!1),Q)D((J=e.orderFeedback)==null?void 0:J.desc),A(!0),w([...T,...((ne=e.orderFeedback)==null?void 0:ne.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const se=n.wrongFeedbacks.find(ee=>ee.id===X);se!=null&&se.desc?(D(se.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),w([...T,...(se==null?void 0:se.rewards)||[]])}else e.solution.wrong.desc?(D(e.solution.wrong.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!Q&&w([...T,...e.solution.wrong.rewards]),F("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};return React$2.useEffect(()=>{y&&a(!0)},[a,y]),React$2.useEffect(()=>{u(()=>{var Q;o({type:"hidePuzzleButtons",payload:!0}),O(!0);const X=[...T,...((Q=e==null?void 0:e.resolve)==null?void 0:Q.rewards)||{}];setTimeout(()=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:X,finish:!0}})},2e3)})},[u,a,T,(B=e==null?void 0:e.resolve)==null?void 0:B.rewards,o,V]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cards-selector ${f!=null&&f.url?"cards-selector--with-custom-bg":""}`,style:f!=null&&f.url?{backgroundImage:`url("${f.url}")`}:{},children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:_,currentOrder:p,cards:r,onFinish:q,resolveWithAnyCard:t,handleError:I,feedbackIsShown:S,resolvePuzzle:P,soundActions:l,handleSuccess:U})}),S&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:g||C,text:k,hasTimeout:!k,translate:G,functionOnClose:z,keyboardControl:h})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:o,index:e,length:r,textToPrint:t,setDoneTyping:n,nextParagraphType:a,isWriting:u}){const[l,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[y,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const p=C=>{if(!C||!C.length)return"";const R=C.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const C=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const T=[...S];if(p(S[A]).length!==0){const w=S[A];return T[A]=`<span class="lastWord" >${w}</span>`,T}return R(S,A-1)};a==="election"?h(C()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},g=t.split("<p>");g.shift();const x=g.length>1;return l&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:u,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&y&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:o,decisionInspected:e,setCurrentDecisionSelected:r,index:t,setCurrentDecisionInspected:n,soundActions:a}){const[u]=a,l=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{u("click-ui"),r(t)},h=E=>{E.keyCode===13&&y(E)},y=E=>{E.preventDefault(),E.stopPropagation(),e===t?(E.target.style.background="",n("")):n(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>c(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:l(o)})}),jsxRuntimeExports.jsx("div",{onClick:y,onKeyDown:h,className:f(o),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(o.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:o,opt:e,index:r,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,soundActions:a}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:o,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,option:e,soundActions:a,index:r}):null}function ElectionComponent({textWithOpts:o,setCurrentDecisionSelected:e,printed:r,soundActions:t}){const[n,a]=React$2.useState("");return React$2.useEffect(()=>{r()},[r]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${n+1}-${o.filter(u=>!!u.fullText).length}`,children:o&&o.map((u,l)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:u,soundActions:t,index:l,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},l))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:o}){const{title:e,body:r}=o.feedback;return jsxRuntimeExports.jsx("div",{children:r!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),r&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[o.correct?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("span",{children:r})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:o,closingAction:e,feedbackIsDone:r,decisionsList:t,texts:n,retryAction:a,retry:u,skip:l,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:y}){const[E]=y,p=g=>o({type:"translate",payload:g}),_=()=>{E("click-ui"),e(),h(),r()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${c.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:p("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(g=>n[g.currenTextParagraph].electionTexts[g.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[g.currenTextParagraph].electionTexts[g.index]},g.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:p("puzzles.skip")}),u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:p(f()?"puzzles.continue":"puzzles.retry")}),!u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:p("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:o,correct:e}){const r=o.split("<p>");r.shift();const t=r.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(o)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:o,styles:e,nodeId:r,retry:t,skip:n,type:a,info:u,setResolveAction:l,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:y,backgroundImage:E}){const p=Ie=>o({type:"translate",payload:Ie}),_=React$2.useRef(),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(0),[T,w]=React$2.useState({[`text_${S}`]:{...h[S],id:`text_${S}`,correct:""}}),[P,O]=React$2.useState(!1),[k,D]=React$2.useState([]),[F,G]=React$2.useState(!1),[V,W]=React$2.useState(!1),[Z,q]=React$2.useState(!1),[z,U]=React$2.useState(!0),[I,$]=React$2.useState([]),[B,X]=React$2.useState(!0),[Q]=y,J=React$2.useRef({}),ne=Ie=>{let et;return Ie.electionTexts.forEach((at,Kt)=>{at.correct&&(et=Kt)}),et},se=React$2.useCallback(Ie=>k.filter(at=>at.currenTextParagraph===Ie)[0].fullText_labelId,[k]),ee=React$2.useCallback(()=>h.map((Ie,et)=>{if(Ie.type==="fixed")return Ie.fullText_labelId??Ie.fullText;if(Ie.type==="election"){const at=ne(Ie);return at>=0?Ie.electionTexts[at].fullText_labelId:se(et)}return""}),[se,h]),ie=12,oe=()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="none"&&(et+=1);return et===Ie}return!0},fe=React$2.useCallback(()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="green"&&(et+=1);return et===Ie}return!0},[k]),de=()=>!!(k&&k.length),ce=()=>k.find(Ie=>{const{feedback:et}=h[Ie.currenTextParagraph].electionTexts[Ie.index];return et.body!==""}),Se=React$2.useCallback(()=>{const Ie=ee();o({type:"finishMedia",payload:{name:c,text:Ie,documentType:a,type:"text"}})},[ee,c,o,a]),ke=React$2.useCallback(Ie=>{const et=fe();Q(C?"fail":et?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ie||I,onFinish:a!=="view"?Se:null}),o({type:"passPuzzle"})},[fe,o,C,Se,Q,I,a]);React$2.useEffect(()=>{g&&X(!1),l(()=>{ke(u.resolve.rewards)})},[o,ke,g,Se,u.resolve.rewards,l,a]);const Ne=()=>{x(!1),A(0),D([]),$([]),R(!1),q(!1),O(!1),W(!1),G(!1),w({text_0:{...h[0],id:"text_0",correct:""}}),U(!0),o({type:"addPoints",complex:!0,finish:!1,payload:I}),o({type:"failPuzzle"})},We=()=>{de()?oe()&&(G(!0),ke()):(G(!0),q(!0),ke()),F?(U(!1),Z&&!V?W(!0):(V||!Z&&!V)&&(!Z&&!V&&t?fe()?ke():Ne():ke())):(G(!0),ce()&&q(!0))},Ke=()=>{const Ie=h[S].electionTexts.filter(at=>at.correct).length,et=h[S].electionTexts;return Ie===0||Ie===et},Qe=Ie=>{const et=h[S].electionTexts[Ie],at=et.feedback.rewards;at&&at[0]&&at[0].points&&(J.current[`t${S}_e${Ie}`]||(et.correct&&(J.current[`t${S}_e${Ie}`]=!0),$([...I,...at])));const Kt=()=>Ke()?"none":et.correct?"green":"red",Xe={currenTextParagraph:S,fullText:et.fullText,index:Ie,isCorrect:Kt()};w({...T,[`text_${S}`]:{type:"fixed",fullText:et.fullText,correct:Xe.isCorrect}}),D([...k,Xe])},pt=()=>{_.current.scrollTop=_.current.scrollHeight+100},vt=()=>{if(_.current.querySelector(".wrapfixed").offsetHeight>_.current.offsetHeight){const Ie=_.current.querySelector(".wrapfixed").offsetHeight;_.current.scrollTo({top:Ie,behavior:"smooth"})}},ct=(Ie,et,at)=>{const Kt=Ie.fullText,Xe=h[at+1]?h[at+1].type:"",it=T[`text_${at+1}`]&&T[`text_${at+1}`].type?T[`text_${at+1}`].type:Xe;return jsxRuntimeExports.jsx(FixedComponent,{length:et,doneTyping:P,index:at,delay:ie,setDoneTyping:O,nextParagraphType:it,isWriting:vt,textToPrint:Kt},at.toString())},mt=(Ie,et)=>{const at=Ie.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:at,correct:Ie.correct},et)},Vt=Ie=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:y,textWithOpts:Ie.electionTexts,setCurrentDecisionSelected:Qe,printed:pt,disableExit:B},Ie.electionTexts),kt=(Ie,et,at)=>Ie.type==="fixed"?ct(Ie,et,at):Vt(Ie);return React$2.useEffect(()=>{P===!0&&(()=>{h[S+1]?(w({...T,[`text_${S+1}`]:{...h[S+1],id:`text_${S+1}`,correct:""}}),A(S+1),O(!1)):x(!0)})()},[P,S,T,h]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:`writer-puzzle writer-puzzle--${e}`,style:E!=null&&E.url?{backgroundImage:`url("${E.url}")`}:{},children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[V&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>R(!0),decisionsList:k,closingAction:We,retry:t,skip:n,checkCorrect:fe,retryAction:Ne,rewardsStack:I,nodeId:r,soundActions:y}),!V&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:f!==""&&f}),jsxRuntimeExports.jsx("div",{className:"writer-puzzle__body",dir:LangIsRtl()?"rtl":"auto",children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__scroll",tabIndex:0,style:{overflowX:"hidden",padding:"0 0 20px 0",height:"95%"},ref:_,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:z&&!F&&Object.values(T).map((Ie,et)=>kt(Ie,Object.values(T).length-1,et))}),F&&Object.values(T).map((Ie,et)=>mt(Ie,et))]})}),g&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:We,children:p("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:o,name:e,isWallpaper:r}){const t=(o==null?void 0:o.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${r?"puzzle--terminal__image--wallpaper":""}`,children:t?jsxRuntimeExports.jsx("img",{src:t,alt:e||""}):null})}const ICONS$1={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",world:"world-icon"};function Visor({file:o,solution:e,showContinue:r,info:t,resolvePuzzle:n,backFile:a,translate:u,soundActions:l,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[y]=l,E={image:{component:Image$1,props:{...o,url:h,soundActions:l}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:l,translate:u}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:l}},pdf:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const p=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),C=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,shortText:!0,success:c===C,text:c===C?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===C?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:u,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(p,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===C&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:u("screens.continue")}):null})]})})}const ICONS={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",application:"pdf-icon",world:"world-icon"};function Item({item:o,selectItem:e}){const r=o.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:r,className:`unset-button puzzle--terminal__item id-${o.id}`,onClick:()=>o.fixed?null:e(o),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[o.type]}`}),jsxRuntimeExports.jsx("span",{children:r})]})})}function FilesGroup({initFile:o,backFile:e,file:r,closeFolder:t,selectItem:n}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:r.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${u}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))}),jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder--head",children:[jsxRuntimeExports.jsx("span",{role:"button",onKeyUp:()=>{},"aria-label":"back file",tabIndex:0,onClick:()=>e(),className:"puzzle--terminal__folder--back",children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__folder--head__icon ${ICONS[r.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:r.name}),jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,"aria-label":"close folder",onKeyUp:()=>{},onClick:()=>t(),className:"puzzle--terminal__folder--close",children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__folder--body",children:jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))})})]})]})})}const DEFAULT_IMG="https://min.gamelearn.io/css-resources/gamelearn/resources/cosmos-bg-min.jpg",FIXED_ITEMS=[{fileId:"ids1",type:"world",fixed:!0,name:"Web builder 3.0"},{fileId:"ids2",type:"cracker",fixed:!0,name:"Decoder.exe"},{fileId:"ids3",type:"terminal",fixed:!0,name:"terminal"}];function TerminalPuzzleComponent({emitEvent:o,items:e,backgroundImage:r,solution:t,info:n,disableExit:a,soundActions:u,setResolveAction:l,nodeId:f,keyboardControl:c}){const[h,y]=React$2.useState({}),[E]=React$2.useState(!1),[p,_]=React$2.useState([]),g=React$2.useRef([]),[x]=u,C=k=>o({type:"translate",payload:k}),R=`terminal-puzzle_${f}`,S=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),A=React$2.useCallback(k=>{x("click-ui"),y(k),_([...p,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[p,a,o,x]);React$2.useEffect(()=>{y(S),_([S])},[S]),React$2.useEffect(()=>{l(()=>{g.current=[...g.current,...n.resolve.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:k,finish:!0}})})},[l,n.resolve.rewards,o,R]);const T=()=>{g.current=[...g.current,...n.solution.wrong.rewards];const k=p.length-1,D=p.filter((F,G)=>k>G);y(p[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=p[0];y(k),_([k])},P=()=>{g.current=[...g.current,...n.solution.right.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),x("score"),o({type:"addPoints",complex:!0,finish:!0,payload:k}),o({type:"passPuzzle"})},O=(r==null?void 0:r.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:h.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:O}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:T,initFile:S,selectItem:A,breadcrumb:p,closeFolder:w,file:h,translate:C})]}):jsxRuntimeExports.jsx(Visor,{soundActions:u,backFile:T,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:C,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:u,emitEvent:l,soundActions:f,keyboardControl:c}){const{solution:h}=t,y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),g=React$2.useRef({}),[x,C]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(),[O]=React$2.useState(new window.Image),k=React$2.useRef([]),[D]=f,F=J=>l({type:"translate",payload:J});React$2.useEffect(()=>{u(x!=="")},[x,u]);const G=(J,ne)=>(J.x+J.width>ne.x&&J.x+J.width<=ne.x+ne.width||ne.x+ne.width>J.x&&ne.x+ne.width<=J.x+J.width)&&(J.y+J.height>ne.y&&J.y+J.height<=ne.y+ne.height||ne.y+ne.height>J.y&&ne.y+ne.height<=J.y+J.height),V=()=>{y&&n&&(y.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},W=()=>{y&&n&&(y.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},Z=React$2.useCallback(J=>{let ne=!1;if(J){const se=p.current;se.setPointersPositions(J);const ee=se.getPointerPosition(),ie=y.current.getClientRect({relativeTo:se});ne=G({...ee,width:1,height:1},ie)}return ne},[]),q=React$2.useCallback(J=>J&&r.uid===JSON.parse(J).uid,[r.uid]),z=React$2.useCallback(()=>{C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:k.current}),l({type:"passPuzzle"}),a&&l({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),l({type:"closeUI",ui:"inventory"})},[a,l,r.name,r.uid]),U=React$2.useCallback(()=>{C("success"),l({type:"hidePuzzleButtons",payload:!0}),k.current=[...k.current,...h.right.rewards],setTimeout(()=>{z()},2e3)},[l,z,h.right.rewards]),I=React$2.useCallback(()=>{l({type:"openUI",ui:"inventory",onFinish:()=>{}}),C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"failPuzzle"}),k.current=[...k.current,...h.wrong.rewards]},[l,h.wrong.rewards]),$=React$2.useCallback(J=>{const ne=J.dataTransfer.getData("item");p.current.setPointersPositions(J);const se=Z(J);l({type:"hidePuzzleButtons",payload:!0}),se&&q(ne)?(C("success"),l({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&U()):(l({type:"closeUI",ui:"inventory"}),C("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{I()},2e3))},[Z,q,l,U,I,t.solution.right.desc,t.solution.wrong.desc]),B=()=>{x==="success"?U():I()};React$2.useEffect(()=>{const J=e.img.url||"";O.src=J,O.onload=()=>{_.current&&(g.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:O.width,height:O.height,offsetX:O.width/2,offsetY:O.height/2,scale:{x:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height),y:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height)}},S(!0))}},[O,e.img.url]),React$2.useEffect(()=>{A||(l({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(!0))},[A,l]);const X=J=>{J!==null&&(y.current=J)},Q=J=>{if(J!==null&&(E.current=J,y.current)){const{x:ne,y:se,width:ee,height:ie}=y.current.getClientRect();J.setAttr("x",ne),J.setAttr("y",se),J.setAttr("height",ie),J.setAttr("width",ee)}};return React$2.useLayoutEffect(()=>{if(y.current&&R){const J=y.current.getClientRect({relativeTo:y.current.getParent()});P({x:J.x+J.width/2,y:J.y+J.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:$,onDragOver:J=>{J.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:_,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:R?jsxRuntimeExports.jsx(Stage,{ref:p,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:O,...g.current}),jsxRuntimeExports.jsxs(Group,{...g.current,children:[w?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...w},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:V,onMouseLeave:W,ref:X,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:V,onMouseLeave:W,ref:Q,text:F("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),x!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[x==="success"?"right":"wrong"].desc,success:x==="success",translate:F,playSound:D,functionOnClose:B,keyboardControl:c}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:o,answered:e,question:r,updateForm:t,result:n,correctQuestions:a,translate:u}){const[l,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let C=!1;return n[r.id].find(R=>R.id===x)&&(C=!0),C},y=x=>{let C="";return l?(e&&h(x.id)&&(C="selected"),o&&h(x.id)&&a.includes(x.id)&&(C="success"),o&&h(x.id)&&!a.includes(x.id)&&(C="failed")):(e&&x.id===n[r.id][0].id&&(C="selected"),o&&x.id===n[r.id][0].id&&(C=n[r.id][0].isCorrect?"success":"failed")),C},E=x=>{const C=y(x);return C==="selected"?"icon-check-circle-black color--selected":C==="success"?"icon-check-circle-black color--success":C==="failed"?"icon-error-circle-black color--error":""},p=x=>o&&x.feedback&&(l&&h(x.id)||x.id===n[r.id][0].id),_=(x,C)=>C===0?"tooltip--right__top":C===x.length-1?"tooltip--right__bottom":"tooltip--center__right",g=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{g.length===1?f(!1):f(!0)},[g.length,l,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),l&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:u("tests.chooseMoreOneAnswer")}):null,c.map((x,C)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[l?jsxRuntimeExports.jsx("input",{checked:e&&h(x.id),disabled:o&&!h(x.id),readOnly:o,type:"checkbox",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!y(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${y(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[C]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:x.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${E(x)}`})]}),o?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${p(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${y(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${C}`,className:`tooltip ${_(c,C)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:u("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:x.feedback})})]})]}):null]},x.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:o,correctQuestions:e,question:r,translate:t}){const n=l=>e.includes(l),a=(l,f)=>l.index<f.index?-1:l.index>f.index?1:0,u=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),u.map(l=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(l.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[l.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:l.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(l.id)?"icon-check-circle-black color--success":"icon-error-circle-black color--error"}`})]}),jsxRuntimeExports.jsxs("div",{className:"test--feedback",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsxs("span",{children:[t("test.feedback")," ",o.length>1?LABELS_INDEX[l.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:l.feedback})]})]},l.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:u,showResults:l,answered:f,answerPage:c,updateForm:h,disabled:y,translate:E,soundActions:p,paused:_,view:g,correctQuestions:x,feedbacksOnlyWhenReview:C}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[T,w]=React$2.useState(),P=o[S].id,[O]=p;React$2.useEffect(()=>{if(u>=0&&!y&&!_){const q=setInterval(()=>{T||e(z=>z-1)},1e3);return r(q),()=>{clearInterval(q)}}},[y,T,_,r,e,u]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!y&&!C?w(!0):(c(!1),A(S+1)))},D=()=>{O("click-ui"),A(S-1)},F=()=>{R.scrollTo(0,0),o[S+1]?(w(!1),c(!1),A(S+1)):l()},G=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!y&&!C?w(!0):l()},V=Math.floor(u/60),W=u%60;React$2.useEffect(()=>{if(g==="review"){const q=t[`q${S}`][0].id,z=document.querySelector(`#${q}`);R.scrollTo(0,z.offsetTop)}},[S,R,t,g]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,z=t[P],U=z.find($=>$.isCorrect===!1);let I=0;return z.forEach($=>{q.includes($.id)&&(I+=1)}),!U&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||T?jsxRuntimeExports.jsx("div",{className:`test-feedback-header ${Z()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${Z()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:Z()?E("tests.resolvedQuestion"):E("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:T?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:x[o[S].id.substring(1)].answers,question:o[S].text,translate:E}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[S+1,"/",o.length," ",jsxRuntimeExports.jsx("span",{children:E("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:E("tests.question")})," ",S+1,"/",o.length]})}),g!=="review"&&u>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${u<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[V<10?`0${V}`:V," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:y,answered:f,updateForm:h,question:o[S],correctQuestions:y?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${g==="review"?"reviewmode":"next"}`,children:[g==="review"?jsxRuntimeExports.jsx("button",{disabled:S===0,id:"back-button",onClick:()=>D(),type:"button",className:`gat--btn__navigation ${S===0?"disabled":""}`,"aria-label":LangIsRtl()?E("survey.next"):E("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!T&&o[S+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,T?jsxRuntimeExports.jsx("button",{id:"next-button",onClick:()=>F(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!T&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&G()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:o,time:e,mandatory:r,correctQuestions:t,isFirst:n,reviewTest:a,finishTest:u,restartTest:l,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:y}){const[E,p]=React$2.useState(0),[_,g]=React$2.useState(),[x,C]=React$2.useState([]),[R,S]=React$2.useState([]),[A,T]=React$2.useState([]),w=React$2.useCallback(()=>{const z=[];return t.forEach(U=>z.push(U.answers)),z},[t]),P=React$2.useCallback(()=>{const z=[];return Object.values(o).forEach(U=>{if(U.length>1){const I=U.find(B=>B.isCorrect===!1),$=[];I?z.push([]):(U.forEach(B=>{B.isCorrect&&$.push(B.id)}),z.push($))}else U[0].isCorrect?z.push([U[0].id]):U[0].isCorrect===!1&&z.push("")}),z},[o]),O=React$2.useCallback(()=>{let z=0;return R.length>0&&x.forEach((U,I)=>{U.length>1?U.every($=>R[I].includes($))&&(z+=1):U.length===1&&R[I]&&U[0]===R[I][0]&&(z+=1)}),z},[x,R]);React$2.useEffect(()=>{C(w),S(P),T(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<y,G=A>=y,V=!r||G,W=Math.trunc(E/k*100),Z=(z,U)=>h({type:"translate",payload:z,values:U}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const z=setInterval(()=>{p(U=>U+1)},100);return g(z),()=>{clearInterval(z)}}},[A,E]),React$2.useEffect(()=>{E>=A&&clearInterval(_)},[A,_,E]),jsxRuntimeExports.jsxs("div",{className:`test--results ${F||f?"test--results--failed":""}`,children:[n&&D?jsxRuntimeExports.jsxs("div",{className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!f&&F?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.NotFinishedSuccessfully")})}):null,!f&&G||D?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.finishedSuccessfully")})}):null,f?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:c})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:Z("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${W}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:F||f?q:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:F||f?q:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{children:E}),jsxRuntimeExports.jsxs("span",{children:["/",k]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:Z("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:Z("tests.minimumQuestionsMessage",{minimumPercentage:y})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>a(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.review")})}),V?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>l(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),V?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.continue")})}):null]})]})}function TestComponent({test:o,countdown:e={},emitEvent:r,soundActions:t,audio:n,required:a,pause:u,minimumPercentage:l=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,y]=React$2.useState({}),[E,p]=React$2.useState(),[_,g]=React$2.useState(0),[x,C]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,T]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[G,V]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,z=React$2.useRef({}),[U,I]=React$2.useState(),[$,B]=t,X=(ie,oe,fe,de,ce)=>{const Se={...ie,index:fe};if(_>0&&(Se.rewards=Se.rewards.filter(Ne=>!G[ie.id]||Ne.points<0)),h[oe]){const Ne=h[oe].find(We=>We.id===ce);if(Ne){if(Ne.id===ie.id){const We=h[oe].find(Qe=>Qe.id===ce),Ke=h[oe].indexOf(We);if(h[oe].splice(Ke,1),h[oe].length===0){T(!1);return}}}else h[oe].push(Se)}else h[oe]=[Se];let ke;de==="isRadio"?ke={...h,[oe]:[Se]}:ke={...h},y(ke),F(ke),V({...G,[ie.id]:{...ie}}),T(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(ie=>{const oe=ie.answers.filter(de=>de.isCorrect),fe=[];return oe.forEach(de=>{fe.push(de.id)}),{question:ie.id,answers:fe}});React$2.useEffect(()=>{C(Q)},[Q]),React$2.useEffect(()=>{if(l){const ie=Math.ceil(c.length*l/100);I(ie)}},[c.length,l]),React$2.useEffect(()=>{R===0&&(clearInterval(E),T(!1),Z(!0),P("results"),B("tts"))},[E,B,R]);const J=()=>{clearInterval(E),T(!1),P("results");const ie={...D};F(ie),B("tts")},ne=()=>{const ie={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(de=>{z.current[de.id]&&(de.rewards=[])})}),r({type:"saveTest",payload:ie})},se=()=>{const ie=()=>{F({}),V({}),P("test"),y({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(de=>{de.forEach(ce=>{ce.isCorrect&&(z.current[ce.id]?ce.rewards=[]:z.current[ce.id]=!0)})});let fe=oe.reduce((de,ce)=>{const Se=[];return ce.forEach(ke=>{Se.push(ke.rewards)}),[...de,...Se.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:ie}),r({type:"failTest"})},ee=(ie,oe)=>r({type:"translate",payload:ie,values:oe});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"test--container",dir:"auto",children:w!=="results"?jsxRuntimeExports.jsx(Container,{result:h,time:R,setTries:g,tries:_,answerPage:T,setTime:S,paused:u,saveInterval:p,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:J,translate:ee,soundActions:t,view:w,correctQuestions:x,feedbacksOnlyWhenReview:f}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),P("review")},isFirst:O,finishTest:ne,time:R,mandatory:q,restartTest:se,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:U})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((u,l)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--response__item ${e[r]===u?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[l]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${u}`)})]},u))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(u=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--points__item ${e[r]===u?"selected":""}`,children:u},u))}),jsxRuntimeExports.jsxs("div",{className:"survey--points__labels",children:[jsxRuntimeExports.jsx("span",{children:t("survey.bad")}),jsxRuntimeExports.jsx("span",{children:t("survey.excellent")})]})]})}function TextBox({setSurveyData:o,survey:e,id:r,literalLabel:t}){const n=a=>{o({...e,[r]:a})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:a=>{a&&a.focus()},className:"survey--textarea",id:t,value:e[r],onChange:a=>n(a.target.value)})})}const INIT_SURVEY={applicable:"",opinion:"",comments:"",suggestions:""},PAGES=[{component:ApplicableBox,id:"applicable"},{component:OpinionBox,id:"opinion"},{component:TextBox,id:"comments"},{component:TextBox,id:"suggestions"}];function SurveyComponent({emitEvent:o,soundActions:e}){const[r,t]=React$2.useState(INIT_SURVEY),[n,a]=React$2.useState(0),[u,l]=React$2.useState(!1),[f]=e,c=(E,p)=>o({type:"translate",payload:E,values:p}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)l(!0);else{E&&l(!1);const p=E?n-1:n+1;a(p)}},y=PAGES[n].component;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"survey--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"survey--container",dir:"auto",children:jsxRuntimeExports.jsxs("div",{className:"survey--questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{children:c("survey.numQuestion",{init:n+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:c("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item",htmlFor:c(`survey.question${n+1}`,{ordinal:n+1}),children:c(`survey.question${n+1}`,{ordinal:n+1})}),jsxRuntimeExports.jsx(y,{setSurveyData:t,id:PAGES[n].id,survey:r,translate:c,changePage:E=>h(!1),literalLabel:c(`survey.question${n+1}`,{ordinal:n+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{id:"survey-button-back",type:"button",disabled:n===0,onClick:()=>h(!0),className:`gat--btn__navigation ${n===0?"disabled":""}`,"aria-label":LangIsRtl()?c("survey.next"):c("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),u&&n===PAGES.length-1?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>{f("click-ui"),o({type:"saveSurvey",payload:r})},className:`gat--btn gat--btn__primary ${r[PAGES[n].id]?"":"disabled"} not-transition`,children:c("survey.finish")}):null,!u&&n!==PAGES.length?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>h(!1),className:`gat--btn__navigation ${r[PAGES[n].id]?"":"disabled"}`,"aria-label":LangIsRtl()?c("survey.previous"):c("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:o,translate:e}){return React$2.useEffect(()=>{let r;return o&&(r=setTimeout(()=>{o()},2e3)),()=>{r&&clearTimeout(r)}},[o]),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__endscreen","aria-label":"auto evaluation endscreen",children:jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__finishband","aria-label":"auto evaluation finishband",children:[jsxRuntimeExports.jsx("span",{className:"icon-check-laptop auto-evaluation__iconendscreen","aria-label":"icon-check",role:"img"}),jsxRuntimeExports.jsx("span",{className:"auto-evaluation__thanks","aria-label":"auto evaluation thanks",role:"contentinfo",children:e("auto-evaluation.thanks")})]})})}function StartScreen({onNext:o,description:e,translate:r}){return jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__startscreen",role:"alertdialog","aria-modal":"true","aria-label":"ae start screen",children:[jsxRuntimeExports.jsx("span",{className:"icon-happy-laptop auto-evaluation__starticon","aria-label":"icon laptop",role:"img"}),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__starttext","aria-label":"desciption",children:jsxRuntimeExports.jsx("span",{children:e})}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:o,children:jsxRuntimeExports.jsx("span",{children:r("auto-evaluation.start")})})]})}function AutoEvaluation({description:o,questions:e,type:r,emitEvent:t,soundActions:n}){var A,T,w;const[a,u]=React$2.useState(null),[l,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(0),[p,_]=React$2.useState({current:{questions:[],type:r}}),[g]=n,x=P=>t({type:"translate",payload:P}),C=P=>{P.keyCode===13&&P.target.blur()},R=()=>{g("click-ui"),t({type:"saveSurveyPrePos",payload:p.current})};React$2.useEffect(()=>{!e.length&&l==="questions"&&f("end")},[e,l]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=p.current.questions.find(F=>F.id===e[y].id))==null?void 0:D.answer;if(g("click-ui"),O)E(y-1),h(!1);else{const F=p.current.questions.findIndex(V=>V.id===e[y].id),G=[...p.current.questions];F>-1?G.splice(F,1,{id:e[y].id,answer:k}):G.push({id:e[y].id,answer:k}),_({...p,current:{...p.current,questions:G}}),y===e.length-1?h(!0):(E(y+1),h(!1))}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay","aria-label":"test container overlay"}),jsxRuntimeExports.jsxs("div",{className:"test--container",dir:"auto","aria-label":"test container",children:[l==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),g("click-ui")},translate:x}),l==="questions"&&jsxRuntimeExports.jsxs("div",{className:"survey--questions","aria-label":"survey questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container","aria-label":"survey questions container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs("span",{children:[x("auto-evaluation.question")," ",y+1," ",x("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:x("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(A=e[y])==null?void 0:A.text}),jsxRuntimeExports.jsx("div",{className:"survey--page__item","aria-label":"survey page item",children:jsxRuntimeExports.jsx("div",{className:"survey--points","aria-label":"survey points",children:Array(11).fill(0).map((P,O)=>{var k;return jsxRuntimeExports.jsx("button",{type:"button",onTouchStart:()=>{u(O)},onTouchEnd:()=>{u(null)},onKeyUp:D=>{C(D)},onClick:()=>{S(O,!1)},className:`survey--points__item ${((k=p.current.questions[y])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[y]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:y===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${y===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),c?jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f("end"),g("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
|
|
252
|
+
`,EMPTY_PROPS={};function applyNodeProps(o,e,r=EMPTY_PROPS){if(!zIndexWarningShowed&&"zIndex"in e&&(console.warn(Z_INDEX_WARNING),zIndexWarningShowed=!0),!dragWarningShowed&&e.draggable){var t=e.x!==void 0||e.y!==void 0,n=e.onDragEnd||e.onDragMove;t&&!n&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var a in r)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",l=r[a]!==e[a];if(u&&l){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),o.off(f,r[a])}var c=!e.hasOwnProperty(a);c&&o.setAttr(a,void 0)}var h=e._useStrictMode,y={},E=!1;const p={};for(var a in e)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",_=r[a]!==e[a];if(u&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(p[f]=e[a])}!u&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,y[a]=e[a])}E&&(o.setAttrs(y),updatePicture(o));for(var f in p)o.on(f+EVENTS_NAMESPACE,p[f])}function updatePicture(o){if(!Global.Konva.autoDrawEnabled){var e=o.getLayer()||o.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(o,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}o.add(e),updatePicture(o)}function createInstance(o,e,r){let t=Konva[o];t||(console.error(`Konva has no node with the type ${o}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${o}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),t=Konva.Group);const n={},a={};for(var u in e){var l=u.slice(0,2)==="on";l?a[u]=e[u]:n[u]=e[u]}const f=new t(n);return applyNodeProps(f,a),f}function createTextInstance(o,e,r){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${o}"`)}function finalizeInitialChildren(o,e,r){return!1}function getPublicInstance(o){return o}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(o,e,r,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(o){}function shouldDeprioritizeSubtree(o,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(o,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function appendChildToContainer(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function insertBefore(o,e,r){e._remove(),o.add(e),e.setZIndex(r.getZIndex()),updatePicture(o)}function insertInContainerBefore(o,e,r){insertBefore(o,e,r)}function removeChild(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function removeChildFromContainer(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function commitTextUpdate(o,e,r){console.error(`Text components are not yet supported in ReactKonva. You text is: "${r}"`)}function commitMount(o,e,r){}function commitUpdate(o,e,r,t,n){applyNodeProps(o,n,t)}function hideInstance(o){o.hide(),updatePicture(o)}function hideTextInstance(o){}function unhideInstance(o,e){(e.visible==null||e.visible)&&o.show()}function unhideTextInstance(o,e){}function clearContainer(o){}function detachDeletedInstance(){}const getCurrentEventPriority=()=>constantsExports.DefaultEventPriority,HostConfig=Object.freeze(Object.defineProperty({__proto__:null,appendChild,appendChildToContainer,appendInitialChild,cancelTimeout,clearContainer,commitMount,commitTextUpdate,commitUpdate,createInstance,createTextInstance,detachDeletedInstance,finalizeInitialChildren,getChildHostContext,getCurrentEventPriority,getPublicInstance,getRootHostContext,hideInstance,hideTextInstance,idlePriority:schedulerExports.unstable_IdlePriority,insertBefore,insertInContainerBefore,isPrimaryRenderer,noTimeout,now:schedulerExports.unstable_now,prepareForCommit,preparePortalMount,prepareUpdate,removeChild,removeChildFromContainer,resetAfterCommit,resetTextContent,run:schedulerExports.unstable_runWithPriority,scheduleTimeout,shouldDeprioritizeSubtree,shouldSetTextContent,supportsMutation,unhideInstance,unhideTextInstance,warnsIfNotActing},Symbol.toStringTag,{value:"Module"}));var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,r)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,__spreadValues=(o,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(o,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(o,r,e[r]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e));function traverseFiber(o,e,r){if(!o)return;if(r(o)===!0)return o;let t=e?o.return:o.child;for(;t;){const n=traverseFiber(t,e,r);if(n)return n;t=e?null:t.sibling}}function wrapContext(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const FiberContext=wrapContext(React__namespace.createContext(null));class FiberProvider extends React__namespace.Component{render(){return React__namespace.createElement(FiberContext.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner,ReactCurrentDispatcher}=React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function useFiber(){const o=React__namespace.useContext(FiberContext);if(o===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=React__namespace.useId();return React__namespace.useMemo(()=>{for(const t of[ReactCurrentOwner==null?void 0:ReactCurrentOwner.current,o,o==null?void 0:o.alternate]){if(!t)continue;const n=traverseFiber(t,!1,a=>{let u=a.memoizedState;for(;u;){if(u.memoizedState===e)return!0;u=u.next}});if(n)return n}},[o,e])}function useContextMap(){var o,e;const r=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let n=r;for(;n;){const a=(o=n.type)==null?void 0:o._context;a&&a!==FiberContext&&!t.has(a)&&t.set(a,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(a))),n=n.return}return t}function useContextBridge(){const o=useContextMap();return React__namespace.useMemo(()=>Array.from(o.keys()).reduce((e,r)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(r.Provider,__spreadProps(__spreadValues({},t),{value:o.get(r)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[o])}function usePrevious(o){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=o}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=o=>{const e=React$2.useRef(),r=React$2.useRef(),t=React$2.useRef(),n=usePrevious(o),a=useContextBridge(),u=l=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(l):f.current=l)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),u(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(u(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{u(r.current),applyNodeProps(r.current,o,n),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current,null)}),React$2.createElement("div",{ref:e,id:o.id,accessKey:o.accessKey,className:o.className,role:o.role,style:o.style,tabIndex:o.tabIndex,title:o.title})},Layer="Layer",Group="Group",Rect="Rect",Line="Line",Image$2="Image",Text="Text",KonvaRenderer=ReactFiberReconciler(HostConfig);KonvaRenderer.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:React$2.version,rendererPackageName:"react-konva"});const Stage=React$2.forwardRef((o,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...o,forwardedRef:e})));var client={},m=require$$0;if(process.env.NODE_ENV==="production")client.createRoot=m.createRoot,client.hydrateRoot=m.hydrateRoot;else{var i=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;client.createRoot=function(o,e){i.usingClientEntryPoint=!0;try{return m.createRoot(o,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(o,e,r){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(o,e,r)}finally{i.usingClientEntryPoint=!1}}}var __rest=globalThis&&globalThis.__rest||function(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(o);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(r[t[n]]=o[t[n]]);return r};const needForceStyle=o=>{const e=window.getComputedStyle(o).position;return!(e==="absolute"||e==="relative")};function useEvent(o=()=>{}){const e=React$2.useRef(o);return e.current=o,React$2.useCallback((...r)=>e.current.apply(null,r),[])}const Html=({children:o,groupProps:e,divProps:r,transform:t,transformFunc:n})=>{const a=React$2.useRef(null);React$2.useRef();const[u]=React$2.useState(()=>document.createElement("div")),l=React$2.useMemo(()=>client.createRoot(u),[u]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),u.style.position="absolute",u.style.zIndex="10",u.style.top="0px",u.style.left="0px",u.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,u.style.transformOrigin="top left"}else u.style.position="",u.style.zIndex="",u.style.top="",u.style.left="",u.style.transform="",u.style.transformOrigin="";const h=r||{},{style:y}=h,E=__rest(h,["style"]);Object.assign(u.style,y),Object.assign(u,E)});return React$2.useLayoutEffect(()=>{var h;const y=a.current;if(!y)return;const E=(h=y.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(u),f&&needForceStyle(E)&&(E.style.position="relative"),y.on("absoluteTransformChange",c),c(),()=>{var p;y.off("absoluteTransformChange",c),(p=u.parentNode)===null||p===void 0||p.removeChild(u)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{l.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{l.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:a},e))};function Area({area:o,finished:e,isClicked:r,isBad:t,hasHighlights:n,completed:a,onClick:u,onClickOutside:l}){const f=React$2.useRef(),[c,h]=React$2.useState(),y=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",p=DeviceDetection(),_=()=>{var S,A,T;n&&!a&&!r&&((S=f.current)==null||S.setAttr("fill","rgba(130, 134, 142, 0.4)"),(A=f.current)==null||A.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(T=f.current)==null||T.to({duration:.25,opacity:1}))},g=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,T;a&&!e&&(t?(T=f.current)==null||T.to({duration:.25,opacity:0}):((S=f.current)==null||S.to({duration:.25,opacity:1}),(A=f.current)==null||A.globalCompositeOperation("destination-out")))},[a,e,t]);const x=()=>{var S,A;a||(t?l(o):u(o),(S=f.current)==null||S.setAttr("fill",y),(A=f.current)==null||A.setAttr("stroke",E))},C=o.scaleX?o.scaleX:1,R=o.scaleY?o.scaleY:1;return React$2.useLayoutEffect(()=>{const S=f.current.getStage();S.on("stage-loaded",()=>{const A=f.current.getClientRect({relativeTo:f.current.getParent()});h({x:A.x+A.width/2,y:A.y+A.height/2}),S.batchDraw()})},[o]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[c?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...c},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:o.id})}):null,jsxRuntimeExports.jsx(Line,{name:o.id,ref:f,onFocus:()=>_(),onMouseOver:()=>_(),onMouseLeave:g,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:C,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":y,stroke:e||r?E:"",strokeWidth:p?10:4,opacity:e||r?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[o,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function r(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),o};function KonvaMapper({areas:o,badAreas:e,imageUrl:r,completed:t,onClick:n,onClickOutside:a,hasHighlights:u,clickedZones:l}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),[g,x]=React$2.useState(new window.Image),[C,R]=useWindowSize(),S=e.find(w=>w.id==="AllArea")||!1,A=e.filter(w=>w.id!=="AllArea");React$2.useEffect(()=>{_.current&&c.current&&t&&(_.current.to({duration:.25,opacity:.5}),c.current.setAttr("visible",!0))},[t]);const T=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{g.src=r,g.addEventListener("load",()=>{if(f.current){const w={x:C/2,y:R/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(C/g.width,R/g.height),y:Math.min(C/g.width,R/g.height)}};y.current&&y.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),p.current&&p.current.setAttrs(w),f.current.batchDraw(),x(g),f.current.fire("stage-loaded")}})},[g,R,r,C]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:C,height:R,onClick:T,onTouchEnd:T,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:p,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:C,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:y,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:l.some(O=>O.index===w.index)},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:h,visible:!1,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0,finished:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:c,visible:!1,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,finished:!0},w.name+"_"+P))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:o,translate:e,onInit:r}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:e(o?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:o}){const e=Math.floor(o/60),r=o%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${o<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",r<10?`0${Math.floor(r)}`:Math.floor(r)]})})}const defaultImg="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function ImageReview(){return jsxRuntimeExports.jsx("div",{className:"puzzle--image__preview",children:jsxRuntimeExports.jsx("img",{alt:"img",src:"https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg"})})}function ImageClickWrapperComponent(o){var ye,Oe;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:u,image:l,areas:f,badAreas:c,hasClickOrder:h,timer:y,hasClickOnce:E,hasHighlights:p,hasImageReview:_,defaultCompleted:g,className:x,emitFinish:C,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:T,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[G,V]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,z]=React$2.useState(!1),[U,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[B,X]=React$2.useState(!0),[Q,J]=React$2.useState(!1),ne=React$2.useRef(null),se=React$2.useRef(null),ee=React$2.useRef(null),ie=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),de=React$2.useRef(null),ce=React$2.useRef(null),Se=React$2.useRef(null),[ke,Ne]=React$2.useState(y),We=Ge=>S?S(Ge):r({type:"translate",payload:Ge}),[Ke]=e,{solution:Qe}=u,pt=l.img.url||defaultImg,vt=f.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),ct=c.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),mt=React$2.useCallback(()=>{if(!B){const Ge=setInterval(()=>{Ne(nt=>nt>1?nt-1:0)},1e3);Se.current=Ge}},[B]),Vt=React$2.useCallback((Ge,nt)=>{C?C(Ge,nt):r({type:"addPoints",payload:Ge})},[r,C]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(g)},[g]);const kt=React$2.useCallback(()=>{clearInterval(ee.current)},[]),Ie=React$2.useCallback(()=>{clearInterval(Se.current)},[]),et=React$2.useCallback(Ge=>{oe.current=Date.now(),ie.current?(de.current=ie.current-oe.current,kt()):(de.current=oe.current-(oe.current-Ge*1e3),kt())},[kt]),at=React$2.useCallback(()=>{I(()=>{var Ge,nt;return{show:!0,success:!1,text:(Ge=u==null?void 0:u.timerFeedback)!=null&&Ge.desc?u.timerFeedback.desc:"",rewards:(nt=u==null?void 0:u.timerFeedback)==null?void 0:nt.rewards}}),J(!0),Ie(),kt()},[Ie,kt,(ye=u.timerFeedback)==null?void 0:ye.desc,(Oe=u.timerFeedback)==null?void 0:Oe.rewards]),Kt=React$2.useCallback(()=>{clearInterval(ee.current),ee.current=setInterval(()=>{se.current=Date.now(),se.current>ie.current&&at()},250)},[at]);React$2.useEffect(()=>{var Ge;if((f.length===G.length||E&&G.length>0)&&!W){Z(!0);const nt=G[G.length-1],je=A==null?void 0:A.correctFeedbacks.find(Ee=>Ee.id===nt.id);(!((Ge=A==null?void 0:A.correctFeedbacks)!=null&&Ge.length)||A!=null&&A.correctFeedbacks.some(Ee=>!Ee.desc)||E)&&(I(Ee=>({...Ee,show:!0,success:!0,text:je?je.desc:u.solution.right.desc,rewards:je?je.rewards:u.solution.right.rewards})),y&&(Ie(),et()))}},[G,f.length,A,E,W,u.solution.right,et,y,Ie]),React$2.useEffect(()=>{a(Ge=>{y&&(Ie(),X(!1),U.show?I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]})):kt()),Z(!0),z(!0),setTimeout(()=>{R?R(Ge):Ge()},4e3)})},[a,R,Ke,y,U.show,kt,Ie]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const Xe=(Ge,nt=!1)=>{var je,Ee;if(!W){const{rewards:Be,desc:qe}=Qe.wrong;let He=qe,ht=Be;const $t=(je=A==null?void 0:A.wrongFeedbacks)==null?void 0:je.find(Lt=>Lt.id===Ge.id);$t&&(He=$t.desc,ht=$t.rewards),h&&(V([]),nt&&(Ee=u==null?void 0:u.orderFeedback)!=null&&Ee.desc&&(He=u.orderFeedback.desc,ht=u.orderFeedback.rewards)),y&&(Ie(),et()),I(Lt=>({...Lt,show:!0,success:!1,text:He,rewards:ht})),Ke("fail")}},it=React$2.useCallback(()=>{fe.current=Date.now();const Ge=fe.current+de.current;se.current=null,ie.current=Ge,(y||Q)&&(U.success?f.length===G.length||E&&G.length>0?Ie():(Ne(de.current*.001),mt(),Kt()):(V([]),X(!0),w())),Vt(U.rewards,U.success),Ke("click-ui"),I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]}))},[y,Q,Vt,U.rewards,U.success,Ke,f.length,G.length,E,w,Ie,mt,Kt]),pe=Ge=>{var nt,je;if(!G.some(Ee=>Ee.index===Ge.index)&&!U.show&&!W){Ke("click-ui");let Ee=Qe.right.desc,{rewards:Be}=Qe.right;const qe=[...G,Ge];if(h&&Ge.index===G.length||!h){if(y&&et(ke),t(),(nt=A==null?void 0:A.correctFeedbacks)!=null&&nt.length){const He=(je=A.correctFeedbacks)==null?void 0:je.find(ht=>ht.id===Ge.id);He&&(Ee=He.desc,Be=He.rewards),!Ee&&f.length>qe.length&&!E?Vt(Be,!0):Ee&&!E&&(I(ht=>({...ht,show:!0,success:!0,text:Ee,rewards:Be})),y&&Ie())}V(qe)}else Xe(Ge,!0)}},ge=React$2.useCallback(()=>{Ie(),Ne(y),mt(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),ie.current=ne.current+y*1e3,Kt()},[Ie,y,mt,P,Kt,k]);return React$2.useEffect(()=>{y&&T>0&&!ce.current&&(P&&Object.keys(O).length&&O[T-1]?(X(!0),ce.current=!0):X(!1))},[g,P,O,T,y]),React$2.useEffect(()=>{y&&ke===0&&at()},[ke,at,y]),React$2.useEffect(()=>{y&&(D?(Ie(),et()):mt())},[Ie,Kt,D,et,mt,y]),jsxRuntimeExports.jsxs("div",{className:x,children:[U.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ke,text:U.text,success:U.success,translate:We,hasTimeout:!U.text,delay:y?1e3:2e3,functionOnClose:it,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&G.length?[G[0]]:vt,badAreas:ct,clickedZones:G,onClick:pe,onClickOutside:Xe,hasHighlights:p,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,y&&B?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[T-1],translate:We,onInit:ge}):null,y?jsxRuntimeExports.jsx(CountDown,{time:ke}):null]})}ImageClickWrapperComponent.defaultProps={info:{instructions:"",resolve:{},solution:{},hint:{},title:""},badAreas:[],className:"puzzle--image__click",hasClickOrder:!1,hasClickOnce:!1,hasHighlights:!1,hasImageReview:!1,defaultCompleted:!1,hideContinue:!1,emitAreaClick:()=>{},handleClick:()=>{}};function ImageClickPuzzleComponent(o){const e=(r,t)=>{t?(o.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:r}),o.emitEvent({type:"passPuzzle"})):(o.emitEvent({type:"addPoints",payload:r,finish:!1}),o.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...o,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(o,e)=>Math.max(Math.abs(o[0]-e[0]),Math.abs(o[1]-e[1])),generatePasswordPositions=(o,e,r,t)=>{const n=[],a=o;for(const u of e.toLowerCase()){const l=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[l][f].value=u,n.push({char:u,position:[l,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let u=0;u<r;u+=1)switch(t.reduce((f,c)=>{const h=[a,u],y=getDistance(c.position,h);return y<f?y:f},9999)){case 0:n[a][u].hiddenColor=GREEN;break;case 1:n[a][u].hiddenColor=ORANGE;break;case 2:n[a][u].hiddenColor=RED;break}return n},resetColors=(o,e,r)=>{const t=r;for(let n=0;n<o;n+=1)for(let a=0;a<e;a+=1)t[n][a].color="",t[n][a].hiddenColor=RED;return t},repaintGridPassword=(o,e,r,t)=>{const n=resetColors(r,t,o),[a,u]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,u)},prepareAcceptedChars=(o,e)=>e.split("").filter(r=>!o.includes(r)).join(""),generateBasicGrid=(o,e,r)=>{const t=[];for(let n=0;n<o;n+=1){const a=[];for(let u=0;u<e;u+=1){const l={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(l)}t.push(a)}return t},makeSomeNoise=({numberOfColumns:o,numberOfRows:e,password:r})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",n=prepareAcceptedChars(r,t),a=generateBasicGrid(e,o,n),[u,l]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(u,e,o,l)};function DrawItem({item:o,rowIndex:e,columnIndex:r,setCursorPosition:t,cursorPosition:n}){const a=Math.abs(e-n[0])<3&&Math.abs(r-n[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${a?o.hiddenColor:o.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,r])},onFocus:()=>{t([e,r])},children:o.value})}DrawItem.defaultProps={setCursorPosition:()=>{}};DrawItem.propTypes={item:PropTypes.shape({color:PropTypes.string,hiddenColor:PropTypes.string,value:PropTypes.string}).isRequired,rowIndex:PropTypes.number.isRequired,columnIndex:PropTypes.number.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired,setCursorPosition:PropTypes.func};function DrawRow({row:o,rowIndex:e,setCursorPosition:r,cursorPosition:t}){return o.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:o.map((n,a)=>jsxRuntimeExports.jsx(DrawItem,{item:n,rowIndex:e,columnIndex:a,setCursorPosition:r,cursorPosition:t},a))}):null}DrawRow.defaultProps={row:[]};DrawRow.propTypes={row:PropTypes.arrayOf(PropTypes.shape({})),rowIndex:PropTypes.number.isRequired,setCursorPosition:PropTypes.func.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired};function DrawGrid({grid:o,cursorPosition:e,setCursorPosition:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:o.map((t,n)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:n,cursorPosition:e,setCursorPosition:r},n))})}DrawGrid.defaultProps={setCursorPosition:()=>{}};const VELOCITY_MAP={slow:2,fast:5,fastest:10},DIFFICULTY_MAP={easy:{visibleRows:"auto",visibleColumns:40,totalRows:25},medium:{visibleRows:"auto",visibleColumns:40,totalRows:40},hard:{visibleRows:"auto",visibleColumns:40,totalRows:80}};function CrackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,velocity:t,password:n,disableExit:a,difficulty:u,setResolveAction:l}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),y=React$2.useRef(),{solution:E}=r,[p,_]=React$2.useState(n.toLowerCase()),[g,x]=React$2.useState(),[C,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([0,0]),P=c("puzzle.cracker.crackedPassword"),O=r.solution.right.desc&&r.solution.right.desc!==""?r.solution.right.desc:"",k=c("puzzle.cracker.congratulations"),[D,F]=React$2.useState([[]]),{visibleRows:G,visibleColumns:V}=DIFFICULTY_MAP[u];let W=G==="auto"?Math.ceil(window.innerHeight*.025):G;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{l(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[l,f]);const Z=()=>{f("click-ui");const{rewards:X}=E.right;o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},q=()=>n.toLowerCase().split("").map((Q,J)=>({char:Q,index:J,used:!1})),z=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),U=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(y.current!==void 0){const Q=X-y.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(U),I=0)}y.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:V,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const B=()=>{if(D.length<=1)return;const[X,Q]=T,J=D[X][Q];if(J.hiddenColor===GREEN){const ne=g.filter(se=>se.char===J.value.toLowerCase()&&se.used===!1)[0];if(ne){const{index:se}=ne;f("score");const ee=g;ee[se].used=!0,x(ee);const ie=[...C];ie[se]=J.value;const oe=z(ee);_(oe);const fe=repaintGridPassword(D,oe,W,V);F(fe),R(ie)}}p<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||B()},[T]),jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__container",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--cracker__header",children:[jsxRuntimeExports.jsx("span",{className:"title",children:"Dcoder.exe"}),jsxRuntimeExports.jsx("div",{className:"puzzle--pieces",children:C.map((X,Q)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:X&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${Q}`,children:X})},`${X+Q}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:S?[[]]:D,cursorPosition:T,setCursorPosition:w}),S&&P&&k&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,cursor:{hideWhenDone:!0},className:"puzzle--cracker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),jsxRuntimeExports.jsxs("span",{children:[`${P} ${n.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),O!==""&&jsxRuntimeExports.jsx("span",{children:O})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:Z,children:c("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(o,e)=>{let r=!1;return e==="or"&&(r=o===""||o===" "||o===","||o==="."||o==="/"),e==="and"&&(r=o&&o!==" "&&o!==","&&o!=="."&&o!==""&&o!=="/"),r},sortChar=(o,e)=>o.char>e.char?1:o.char<e.char?-1:0,analyzeChars=o=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let r=0;r<o.length;r+=1){const t=o[r].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(o[r])&&(e.anyArabic=!0)}return e},makeChar=o=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let n="";return o.anyWestern&&(n+=r),o.anyNumber&&(n+=t),o.anyArabic&&(n+=e),n.charAt(Math.floor(Math.random()*n.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:o,flickerPosition:e,show:r=!1,showCorrectSolution:t})=>{const n=[];let a=0;return o.forEach(u=>{n[a]||(n[a]=[]),n[a]=[...n[a],u],u.char===" "&&(a+=1),t||(u.positionInitial=u.index)}),n.map((u,l)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${l}`,children:r?u.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):u.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${u[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${u+l}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:o,emitEvent:e,disableExit:r,question:t,image:n,info:a,answer:u,hintUsed:l,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[y]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[p,_]=React$2.useState(0),[g,x]=React$2.useState(!1),[C,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,G]=React$2.useState([]),[V,W]=React$2.useState(!1),Z=u.toUpperCase().split(""),q=Z.filter(de=>restrictCharacters(de,"and")),z=de=>e({type:"translate",payload:de}),U=React$2.useCallback(()=>{const de=q.map(ke=>({char:ke}));let ce=[];const Se=analyzeChars(q);for(;ce.length<MAX_EXTRA_LETTERS;){const ke=makeChar(Se);ce=[...ce,{char:ke}]}return[...de,...ce]},[q]),I=u.toUpperCase().split("").map((de,ce)=>restrictCharacters(de,"or")?{index:ce,letter:de,char:de,fixed:!0}:{index:ce,letter:de,char:""}),$=React$2.useCallback(()=>{let de=U();for(;de.length>MAX_POOL_LETTERS;){const ce=Math.trunc(Math.random()*(de.length-1))+1,Se=de[ce],ke=I.find((Ne,We)=>Se.char===Ne.letter&&!I[We].fixed);ke&&(de.splice(ce,1),I[ke.index]={...ke,char:ke.letter,fixed:!0})}l&&(de=[],I.forEach(({letter:ce})=>{ce!==" "&&de.push({char:ce})})),w(I),R(de)},[I,l,U]),B=(de,ce)=>C.map((ke,Ne)=>Ne===ce?{...ke,deleted:!0}:{...ke}),X=(de,ce,Se)=>{const ke=ce.map((We,Ke)=>Se.find(pt=>pt.poolIndex===Ke)?{char:We.char}:We);R(ke),w(de);const Ne=de.find(We=>We.char==="");_(Ne.index)},Q=(de,ce)=>{y("click-ui");let Se=!1;const ke=T.map(Ke=>!Ke.char&&!Se?(Se=!0,{...Ke,char:de,poolIndex:ce}):Ke),Ne=B(de,ce),We=ke.filter(Ke=>Ke.char).length;R(Ne),w(ke),J(),We===T.length&&ie(ke,Ne)},J=()=>{var de;if(g){const ce=T.find(Se=>Se.index!==p&&Se.letter!==" "&&Se.char===""&&Se.poolIndex===!1);ce&&_(ce.index)}else{const ce=T.find(Se=>Se.char==="");_(ce.index+1),((de=T[ce.index+1])==null?void 0:de.letter)===" "&&_(ce.index+2)}},ne=()=>{y("click-ui");const de=T.map((ce,Se)=>T[T.length-1-Se]).find(ce=>ce.char&&!ce.fixed);if(de){const ce=T.map(Ne=>Ne.index===de.index?{...de,char:""}:Ne);let Se=!1;const ke=C.map((Ne,We)=>We===de.poolIndex&&(Ne.deleted||!Se)?(Se=!0,{char:Ne.char}):Ne);R(ke),w(ce),_(de.index)}},se=()=>{r(!0),O("");const de=[...F,...a.solution.right.rewards];y("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:de}),e({type:"passPuzzle"})},ee=()=>{y("fail"),e({type:"hidePuzzleButtons",payload:!1}),G([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},ie=(de,ce)=>{let Se=[];D(!0);const ke=de.map((We,Ke)=>Z[Ke]===We.char?{...We,fixed:!0}:(Se=[...Se,We],{...We,poolIndex:!1,char:""})),Ne=ke.filter(We=>We.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Ne===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{se()},2e3)):(O("failed"),X(ke,ce,Se),a.solution.wrong.desc===""&&setTimeout(()=>{ee()},2e3))},oe=()=>{if(P==="success")se();else{ee();const de=T.find(ce=>ce.char==="");_(de.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(de=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),de()},2e3)}),c(de=>{const ce=[];I.forEach(({letter:Se})=>{Se!==" "&&ce.push({char:Se})}),R(ce),de()})},[$,S,u,f,e,F,a.resolve.rewards,I,c]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${E}")`},children:[P?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:z,functionOnClose:oe,keyboardControl:h}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--hanged__content",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__controls",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__header",children:t}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${P}`,"data-testid":`${P}`,children:V?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,answer:u.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,flickerPosition:p,answer:T})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[C.sort((de,ce)=>sortChar(de,ce)).map((de,ce)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${de.char}`,type:"button",onClick:()=>{!de.deleted&&!P&&!k&&(Q(de.char,ce),y("click-ui"))},className:`puzzle--hanged__keyboard--item ${de.deleted||k?"disabled":""}`,children:de.char},`${de+ce}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":z("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${k?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})]})})]})}HangedPuzzleComponent.defaultProps={question:"",answer:"",image:{},hintBought:!1,info:{description:"",instructions:"",resolve:{},solution:{},hintBought:{}}};function CurrentImageClickPuzzle({list:o,description:e,nodeId:r,setInfo:t,emitEvent:n,disableExit:a,setResolveAction:u,soundActions:l,setSelected:f,selected:c,pause:h,loadPuzzleStatus:y,index:E,setIndex:p,slidesCompleted:_,setSlidesCompleted:g,keyboardControl:x,totalCorrects:C}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),T=`chained-image-click-puzzle_${E}_${r}`,[w]=l,P=Z=>{R.current=[...R.current,...Z]},O=React$2.useCallback(Z=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...Z]}),n({type:"passPuzzle"})},[w,n]),k=o[E],{info:D,specificFeedbacks:F}=k;D.description=e,React$2.useEffect(()=>{S.current=0,A.current=0},[E]);const G=React$2.useCallback((Z,q=!1)=>{var U;let z={..._};if(q){if((U=F==null?void 0:F.correctFeedbacks)!=null&&U.length&&!k.hasClickOnce)S.current+=1;else{let I=c;A.current&&(I-=A.current),S.current=k.areas.length,f(I+S.current)}S.current===k.areas.length&&(E+1>=o.length?O(Z):p(E+1),z={...z,[E]:!0},g(z)),P(Z)}else n({type:"addPoints",payload:Z,finish:!1}),n({type:"failPuzzle"}),k.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&k.hasClickOrder&&!c&&f(0)},[_,F,k.hasClickOnce,k.areas.length,k.hasClickOrder,c,f,E,o.length,g,O,p,n]),V=()=>{E>=o.length-1&&f(C),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:T,rewards:D.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...D,hintId:T})},[D,T,t]),React$2.useEffect(()=>{y&&E!==o.length-1&&G([],!0)},[E,o.length,y,G]);const W=()=>{const Z=k.hasClickOnce?k.areas.length:1;A.current+=Z,f(c+Z)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...k,puzzle:{name:T,component:"chained-image-click-puzzle"},specificFeedbacks:F,emitFinish:G,emitError:P,emitResolve:V,isLast:E+1===o.length,defaultCompleted:_[E]||!!y,hideContinue:E+1!==o.length,handleClick:W,emitEvent:n,disableExit:a,soundActions:l,setResolveAction:u,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:u,showFrames:l,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[y,E]=React$2.useState(0),[p,_]=React$2.useState(0),[g,x]=React$2.useState({}),C=`chained-image-click-puzzle_${p}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:C}),[r,C]),S=n.reduce((T,w)=>T+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:u,setInfo:e,setSelected:E,selected:y,index:p,setIndex:_,slidesCompleted:g,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[l?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[y," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:u,setFramesCompleted:l,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:y,description:E,translateFromParent:p,setInfo:_,emitEvent:g,nodeId:x,setSelected:C,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:T,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:G}){var J;const[V]=c,W=o[e],{info:Z,specificFeedbacks:q}=W;Z.description=E;const z=React$2.useRef(0),U=React$2.useRef(0),I=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...Z,hintId:I})},[_,Z,I]),React$2.useEffect(()=>{O&&(U.current=0,z.current=0,C(0),k(!1))},[O,k,C]),React$2.useEffect(()=>{U.current=0,z.current=0},[e]);const $=React$2.useCallback((ne,se=!1)=>{var ie;let ee={...t};if(se){if((ie=q==null?void 0:q.correctFeedbacks)!=null&&ie.length&&!W.hasClickOnce)U.current+=1;else{let oe=R;z.current&&(oe-=z.current),U.current=W.areas.length,w[0]&&Object.entries(t).length===0?C(U.current):C(oe+U.current)}U.current===W.areas.length&&(e+1>=o.length&&n(ne),ee={...ee,[e]:!0},l(ee),u(e+1>o.length-1?0:e+1)),a(ne)}else g({type:"addPoints",payload:ne,finish:!1}),g({type:"failPuzzle"}),W.hasClickOrder&&(C(R-U.current),U.current=0)},[t,(J=q==null?void 0:q.correctFeedbacks)==null?void 0:J.length,W.hasClickOnce,W.areas.length,W.hasClickOrder,a,R,w,C,e,o.length,l,u,n,g]),B=React$2.useCallback(()=>{e>=o.length-1&&C(G),V("score"),g({type:"hidePuzzleButtons",payload:!1}),T(ne=>({...ne,[e]:!0})),g({type:"puzzleAction",action:"resolve",payload:{element:I,rewards:Z.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,V,g,T,I,Z.resolve.rewards,C,G]),X=React$2.useCallback(()=>{l({}),U.current=0,z.current=0,S()},[S,l]);React$2.useEffect(()=>{f&&e!==o.length-1&&$([],!0)},[t,e,o.length,f,$]);const Q=()=>{const ne=W.hasClickOnce?W.areas.length:1;z.current+=ne,C(R+ne)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...W,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:q,emitFinish:$,emitResolve:B,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:y,translateFromParent:p,emitEvent:g,slideNumber:e,handleClick:Q,emitResetPuzzle:X,firstTryForFrame:A,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,pause:D,keyboardControl:F},e)}function Tooltip({emitEvent:o}){const e=r=>o({type:"translate",payload:r});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:o,total:e,tooltip:r,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[r?jsxRuntimeExports.jsx(Tooltip,{emitEvent:t}):null,jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__info--frames",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[o," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:o,nodeId:e,list:r,description:t,showFrames:n,soundActions:a,disableExit:u,setResolveAction:l,setInfo:f,pause:c,keyboardControl:h}){const[y,E]=React$2.useState({}),p=React$2.useRef([]),[_,g]=React$2.useState(0),[x,C]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[T,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((B,X)=>B+X.areas.length,0),G=B=>{p.current=[...p.current,...B]},V=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:V}),[o,V]),Z=React$2.useCallback(B=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...p.current,...B]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),p.current=[],S(0),g(0),C({}),w(!0),D(!0)},[]),z=B=>o({type:"translate",payload:B}),U=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:G,accRewards:p,setSelected:S,selected:R,setIndex:g,setFramesCompleted:C,loadPuzzleStatus:W,soundActions:a,setResolveAction:l,disableExit:u,translateFromParent:z,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:y,emitOpenPopupCounterInfo:()=>{_===0&&w(!1)},pause:c,keyboardControl:h,totalCorrects:F};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...$}),jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__content",children:[jsxRuntimeExports.jsx("div",{className:"puzzle-frame__controls",children:jsxRuntimeExports.jsx("div",{className:"puzzle-frame__progress",children:jsxRuntimeExports.jsx("div",{style:{width:`${R/F*100}%`},className:"puzzle-frame__progress--handle"})})}),n?jsxRuntimeExports.jsx("button",{disabled:T,"aria-hidden":T,type:"button",className:"puzzle-frame__info",onClick:U,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!T,emitEvent:o})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:o,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${o} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:o,children:jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"})})}EditButton.defaultProps={action:()=>{},className:""};const path="https://min.gamelearn.io/css-resources/gamelearn/resources/",imagesOptions=[{name:"webbuilder.imageOptions.image1",src:"Amor.jpg"},{name:"webbuilder.imageOptions.image2",src:"Bancorp.svg"},{name:"webbuilder.imageOptions.image3",src:"Amanda.jpg"},{name:"webbuilder.imageOptions.image4",src:"keyboard.jpg"},{name:"webbuilder.imageOptions.image5",src:"Melanie.jpg"},{name:"webbuilder.imageOptions.image6",src:"Sharon.jpg"},{name:"webbuilder.imageOptions.image7",src:"Bankex.svg"},{name:"webbuilder.imageOptions.image8",src:"Futbol.jpg"},{name:"webbuilder.imageOptions.image9",src:"GBL.svg"},{name:"webbuilder.imageOptions.image10",src:"Fooder.jpg"},{name:"webbuilder.imageOptions.image11",src:"Corporate.jpg"},{name:"webbuilder.imageOptions.image12",src:"Bank of Zamunda.svg"},{name:"webbuilder.imageOptions.image13",src:"mindfullness.jpg"},{name:"webbuilder.imageOptions.image14",src:"Nature.jpg"},{name:"webbuilder.imageOptions.image15",src:"Shopper.jpg"},{name:"webbuilder.imageOptions.image16",src:"Lab.jpg"}],colorOptions=["#c66a46","#3c9dc0","#6236ff","#21254f"],colorOptions2=["#39b7b9","#25a1d4","#f5a623","#080269"],titleOptions=[{title:"webbuilder.bank.titleOptions.title1.text",desc:"webbuilder.bank.titleOptions.title1.description"},{title:"webbuilder.bank.titleOptions.title2.text",desc:"webbuilder.bank.titleOptions.title2.description"},{title:"webbuilder.bank.titleOptions.title3.text",desc:"webbuilder.bank.titleOptions.title3.description"},{title:"webbuilder.bank.titleOptions.title4.text",desc:"webbuilder.bank.titleOptions.title4.description"},{title:"webbuilder.bank.titleOptions.title5.text",desc:"webbuilder.bank.titleOptions.title5.description"}],bankProps={backgroundImage:imagesOptions[10].src,backgroundLogo:imagesOptions[11].src,backgroundColor:"#21254f",btnColor:"#25a1d4"},BankTemplate={header:{color:bankProps.backgroundColor,logo:bankProps.backgroundLogo},body:{bankTitle:titleOptions[0].title,bankDesc:titleOptions[0].desc,bgImage:bankProps.backgroundImage,btnColor:bankProps.btnColor}};function BankHeader({showingReference:o,usingTemplate:e,openPopup:r,onSave:t,header:n,translate:a}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o?jsxRuntimeExports.jsx("div",{className:"bank--edit__logo",children:jsxRuntimeExports.jsx("img",{src:path+e.header.logo,alt:"",title:""})}):jsxRuntimeExports.jsxs("div",{className:"bank--edit__logo",children:[n.logo?jsxRuntimeExports.jsx("img",{src:path+n.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:u=>t({logo:u})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.mortgage")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupColorComponent",{colors:colorOptions,onSave:u=>t({color:u})})})]})]})}BankHeader.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};BankHeader.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookHeader({showingReference:o,usingTemplate:e,header:r,translate:t}){const n=o?e.header.userImage:r.userImage,a=o?e.header.username:r.username;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__logo",children:jsxRuntimeExports.jsx("span",{className:"icon-fb-logo"})}),jsxRuntimeExports.jsxs("span",{className:"facebook--header__user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__user--circle",style:{backgroundImage:`url(${path+n})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(a||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(o){const{isFacebook:e,header:r,showingReference:t,usingTemplate:n}=o,a=t?n.header.color:r.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${a}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...o}):jsxRuntimeExports.jsx(BankHeader,{...o})})})}WebBuilderHeader.defaultProps={isFacebook:!1,showingReference:!1,usingTemplate:{},header:{}};WebBuilderHeader.propTypes={isFacebook:PropTypes.bool,showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),header:PropTypes.shape({})};const facebookProps={backgroundImage:imagesOptions[12].src,backgroundUser:imagesOptions[5].src},userOptions=["webbuilder.userOptions.user1","webbuilder.userOptions.user2","webbuilder.userOptions.user3"],workOptions=["webbuilder.workOptions.work1","webbuilder.workOptions.work2","webbuilder.workOptions.work3"],studiesOptions=["webbuilder.studiesOptions.study1","webbuilder.studiesOptions.study2","webbuilder.studiesOptions.study3"],mailOptions=["webbuilder.mailOptions.mail1","webbuilder.mailOptions.mail2","webbuilder.mailOptions.mail3"],homeOptions=["webbuilder.homeOptions.home1","webbuilder.homeOptions.home2","webbuilder.homeOptions.home3"],FacebookTemplate={header:{username:userOptions[1],userImage:facebookProps.backgroundUser,bgImage:facebookProps.backgroundImage},body:{work:workOptions[2],home:homeOptions[1],studies:studiesOptions[0],mail:mailOptions[0]}};function WebBuilderFront({showingReference:o,usingTemplate:e,header:r,onSave:t,translate:n,openPopup:a}){const u=o?e.header.userImage:r.userImage,l=o?e.header.username:r.username,f=o?e.header.bgImage:r.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+u})`},children:o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({userImage:c})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:n(l||"webbuilder.facebook.header.userName")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:userOptions,onSave:c=>t({username:c})})}})]}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({bgImage:c})})}})]})}WebBuilderFront.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};WebBuilderFront.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.work:r.work,l=o?e.body.studies:r.studies,f=o?e.body.home:r.home,c=o?e.body.mail:r.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${u||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(u||"webbuilder.facebook.body.work")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:workOptions,onSave:h=>t({work:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${l||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(l||"webbuilder.facebook.body.studies")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:studiesOptions,onSave:h=>t({studies:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(f||"webbuilder.facebook.body.home")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:homeOptions,onSave:h=>t({home:h})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${c||o?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(c||"webbuilder.facebook.body.email")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:mailOptions,onSave:h=>t({mail:h})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),a("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),a("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),a("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),a("webbuilder.facebook.body.facebookEvent")]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--thinking",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--textarea",children:[jsxRuntimeExports.jsx("div",{className:"facebook--textarea__circle"}),jsxRuntimeExports.jsx("div",{className:"facebook--textarea__placeholder",children:a("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.bgImage:r.bgImage,l=o?e.body.btnColor:r.btnColor,f=a(o?e.body.bankTitle:"webbuilder.bank.body.image.title"),c=a(o?e.body.bankDesc:"webbuilder.bank.body.image.description");return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"bank--image__front",style:{backgroundImage:`url(${path+u})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:r.bankTitle&&!o?a(r.bankTitle):f}),jsxRuntimeExports.jsx("span",{children:r.bankDesc&&!o?a(r.bankDesc):c}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:titleOptions,onSave:h=>t({bankTitle:h.title,bankDesc:h.desc})})}}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{n("PopupImageComponent",{images:imagesOptions,onSave:h=>t({bgImage:h})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:a("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.current")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.new")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.confirm")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"bank--form__btn",style:{backgroundColor:`${l}`},children:a("webbuilder.save")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupColorComponent",{colors:colorOptions2,onSave:h=>t({btnColor:h})})}})]})]})})]})}function WebBuilderBody(o){const{isFacebook:e}=o;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...o}):jsxRuntimeExports.jsx(BankBody,{...o})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:o,backActive:e,action:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:r,children:o(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:o,displayButton:e,clickAction:r,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:o,action:r,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:o,success:e,showButton:r,translate:t}){const n=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),a=t(e?"webbuilder.feedback.success":"webbuilder.feedback.fail");return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`puzzle--webBuilder__feedback bottom ${e?"success":"failed"}`,style:e?{zIndex:"11"}:{},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"title",children:n}),jsxRuntimeExports.jsx("div",{className:"description",children:a})]}),r?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:o,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:o,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:o,children:jsxRuntimeExports.jsxs("div",{className:"gat--btn gat--btn__primary",children:[jsxRuntimeExports.jsx("span",{className:"icon-download-cloud"}),e("webbuilder.publish")]})})}PublishButton.defaultProps={onPublish:()=>{}};function PopupColorComponent({colors:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=u===null;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__colors",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--title",children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.colorSelect.title")})}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--items",children:o.map(c=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${u===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>l(c),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${c}`}})},c+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}PopupColorComponent.defaultProps={closingAction:()=>{},onSave:()=>{},colors:{}};PopupColorComponent.propTypes={closingAction:PropTypes.func,onSave:PropTypes.func,colors:PropTypes.arrayOf(PropTypes.string)};function PopupImageComponent({images:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=!u;return jsxRuntimeExports.jsx("div",{className:"folder-popup",children:jsxRuntimeExports.jsxs("div",{className:"folder-popup__content",children:[jsxRuntimeExports.jsxs("div",{className:"folder-popup__header",children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__title",children:[jsxRuntimeExports.jsx("span",{className:"folder-popup__icon-header icon-fb-search"}),jsxRuntimeExports.jsx("span",{children:t("webbuilder.imageSelect.title")})]}),jsxRuntimeExports.jsx("button",{onClick:r,className:"folder-popup__close",type:"button",children:jsxRuntimeExports.jsx("span",{className:"icon-close-fit"})})]}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__body",children:[jsxRuntimeExports.jsx("div",{className:"folder-popup__scroll",children:jsxRuntimeExports.jsx("ul",{className:"folder-popup__list",children:o.map(c=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>l(c),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:c.src,src:path+c.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:c.src,children:c.src})]},c.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:o,translate:e}){return o instanceof Object?e(o.title.toString()):jsxRuntimeExports.jsx("span",{children:e(o||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:o,onSave:e,options:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(""),f=u==="",[c,h]=React$2.useState(!1),y=c?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",E=()=>{h(!c)};return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__select",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__select--label",children:jsxRuntimeExports.jsx("div",{dir:"auto",children:t("webbuilder.textSelect.title")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:y,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:u,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(p=>p instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:[jsxRuntimeExports.jsx("span",{children:t(p.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(p.desc)})]},p.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:t(p)},p))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:o,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,disabled:f,onClick:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}const POPUPS=Object.freeze(Object.defineProperty({__proto__:null,PopupColorComponent,PopupImageComponent,PopupTextComponent},Symbol.toStringTag,{value:"Module"})),defaultHeader={username:null,logo:null,userImage:null,bgImage:null,color:""},defaultBody={bankTitle:null,color:"",btnColor:"",work:null,home:null,mail:null,studies:null,bgImage:null};function PopupComponent({type:o,close:e,translate:r,soundActions:t,...n}){const a=POPUPS[o];return a?jsxRuntimeExports.jsx(a,{type:o,...n.props,closingAction:e,translate:r,soundActions:t}):null}function DisplayingFeedback({feed:o,resolved:e,translate:r,onNext:t}){return o==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:r}):o==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:r}):null}function WebBuilderPuzzleComponent({type:o,info:e,emitEvent:r,setResolveAction:t,soundActions:n,disableExit:a,keyboardControl:u}){const[l,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(!1),[p,_]=React$2.useState(!1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[T,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,G=Q=>r({type:"translate",payload:Q}),V=()=>{w({type:"",props:{}})},W=(Q,J={})=>{w({type:Q,props:J})},Z=()=>{if(e.solution){const{rewards:Q}=e.solution.right,{rewards:J}=e.solution.wrong;F(y?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:y?J:Q}),r({type:"passPuzzle"})}};u(null,C==="success"?Z:null,C==="success"?Z:null);const q=(Q,J)=>{const ne=Object.keys(Q),se={existing:0,equal:0};return ne.forEach(ee=>{J[ee]!==null&&J[ee]!==""&&(se.existing+=1),Q[ee]===J[ee]&&(se.equal+=1)}),se},z=(Q,J)=>{const ne=Object.keys(A.header).length,se=Object.keys(A.body).length,ee=q(A.header,Q),ie=q(A.body,J),oe=ie.existing+ee.existing===ne+se,fe=ie.equal+ee.equal===ne+se;return{exist:oe,equal:fe}},U=()=>{F("click-ui");const{exist:Q,equal:J}=z(P,k);r({type:"hidePuzzleButtons",payload:!0}),Q&&!J?(g&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):Q&&J&&(g&&(a(!1),x(!1)),_(!0),R("success"))},I=Q=>{if(Object.keys(Q).length>0){const J={...P,...Q};O(J),V();const{exist:ne}=z(J,k);x(!!ne)}},$=Q=>{if(Object.keys(Q).length>0){const J={...k,...Q};D(J),V();const{exist:ne}=z(P,J);x(!!ne)}};React$2.useEffect(()=>{t(Q=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),Q()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const B={showingReference:l||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:G},X=()=>{C==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):C==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:T.type,...T,close:V,soundActions:n,translate:G}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:l,displayButton:!c&&!p,translate:G,clickAction:()=>{F("click-ui"),f(!l)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...B,header:P,onSave:I}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...B,header:P,onSave:I}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...B,body:k,onSave:$})]}),!g&&!l?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:C,onNext:X,resolved:c,translate:G}):null,g&&!l?jsxRuntimeExports.jsx(PublishButton,{onPublish:U,translate:G}):null]})}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),u=()=>{const _=(o.img||{}).url;return jsxRuntimeExports.jsx("img",{src:_,alt:""})},l=()=>o.text?jsxRuntimeExports.jsx("div",{className:`card-selector-item__textbox ${o.img?"":"card-selector-item__textbox--noimage"}`,children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__text",children:jsxRuntimeExports.jsx("span",{children:o.text||"_"})})}):null,f=()=>!!(r&&!o.correct||!r),c=()=>jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedback card-selector-item__feedback--error",children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black"})})}),h=()=>o.order?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:o.order})}):null,y=()=>jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[h(),jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black"})})]}),E=()=>!a()&&r&&o.correct&&!n?y():!a()&&r?c():null;return jsxRuntimeExports.jsxs("button",{type:"button",order:o.order,onClick:()=>{!a()&&f()&&e(t)},className:`unset-button card-selector-item ${a()?"card-selector-item--empty":""}`,"aria-label":o.text?o.text:null,children:[u(),l(),E()]})}Card.defaultProps={handleClick:()=>{},documentsDict:{},card:{},flipped:!1,wrongOrder:!1,cardIndex:0};Card.propTypes={wrongOrder:PropTypes.bool,handleClick:PropTypes.func,cardIndex:PropTypes.number,flipped:PropTypes.bool,documentsDict:PropTypes.shape({}),card:PropTypes.shape({correct:PropTypes.bool,order:PropTypes.number,text:PropTypes.string,imgId:PropTypes.string,status:PropTypes.string})};function Board({cards:o,currentOrder:e,setCurrentOrder:r,handleError:t,feedbackIsShown:n,resolvePuzzle:a,soundActions:u,onFinish:l,handleSuccess:f,resolveWithAnyCard:c}){const[h,y]=React$2.useState(Array(o.length).fill(!1)),[E,p]=React$2.useState(Array(o.length).fill(!1)),[_,g]=React$2.useState(0),[x,C]=React$2.useState(!1),[R]=u,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,T=React$2.useCallback(()=>{y(Array(o.length).fill(!1)),p(Array(o.length).fill(!1)),g(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{T()},1e3)};function P(F){const G=Array.from(h);G[F]=F,y(G)}const O=React$2.useCallback(()=>{const F=[];o.forEach((G,V)=>{G.correct===!0&&F.push(V)}),y(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(l(),C(!0),g(0))},[_,l,S,c]);const k=F=>{P(F),f(o[F].id||null),g(_+1)},D=F=>{var G,V;if(!x&&!n)if(R("click-ui"),o[F].correct&&!A)k(F);else if(A)if(o[F].order===e)r(e+1),k(F);else{if(o[F].order!==e){const W=Array.from(E);W[F]=F,p(W),t(((G=o[F])==null?void 0:G.id)||null,o[F].correct),w()}P(F)}else t(((V=o[F])==null?void 0:V.id)||null),w(),P(F)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,G)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(G),flipped:h.includes(G),wrongOrder:E.includes(G),cardIndex:G},`cardPuzzle ${o.indexOf(F)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:o,info:e,cards:r,resolveWithAnyCard:t,specificFeedbacks:n,disableExit:a,setResolveAction:u,soundActions:l,backgroundImage:f,nodeId:c,keyboardControl:h}){var $,B;const[y,E]=React$2.useState(!1),[p,_]=React$2.useState(1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(!1),[k,D]=React$2.useState(""),[F]=l,G=X=>o({type:"translate",payload:X}),V=`cards-selector-puzzle_${c}`,W=React$2.useCallback(X=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},[o]),Z=React$2.useCallback(()=>{var ne,se;o({type:"hidePuzzleButtons",payload:!0}),x(!0);const{rewards:X}=((ne=e==null?void 0:e.solution)==null?void 0:ne.right)||{},Q=((se=n==null?void 0:n.correctFeedbacks)==null?void 0:se.map(ee=>ee.rewards).flat())||[],J=[...T,...X,...Q];F("score"),W(J)},[T,W,o,($=e==null?void 0:e.solution)==null?void 0:$.right,F,n==null?void 0:n.correctFeedbacks]),q=()=>{E(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&D(e.solution.right.desc),A(!0)},z=()=>{g||y?Z():(x(!1),a(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1})),D("")},U=X=>{if(R(!0),n!=null&&n.specificCorrectFeedbacks){const Q=n.correctFeedbacks.find(J=>J.id===X);Q!=null&&Q.desc&&(D(Q.desc),A(!0))}F("score"),o({type:"hidePuzzleButtons",payload:!0})},I=(X,Q=!1)=>{var J,ne;if(R(!1),Q)D((J=e.orderFeedback)==null?void 0:J.desc),A(!0),w([...T,...((ne=e.orderFeedback)==null?void 0:ne.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const se=n.wrongFeedbacks.find(ee=>ee.id===X);se!=null&&se.desc?(D(se.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),w([...T,...(se==null?void 0:se.rewards)||[]])}else e.solution.wrong.desc?(D(e.solution.wrong.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!Q&&w([...T,...e.solution.wrong.rewards]),F("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};return React$2.useEffect(()=>{y&&a(!0)},[a,y]),React$2.useEffect(()=>{u(()=>{var Q;o({type:"hidePuzzleButtons",payload:!0}),O(!0);const X=[...T,...((Q=e==null?void 0:e.resolve)==null?void 0:Q.rewards)||{}];setTimeout(()=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:X,finish:!0}})},2e3)})},[u,a,T,(B=e==null?void 0:e.resolve)==null?void 0:B.rewards,o,V]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cards-selector ${f!=null&&f.url?"cards-selector--with-custom-bg":""}`,style:f!=null&&f.url?{backgroundImage:`url("${f.url}")`}:{},children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:_,currentOrder:p,cards:r,onFinish:q,resolveWithAnyCard:t,handleError:I,feedbackIsShown:S,resolvePuzzle:P,soundActions:l,handleSuccess:U})}),S&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:g||C,text:k,hasTimeout:!k,translate:G,functionOnClose:z,keyboardControl:h})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:o,index:e,length:r,textToPrint:t,setDoneTyping:n,nextParagraphType:a,isWriting:u}){const[l,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[y,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const p=C=>{if(!C||!C.length)return"";const R=C.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const C=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const T=[...S];if(p(S[A]).length!==0){const w=S[A];return T[A]=`<span class="lastWord" >${w}</span>`,T}return R(S,A-1)};a==="election"?h(C()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},g=t.split("<p>");g.shift();const x=g.length>1;return l&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:u,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&y&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:o,decisionInspected:e,setCurrentDecisionSelected:r,index:t,setCurrentDecisionInspected:n,soundActions:a}){const[u]=a,l=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{u("click-ui"),r(t)},h=E=>{E.keyCode===13&&y(E)},y=E=>{E.preventDefault(),E.stopPropagation(),e===t?(E.target.style.background="",n("")):n(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>c(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:l(o)})}),jsxRuntimeExports.jsx("div",{onClick:y,onKeyDown:h,className:f(o),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(o.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:o,opt:e,index:r,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,soundActions:a}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:o,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,option:e,soundActions:a,index:r}):null}function ElectionComponent({textWithOpts:o,setCurrentDecisionSelected:e,printed:r,soundActions:t}){const[n,a]=React$2.useState("");return React$2.useEffect(()=>{r()},[r]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${n+1}-${o.filter(u=>!!u.fullText).length}`,children:o&&o.map((u,l)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:u,soundActions:t,index:l,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},l))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:o}){const{title:e,body:r}=o.feedback;return jsxRuntimeExports.jsx("div",{children:r!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),r&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[o.correct?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("span",{children:r})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:o,closingAction:e,feedbackIsDone:r,decisionsList:t,texts:n,retryAction:a,retry:u,skip:l,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:y}){const[E]=y,p=g=>o({type:"translate",payload:g}),_=()=>{E("click-ui"),e(),h(),r()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${c.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:p("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(g=>n[g.currenTextParagraph].electionTexts[g.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[g.currenTextParagraph].electionTexts[g.index]},g.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:p("puzzles.skip")}),u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:p(f()?"puzzles.continue":"puzzles.retry")}),!u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:p("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:o,correct:e}){const r=o.split("<p>");r.shift();const t=r.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(o)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:o,styles:e,nodeId:r,retry:t,skip:n,type:a,info:u,setResolveAction:l,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:y,backgroundImage:E}){const p=Ie=>o({type:"translate",payload:Ie}),_=React$2.useRef(),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(0),[T,w]=React$2.useState({[`text_${S}`]:{...h[S],id:`text_${S}`,correct:""}}),[P,O]=React$2.useState(!1),[k,D]=React$2.useState([]),[F,G]=React$2.useState(!1),[V,W]=React$2.useState(!1),[Z,q]=React$2.useState(!1),[z,U]=React$2.useState(!0),[I,$]=React$2.useState([]),[B,X]=React$2.useState(!0),[Q]=y,J=React$2.useRef({}),ne=Ie=>{let et;return Ie.electionTexts.forEach((at,Kt)=>{at.correct&&(et=Kt)}),et},se=React$2.useCallback(Ie=>k.filter(at=>at.currenTextParagraph===Ie)[0].fullText_labelId,[k]),ee=React$2.useCallback(()=>h.map((Ie,et)=>{if(Ie.type==="fixed")return Ie.fullText_labelId??Ie.fullText;if(Ie.type==="election"){const at=ne(Ie);return at>=0?Ie.electionTexts[at].fullText_labelId:se(et)}return""}),[se,h]),ie=12,oe=()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="none"&&(et+=1);return et===Ie}return!0},fe=React$2.useCallback(()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="green"&&(et+=1);return et===Ie}return!0},[k]),de=()=>!!(k&&k.length),ce=()=>k.find(Ie=>{const{feedback:et}=h[Ie.currenTextParagraph].electionTexts[Ie.index];return et.body!==""}),Se=React$2.useCallback(()=>{const Ie=ee();o({type:"finishMedia",payload:{name:c,text:Ie,documentType:a,type:"text"}})},[ee,c,o,a]),ke=React$2.useCallback(Ie=>{const et=fe();Q(C?"fail":et?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ie||I,onFinish:a!=="view"?Se:null}),o({type:"passPuzzle"})},[fe,o,C,Se,Q,I,a]);React$2.useEffect(()=>{g&&X(!1),l(()=>{ke(u.resolve.rewards)})},[o,ke,g,Se,u.resolve.rewards,l,a]);const Ne=()=>{x(!1),A(0),D([]),$([]),R(!1),q(!1),O(!1),W(!1),G(!1),w({text_0:{...h[0],id:"text_0",correct:""}}),U(!0),o({type:"addPoints",complex:!0,finish:!1,payload:I}),o({type:"failPuzzle"})},We=()=>{de()?oe()&&(G(!0),ke()):(G(!0),q(!0),ke()),F?(U(!1),Z&&!V?W(!0):(V||!Z&&!V)&&(!Z&&!V&&t?fe()?ke():Ne():ke())):(G(!0),ce()&&q(!0))},Ke=()=>{const Ie=h[S].electionTexts.filter(at=>at.correct).length,et=h[S].electionTexts;return Ie===0||Ie===et},Qe=Ie=>{const et=h[S].electionTexts[Ie],at=et.feedback.rewards;at&&at[0]&&at[0].points&&(J.current[`t${S}_e${Ie}`]||(et.correct&&(J.current[`t${S}_e${Ie}`]=!0),$([...I,...at])));const Kt=()=>Ke()?"none":et.correct?"green":"red",Xe={currenTextParagraph:S,fullText:et.fullText,index:Ie,isCorrect:Kt()};w({...T,[`text_${S}`]:{type:"fixed",fullText:et.fullText,correct:Xe.isCorrect}}),D([...k,Xe])},pt=()=>{_.current.scrollTop=_.current.scrollHeight+100},vt=()=>{if(_.current.querySelector(".wrapfixed").offsetHeight>_.current.offsetHeight){const Ie=_.current.querySelector(".wrapfixed").offsetHeight;_.current.scrollTo({top:Ie,behavior:"smooth"})}},ct=(Ie,et,at)=>{const Kt=Ie.fullText,Xe=h[at+1]?h[at+1].type:"",it=T[`text_${at+1}`]&&T[`text_${at+1}`].type?T[`text_${at+1}`].type:Xe;return jsxRuntimeExports.jsx(FixedComponent,{length:et,doneTyping:P,index:at,delay:ie,setDoneTyping:O,nextParagraphType:it,isWriting:vt,textToPrint:Kt},at.toString())},mt=(Ie,et)=>{const at=Ie.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:at,correct:Ie.correct},et)},Vt=Ie=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:y,textWithOpts:Ie.electionTexts,setCurrentDecisionSelected:Qe,printed:pt,disableExit:B},Ie.electionTexts),kt=(Ie,et,at)=>Ie.type==="fixed"?ct(Ie,et,at):Vt(Ie);return React$2.useEffect(()=>{P===!0&&(()=>{h[S+1]?(w({...T,[`text_${S+1}`]:{...h[S+1],id:`text_${S+1}`,correct:""}}),A(S+1),O(!1)):x(!0)})()},[P,S,T,h]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:`writer-puzzle writer-puzzle--${e}`,style:E!=null&&E.url?{backgroundImage:`url("${E.url}")`}:{},children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[V&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>R(!0),decisionsList:k,closingAction:We,retry:t,skip:n,checkCorrect:fe,retryAction:Ne,rewardsStack:I,nodeId:r,soundActions:y}),!V&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:f!==""&&f}),jsxRuntimeExports.jsx("div",{className:"writer-puzzle__body",dir:LangIsRtl()?"rtl":"auto",children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__scroll",tabIndex:0,style:{overflowX:"hidden",padding:"0 0 20px 0",height:"95%"},ref:_,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:z&&!F&&Object.values(T).map((Ie,et)=>kt(Ie,Object.values(T).length-1,et))}),F&&Object.values(T).map((Ie,et)=>mt(Ie,et))]})}),g&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:We,children:p("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:o,name:e,isWallpaper:r}){const t=(o==null?void 0:o.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${r?"puzzle--terminal__image--wallpaper":""}`,children:t?jsxRuntimeExports.jsx("img",{src:t,alt:e||""}):null})}const ICONS$1={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",world:"world-icon"};function Visor({file:o,solution:e,showContinue:r,info:t,resolvePuzzle:n,backFile:a,translate:u,soundActions:l,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[y]=l,E={image:{component:Image$1,props:{...o,url:h,soundActions:l}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:l,translate:u}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:l}},pdf:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const p=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),C=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,shortText:!0,success:c===C,text:c===C?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===C?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:u,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(p,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===C&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:u("screens.continue")}):null})]})})}const ICONS={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",application:"pdf-icon",world:"world-icon"};function Item({item:o,selectItem:e}){const r=o.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:r,className:`unset-button puzzle--terminal__item id-${o.id}`,onClick:()=>o.fixed?null:e(o),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[o.type]}`}),jsxRuntimeExports.jsx("span",{children:r})]})})}function FilesGroup({initFile:o,backFile:e,file:r,closeFolder:t,selectItem:n}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:r.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${u}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))}),jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder--head",children:[jsxRuntimeExports.jsx("span",{role:"button",onKeyUp:()=>{},"aria-label":"back file",tabIndex:0,onClick:()=>e(),className:"puzzle--terminal__folder--back",children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__folder--head__icon ${ICONS[r.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:r.name}),jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,"aria-label":"close folder",onKeyUp:()=>{},onClick:()=>t(),className:"puzzle--terminal__folder--close",children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__folder--body",children:jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))})})]})]})})}const DEFAULT_IMG="https://min.gamelearn.io/css-resources/gamelearn/resources/cosmos-bg-min.jpg",FIXED_ITEMS=[{fileId:"ids1",type:"world",fixed:!0,name:"Web builder 3.0"},{fileId:"ids2",type:"cracker",fixed:!0,name:"Decoder.exe"},{fileId:"ids3",type:"terminal",fixed:!0,name:"terminal"}];function TerminalPuzzleComponent({emitEvent:o,items:e,backgroundImage:r,solution:t,info:n,disableExit:a,soundActions:u,setResolveAction:l,nodeId:f,keyboardControl:c}){const[h,y]=React$2.useState({}),[E]=React$2.useState(!1),[p,_]=React$2.useState([]),g=React$2.useRef([]),[x]=u,C=k=>o({type:"translate",payload:k}),R=`terminal-puzzle_${f}`,S=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),A=React$2.useCallback(k=>{x("click-ui"),y(k),_([...p,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[p,a,o,x]);React$2.useEffect(()=>{y(S),_([S])},[S]),React$2.useEffect(()=>{l(()=>{g.current=[...g.current,...n.resolve.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:k,finish:!0}})})},[l,n.resolve.rewards,o,R]);const T=()=>{g.current=[...g.current,...n.solution.wrong.rewards];const k=p.length-1,D=p.filter((F,G)=>k>G);y(p[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=p[0];y(k),_([k])},P=()=>{g.current=[...g.current,...n.solution.right.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),x("score"),o({type:"addPoints",complex:!0,finish:!0,payload:k}),o({type:"passPuzzle"})},O=(r==null?void 0:r.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:h.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:O}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:T,initFile:S,selectItem:A,breadcrumb:p,closeFolder:w,file:h,translate:C})]}):jsxRuntimeExports.jsx(Visor,{soundActions:u,backFile:T,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:C,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:u,emitEvent:l,soundActions:f,keyboardControl:c}){const{solution:h}=t,y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),g=React$2.useRef({}),[x,C]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(),[O]=React$2.useState(new window.Image),k=React$2.useRef([]),[D]=f,F=J=>l({type:"translate",payload:J});React$2.useEffect(()=>{u(x!=="")},[x,u]);const G=(J,ne)=>(J.x+J.width>ne.x&&J.x+J.width<=ne.x+ne.width||ne.x+ne.width>J.x&&ne.x+ne.width<=J.x+J.width)&&(J.y+J.height>ne.y&&J.y+J.height<=ne.y+ne.height||ne.y+ne.height>J.y&&ne.y+ne.height<=J.y+J.height),V=()=>{y&&n&&(y.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},W=()=>{y&&n&&(y.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},Z=React$2.useCallback(J=>{let ne=!1;if(J){const se=p.current;se.setPointersPositions(J);const ee=se.getPointerPosition(),ie=y.current.getClientRect({relativeTo:se});ne=G({...ee,width:1,height:1},ie)}return ne},[]),q=React$2.useCallback(J=>J&&r.uid===JSON.parse(J).uid,[r.uid]),z=React$2.useCallback(()=>{C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:k.current}),l({type:"passPuzzle"}),a&&l({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),l({type:"closeUI",ui:"inventory"})},[a,l,r.name,r.uid]),U=React$2.useCallback(()=>{C("success"),l({type:"hidePuzzleButtons",payload:!0}),k.current=[...k.current,...h.right.rewards],setTimeout(()=>{z()},2e3)},[l,z,h.right.rewards]),I=React$2.useCallback(()=>{l({type:"openUI",ui:"inventory",onFinish:()=>{}}),C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"failPuzzle"}),k.current=[...k.current,...h.wrong.rewards]},[l,h.wrong.rewards]),$=React$2.useCallback(J=>{const ne=J.dataTransfer.getData("item");p.current.setPointersPositions(J);const se=Z(J);l({type:"hidePuzzleButtons",payload:!0}),se&&q(ne)?(C("success"),l({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&U()):(l({type:"closeUI",ui:"inventory"}),C("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{I()},2e3))},[Z,q,l,U,I,t.solution.right.desc,t.solution.wrong.desc]),B=()=>{x==="success"?U():I()};React$2.useEffect(()=>{const J=e.img.url||"";O.src=J,O.onload=()=>{_.current&&(g.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:O.width,height:O.height,offsetX:O.width/2,offsetY:O.height/2,scale:{x:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height),y:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height)}},S(!0))}},[O,e.img.url]),React$2.useEffect(()=>{A||(l({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(!0))},[A,l]);const X=J=>{J!==null&&(y.current=J)},Q=J=>{if(J!==null&&(E.current=J,y.current)){const{x:ne,y:se,width:ee,height:ie}=y.current.getClientRect();J.setAttr("x",ne),J.setAttr("y",se),J.setAttr("height",ie),J.setAttr("width",ee)}};return React$2.useLayoutEffect(()=>{if(y.current&&R){const J=y.current.getClientRect({relativeTo:y.current.getParent()});P({x:J.x+J.width/2,y:J.y+J.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:$,onDragOver:J=>{J.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:_,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:R?jsxRuntimeExports.jsx(Stage,{ref:p,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:O,...g.current}),jsxRuntimeExports.jsxs(Group,{...g.current,children:[w?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...w},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:V,onMouseLeave:W,ref:X,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:V,onMouseLeave:W,ref:Q,text:F("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),x!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[x==="success"?"right":"wrong"].desc,success:x==="success",translate:F,playSound:D,functionOnClose:B,keyboardControl:c}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:o,answered:e,question:r,updateForm:t,result:n,correctQuestions:a,translate:u}){const[l,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let C=!1;return n[r.id].find(R=>R.id===x)&&(C=!0),C},y=x=>{let C="";return l?(e&&h(x.id)&&(C="selected"),o&&h(x.id)&&a.includes(x.id)&&(C="success"),o&&h(x.id)&&!a.includes(x.id)&&(C="failed")):(e&&x.id===n[r.id][0].id&&(C="selected"),o&&x.id===n[r.id][0].id&&(C=n[r.id][0].isCorrect?"success":"failed")),C},E=x=>{const C=y(x);return C==="selected"?"icon-check-circle-black color--selected":C==="success"?"icon-check-circle-black color--success":C==="failed"?"icon-error-circle-black color--error":""},p=x=>o&&x.feedback&&(l&&h(x.id)||x.id===n[r.id][0].id),_=(x,C)=>C===0?"tooltip--right__top":C===x.length-1?"tooltip--right__bottom":"tooltip--center__right",g=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{g.length===1?f(!1):f(!0)},[g.length,l,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),l&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:u("tests.chooseMoreOneAnswer")}):null,c.map((x,C)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[l?jsxRuntimeExports.jsx("input",{checked:e&&h(x.id),disabled:o&&!h(x.id),readOnly:o,type:"checkbox",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!y(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${y(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[C]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:x.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${E(x)}`})]}),o?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${p(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${y(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${C}`,className:`tooltip ${_(c,C)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:u("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:x.feedback})})]})]}):null]},x.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:o,correctQuestions:e,question:r,translate:t}){const n=l=>e.includes(l),a=(l,f)=>l.index<f.index?-1:l.index>f.index?1:0,u=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),u.map(l=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(l.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[l.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:l.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(l.id)?"icon-check-circle-black color--success":"icon-error-circle-black color--error"}`})]}),jsxRuntimeExports.jsxs("div",{className:"test--feedback",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsxs("span",{children:[t("test.feedback")," ",o.length>1?LABELS_INDEX[l.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:l.feedback})]})]},l.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:u,showResults:l,answered:f,answerPage:c,updateForm:h,disabled:y,translate:E,soundActions:p,paused:_,view:g,correctQuestions:x,feedbacksOnlyWhenReview:C}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[T,w]=React$2.useState(),P=o[S].id,[O]=p;React$2.useEffect(()=>{if(u>=0&&!y&&!_){const q=setInterval(()=>{T||e(z=>z-1)},1e3);return r(q),()=>{clearInterval(q)}}},[y,T,_,r,e,u]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!y&&!C?w(!0):(c(!1),A(S+1)))},D=()=>{O("click-ui"),A(S-1)},F=()=>{R.scrollTo(0,0),o[S+1]?(w(!1),c(!1),A(S+1)):l()},G=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!y&&!C?w(!0):l()},V=Math.floor(u/60),W=u%60;React$2.useEffect(()=>{if(g==="review"){const q=t[`q${S}`][0].id,z=document.querySelector(`#${q}`);R.scrollTo(0,z.offsetTop)}},[S,R,t,g]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,z=t[P],U=z.find($=>$.isCorrect===!1);let I=0;return z.forEach($=>{q.includes($.id)&&(I+=1)}),!U&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||T?jsxRuntimeExports.jsx("div",{className:`test-feedback-header ${Z()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${Z()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:Z()?E("tests.resolvedQuestion"):E("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:T?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:x[o[S].id.substring(1)].answers,question:o[S].text,translate:E}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[S+1,"/",o.length," ",jsxRuntimeExports.jsx("span",{children:E("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:E("tests.question")})," ",S+1,"/",o.length]})}),g!=="review"&&u>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${u<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[V<10?`0${V}`:V," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:y,answered:f,updateForm:h,question:o[S],correctQuestions:y?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${g==="review"?"reviewmode":"next"}`,children:[g==="review"?jsxRuntimeExports.jsx("button",{disabled:S===0,id:"back-button",onClick:()=>D(),type:"button",className:`gat--btn__navigation ${S===0?"disabled":""}`,"aria-label":LangIsRtl()?E("survey.next"):E("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!T&&o[S+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,T?jsxRuntimeExports.jsx("button",{id:"next-button",onClick:()=>F(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!T&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&G()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:o,time:e,mandatory:r,correctQuestions:t,isFirst:n,reviewTest:a,finishTest:u,restartTest:l,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:y}){const[E,p]=React$2.useState(0),[_,g]=React$2.useState(),[x,C]=React$2.useState([]),[R,S]=React$2.useState([]),[A,T]=React$2.useState([]),w=React$2.useCallback(()=>{const z=[];return t.forEach(U=>z.push(U.answers)),z},[t]),P=React$2.useCallback(()=>{const z=[];return Object.values(o).forEach(U=>{if(U.length>1){const I=U.find(B=>B.isCorrect===!1),$=[];I?z.push([]):(U.forEach(B=>{B.isCorrect&&$.push(B.id)}),z.push($))}else U[0].isCorrect?z.push([U[0].id]):U[0].isCorrect===!1&&z.push("")}),z},[o]),O=React$2.useCallback(()=>{let z=0;return R.length>0&&x.forEach((U,I)=>{U.length>1?U.every($=>R[I].includes($))&&(z+=1):U.length===1&&R[I]&&U[0]===R[I][0]&&(z+=1)}),z},[x,R]);React$2.useEffect(()=>{C(w),S(P),T(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<y,G=A>=y,V=!r||G,W=Math.trunc(E/k*100),Z=(z,U)=>h({type:"translate",payload:z,values:U}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const z=setInterval(()=>{p(U=>U+1)},100);return g(z),()=>{clearInterval(z)}}},[A,E]),React$2.useEffect(()=>{E>=A&&clearInterval(_)},[A,_,E]),jsxRuntimeExports.jsxs("div",{className:`test--results ${F||f?"test--results--failed":""}`,children:[n&&D?jsxRuntimeExports.jsxs("div",{className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!f&&F?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.NotFinishedSuccessfully")})}):null,!f&&G||D?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.finishedSuccessfully")})}):null,f?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:c})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:Z("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${W}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:F||f?q:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:F||f?q:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{children:E}),jsxRuntimeExports.jsxs("span",{children:["/",k]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:Z("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:Z("tests.minimumQuestionsMessage",{minimumPercentage:y})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>a(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.review")})}),V?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>l(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),V?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.continue")})}):null]})]})}function TestComponent({test:o,countdown:e={},emitEvent:r,soundActions:t,audio:n,required:a,pause:u,minimumPercentage:l=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,y]=React$2.useState({}),[E,p]=React$2.useState(),[_,g]=React$2.useState(0),[x,C]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,T]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[G,V]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,z=React$2.useRef({}),[U,I]=React$2.useState(),[$,B]=t,X=(ie,oe,fe,de,ce)=>{const Se={...ie,index:fe};if(_>0&&(Se.rewards=Se.rewards.filter(Ne=>!G[ie.id]||Ne.points<0)),h[oe]){const Ne=h[oe].find(We=>We.id===ce);if(Ne){if(Ne.id===ie.id){const We=h[oe].find(Qe=>Qe.id===ce),Ke=h[oe].indexOf(We);if(h[oe].splice(Ke,1),h[oe].length===0){T(!1);return}}}else h[oe].push(Se)}else h[oe]=[Se];let ke;de==="isRadio"?ke={...h,[oe]:[Se]}:ke={...h},y(ke),F(ke),V({...G,[ie.id]:{...ie}}),T(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(ie=>{const oe=ie.answers.filter(de=>de.isCorrect),fe=[];return oe.forEach(de=>{fe.push(de.id)}),{question:ie.id,answers:fe}});React$2.useEffect(()=>{C(Q)},[Q]),React$2.useEffect(()=>{if(l){const ie=Math.ceil(c.length*l/100);I(ie)}},[c.length,l]),React$2.useEffect(()=>{R===0&&(clearInterval(E),T(!1),Z(!0),P("results"),B("tts"))},[E,B,R]);const J=()=>{clearInterval(E),T(!1),P("results");const ie={...D};F(ie),B("tts")},ne=()=>{const ie={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(de=>{z.current[de.id]&&(de.rewards=[])})}),r({type:"saveTest",payload:ie})},se=()=>{const ie=()=>{F({}),V({}),P("test"),y({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(de=>{de.forEach(ce=>{ce.isCorrect&&(z.current[ce.id]?ce.rewards=[]:z.current[ce.id]=!0)})});let fe=oe.reduce((de,ce)=>{const Se=[];return ce.forEach(ke=>{Se.push(ke.rewards)}),[...de,...Se.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:ie}),r({type:"failTest"})},ee=(ie,oe)=>r({type:"translate",payload:ie,values:oe});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"test--container",dir:"auto",children:w!=="results"?jsxRuntimeExports.jsx(Container,{result:h,time:R,setTries:g,tries:_,answerPage:T,setTime:S,paused:u,saveInterval:p,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:J,translate:ee,soundActions:t,view:w,correctQuestions:x,feedbacksOnlyWhenReview:f}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),P("review")},isFirst:O,finishTest:ne,time:R,mandatory:q,restartTest:se,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:U})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((u,l)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--response__item ${e[r]===u?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[l]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${u}`)})]},u))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(u=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--points__item ${e[r]===u?"selected":""}`,children:u},u))}),jsxRuntimeExports.jsxs("div",{className:"survey--points__labels",children:[jsxRuntimeExports.jsx("span",{children:t("survey.bad")}),jsxRuntimeExports.jsx("span",{children:t("survey.excellent")})]})]})}function TextBox({setSurveyData:o,survey:e,id:r,literalLabel:t}){const n=a=>{o({...e,[r]:a})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:a=>{a&&a.focus()},className:"survey--textarea",id:t,value:e[r],onChange:a=>n(a.target.value)})})}const INIT_SURVEY={applicable:"",opinion:"",comments:"",suggestions:""},PAGES=[{component:ApplicableBox,id:"applicable"},{component:OpinionBox,id:"opinion"},{component:TextBox,id:"comments"},{component:TextBox,id:"suggestions"}];function SurveyComponent({emitEvent:o,soundActions:e}){const[r,t]=React$2.useState(INIT_SURVEY),[n,a]=React$2.useState(0),[u,l]=React$2.useState(!1),[f]=e,c=(E,p)=>o({type:"translate",payload:E,values:p}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)l(!0);else{E&&l(!1);const p=E?n-1:n+1;a(p)}},y=PAGES[n].component;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"survey--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"survey--container",dir:"auto",children:jsxRuntimeExports.jsxs("div",{className:"survey--questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{children:c("survey.numQuestion",{init:n+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:c("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item",htmlFor:c(`survey.question${n+1}`,{ordinal:n+1}),children:c(`survey.question${n+1}`,{ordinal:n+1})}),jsxRuntimeExports.jsx(y,{setSurveyData:t,id:PAGES[n].id,survey:r,translate:c,changePage:E=>h(!1),literalLabel:c(`survey.question${n+1}`,{ordinal:n+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{id:"survey-button-back",type:"button",disabled:n===0,onClick:()=>h(!0),className:`gat--btn__navigation ${n===0?"disabled":""}`,"aria-label":LangIsRtl()?c("survey.next"):c("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),u&&n===PAGES.length-1?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>{f("click-ui"),o({type:"saveSurvey",payload:r})},className:`gat--btn gat--btn__primary ${r[PAGES[n].id]?"":"disabled"} not-transition`,children:c("survey.finish")}):null,!u&&n!==PAGES.length?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>h(!1),className:`gat--btn__navigation ${r[PAGES[n].id]?"":"disabled"}`,"aria-label":LangIsRtl()?c("survey.previous"):c("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:o,translate:e}){return React$2.useEffect(()=>{let r;return o&&(r=setTimeout(()=>{o()},2e3)),()=>{r&&clearTimeout(r)}},[o]),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__endscreen","aria-label":"auto evaluation endscreen",children:jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__finishband","aria-label":"auto evaluation finishband",children:[jsxRuntimeExports.jsx("span",{className:"icon-check-laptop auto-evaluation__iconendscreen","aria-label":"icon-check",role:"img"}),jsxRuntimeExports.jsx("span",{className:"auto-evaluation__thanks","aria-label":"auto evaluation thanks",role:"contentinfo",children:e("auto-evaluation.thanks")})]})})}function StartScreen({onNext:o,description:e,translate:r}){return jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__startscreen",role:"alertdialog","aria-modal":"true","aria-label":"ae start screen",children:[jsxRuntimeExports.jsx("span",{className:"icon-happy-laptop auto-evaluation__starticon","aria-label":"icon laptop",role:"img"}),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__starttext","aria-label":"desciption",children:jsxRuntimeExports.jsx("span",{children:e})}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:o,children:jsxRuntimeExports.jsx("span",{children:r("auto-evaluation.start")})})]})}function AutoEvaluation({description:o,questions:e,type:r,emitEvent:t,soundActions:n}){var A,T,w;const[a,u]=React$2.useState(null),[l,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(0),[p,_]=React$2.useState({current:{questions:[],type:r}}),[g]=n,x=P=>t({type:"translate",payload:P}),C=P=>{P.keyCode===13&&P.target.blur()},R=()=>{g("click-ui"),t({type:"saveSurveyPrePos",payload:p.current})};React$2.useEffect(()=>{!e.length&&l==="questions"&&f("end")},[e,l]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=p.current.questions.find(F=>F.id===e[y].id))==null?void 0:D.answer;if(g("click-ui"),O)E(y-1),h(!1);else{const F=p.current.questions.findIndex(V=>V.id===e[y].id),G=[...p.current.questions];F>-1?G.splice(F,1,{id:e[y].id,answer:k}):G.push({id:e[y].id,answer:k}),_({...p,current:{...p.current,questions:G}}),y===e.length-1?h(!0):(E(y+1),h(!1))}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay","aria-label":"test container overlay"}),jsxRuntimeExports.jsxs("div",{className:"test--container",dir:"auto","aria-label":"test container",children:[l==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),g("click-ui")},translate:x}),l==="questions"&&jsxRuntimeExports.jsxs("div",{className:"survey--questions","aria-label":"survey questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container","aria-label":"survey questions container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs("span",{children:[x("auto-evaluation.question")," ",y+1," ",x("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:x("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(A=e[y])==null?void 0:A.text}),jsxRuntimeExports.jsx("div",{className:"survey--page__item","aria-label":"survey page item",children:jsxRuntimeExports.jsx("div",{className:"survey--points","aria-label":"survey points",children:Array(11).fill(0).map((P,O)=>{var k;return jsxRuntimeExports.jsx("button",{type:"button",onTouchStart:()=>{u(O)},onTouchEnd:()=>{u(null)},onKeyUp:D=>{C(D)},onClick:()=>{S(O,!1)},className:`survey--points__item ${((k=p.current.questions[y])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[y]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:y===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${y===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),c?jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f("end"),g("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
|
|
253
253
|
`,children:jsxRuntimeExports.jsx("span",{children:x("auto-evaluation.end")})}):jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>S(null,!1),disabled:((T=p.current.questions[y])==null?void 0:T.answer)===void 0,"aria-label":LangIsRtl()?x("survey.previous"):x("survey.next"),className:`gat--btn__navigation ${((w=p.current.questions[y])==null?void 0:w.answer)===void 0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]}),l==="end"&&jsxRuntimeExports.jsx(EndScreen,{onFinish:R,translate:x})]})]})}function PatternComponent({img:o,name:e,viewed:r,emitEvent:t,soundActions:n,keyboardControl:a}){const[u]=n,l=h=>t({type:"translate",payload:h});if(!o)return null;const f=o.url,c=()=>{u("click-ui"),t({type:"emitSavePattern",payload:{imgId:o.resourceId,name:e,viewed:!0,url:f,type:"pattern"}})};return a(null,r?null:c,r?null:c),jsxRuntimeExports.jsx("div",{className:r?"notes--results":"readings--container pattern-wrap--overlay",children:jsxRuntimeExports.jsx("div",{className:r?"notes--results__text":"pattern-wrap",children:r?jsxRuntimeExports.jsx("div",{children:f&&jsxRuntimeExports.jsx("img",{src:f,alt:"pattern"})}):jsxRuntimeExports.jsxs("div",{className:"pattern",children:[jsxRuntimeExports.jsxs("div",{className:"pattern__header",children:[jsxRuntimeExports.jsx("div",{className:"pattern__title",children:l("phone.pattern")}),jsxRuntimeExports.jsx("button",{type:"button","aria-label":l("storylines.misc.closePiece"),className:"pattern__close gat--btn__round gat--btn__close",onClick:()=>c(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("figure",{className:"pattern__figure",children:f&&jsxRuntimeExports.jsx("img",{src:f,alt:"pattern"})})]})})})}const getRecursiveJSX=(o,e=0,r,t,n)=>{var a,u;if((a=o.props)!=null&&a.children){const l=o.type,{children:f,...c}=o.props;if(o.props["data-text-id"]){if(c.dir="auto",c.onClick=h=>t(h,c["data-text-id"]||-1),r!=null&&r.hasHighlights){const h=[...r.correctTexts,...r.wrongTexts];for(let y=0;y<h.length;y+=1)c["data-text-id"]===h[y].id&&(c.className="text-click__hover-correct")}}else r!=null&&r.allWrong&&!o.props["data-text-id"]&&(c.onClick=h=>t(h,"allWrong"));return Array.isArray(f)?jsxRuntimeExports.jsx(l,{...c,children:f.map((h,y)=>getRecursiveJSX(h,y,r,t))},`${o.type}_${e}`):jsxRuntimeExports.jsx(l,{...c,children:getRecursiveJSX(f,e,r,t)},`${o.type}_${e}`)}return((u=o.props)==null?void 0:u.children)!==null?o.split(" ").filter(l=>l!=="").map(l=>jsxRuntimeExports.jsx("span",{dir:"auto",children:l},l)):null};function TextClickPuzzleComponent({emitEvent:o,showFrames:e,styles:r,list:t,soundActions:n,description:a,setInfo:u,setResolveAction:l,keyboardControl:f,backgroundImage:c}){const[h,y]=React$2.useState({result:null,show:!1,text:"",timeout:!1}),[E]=n,[p,_]=React$2.useState(0),[g,x]=React$2.useState(0),[C,R]=React$2.useState(0),S=React$2.useRef(0),A=React$2.useRef([]),[T,w]=React$2.useState(0),[P,O]=React$2.useState(),k=React$2.useCallback($=>o({type:"translate",payload:$}),[o]),D=React$2.useRef(null),F=React$2.useCallback(()=>S.current===t[p].correctTexts.length||t[p].hasClickOnce&&S.current>=1,[p,t]),G=React$2.useCallback(($,B)=>{$&&o({type:"hidePuzzleButtons",payload:!0}),y(X=>({...X,show:$,...B}))},[o]),V=React$2.useCallback(()=>{if(F())if(y($=>({...$,result:!1})),S.current=0,C===g){const $=A.current.reduce((B,X)=>{const Q=B.findIndex(J=>J.id===X.id);return Q>=0?B[Q].points+=X.points:B.push({...X}),B},[]);o({type:"addPoints",complex:!0,finish:!0,payload:$}),o({type:"passPuzzle"})}else D.current=null,_(p+1),w(0),O(!0),setTimeout(()=>{O(!1)},1200)},[F,C,g,o,p]),W=React$2.useCallback(()=>{o({type:"hidePuzzleButtons",payload:!1}),V(),y(B=>({...B,show:!1,text:""}));const $=document.querySelectorAll(".text-click__failed");$.length>0&&$.forEach(B=>B.classList.remove("text-click__failed"))},[o,V]),Z=React$2.useCallback(($,B)=>{var X,Q;$.forEach(J=>J.classList.add("text-click__success")),R(C+1),S.current+=1,E("score"),(X=t[p].info.solution.right)!=null&&X.desc?F()&&(A.current=[...A.current,...t[p].info.solution.right.rewards],G(!0,{result:!0,text:t[p].info.solution.right.desc,timeout:!1})):t[p].info.solution.right.desc===""&&(B!=null&&B.desc)?(A.current=((Q=B==null?void 0:B.rewards)==null?void 0:Q.length)>0?[...A.current,...(B==null?void 0:B.rewards)||{}]:[...A.current],G(!0,{result:!0,text:B.desc,timeout:!1})):t[p].specificFeedbacks.specificCorrectFeedbacks?(A.current=[...A.current,...(B==null?void 0:B.rewards)||{}],F()&&G(!0,{result:!0,timeout:!0})):F()&&(A.current=[...A.current,...t[p].info.solution.right.rewards],G(!0,{result:!0,timeout:!0}))},[C,E,t,p,F,G]),q=React$2.useCallback(($,B)=>{var X;$.forEach(Q=>Q.classList.add("text-click__failed")),E("fail"),o({type:"failPuzzle"}),t[p].info.solution.wrong.desc!==""?(A.current=[...A.current,...t[p].info.solution.wrong.rewards],G(!0,{result:!1,text:t[p].info.solution.wrong.desc,timeout:!1})):t[p].info.solution.wrong.desc===""&&(B!=null&&B.desc)?(A.current=(X=B==null?void 0:B.rewards)!=null&&X.length?[...A.current,...(B==null?void 0:B.rewards)||{}]:[...A.current],G(!0,{result:!1,text:B.desc,timeout:!1})):t[p].specificFeedbacks.specificWrongFeedbacks?(A.current=[...A.current,...(B==null?void 0:B.rewards)||{}],G(!0,{result:!1,timeout:!0})):(A.current=[...A.current,...t[p].info.solution.wrong.rewards],G(!0,{result:!1,timeout:!0}))},[E,o,t,p,G]),z=React$2.useCallback(($,B)=>{var ie,oe,fe,de;$.stopPropagation();const X=document.querySelectorAll(`[data-text-id="${B}"]`),Q=document.querySelectorAll("[data-text-id]"),J=t[p].correctTexts.find(ce=>ce.id===B),ne=t[p].wrongTexts.find(ce=>ce.id===B),se=(oe=(ie=t[p])==null?void 0:ie.specificFeedbacks)==null?void 0:oe.correctFeedbacks.find(ce=>ce.id===B),ee=(de=(fe=t[p])==null?void 0:fe.specificFeedbacks)==null?void 0:de.wrongFeedbacks.find(ce=>ce.id===B);E("click-ui"),t[p].hasClickOrder?t[p].correctTexts[T].id===B?(w(T+1),Z(X,se)):t[p].correctTexts.find(ce=>ce.id===B)&&t[p].correctTexts[T].id!==B?(Q.forEach(ce=>ce.classList.remove("text-click__success")),w(0),R(0),S.current=0,G(!0,{result:!1,text:t[p].info.orderFeedback.desc||k("puzzles.incorrectOrder"),timeout:!1}),_(0)):q(X,ee):(J==null?void 0:J.id)===B?Z(X,se):((ne==null?void 0:ne.id)===B||B==="allWrong")&&q(X,ee)},[t,p,E,T,Z,G,k,q]),U=React$2.useCallback($=>getRecursiveJSX($,0,t[p],z),[p,t,z]),I=React$2.useCallback(()=>{let $=0;for(let B=0;B<t.length;B+=1)if(t[B].hasClickOnce)$+=1,x($);else for(let X=0;X<t[B].correctTexts.length;X+=1)$+=1,x($)},[t]);return React$2.useEffect(()=>{var $;if(t!=null&&t[p]&&u({...t[p].info,description:a}),($=t[p])!=null&&$.text){const B=HTMLReactParser$1(t[p].text);D.current=U(B),I()}else D.current=""},[p,a,I,t,U,u]),React$2.useEffect(()=>{l($=>{o({type:"hidePuzzleButtons",payload:!0}),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),$()},2e3)})},[l,o,t,p]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:`text-click text-click--${r}`,style:(h.show,c!=null&&c.url?{backgroundImage:`url("${c.url}")`}:{}),children:[jsxRuntimeExports.jsx("div",{className:"text-click__overlay",children:jsxRuntimeExports.jsx("div",{className:`text-click__container ${P?"slideInLeft":""} `,children:jsxRuntimeExports.jsx("div",{className:"text-click__body",children:jsxRuntimeExports.jsx("div",{className:"text-click__scroll",dir:LangIsRtl()?"rtl":"auto",children:D.current})})})}),e&&jsxRuntimeExports.jsxs("div",{className:"text-click__paginator",children:[jsxRuntimeExports.jsx("div",{className:"text-click__icon-check-circle-black",children:jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black"})}),jsxRuntimeExports.jsxs("span",{className:"text-click__slide",children:[C," / ",g]})]})]}),h.show&&jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:E,success:h.result,text:h.text,translate:k,functionOnClose:W,hasTimeout:h.timeout,keyboardControl:f})]})}function ZoomTest({targetId:o,emitEvent:e}){const[r,t]=React$2.useState(!1),n=fiber.useThree(c=>c.camera),a=React$2.useRef(!1),u=React$2.useRef(null),l=({scene:c,camera:h},y)=>{const E=c.getObjectByName(o);if(E){const p=E.getObjectByName("Head_M"),_=p.getWorldPosition(new three.Vector3);h.position.distanceTo(new three.Vector3)<=5?f({scene:c,camera:h}):(p.attach(h),h.position.lerp(new three.Vector3,y*.5),h.lookAt(_))}else a.current=!1},f=({camera:c})=>{a.current=!1,c.parent=null,c.copy(u.current),e({type:"success"})};return React$2.useEffect(()=>{r||(a.current=!0,u.current=n.clone(),t(!0))},[n,r]),fiber.useFrame((c,h)=>{a.current&&l(c,h)}),null}function _assertThisInitialized(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function _inheritsLoose(o,e){o.prototype=Object.create(e.prototype),o.prototype.constructor=o,o.__proto__=e}/*!
|
|
254
254
|
* GSAP 3.12.4
|
|
255
255
|
* https://gsap.com
|
|
@@ -52780,7 +52780,7 @@ const POPUPS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
52780
52780
|
};
|
|
52781
52781
|
function PopupComponent({ type: o, close: e, translate: r, soundActions: t, ...n }) {
|
|
52782
52782
|
const a = POPUPS[o];
|
|
52783
|
-
return a ? /* @__PURE__ */ jsxRuntimeExports.jsx(a, { type: o, ...n, closingAction: e, translate: r, soundActions: t }) : null;
|
|
52783
|
+
return a ? /* @__PURE__ */ jsxRuntimeExports.jsx(a, { type: o, ...n.props, closingAction: e, translate: r, soundActions: t }) : null;
|
|
52784
52784
|
}
|
|
52785
52785
|
function DisplayingFeedback({ feed: o, resolved: e, translate: r, onNext: t }) {
|
|
52786
52786
|
return o === "success" ? /* @__PURE__ */ jsxRuntimeExports.jsx(FeedbackResult, { success: !0, showButton: !e, onNext: t, translate: r }) : o === "failed" ? /* @__PURE__ */ jsxRuntimeExports.jsx(FeedbackResult, { onNext: t, translate: r }) : null;
|