@gamelearn/arcade-components 3.12.1 → 3.12.2

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 l=a.slice(0,2)==="on",u=r[a]!==e[a];if(l&&u){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,v={},E=!1;const g={};for(var a in e)if(!propsToSkip[a]){var l=a.slice(0,2)==="on",_=r[a]!==e[a];if(l&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(g[f]=e[a])}!l&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,v[a]=e[a])}E&&(o.setAttrs(v),updatePicture(o));for(var f in g)o.on(f+EVENTS_NAMESPACE,g[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 l in e){var u=l.slice(0,2)==="on";u?a[l]=e[l]:n[l]=e[l]}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 l=a.memoizedState;for(;l;){if(l.memoizedState===e)return!0;l=l.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(),l=u=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(u):f.current=u)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),l(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(l(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{l(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=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[l]=React$2.useState(()=>document.createElement("div")),u=React$2.useMemo(()=>client.createRoot(l),[l]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),l.style.position="absolute",l.style.zIndex="10",l.style.top="0px",l.style.left="0px",l.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,l.style.transformOrigin="top left"}else l.style.position="",l.style.zIndex="",l.style.top="",l.style.left="",l.style.transform="",l.style.transformOrigin="";const h=r||{},{style:v}=h,E=__rest(h,["style"]);Object.assign(l.style,v),Object.assign(l,E)});return React$2.useLayoutEffect(()=>{var h;const v=a.current;if(!v)return;const E=(h=v.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(l),f&&needForceStyle(E)&&(E.style.position="relative"),v.on("absoluteTransformChange",c),c(),()=>{var g;v.off("absoluteTransformChange",c),(g=l.parentNode)===null||g===void 0||g.removeChild(l)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{u.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{u.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:l,onClickOutside:u}){const f=React$2.useRef(),[c,h]=React$2.useState(),v=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",g=DeviceDetection(),_=()=>{var S,A,C;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)"),(C=f.current)==null||C.to({duration:.25,opacity:1}))},p=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,C;a&&!e&&(t?(C=f.current)==null||C.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?u(o):l(o),(S=f.current)==null||S.setAttr("fill",v),(A=f.current)==null||A.setAttr("stroke",E))},T=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:p,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:T,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":v,stroke:e||r?E:"",strokeWidth:g?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:l,clickedZones:u}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),[p,x]=React$2.useState(new window.Image),[T,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 C=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{p.src=r,p.addEventListener("load",()=>{if(f.current){const w={x:T/2,y:R/2,width:p.width,height:p.height,offsetX:p.width/2,offsetY:p.height/2,scale:{x:Math.min(T/p.width,R/p.height),y:Math.min(T/p.width,R/p.height)}};v.current&&v.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),g.current&&g.current.setAttrs(w),f.current.batchDraw(),x(p),f.current.fire("stage-loaded")}})},[p,R,r,T]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:T,height:R,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:g,image:p})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:T,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:v,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:u.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:l,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:l,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 ge,Ee;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:l,image:u,areas:f,badAreas:c,hasClickOrder:h,timer:v,hasClickOnce:E,hasHighlights:g,hasImageReview:_,defaultCompleted:p,className:x,emitFinish:T,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:C,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[U,H]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[V,X]=React$2.useState(!0),[Q,re]=React$2.useState(!1),ne=React$2.useRef(null),ie=React$2.useRef(null),J=React$2.useRef(null),se=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),he=React$2.useRef(null),ue=React$2.useRef(null),_e=React$2.useRef(null),[Oe,Te]=React$2.useState(v),He=Le=>S?S(Le):r({type:"translate",payload:Le}),[Ge]=e,{solution:Xe}=l,pt=u.img.url||defaultImg,yt=f.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),at=c.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),ht=React$2.useCallback(()=>{if(!V){const Le=setInterval(()=>{Te(Ve=>Ve>1?Ve-1:0)},1e3);_e.current=Le}},[V]),er=React$2.useCallback((Le,Ve)=>{T?T(Le,Ve):r({type:"addPoints",payload:Le})},[r,T]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(p)},[p]);const Ot=React$2.useCallback(()=>{clearInterval(J.current)},[]),_t=React$2.useCallback(()=>{clearInterval(_e.current)},[]),kt=React$2.useCallback(Le=>{oe.current=Date.now(),se.current?(he.current=se.current-oe.current,Ot()):(he.current=oe.current-(oe.current-Le*1e3),Ot())},[Ot]),Ft=React$2.useCallback(()=>{I(()=>{var Le,Ve;return{show:!0,success:!1,text:(Le=l==null?void 0:l.timerFeedback)!=null&&Le.desc?l.timerFeedback.desc:"",rewards:(Ve=l==null?void 0:l.timerFeedback)==null?void 0:Ve.rewards}}),re(!0),_t(),Ot()},[_t,Ot,(ge=l.timerFeedback)==null?void 0:ge.desc,(Ee=l.timerFeedback)==null?void 0:Ee.rewards]),Ke=React$2.useCallback(()=>{clearInterval(J.current),J.current=setInterval(()=>{ie.current=Date.now(),ie.current>se.current&&Ft()},250)},[Ft]);React$2.useEffect(()=>{var Le;if((f.length===U.length||E&&U.length>0)&&!W){Z(!0);const Ve=U[U.length-1],De=A==null?void 0:A.correctFeedbacks.find(ze=>ze.id===Ve.id);(!((Le=A==null?void 0:A.correctFeedbacks)!=null&&Le.length)||A!=null&&A.correctFeedbacks.some(ze=>!ze.desc)||E)&&(I(ze=>({...ze,show:!0,success:!0,text:De?De.desc:l.solution.right.desc,rewards:De?De.rewards:l.solution.right.rewards})),v&&(_t(),kt()))}},[U,f.length,A,E,W,l.solution.right,kt,v,_t]),React$2.useEffect(()=>{a(Le=>{v&&(_t(),X(!1),G.show?I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]})):Ot()),Z(!0),B(!0),setTimeout(()=>{R?R(Le):Le()},4e3)})},[a,R,Ge,v,G.show,Ot,_t]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const mt=(Le,Ve=!1)=>{var De,ze;if(!W){const{rewards:jt,desc:Mt}=Xe.wrong;let dt=Mt,vr=jt;const Wr=(De=A==null?void 0:A.wrongFeedbacks)==null?void 0:De.find(pn=>pn.id===Le.id);Wr&&(dt=Wr.desc,vr=Wr.rewards),h&&(H([]),Ve&&(ze=l==null?void 0:l.orderFeedback)!=null&&ze.desc&&(dt=l.orderFeedback.desc,vr=l.orderFeedback.rewards)),v&&(_t(),kt()),I(pn=>({...pn,show:!0,success:!1,text:dt,rewards:vr})),Ge("fail")}},ct=React$2.useCallback(()=>{fe.current=Date.now();const Le=fe.current+he.current;ie.current=null,se.current=Le,(v||Q)&&(G.success?f.length===U.length||E&&U.length>0?_t():(Te(he.current*.001),ht(),Ke()):(H([]),X(!0),w())),er(G.rewards,G.success),Ge("click-ui"),I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]}))},[v,Q,er,G.rewards,G.success,Ge,f.length,U.length,E,w,_t,ht,Ke]),ye=Le=>{var Ve,De;if(!U.some(ze=>ze.index===Le.index)&&!G.show&&!W){Ge("click-ui");let ze=Xe.right.desc,{rewards:jt}=Xe.right;const Mt=[...U,Le];if(h&&Le.index===U.length||!h){if(v&&kt(Oe),t(),(Ve=A==null?void 0:A.correctFeedbacks)!=null&&Ve.length){const dt=(De=A.correctFeedbacks)==null?void 0:De.find(vr=>vr.id===Le.id);dt&&(ze=dt.desc,jt=dt.rewards),!ze&&f.length>Mt.length&&!E?er(jt,!0):ze&&!E&&(I(vr=>({...vr,show:!0,success:!0,text:ze,rewards:jt})),v&&_t())}H(Mt)}else mt(Le,!0)}},de=React$2.useCallback(()=>{_t(),Te(v),ht(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),se.current=ne.current+v*1e3,Ke()},[_t,v,ht,P,Ke,k]);return React$2.useEffect(()=>{v&&C>0&&!ue.current&&(P&&Object.keys(O).length&&O[C-1]?(X(!0),ue.current=!0):X(!1))},[p,P,O,C,v]),React$2.useEffect(()=>{v&&Oe===0&&Ft()},[Oe,Ft,v]),React$2.useEffect(()=>{v&&(D?(_t(),kt()):ht())},[_t,Ke,D,kt,ht,v]),jsxRuntimeExports.jsxs("div",{className:x,children:[G.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ge,text:G.text,success:G.success,translate:He,hasTimeout:!G.text,delay:v?1e3:2e3,functionOnClose:ct,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&U.length?[U[0]]:yt,badAreas:at,clickedZones:U,onClick:ye,onClickOutside:mt,hasHighlights:g,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,v&&V?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[C-1],translate:He,onInit:de}):null,v?jsxRuntimeExports.jsx(CountDown,{time:Oe}):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 l of e.toLowerCase()){const u=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[u][f].value=l,n.push({char:l,position:[u,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let l=0;l<r;l+=1)switch(t.reduce((f,c)=>{const h=[a,l],v=getDistance(c.position,h);return v<f?v:f},9999)){case 0:n[a][l].hiddenColor=GREEN;break;case 1:n[a][l].hiddenColor=ORANGE;break;case 2:n[a][l].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,l]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,l)},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 l=0;l<e;l+=1){const u={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(u)}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),[l,u]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(l,e,o,u)};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:l,setResolveAction:u}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),v=React$2.useRef(),{solution:E}=r,[g,_]=React$2.useState(n.toLowerCase()),[p,x]=React$2.useState(),[T,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[C,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:U,visibleColumns:H}=DIFFICULTY_MAP[l];let W=U==="auto"?Math.ceil(window.innerHeight*.025):U;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{u(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[u,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,re)=>({char:Q,index:re,used:!1})),B=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),G=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(v.current!==void 0){const Q=X-v.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(G),I=0)}v.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:H,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const V=()=>{if(D.length<=1)return;const[X,Q]=C,re=D[X][Q];if(re.hiddenColor===GREEN){const ne=p.filter(ie=>ie.char===re.value.toLowerCase()&&ie.used===!1)[0];if(ne){const{index:ie}=ne;f("score");const J=p;J[ie].used=!0,x(J);const se=[...T];se[ie]=re.value;const oe=B(J);_(oe);const fe=repaintGridPassword(D,oe,W,H);F(fe),R(se)}}g<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||V()},[C]),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:T.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:C,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(l=>{n[a]||(n[a]=[]),n[a]=[...n[a],l],l.char===" "&&(a+=1),t||(l.positionInitial=l.index)}),n.map((l,u)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${u}`,children:r?l.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):l.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${l[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${l+u}`))},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:l,hintUsed:u,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[v]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[g,_]=React$2.useState(0),[p,x]=React$2.useState(!1),[T,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[C,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,U]=React$2.useState([]),[H,W]=React$2.useState(!1),Z=l.toUpperCase().split(""),q=Z.filter(he=>restrictCharacters(he,"and")),B=he=>e({type:"translate",payload:he}),G=React$2.useCallback(()=>{const he=q.map(Oe=>({char:Oe}));let ue=[];const _e=analyzeChars(q);for(;ue.length<MAX_EXTRA_LETTERS;){const Oe=makeChar(_e);ue=[...ue,{char:Oe}]}return[...he,...ue]},[q]),I=l.toUpperCase().split("").map((he,ue)=>restrictCharacters(he,"or")?{index:ue,letter:he,char:he,fixed:!0}:{index:ue,letter:he,char:""}),$=React$2.useCallback(()=>{let he=G();for(;he.length>MAX_POOL_LETTERS;){const ue=Math.trunc(Math.random()*(he.length-1))+1,_e=he[ue],Oe=I.find((Te,He)=>_e.char===Te.letter&&!I[He].fixed);Oe&&(he.splice(ue,1),I[Oe.index]={...Oe,char:Oe.letter,fixed:!0})}u&&(he=[],I.forEach(({letter:ue})=>{ue!==" "&&he.push({char:ue})})),w(I),R(he)},[I,u,G]),V=(he,ue)=>T.map((Oe,Te)=>Te===ue?{...Oe,deleted:!0}:{...Oe}),X=(he,ue,_e)=>{const Oe=ue.map((He,Ge)=>_e.find(pt=>pt.poolIndex===Ge)?{char:He.char}:He);R(Oe),w(he);const Te=he.find(He=>He.char==="");_(Te.index)},Q=(he,ue)=>{v("click-ui");let _e=!1;const Oe=C.map(Ge=>!Ge.char&&!_e?(_e=!0,{...Ge,char:he,poolIndex:ue}):Ge),Te=V(he,ue),He=Oe.filter(Ge=>Ge.char).length;R(Te),w(Oe),re(),He===C.length&&se(Oe,Te)},re=()=>{var he;if(p){const ue=C.find(_e=>_e.index!==g&&_e.letter!==" "&&_e.char===""&&_e.poolIndex===!1);ue&&_(ue.index)}else{const ue=C.find(_e=>_e.char==="");_(ue.index+1),((he=C[ue.index+1])==null?void 0:he.letter)===" "&&_(ue.index+2)}},ne=()=>{v("click-ui");const he=C.map((ue,_e)=>C[C.length-1-_e]).find(ue=>ue.char&&!ue.fixed);if(he){const ue=C.map(Te=>Te.index===he.index?{...he,char:""}:Te);let _e=!1;const Oe=T.map((Te,He)=>He===he.poolIndex&&(Te.deleted||!_e)?(_e=!0,{char:Te.char}):Te);R(Oe),w(ue),_(he.index)}},ie=()=>{r(!0),O("");const he=[...F,...a.solution.right.rewards];v("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:he}),e({type:"passPuzzle"})},J=()=>{v("fail"),e({type:"hidePuzzleButtons",payload:!1}),U([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},se=(he,ue)=>{let _e=[];D(!0);const Oe=he.map((He,Ge)=>Z[Ge]===He.char?{...He,fixed:!0}:(_e=[..._e,He],{...He,poolIndex:!1,char:""})),Te=Oe.filter(He=>He.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Te===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{ie()},2e3)):(O("failed"),X(Oe,ue,_e),a.solution.wrong.desc===""&&setTimeout(()=>{J()},2e3))},oe=()=>{if(P==="success")ie();else{J();const he=C.find(ue=>ue.char==="");_(he.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(he=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),he()},2e3)}),c(he=>{const ue=[];I.forEach(({letter:_e})=>{_e!==" "&&ue.push({char:_e})}),R(ue),he()})},[$,S,l,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:v,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:B,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:H?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,answer:l.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,flickerPosition:g,answer:C})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[T.sort((he,ue)=>sortChar(he,ue)).map((he,ue)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${he.char}`,type:"button",onClick:()=>{!he.deleted&&!P&&!k&&(Q(he.char,ue),v("click-ui"))},className:`puzzle--hanged__keyboard--item ${he.deleted||k?"disabled":""}`,children:he.char},`${he+ue}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":B("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:l,soundActions:u,setSelected:f,selected:c,pause:h,loadPuzzleStatus:v,index:E,setIndex:g,slidesCompleted:_,setSlidesCompleted:p,keyboardControl:x,totalCorrects:T}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),C=`chained-image-click-puzzle_${E}_${r}`,[w]=u,P=B=>{R.current=[...R.current,...B]},O=React$2.useCallback(B=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...B]}),n({type:"passPuzzle"})},[w,n]),[k,D]=React$2.useState(!1),F=o[E],{info:U,specificFeedbacks:H}=F;U.description=e,React$2.useEffect(()=>{S.current=0,A.current=0,D(!1)},[E]);const W=React$2.useCallback((B,G=!1)=>{var $;let I={..._};if(G){if(($=H==null?void 0:H.correctFeedbacks)!=null&&$.length&&!F.hasClickOnce){const V=H.correctFeedbacks.length;k&&V?(S.current>0?f(c+(V-S.current)):f(c+V),S.current=V):S.current+=1}else{let V=c;A.current&&(V-=A.current),S.current=F.areas.length,f(V+S.current)}S.current===F.areas.length&&(E+1>=o.length?O(B):g(E+1),I={...I,[E]:!0},p(I)),P(B)}else n({type:"addPoints",payload:B,finish:!1}),n({type:"failPuzzle"}),F.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&F.hasClickOrder&&!c&&f(0)},[_,H,F.hasClickOnce,F.areas.length,F.hasClickOrder,c,f,E,o.length,p,O,g,n]),Z=()=>{D(!0),E>=o.length-1&&f(T),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...U,hintId:C})},[U,C,t]),React$2.useEffect(()=>{v&&E!==o.length-1&&W([],!0)},[E,o.length,v,W]);const q=()=>{const B=F.hasClickOnce?F.areas.length:1;A.current+=B,f(c+B)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...F,puzzle:{name:C,component:"chained-image-click-puzzle"},specificFeedbacks:H,emitFinish:W,emitError:P,emitResolve:Z,isLast:E+1===o.length,defaultCompleted:_[E]||!!v,hideContinue:E+1!==o.length,handleClick:q,emitEvent:n,disableExit:a,soundActions:u,setResolveAction:l,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:l,showFrames:u,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[v,E]=React$2.useState(0),[g,_]=React$2.useState(0),[p,x]=React$2.useState({}),T=`chained-image-click-puzzle_${g}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:T}),[r,T]),S=n.reduce((C,w)=>C+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:l,setInfo:e,setSelected:E,selected:v,index:g,setIndex:_,slidesCompleted:p,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[u?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[v," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:l,setFramesCompleted:u,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:v,description:E,translateFromParent:g,setInfo:_,emitEvent:p,nodeId:x,setSelected:T,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:C,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:U}){var ie;const[H]=c,[W,Z]=React$2.useState(!1),q=o[e],{info:B,specificFeedbacks:G}=q;B.description=E;const I=React$2.useRef(0),$=React$2.useRef(0),V=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...B,hintId:V})},[_,B,V]),React$2.useEffect(()=>{O&&($.current=0,I.current=0,T(0),k(!1))},[O,k,T]),React$2.useEffect(()=>{$.current=0,I.current=0,Z(!1)},[e]);const X=React$2.useCallback((J,se=!1)=>{var fe;let oe={...t};if(se){if((fe=G==null?void 0:G.correctFeedbacks)!=null&&fe.length&&!q.hasClickOnce){const he=G.correctFeedbacks.length;W&&he?($.current>0?T(R+(he-$.current)):T(R+he),$.current=he):$.current+=1}else{let he=R;I.current&&(he-=I.current),$.current=q.areas.length,w[0]&&Object.entries(t).length===0?T($.current):T(he+$.current)}$.current===q.areas.length&&(e+1>=o.length&&n(J),oe={...oe,[e]:!0},u(oe),l(e+1>o.length-1?0:e+1)),a(J)}else p({type:"addPoints",payload:J,finish:!1}),p({type:"failPuzzle"}),q.hasClickOrder&&(T(R-$.current),$.current=0)},[t,(ie=G==null?void 0:G.correctFeedbacks)==null?void 0:ie.length,q.hasClickOnce,q.areas.length,q.hasClickOrder,a,R,w,T,e,o.length,u,l,n,p]),Q=React$2.useCallback(()=>{Z(!0),e>=o.length-1&&T(U),H("score"),p({type:"hidePuzzleButtons",payload:!1}),C(J=>({...J,[e]:!0})),p({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:B.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,H,p,C,V,B.resolve.rewards,T,U]),re=React$2.useCallback(()=>{u({}),$.current=0,I.current=0,S()},[S,u]);React$2.useEffect(()=>{f&&e!==o.length-1&&X([],!0)},[t,e,o.length,f,X]);const ne=()=>{const J=q.hasClickOnce?q.areas.length:1;I.current+=J,T(R+J)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...q,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:G,emitFinish:X,emitResolve:Q,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:v,translateFromParent:g,emitEvent:p,slideNumber:e,handleClick:ne,emitResetPuzzle:re,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:l,setResolveAction:u,setInfo:f,pause:c,keyboardControl:h}){const[v,E]=React$2.useState({}),g=React$2.useRef([]),[_,p]=React$2.useState(0),[x,T]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[C,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((V,X)=>V+X.areas.length,0),U=V=>{g.current=[...g.current,...V]},H=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:H}),[o,H]),Z=React$2.useCallback(V=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...g.current,...V]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),g.current=[],S(0),p(0),T({}),w(!0),D(!0)},[]),B=V=>o({type:"translate",payload:V}),G=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:U,accRewards:g,setSelected:S,selected:R,setIndex:p,setFramesCompleted:T,loadPuzzleStatus:W,soundActions:a,setResolveAction:u,disableExit:l,translateFromParent:B,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:v,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:C,"aria-hidden":C,type:"button",className:"puzzle-frame__info",onClick:G,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!C,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:l=>t({logo:l})})})]}),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:l=>t({color:l})})})]})]})}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 l=o?e.header.userImage:r.userImage,u=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+l})`},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(u||"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 l=o?e.body.work:r.work,u=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 ${l||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(l||"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 ${u||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(u||"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 l=o?e.body.bgImage:r.bgImage,u=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+l})`},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:`${u}`},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,[l,u]=React$2.useState(),f=l===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 ${l===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>u(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(l)},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,[l,u]=React$2.useState(),f=!l;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:()=>u(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(l.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,[l,u]=React$2.useState(""),f=l==="",[c,h]=React$2.useState(!1),v=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:v,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:l,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(g=>g instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:[jsxRuntimeExports.jsx("span",{children:t(g.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(g.desc)})]},g.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:t(g)},g))})]})]})})}),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(l)},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:l}){const[u,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(!1),[g,_]=React$2.useState(!1),[p,x]=React$2.useState(!1),[T,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[C,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,U=re=>r({type:"translate",payload:re}),H=()=>{w({type:"",props:{}})},W=(re,ne={})=>{w({type:re,props:ne})},Z=()=>{if(e.solution){const{rewards:re}=e.solution.right,{rewards:ne}=e.solution.wrong;F(v?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:v?ne:re}),r({type:"passPuzzle"})}},q=l({disabled:T!=="success",forward:Z,escape:Z});React$2.useEffect(()=>q(),[q]);const B=(re,ne)=>{const ie=Object.keys(re),J={existing:0,equal:0};return ie.forEach(se=>{ne[se]!==null&&ne[se]!==""&&(J.existing+=1),re[se]===ne[se]&&(J.equal+=1)}),J},G=(re,ne)=>{const ie=Object.keys(A.header).length,J=Object.keys(A.body).length,se=B(A.header,re),oe=B(A.body,ne),fe=oe.existing+se.existing===ie+J,he=oe.equal+se.equal===ie+J;return{exist:fe,equal:he}},I=()=>{F("click-ui");const{exist:re,equal:ne}=G(P,k);r({type:"hidePuzzleButtons",payload:!0}),re&&!ne?(p&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):re&&ne&&(p&&(a(!1),x(!1)),_(!0),R("success"))},$=re=>{if(Object.keys(re).length>0){const ne={...P,...re};O(ne),H();const{exist:ie}=G(ne,k);x(!!ie)}},V=re=>{if(Object.keys(re).length>0){const ne={...k,...re};D(ne),H();const{exist:ie}=G(P,ne);x(!!ie)}};React$2.useEffect(()=>{t(re=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),re()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const X={showingReference:u||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:U},Q=()=>{T==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):T==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:C.type,...C,close:H,soundActions:n,translate:U}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:u,displayButton:!c&&!g,translate:U,clickAction:()=>{F("click-ui"),f(!u)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...X,header:P,onSave:$}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...X,header:P,onSave:$}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...X,body:k,onSave:V})]}),!p&&!u?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:T,onNext:Q,resolved:c,translate:U}):null,p&&!u?jsxRuntimeExports.jsx(PublishButton,{onPublish:I,translate:U}):null]})}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),l=()=>{const _=(o.img||{}).url;return jsxRuntimeExports.jsx("img",{src:_,alt:""})},u=()=>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,v=()=>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?v():!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:[l(),u(),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:l,onFinish:u,handleSuccess:f,resolveWithAnyCard:c}){const[h,v]=React$2.useState(Array(o.length).fill(!1)),[E,g]=React$2.useState(Array(o.length).fill(!1)),[_,p]=React$2.useState(0),[x,T]=React$2.useState(!1),[R]=l,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,C=React$2.useCallback(()=>{v(Array(o.length).fill(!1)),g(Array(o.length).fill(!1)),p(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{C()},1e3)};function P(F){const U=Array.from(h);U[F]=F,v(U)}const O=React$2.useCallback(()=>{const F=[];o.forEach((U,H)=>{U.correct===!0&&F.push(H)}),v(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(u(),T(!0),p(0))},[_,u,S,c]);const k=F=>{P(F),f(o[F].id||null),p(_+1)},D=F=>{var U,H;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,g(W),t(((U=o[F])==null?void 0:U.id)||null,o[F].correct),w()}P(F)}else t(((H=o[F])==null?void 0:H.id)||null),w(),P(F)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,U)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(U),flipped:h.includes(U),wrongOrder:E.includes(U),cardIndex:U},`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:l,soundActions:u,backgroundImage:f,nodeId:c,keyboardControl:h,hideBackgroundImageTheme:v=!1}){var Q,re;const[E,g]=React$2.useState(!1),[_,p]=React$2.useState(1),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(!1),[w,P]=React$2.useState([]),[O,k]=React$2.useState(!1),[D,F]=React$2.useState(""),[U]=u,H=ne=>o({type:"translate",payload:ne}),W=`cards-selector-puzzle_${c}`,Z=React$2.useCallback(ne=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:ne}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{var se,oe;o({type:"hidePuzzleButtons",payload:!0}),T(!0);const{rewards:ne}=((se=e==null?void 0:e.solution)==null?void 0:se.right)||{},ie=((oe=n==null?void 0:n.correctFeedbacks)==null?void 0:oe.map(fe=>fe.rewards).flat())||[],J=[...w,...ne,...ie];U("score"),Z(J)},[w,Z,o,(Q=e==null?void 0:e.solution)==null?void 0:Q.right,U,n==null?void 0:n.correctFeedbacks]),B=()=>{g(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&F(e.solution.right.desc),C(!0)},G=()=>{x||E?q():(T(!1),a(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1})),F("")},I=ne=>{if(S(!0),n!=null&&n.specificCorrectFeedbacks){const ie=n.correctFeedbacks.find(J=>J.id===ne);ie!=null&&ie.desc&&(F(ie.desc),C(!0))}U("score"),o({type:"hidePuzzleButtons",payload:!0})},$=(ne,ie=!1)=>{var J,se;if(S(!1),ie)F((J=e.orderFeedback)==null?void 0:J.desc),C(!0),P([...w,...((se=e.orderFeedback)==null?void 0:se.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const oe=n.wrongFeedbacks.find(fe=>fe.id===ne);oe!=null&&oe.desc?(F(oe.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),P([...w,...(oe==null?void 0:oe.rewards)||[]])}else e.solution.wrong.desc?(F(e.solution.wrong.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!ie&&P([...w,...e.solution.wrong.rewards]),U("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};React$2.useEffect(()=>{E&&a(!0)},[a,E]),React$2.useEffect(()=>{l(()=>{var ie;o({type:"hidePuzzleButtons",payload:!0}),k(!0);const ne=[...w,...((ie=e==null?void 0:e.resolve)==null?void 0:ie.rewards)||{}];setTimeout(()=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:W,rewards:ne,finish:!0}})},2e3)})},[l,a,w,(re=e==null?void 0:e.resolve)==null?void 0:re.rewards,o,W]);const V=React$2.useMemo(()=>{let ne="";return ne="cards-selector",f!=null&&f.url&&(ne+=" cards-selector--with-custom-bg"),v&&(ne+=" disable-background-image"),ne},[f==null?void 0:f.url,v]),X={backgroundImage:f!=null&&f.url?`url('${f.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:V,style:X,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:p,currentOrder:_,cards:r,onFinish:B,resolveWithAnyCard:t,handleError:$,feedbackIsShown:A,resolvePuzzle:O,soundActions:u,handleSuccess:I})}),A&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:x||R,text:D,hasTimeout:!D,translate:H,functionOnClose:G,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:l}){const[u,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[v,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const g=T=>{if(!T||!T.length)return"";const R=T.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const T=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const C=[...S];if(g(S[A]).length!==0){const w=S[A];return C[A]=`<span class="lastWord" >${w}</span>`,C}return R(S,A-1)};a==="election"?h(T()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},p=t.split("<p>");p.shift();const x=p.length>1;return u&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:l,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&v&&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[l]=a,u=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{l("click-ui"),r(t)},h=E=>{E.keyCode===13&&v(E)},v=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:u(o)})}),jsxRuntimeExports.jsx("div",{onClick:v,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(l=>!!l.fullText).length}`,children:o&&o.map((l,u)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:l,soundActions:t,index:u,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},u))})}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:l,skip:u,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:v}){const[E]=v,g=p=>o({type:"translate",payload:p}),_=()=>{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:g("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(p=>n[p.currenTextParagraph].electionTexts[p.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[p.currenTextParagraph].electionTexts[p.index]},p.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:g("puzzles.skip")}),l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:g(f()?"puzzles.continue":"puzzles.retry")}),!l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:g("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:l,setResolveAction:u,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:v,backgroundImage:E,hideBackgroundImageTheme:g=!1}){const _=Ke=>o({type:"translate",payload:Ke}),p=React$2.useRef(),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(0),[w,P]=React$2.useState({[`text_${A}`]:{...h[A],id:`text_${A}`,correct:""}}),[O,k]=React$2.useState(!1),[D,F]=React$2.useState([]),[U,H]=React$2.useState(!1),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState(!0),[$,V]=React$2.useState([]),[X,Q]=React$2.useState(!0),[re]=v,ne=React$2.useRef({}),ie=Ke=>{let mt;return Ke.electionTexts.forEach((ct,ye)=>{ct.correct&&(mt=ye)}),mt},J=React$2.useCallback(Ke=>D.filter(ct=>ct.currenTextParagraph===Ke)[0].fullText_labelId,[D]),se=React$2.useCallback(()=>h.map((Ke,mt)=>{if(Ke.type==="fixed")return Ke.fullText_labelId??Ke.fullText;if(Ke.type==="election"){const ct=ie(Ke);return ct>=0?Ke.electionTexts[ct].fullText_labelId:J(mt)}return""}),[J,h]),oe=12,fe=()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="none"&&(mt+=1);return mt===Ke}return!0},he=React$2.useCallback(()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="green"&&(mt+=1);return mt===Ke}return!0},[D]),ue=()=>!!(D&&D.length),_e=()=>D.find(Ke=>{const{feedback:mt}=h[Ke.currenTextParagraph].electionTexts[Ke.index];return mt.body!==""}),Oe=React$2.useCallback(()=>{const Ke=se();o({type:"finishMedia",payload:{name:c,text:Ke,documentType:a,type:"text"}})},[se,c,o,a]),Te=React$2.useCallback(Ke=>{const mt=he();re(R?"fail":mt?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ke||$,onFinish:a!=="view"?Oe:null}),o({type:"passPuzzle"})},[he,o,R,Oe,re,$,a]);React$2.useEffect(()=>{x&&Q(!1),u(()=>{Te(l.resolve.rewards)})},[o,Te,x,Oe,l.resolve.rewards,u,a]);const He=()=>{T(!1),C(0),F([]),V([]),S(!1),B(!1),k(!1),Z(!1),H(!1),P({text_0:{...h[0],id:"text_0",correct:""}}),I(!0),o({type:"addPoints",complex:!0,finish:!1,payload:$}),o({type:"failPuzzle"})},Ge=()=>{ue()?fe()&&(H(!0),Te()):(H(!0),B(!0),Te()),U?(I(!1),q&&!W?Z(!0):(W||!q&&!W)&&(!q&&!W&&t?he()?Te():He():Te())):(H(!0),_e()&&B(!0))},Xe=()=>{const Ke=h[A].electionTexts.filter(ct=>ct.correct).length,mt=h[A].electionTexts;return Ke===0||Ke===mt},pt=Ke=>{const mt=h[A].electionTexts[Ke],ct=mt.feedback.rewards;ct&&ct[0]&&ct[0].points&&(ne.current[`t${A}_e${Ke}`]||(mt.correct&&(ne.current[`t${A}_e${Ke}`]=!0),V([...$,...ct])));const ye=()=>Xe()?"none":mt.correct?"green":"red",de={currenTextParagraph:A,fullText:mt.fullText,index:Ke,isCorrect:ye()};P({...w,[`text_${A}`]:{type:"fixed",fullText:mt.fullText,correct:de.isCorrect}}),F([...D,de])},yt=()=>{p.current.scrollTop=p.current.scrollHeight+100},at=()=>{if(p.current.querySelector(".wrapfixed").offsetHeight>p.current.offsetHeight){const Ke=p.current.querySelector(".wrapfixed").offsetHeight;p.current.scrollTo({top:Ke,behavior:"smooth"})}},ht=(Ke,mt,ct)=>{const ye=Ke.fullText,de=h[ct+1]?h[ct+1].type:"",ge=w[`text_${ct+1}`]&&w[`text_${ct+1}`].type?w[`text_${ct+1}`].type:de;return jsxRuntimeExports.jsx(FixedComponent,{length:mt,doneTyping:O,index:ct,delay:oe,setDoneTyping:k,nextParagraphType:ge,isWriting:at,textToPrint:ye},ct.toString())},er=(Ke,mt)=>{const ct=Ke.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:ct,correct:Ke.correct},mt)},Ot=Ke=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:v,textWithOpts:Ke.electionTexts,setCurrentDecisionSelected:pt,printed:yt,disableExit:X},Ke.electionTexts),_t=(Ke,mt,ct)=>Ke.type==="fixed"?ht(Ke,mt,ct):Ot(Ke);React$2.useEffect(()=>{O===!0&&(()=>{h[A+1]?(P({...w,[`text_${A+1}`]:{...h[A+1],id:`text_${A+1}`,correct:""}}),C(A+1),k(!1)):T(!0)})()},[O,A,w,h]);const kt=React$2.useMemo(()=>{let Ke=`writer-puzzle writer-puzzle--${e}`;return g&&(Ke+=" disable-background-image"),Ke},[g,e]),Ft={backgroundImage:E!=null&&E.url?`url('${E.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:kt,style:Ft,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[W&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>S(!0),decisionsList:D,closingAction:Ge,retry:t,skip:n,checkCorrect:he,retryAction:He,rewardsStack:$,nodeId:r,soundActions:v}),!W&&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:p,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:G&&!U&&Object.values(w).map((Ke,mt)=>_t(Ke,Object.values(w).length-1,mt))}),U&&Object.values(w).map((Ke,mt)=>er(Ke,mt))]})}),x&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Ge,children:_("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:l,soundActions:u,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[v]=u,E={image:{component:Image$1,props:{...o,url:h,soundActions:u}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:u,translate:l}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:u}},pdf:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const g=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),T=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:v,shortText:!0,success:c===T,text:c===T?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===T?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:l,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(g,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===T&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:l("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,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${l}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+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,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+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:l,setResolveAction:u,nodeId:f,keyboardControl:c}){const[h,v]=React$2.useState({}),[E]=React$2.useState(!1),[g,_]=React$2.useState([]),p=React$2.useRef([]),[x]=l,T=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"),v(k),_([...g,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[g,a,o,x]);React$2.useEffect(()=>{v(S),_([S])},[S]),React$2.useEffect(()=>{u(()=>{p.current=[...p.current,...n.resolve.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,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}})})},[u,n.resolve.rewards,o,R]);const C=()=>{p.current=[...p.current,...n.solution.wrong.rewards];const k=g.length-1,D=g.filter((F,U)=>k>U);v(g[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=g[0];v(k),_([k])},P=()=>{p.current=[...p.current,...n.solution.right.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,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:C,initFile:S,selectItem:A,breadcrumb:g,closeFolder:w,file:h,translate:T})]}):jsxRuntimeExports.jsx(Visor,{soundActions:l,backFile:C,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:T,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:l,emitEvent:u,soundActions:f,keyboardControl:c}){const{solution:h}=t,v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),p=React$2.useRef({}),[x,T]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(),[w]=React$2.useState(new window.Image),P=React$2.useRef([]),[O]=f,k=X=>u({type:"translate",payload:X});React$2.useEffect(()=>{l(x!=="")},[x,l]);const D=(X,Q)=>(X.x+X.width>Q.x&&X.x+X.width<=Q.x+Q.width||Q.x+Q.width>X.x&&Q.x+Q.width<=X.x+X.width)&&(X.y+X.height>Q.y&&X.y+X.height<=Q.y+Q.height||Q.y+Q.height>X.y&&Q.y+Q.height<=X.y+X.height),F=()=>{v&&n&&(v.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},U=()=>{v&&n&&(v.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},H=React$2.useCallback(X=>{let Q=!1;if(X){const re=g.current;re.setPointersPositions(X);const ne=re.getPointerPosition(),ie=v.current.getClientRect({relativeTo:re});Q=D({...ne,width:1,height:1},ie)}return Q},[]),W=React$2.useCallback(X=>X&&r.uid===JSON.parse(X).uid,[r.uid]),Z=React$2.useCallback(()=>{T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"addPoints",complex:!0,finish:!0,payload:P.current}),u({type:"passPuzzle"}),a&&u({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),u({type:"closeUI",ui:"inventory"})},[a,u,r.name,r.uid]),q=React$2.useCallback(()=>{T("success"),u({type:"hidePuzzleButtons",payload:!0}),P.current=[...P.current,...h.right.rewards],setTimeout(()=>{Z()},2e3)},[u,Z,h.right.rewards]),B=React$2.useCallback(()=>{u({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"failPuzzle"}),P.current=[...P.current,...h.wrong.rewards]},[u,h.wrong.rewards]),G=React$2.useCallback(X=>{const Q=X.dataTransfer.getData("item");g.current.setPointersPositions(X);const re=H(X);u({type:"hidePuzzleButtons",payload:!0}),re&&W(Q)?(T("success"),u({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&q()):(u({type:"closeUI",ui:"inventory"}),T("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{B()},2e3))},[H,W,u,q,B,t.solution.right.desc,t.solution.wrong.desc]),I=()=>{x==="success"?q():B()};React$2.useEffect(()=>{const X=e.img.url||"";w.src=X,w.onload=()=>{_.current&&(p.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:w.width,height:w.height,offsetX:w.width/2,offsetY:w.height/2,scale:{x:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height),y:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height)}},S(!0))}},[w,e.img.url]);const $=X=>{X!==null&&(v.current=X)},V=X=>{if(X!==null&&(E.current=X,v.current)){const{x:Q,y:re,width:ne,height:ie}=v.current.getClientRect();X.setAttr("x",Q),X.setAttr("y",re),X.setAttr("height",ie),X.setAttr("width",ne)}};return React$2.useLayoutEffect(()=>{if(v.current&&R){const X=v.current.getClientRect({relativeTo:v.current.getParent()});C({x:X.x+X.width/2,y:X.y+X.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:G,onDragOver:X=>{X.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:g,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:w,...p.current}),jsxRuntimeExports.jsxs(Group,{...p.current,children:[A?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...A},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:F,onMouseLeave:U,ref:$,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:F,onMouseLeave:U,ref:V,text:k("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:k,playSound:O,functionOnClose:I,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:l}){const[u,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let T=!1;return n[r.id].find(R=>R.id===x)&&(T=!0),T},v=x=>{let T="";return u?(e&&h(x.id)&&(T="selected"),o&&h(x.id)&&a.includes(x.id)&&(T="success"),o&&h(x.id)&&!a.includes(x.id)&&(T="failed")):(e&&x.id===n[r.id][0].id&&(T="selected"),o&&x.id===n[r.id][0].id&&(T=n[r.id][0].isCorrect?"success":"failed")),T},E=x=>{const T=v(x);return T==="selected"?"icon-check-circle-black color--selected":T==="success"?"icon-check-circle-black color--success":T==="failed"?"icon-error-circle-black color--error":""},g=x=>o&&x.feedback&&(u&&h(x.id)||x.id===n[r.id][0].id),_=(x,T)=>T===0?"tooltip--right__top":T===x.length-1?"tooltip--right__bottom":"tooltip--center__right",p=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{p.length===1?f(!1):f(!0)},[p.length,u,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),u&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:l("tests.chooseMoreOneAnswer")}):null,c.map((x,T)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[u?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,T,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!v(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,T,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${v(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[T]}),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 ${g(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${v(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${T}`,className:`tooltip ${_(c,T)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:l("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=u=>e.includes(u),a=(u,f)=>u.index<f.index?-1:u.index>f.index?1:0,l=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),l.map(u=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(u.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[u.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:u.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(u.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[u.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:u.feedback})]})]},u.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:l,showResults:u,answered:f,answerPage:c,updateForm:h,disabled:v,translate:E,soundActions:g,paused:_,view:p,correctQuestions:x,feedbacksOnlyWhenReview:T}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[C,w]=React$2.useState(),P=o[S].id,[O]=g;React$2.useEffect(()=>{if(l>=0&&!v&&!_){const q=setInterval(()=>{C||e(B=>B-1)},1e3);return r(q),()=>{clearInterval(q)}}},[v,C,_,r,e,l]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!v&&!T?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)):u()},U=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!v&&!T?w(!0):u()},H=Math.floor(l/60),W=l%60;React$2.useEffect(()=>{if(p==="review"){const q=t[`q${S}`][0].id,B=document.querySelector(`#${q}`);R.scrollTo(0,B.offsetTop)}},[S,R,t,p]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,B=t[P],G=B.find($=>$.isCorrect===!1);let I=0;return B.forEach($=>{q.includes($.id)&&(I+=1)}),!G&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[p==="review"||C?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:C?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]})}),p!=="review"&&l>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${l<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[H<10?`0${H}`:H," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:v,answered:f,updateForm:h,question:o[S],correctQuestions:v?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${p==="review"?"reviewmode":"next"}`,children:[p==="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,!C&&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,C?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,!C&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&U()},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:l,restartTest:u,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:v}){const[E,g]=React$2.useState(0),[_,p]=React$2.useState(),[x,T]=React$2.useState([]),[R,S]=React$2.useState([]),[A,C]=React$2.useState([]),w=React$2.useCallback(()=>{const B=[];return t.forEach(G=>B.push(G.answers)),B},[t]),P=React$2.useCallback(()=>{const B=[];return Object.values(o).forEach(G=>{if(G.length>1){const I=G.find(V=>V.isCorrect===!1),$=[];I?B.push([]):(G.forEach(V=>{V.isCorrect&&$.push(V.id)}),B.push($))}else G[0].isCorrect?B.push([G[0].id]):G[0].isCorrect===!1&&B.push("")}),B},[o]),O=React$2.useCallback(()=>{let B=0;return R.length>0&&x.forEach((G,I)=>{G.length>1?G.every($=>R[I].includes($))&&(B+=1):G.length===1&&R[I]&&G[0]===R[I][0]&&(B+=1)}),B},[x,R]);React$2.useEffect(()=>{T(w),S(P),C(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<v,U=A>=v,H=!r||U,W=Math.trunc(E/k*100),Z=(B,G)=>h({type:"translate",payload:B,values:G}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const B=setInterval(()=>{g(G=>G+1)},100);return p(B),()=>{clearInterval(B)}}},[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&&U||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:v})})]}),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")})}),H?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),H?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>l(),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:l,minimumPercentage:u=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,v]=React$2.useState({}),[E,g]=React$2.useState(),[_,p]=React$2.useState(0),[x,T]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,C]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[U,H]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,B=React$2.useRef({}),[G,I]=React$2.useState(),[$,V]=t,X=(se,oe,fe,he,ue)=>{const _e={...se,index:fe};if(_>0&&(_e.rewards=_e.rewards.filter(Te=>!U[se.id]||Te.points<0)),h[oe]){const Te=h[oe].find(He=>He.id===ue);if(Te){if(Te.id===se.id){const He=h[oe].find(Xe=>Xe.id===ue),Ge=h[oe].indexOf(He);if(h[oe].splice(Ge,1),h[oe].length===0){C(!1);return}}}else h[oe].push(_e)}else h[oe]=[_e];let Oe;he==="isRadio"?Oe={...h,[oe]:[_e]}:Oe={...h},v(Oe),F(Oe),H({...U,[se.id]:{...se}}),C(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(se=>{const oe=se.answers.filter(he=>he.isCorrect),fe=[];return oe.forEach(he=>{fe.push(he.id)}),{question:se.id,answers:fe}});React$2.useEffect(()=>{T(Q)},[Q]),React$2.useEffect(()=>{if(u){const se=Math.ceil(c.length*u/100);I(se)}},[c.length,u]),React$2.useEffect(()=>{R===0&&(clearInterval(E),C(!1),Z(!0),P("results"),V("tts"))},[E,V,R]);const re=()=>{clearInterval(E),C(!1),P("results");const se={...D};F(se),V("tts")},ne=()=>{const se={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(he=>{B.current[he.id]&&(he.rewards=[])})}),r({type:"saveTest",payload:se})},ie=()=>{const se=()=>{F({}),H({}),P("test"),v({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(he=>{he.forEach(ue=>{ue.isCorrect&&(B.current[ue.id]?ue.rewards=[]:B.current[ue.id]=!0)})});let fe=oe.reduce((he,ue)=>{const _e=[];return ue.forEach(Oe=>{_e.push(Oe.rewards)}),[...he,..._e.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:se}),r({type:"failTest"})},J=(se,oe)=>r({type:"translate",payload:se,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:p,tries:_,answerPage:C,setTime:S,paused:l,saveInterval:g,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:re,translate:J,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:ie,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:G})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((l,u)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--response__item ${e[r]===l?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[u]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${l}`)})]},l))})}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=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(l=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--points__item survey--points__item--colorized ${e[r]===l?"selected":""}`,children:l},l))}),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),[l,u]=React$2.useState(!1),[f]=e,c=(E,g)=>o({type:"translate",payload:E,values:g}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)u(!0);else{E&&u(!1);const g=E?n-1:n+1;a(g)}},v=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(v,{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"})}),l&&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,!l&&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,C,w;const[a,l]=React$2.useState(null),[u,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(0),[g,_]=React$2.useState({current:{questions:[],type:r}}),[p]=n,x=P=>t({type:"translate",payload:P}),T=P=>{P.keyCode===13&&P.target.blur()},R=()=>{p("click-ui"),t({type:"saveSurveyPrePos",payload:g.current})};React$2.useEffect(()=>{!e.length&&u==="questions"&&f("end")},[e,u]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=g.current.questions.find(F=>F.id===e[v].id))==null?void 0:D.answer;if(p("click-ui"),O)E(v-1),h(!1);else{const F=g.current.questions.findIndex(H=>H.id===e[v].id),U=[...g.current.questions];F>-1?U.splice(F,1,{id:e[v].id,answer:k}):U.push({id:e[v].id,answer:k}),_({...g,current:{...g.current,questions:U}}),v===e.length-1?h(!0):(E(v+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:[u==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),p("click-ui")},translate:x}),u==="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")," ",v+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[v])==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:()=>{l(O)},onTouchEnd:()=>{l(null)},onKeyUp:D=>{T(D)},onClick:()=>{S(O,!1)},className:`survey--points__item survey--points__item--simple ${((k=g.current.questions[v])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[v]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:v===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${v===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"),p("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 l=a.slice(0,2)==="on",u=r[a]!==e[a];if(l&&u){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,v={},E=!1;const g={};for(var a in e)if(!propsToSkip[a]){var l=a.slice(0,2)==="on",_=r[a]!==e[a];if(l&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(g[f]=e[a])}!l&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,v[a]=e[a])}E&&(o.setAttrs(v),updatePicture(o));for(var f in g)o.on(f+EVENTS_NAMESPACE,g[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 l in e){var u=l.slice(0,2)==="on";u?a[l]=e[l]:n[l]=e[l]}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 l=a.memoizedState;for(;l;){if(l.memoizedState===e)return!0;l=l.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(),l=u=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(u):f.current=u)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),l(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(l(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{l(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=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[l]=React$2.useState(()=>document.createElement("div")),u=React$2.useMemo(()=>client.createRoot(l),[l]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),l.style.position="absolute",l.style.zIndex="10",l.style.top="0px",l.style.left="0px",l.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,l.style.transformOrigin="top left"}else l.style.position="",l.style.zIndex="",l.style.top="",l.style.left="",l.style.transform="",l.style.transformOrigin="";const h=r||{},{style:v}=h,E=__rest(h,["style"]);Object.assign(l.style,v),Object.assign(l,E)});return React$2.useLayoutEffect(()=>{var h;const v=a.current;if(!v)return;const E=(h=v.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(l),f&&needForceStyle(E)&&(E.style.position="relative"),v.on("absoluteTransformChange",c),c(),()=>{var g;v.off("absoluteTransformChange",c),(g=l.parentNode)===null||g===void 0||g.removeChild(l)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{u.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{u.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:l,onClickOutside:u}){const f=React$2.useRef(),[c,h]=React$2.useState(),v=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",g=DeviceDetection(),_=()=>{var S,A,C;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)"),(C=f.current)==null||C.to({duration:.25,opacity:1}))},p=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,C;a&&!e&&(t?(C=f.current)==null||C.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?u(o):l(o),(S=f.current)==null||S.setAttr("fill",v),(A=f.current)==null||A.setAttr("stroke",E))},T=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:p,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:T,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":v,stroke:e||r?E:"",strokeWidth:g?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:l,clickedZones:u}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),[p,x]=React$2.useState(new window.Image),[T,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 C=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{p.src=r,p.addEventListener("load",()=>{if(f.current){const w={x:T/2,y:R/2,width:p.width,height:p.height,offsetX:p.width/2,offsetY:p.height/2,scale:{x:Math.min(T/p.width,R/p.height),y:Math.min(T/p.width,R/p.height)}};v.current&&v.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),g.current&&g.current.setAttrs(w),f.current.batchDraw(),x(p),f.current.fire("stage-loaded")}})},[p,R,r,T]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:T,height:R,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:g,image:p})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:T,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:v,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:l,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:u.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:l,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:l,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 ge,Ee;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:l,image:u,areas:f,badAreas:c,hasClickOrder:h,timer:v,hasClickOnce:E,hasHighlights:g,hasImageReview:_,defaultCompleted:p,className:x,emitFinish:T,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:C,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[U,H]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[V,X]=React$2.useState(!0),[Q,re]=React$2.useState(!1),ne=React$2.useRef(null),ie=React$2.useRef(null),J=React$2.useRef(null),se=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),he=React$2.useRef(null),ue=React$2.useRef(null),_e=React$2.useRef(null),[Oe,Te]=React$2.useState(v),He=Le=>S?S(Le):r({type:"translate",payload:Le}),[Ge]=e,{solution:Xe}=l,pt=u.img.url||defaultImg,yt=f.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),at=c.map((Le,Ve)=>({index:Ve,shape:"poly",...Le})),ht=React$2.useCallback(()=>{if(!V){const Le=setInterval(()=>{Te(Ve=>Ve>1?Ve-1:0)},1e3);_e.current=Le}},[V]),er=React$2.useCallback((Le,Ve)=>{T?T(Le,Ve):r({type:"addPoints",payload:Le})},[r,T]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(p)},[p]);const Ot=React$2.useCallback(()=>{clearInterval(J.current)},[]),_t=React$2.useCallback(()=>{clearInterval(_e.current)},[]),kt=React$2.useCallback(Le=>{oe.current=Date.now(),se.current?(he.current=se.current-oe.current,Ot()):(he.current=oe.current-(oe.current-Le*1e3),Ot())},[Ot]),Ft=React$2.useCallback(()=>{I(()=>{var Le,Ve;return{show:!0,success:!1,text:(Le=l==null?void 0:l.timerFeedback)!=null&&Le.desc?l.timerFeedback.desc:"",rewards:(Ve=l==null?void 0:l.timerFeedback)==null?void 0:Ve.rewards}}),re(!0),_t(),Ot()},[_t,Ot,(ge=l.timerFeedback)==null?void 0:ge.desc,(Ee=l.timerFeedback)==null?void 0:Ee.rewards]),Ke=React$2.useCallback(()=>{clearInterval(J.current),J.current=setInterval(()=>{ie.current=Date.now(),ie.current>se.current&&Ft()},250)},[Ft]);React$2.useEffect(()=>{var Le;if((f.length===U.length||E&&U.length>0)&&!W){Z(!0);const Ve=U[U.length-1],De=A==null?void 0:A.correctFeedbacks.find(ze=>ze.id===Ve.id);(!((Le=A==null?void 0:A.correctFeedbacks)!=null&&Le.length)||A!=null&&A.correctFeedbacks.some(ze=>!ze.desc)||E)&&(I(ze=>({...ze,show:!0,success:!0,text:De?De.desc:l.solution.right.desc,rewards:De?De.rewards:l.solution.right.rewards})),v&&(_t(),kt()))}},[U,f.length,A,E,W,l.solution.right,kt,v,_t]),React$2.useEffect(()=>{a(Le=>{v&&(_t(),X(!1),G.show?I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]})):Ot()),Z(!0),B(!0),setTimeout(()=>{R?R(Le):Le()},4e3)})},[a,R,Ge,v,G.show,Ot,_t]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const mt=(Le,Ve=!1)=>{var De,ze;if(!W){const{rewards:jt,desc:Mt}=Xe.wrong;let dt=Mt,vr=jt;const Wr=(De=A==null?void 0:A.wrongFeedbacks)==null?void 0:De.find(pn=>pn.id===Le.id);Wr&&(dt=Wr.desc,vr=Wr.rewards),h&&(H([]),Ve&&(ze=l==null?void 0:l.orderFeedback)!=null&&ze.desc&&(dt=l.orderFeedback.desc,vr=l.orderFeedback.rewards)),v&&(_t(),kt()),I(pn=>({...pn,show:!0,success:!1,text:dt,rewards:vr})),Ge("fail")}},ct=React$2.useCallback(()=>{fe.current=Date.now();const Le=fe.current+he.current;ie.current=null,se.current=Le,(v||Q)&&(G.success?f.length===U.length||E&&U.length>0?_t():(Te(he.current*.001),ht(),Ke()):(H([]),X(!0),w())),er(G.rewards,G.success),Ge("click-ui"),I(Ve=>({...Ve,show:!1,success:!1,text:"",rewards:[]}))},[v,Q,er,G.rewards,G.success,Ge,f.length,U.length,E,w,_t,ht,Ke]),ye=Le=>{var Ve,De;if(!U.some(ze=>ze.index===Le.index)&&!G.show&&!W){Ge("click-ui");let ze=Xe.right.desc,{rewards:jt}=Xe.right;const Mt=[...U,Le];if(h&&Le.index===U.length||!h){if(v&&kt(Oe),t(),(Ve=A==null?void 0:A.correctFeedbacks)!=null&&Ve.length){const dt=(De=A.correctFeedbacks)==null?void 0:De.find(vr=>vr.id===Le.id);dt&&(ze=dt.desc,jt=dt.rewards),!ze&&f.length>Mt.length&&!E?er(jt,!0):ze&&!E&&(I(vr=>({...vr,show:!0,success:!0,text:ze,rewards:jt})),v&&_t())}H(Mt)}else mt(Le,!0)}},de=React$2.useCallback(()=>{_t(),Te(v),ht(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),se.current=ne.current+v*1e3,Ke()},[_t,v,ht,P,Ke,k]);return React$2.useEffect(()=>{v&&C>0&&!ue.current&&(P&&Object.keys(O).length&&O[C-1]?(X(!0),ue.current=!0):X(!1))},[p,P,O,C,v]),React$2.useEffect(()=>{v&&Oe===0&&Ft()},[Oe,Ft,v]),React$2.useEffect(()=>{v&&(D?(_t(),kt()):ht())},[_t,Ke,D,kt,ht,v]),jsxRuntimeExports.jsxs("div",{className:x,children:[G.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ge,text:G.text,success:G.success,translate:He,hasTimeout:!G.text,delay:v?1e3:2e3,functionOnClose:ct,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&U.length?[U[0]]:yt,badAreas:at,clickedZones:U,onClick:ye,onClickOutside:mt,hasHighlights:g,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,v&&V?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[C-1],translate:He,onInit:de}):null,v?jsxRuntimeExports.jsx(CountDown,{time:Oe}):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 l of e.toLowerCase()){const u=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[u][f].value=l,n.push({char:l,position:[u,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let l=0;l<r;l+=1)switch(t.reduce((f,c)=>{const h=[a,l],v=getDistance(c.position,h);return v<f?v:f},9999)){case 0:n[a][l].hiddenColor=GREEN;break;case 1:n[a][l].hiddenColor=ORANGE;break;case 2:n[a][l].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,l]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,l)},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 l=0;l<e;l+=1){const u={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(u)}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),[l,u]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(l,e,o,u)};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:l,setResolveAction:u}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),v=React$2.useRef(),{solution:E}=r,[g,_]=React$2.useState(n.toLowerCase()),[p,x]=React$2.useState(),[T,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[C,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:U,visibleColumns:H}=DIFFICULTY_MAP[l];let W=U==="auto"?Math.ceil(window.innerHeight*.025):U;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{u(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[u,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,re)=>({char:Q,index:re,used:!1})),B=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),G=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(v.current!==void 0){const Q=X-v.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(G),I=0)}v.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:H,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const V=()=>{if(D.length<=1)return;const[X,Q]=C,re=D[X][Q];if(re.hiddenColor===GREEN){const ne=p.filter(ie=>ie.char===re.value.toLowerCase()&&ie.used===!1)[0];if(ne){const{index:ie}=ne;f("score");const J=p;J[ie].used=!0,x(J);const se=[...T];se[ie]=re.value;const oe=B(J);_(oe);const fe=repaintGridPassword(D,oe,W,H);F(fe),R(se)}}g<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||V()},[C]),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:T.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:C,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(l=>{n[a]||(n[a]=[]),n[a]=[...n[a],l],l.char===" "&&(a+=1),t||(l.positionInitial=l.index)}),n.map((l,u)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${u}`,children:r?l.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):l.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${l[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${l+u}`))},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:l,hintUsed:u,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[v]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[g,_]=React$2.useState(0),[p,x]=React$2.useState(!1),[T,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[C,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,U]=React$2.useState([]),[H,W]=React$2.useState(!1),Z=l.toUpperCase().split(""),q=Z.filter(he=>restrictCharacters(he,"and")),B=he=>e({type:"translate",payload:he}),G=React$2.useCallback(()=>{const he=q.map(Oe=>({char:Oe}));let ue=[];const _e=analyzeChars(q);for(;ue.length<MAX_EXTRA_LETTERS;){const Oe=makeChar(_e);ue=[...ue,{char:Oe}]}return[...he,...ue]},[q]),I=l.toUpperCase().split("").map((he,ue)=>restrictCharacters(he,"or")?{index:ue,letter:he,char:he,fixed:!0}:{index:ue,letter:he,char:""}),$=React$2.useCallback(()=>{let he=G();for(;he.length>MAX_POOL_LETTERS;){const ue=Math.trunc(Math.random()*(he.length-1))+1,_e=he[ue],Oe=I.find((Te,He)=>_e.char===Te.letter&&!I[He].fixed);Oe&&(he.splice(ue,1),I[Oe.index]={...Oe,char:Oe.letter,fixed:!0})}u&&(he=[],I.forEach(({letter:ue})=>{ue!==" "&&he.push({char:ue})})),w(I),R(he)},[I,u,G]),V=(he,ue)=>T.map((Oe,Te)=>Te===ue?{...Oe,deleted:!0}:{...Oe}),X=(he,ue,_e)=>{const Oe=ue.map((He,Ge)=>_e.find(pt=>pt.poolIndex===Ge)?{char:He.char}:He);R(Oe),w(he);const Te=he.find(He=>He.char==="");_(Te.index)},Q=(he,ue)=>{v("click-ui");let _e=!1;const Oe=C.map(Ge=>!Ge.char&&!_e?(_e=!0,{...Ge,char:he,poolIndex:ue}):Ge),Te=V(he,ue),He=Oe.filter(Ge=>Ge.char).length;R(Te),w(Oe),re(),He===C.length&&se(Oe,Te)},re=()=>{var he;if(p){const ue=C.find(_e=>_e.index!==g&&_e.letter!==" "&&_e.char===""&&_e.poolIndex===!1);ue&&_(ue.index)}else{const ue=C.find(_e=>_e.char==="");_(ue.index+1),((he=C[ue.index+1])==null?void 0:he.letter)===" "&&_(ue.index+2)}},ne=()=>{v("click-ui");const he=C.map((ue,_e)=>C[C.length-1-_e]).find(ue=>ue.char&&!ue.fixed);if(he){const ue=C.map(Te=>Te.index===he.index?{...he,char:""}:Te);let _e=!1;const Oe=T.map((Te,He)=>He===he.poolIndex&&(Te.deleted||!_e)?(_e=!0,{char:Te.char}):Te);R(Oe),w(ue),_(he.index)}},ie=()=>{r(!0),O("");const he=[...F,...a.solution.right.rewards];v("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:he}),e({type:"passPuzzle"})},J=()=>{v("fail"),e({type:"hidePuzzleButtons",payload:!1}),U([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},se=(he,ue)=>{let _e=[];D(!0);const Oe=he.map((He,Ge)=>Z[Ge]===He.char?{...He,fixed:!0}:(_e=[..._e,He],{...He,poolIndex:!1,char:""})),Te=Oe.filter(He=>He.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Te===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{ie()},2e3)):(O("failed"),X(Oe,ue,_e),a.solution.wrong.desc===""&&setTimeout(()=>{J()},2e3))},oe=()=>{if(P==="success")ie();else{J();const he=C.find(ue=>ue.char==="");_(he.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(he=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),he()},2e3)}),c(he=>{const ue=[];I.forEach(({letter:_e})=>{_e!==" "&&ue.push({char:_e})}),R(ue),he()})},[$,S,l,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:v,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:B,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:H?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,answer:l.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:H,flickerPosition:g,answer:C})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[T.sort((he,ue)=>sortChar(he,ue)).map((he,ue)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${he.char}`,type:"button",onClick:()=>{!he.deleted&&!P&&!k&&(Q(he.char,ue),v("click-ui"))},className:`puzzle--hanged__keyboard--item ${he.deleted||k?"disabled":""}`,children:he.char},`${he+ue}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":B("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:l,soundActions:u,setSelected:f,selected:c,pause:h,loadPuzzleStatus:v,index:E,setIndex:g,slidesCompleted:_,setSlidesCompleted:p,keyboardControl:x,totalCorrects:T}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),C=`chained-image-click-puzzle_${E}_${r}`,[w]=u,P=B=>{R.current=[...R.current,...B]},O=React$2.useCallback(B=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...B]}),n({type:"passPuzzle"})},[w,n]),[k,D]=React$2.useState(!1),F=o[E],{info:U,specificFeedbacks:H}=F;U.description=e,React$2.useEffect(()=>{S.current=0,A.current=0,D(!1)},[E]);const W=React$2.useCallback((B,G=!1)=>{var $;let I={..._};if(G){if(($=H==null?void 0:H.correctFeedbacks)!=null&&$.length&&!F.hasClickOnce){const V=H.correctFeedbacks.length;k&&V?(S.current>0?f(c+(V-S.current)):f(c+V),S.current=V):S.current+=1}else{let V=c;A.current&&(V-=A.current),S.current=F.areas.length,f(V+S.current)}S.current===F.areas.length&&(E+1>=o.length?O(B):g(E+1),I={...I,[E]:!0},p(I)),P(B)}else n({type:"addPoints",payload:B,finish:!1}),n({type:"failPuzzle"}),F.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&F.hasClickOrder&&!c&&f(0)},[_,H,F.hasClickOnce,F.areas.length,F.hasClickOrder,c,f,E,o.length,p,O,g,n]),Z=()=>{D(!0),E>=o.length-1&&f(T),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...U,hintId:C})},[U,C,t]),React$2.useEffect(()=>{v&&E!==o.length-1&&W([],!0)},[E,o.length,v,W]);const q=()=>{const B=F.hasClickOnce?F.areas.length:1;A.current+=B,f(c+B)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...F,puzzle:{name:C,component:"chained-image-click-puzzle"},specificFeedbacks:H,emitFinish:W,emitError:P,emitResolve:Z,isLast:E+1===o.length,defaultCompleted:_[E]||!!v,hideContinue:E+1!==o.length,handleClick:q,emitEvent:n,disableExit:a,soundActions:u,setResolveAction:l,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:l,showFrames:u,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[v,E]=React$2.useState(0),[g,_]=React$2.useState(0),[p,x]=React$2.useState({}),T=`chained-image-click-puzzle_${g}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:T}),[r,T]),S=n.reduce((C,w)=>C+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:l,setInfo:e,setSelected:E,selected:v,index:g,setIndex:_,slidesCompleted:p,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[u?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[v," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:l,setFramesCompleted:u,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:v,description:E,translateFromParent:g,setInfo:_,emitEvent:p,nodeId:x,setSelected:T,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:C,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:U}){var ie;const[H]=c,[W,Z]=React$2.useState(!1),q=o[e],{info:B,specificFeedbacks:G}=q;B.description=E;const I=React$2.useRef(0),$=React$2.useRef(0),V=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...B,hintId:V})},[_,B,V]),React$2.useEffect(()=>{O&&($.current=0,I.current=0,T(0),k(!1))},[O,k,T]),React$2.useEffect(()=>{$.current=0,I.current=0,Z(!1)},[e]);const X=React$2.useCallback((J,se=!1)=>{var fe;let oe={...t};if(se){if((fe=G==null?void 0:G.correctFeedbacks)!=null&&fe.length&&!q.hasClickOnce){const he=G.correctFeedbacks.length;W&&he?($.current>0?T(R+(he-$.current)):T(R+he),$.current=he):$.current+=1}else{let he=R;I.current&&(he-=I.current),$.current=q.areas.length,w[0]&&Object.entries(t).length===0?T($.current):T(he+$.current)}$.current===q.areas.length&&(e+1>=o.length&&n(J),oe={...oe,[e]:!0},u(oe),l(e+1>o.length-1?0:e+1)),a(J)}else p({type:"addPoints",payload:J,finish:!1}),p({type:"failPuzzle"}),q.hasClickOrder&&(T(R-$.current),$.current=0)},[t,(ie=G==null?void 0:G.correctFeedbacks)==null?void 0:ie.length,q.hasClickOnce,q.areas.length,q.hasClickOrder,a,R,w,T,e,o.length,u,l,n,p]),Q=React$2.useCallback(()=>{Z(!0),e>=o.length-1&&T(U),H("score"),p({type:"hidePuzzleButtons",payload:!1}),C(J=>({...J,[e]:!0})),p({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:B.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,H,p,C,V,B.resolve.rewards,T,U]),re=React$2.useCallback(()=>{u({}),$.current=0,I.current=0,S()},[S,u]);React$2.useEffect(()=>{f&&e!==o.length-1&&X([],!0)},[t,e,o.length,f,X]);const ne=()=>{const J=q.hasClickOnce?q.areas.length:1;I.current+=J,T(R+J)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...q,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:G,emitFinish:X,emitResolve:Q,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:v,translateFromParent:g,emitEvent:p,slideNumber:e,handleClick:ne,emitResetPuzzle:re,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:l,setResolveAction:u,setInfo:f,pause:c,keyboardControl:h}){const[v,E]=React$2.useState({}),g=React$2.useRef([]),[_,p]=React$2.useState(0),[x,T]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[C,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((V,X)=>V+X.areas.length,0),U=V=>{g.current=[...g.current,...V]},H=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:H}),[o,H]),Z=React$2.useCallback(V=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...g.current,...V]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),g.current=[],S(0),p(0),T({}),w(!0),D(!0)},[]),B=V=>o({type:"translate",payload:V}),G=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:U,accRewards:g,setSelected:S,selected:R,setIndex:p,setFramesCompleted:T,loadPuzzleStatus:W,soundActions:a,setResolveAction:u,disableExit:l,translateFromParent:B,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:v,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:C,"aria-hidden":C,type:"button",className:"puzzle-frame__info",onClick:G,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!C,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:l=>t({logo:l})})})]}),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:l=>t({color:l})})})]})]})}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 l=o?e.header.userImage:r.userImage,u=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+l})`},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(u||"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 l=o?e.body.work:r.work,u=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 ${l||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(l||"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 ${u||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(u||"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 l=o?e.body.bgImage:r.bgImage,u=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+l})`},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:`${u}`},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,[l,u]=React$2.useState(),f=l===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 ${l===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>u(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(l)},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,[l,u]=React$2.useState(),f=!l;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:()=>u(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(l.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,[l,u]=React$2.useState(""),f=l==="",[c,h]=React$2.useState(!1),v=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:v,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:l,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(g=>g instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:[jsxRuntimeExports.jsx("span",{children:t(g.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(g.desc)})]},g.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{u(g)},children:t(g)},g))})]})]})})}),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(l)},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:l}){const[u,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(!1),[g,_]=React$2.useState(!1),[p,x]=React$2.useState(!1),[T,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[C,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,U=re=>r({type:"translate",payload:re}),H=()=>{w({type:"",props:{}})},W=(re,ne={})=>{w({type:re,props:ne})},Z=()=>{if(e.solution){const{rewards:re}=e.solution.right,{rewards:ne}=e.solution.wrong;F(v?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:v?ne:re}),r({type:"passPuzzle"})}},q=l({disabled:T!=="success",forward:Z,escape:Z});React$2.useEffect(()=>q(),[q]);const B=(re,ne)=>{const ie=Object.keys(re),J={existing:0,equal:0};return ie.forEach(se=>{ne[se]!==null&&ne[se]!==""&&(J.existing+=1),re[se]===ne[se]&&(J.equal+=1)}),J},G=(re,ne)=>{const ie=Object.keys(A.header).length,J=Object.keys(A.body).length,se=B(A.header,re),oe=B(A.body,ne),fe=oe.existing+se.existing===ie+J,he=oe.equal+se.equal===ie+J;return{exist:fe,equal:he}},I=()=>{F("click-ui");const{exist:re,equal:ne}=G(P,k);r({type:"hidePuzzleButtons",payload:!0}),re&&!ne?(p&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):re&&ne&&(p&&(a(!1),x(!1)),_(!0),R("success"))},$=re=>{if(Object.keys(re).length>0){const ne={...P,...re};O(ne),H();const{exist:ie}=G(ne,k);x(!!ie)}},V=re=>{if(Object.keys(re).length>0){const ne={...k,...re};D(ne),H();const{exist:ie}=G(P,ne);x(!!ie)}};React$2.useEffect(()=>{t(re=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),re()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const X={showingReference:u||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:U},Q=()=>{T==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):T==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:C.type,...C,close:H,soundActions:n,translate:U}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:u,displayButton:!c&&!g,translate:U,clickAction:()=>{F("click-ui"),f(!u)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...X,header:P,onSave:$}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...X,header:P,onSave:$}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...X,body:k,onSave:V})]}),!p&&!u?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:T,onNext:Q,resolved:c,translate:U}):null,p&&!u?jsxRuntimeExports.jsx(PublishButton,{onPublish:I,translate:U}):null]})}function CardImage({img:o}){const r=(o||{}).url;return jsxRuntimeExports.jsx("img",{src:r,alt:""})}function CardText({text:o,hasImage:e}){return o?jsxRuntimeExports.jsx("div",{className:`card-selector-item__textbox ${e?"":"card-selector-item__textbox--noimage"}`,children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__text",children:jsxRuntimeExports.jsx("span",{children:o||"_"})})}):null}function CardNumber({order:o}){return o?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:o})}):null}function CardSuccess({order:o}){return jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[jsxRuntimeExports.jsx(CardNumber,{order:o}),jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black"})})]})}function CardFail(){return 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"})})})}function CardContainer({flipped:o,correct:e,order:r,wrongOrder:t,isEmpty:n}){return!n&&o&&e&&!t?jsxRuntimeExports.jsx(CardSuccess,{order:r}):!n&&o?jsxRuntimeExports.jsx(CardFail,{}):null}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),l=()=>!!(r&&!o.correct||!r);return jsxRuntimeExports.jsxs("button",{type:"button",order:o.order,onClick:()=>{!a()&&l()&&e(t)},className:`unset-button card-selector-item ${a()?"card-selector-item--empty":""}`,"aria-label":o.text?o.text:null,children:[jsxRuntimeExports.jsx(CardImage,{img:o.img}),jsxRuntimeExports.jsx(CardText,{text:o.text,hasImage:!!o.img}),jsxRuntimeExports.jsx(CardContainer,{isEmpty:a(),flipped:r,wrongOrder:n,order:o.order,correct:o.correct})]})}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:l,onFinish:u,handleSuccess:f,resolveWithAnyCard:c}){const[h,v]=React$2.useState(Array(o.length).fill(!1)),[E,g]=React$2.useState(Array(o.length).fill(!1)),[_,p]=React$2.useState(0),[x,T]=React$2.useState(!1),[R]=l,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,C=React$2.useCallback(()=>{v(Array(o.length).fill(!1)),g(Array(o.length).fill(!1)),p(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{C()},1e3)};function P(F,U=F){const H=Array.from(h);H[F]=U,v(H)}const O=React$2.useCallback(()=>{const F=[];o.forEach((U,H)=>{U.correct===!0&&F.push(H)}),v(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(u(),T(!0),p(0))},[_,u,S,c]);const k=F=>{P(F),f(o[F].id||null),p(_+1)},D=F=>{var U,H;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(P(F),o[F].order!==e){const W=Array.from(E);W[F]=F,g(W),t(((U=o[F])==null?void 0:U.id)||null,o[F].correct),w()}}else t(((H=o[F])==null?void 0:H.id)||null),P(F),setTimeout(()=>{P(F,!1)},1e3)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,U)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(U),flipped:h.includes(U),wrongOrder:E.includes(U),cardIndex:U},`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:l,soundActions:u,backgroundImage:f,nodeId:c,keyboardControl:h,hideBackgroundImageTheme:v=!1}){var Q,re;const[E,g]=React$2.useState(!1),[_,p]=React$2.useState(1),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(!1),[w,P]=React$2.useState([]),[O,k]=React$2.useState(!1),[D,F]=React$2.useState(""),[U]=u,H=ne=>o({type:"translate",payload:ne}),W=`cards-selector-puzzle_${c}`,Z=React$2.useCallback(ne=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:ne}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{var se,oe;o({type:"hidePuzzleButtons",payload:!0}),T(!0);const{rewards:ne}=((se=e==null?void 0:e.solution)==null?void 0:se.right)||{},ie=((oe=n==null?void 0:n.correctFeedbacks)==null?void 0:oe.map(fe=>fe.rewards).flat())||[],J=[...w,...ne,...ie];U("score"),Z(J)},[w,Z,o,(Q=e==null?void 0:e.solution)==null?void 0:Q.right,U,n==null?void 0:n.correctFeedbacks]),B=()=>{g(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&F(e.solution.right.desc),C(!0)},G=()=>{x||E?q():(T(!1),a(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1})),F("")},I=ne=>{if(S(!0),n!=null&&n.specificCorrectFeedbacks){const ie=n.correctFeedbacks.find(J=>J.id===ne);ie!=null&&ie.desc&&(F(ie.desc),C(!0))}U("score"),o({type:"hidePuzzleButtons",payload:!0})},$=(ne,ie=!1)=>{var J,se;if(S(!1),ie)F((J=e.orderFeedback)==null?void 0:J.desc),C(!0),P([...w,...((se=e.orderFeedback)==null?void 0:se.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const oe=n.wrongFeedbacks.find(fe=>fe.id===ne);oe!=null&&oe.desc?(F(oe.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),P([...w,...(oe==null?void 0:oe.rewards)||[]])}else e.solution.wrong.desc?(F(e.solution.wrong.desc),C(!0)):(C(!0),setTimeout(()=>{G(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!ie&&P([...w,...e.solution.wrong.rewards]),U("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};React$2.useEffect(()=>{E&&a(!0)},[a,E]),React$2.useEffect(()=>{l(()=>{var ie;o({type:"hidePuzzleButtons",payload:!0}),k(!0);const ne=[...w,...((ie=e==null?void 0:e.resolve)==null?void 0:ie.rewards)||{}];setTimeout(()=>{T(!1),C(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:W,rewards:ne,finish:!0}})},2e3)})},[l,a,w,(re=e==null?void 0:e.resolve)==null?void 0:re.rewards,o,W]);const V=React$2.useMemo(()=>{let ne="";return ne="cards-selector",f!=null&&f.url&&(ne+=" cards-selector--with-custom-bg"),v&&(ne+=" disable-background-image"),ne},[f==null?void 0:f.url,v]),X={backgroundImage:f!=null&&f.url?`url('${f.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:V,style:X,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:p,currentOrder:_,cards:r,onFinish:B,resolveWithAnyCard:t,handleError:$,feedbackIsShown:A,resolvePuzzle:O,soundActions:u,handleSuccess:I})}),A&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:x||R,text:D,hasTimeout:!D,translate:H,functionOnClose:G,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:l}){const[u,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[v,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const g=T=>{if(!T||!T.length)return"";const R=T.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const T=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const C=[...S];if(g(S[A]).length!==0){const w=S[A];return C[A]=`<span class="lastWord" >${w}</span>`,C}return R(S,A-1)};a==="election"?h(T()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},p=t.split("<p>");p.shift();const x=p.length>1;return u&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:l,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${v?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&v&&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[l]=a,u=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{l("click-ui"),r(t)},h=E=>{E.keyCode===13&&v(E)},v=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:u(o)})}),jsxRuntimeExports.jsx("div",{onClick:v,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(l=>!!l.fullText).length}`,children:o&&o.map((l,u)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:l,soundActions:t,index:u,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},u))})}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:l,skip:u,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:v}){const[E]=v,g=p=>o({type:"translate",payload:p}),_=()=>{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:g("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(p=>n[p.currenTextParagraph].electionTexts[p.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[p.currenTextParagraph].electionTexts[p.index]},p.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:g("puzzles.skip")}),l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:g(f()?"puzzles.continue":"puzzles.retry")}),!l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:g("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:l,setResolveAction:u,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:v,backgroundImage:E,hideBackgroundImageTheme:g=!1}){const _=Ke=>o({type:"translate",payload:Ke}),p=React$2.useRef(),[x,T]=React$2.useState(!1),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(0),[w,P]=React$2.useState({[`text_${A}`]:{...h[A],id:`text_${A}`,correct:""}}),[O,k]=React$2.useState(!1),[D,F]=React$2.useState([]),[U,H]=React$2.useState(!1),[W,Z]=React$2.useState(!1),[q,B]=React$2.useState(!1),[G,I]=React$2.useState(!0),[$,V]=React$2.useState([]),[X,Q]=React$2.useState(!0),[re]=v,ne=React$2.useRef({}),ie=Ke=>{let mt;return Ke.electionTexts.forEach((ct,ye)=>{ct.correct&&(mt=ye)}),mt},J=React$2.useCallback(Ke=>D.filter(ct=>ct.currenTextParagraph===Ke)[0].fullText_labelId,[D]),se=React$2.useCallback(()=>h.map((Ke,mt)=>{if(Ke.type==="fixed")return Ke.fullText_labelId??Ke.fullText;if(Ke.type==="election"){const ct=ie(Ke);return ct>=0?Ke.electionTexts[ct].fullText_labelId:J(mt)}return""}),[J,h]),oe=12,fe=()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="none"&&(mt+=1);return mt===Ke}return!0},he=React$2.useCallback(()=>{if(D){const Ke=D.length;let mt=0;for(let ct=0;ct<Ke;ct+=1)D[ct].isCorrect==="green"&&(mt+=1);return mt===Ke}return!0},[D]),ue=()=>!!(D&&D.length),_e=()=>D.find(Ke=>{const{feedback:mt}=h[Ke.currenTextParagraph].electionTexts[Ke.index];return mt.body!==""}),Oe=React$2.useCallback(()=>{const Ke=se();o({type:"finishMedia",payload:{name:c,text:Ke,documentType:a,type:"text"}})},[se,c,o,a]),Te=React$2.useCallback(Ke=>{const mt=he();re(R?"fail":mt?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ke||$,onFinish:a!=="view"?Oe:null}),o({type:"passPuzzle"})},[he,o,R,Oe,re,$,a]);React$2.useEffect(()=>{x&&Q(!1),u(()=>{Te(l.resolve.rewards)})},[o,Te,x,Oe,l.resolve.rewards,u,a]);const He=()=>{T(!1),C(0),F([]),V([]),S(!1),B(!1),k(!1),Z(!1),H(!1),P({text_0:{...h[0],id:"text_0",correct:""}}),I(!0),o({type:"addPoints",complex:!0,finish:!1,payload:$}),o({type:"failPuzzle"})},Ge=()=>{ue()?fe()&&(H(!0),Te()):(H(!0),B(!0),Te()),U?(I(!1),q&&!W?Z(!0):(W||!q&&!W)&&(!q&&!W&&t?he()?Te():He():Te())):(H(!0),_e()&&B(!0))},Xe=()=>{const Ke=h[A].electionTexts.filter(ct=>ct.correct).length,mt=h[A].electionTexts;return Ke===0||Ke===mt},pt=Ke=>{const mt=h[A].electionTexts[Ke],ct=mt.feedback.rewards;ct&&ct[0]&&ct[0].points&&(ne.current[`t${A}_e${Ke}`]||(mt.correct&&(ne.current[`t${A}_e${Ke}`]=!0),V([...$,...ct])));const ye=()=>Xe()?"none":mt.correct?"green":"red",de={currenTextParagraph:A,fullText:mt.fullText,index:Ke,isCorrect:ye()};P({...w,[`text_${A}`]:{type:"fixed",fullText:mt.fullText,correct:de.isCorrect}}),F([...D,de])},yt=()=>{p.current.scrollTop=p.current.scrollHeight+100},at=()=>{if(p.current.querySelector(".wrapfixed").offsetHeight>p.current.offsetHeight){const Ke=p.current.querySelector(".wrapfixed").offsetHeight;p.current.scrollTo({top:Ke,behavior:"smooth"})}},ht=(Ke,mt,ct)=>{const ye=Ke.fullText,de=h[ct+1]?h[ct+1].type:"",ge=w[`text_${ct+1}`]&&w[`text_${ct+1}`].type?w[`text_${ct+1}`].type:de;return jsxRuntimeExports.jsx(FixedComponent,{length:mt,doneTyping:O,index:ct,delay:oe,setDoneTyping:k,nextParagraphType:ge,isWriting:at,textToPrint:ye},ct.toString())},er=(Ke,mt)=>{const ct=Ke.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:ct,correct:Ke.correct},mt)},Ot=Ke=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:v,textWithOpts:Ke.electionTexts,setCurrentDecisionSelected:pt,printed:yt,disableExit:X},Ke.electionTexts),_t=(Ke,mt,ct)=>Ke.type==="fixed"?ht(Ke,mt,ct):Ot(Ke);React$2.useEffect(()=>{O===!0&&(()=>{h[A+1]?(P({...w,[`text_${A+1}`]:{...h[A+1],id:`text_${A+1}`,correct:""}}),C(A+1),k(!1)):T(!0)})()},[O,A,w,h]);const kt=React$2.useMemo(()=>{let Ke=`writer-puzzle writer-puzzle--${e}`;return g&&(Ke+=" disable-background-image"),Ke},[g,e]),Ft={backgroundImage:E!=null&&E.url?`url('${E.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:kt,style:Ft,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[W&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>S(!0),decisionsList:D,closingAction:Ge,retry:t,skip:n,checkCorrect:he,retryAction:He,rewardsStack:$,nodeId:r,soundActions:v}),!W&&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:p,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:G&&!U&&Object.values(w).map((Ke,mt)=>_t(Ke,Object.values(w).length-1,mt))}),U&&Object.values(w).map((Ke,mt)=>er(Ke,mt))]})}),x&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Ge,children:_("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:l,soundActions:u,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[v]=u,E={image:{component:Image$1,props:{...o,url:h,soundActions:u}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:u,translate:l}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:u}},pdf:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:l,soundActions:u,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const g=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),T=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:v,shortText:!0,success:c===T,text:c===T?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===T?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:l,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(g,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===T&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:l("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,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${l}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+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,l)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${l+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:l,setResolveAction:u,nodeId:f,keyboardControl:c}){const[h,v]=React$2.useState({}),[E]=React$2.useState(!1),[g,_]=React$2.useState([]),p=React$2.useRef([]),[x]=l,T=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"),v(k),_([...g,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[g,a,o,x]);React$2.useEffect(()=>{v(S),_([S])},[S]),React$2.useEffect(()=>{u(()=>{p.current=[...p.current,...n.resolve.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,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}})})},[u,n.resolve.rewards,o,R]);const C=()=>{p.current=[...p.current,...n.solution.wrong.rewards];const k=g.length-1,D=g.filter((F,U)=>k>U);v(g[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=g[0];v(k),_([k])},P=()=>{p.current=[...p.current,...n.solution.right.rewards];const k=p.current.map(D=>{var q;const{name:F,points:U,type:H,id:W}=D,Z={name:F,points:U,type:H,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:C,initFile:S,selectItem:A,breadcrumb:g,closeFolder:w,file:h,translate:T})]}):jsxRuntimeExports.jsx(Visor,{soundActions:l,backFile:C,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:T,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:l,emitEvent:u,soundActions:f,keyboardControl:c}){const{solution:h}=t,v=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef(),_=React$2.useRef(),p=React$2.useRef({}),[x,T]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,C]=React$2.useState(),[w]=React$2.useState(new window.Image),P=React$2.useRef([]),[O]=f,k=X=>u({type:"translate",payload:X});React$2.useEffect(()=>{l(x!=="")},[x,l]);const D=(X,Q)=>(X.x+X.width>Q.x&&X.x+X.width<=Q.x+Q.width||Q.x+Q.width>X.x&&Q.x+Q.width<=X.x+X.width)&&(X.y+X.height>Q.y&&X.y+X.height<=Q.y+Q.height||Q.y+Q.height>X.y&&Q.y+Q.height<=X.y+X.height),F=()=>{v&&n&&(v.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},U=()=>{v&&n&&(v.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},H=React$2.useCallback(X=>{let Q=!1;if(X){const re=g.current;re.setPointersPositions(X);const ne=re.getPointerPosition(),ie=v.current.getClientRect({relativeTo:re});Q=D({...ne,width:1,height:1},ie)}return Q},[]),W=React$2.useCallback(X=>X&&r.uid===JSON.parse(X).uid,[r.uid]),Z=React$2.useCallback(()=>{T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"addPoints",complex:!0,finish:!0,payload:P.current}),u({type:"passPuzzle"}),a&&u({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),u({type:"closeUI",ui:"inventory"})},[a,u,r.name,r.uid]),q=React$2.useCallback(()=>{T("success"),u({type:"hidePuzzleButtons",payload:!0}),P.current=[...P.current,...h.right.rewards],setTimeout(()=>{Z()},2e3)},[u,Z,h.right.rewards]),B=React$2.useCallback(()=>{u({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(""),u({type:"hidePuzzleButtons",payload:!1}),u({type:"failPuzzle"}),P.current=[...P.current,...h.wrong.rewards]},[u,h.wrong.rewards]),G=React$2.useCallback(X=>{const Q=X.dataTransfer.getData("item");g.current.setPointersPositions(X);const re=H(X);u({type:"hidePuzzleButtons",payload:!0}),re&&W(Q)?(T("success"),u({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&q()):(u({type:"closeUI",ui:"inventory"}),T("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{B()},2e3))},[H,W,u,q,B,t.solution.right.desc,t.solution.wrong.desc]),I=()=>{x==="success"?q():B()};React$2.useEffect(()=>{const X=e.img.url||"";w.src=X,w.onload=()=>{_.current&&(p.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:w.width,height:w.height,offsetX:w.width/2,offsetY:w.height/2,scale:{x:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height),y:Math.min(_.current.clientWidth/w.width,_.current.clientHeight/w.height)}},S(!0))}},[w,e.img.url]);const $=X=>{X!==null&&(v.current=X)},V=X=>{if(X!==null&&(E.current=X,v.current)){const{x:Q,y:re,width:ne,height:ie}=v.current.getClientRect();X.setAttr("x",Q),X.setAttr("y",re),X.setAttr("height",ie),X.setAttr("width",ne)}};return React$2.useLayoutEffect(()=>{if(v.current&&R){const X=v.current.getClientRect({relativeTo:v.current.getParent()});C({x:X.x+X.width/2,y:X.y+X.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:G,onDragOver:X=>{X.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:g,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:w,...p.current}),jsxRuntimeExports.jsxs(Group,{...p.current,children:[A?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...A},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:F,onMouseLeave:U,ref:$,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:F,onMouseLeave:U,ref:V,text:k("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:k,playSound:O,functionOnClose:I,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:l}){const[u,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let T=!1;return n[r.id].find(R=>R.id===x)&&(T=!0),T},v=x=>{let T="";return u?(e&&h(x.id)&&(T="selected"),o&&h(x.id)&&a.includes(x.id)&&(T="success"),o&&h(x.id)&&!a.includes(x.id)&&(T="failed")):(e&&x.id===n[r.id][0].id&&(T="selected"),o&&x.id===n[r.id][0].id&&(T=n[r.id][0].isCorrect?"success":"failed")),T},E=x=>{const T=v(x);return T==="selected"?"icon-check-circle-black color--selected":T==="success"?"icon-check-circle-black color--success":T==="failed"?"icon-error-circle-black color--error":""},g=x=>o&&x.feedback&&(u&&h(x.id)||x.id===n[r.id][0].id),_=(x,T)=>T===0?"tooltip--right__top":T===x.length-1?"tooltip--right__bottom":"tooltip--center__right",p=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{p.length===1?f(!1):f(!0)},[p.length,u,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),u&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:l("tests.chooseMoreOneAnswer")}):null,c.map((x,T)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[u?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,T,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!v(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,T,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${v(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[T]}),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 ${g(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${v(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${T}`,className:`tooltip ${_(c,T)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:l("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=u=>e.includes(u),a=(u,f)=>u.index<f.index?-1:u.index>f.index?1:0,l=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),l.map(u=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(u.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[u.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:u.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(u.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[u.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:u.feedback})]})]},u.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:l,showResults:u,answered:f,answerPage:c,updateForm:h,disabled:v,translate:E,soundActions:g,paused:_,view:p,correctQuestions:x,feedbacksOnlyWhenReview:T}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[C,w]=React$2.useState(),P=o[S].id,[O]=g;React$2.useEffect(()=>{if(l>=0&&!v&&!_){const q=setInterval(()=>{C||e(B=>B-1)},1e3);return r(q),()=>{clearInterval(q)}}},[v,C,_,r,e,l]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!v&&!T?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)):u()},U=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!v&&!T?w(!0):u()},H=Math.floor(l/60),W=l%60;React$2.useEffect(()=>{if(p==="review"){const q=t[`q${S}`][0].id,B=document.querySelector(`#${q}`);R.scrollTo(0,B.offsetTop)}},[S,R,t,p]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,B=t[P],G=B.find($=>$.isCorrect===!1);let I=0;return B.forEach($=>{q.includes($.id)&&(I+=1)}),!G&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[p==="review"||C?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:C?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]})}),p!=="review"&&l>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${l<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[H<10?`0${H}`:H," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:v,answered:f,updateForm:h,question:o[S],correctQuestions:v?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${p==="review"?"reviewmode":"next"}`,children:[p==="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,!C&&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,C?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,!C&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&U()},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:l,restartTest:u,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:v}){const[E,g]=React$2.useState(0),[_,p]=React$2.useState(),[x,T]=React$2.useState([]),[R,S]=React$2.useState([]),[A,C]=React$2.useState([]),w=React$2.useCallback(()=>{const B=[];return t.forEach(G=>B.push(G.answers)),B},[t]),P=React$2.useCallback(()=>{const B=[];return Object.values(o).forEach(G=>{if(G.length>1){const I=G.find(V=>V.isCorrect===!1),$=[];I?B.push([]):(G.forEach(V=>{V.isCorrect&&$.push(V.id)}),B.push($))}else G[0].isCorrect?B.push([G[0].id]):G[0].isCorrect===!1&&B.push("")}),B},[o]),O=React$2.useCallback(()=>{let B=0;return R.length>0&&x.forEach((G,I)=>{G.length>1?G.every($=>R[I].includes($))&&(B+=1):G.length===1&&R[I]&&G[0]===R[I][0]&&(B+=1)}),B},[x,R]);React$2.useEffect(()=>{T(w),S(P),C(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<v,U=A>=v,H=!r||U,W=Math.trunc(E/k*100),Z=(B,G)=>h({type:"translate",payload:B,values:G}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const B=setInterval(()=>{g(G=>G+1)},100);return p(B),()=>{clearInterval(B)}}},[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&&U||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:v})})]}),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")})}),H?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),H?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>l(),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:l,minimumPercentage:u=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,v]=React$2.useState({}),[E,g]=React$2.useState(),[_,p]=React$2.useState(0),[x,T]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,C]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[U,H]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,B=React$2.useRef({}),[G,I]=React$2.useState(),[$,V]=t,X=(se,oe,fe,he,ue)=>{const _e={...se,index:fe};if(_>0&&(_e.rewards=_e.rewards.filter(Te=>!U[se.id]||Te.points<0)),h[oe]){const Te=h[oe].find(He=>He.id===ue);if(Te){if(Te.id===se.id){const He=h[oe].find(Xe=>Xe.id===ue),Ge=h[oe].indexOf(He);if(h[oe].splice(Ge,1),h[oe].length===0){C(!1);return}}}else h[oe].push(_e)}else h[oe]=[_e];let Oe;he==="isRadio"?Oe={...h,[oe]:[_e]}:Oe={...h},v(Oe),F(Oe),H({...U,[se.id]:{...se}}),C(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(se=>{const oe=se.answers.filter(he=>he.isCorrect),fe=[];return oe.forEach(he=>{fe.push(he.id)}),{question:se.id,answers:fe}});React$2.useEffect(()=>{T(Q)},[Q]),React$2.useEffect(()=>{if(u){const se=Math.ceil(c.length*u/100);I(se)}},[c.length,u]),React$2.useEffect(()=>{R===0&&(clearInterval(E),C(!1),Z(!0),P("results"),V("tts"))},[E,V,R]);const re=()=>{clearInterval(E),C(!1),P("results");const se={...D};F(se),V("tts")},ne=()=>{const se={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(he=>{B.current[he.id]&&(he.rewards=[])})}),r({type:"saveTest",payload:se})},ie=()=>{const se=()=>{F({}),H({}),P("test"),v({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(he=>{he.forEach(ue=>{ue.isCorrect&&(B.current[ue.id]?ue.rewards=[]:B.current[ue.id]=!0)})});let fe=oe.reduce((he,ue)=>{const _e=[];return ue.forEach(Oe=>{_e.push(Oe.rewards)}),[...he,..._e.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:se}),r({type:"failTest"})},J=(se,oe)=>r({type:"translate",payload:se,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:p,tries:_,answerPage:C,setTime:S,paused:l,saveInterval:g,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:re,translate:J,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:ie,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:G})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((l,u)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--response__item ${e[r]===l?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[u]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${l}`)})]},l))})}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=l=>{o({...e,[r]:l}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(l=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(l),className:`unset-button survey--points__item survey--points__item--colorized ${e[r]===l?"selected":""}`,children:l},l))}),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),[l,u]=React$2.useState(!1),[f]=e,c=(E,g)=>o({type:"translate",payload:E,values:g}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)u(!0);else{E&&u(!1);const g=E?n-1:n+1;a(g)}},v=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(v,{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"})}),l&&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,!l&&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,C,w;const[a,l]=React$2.useState(null),[u,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[v,E]=React$2.useState(0),[g,_]=React$2.useState({current:{questions:[],type:r}}),[p]=n,x=P=>t({type:"translate",payload:P}),T=P=>{P.keyCode===13&&P.target.blur()},R=()=>{p("click-ui"),t({type:"saveSurveyPrePos",payload:g.current})};React$2.useEffect(()=>{!e.length&&u==="questions"&&f("end")},[e,u]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=g.current.questions.find(F=>F.id===e[v].id))==null?void 0:D.answer;if(p("click-ui"),O)E(v-1),h(!1);else{const F=g.current.questions.findIndex(H=>H.id===e[v].id),U=[...g.current.questions];F>-1?U.splice(F,1,{id:e[v].id,answer:k}):U.push({id:e[v].id,answer:k}),_({...g,current:{...g.current,questions:U}}),v===e.length-1?h(!0):(E(v+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:[u==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),p("click-ui")},translate:x}),u==="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")," ",v+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[v])==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:()=>{l(O)},onTouchEnd:()=>{l(null)},onKeyUp:D=>{T(D)},onClick:()=>{S(O,!1)},className:`survey--points__item survey--points__item--simple ${((k=g.current.questions[v])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[v]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:v===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${v===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"),p("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:((C=g.current.questions[v])==null?void 0:C.answer)===void 0,"aria-label":LangIsRtl()?x("survey.previous"):x("survey.next"),className:`gat--btn__navigation ${((w=g.current.questions[v])==null?void 0:w.answer)===void 0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]}),u==="end"&&jsxRuntimeExports.jsx(EndScreen,{onFinish:R,translate:x})]})]})}function PatternComponent({img:o,name:e,viewed:r,emitEvent:t,soundActions:n,keyboardControl:a}){const[l]=n,u=v=>t({type:"translate",payload:v}),f=()=>{l("click-ui"),t({type:"emitSavePattern",payload:{imgId:o.resourceId,name:e,viewed:!0,url:h,type:"pattern"}})},c=a({disabled:r,forward:f,escape:f});if(React$2.useEffect(()=>c(),[c]),!o)return null;const h=o.url;return 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:h&&jsxRuntimeExports.jsx("img",{src:h,alt:"pattern"})}):jsxRuntimeExports.jsxs("div",{className:"pattern",children:[jsxRuntimeExports.jsxs("div",{className:"pattern__header",children:[jsxRuntimeExports.jsx("div",{className:"pattern__title",children:u("phone.pattern")}),jsxRuntimeExports.jsx("button",{type:"button","aria-label":u("storylines.misc.closePiece"),className:"pattern__close gat--btn__round gat--btn__close",onClick:()=>f(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("figure",{className:"pattern__figure",children:h&&jsxRuntimeExports.jsx("img",{src:h,alt:"pattern"})})]})})})}const getRecursiveJSX=(o,e=0,r,t,n)=>{var a,l;if((a=o.props)!=null&&a.children){const u=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 v=0;v<h.length;v+=1)c["data-text-id"]===h[v].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(u,{...c,children:f.map((h,v)=>getRecursiveJSX(h,v,r,t))},`${o.type}_${e}`):jsxRuntimeExports.jsx(u,{...c,children:getRecursiveJSX(f,e,r,t)},`${o.type}_${e}`)}return((l=o.props)==null?void 0:l.children)!==null?o.split(" ").filter(u=>u!=="").map(u=>jsxRuntimeExports.jsx("span",{dir:"auto",children:u},u)):null};function TextClickPuzzleComponent({emitEvent:o,showFrames:e,styles:r,list:t,soundActions:n,description:a,setInfo:l,setResolveAction:u,keyboardControl:f,backgroundImage:c,hideBackgroundImageTheme:h=!1,nodeId:v}){const E=`textclick-puzzle_${v}`,[g,_]=React$2.useState({result:null,show:!1,text:"",timeout:!1}),[p]=n,[x,T]=React$2.useState(0),[R,S]=React$2.useState(0),[A,C]=React$2.useState(0),w=React$2.useRef(0),P=React$2.useRef([]),[O,k]=React$2.useState(0),[D,F]=React$2.useState(),U=React$2.useCallback(ne=>o({type:"translate",payload:ne}),[o]),H=React$2.useRef(null),W=React$2.useCallback(()=>w.current===t[x].correctTexts.length||t[x].hasClickOnce&&w.current>=1,[x,t]),Z=React$2.useCallback((ne,ie)=>{ne&&o({type:"hidePuzzleButtons",payload:!0}),_(J=>({...J,show:ne,...ie}))},[o]),q=React$2.useCallback(()=>{if(W())if(_(ne=>({...ne,result:!1})),w.current=0,A===R){const ne=P.current.reduce((ie,J)=>{const se=ie.findIndex(oe=>oe.id===J.id);return se>=0?ie[se].points+=J.points:ie.push({...J}),ie},[]);o({type:"addPoints",complex:!0,finish:!0,payload:ne}),o({type:"passPuzzle"})}else H.current=null,T(x+1),k(0),F(!0),setTimeout(()=>{F(!1)},1200)},[W,A,R,o,x]),B=React$2.useCallback(()=>{o({type:"hidePuzzleButtons",payload:!1}),q(),_(ie=>({...ie,show:!1,text:""}));const ne=document.querySelectorAll(".text-click__failed");ne.length>0&&ne.forEach(ie=>ie.classList.remove("text-click__failed"))},[o,q]),G=React$2.useCallback((ne,ie)=>{var J,se;ne.forEach(oe=>oe.classList.add("text-click__success")),C(A+1),w.current+=1,p("score"),(J=t[x].info.solution.right)!=null&&J.desc?W()&&(P.current=[...P.current,...t[x].info.solution.right.rewards],Z(!0,{result:!0,text:t[x].info.solution.right.desc,timeout:!1})):t[x].info.solution.right.desc===""&&(ie!=null&&ie.desc)?(P.current=((se=ie==null?void 0:ie.rewards)==null?void 0:se.length)>0?[...P.current,...(ie==null?void 0:ie.rewards)||{}]:[...P.current],Z(!0,{result:!0,text:ie.desc,timeout:!1})):t[x].specificFeedbacks.specificCorrectFeedbacks?(P.current=[...P.current,...(ie==null?void 0:ie.rewards)||{}],W()&&Z(!0,{result:!0,timeout:!0})):W()&&(P.current=[...P.current,...t[x].info.solution.right.rewards],Z(!0,{result:!0,timeout:!0}))},[A,p,t,x,W,Z]),I=React$2.useCallback((ne,ie)=>{var J;ne.forEach(se=>se.classList.add("text-click__failed")),p("fail"),o({type:"failPuzzle"}),t[x].info.solution.wrong.desc!==""?(P.current=[...P.current,...t[x].info.solution.wrong.rewards],Z(!0,{result:!1,text:t[x].info.solution.wrong.desc,timeout:!1})):t[x].info.solution.wrong.desc===""&&(ie!=null&&ie.desc)?(P.current=(J=ie==null?void 0:ie.rewards)!=null&&J.length?[...P.current,...(ie==null?void 0:ie.rewards)||{}]:[...P.current],Z(!0,{result:!1,text:ie.desc,timeout:!1})):t[x].specificFeedbacks.specificWrongFeedbacks?(P.current=[...P.current,...(ie==null?void 0:ie.rewards)||{}],Z(!0,{result:!1,timeout:!0})):(P.current=[...P.current,...t[x].info.solution.wrong.rewards],Z(!0,{result:!1,timeout:!0}))},[p,o,t,x,Z]),$=React$2.useCallback((ne,ie)=>{var _e,Oe,Te,He;ne.stopPropagation();const J=document.querySelectorAll(`[data-text-id="${ie}"]`),se=document.querySelectorAll("[data-text-id]"),oe=t[x].correctTexts.find(Ge=>Ge.id===ie),fe=t[x].wrongTexts.find(Ge=>Ge.id===ie),he=(Oe=(_e=t[x])==null?void 0:_e.specificFeedbacks)==null?void 0:Oe.correctFeedbacks.find(Ge=>Ge.id===ie),ue=(He=(Te=t[x])==null?void 0:Te.specificFeedbacks)==null?void 0:He.wrongFeedbacks.find(Ge=>Ge.id===ie);p("click-ui"),t[x].hasClickOrder?t[x].correctTexts[O].id===ie?(k(O+1),G(J,he)):t[x].correctTexts.find(Ge=>Ge.id===ie)&&t[x].correctTexts[O].id!==ie?(se.forEach(Ge=>Ge.classList.remove("text-click__success")),k(0),C(0),w.current=0,Z(!0,{result:!1,text:t[x].info.orderFeedback.desc||U("puzzles.incorrectOrder"),timeout:!1}),T(0)):I(J,ue):(oe==null?void 0:oe.id)===ie?G(J,he):((fe==null?void 0:fe.id)===ie||ie==="allWrong")&&I(J,ue)},[t,x,p,O,G,Z,U,I]),V=React$2.useCallback(ne=>getRecursiveJSX(ne,0,t[x],$),[x,t,$]),X=React$2.useCallback(()=>{let ne=0;for(let ie=0;ie<t.length;ie+=1)if(t[ie].hasClickOnce)ne+=1,S(ne);else for(let J=0;J<t[ie].correctTexts.length;J+=1)ne+=1,S(ne)},[t]);React$2.useEffect(()=>{var ne;if(t!=null&&t[x]&&l({...t[x].info,description:a}),(ne=t[x])!=null&&ne.text){const ie=HTMLReactParser$1(t[x].text);H.current=V(ie),X()}else H.current=""},[x,a,X,t,V,l]),React$2.useEffect(()=>{u(()=>{o({type:"hidePuzzleButtons",payload:!0});const ne=document.querySelectorAll(".text-click [data-text-id]"),ie=t[x].correctTexts.map(se=>se.id);ne.forEach(se=>{ie.includes(se.getAttribute("data-text-id"))&&se.classList.add("text-click__success")});const J=t[x].info.resolve.rewards;x+1<t.length?(setTimeout(()=>{o({type:"puzzleAction",action:"addPoints",payload:{element:E,rewards:J,finish:!1,payload:J}});let se=0;t.forEach((oe,fe)=>{fe<=x&&(se+=oe.correctTexts.length)}),C(se),H.current=null,w.current=0,F(!0),T(x+1)},2e3),setTimeout(()=>{F(!1),o({type:"hidePuzzleButtons",payload:!1})},3200)):setTimeout(()=>{o({type:"puzzleAction",action:"resolve",payload:{element:E,rewards:J,finish:x+1>=t.length}})},2e3)})},[u,o,t,x,E]);const Q=React$2.useMemo(()=>{let ne=`text-click text-click--${r}`;return h&&(ne+=" disable-background-image"),ne},[h,r]),re={pointerEvents:g.show?"none":null,backgroundImage:c!=null&&c.url?`url('${c.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:Q,style:re,children:[jsxRuntimeExports.jsx("div",{className:"text-click__overlay",children:jsxRuntimeExports.jsx("div",{className:`text-click__container ${D?"slideInLeft":""} `,children:jsxRuntimeExports.jsx("div",{className:"text-click__body",children:jsxRuntimeExports.jsx("div",{className:"text-click__scroll",dir:LangIsRtl()?"rtl":"auto",children:H.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:[A," / ",R]})]})]}),g.show&&jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:p,success:g.result,text:g.text,translate:U,functionOnClose:B,hasTimeout:g.timeout,keyboardControl:f})]})}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