@roudanio/maze 0.2.1 → 0.2.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.
package/dist/maze.iife.js CHANGED
@@ -1,4 +1,4 @@
1
- var Maze=function(){"use strict";var re,A,Ae,B,Pe,Ie,xe,Re,ge,pe,we,Fe,Q={},De=[],yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function Ce(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function bt(t,e,n){var o,i,s,a={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?re.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)a[s]==null&&(a[s]=t.defaultProps[s]);return se(t,a,o,i,null)}function se(t,e,n,o,i){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ae,__i:-1,__u:0};return i==null&&A.vnode!=null&&A.vnode(s),s}function ae(t){return t.children}function le(t,e){this.props=t,this.context=e}function Y(t,e){if(e==null)return t.__?Y(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Y(t):null}function Oe(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Oe(t)}}function ye(t){(!t.__d&&(t.__d=!0)&&B.push(t)&&!ce.__r++||Pe!=A.debounceRendering)&&((Pe=A.debounceRendering)||Ie)(ce)}function ce(){for(var t,e,n,o,i,s,a,r=1;B.length;)B.length>r&&B.sort(xe),t=B.shift(),r=B.length,t.__d&&(n=void 0,i=(o=(e=t).__v).__e,s=[],a=[],e.__P&&((n=H({},o)).__v=o.__v+1,A.vnode&&A.vnode(n),be(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[i]:null,s,i??Y(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,je(s,n,a),n.__e!=i&&Oe(n)));ce.__r=0}function $e(t,e,n,o,i,s,a,r,l,c,d){var u,h,f,k,p,_,b=o&&o.__k||De,w=e.length;for(l=Tt(n,e,b,l,w),u=0;u<w;u++)(f=n.__k[u])!=null&&(h=f.__i==-1?Q:b[f.__i]||Q,f.__i=u,_=be(t,f,h,i,s,a,r,l,c,d),k=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Te(h.ref,null,f),d.push(f.ref,f.__c||k,f)),p==null&&k!=null&&(p=k),4&f.__u||h.__k===f.__k?l=Ue(f,l,t):typeof f.type=="function"&&_!==void 0?l=_:k&&(l=k.nextSibling),f.__u&=-7);return n.__e=p,l}function Tt(t,e,n,o,i){var s,a,r,l,c,d=n.length,u=d,h=0;for(t.__k=new Array(i),s=0;s<i;s++)(a=e[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(l=s+h,(a=t.__k[s]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?se(null,a,null,null,null):ie(a)?se(ae,{children:a},null,null,null):a.constructor==null&&a.__b>0?se(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,r=null,(c=a.__i=kt(a,n,l,u))!=-1&&(u--,(r=n[c])&&(r.__u|=2)),r==null||r.__v==null?(c==-1&&(i>d?h--:i<d&&h++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,a.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<d;s++)(r=n[s])!=null&&(2&r.__u)==0&&(r.__e==o&&(o=Y(r)),He(r,r));return o}function Ue(t,e,n){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Ue(o[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=Y(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function kt(t,e,n,o){var i,s,a=t.key,r=t.type,l=e[n];if(l===null&&t.key==null||l&&a==l.key&&r==l.type&&(2&l.__u)==0)return n;if(o>(l!=null&&(2&l.__u)==0?1:0))for(i=n-1,s=n+1;i>=0||s<e.length;){if(i>=0){if((l=e[i])&&(2&l.__u)==0&&a==l.key&&r==l.type)return i;i--}if(s<e.length){if((l=e[s])&&(2&l.__u)==0&&a==l.key&&r==l.type)return s;s++}}return-1}function Ge(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||yt.test(e)?n:n+"px"}function ue(t,e,n,o,i){var s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Ge(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Ge(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Re,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?o?n.u=o.u:(n.u=ge,t.addEventListener(e,s?we:pe,s)):t.removeEventListener(e,s?we:pe,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ge++;else if(e.t<n.u)return;return n(A.event?A.event(e):e)}}}function be(t,e,n,o,i,s,a,r,l,c){var d,u,h,f,k,p,_,b,w,M,C,z,S,E,L,y,g,v=e.type;if(e.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),s=[r=e.__e=n.__e]),(d=A.__b)&&d(e);e:if(typeof v=="function")try{if(b=e.props,w="prototype"in v&&v.prototype.render,M=(d=v.contextType)&&o[d.__c],C=d?M?M.props.value:d.__:o,n.__c?_=(u=e.__c=n.__c).__=u.__E:(w?e.__c=u=new v(b,C):(e.__c=u=new le(b,C),u.constructor=v,u.render=zt),M&&M.sub(u),u.props=b,u.state||(u.state={}),u.context=C,u.__n=o,h=u.__d=!0,u.__h=[],u._sb=[]),w&&u.__s==null&&(u.__s=u.state),w&&v.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=H({},u.__s)),H(u.__s,v.getDerivedStateFromProps(b,u.__s))),f=u.props,k=u.state,u.__v=e,h)w&&v.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),w&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(w&&v.getDerivedStateFromProps==null&&b!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,C),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,C)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(u.props=b,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(T){T&&(T.__=e)}),z=0;z<u._sb.length;z++)u.__h.push(u._sb[z]);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,C),w&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,k,p)})}if(u.context=C,u.props=b,u.__P=t,u.__e=!1,S=A.__r,E=0,w){for(u.state=u.__s,u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),L=0;L<u._sb.length;L++)u.__h.push(u._sb[L]);u._sb=[]}else do u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++E<25);u.state=u.__s,u.getChildContext!=null&&(o=H(H({},o),u.getChildContext())),w&&!h&&u.getSnapshotBeforeUpdate!=null&&(p=u.getSnapshotBeforeUpdate(f,k)),y=d,d!=null&&d.type===ae&&d.key==null&&(y=qe(d.props.children)),r=$e(t,ie(y)?y:[y],e,n,o,i,s,a,r,l,c),u.base=e.__e,e.__u&=-161,u.__h.length&&a.push(u),_&&(u.__E=u.__=null)}catch(T){if(e.__v=null,l||s!=null)if(T.then){for(e.__u|=l?160:128;r&&r.nodeType==8&&r.nextSibling;)r=r.nextSibling;s[s.indexOf(r)]=null,e.__e=r}else for(g=s.length;g--;)Ce(s[g]);else e.__e=n.__e,e.__k=n.__k;A.__e(T,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):r=e.__e=St(n.__e,e,n,o,i,s,a,l,c);return(d=A.diffed)&&d(e),128&e.__u?void 0:r}function je(t,e,n){for(var o=0;o<n.length;o++)Te(n[o],n[++o],n[++o]);A.__c&&A.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){A.__e(s,i.__v)}})}function qe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:ie(t)?t.map(qe):H({},t)}function St(t,e,n,o,i,s,a,r,l){var c,d,u,h,f,k,p,_=n.props,b=e.props,w=e.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!w&&(w?f.localName==w:f.nodeType==3)){t=f,s[c]=null;break}}if(t==null){if(w==null)return document.createTextNode(b);t=document.createElementNS(i,w,b.is&&b),r&&(A.__m&&A.__m(e,s),r=!1),s=null}if(w==null)_===b||r&&t.data==b||(t.data=b);else{if(s=s&&re.call(t.childNodes),_=n.props||Q,!r&&s!=null)for(_={},c=0;c<t.attributes.length;c++)_[(f=t.attributes[c]).name]=f.value;for(c in _)if(f=_[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=f;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;ue(t,c,null,f,i)}}for(c in b)f=b[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?d=f:c=="value"?k=f:c=="checked"?p=f:r&&typeof f!="function"||_[c]===f||ue(t,c,f,_[c],i);if(d)r||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),$e(e.type=="template"?t.content:t,ie(h)?h:[h],e,n,o,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&Y(n,0),r,l),s!=null)for(c=s.length;c--;)Ce(s[c]);r||(c="value",w=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[c]||w=="progress"&&!k||w=="option"&&k!=_[c])&&ue(t,c,k,_[c],i),c="checked",p!=null&&p!=t[c]&&ue(t,c,p,_[c],i))}return t}function Te(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){A.__e(i,n)}}function He(t,e,n){var o,i;if(A.unmount&&A.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||Te(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){A.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&He(o[i],e,n||typeof t.type!="function");n||Ce(t.__e),t.__c=t.__=t.__e=void 0}function zt(t,e,n){return this.constructor(t,n)}function Be(t,e,n){var o,i,s,a;e==document&&(e=document.documentElement),A.__&&A.__(t,e),i=(o=!1)?null:e.__k,s=[],a=[],be(e,t=e.__k=bt(ae,null,[t]),i||Q,Q,e.namespaceURI,i?null:e.firstChild?re.call(e.childNodes):null,s,i?i.__e:e.firstChild,o,a),je(s,t,a)}function Et(t){function e(n){var o,i;return this.getChildContext||(o=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,ye(a)})},this.sub=function(s){o.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),a&&a.call(s)}}),n.children}return e.__c="__cC"+Fe++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,o){return n.children(o)}).contextType=e,e}re=De.slice,A={__e:function(t,e,n,o){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,o||{}),a=i.__d),a)return i.__E=i}catch(r){t=r}throw t}},Ae=0,le.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ye(this))},le.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ye(this))},le.prototype.render=ae,B=[],Ie=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xe=function(t,e){return t.__v.__b-e.__v.__b},ce.__r=0,Re=/(PointerCapture)$|Capture$/i,ge=0,pe=We(!1),we=We(!0),Fe=0;var Lt=0;function m(t,e,n,o,i,s){e||(e={});var a,r,l=e;if("ref"in l)for(r in l={},e)r=="ref"?a=e[r]:l[r]=e[r];var c={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lt,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(a=t.defaultProps))for(r in a)l[r]===void 0&&(l[r]=a[r]);return A.vnode&&A.vnode(c),c}var K,P,ke,Ve,ee=0,Xe=[],F=A,Ye=F.__b,Ke=F.__r,Je=F.diffed,Ze=F.__c,Qe=F.unmount,et=F.__;function de(t,e){F.__h&&F.__h(P,t,ee||e),ee=0;var n=P.__H||(P.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function U(t){return ee=1,Nt(rt,t)}function Nt(t,e,n){var o=de(K++,2);if(o.t=t,!o.__c&&(o.__=[rt(void 0,e),function(r){var l=o.__N?o.__N[0]:o.__[0],c=o.t(l,r);l!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=P,!P.__f)){var i=function(r,l,c){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(h){return!!h.__c});if(d.every(function(h){return!h.__N}))return!s||s.call(this,r,l,c);var u=o.__c.props!==r;return d.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(u=!0)}}),s&&s.call(this,r,l,c)||u};P.__f=!0;var s=P.shouldComponentUpdate,a=P.componentWillUpdate;P.componentWillUpdate=function(r,l,c){if(this.__e){var d=s;s=void 0,i(r,l,c),s=d}a&&a.call(this,r,l,c)},P.shouldComponentUpdate=i}return o.__N||o.__}function R(t,e){var n=de(K++,3);!F.__s&&ot(n.__H,e)&&(n.__=t,n.u=e,P.__H.__h.push(n))}function D(t){return ee=5,J(function(){return{current:t}},[])}function J(t,e){var n=de(K++,7);return ot(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function tt(t,e){return ee=8,J(function(){return t},e)}function Mt(t){var e=P.context[t.__c],n=de(K++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(P)),e.props.value):t.__}function At(){for(var t;t=Xe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(he),t.__H.__h.forEach(Se),t.__H.__h=[]}catch(e){t.__H.__h=[],F.__e(e,t.__v)}}F.__b=function(t){P=null,Ye&&Ye(t)},F.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),et&&et(t,e)},F.__r=function(t){Ke&&Ke(t),K=0;var e=(P=t.__c).__H;e&&(ke===P?(e.__h=[],P.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(he),e.__h.forEach(Se),e.__h=[],K=0)),ke=P},F.diffed=function(t){Je&&Je(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Xe.push(e)!==1&&Ve===F.requestAnimationFrame||((Ve=F.requestAnimationFrame)||Pt)(At)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ke=P=null},F.__c=function(t,e){e.some(function(n){try{n.__h.forEach(he),n.__h=n.__h.filter(function(o){return!o.__||Se(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],F.__e(o,n.__v)}}),Ze&&Ze(t,e)},F.unmount=function(t){Qe&&Qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{he(o)}catch(i){e=i}}),n.__H=void 0,e&&F.__e(e,n.__v))};var nt=typeof requestAnimationFrame=="function";function Pt(t){var e,n=function(){clearTimeout(o),nt&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,100);nt&&(e=requestAnimationFrame(n))}function he(t){var e=P,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),P=e}function Se(t){var e=P;t.__c=t.__(),P=e}function ot(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function rt(t,e){return typeof e=="function"?e(t):e}const It=t=>({saveGameData(e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error("Failed to save maze game data:",n)}},loadGameData(){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset maze game data:",e)}}}),it=Et(void 0),st={currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,levelScores:{},totalScore:0},ze={isGameActive:!0,levelTransitioning:!1,maze:null,playerCell:{row:0,col:0},exitCell:{row:0,col:0},foodCells:[],playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,playerPath:[],visitCounts:{}},xt=({children:t,config:e})=>{const n=It(e.lcPrefix+"progress"),o=n.loadGameData(),[i,s]=U(()=>o||{...st});R(()=>{const u=Object.values(i.levelScores).reduce((h,f)=>h+f,0);s(h=>({...h,totalScore:u}))},[i.levelScores]),R(()=>{n.saveGameData(i)},[i.currentLevel,i.highestUnlockedLevel,i.currentTier,i.highestUnlockedTier,i.levelScores,i.totalScore]);const[a,r]=U({...ze}),l=D(a);R(()=>{l.current=a},[a]);const c=J(()=>[a.playerAtExit?1:0,a.foodCollected===a.totalFoodCount?1:0,a.showClue?0:1],[a.playerAtExit,a.foodCollected,a.totalFoodCount,a.showClue]),d=()=>{n.resetGameData(),s({...st}),r({...ze})};return m(it.Provider,{value:{gameProgress:i,setGameProgress:s,gamePlayState:a,setGamePlayState:r,gamePlayStateRef:l,currentScore:c,config:e,resetGame:d},children:t})},te=()=>{const t=Mt(it);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t},ne=t=>J(()=>{const e=t.map(r=>r.length),n=e.reduce((r,l)=>r+l,0),o=t.length,i=r=>{if(r<1||r>n)return 0;let l=0;for(let c=0;c<e.length;c++)if(l+=e[c],r<=l)return c+1;return 0},s=r=>r<1||r>o?0:e.slice(0,r-1).reduce((l,c)=>l+c,0)+1,a={getTotalLevels:()=>n,getTotalTiers:()=>o,getTierLevelsRange:r=>{if(r<1||r>o)return[0,0];const l=s(r),c=l+e[r-1]-1;return[l,c]},getTierByLevel:i,getFirstLevelOfTier:s,getLevelConfig:r=>{if(r<1||r>n)return null;const l=i(r),c=s(l),d=r-c;return t[l-1][d]},getTierConfig:r=>r<1||r>o?null:t[r-1],isLevelUnlocked:(r,l)=>r<=l,isTierUnlocked:(r,l)=>r<=l,getNextLevelInfo:r=>{if(r>=n)return null;const l=r+1,c=i(r),d=i(l);return{nextLevel:l,nextTier:d,isTierChange:d>c}},getCurrentTierProgress:(r,l)=>{const[c,d]=a.getTierLevelsRange(l),u=r-c+1,h=d-c+1;return{current:u,total:h}},isLastLevelInTier:r=>{const l=i(r),[,c]=a.getTierLevelsRange(l);return r===c},getPreviousLevelInfo:r=>{if(r<=1)return null;const l=r-1,c=i(r),d=i(l);return{prevLevel:l,prevTier:d,isTierChange:d<c}}};return a},[t]),Rt=({onTierChange:t,disabled:e})=>{const{gameProgress:n,config:o}=te(),{i18n:i,levelConfig:s}=o,{currentTier:a,highestUnlockedTier:r}=n,c=ne(s).getTotalTiers();return m("div",{className:"tier-selector",children:m("select",{value:a,onChange:d=>{d.target&&d.target.value&&t(Number(d.target.value))},disabled:e,className:"tier-dropdown",children:Array.from({length:c},(d,u)=>u+1).map(d=>m("option",{value:d,disabled:d>r,children:i.tier+" "+d},`tier-${d}`))})})},Ft=({onLevelChange:t,disabled:e})=>{const{gameProgress:n,config:o}=te(),{i18n:i,levelConfig:s}=o,{currentTier:a,levelScores:r,currentLevel:l,highestUnlockedLevel:c}=n,d=ne(s),u=J(()=>{const[h,f]=d.getTierLevelsRange(a);return Array.from({length:f-h+1},(k,p)=>{const _=h+p,b=r[_]||0;return{level:_,score:b}})},[a,r]);return m("div",{className:"level-selector",children:m("select",{value:l,onChange:h=>{h.target&&h.target.value&&t(Number(h.target.value))},disabled:e,className:"level-dropdown",children:u.map(({level:h,score:f})=>m("option",{value:h,disabled:h>c,children:`${i.level} ${h} ${"★".repeat(f)}`},`level-${h}`))})})},oe=({isOpen:t,title:e,className:n="",message:o,children:i,noConfirm:s=!1,noCancel:a=!1,confirmText:r="OK",cancelText:l="Cancel",confirmClass:c="",cancelClass:d="",onConfirm:u,onCancel:h})=>{const f=D(null);return R(()=>{const k=p=>{p.key==="Escape"&&h?.()};return t&&document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[t,h]),m("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:m("div",{className:"maze-dialog "+n,ref:f,children:[m("div",{className:"maze-dialog-title",children:e}),m("div",{className:"maze-dialog-content",children:i||m("div",{className:"maze-dialog-message",children:o})}),(!a||!s)&&m("div",{className:"maze-dialog-buttons",children:[!a&&m("button",{type:"button",className:"maze-dialog-cancel "+d,onClick:h,children:l}),!s&&m("button",{type:"button",className:"maze-dialog-confirm "+c,onClick:u,children:r})]})]})})},G={container:null,attachTo(t){return this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=document.createElement("div"),this.container.className="toast-container position-bottom",t.appendChild(this.container),this.container},currentToast:null,currentTimer:null,show(t,e=2e3){if(!this.container){console.warn("NativeToast: container not initialized, please call attachTo first");return}this.currentToast&&this.container.contains(this.currentToast)&&(this.container.removeChild(this.currentToast),this.currentToast=null),this.currentTimer&&(clearTimeout(this.currentTimer),this.currentTimer=null);const n=document.createElement("div");n.className="toast-message toast-visible",n.textContent=t,this.container.appendChild(n),this.currentToast=n,this.currentTimer=setTimeout(()=>{n.classList.remove("toast-visible"),setTimeout(()=>{this.container&&this.container.contains(n)&&(this.container.removeChild(n),this.currentToast===n&&(this.currentToast=null))},300),this.currentTimer=null},e)},clearAll(){if(this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}},Dt=()=>{const{gameProgress:t,setGameProgress:e,gamePlayState:n,setGamePlayState:o,gamePlayStateRef:i,resetGame:s,config:a}=te(),{i18n:r,levelConfig:l}=a,c=ne(l),{levelTransitioning:d,showClue:u}=n,{highestUnlockedLevel:h,totalScore:f}=t,k=c.getTotalLevels(),[p,_]=U(!1),[b,w]=U(!1),[M,C]=U(!1),z=O=>{const x=c.getFirstLevelOfTier(O);c.isLevelUnlocked(x,h)&&(e($=>({...$,currentTier:O})),S(x))},S=O=>{c.isLevelUnlocked(O,h)&&(e(x=>({...x,currentLevel:O})),G.show(r.levelGoToast.replace("%LEVEL%",O.toString())))},E=()=>{_(!0)},L=()=>{_(!1)},y=()=>{C(!0)},g=()=>{C(!1)},v=()=>{G.show(u?r.cluePathDisabled:r.cluePathEnabled),o(()=>({...i.current,showClue:!i.current.showClue})),C(!1)},T=()=>{w(!0)},N=()=>{s(),w(!1),G.show(r.resetDoneToast)},I=()=>{w(!1)};return m("div",{class:"game-panel-container",children:[m("div",{className:"game-controls",children:[m("div",{className:"selectors-container",children:[m(Rt,{onTierChange:z,disabled:d}),m(Ft,{onLevelChange:S,disabled:d})]}),m("button",{className:`settings-clue-button ${u?"clue-on":"clue-off"}`,disabled:u,title:"Toggle Clue",onClick:y,children:u?r.clueOn:r.clueOff})]}),m("div",{className:"game-settings",children:m("span",{className:"game-settings-icon",onClick:E,children:"★ "+f})}),m(oe,{isOpen:p,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:L,children:[m("div",{className:"settings-stats",children:[m("div",{children:r.levelComplete+`: ${h}/${k}`}),m("div",{children:r.starsCollected+": "+f}),m("div",{children:r.avgStarPerLevel+": "+(f/h).toFixed(2)})]}),m("div",{className:"settings-item-box",children:[m("button",{className:"settings-reset-button",title:"Reset Game",onClick:T,children:r.reset}),m("div",{className:"settings-item-tip",children:r.resetTip})]})]}),m(oe,{isOpen:b,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:N,onCancel:I}),m(oe,{isOpen:M,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:v,onCancel:g})]})};function Ee(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function Le(t,e,n){return e&&Ot(t.prototype,e),t}function at(t){return+t.replace(/px/,"")}function $t(t){var e=window.devicePixelRatio,n=getComputedStyle(t),o=at(n.getPropertyValue("width")),i=at(n.getPropertyValue("height"));t.setAttribute("width",(o*e).toString()),t.setAttribute("height",(i*e).toString())}function W(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=Math.random()*(e-t)+t;return Math.floor(o*Math.pow(10,n))/Math.pow(10,n)}function lt(t){return t[W(0,t.length)]}var Ut=.00125,Gt=5e-4,Wt=9e-4,jt=1e-5,qt=6,Ht=80,Bt=.9,Vt=1.7,Xt=.2,Yt=.6,Kt=.03,Jt=.07,Zt=15,Qt=82,en=100,tn=250,nn=40,on=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function ct(t){var e=1920;return Math.log(t)/Math.log(e)}var ut=function(){function t(e){Ee(this,t);var n=e.initialPosition,o=e.direction,i=e.confettiRadius,s=e.confettiColors,a=e.emojis,r=e.emojiSize,l=e.canvasWidth,c=W(Bt,Vt,3),d=c*ct(l);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=W(Xt,Yt,3),this.rotationSpeed=a.length?.01:W(Kt,Jt,3)*ct(l),this.dragForceCoefficient=W(Gt,Wt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=o==="left"?W(0,.2,3):W(-.2,0,3),this.emojiSize=r,this.emojiRotationAngle=W(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=o==="left"?W(Qt,Zt)*Math.PI/180:W(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var h=W(-150,0),f={x:n.x+(o==="left"?-h:h)*this.absCos,y:n.y-h*this.absSin};this.currentPosition=Object.assign({},f),this.initialPosition=Object.assign({},f),this.color=a.length?null:lt(s),this.emoji=a.length?lt(a):null,this.createdAt=new Date().getTime(),this.direction=o}return Le(t,[{key:"draw",value:function(n){var o=this.currentPosition,i=this.radius,s=this.color,a=this.emoji,r=this.rotationAngle,l=this.emojiRotationAngle,c=this.emojiSize,d=window.devicePixelRatio;s?(n.fillStyle=s,n.beginPath(),n.ellipse(o.x*d,o.y*d,i.x*d,i.y*d,r,0,2*Math.PI),n.fill()):a&&(n.font="".concat(c,"px serif"),n.save(),n.translate(d*o.x,d*o.y),n.rotate(l),n.textAlign="center",n.fillText(a,0,0),n.restore())}},{key:"updatePosition",value:function(n,o){var i=this.confettiSpeed,s=this.dragForceCoefficient,a=this.finalConfettiSpeedX,r=this.radiusYUpdateDirection,l=this.rotationSpeed,c=this.createdAt,d=this.direction,u=o-c;if(i.x>a&&(this.confettiSpeed.x-=s*n),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*n,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+Ut*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:jt*n,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*n%(2*Math.PI);return}r==="down"?(this.radius.y-=n*l,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=n*l,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(n){return this.currentPosition.y<n+en}}]),t}();function rn(){var t=document.createElement("canvas");return t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.zIndex="1000",t.style.pointerEvents="none",document.body.appendChild(t),t}function sn(t){var e=t.confettiRadius,n=e===void 0?qt:e,o=t.confettiNumber,i=o===void 0?t.confettiesNumber||(t.emojis?nn:tn):o,s=t.confettiColors,a=s===void 0?on:s,r=t.emojis,l=r===void 0?t.emojies||[]:r,c=t.emojiSize,d=c===void 0?Ht:c;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:n,confettiNumber:i,confettiColors:a,emojis:l,emojiSize:d}}var an=function(){function t(e){var n=this;Ee(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(o){return n.resolvePromise=o})}return Le(t,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var n;(n=this.shapes).push.apply(n,arguments)}},{key:"complete",value:function(){var n;return this.shapes.length?!1:((n=this.resolvePromise)===null||n===void 0||n.call(this),!0)}},{key:"processShapes",value:function(n,o,i){var s=this,a=n.timeDelta,r=n.currentTime;this.shapes=this.shapes.filter(function(l){return l.updatePosition(a,r),l.draw(s.canvasContext),i?l.getIsVisibleOnCanvas(o):!0})}}]),t}(),ln=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ee(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||rn(),this.canvasContext=this.canvas.getContext("2d"),this.requestAnimationFrameRequested=!1,this.lastUpdated=new Date().getTime(),this.iterationIndex=0,this.loop=this.loop.bind(this),requestAnimationFrame(this.loop)}return Le(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,$t(this.canvas);var n=new Date().getTime(),o=n-this.lastUpdated,i=this.canvas.offsetHeight,s=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(a){return a.processShapes({timeDelta:o,currentTime:n},i,s),s?!a.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(n)}},{key:"queueAnimationFrameIfNeeded",value:function(n){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=n||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=sn(n),i=o.confettiRadius,s=o.confettiNumber,a=o.confettiColors,r=o.emojis,l=o.emojiSize,c=this.canvas.getBoundingClientRect(),d=c.width,u=c.height,h=u*5/7,f={x:0,y:h},k={x:d,y:h},p=new an(this.canvasContext),_=0;_<s/2;_++){var b=new ut({initialPosition:f,direction:"right",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d}),w=new ut({initialPosition:k,direction:"left",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d});p.addShapes(b,w)}return this.activeConfettiBatches.push(p),this.queueAnimationFrameIfNeeded(),p.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const cn=new ln,Ne=3,un=({onRetry:t})=>{const{config:e,currentScore:n,gamePlayState:o,setGamePlayState:i,gameProgress:s,setGameProgress:a}=te(),{i18n:r,levelConfig:l}=e,[c,d,u]=n,{foodCollected:h,totalFoodCount:f,playerAtExit:k,levelTransitioning:p}=o,{currentLevel:_}=s,[b,w]=U(!1);R(()=>{k&&p&&(cn.addConfetti(),G.show(r.levelCompleteToast),w(!0))},[k,p]);const M=ne(l),C=M.getTotalLevels(),z=J(()=>_>=C,[_,C]),S=()=>{w(!1),G.show(r.levelRestartToast),t?.()},E=()=>{w(!1),i(g=>({...g,isGameActive:!0,levelTransitioning:!1}))},L=()=>{w(!1);const g=M.getNextLevelInfo(_);if(!g)return;const{nextLevel:v,nextTier:T,isTierChange:N}=g;N&&G.show(r.tierUnlockedToast.replace("%TIER%",T.toString())),a(I=>({...I,currentLevel:v,currentTier:T,highestUnlockedLevel:Math.max(I.highestUnlockedLevel,v),highestUnlockedTier:Math.max(I.highestUnlockedTier,T),levelScores:{...I.levelScores,[I.currentLevel]:Math.max(Object.values(n).filter(Boolean).length,I.levelScores[I.currentLevel]||0)}}))},y=()=>{w(!1),a(g=>{const v=Math.max(Object.values(n).filter(Boolean).length,g.levelScores[g.currentLevel]||0),T={...g.levelScores,[g.currentLevel]:v};let N=0,I=0;const O=Object.entries(T).sort((x,$)=>Number(x[0])-Number($[0]));for(const[x,$]of O)if($<Ne){N=Number(x),I=M.getTierByLevel(N);break}return(N>0&&N!==_||v<Ne)&&G.show(r.notCompleteLevel),(N===0||v<Ne)&&t?.(),{...g,currentLevel:N||g.currentLevel,currentTier:I||g.currentTier,levelScores:T}})};return R(()=>{const g=document.querySelector(".maze-game-container"),v=T=>{b&&((T.key===" "||T.code==="Space")&&g&&(g.contains(document.activeElement)||document.activeElement===document.body)&&(T.preventDefault(),z?y():L()),(T.key==="r"||T.code==="KeyR")&&S(),(T.key==="c"||T.code==="KeyC")&&E())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b,z]),m(oe,{className:"level-complete-dialog",isOpen:b,title:r.congratulations,cancelText:r.retry+" (R)",onCancel:S,noConfirm:!!d,confirmText:r.continue+" (C)",onConfirm:E,confirmClass:"maze-continue-btn",children:[m("div",{className:"maze-summary-message",children:[!!c&&m("div",{children:"★ - "+r.findYourExit}),m("div",{children:u?"★ - "+r.withoutClue:"☆ - "+r.withClue}),m("div",{children:(d?"★ - "+r.collectAllStars:"☆ - "+r.notCollectAllStars)+` (${h}/${f})`})]}),z&&m("div",{className:"all-levels-completed",children:r.allLevelsCompleted}),m("div",{className:"maze-go-next",children:z?m("button",{className:"maze-go-next-btn",type:"button",onClick:y,children:[m("span",{children:r.lastOK}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]}):m("button",{className:"maze-go-next-btn",type:"button",onClick:L,children:[m("span",{children:r.nextLevel}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]})}),!d&&m("div",{className:"not-all-stars-collected",children:r.continueMessage})]})},dt=(t,e)=>{const n=D({canvasWidth:0,canvasHeight:0});return R(()=>{const o=()=>{const s=t.current;if(!s)return;const a=s.parentElement;if(!a)return;const r=a.clientWidth,l=window.devicePixelRatio||1;s.style.width=`${r}px`,s.style.height=`${r}px`;const c=r*l,d=r*l;s.width=c,s.height=d,n.current={canvasWidth:c,canvasHeight:d},e?.()};o();let i=null;return window.ResizeObserver&&t.current&&(i=new ResizeObserver(o),i.observe(t.current.parentElement)),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i?.disconnect()}},[t,e]),n},ht=(t,e,n)=>{const o=D({cellWidth:0,cellHeight:0});return R(()=>{const i=()=>{const a=t.current,r=e.maze;if(!a||!r)return;const{rows:l,cols:c}=r;if(l<=0||c<=0)return;const d=(a.width-n*2)/c,u=(a.height-n*2)/l;o.current={cellWidth:d,cellHeight:u}};i();let s=null;return t.current&&window.ResizeObserver&&(s=new ResizeObserver(i),s.observe(t.current)),()=>{t.current&&s?.disconnect()}},[t,e.maze,n]),o},fe={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},ft=({containerRef:t,gamePlayStateRef:e,setGamePlayState:n,moveSpeed:o,moveSpeedRef:i,playerRadius:s,onFoodCollected:a,onExitReached:r,onFirstMove:l})=>{const c=()=>i?.current??o??.03,d=D(!1),u=D(new Set),h=D(!1),f=tt((C,z)=>{const S=e.current;if(!S.maze)return{canMove:!1,newCell:null};const E=c(),[L,y]=fe[C];if(mt(z,L,y,s,E,S.maze))return{canMove:!1,newCell:null};const{row:v,col:T}=z,N=v+L*E,I=T+y*E,O=-.5,x=S.maze.rows,$=S.maze.cols;if(N<O||N>=x||I<O||I>=$)return{canMove:!1,newCell:null};const V=v<0?0:Math.floor(v),X=T<0?0:Math.floor(T),j=N<0?0:Math.floor(N),q=I<0?0:Math.floor(I);return j!==V||q!==X?S.maze.isValid(j,q)?{canMove:!0,newCell:{row:j,col:q}}:{canMove:!1,newCell:null}:{canMove:!0,newCell:null}},[s,c]),k=()=>{const C=e.current,{row:z,col:S}=C.playerCell,E=s*2,L=C.foodCells.findIndex(v=>Math.sqrt(Math.pow(z-v.row,2)+Math.pow(S-v.col,2))<E);L!==-1&&a&&(a(),e.current={...e.current,foodCollected:e.current.foodCollected+1,foodCells:e.current.foodCells.filter((v,T)=>T!==L)});const g=fn(C.playerCell,C.exitCell,C.maze);g&&!e.current.playerAtExit?(e.current={...e.current,playerAtExit:!0,isGameActive:!1,levelTransitioning:!0},r&&r(),requestIdleCallback(()=>{n(()=>({...e.current}))},{timeout:10})):!g&&e.current.playerAtExit&&(e.current={...e.current,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1})},p=C=>{const z=e.current,S=Math.round(C.row),E=Math.round(C.col),L=z.playerPath[z.playerPath.length-1],y=L.row===S&&L.col===E,g=Math.abs(L.row-S),v=Math.abs(L.col-E);if((g===1&&v===0||g===0&&v===1)&&!y){const N=`${L.row},${L.col}-${S},${E}`;e.current={...e.current,playerPath:[...e.current.playerPath,{row:S,col:E}],visitCounts:{...e.current.visitCounts,[N]:(e.current.visitCounts[N]||0)+1}}}},_=()=>{if(d.current||u.current.size===0)return;const C=e.current;!C.playerCell||!Array.from(u.current).some(S=>{const{canMove:E}=f(S,C.playerCell);return E})||(!h.current&&l&&(h.current=!0,l()),d.current=!0)};R(()=>{const C=y=>{if(y.key==="ArrowUp"||y.key==="ArrowDown"||y.key==="ArrowLeft"||y.key==="ArrowRight"||y.key===" "){const g=document.activeElement;if(g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.getAttribute("contenteditable")==="true"))return;y.preventDefault()}},z=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),e.current.isGameActive&&(u.current.has(g)||(u.current.add(g),d.current||_())))},S=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),u.current.delete(g),u.current.size===0&&w())},E=y=>{y.preventDefault();const g=e.current;if(!g.isGameActive||!g.maze||d.current)return;const v=y.touches[0],T=document.elementFromPoint(v.clientX,v.clientY);let N=null;T&&(T.classList.contains("maze-up")?N="ArrowUp":T.classList.contains("maze-down")?N="ArrowDown":T.classList.contains("maze-left")?N="ArrowLeft":T.classList.contains("maze-right")&&(N="ArrowRight")),N&&(u.current.clear(),u.current.add(N),_())},L=()=>{w()};return window.addEventListener("keydown",C,{capture:!0}),window.addEventListener("keydown",z),window.addEventListener("keyup",S),t.current?.addEventListener("touchstart",E,{passive:!1}),t.current?.addEventListener("touchend",L),()=>{window.removeEventListener("keydown",C,{capture:!0}),window.removeEventListener("keydown",z),window.removeEventListener("keyup",S),t.current?.removeEventListener("touchstart",E),t.current?.removeEventListener("touchend",L)}},[]);const b=tt(()=>{if(!d.current||u.current.size===0)return e.current.playerCell;const C=c(),z=e.current.playerCell;let S=0,E=0,L=0;for(const Z of u.current){const{canMove:Me}=f(Z,z);if(Me){const[Ct,xn]=fe[Z];S+=Ct,E+=xn,L++}}if(L===0)return e.current.playerCell;const y=Math.sqrt(S*S+E*E),g=y>0?S/y:0,v=y>0?E/y:0,T=Number((z.row+g*C).toFixed(2)),N=Number((z.col+v*C).toFixed(2)),I=T-z.row,O=N-z.col,x=Math.sqrt(I*I+O*O);if(x>0){const Z=I/x,Me=O/x;if(mt(z,Z,Me,s,x,e.current.maze))return e.current.playerCell}e.current.playerCell={row:T,col:N},k();const $=z.row<0?0:Math.round(z.row),V=z.col<0?0:Math.round(z.col),X=T<0?0:Math.round(T),j=N<0?0:Math.round(N);return(X!==$||j!==V)&&p({row:X,col:j}),e.current.playerCell},[c,f]),w=()=>{d.current=!1,u.current.clear()};return{updatePlayerPos:b,resetMovingState:w,resetFirstMoveState:()=>{h.current=!1}}};function mt(t,e,n,o,i,s){const a=t.row+e*i,r=t.col+n*i,l={row:a,col:r},c=[],d=t.row<0?0:Math.floor(t.row),u=t.col<0?0:Math.floor(t.col);c.push({row:d,col:u});const h=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[f,k]of h){const p=d+f,_=u+k;s.isValid(p,_)&&c.push({row:p,col:_})}for(const f of c){const k=dn(f.row,f.col,s);for(const p of k)if(hn(l,p)<o)return!0}return!1}function dn(t,e,n){const o=[],i=n.grid[t][e];return i.walls.top&&o.push({start:{row:t-.5,col:e-.5},end:{row:t-.5,col:e+.5}}),i.walls.right&&o.push({start:{row:t-.5,col:e+.5},end:{row:t+.5,col:e+.5}}),i.walls.bottom&&o.push({start:{row:t+.5,col:e-.5},end:{row:t+.5,col:e+.5}}),i.walls.left&&o.push({start:{row:t-.5,col:e-.5},end:{row:t+.5,col:e-.5}}),o}function hn(t,e){const{start:n,end:o}=e,i=o.col-n.col,s=o.row-n.row,a=t.col-n.col,r=t.row-n.row,l=i*i+s*s;if(l===0)return Math.sqrt(a*a+r*r);const c=Math.max(0,Math.min(1,(a*i+r*s)/l)),d=n.col+c*i,u=n.row+c*s,h=t.col-d,f=t.row-u;return Math.sqrt(h*h+f*f)}function fn(t,e,n){if(!n.isValid(e.row,e.col))return!1;const o=t.col>=e.col-.5&&t.col<=e.col+.5,i=t.row>=e.row+.5,s=t.row>=e.row-.5;return o&&i&&s}function _t(t,e,n,o,i){if(!t||!e.maze)return;const{canvasWidth:s,canvasHeight:a}=n,{cellWidth:r,cellHeight:l}=o,{maze:c,playerCell:d,exitCell:u,foodCells:h,showClue:f,playerPath:k,visitCounts:p}=e,{padding:_,wallWidth:b,wallColor:w,playerColor:M,playerRadius:C,foodColor:z,backgroundColor:S,clueColor:E,exitColor:L,exitWallWidth:y,exitDashArray:g}=i;t.clearRect(0,0,s,a),t.save(),t.fillStyle=S,t.fillRect(0,0,s,a),t.restore(),f&&wn({ctx:t,playerPath:k,visitCounts:p,cellWidth:r,cellHeight:l,padding:_,clueColor:E}),mn({ctx:t,maze:c,cellWidth:r,cellHeight:l,padding:_,wallColor:w,wallWidth:b}),vn({ctx:t,maze:c,exitCell:u,cellWidth:r,cellHeight:l,padding:_,exitColor:L,exitWallWidth:y,exitDashArray:g}),gn({ctx:t,foodCells:h,cellWidth:r,cellHeight:l,padding:_,foodColor:z}),_n({ctx:t,playerCell:d,playerRadius:C,cellWidth:r,cellHeight:l,padding:_,playerColor:M})}function mn({ctx:t,maze:e,cellWidth:n,cellHeight:o,padding:i,wallColor:s,wallWidth:a}){t.save(),t.strokeStyle=s,t.lineWidth=a,t.lineCap="round",t.beginPath(),Cn(e,n,o,i).forEach(l=>{t.moveTo(l.x1,l.y1),t.lineTo(l.x2,l.y2)}),t.stroke(),t.restore()}function _n({ctx:t,playerCell:e,playerRadius:n,cellWidth:o,cellHeight:i,padding:s,playerColor:a}){const{x:r,y:l}=me(e.row,e.col,o,i,s),c=Math.min(o,i)*Math.min(n,.5);t.save(),t.fillStyle=a,t.beginPath(),t.arc(r,l,c,0,Math.PI*2),t.fill(),t.restore()}function vn({ctx:t,maze:e,exitCell:n,cellWidth:o,cellHeight:i,padding:s,exitColor:a,exitWallWidth:r,exitDashArray:l=[8,12]}){const{row:c,col:d}=n;if(!e.isValid(c,d))return;const u=s+d*o,h=s+c*i;t.save(),t.globalCompositeOperation="destination-out",t.lineWidth=r,t.lineCap="round",t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.globalCompositeOperation="source-over",t.strokeStyle=a,t.lineWidth=r,t.setLineDash(l),t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.restore()}function gn({ctx:t,foodCells:e,cellWidth:n,cellHeight:o,padding:i,foodColor:s}){t.fillStyle=s;const a=Math.min(n,o)*.25;e.forEach(r=>{const{x:l,y:c}=me(r.row,r.col,n,o,i);pn(t,l,c,a*1.2,5,a*.6)})}function pn(t,e,n,o,i,s){t.save(),t.beginPath();for(let a=0;a<i*2;a++){const r=a%2===0?o:s,l=Math.PI*a/i;t.lineTo(e+r*Math.sin(l),n+r*Math.cos(l))}t.closePath(),t.fill(),t.restore()}function wn({ctx:t,playerPath:e,visitCounts:n,cellWidth:o,cellHeight:i,padding:s,clueColor:a}){if(!(!e||e.length<2||!n)){t.save();for(let r=1;r<e.length;r++){const l=e[r-1],c=e[r],d=`${l.row},${l.col}-${c.row},${c.col}`,u=`${c.row},${c.col}-${l.row},${l.col}`,h=(n[d]||0)+(n[u]||0),f=Math.min(.2+h*.1,.9),k=Math.max(3,o*.1)+h*.5;try{t.strokeStyle=a.replace(")",`, ${f})`).replace("rgb(","rgba(")}catch{t.strokeStyle=`rgba(255, 0, 0, ${f})`}t.lineWidth=k,t.lineCap="round",t.lineJoin="round";const{x:p,y:_}=me(l.row,l.col,o,i,s),{x:b,y:w}=me(c.row,c.col,o,i,s);t.beginPath(),t.moveTo(p,_),t.lineTo(b,w),t.stroke()}t.restore()}}function Cn(t,e,n,o){const i=[];for(let s=0;s<t.rows;s++)for(let a=0;a<t.cols;a++){const r=t.grid[s][a],l=o+a*e,c=o+s*n;r.walls.top&&i.push({x1:l,y1:c,x2:l+e,y2:c}),r.walls.right&&i.push({x1:l+e,y1:c,x2:l+e,y2:c+n}),r.walls.bottom&&i.push({x1:l,y1:c+n,x2:l+e,y2:c+n}),r.walls.left&&i.push({x1:l,y1:c,x2:l,y2:c+n})}return i}function me(t,e,n,o,i){return{x:i+e*n+n/2,y:i+t*o+o/2}}function yn(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}class bn{constructor(e,n){this.row=e,this.col=n}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class vt{rows;cols;grid;seed;random;constructor(e,n,o,i,s={row:0,col:0},a={row:e-1,col:n-1}){this.rows=e,this.cols=n,this.seed=i??Math.floor(Math.random()*1e6),this.random=yn(this.seed),this.grid=this.initializeGrid(),this.generate(o,s,a)}initializeGrid(){const e=[];for(let n=0;n<this.rows;n++){e[n]=[];for(let o=0;o<this.cols;o++)e[n][o]=new bn(n,o)}return e}isValid(e,n){return e>=0&&e<this.rows&&n>=0&&n<this.cols}getNeighbors(e,n){const o=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const s of i){const a=e+s.r,r=n+s.c;this.isValid(a,r)&&o.push({row:a,col:r})}return o}getUnvisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>!this.grid[o.row][o.col].visited)}getVisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>this.grid[o.row][o.col].visited)}removeWall(e,n,o,i){const s=this.grid[e][n],a=this.grid[o][i];e===o+1?(s.walls.top=!1,a.walls.bottom=!1):e===o-1?(s.walls.bottom=!1,a.walls.top=!1):n===i+1?(s.walls.left=!1,a.walls.right=!1):n===i-1&&(s.walls.right=!1,a.walls.left=!1)}generate(e,n={row:0,col:0},o={row:this.rows-1,col:this.cols-1}){switch(e){case"backtracking":this.generateWithBacktracking();break;case"prims":this.generateWithPrims();break;default:throw new Error(`Unknown maze generation method: ${e}`)}this.addOpenings(n,o)}generateWithBacktracking(){const e=[],n=this.randomNumber(this.rows),o=this.randomNumber(this.cols);let i={row:n,col:o};for(this.grid[n][o].visited=!0,e.push(i);e.length>0;){i=e[e.length-1];const{row:s,col:a}=i,r=this.getUnvisitedNeighbors(s,a);if(r.length>0){const l=this.randomPick(r),{row:c,col:d}=l;this.removeWall(s,a,c,d),this.grid[c][d].visited=!0,e.push(l)}else e.pop()}}generateWithPrims(){const e=[],n=(s,a)=>{const r=this.getNeighbors(s,a);for(const l of r)!this.grid[l.row][l.col].visited&&!e.some(c=>c.row===l.row&&c.col===l.col)&&e.push(l)},o=this.randomNumber(this.rows),i=this.randomNumber(this.cols);for(this.grid[o][i].visited=!0,n(o,i);e.length>0;){const s=this.randomNumber(e.length),a=e[s],{row:r,col:l}=a,c=this.getVisitedNeighbors(r,l);if(c.length>0){const d=this.randomPick(c);this.removeWall(r,l,d.row,d.col),this.grid[r][l].visited=!0,n(r,l)}e.splice(s,1)}}addOpenings(e,n){this.grid[e.row][e.col].walls.top=!1,this.isValid(n.row,n.col)&&(this.grid[n.row][n.col].walls.bottom=!1)}randomNumber(e){return Math.floor(this.random()*e)}randomPick(e){return e[Math.floor(this.random()*e.length)]}}const gt=(t,e,n)=>{if(!t.isValid(e,n))return!1;const o=t.grid[e][n];return!o.walls.top||!o.walls.right||!o.walls.bottom||!o.walls.left},Tn=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6,kn=(t,e)=>{if(!e)return console.error(`Cannot find Level ${t}'s config.`),null;const{size:n,seed:o,method:i,entry:s,exit:a}=e,r=n,l=n,c=s||{row:0,col:0},d=a||{row:r-1,col:l-1},u=new vt(r,l,i,o,c,d),h=Tn(t),f=[];for(let k=0;k<h;k++){let p;do p={row:Math.floor(u.random()*r),col:Math.floor(u.random()*l)};while(p.row===c.row&&p.col===c.col||p.row===d.row&&p.col===d.col||!gt(u,p.row,p.col)||f.some(_=>_.row===p.row&&_.col===p.col));f.push(p)}return{isGameActive:!0,levelTransitioning:!1,maze:u,playerCell:c,exitCell:d,foodCells:f,playerAtExit:!1,foodCollected:0,totalFoodCount:h,showClue:!1,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1}}},Sn=({size:t,seed:e,method:n,foodCount:o})=>{const i=t,s=t,a={row:0,col:0},r={row:i-1,col:s-1},l=new vt(i,s,n,e,a,r),c=[];for(let d=0;d<o;d++){let u,h=0;do u={row:Math.floor(l.random()*i),col:Math.floor(l.random()*s)},h++;while(h<50&&(u.row===a.row&&u.col===a.col||u.row===r.row&&u.col===r.col||!gt(l,u.row,u.col)||c.some(f=>f.row===u.row&&f.col===u.col)));h<50&&c.push(u)}return{isGameActive:!0,levelTransitioning:!1,maze:l,playerCell:a,exitCell:r,foodCells:c,playerAtExit:!1,foodCollected:0,totalFoodCount:o}};function zn(){const{setGamePlayState:t,gamePlayState:e,gamePlayStateRef:n,gameProgress:o,config:i}=te(),s=D(null),a=D(null),{i18n:r,levelConfig:l,renderConfig:c}=i,d=ne(l),u=D(d.getLevelConfig(o.currentLevel));R(()=>{s.current&&G.attachTo(s.current)},[]);const h=D(),f=dt(a,()=>{h.current?.()}),k=ht(a,e,c.padding);R(()=>{u.current=d.getLevelConfig(o.currentLevel)},[o.currentLevel]);const p=()=>{const M=kn(o.currentLevel,u.current);M&&t(C=>({...C,...M}))};R(()=>{p()},[o.currentLevel]);const _=()=>{p()},{updatePlayerPos:b,resetMovingState:w}=ft({containerRef:s,gamePlayStateRef:n,setGamePlayState:t,playerRadius:c.playerRadius,moveSpeed:c.gridMoveSpeed,onFoodCollected:()=>{const M=n.current.totalFoodCount-n.current.foodCollected-1;M>0?G.show(r.foodCollectedToast.replace("%NUM%",M.toString()),3e3):G.show(r.allFoodCollectedToast)}});return R(()=>{w()},[o.currentLevel,w]),R(()=>{let M,C=!document.hidden;const z=()=>{const L=a.current?.getContext("2d"),y=n.current;if(!(C&&y?.isGameActive&&L&&y?.maze)){M=requestAnimationFrame(z);return}b(),S(),M=requestAnimationFrame(z)},S=()=>{const L=a.current?.getContext("2d"),y=n.current;if(L&&y?.maze){const g=u.current?.wallWidth||c?.wallWidth,v=u.current?.exitColor||c?.exitColor,T=u.current?.exitWallWidth||c?.exitWallWidth,N=u.current?.exitDashArray||c?.exitDashArray;_t(L,y,f.current,k.current,{...c,wallWidth:g,exitColor:v,exitWallWidth:T,exitDashArray:N})}};h.current=S;const E=L=>{const y=C;C=!document.hidden&&document.visibilityState==="visible"&&(!L||L.type!=="blur"),!y&&C?n.current?.levelTransitioning===!1&&t({...n.current,isGameActive:!0}):y&&!C&&t({...n.current,isGameActive:!1})};return document.addEventListener("visibilitychange",E),window.addEventListener("blur",E),window.addEventListener("focus",E),M=requestAnimationFrame(z),()=>{cancelAnimationFrame(M),document.removeEventListener("visibilitychange",E),window.removeEventListener("blur",E),window.removeEventListener("focus",E)}},[]),R(()=>{G.show(r.useArrowKeyTips,3e3)},[]),m("div",{className:"maze-game-container",children:[m(Dt,{}),m(un,{onRetry:_}),m("div",{className:"maze-canvas-container",ref:s,children:[m("canvas",{ref:a,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]})]})}const En=t=>{const e=Math.floor(t/60),n=t%60;return`${e.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`},Ln=({timer:t,onTimeUp:e})=>{const[n,o]=U(t),i=D(),s=D(!1);return R(()=>{const a=()=>{!s.current&&!i.current&&(s.current=!0,i.current=setInterval(()=>{o(l=>l<=1?(clearInterval(i.current),e(),0):l-1)},1e3))},r=()=>{clearInterval(i.current),i.current=void 0};return window.addEventListener("maze:firstMove",a),window.addEventListener("maze:gameSuccess",r),()=>{window.removeEventListener("maze:firstMove",a),window.removeEventListener("maze:gameSuccess",r),clearInterval(i.current)}},[]),R(()=>{i.current&&(clearInterval(i.current),i.current=void 0),o(t),s.current=!1},[t]),m("div",{className:"single-maze-timer",children:m("span",{className:`maze-timer-text ${n<=10&&s.current?"maze-timer-warning":""}`,children:["⏱️ ",En(n)]})})};function Nn({config:t}){const{size:e,seed:n,method:o,foodCount:i,renderConfig:s,successCallback:a,failCallback:r,timer:l,i18n:c}=t,[d,u]=U({...ze}),[h,f]=U(!1),[k,p]=U(!1),[_,b]=U(!1),[w,M]=U(""),C=D(null),z=D(null),S=D(d),E=D(),L=dt(C,()=>{E.current?.()}),y=ht(C,d,s.padding);R(()=>{S.current=d},[d]);const{updatePlayerPos:g,resetMovingState:v,resetFirstMoveState:T}=ft({containerRef:z,gamePlayStateRef:S,setGamePlayState:u,playerRadius:s.playerRadius,moveSpeed:s.gridMoveSpeed,onFoodCollected:()=>{console.log("Food collected in single maze")},onExitReached:()=>{k||I()},onFirstMove:()=>{window.dispatchEvent(new CustomEvent("maze:firstMove"))}}),N=()=>{p(!0),M(`⏰ ${c.failMsg}`),b(!0),u(x=>({...x,isGameActive:!1})),r&&r()},I=()=>{p(!0),M(`🎉 ${c.successMsg}`),b(!0),window.dispatchEvent(new CustomEvent("maze:gameSuccess")),a&&a()},O=()=>{b(!1)};return R(()=>{(async()=>{f(!0);try{const $=Sn({size:e,seed:n,method:o,foodCount:i});S.current=$,u($)}catch($){console.error("Error generating single maze:",$)}finally{f(!1)}})()},[t]),R(()=>{let x;const $=!document.hidden,V=()=>{const j=C.current?.getContext("2d"),q=S.current;if(!($&&q?.isGameActive&&j&&q?.maze)){x=requestAnimationFrame(V);return}g(),X(),x=requestAnimationFrame(V)},X=()=>{const j=C.current?.getContext("2d"),q=S.current;j&&q?.maze&&_t(j,q,L.current,y.current,s)};return E.current=X,x=requestAnimationFrame(V),()=>{cancelAnimationFrame(x)}},[]),R(()=>{v(),T()},[t,v,T]),h?m("div",{className:"single-maze-loading",children:m("div",{children:"Generating maze..."})}):d?m("div",{className:"maze-game-container",children:[m(Ln,{timer:l,onTimeUp:N}),m("div",{className:"single-maze-canvas-container",ref:z,children:[m("canvas",{ref:C,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]}),m(oe,{isOpen:_,title:w,noConfirm:!0,cancelText:"OK",onCancel:O})]}):m("div",{className:"single-maze-error",children:m("div",{children:"Failed to generate maze"})})}const pt=[[{size:8,seed:12345,method:"backtracking",wallWidth:4,exitWallWidth:6,exitDashArray:[8,12]},{size:8,seed:23456,method:"backtracking",exitColor:"#33f",exitWallWidth:4,exitDashArray:[8,16]},{size:8,seed:34567,method:"prims"},{size:8,seed:45678,method:"backtracking"},{size:9,seed:56789,method:"prims"},{size:9,seed:67890,method:"backtracking"},{size:9,seed:78901,method:"prims"},{size:9,seed:89012,method:"backtracking"},{size:10,seed:90123,method:"prims"},{size:11,seed:11111,method:"backtracking"},{size:12,seed:22222,method:"prims"},{size:13,seed:33333,method:"backtracking"}],[{size:12,seed:44444,method:"prims"},{size:12,seed:55555,method:"backtracking"},{size:12,seed:66666,method:"prims"},{size:12,seed:77777,method:"backtracking"},{size:13,seed:88888,method:"prims"},{size:13,seed:99999,method:"backtracking"},{size:13,seed:12121,method:"prims"},{size:14,seed:23232,method:"backtracking"},{size:15,seed:34343,method:"prims"},{size:16,seed:45454,method:"backtracking"},{size:17,seed:56565,method:"prims"},{size:18,seed:67676,method:"backtracking"}],[{size:19,seed:78787,method:"prims"},{size:20,seed:89898,method:"backtracking"},{size:21,seed:90909,method:"prims"},{size:22,seed:10101,method:"backtracking"},{size:23,seed:20202,method:"prims"},{size:25,seed:30303,method:"backtracking"},{size:27,seed:40404,method:"prims"},{size:29,seed:50505,method:"backtracking"},{size:31,seed:60606,method:"prims"},{size:33,seed:70707,method:"backtracking"},{size:37,seed:80808,method:"prims"},{size:40,seed:90909,method:"backtracking"}],[{size:41,seed:10111,method:"prims"},{size:42,seed:11121,method:"backtracking"},{size:43,seed:12131,method:"prims"},{size:44,seed:13141,method:"backtracking"},{size:45,seed:14151,method:"prims"},{size:46,seed:15161,method:"backtracking"},{size:47,seed:16171,method:"prims"},{size:48,seed:17181,method:"backtracking"},{size:49,seed:18191,method:"prims"},{size:50,seed:19201,method:"backtracking"},{size:51,seed:20211,method:"prims"},{size:52,seed:21221,method:"backtracking"}],[{size:53,seed:22231,method:"prims"},{size:54,seed:23241,method:"backtracking"},{size:55,seed:24251,method:"prims"},{size:56,seed:25261,method:"backtracking"},{size:57,seed:26271,method:"prims"},{size:58,seed:27281,method:"backtracking"},{size:59,seed:28291,method:"prims"},{size:60,seed:29301,method:"backtracking"},{size:62,seed:30311,method:"prims"},{size:64,seed:31321,method:"backtracking"},{size:66,seed:32331,method:"prims"},{size:68,seed:33341,method:"backtracking"}]],wt={gridMoveSpeed:.07,padding:10,wallWidth:2,wallColor:"#000000",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerRadius:.2,exitColor:"#F44336",exitWallWidth:4,exitDashArray:[8,12]},_e={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",congratulations:"Congratulations!",findYourExit:"Find your exit!",withoutClue:"Without clue!",withClue:"You used the clue!",collectAllStars:"Collect all stars!",notCollectAllStars:"Not collect all stars.",nextLevel:"Next Level ➤",spacebarTip:"Spacebar",retry:"Retry",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",allLevelsCompleted:"You completed all levels!",lastOK:"OK",notCompleteLevel:"You still have levels not collected all stars! Try again to collect them all!",continueMessage:"You still have levels where you haven't collected all stars. Try again to collect them all!",continue:"Continue",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:wt,levelConfig:pt},ve={i18n:{successMsg:"Congratulations! You completed the maze!",failMsg:"Time is up!",restart:"Restart"},size:8,seed:12345,method:"backtracking",foodCount:3,renderConfig:wt,timer:10*60,successCallback:()=>{console.log("🎉 Single maze completed successfully!")},failCallback:()=>{console.log("⏰ Time is up! Game failed.")}};function Mn({config:t={}}){const e={..._e.i18n,...t.i18n||{}},n={..._e.renderConfig,...t.renderConfig||{}},o=t.levelConfig||pt,i={..._e,...t,i18n:e,levelConfig:o,renderConfig:n};return m(xt,{config:i,children:m(zn,{})})}function An({config:t={}}){const e={...ve.i18n,...t.i18n||{}},n={...ve.renderConfig,...t.renderConfig||{}},o={...ve,...t,i18n:e,renderConfig:n};return m(Nn,{config:o})}const Pn={root:"https://unpkg.com/@roudanio/maze@0.2.1/dist/",..._e};`${JSON.stringify(Pn,null,2)}`;const In={root:"https://unpkg.com/@roudanio/maze@0.2.1/dist/",...ve};return`${JSON.stringify(In,(t,e)=>typeof e=="function"?e.toString():e,2)}`,{showNotice(){console.warn("Cannot find the root element");const t=document.createElement("div");t.style.textAlign="center",t.style.padding="20px",t.innerHTML="Cannot find the root element",document.body.append(t)},addLoadingIndicator(t){const e=document.createElement("div"),n=document.createElement("div");e.style.cssText=`
1
+ var Maze=function(){"use strict";var re,A,Ae,B,Pe,Ie,xe,Re,ge,pe,Ce,Fe,Q={},De=[],yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function we(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function bt(t,e,n){var o,i,s,a={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?re.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)a[s]==null&&(a[s]=t.defaultProps[s]);return se(t,a,o,i,null)}function se(t,e,n,o,i){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ae,__i:-1,__u:0};return i==null&&A.vnode!=null&&A.vnode(s),s}function ae(t){return t.children}function le(t,e){this.props=t,this.context=e}function Y(t,e){if(e==null)return t.__?Y(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Y(t):null}function Oe(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Oe(t)}}function ye(t){(!t.__d&&(t.__d=!0)&&B.push(t)&&!ce.__r++||Pe!=A.debounceRendering)&&((Pe=A.debounceRendering)||Ie)(ce)}function ce(){for(var t,e,n,o,i,s,a,r=1;B.length;)B.length>r&&B.sort(xe),t=B.shift(),r=B.length,t.__d&&(n=void 0,i=(o=(e=t).__v).__e,s=[],a=[],e.__P&&((n=H({},o)).__v=o.__v+1,A.vnode&&A.vnode(n),be(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[i]:null,s,i??Y(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,je(s,n,a),n.__e!=i&&Oe(n)));ce.__r=0}function $e(t,e,n,o,i,s,a,r,l,c,d){var u,h,f,k,p,_,b=o&&o.__k||De,C=e.length;for(l=Tt(n,e,b,l,C),u=0;u<C;u++)(f=n.__k[u])!=null&&(h=f.__i==-1?Q:b[f.__i]||Q,f.__i=u,_=be(t,f,h,i,s,a,r,l,c,d),k=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Te(h.ref,null,f),d.push(f.ref,f.__c||k,f)),p==null&&k!=null&&(p=k),4&f.__u||h.__k===f.__k?l=Ue(f,l,t):typeof f.type=="function"&&_!==void 0?l=_:k&&(l=k.nextSibling),f.__u&=-7);return n.__e=p,l}function Tt(t,e,n,o,i){var s,a,r,l,c,d=n.length,u=d,h=0;for(t.__k=new Array(i),s=0;s<i;s++)(a=e[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(l=s+h,(a=t.__k[s]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?se(null,a,null,null,null):ie(a)?se(ae,{children:a},null,null,null):a.constructor==null&&a.__b>0?se(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,r=null,(c=a.__i=kt(a,n,l,u))!=-1&&(u--,(r=n[c])&&(r.__u|=2)),r==null||r.__v==null?(c==-1&&(i>d?h--:i<d&&h++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,a.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<d;s++)(r=n[s])!=null&&(2&r.__u)==0&&(r.__e==o&&(o=Y(r)),He(r,r));return o}function Ue(t,e,n){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Ue(o[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=Y(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function kt(t,e,n,o){var i,s,a=t.key,r=t.type,l=e[n];if(l===null&&t.key==null||l&&a==l.key&&r==l.type&&(2&l.__u)==0)return n;if(o>(l!=null&&(2&l.__u)==0?1:0))for(i=n-1,s=n+1;i>=0||s<e.length;){if(i>=0){if((l=e[i])&&(2&l.__u)==0&&a==l.key&&r==l.type)return i;i--}if(s<e.length){if((l=e[s])&&(2&l.__u)==0&&a==l.key&&r==l.type)return s;s++}}return-1}function Ge(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||yt.test(e)?n:n+"px"}function ue(t,e,n,o,i){var s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Ge(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Ge(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Re,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?o?n.u=o.u:(n.u=ge,t.addEventListener(e,s?Ce:pe,s)):t.removeEventListener(e,s?Ce:pe,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ge++;else if(e.t<n.u)return;return n(A.event?A.event(e):e)}}}function be(t,e,n,o,i,s,a,r,l,c){var d,u,h,f,k,p,_,b,C,M,w,z,S,E,L,y,g,v=e.type;if(e.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),s=[r=e.__e=n.__e]),(d=A.__b)&&d(e);e:if(typeof v=="function")try{if(b=e.props,C="prototype"in v&&v.prototype.render,M=(d=v.contextType)&&o[d.__c],w=d?M?M.props.value:d.__:o,n.__c?_=(u=e.__c=n.__c).__=u.__E:(C?e.__c=u=new v(b,w):(e.__c=u=new le(b,w),u.constructor=v,u.render=zt),M&&M.sub(u),u.props=b,u.state||(u.state={}),u.context=w,u.__n=o,h=u.__d=!0,u.__h=[],u._sb=[]),C&&u.__s==null&&(u.__s=u.state),C&&v.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=H({},u.__s)),H(u.__s,v.getDerivedStateFromProps(b,u.__s))),f=u.props,k=u.state,u.__v=e,h)C&&v.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),C&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(C&&v.getDerivedStateFromProps==null&&b!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,w),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,w)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(u.props=b,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(T){T&&(T.__=e)}),z=0;z<u._sb.length;z++)u.__h.push(u._sb[z]);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,w),C&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,k,p)})}if(u.context=w,u.props=b,u.__P=t,u.__e=!1,S=A.__r,E=0,C){for(u.state=u.__s,u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),L=0;L<u._sb.length;L++)u.__h.push(u._sb[L]);u._sb=[]}else do u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++E<25);u.state=u.__s,u.getChildContext!=null&&(o=H(H({},o),u.getChildContext())),C&&!h&&u.getSnapshotBeforeUpdate!=null&&(p=u.getSnapshotBeforeUpdate(f,k)),y=d,d!=null&&d.type===ae&&d.key==null&&(y=qe(d.props.children)),r=$e(t,ie(y)?y:[y],e,n,o,i,s,a,r,l,c),u.base=e.__e,e.__u&=-161,u.__h.length&&a.push(u),_&&(u.__E=u.__=null)}catch(T){if(e.__v=null,l||s!=null)if(T.then){for(e.__u|=l?160:128;r&&r.nodeType==8&&r.nextSibling;)r=r.nextSibling;s[s.indexOf(r)]=null,e.__e=r}else for(g=s.length;g--;)we(s[g]);else e.__e=n.__e,e.__k=n.__k;A.__e(T,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):r=e.__e=St(n.__e,e,n,o,i,s,a,l,c);return(d=A.diffed)&&d(e),128&e.__u?void 0:r}function je(t,e,n){for(var o=0;o<n.length;o++)Te(n[o],n[++o],n[++o]);A.__c&&A.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){A.__e(s,i.__v)}})}function qe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:ie(t)?t.map(qe):H({},t)}function St(t,e,n,o,i,s,a,r,l){var c,d,u,h,f,k,p,_=n.props,b=e.props,C=e.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!C&&(C?f.localName==C:f.nodeType==3)){t=f,s[c]=null;break}}if(t==null){if(C==null)return document.createTextNode(b);t=document.createElementNS(i,C,b.is&&b),r&&(A.__m&&A.__m(e,s),r=!1),s=null}if(C==null)_===b||r&&t.data==b||(t.data=b);else{if(s=s&&re.call(t.childNodes),_=n.props||Q,!r&&s!=null)for(_={},c=0;c<t.attributes.length;c++)_[(f=t.attributes[c]).name]=f.value;for(c in _)if(f=_[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=f;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;ue(t,c,null,f,i)}}for(c in b)f=b[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?d=f:c=="value"?k=f:c=="checked"?p=f:r&&typeof f!="function"||_[c]===f||ue(t,c,f,_[c],i);if(d)r||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),$e(e.type=="template"?t.content:t,ie(h)?h:[h],e,n,o,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&Y(n,0),r,l),s!=null)for(c=s.length;c--;)we(s[c]);r||(c="value",C=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[c]||C=="progress"&&!k||C=="option"&&k!=_[c])&&ue(t,c,k,_[c],i),c="checked",p!=null&&p!=t[c]&&ue(t,c,p,_[c],i))}return t}function Te(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){A.__e(i,n)}}function He(t,e,n){var o,i;if(A.unmount&&A.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||Te(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){A.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&He(o[i],e,n||typeof t.type!="function");n||we(t.__e),t.__c=t.__=t.__e=void 0}function zt(t,e,n){return this.constructor(t,n)}function Be(t,e,n){var o,i,s,a;e==document&&(e=document.documentElement),A.__&&A.__(t,e),i=(o=!1)?null:e.__k,s=[],a=[],be(e,t=e.__k=bt(ae,null,[t]),i||Q,Q,e.namespaceURI,i?null:e.firstChild?re.call(e.childNodes):null,s,i?i.__e:e.firstChild,o,a),je(s,t,a)}function Et(t){function e(n){var o,i;return this.getChildContext||(o=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,ye(a)})},this.sub=function(s){o.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),a&&a.call(s)}}),n.children}return e.__c="__cC"+Fe++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,o){return n.children(o)}).contextType=e,e}re=De.slice,A={__e:function(t,e,n,o){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,o||{}),a=i.__d),a)return i.__E=i}catch(r){t=r}throw t}},Ae=0,le.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ye(this))},le.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ye(this))},le.prototype.render=ae,B=[],Ie=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xe=function(t,e){return t.__v.__b-e.__v.__b},ce.__r=0,Re=/(PointerCapture)$|Capture$/i,ge=0,pe=We(!1),Ce=We(!0),Fe=0;var Lt=0;function m(t,e,n,o,i,s){e||(e={});var a,r,l=e;if("ref"in l)for(r in l={},e)r=="ref"?a=e[r]:l[r]=e[r];var c={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lt,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(a=t.defaultProps))for(r in a)l[r]===void 0&&(l[r]=a[r]);return A.vnode&&A.vnode(c),c}var K,P,ke,Ve,ee=0,Xe=[],F=A,Ye=F.__b,Ke=F.__r,Je=F.diffed,Ze=F.__c,Qe=F.unmount,et=F.__;function de(t,e){F.__h&&F.__h(P,t,ee||e),ee=0;var n=P.__H||(P.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function U(t){return ee=1,Nt(rt,t)}function Nt(t,e,n){var o=de(K++,2);if(o.t=t,!o.__c&&(o.__=[rt(void 0,e),function(r){var l=o.__N?o.__N[0]:o.__[0],c=o.t(l,r);l!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=P,!P.__f)){var i=function(r,l,c){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(h){return!!h.__c});if(d.every(function(h){return!h.__N}))return!s||s.call(this,r,l,c);var u=o.__c.props!==r;return d.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(u=!0)}}),s&&s.call(this,r,l,c)||u};P.__f=!0;var s=P.shouldComponentUpdate,a=P.componentWillUpdate;P.componentWillUpdate=function(r,l,c){if(this.__e){var d=s;s=void 0,i(r,l,c),s=d}a&&a.call(this,r,l,c)},P.shouldComponentUpdate=i}return o.__N||o.__}function R(t,e){var n=de(K++,3);!F.__s&&ot(n.__H,e)&&(n.__=t,n.u=e,P.__H.__h.push(n))}function D(t){return ee=5,J(function(){return{current:t}},[])}function J(t,e){var n=de(K++,7);return ot(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function tt(t,e){return ee=8,J(function(){return t},e)}function Mt(t){var e=P.context[t.__c],n=de(K++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(P)),e.props.value):t.__}function At(){for(var t;t=Xe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(he),t.__H.__h.forEach(Se),t.__H.__h=[]}catch(e){t.__H.__h=[],F.__e(e,t.__v)}}F.__b=function(t){P=null,Ye&&Ye(t)},F.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),et&&et(t,e)},F.__r=function(t){Ke&&Ke(t),K=0;var e=(P=t.__c).__H;e&&(ke===P?(e.__h=[],P.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(he),e.__h.forEach(Se),e.__h=[],K=0)),ke=P},F.diffed=function(t){Je&&Je(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Xe.push(e)!==1&&Ve===F.requestAnimationFrame||((Ve=F.requestAnimationFrame)||Pt)(At)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ke=P=null},F.__c=function(t,e){e.some(function(n){try{n.__h.forEach(he),n.__h=n.__h.filter(function(o){return!o.__||Se(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],F.__e(o,n.__v)}}),Ze&&Ze(t,e)},F.unmount=function(t){Qe&&Qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{he(o)}catch(i){e=i}}),n.__H=void 0,e&&F.__e(e,n.__v))};var nt=typeof requestAnimationFrame=="function";function Pt(t){var e,n=function(){clearTimeout(o),nt&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,100);nt&&(e=requestAnimationFrame(n))}function he(t){var e=P,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),P=e}function Se(t){var e=P;t.__c=t.__(),P=e}function ot(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function rt(t,e){return typeof e=="function"?e(t):e}const It=t=>({saveGameData(e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error("Failed to save maze game data:",n)}},loadGameData(){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset maze game data:",e)}}}),it=Et(void 0),st={currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,levelScores:{},totalScore:0},ze={isGameActive:!0,levelTransitioning:!1,maze:null,playerCell:{row:0,col:0},exitCell:{row:0,col:0},foodCells:[],playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,playerPath:[],visitCounts:{}},xt=({children:t,config:e})=>{const n=It(e.lcPrefix+"progress"),o=n.loadGameData(),[i,s]=U(()=>o||{...st});R(()=>{const u=Object.values(i.levelScores).reduce((h,f)=>h+f,0);s(h=>({...h,totalScore:u}))},[i.levelScores]),R(()=>{n.saveGameData(i)},[i.currentLevel,i.highestUnlockedLevel,i.currentTier,i.highestUnlockedTier,i.levelScores,i.totalScore]);const[a,r]=U({...ze}),l=D(a);R(()=>{l.current=a},[a]);const c=J(()=>[a.playerAtExit?1:0,a.foodCollected===a.totalFoodCount?1:0,a.showClue?0:1],[a.playerAtExit,a.foodCollected,a.totalFoodCount,a.showClue]),d=()=>{n.resetGameData(),s({...st}),r({...ze})};return m(it.Provider,{value:{gameProgress:i,setGameProgress:s,gamePlayState:a,setGamePlayState:r,gamePlayStateRef:l,currentScore:c,config:e,resetGame:d},children:t})},te=()=>{const t=Mt(it);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t},ne=t=>J(()=>{const e=t.map(r=>r.length),n=e.reduce((r,l)=>r+l,0),o=t.length,i=r=>{if(r<1||r>n)return 0;let l=0;for(let c=0;c<e.length;c++)if(l+=e[c],r<=l)return c+1;return 0},s=r=>r<1||r>o?0:e.slice(0,r-1).reduce((l,c)=>l+c,0)+1,a={getTotalLevels:()=>n,getTotalTiers:()=>o,getTierLevelsRange:r=>{if(r<1||r>o)return[0,0];const l=s(r),c=l+e[r-1]-1;return[l,c]},getTierByLevel:i,getFirstLevelOfTier:s,getLevelConfig:r=>{if(r<1||r>n)return null;const l=i(r),c=s(l),d=r-c;return t[l-1][d]},getTierConfig:r=>r<1||r>o?null:t[r-1],isLevelUnlocked:(r,l)=>r<=l,isTierUnlocked:(r,l)=>r<=l,getNextLevelInfo:r=>{if(r>=n)return null;const l=r+1,c=i(r),d=i(l);return{nextLevel:l,nextTier:d,isTierChange:d>c}},getCurrentTierProgress:(r,l)=>{const[c,d]=a.getTierLevelsRange(l),u=r-c+1,h=d-c+1;return{current:u,total:h}},isLastLevelInTier:r=>{const l=i(r),[,c]=a.getTierLevelsRange(l);return r===c},getPreviousLevelInfo:r=>{if(r<=1)return null;const l=r-1,c=i(r),d=i(l);return{prevLevel:l,prevTier:d,isTierChange:d<c}}};return a},[t]),Rt=({onTierChange:t,disabled:e})=>{const{gameProgress:n,config:o}=te(),{i18n:i,levelConfig:s}=o,{currentTier:a,highestUnlockedTier:r}=n,c=ne(s).getTotalTiers();return m("div",{className:"tier-selector",children:m("select",{value:a,onChange:d=>{d.target&&d.target.value&&t(Number(d.target.value))},disabled:e,className:"tier-dropdown",children:Array.from({length:c},(d,u)=>u+1).map(d=>m("option",{value:d,disabled:d>r,children:i.tier+" "+d},`tier-${d}`))})})},Ft=({onLevelChange:t,disabled:e})=>{const{gameProgress:n,config:o}=te(),{i18n:i,levelConfig:s}=o,{currentTier:a,levelScores:r,currentLevel:l,highestUnlockedLevel:c}=n,d=ne(s),u=J(()=>{const[h,f]=d.getTierLevelsRange(a);return Array.from({length:f-h+1},(k,p)=>{const _=h+p,b=r[_]||0;return{level:_,score:b}})},[a,r]);return m("div",{className:"level-selector",children:m("select",{value:l,onChange:h=>{h.target&&h.target.value&&t(Number(h.target.value))},disabled:e,className:"level-dropdown",children:u.map(({level:h,score:f})=>m("option",{value:h,disabled:h>c,children:`${i.level} ${h} ${"★".repeat(f)}`},`level-${h}`))})})},oe=({isOpen:t,title:e,className:n="",message:o,children:i,noConfirm:s=!1,noCancel:a=!1,confirmText:r="OK",cancelText:l="Cancel",confirmClass:c="",cancelClass:d="",onConfirm:u,onCancel:h})=>{const f=D(null);return R(()=>{const k=p=>{p.key==="Escape"&&h?.()};return t&&document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[t,h]),m("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:m("div",{className:"maze-dialog "+n,ref:f,children:[m("div",{className:"maze-dialog-title",children:e}),m("div",{className:"maze-dialog-content",children:i||m("div",{className:"maze-dialog-message",children:o})}),(!a||!s)&&m("div",{className:"maze-dialog-buttons",children:[!a&&m("button",{type:"button",className:"maze-dialog-cancel "+d,onClick:h,children:l}),!s&&m("button",{type:"button",className:"maze-dialog-confirm "+c,onClick:u,children:r})]})]})})},G={container:null,attachTo(t){return this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=document.createElement("div"),this.container.className="toast-container position-bottom",t.appendChild(this.container),this.container},currentToast:null,currentTimer:null,show(t,e=2e3){if(!this.container){console.warn("NativeToast: container not initialized, please call attachTo first");return}this.currentToast&&this.container.contains(this.currentToast)&&(this.container.removeChild(this.currentToast),this.currentToast=null),this.currentTimer&&(clearTimeout(this.currentTimer),this.currentTimer=null);const n=document.createElement("div");n.className="toast-message toast-visible",n.textContent=t,this.container.appendChild(n),this.currentToast=n,this.currentTimer=setTimeout(()=>{n.classList.remove("toast-visible"),setTimeout(()=>{this.container&&this.container.contains(n)&&(this.container.removeChild(n),this.currentToast===n&&(this.currentToast=null))},300),this.currentTimer=null},e)},clearAll(){if(this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}},Dt=()=>{const{gameProgress:t,setGameProgress:e,gamePlayState:n,setGamePlayState:o,gamePlayStateRef:i,resetGame:s,config:a}=te(),{i18n:r,levelConfig:l}=a,c=ne(l),{levelTransitioning:d,showClue:u}=n,{highestUnlockedLevel:h,totalScore:f}=t,k=c.getTotalLevels(),[p,_]=U(!1),[b,C]=U(!1),[M,w]=U(!1),z=O=>{const x=c.getFirstLevelOfTier(O);c.isLevelUnlocked(x,h)&&(e($=>({...$,currentTier:O})),S(x))},S=O=>{c.isLevelUnlocked(O,h)&&(e(x=>({...x,currentLevel:O})),G.show(r.levelGoToast.replace("%LEVEL%",O.toString())))},E=()=>{_(!0)},L=()=>{_(!1)},y=()=>{w(!0)},g=()=>{w(!1)},v=()=>{G.show(u?r.cluePathDisabled:r.cluePathEnabled),o(()=>({...i.current,showClue:!i.current.showClue})),w(!1)},T=()=>{C(!0)},N=()=>{s(),C(!1),G.show(r.resetDoneToast)},I=()=>{C(!1)};return m("div",{class:"game-panel-container",children:[m("div",{className:"game-controls",children:[m("div",{className:"selectors-container",children:[m(Rt,{onTierChange:z,disabled:d}),m(Ft,{onLevelChange:S,disabled:d})]}),m("button",{className:`settings-clue-button ${u?"clue-on":"clue-off"}`,disabled:u,title:"Toggle Clue",onClick:y,children:u?r.clueOn:r.clueOff})]}),m("div",{className:"game-settings",children:m("span",{className:"game-settings-icon",onClick:E,children:"★ "+f})}),m(oe,{isOpen:p,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:L,children:[m("div",{className:"settings-stats",children:[m("div",{children:r.levelComplete+`: ${h}/${k}`}),m("div",{children:r.starsCollected+": "+f}),m("div",{children:r.avgStarPerLevel+": "+(f/h).toFixed(2)})]}),m("div",{className:"settings-item-box",children:[m("button",{className:"settings-reset-button",title:"Reset Game",onClick:T,children:r.reset}),m("div",{className:"settings-item-tip",children:r.resetTip})]})]}),m(oe,{isOpen:b,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:N,onCancel:I}),m(oe,{isOpen:M,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:v,onCancel:g})]})};function Ee(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function Le(t,e,n){return e&&Ot(t.prototype,e),t}function at(t){return+t.replace(/px/,"")}function $t(t){var e=window.devicePixelRatio,n=getComputedStyle(t),o=at(n.getPropertyValue("width")),i=at(n.getPropertyValue("height"));t.setAttribute("width",(o*e).toString()),t.setAttribute("height",(i*e).toString())}function W(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=Math.random()*(e-t)+t;return Math.floor(o*Math.pow(10,n))/Math.pow(10,n)}function lt(t){return t[W(0,t.length)]}var Ut=.00125,Gt=5e-4,Wt=9e-4,jt=1e-5,qt=6,Ht=80,Bt=.9,Vt=1.7,Xt=.2,Yt=.6,Kt=.03,Jt=.07,Zt=15,Qt=82,en=100,tn=250,nn=40,on=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function ct(t){var e=1920;return Math.log(t)/Math.log(e)}var ut=function(){function t(e){Ee(this,t);var n=e.initialPosition,o=e.direction,i=e.confettiRadius,s=e.confettiColors,a=e.emojis,r=e.emojiSize,l=e.canvasWidth,c=W(Bt,Vt,3),d=c*ct(l);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=W(Xt,Yt,3),this.rotationSpeed=a.length?.01:W(Kt,Jt,3)*ct(l),this.dragForceCoefficient=W(Gt,Wt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=o==="left"?W(0,.2,3):W(-.2,0,3),this.emojiSize=r,this.emojiRotationAngle=W(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=o==="left"?W(Qt,Zt)*Math.PI/180:W(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var h=W(-150,0),f={x:n.x+(o==="left"?-h:h)*this.absCos,y:n.y-h*this.absSin};this.currentPosition=Object.assign({},f),this.initialPosition=Object.assign({},f),this.color=a.length?null:lt(s),this.emoji=a.length?lt(a):null,this.createdAt=new Date().getTime(),this.direction=o}return Le(t,[{key:"draw",value:function(n){var o=this.currentPosition,i=this.radius,s=this.color,a=this.emoji,r=this.rotationAngle,l=this.emojiRotationAngle,c=this.emojiSize,d=window.devicePixelRatio;s?(n.fillStyle=s,n.beginPath(),n.ellipse(o.x*d,o.y*d,i.x*d,i.y*d,r,0,2*Math.PI),n.fill()):a&&(n.font="".concat(c,"px serif"),n.save(),n.translate(d*o.x,d*o.y),n.rotate(l),n.textAlign="center",n.fillText(a,0,0),n.restore())}},{key:"updatePosition",value:function(n,o){var i=this.confettiSpeed,s=this.dragForceCoefficient,a=this.finalConfettiSpeedX,r=this.radiusYUpdateDirection,l=this.rotationSpeed,c=this.createdAt,d=this.direction,u=o-c;if(i.x>a&&(this.confettiSpeed.x-=s*n),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*n,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+Ut*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:jt*n,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*n%(2*Math.PI);return}r==="down"?(this.radius.y-=n*l,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=n*l,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(n){return this.currentPosition.y<n+en}}]),t}();function rn(){var t=document.createElement("canvas");return t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.zIndex="1000",t.style.pointerEvents="none",document.body.appendChild(t),t}function sn(t){var e=t.confettiRadius,n=e===void 0?qt:e,o=t.confettiNumber,i=o===void 0?t.confettiesNumber||(t.emojis?nn:tn):o,s=t.confettiColors,a=s===void 0?on:s,r=t.emojis,l=r===void 0?t.emojies||[]:r,c=t.emojiSize,d=c===void 0?Ht:c;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:n,confettiNumber:i,confettiColors:a,emojis:l,emojiSize:d}}var an=function(){function t(e){var n=this;Ee(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(o){return n.resolvePromise=o})}return Le(t,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var n;(n=this.shapes).push.apply(n,arguments)}},{key:"complete",value:function(){var n;return this.shapes.length?!1:((n=this.resolvePromise)===null||n===void 0||n.call(this),!0)}},{key:"processShapes",value:function(n,o,i){var s=this,a=n.timeDelta,r=n.currentTime;this.shapes=this.shapes.filter(function(l){return l.updatePosition(a,r),l.draw(s.canvasContext),i?l.getIsVisibleOnCanvas(o):!0})}}]),t}(),ln=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ee(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||rn(),this.canvasContext=this.canvas.getContext("2d"),this.requestAnimationFrameRequested=!1,this.lastUpdated=new Date().getTime(),this.iterationIndex=0,this.loop=this.loop.bind(this),requestAnimationFrame(this.loop)}return Le(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,$t(this.canvas);var n=new Date().getTime(),o=n-this.lastUpdated,i=this.canvas.offsetHeight,s=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(a){return a.processShapes({timeDelta:o,currentTime:n},i,s),s?!a.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(n)}},{key:"queueAnimationFrameIfNeeded",value:function(n){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=n||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=sn(n),i=o.confettiRadius,s=o.confettiNumber,a=o.confettiColors,r=o.emojis,l=o.emojiSize,c=this.canvas.getBoundingClientRect(),d=c.width,u=c.height,h=u*5/7,f={x:0,y:h},k={x:d,y:h},p=new an(this.canvasContext),_=0;_<s/2;_++){var b=new ut({initialPosition:f,direction:"right",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d}),C=new ut({initialPosition:k,direction:"left",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d});p.addShapes(b,C)}return this.activeConfettiBatches.push(p),this.queueAnimationFrameIfNeeded(),p.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const cn=new ln,Ne=3,un=({onRetry:t})=>{const{config:e,currentScore:n,gamePlayState:o,setGamePlayState:i,gameProgress:s,setGameProgress:a}=te(),{i18n:r,levelConfig:l}=e,[c,d,u]=n,{foodCollected:h,totalFoodCount:f,playerAtExit:k,levelTransitioning:p}=o,{currentLevel:_}=s,[b,C]=U(!1);R(()=>{k&&p&&(cn.addConfetti(),G.show(r.levelCompleteToast),C(!0))},[k,p]);const M=ne(l),w=M.getTotalLevels(),z=J(()=>_>=w,[_,w]),S=()=>{C(!1),G.show(r.levelRestartToast),t?.()},E=()=>{C(!1),i(g=>({...g,isGameActive:!0,levelTransitioning:!1}))},L=()=>{C(!1);const g=M.getNextLevelInfo(_);if(!g)return;const{nextLevel:v,nextTier:T,isTierChange:N}=g;N&&G.show(r.tierUnlockedToast.replace("%TIER%",T.toString())),a(I=>({...I,currentLevel:v,currentTier:T,highestUnlockedLevel:Math.max(I.highestUnlockedLevel,v),highestUnlockedTier:Math.max(I.highestUnlockedTier,T),levelScores:{...I.levelScores,[I.currentLevel]:Math.max(Object.values(n).filter(Boolean).length,I.levelScores[I.currentLevel]||0)}}))},y=()=>{C(!1),a(g=>{const v=Math.max(Object.values(n).filter(Boolean).length,g.levelScores[g.currentLevel]||0),T={...g.levelScores,[g.currentLevel]:v};let N=0,I=0;const O=Object.entries(T).sort((x,$)=>Number(x[0])-Number($[0]));for(const[x,$]of O)if($<Ne){N=Number(x),I=M.getTierByLevel(N);break}return(N>0&&N!==_||v<Ne)&&G.show(r.notCompleteLevel),(N===0||v<Ne)&&t?.(),{...g,currentLevel:N||g.currentLevel,currentTier:I||g.currentTier,levelScores:T}})};return R(()=>{const g=document.querySelector(".maze-game-container"),v=T=>{b&&((T.key===" "||T.code==="Space")&&g&&(g.contains(document.activeElement)||document.activeElement===document.body)&&(T.preventDefault(),z?y():L()),(T.key==="r"||T.code==="KeyR")&&S(),(T.key==="c"||T.code==="KeyC")&&E())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b,z]),m(oe,{className:"level-complete-dialog",isOpen:b,title:r.congratulations,cancelText:r.retry+" (R)",onCancel:S,noConfirm:!!d,confirmText:r.continue+" (C)",onConfirm:E,confirmClass:"maze-continue-btn",children:[m("div",{className:"maze-summary-message",children:[!!c&&m("div",{children:"★ - "+r.findYourExit}),m("div",{children:u?"★ - "+r.withoutClue:"☆ - "+r.withClue}),m("div",{children:(d?"★ - "+r.collectAllStars:"☆ - "+r.notCollectAllStars)+` (${h}/${f})`})]}),z&&m("div",{className:"all-levels-completed",children:r.allLevelsCompleted}),m("div",{className:"maze-go-next",children:z?m("button",{className:"maze-go-next-btn",type:"button",onClick:y,children:[m("span",{children:r.lastOK}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]}):m("button",{className:"maze-go-next-btn",type:"button",onClick:L,children:[m("span",{children:r.nextLevel}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]})}),!d&&m("div",{className:"not-all-stars-collected",children:r.continueMessage})]})},dt=(t,e)=>{const n=D({canvasWidth:0,canvasHeight:0});return R(()=>{const o=()=>{const s=t.current;if(!s)return;const a=s.parentElement;if(!a)return;const r=a.clientWidth,l=window.devicePixelRatio||1;s.style.width=`${r}px`,s.style.height=`${r}px`;const c=r*l,d=r*l;s.width=c,s.height=d,n.current={canvasWidth:c,canvasHeight:d},e?.()};o();let i=null;return window.ResizeObserver&&t.current&&(i=new ResizeObserver(o),i.observe(t.current.parentElement)),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i?.disconnect()}},[t,e]),n},ht=(t,e,n)=>{const o=D({cellWidth:0,cellHeight:0});return R(()=>{const i=()=>{const a=t.current,r=e.maze;if(!a||!r)return;const{rows:l,cols:c}=r;if(l<=0||c<=0)return;const d=(a.width-n*2)/c,u=(a.height-n*2)/l;o.current={cellWidth:d,cellHeight:u}};i();let s=null;return t.current&&window.ResizeObserver&&(s=new ResizeObserver(i),s.observe(t.current)),()=>{t.current&&s?.disconnect()}},[t,e.maze,n]),o},fe={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},ft=({containerRef:t,gamePlayStateRef:e,setGamePlayState:n,moveSpeed:o,moveSpeedRef:i,playerRadius:s,onFoodCollected:a,onExitReached:r,onFirstMove:l})=>{const c=()=>i?.current??o??.03,d=D(!1),u=D(new Set),h=D(!1),f=tt((w,z)=>{const S=e.current;if(!S.maze)return{canMove:!1,newCell:null};const E=c(),[L,y]=fe[w];if(mt(z,L,y,s,E,S.maze))return{canMove:!1,newCell:null};const{row:v,col:T}=z,N=v+L*E,I=T+y*E,O=-.5,x=S.maze.rows,$=S.maze.cols;if(N<O||N>=x||I<O||I>=$)return{canMove:!1,newCell:null};const V=v<0?0:Math.floor(v),X=T<0?0:Math.floor(T),j=N<0?0:Math.floor(N),q=I<0?0:Math.floor(I);return j!==V||q!==X?S.maze.isValid(j,q)?{canMove:!0,newCell:{row:j,col:q}}:{canMove:!1,newCell:null}:{canMove:!0,newCell:null}},[s,c]),k=()=>{const w=e.current,{row:z,col:S}=w.playerCell,E=s*2,L=w.foodCells.findIndex(v=>Math.sqrt(Math.pow(z-v.row,2)+Math.pow(S-v.col,2))<E);L!==-1&&a&&(a(),e.current={...e.current,foodCollected:e.current.foodCollected+1,foodCells:e.current.foodCells.filter((v,T)=>T!==L)});const g=fn(w.playerCell,w.exitCell,w.maze);g&&!e.current.playerAtExit?(e.current={...e.current,playerAtExit:!0,isGameActive:!1,levelTransitioning:!0},r&&r(),requestIdleCallback(()=>{n(()=>({...e.current}))},{timeout:10})):!g&&e.current.playerAtExit&&(e.current={...e.current,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1})},p=w=>{const z=e.current,S=Math.round(w.row),E=Math.round(w.col),L=z.playerPath?.[z.playerPath.length-1],y=L?.row===S&&L?.col===E,g=Math.abs(L?.row??0-S),v=Math.abs(L?.col??0-E);if((g===1&&v===0||g===0&&v===1)&&!y){const N=`${L?.row},${L?.col}-${S},${E}`;e.current={...e.current,playerPath:[...e.current.playerPath??[],{row:S,col:E}],visitCounts:{...e.current.visitCounts,[N]:(e.current.visitCounts?.[N]||0)+1}}}},_=()=>{if(d.current||u.current.size===0)return;const w=e.current;!w.playerCell||!Array.from(u.current).some(S=>{const{canMove:E}=f(S,w.playerCell);return E})||(!h.current&&l&&(h.current=!0,l()),d.current=!0)};R(()=>{const w=y=>{if(y.key==="ArrowUp"||y.key==="ArrowDown"||y.key==="ArrowLeft"||y.key==="ArrowRight"||y.key===" "){const g=document.activeElement;if(g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.getAttribute("contenteditable")==="true"))return;y.preventDefault()}},z=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),e.current.isGameActive&&(u.current.has(g)||(u.current.add(g),d.current||_())))},S=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),u.current.delete(g),u.current.size===0&&C())},E=y=>{y.preventDefault();const g=e.current;if(!g.isGameActive||!g.maze||d.current)return;const v=y.touches[0],T=document.elementFromPoint(v.clientX,v.clientY);let N=null;T&&(T.classList.contains("maze-up")?N="ArrowUp":T.classList.contains("maze-down")?N="ArrowDown":T.classList.contains("maze-left")?N="ArrowLeft":T.classList.contains("maze-right")&&(N="ArrowRight")),N&&(u.current.clear(),u.current.add(N),_())},L=()=>{C()};return window.addEventListener("keydown",w,{capture:!0}),window.addEventListener("keydown",z),window.addEventListener("keyup",S),t.current?.addEventListener("touchstart",E,{passive:!1}),t.current?.addEventListener("touchend",L),()=>{window.removeEventListener("keydown",w,{capture:!0}),window.removeEventListener("keydown",z),window.removeEventListener("keyup",S),t.current?.removeEventListener("touchstart",E),t.current?.removeEventListener("touchend",L)}},[]);const b=tt(()=>{if(!d.current||u.current.size===0)return e.current.playerCell;const w=c(),z=e.current.playerCell;let S=0,E=0,L=0;for(const Z of u.current){const{canMove:Me}=f(Z,z);if(Me){const[wt,xn]=fe[Z];S+=wt,E+=xn,L++}}if(L===0)return e.current.playerCell;const y=Math.sqrt(S*S+E*E),g=y>0?S/y:0,v=y>0?E/y:0,T=Number((z.row+g*w).toFixed(2)),N=Number((z.col+v*w).toFixed(2)),I=T-z.row,O=N-z.col,x=Math.sqrt(I*I+O*O);if(x>0){const Z=I/x,Me=O/x;if(mt(z,Z,Me,s,x,e.current.maze))return e.current.playerCell}e.current.playerCell={row:T,col:N},k();const $=z.row<0?0:Math.round(z.row),V=z.col<0?0:Math.round(z.col),X=T<0?0:Math.round(T),j=N<0?0:Math.round(N);return(X!==$||j!==V)&&p({row:X,col:j}),e.current.playerCell},[c,f]),C=()=>{d.current=!1,u.current.clear()};return{updatePlayerPos:b,resetMovingState:C,resetFirstMoveState:()=>{h.current=!1}}};function mt(t,e,n,o,i,s){const a=t.row+e*i,r=t.col+n*i,l={row:a,col:r},c=[],d=t.row<0?0:Math.floor(t.row),u=t.col<0?0:Math.floor(t.col);c.push({row:d,col:u});const h=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[f,k]of h){const p=d+f,_=u+k;s.isValid(p,_)&&c.push({row:p,col:_})}for(const f of c){const k=dn(f.row,f.col,s);for(const p of k)if(hn(l,p)<o)return!0}return!1}function dn(t,e,n){const o=[],i=n.grid[t][e];return i.walls.top&&o.push({start:{row:t-.5,col:e-.5},end:{row:t-.5,col:e+.5}}),i.walls.right&&o.push({start:{row:t-.5,col:e+.5},end:{row:t+.5,col:e+.5}}),i.walls.bottom&&o.push({start:{row:t+.5,col:e-.5},end:{row:t+.5,col:e+.5}}),i.walls.left&&o.push({start:{row:t-.5,col:e-.5},end:{row:t+.5,col:e-.5}}),o}function hn(t,e){const{start:n,end:o}=e,i=o.col-n.col,s=o.row-n.row,a=t.col-n.col,r=t.row-n.row,l=i*i+s*s;if(l===0)return Math.sqrt(a*a+r*r);const c=Math.max(0,Math.min(1,(a*i+r*s)/l)),d=n.col+c*i,u=n.row+c*s,h=t.col-d,f=t.row-u;return Math.sqrt(h*h+f*f)}function fn(t,e,n){if(!n.isValid(e.row,e.col))return!1;const o=t.col>=e.col-.5&&t.col<=e.col+.5,i=t.row>=e.row+.5,s=t.row>=e.row-.5;return o&&i&&s}function _t(t,e,n,o,i){if(!t||!e.maze)return;const{canvasWidth:s,canvasHeight:a}=n,{cellWidth:r,cellHeight:l}=o,{maze:c,playerCell:d,exitCell:u,foodCells:h,showClue:f,playerPath:k,visitCounts:p}=e,{padding:_,wallWidth:b,wallColor:C,playerColor:M,playerRadius:w,foodColor:z,backgroundColor:S,clueColor:E,exitColor:L,exitWallWidth:y,exitDashArray:g}=i;t.clearRect(0,0,s,a),t.save(),t.fillStyle=S,t.fillRect(0,0,s,a),t.restore(),f&&Cn({ctx:t,playerPath:k??[],visitCounts:p??{},cellWidth:r,cellHeight:l,padding:_,clueColor:E}),mn({ctx:t,maze:c,cellWidth:r,cellHeight:l,padding:_,wallColor:C,wallWidth:b}),vn({ctx:t,maze:c,exitCell:u,cellWidth:r,cellHeight:l,padding:_,exitColor:L,exitWallWidth:y,exitDashArray:g}),gn({ctx:t,foodCells:h,cellWidth:r,cellHeight:l,padding:_,foodColor:z}),_n({ctx:t,playerCell:d,playerRadius:w,cellWidth:r,cellHeight:l,padding:_,playerColor:M})}function mn({ctx:t,maze:e,cellWidth:n,cellHeight:o,padding:i,wallColor:s,wallWidth:a}){t.save(),t.strokeStyle=s,t.lineWidth=a,t.lineCap="round",t.beginPath(),wn(e,n,o,i).forEach(l=>{t.moveTo(l.x1,l.y1),t.lineTo(l.x2,l.y2)}),t.stroke(),t.restore()}function _n({ctx:t,playerCell:e,playerRadius:n,cellWidth:o,cellHeight:i,padding:s,playerColor:a}){const{x:r,y:l}=me(e.row,e.col,o,i,s),c=Math.min(o,i)*Math.min(n,.5);t.save(),t.fillStyle=a,t.beginPath(),t.arc(r,l,c,0,Math.PI*2),t.fill(),t.restore()}function vn({ctx:t,maze:e,exitCell:n,cellWidth:o,cellHeight:i,padding:s,exitColor:a,exitWallWidth:r,exitDashArray:l=[8,12]}){const{row:c,col:d}=n;if(!e.isValid(c,d))return;const u=s+d*o,h=s+c*i;t.save(),t.globalCompositeOperation="destination-out",t.lineWidth=r,t.lineCap="round",t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.globalCompositeOperation="source-over",t.strokeStyle=a,t.lineWidth=r,t.setLineDash(l),t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.restore()}function gn({ctx:t,foodCells:e,cellWidth:n,cellHeight:o,padding:i,foodColor:s}){t.fillStyle=s;const a=Math.min(n,o)*.25;e.forEach(r=>{const{x:l,y:c}=me(r.row,r.col,n,o,i);pn(t,l,c,a*1.2,5,a*.6)})}function pn(t,e,n,o,i,s){t.save(),t.beginPath();for(let a=0;a<i*2;a++){const r=a%2===0?o:s,l=Math.PI*a/i;t.lineTo(e+r*Math.sin(l),n+r*Math.cos(l))}t.closePath(),t.fill(),t.restore()}function Cn({ctx:t,playerPath:e,visitCounts:n,cellWidth:o,cellHeight:i,padding:s,clueColor:a}){if(!(!e||e.length<2||!n)){t.save();for(let r=1;r<e.length;r++){const l=e[r-1],c=e[r],d=`${l.row},${l.col}-${c.row},${c.col}`,u=`${c.row},${c.col}-${l.row},${l.col}`,h=(n[d]||0)+(n[u]||0),f=Math.min(.2+h*.1,.9),k=Math.max(3,o*.1)+h*.5;try{t.strokeStyle=a.replace(")",`, ${f})`).replace("rgb(","rgba(")}catch{t.strokeStyle=`rgba(255, 0, 0, ${f})`}t.lineWidth=k,t.lineCap="round",t.lineJoin="round";const{x:p,y:_}=me(l.row,l.col,o,i,s),{x:b,y:C}=me(c.row,c.col,o,i,s);t.beginPath(),t.moveTo(p,_),t.lineTo(b,C),t.stroke()}t.restore()}}function wn(t,e,n,o){const i=[];for(let s=0;s<t.rows;s++)for(let a=0;a<t.cols;a++){const r=t.grid[s][a],l=o+a*e,c=o+s*n;r.walls.top&&i.push({x1:l,y1:c,x2:l+e,y2:c}),r.walls.right&&i.push({x1:l+e,y1:c,x2:l+e,y2:c+n}),r.walls.bottom&&i.push({x1:l,y1:c+n,x2:l+e,y2:c+n}),r.walls.left&&i.push({x1:l,y1:c,x2:l,y2:c+n})}return i}function me(t,e,n,o,i){return{x:i+e*n+n/2,y:i+t*o+o/2}}function yn(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}class bn{constructor(e,n){this.row=e,this.col=n}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class vt{rows;cols;grid;seed;random;constructor(e,n,o,i,s={row:0,col:0},a={row:e-1,col:n-1}){this.rows=e,this.cols=n,this.seed=i??Math.floor(Math.random()*1e6),this.random=yn(this.seed),this.grid=this.initializeGrid(),this.generate(o,s,a)}initializeGrid(){const e=[];for(let n=0;n<this.rows;n++){e[n]=[];for(let o=0;o<this.cols;o++)e[n][o]=new bn(n,o)}return e}isValid(e,n){return e>=0&&e<this.rows&&n>=0&&n<this.cols}getNeighbors(e,n){const o=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const s of i){const a=e+s.r,r=n+s.c;this.isValid(a,r)&&o.push({row:a,col:r})}return o}getUnvisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>!this.grid[o.row][o.col].visited)}getVisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>this.grid[o.row][o.col].visited)}removeWall(e,n,o,i){const s=this.grid[e][n],a=this.grid[o][i];e===o+1?(s.walls.top=!1,a.walls.bottom=!1):e===o-1?(s.walls.bottom=!1,a.walls.top=!1):n===i+1?(s.walls.left=!1,a.walls.right=!1):n===i-1&&(s.walls.right=!1,a.walls.left=!1)}generate(e,n={row:0,col:0},o={row:this.rows-1,col:this.cols-1}){switch(e){case"backtracking":this.generateWithBacktracking();break;case"prims":this.generateWithPrims();break;default:throw new Error(`Unknown maze generation method: ${e}`)}this.addOpenings(n,o)}generateWithBacktracking(){const e=[],n=this.randomNumber(this.rows),o=this.randomNumber(this.cols);let i={row:n,col:o};for(this.grid[n][o].visited=!0,e.push(i);e.length>0;){i=e[e.length-1];const{row:s,col:a}=i,r=this.getUnvisitedNeighbors(s,a);if(r.length>0){const l=this.randomPick(r),{row:c,col:d}=l;this.removeWall(s,a,c,d),this.grid[c][d].visited=!0,e.push(l)}else e.pop()}}generateWithPrims(){const e=[],n=(s,a)=>{const r=this.getNeighbors(s,a);for(const l of r)!this.grid[l.row][l.col].visited&&!e.some(c=>c.row===l.row&&c.col===l.col)&&e.push(l)},o=this.randomNumber(this.rows),i=this.randomNumber(this.cols);for(this.grid[o][i].visited=!0,n(o,i);e.length>0;){const s=this.randomNumber(e.length),a=e[s],{row:r,col:l}=a,c=this.getVisitedNeighbors(r,l);if(c.length>0){const d=this.randomPick(c);this.removeWall(r,l,d.row,d.col),this.grid[r][l].visited=!0,n(r,l)}e.splice(s,1)}}addOpenings(e,n){this.grid[e.row][e.col].walls.top=!1,this.isValid(n.row,n.col)&&(this.grid[n.row][n.col].walls.bottom=!1)}randomNumber(e){return Math.floor(this.random()*e)}randomPick(e){return e[Math.floor(this.random()*e.length)]}}const gt=(t,e,n)=>{if(!t.isValid(e,n))return!1;const o=t.grid[e][n];return!o.walls.top||!o.walls.right||!o.walls.bottom||!o.walls.left},Tn=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6,kn=(t,e)=>{if(!e)return console.error(`Cannot find Level ${t}'s config.`),null;const{size:n,seed:o,method:i,entry:s,exit:a}=e,r=n,l=n,c=s||{row:0,col:0},d=a||{row:r-1,col:l-1},u=new vt(r,l,i,o,c,d),h=Tn(t),f=[];for(let k=0;k<h;k++){let p;do p={row:Math.floor(u.random()*r),col:Math.floor(u.random()*l)};while(p.row===c.row&&p.col===c.col||p.row===d.row&&p.col===d.col||!gt(u,p.row,p.col)||f.some(_=>_.row===p.row&&_.col===p.col));f.push(p)}return{isGameActive:!0,levelTransitioning:!1,maze:u,playerCell:c,exitCell:d,foodCells:f,playerAtExit:!1,foodCollected:0,totalFoodCount:h,showClue:!1,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1}}},Sn=({size:t,seed:e,method:n,foodCount:o})=>{const i=t,s=t,a={row:0,col:0},r={row:i-1,col:s-1},l=new vt(i,s,n,e,a,r),c=[];for(let d=0;d<o;d++){let u,h=0;do u={row:Math.floor(l.random()*i),col:Math.floor(l.random()*s)},h++;while(h<50&&(u.row===a.row&&u.col===a.col||u.row===r.row&&u.col===r.col||!gt(l,u.row,u.col)||c.some(f=>f.row===u.row&&f.col===u.col)));h<50&&c.push(u)}return{isGameActive:!0,levelTransitioning:!1,maze:l,playerCell:a,exitCell:r,foodCells:c,playerAtExit:!1,foodCollected:0,totalFoodCount:o}};function zn(){const{setGamePlayState:t,gamePlayState:e,gamePlayStateRef:n,gameProgress:o,config:i}=te(),s=D(null),a=D(null),{i18n:r,levelConfig:l,renderConfig:c}=i,d=ne(l),u=D(d.getLevelConfig(o.currentLevel));R(()=>{s.current&&G.attachTo(s.current)},[]);const h=D(),f=dt(a,()=>{h.current?.()}),k=ht(a,e,c.padding);R(()=>{u.current=d.getLevelConfig(o.currentLevel)},[o.currentLevel]);const p=()=>{const M=kn(o.currentLevel,u.current);M&&t(w=>({...w,...M}))};R(()=>{p()},[o.currentLevel]);const _=()=>{p()},{updatePlayerPos:b,resetMovingState:C}=ft({containerRef:s,gamePlayStateRef:n,setGamePlayState:t,playerRadius:c.playerRadius,moveSpeed:c.gridMoveSpeed,onFoodCollected:()=>{const M=n.current.totalFoodCount-n.current.foodCollected-1;M>0?G.show(r.foodCollectedToast.replace("%NUM%",M.toString()),3e3):G.show(r.allFoodCollectedToast)}});return R(()=>{C()},[o.currentLevel,C]),R(()=>{let M,w=!document.hidden;const z=()=>{const L=a.current?.getContext("2d"),y=n.current;if(!(w&&y?.isGameActive&&L&&y?.maze)){M=requestAnimationFrame(z);return}b(),S(),M=requestAnimationFrame(z)},S=()=>{const L=a.current?.getContext("2d"),y=n.current;if(L&&y?.maze){const g=u.current?.wallWidth||c?.wallWidth,v=u.current?.exitColor||c?.exitColor,T=u.current?.exitWallWidth||c?.exitWallWidth,N=u.current?.exitDashArray||c?.exitDashArray;_t(L,y,f.current,k.current,{...c,wallWidth:g,exitColor:v,exitWallWidth:T,exitDashArray:N})}};h.current=S;const E=L=>{const y=w;w=!document.hidden&&document.visibilityState==="visible"&&(!L||L.type!=="blur"),!y&&w?n.current?.levelTransitioning===!1&&t({...n.current,isGameActive:!0}):y&&!w&&t({...n.current,isGameActive:!1})};return document.addEventListener("visibilitychange",E),window.addEventListener("blur",E),window.addEventListener("focus",E),M=requestAnimationFrame(z),()=>{cancelAnimationFrame(M),document.removeEventListener("visibilitychange",E),window.removeEventListener("blur",E),window.removeEventListener("focus",E)}},[]),R(()=>{G.show(r.useArrowKeyTips,3e3)},[]),m("div",{className:"maze-game-container",children:[m(Dt,{}),m(un,{onRetry:_}),m("div",{className:"maze-canvas-container",ref:s,children:[m("canvas",{ref:a,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]})]})}const En=t=>{const e=Math.floor(t/60),n=t%60;return`${e.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`},Ln=({timer:t,onTimeUp:e})=>{const[n,o]=U(t),i=D(),s=D(!1);return R(()=>{const a=()=>{!s.current&&!i.current&&(s.current=!0,i.current=setInterval(()=>{o(l=>l<=1?(clearInterval(i.current),e(),0):l-1)},1e3))},r=()=>{clearInterval(i.current),i.current=void 0};return window.addEventListener("maze:firstMove",a),window.addEventListener("maze:gameSuccess",r),()=>{window.removeEventListener("maze:firstMove",a),window.removeEventListener("maze:gameSuccess",r),clearInterval(i.current)}},[]),R(()=>{i.current&&(clearInterval(i.current),i.current=void 0),o(t),s.current=!1},[t]),m("div",{className:"single-maze-timer",children:m("span",{className:`maze-timer-text ${n<=10&&s.current?"maze-timer-warning":""}`,children:["⏱️ ",En(n)]})})};function Nn({config:t}){const{size:e,seed:n,method:o,foodCount:i,renderConfig:s,successCallback:a,failCallback:r,timer:l,i18n:c}=t,[d,u]=U({...ze}),[h,f]=U(!1),[k,p]=U(!1),[_,b]=U(!1),[C,M]=U(""),w=D(null),z=D(null),S=D(d),E=D(),L=dt(w,()=>{E.current?.()}),y=ht(w,d,s.padding);R(()=>{S.current=d},[d]);const{updatePlayerPos:g,resetMovingState:v,resetFirstMoveState:T}=ft({containerRef:z,gamePlayStateRef:S,setGamePlayState:u,playerRadius:s.playerRadius,moveSpeed:s.gridMoveSpeed,onFoodCollected:()=>{console.log("Food collected in single maze")},onExitReached:()=>{k||I()},onFirstMove:()=>{window.dispatchEvent(new CustomEvent("maze:firstMove"))}}),N=()=>{p(!0),M(`⏰ ${c.failMsg}`),b(!0),u(x=>({...x,isGameActive:!1})),r&&r()},I=()=>{p(!0),M(`🎉 ${c.successMsg}`),b(!0),window.dispatchEvent(new CustomEvent("maze:gameSuccess")),a&&a()},O=()=>{b(!1)};return R(()=>{(async()=>{f(!0);try{const $=Sn({size:e,seed:n,method:o,foodCount:i});S.current=$,u($)}catch($){console.error("Error generating single maze:",$)}finally{f(!1)}})()},[t]),R(()=>{let x;const $=!document.hidden,V=()=>{const j=w.current?.getContext("2d"),q=S.current;if(!($&&q?.isGameActive&&j&&q?.maze)){x=requestAnimationFrame(V);return}g(),X(),x=requestAnimationFrame(V)},X=()=>{const j=w.current?.getContext("2d"),q=S.current;j&&q?.maze&&_t(j,q,L.current,y.current,s)};return E.current=X,x=requestAnimationFrame(V),()=>{cancelAnimationFrame(x)}},[]),R(()=>{v(),T()},[t,v,T]),h?m("div",{className:"single-maze-loading",children:m("div",{children:"Generating maze..."})}):d?m("div",{className:"maze-game-container",children:[m(Ln,{timer:l,onTimeUp:N}),m("div",{className:"single-maze-canvas-container",ref:z,children:[m("canvas",{ref:w,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]}),m(oe,{isOpen:_,title:C,noConfirm:!0,cancelText:"OK",onCancel:O})]}):m("div",{className:"single-maze-error",children:m("div",{children:"Failed to generate maze"})})}const pt=[[{size:8,seed:12345,method:"backtracking",wallWidth:4,exitWallWidth:6,exitDashArray:[8,12]},{size:8,seed:23456,method:"backtracking",exitColor:"#33f",exitWallWidth:4,exitDashArray:[8,16]},{size:8,seed:34567,method:"prims"},{size:8,seed:45678,method:"backtracking"},{size:9,seed:56789,method:"prims"},{size:9,seed:67890,method:"backtracking"},{size:9,seed:78901,method:"prims"},{size:9,seed:89012,method:"backtracking"},{size:10,seed:90123,method:"prims"},{size:11,seed:11111,method:"backtracking"},{size:12,seed:22222,method:"prims"},{size:13,seed:33333,method:"backtracking"}],[{size:12,seed:44444,method:"prims"},{size:12,seed:55555,method:"backtracking"},{size:12,seed:66666,method:"prims"},{size:12,seed:77777,method:"backtracking"},{size:13,seed:88888,method:"prims"},{size:13,seed:99999,method:"backtracking"},{size:13,seed:12121,method:"prims"},{size:14,seed:23232,method:"backtracking"},{size:15,seed:34343,method:"prims"},{size:16,seed:45454,method:"backtracking"},{size:17,seed:56565,method:"prims"},{size:18,seed:67676,method:"backtracking"}],[{size:19,seed:78787,method:"prims"},{size:20,seed:89898,method:"backtracking"},{size:21,seed:90909,method:"prims"},{size:22,seed:10101,method:"backtracking"},{size:23,seed:20202,method:"prims"},{size:25,seed:30303,method:"backtracking"},{size:27,seed:40404,method:"prims"},{size:29,seed:50505,method:"backtracking"},{size:31,seed:60606,method:"prims"},{size:33,seed:70707,method:"backtracking"},{size:37,seed:80808,method:"prims"},{size:40,seed:90909,method:"backtracking"}],[{size:41,seed:10111,method:"prims"},{size:42,seed:11121,method:"backtracking"},{size:43,seed:12131,method:"prims"},{size:44,seed:13141,method:"backtracking"},{size:45,seed:14151,method:"prims"},{size:46,seed:15161,method:"backtracking"},{size:47,seed:16171,method:"prims"},{size:48,seed:17181,method:"backtracking"},{size:49,seed:18191,method:"prims"},{size:50,seed:19201,method:"backtracking"},{size:51,seed:20211,method:"prims"},{size:52,seed:21221,method:"backtracking"}],[{size:53,seed:22231,method:"prims"},{size:54,seed:23241,method:"backtracking"},{size:55,seed:24251,method:"prims"},{size:56,seed:25261,method:"backtracking"},{size:57,seed:26271,method:"prims"},{size:58,seed:27281,method:"backtracking"},{size:59,seed:28291,method:"prims"},{size:60,seed:29301,method:"backtracking"},{size:62,seed:30311,method:"prims"},{size:64,seed:31321,method:"backtracking"},{size:66,seed:32331,method:"prims"},{size:68,seed:33341,method:"backtracking"}]],Ct={gridMoveSpeed:.07,padding:10,wallWidth:2,wallColor:"#000000",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerRadius:.2,exitColor:"#F44336",exitWallWidth:4,exitDashArray:[8,12]},_e={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",congratulations:"Congratulations!",findYourExit:"Find your exit!",withoutClue:"Without clue!",withClue:"You used the clue!",collectAllStars:"Collect all stars!",notCollectAllStars:"Not collect all stars.",nextLevel:"Next Level ➤",spacebarTip:"Spacebar",retry:"Retry",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",allLevelsCompleted:"You completed all levels!",lastOK:"OK",notCompleteLevel:"You still have levels not collected all stars! Try again to collect them all!",continueMessage:"You still have levels where you haven't collected all stars. Try again to collect them all!",continue:"Continue",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:Ct,levelConfig:pt},ve={i18n:{successMsg:"Congratulations! You completed the maze!",failMsg:"Time is up!",restart:"Restart"},size:8,seed:12345,method:"backtracking",foodCount:3,renderConfig:Ct,timer:10*60,successCallback:()=>{console.log("🎉 Single maze completed successfully!")},failCallback:()=>{console.log("⏰ Time is up! Game failed.")}};function Mn({config:t={}}){const e={..._e.i18n,...t.i18n||{}},n={..._e.renderConfig,...t.renderConfig||{}},o=t.levelConfig||pt,i={..._e,...t,i18n:e,levelConfig:o,renderConfig:n};return m(xt,{config:i,children:m(zn,{})})}function An({config:t={}}){const e={...ve.i18n,...t.i18n||{}},n={...ve.renderConfig,...t.renderConfig||{}},o={...ve,...t,i18n:e,renderConfig:n};return m(Nn,{config:o})}const Pn={root:"https://unpkg.com/@roudanio/maze@0.2.2/dist/",..._e};`${JSON.stringify(Pn,null,2)}`;const In={root:"https://unpkg.com/@roudanio/maze@0.2.2/dist/",...ve};return`${JSON.stringify(In,(t,e)=>typeof e=="function"?e.toString():e,2)}`,{showNotice(){console.warn("Cannot find the root element");const t=document.createElement("div");t.style.textAlign="center",t.style.padding="20px",t.innerHTML="Cannot find the root element",document.body.append(t)},addLoadingIndicator(t){const e=document.createElement("div"),n=document.createElement("div");e.style.cssText=`
2
2
  height: 30px;
3
3
  width: 100%;
4
4
  border: solid 2px #999;
package/dist/maze.js CHANGED
@@ -1,4 +1,4 @@
1
- var fe, A, Je, X, Pe, Ze, Qe, et, Se, Ce, ye, tt, ee = {}, nt = [], bt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, me = Array.isArray;
1
+ var fe, A, Je, X, Pe, Ze, Qe, et, Se, we, ye, tt, ee = {}, nt = [], bt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, me = Array.isArray;
2
2
  function H(t, e) {
3
3
  for (var n in e) t[n] = e[n];
4
4
  return t;
@@ -45,8 +45,8 @@ function de() {
45
45
  de.__r = 0;
46
46
  }
47
47
  function rt(t, e, n, o, i, s, a, r, l, c, d) {
48
- var u, h, f, k, p, _, b = o && o.__k || nt, w = e.length;
49
- for (l = kt(n, e, b, l, w), u = 0; u < w; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? ee : b[f.__i] || ee, f.__i = u, _ = Ee(t, f, h, i, s, a, r, l, c, d), k = f.__e, f.ref && h.ref != f.ref && (h.ref && Le(h.ref, null, f), d.push(f.ref, f.__c || k, f)), p == null && k != null && (p = k), 4 & f.__u || h.__k === f.__k ? l = it(f, l, t) : typeof f.type == "function" && _ !== void 0 ? l = _ : k && (l = k.nextSibling), f.__u &= -7);
48
+ var u, h, f, k, p, _, b = o && o.__k || nt, C = e.length;
49
+ for (l = kt(n, e, b, l, C), u = 0; u < C; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? ee : b[f.__i] || ee, f.__i = u, _ = Ee(t, f, h, i, s, a, r, l, c, d), k = f.__e, f.ref && h.ref != f.ref && (h.ref && Le(h.ref, null, f), d.push(f.ref, f.__c || k, f)), p == null && k != null && (p = k), 4 & f.__u || h.__k === f.__k ? l = it(f, l, t) : typeof f.type == "function" && _ !== void 0 ? l = _ : k && (l = k.nextSibling), f.__u &= -7);
50
50
  return n.__e = p, l;
51
51
  }
52
52
  function kt(t, e, n, o, i) {
@@ -92,7 +92,7 @@ function re(t, e, n, o, i) {
92
92
  if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || Ie(t.style, e, "");
93
93
  if (n) for (e in n) o && n[e] == o[e] || Ie(t.style, e, n[e]);
94
94
  }
95
- else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(et, "$1")), e = e.toLowerCase() in t || e == "onFocusOut" || e == "onFocusIn" ? e.toLowerCase().slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + s] = n, n ? o ? n.u = o.u : (n.u = Se, t.addEventListener(e, s ? ye : Ce, s)) : t.removeEventListener(e, s ? ye : Ce, s);
95
+ else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(et, "$1")), e = e.toLowerCase() in t || e == "onFocusOut" || e == "onFocusIn" ? e.toLowerCase().slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + s] = n, n ? o ? n.u = o.u : (n.u = Se, t.addEventListener(e, s ? ye : we, s)) : t.removeEventListener(e, s ? ye : we, s);
96
96
  else {
97
97
  if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
98
98
  else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
@@ -114,30 +114,30 @@ function xe(t) {
114
114
  };
115
115
  }
116
116
  function Ee(t, e, n, o, i, s, a, r, l, c) {
117
- var d, u, h, f, k, p, _, b, w, M, C, z, S, E, L, y, g, v = e.type;
117
+ var d, u, h, f, k, p, _, b, C, M, w, z, S, E, L, y, g, v = e.type;
118
118
  if (e.constructor != null) return null;
119
119
  128 & n.__u && (l = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d = A.__b) && d(e);
120
120
  e: if (typeof v == "function") try {
121
- if (b = e.props, w = "prototype" in v && v.prototype.render, M = (d = v.contextType) && o[d.__c], C = d ? M ? M.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (w ? e.__c = u = new v(b, C) : (e.__c = u = new ae(b, C), u.constructor = v, u.render = Et), M && M.sub(u), u.props = b, u.state || (u.state = {}), u.context = C, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), w && u.__s == null && (u.__s = u.state), w && v.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = H({}, u.__s)), H(u.__s, v.getDerivedStateFromProps(b, u.__s))), f = u.props, k = u.state, u.__v = e, h) w && v.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), w && u.componentDidMount != null && u.__h.push(u.componentDidMount);
121
+ if (b = e.props, C = "prototype" in v && v.prototype.render, M = (d = v.contextType) && o[d.__c], w = d ? M ? M.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (C ? e.__c = u = new v(b, w) : (e.__c = u = new ae(b, w), u.constructor = v, u.render = Et), M && M.sub(u), u.props = b, u.state || (u.state = {}), u.context = w, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), C && u.__s == null && (u.__s = u.state), C && v.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = H({}, u.__s)), H(u.__s, v.getDerivedStateFromProps(b, u.__s))), f = u.props, k = u.state, u.__v = e, h) C && v.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), C && u.componentDidMount != null && u.__h.push(u.componentDidMount);
122
122
  else {
123
- if (w && v.getDerivedStateFromProps == null && b !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(b, C), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(b, u.__s, C) === !1 || e.__v == n.__v) {
123
+ if (C && v.getDerivedStateFromProps == null && b !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(b, w), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(b, u.__s, w) === !1 || e.__v == n.__v) {
124
124
  for (e.__v != n.__v && (u.props = b, u.state = u.__s, u.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(T) {
125
125
  T && (T.__ = e);
126
126
  }), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
127
127
  u._sb = [], u.__h.length && a.push(u);
128
128
  break e;
129
129
  }
130
- u.componentWillUpdate != null && u.componentWillUpdate(b, u.__s, C), w && u.componentDidUpdate != null && u.__h.push(function() {
130
+ u.componentWillUpdate != null && u.componentWillUpdate(b, u.__s, w), C && u.componentDidUpdate != null && u.__h.push(function() {
131
131
  u.componentDidUpdate(f, k, p);
132
132
  });
133
133
  }
134
- if (u.context = C, u.props = b, u.__P = t, u.__e = !1, S = A.__r, E = 0, w) {
134
+ if (u.context = w, u.props = b, u.__P = t, u.__e = !1, S = A.__r, E = 0, C) {
135
135
  for (u.state = u.__s, u.__d = !1, S && S(e), d = u.render(u.props, u.state, u.context), L = 0; L < u._sb.length; L++) u.__h.push(u._sb[L]);
136
136
  u._sb = [];
137
137
  } else do
138
138
  u.__d = !1, S && S(e), d = u.render(u.props, u.state, u.context), u.state = u.__s;
139
139
  while (u.__d && ++E < 25);
140
- u.state = u.__s, u.getChildContext != null && (o = H(H({}, o), u.getChildContext())), w && !h && u.getSnapshotBeforeUpdate != null && (p = u.getSnapshotBeforeUpdate(f, k)), y = d, d != null && d.type === _e && d.key == null && (y = at(d.props.children)), r = rt(t, me(y) ? y : [y], e, n, o, i, s, a, r, l, c), u.base = e.__e, e.__u &= -161, u.__h.length && a.push(u), _ && (u.__E = u.__ = null);
140
+ u.state = u.__s, u.getChildContext != null && (o = H(H({}, o), u.getChildContext())), C && !h && u.getSnapshotBeforeUpdate != null && (p = u.getSnapshotBeforeUpdate(f, k)), y = d, d != null && d.type === _e && d.key == null && (y = at(d.props.children)), r = rt(t, me(y) ? y : [y], e, n, o, i, s, a, r, l, c), u.base = e.__e, e.__u &= -161, u.__h.length && a.push(u), _ && (u.__E = u.__ = null);
141
141
  } catch (T) {
142
142
  if (e.__v = null, l || s != null) if (T.then) {
143
143
  for (e.__u |= l ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
@@ -165,18 +165,18 @@ function at(t) {
165
165
  return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : me(t) ? t.map(at) : H({}, t);
166
166
  }
167
167
  function zt(t, e, n, o, i, s, a, r, l) {
168
- var c, d, u, h, f, k, p, _ = n.props, b = e.props, w = e.type;
169
- if (w == "svg" ? i = "http://www.w3.org/2000/svg" : w == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
170
- for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!w && (w ? f.localName == w : f.nodeType == 3)) {
168
+ var c, d, u, h, f, k, p, _ = n.props, b = e.props, C = e.type;
169
+ if (C == "svg" ? i = "http://www.w3.org/2000/svg" : C == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
170
+ for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!C && (C ? f.localName == C : f.nodeType == 3)) {
171
171
  t = f, s[c] = null;
172
172
  break;
173
173
  }
174
174
  }
175
175
  if (t == null) {
176
- if (w == null) return document.createTextNode(b);
177
- t = document.createElementNS(i, w, b.is && b), r && (A.__m && A.__m(e, s), r = !1), s = null;
176
+ if (C == null) return document.createTextNode(b);
177
+ t = document.createElementNS(i, C, b.is && b), r && (A.__m && A.__m(e, s), r = !1), s = null;
178
178
  }
179
- if (w == null) _ === b || r && t.data == b || (t.data = b);
179
+ if (C == null) _ === b || r && t.data == b || (t.data = b);
180
180
  else {
181
181
  if (s = s && fe.call(t.childNodes), _ = n.props || ee, !r && s != null) for (_ = {}, c = 0; c < t.attributes.length; c++) _[(f = t.attributes[c]).name] = f.value;
182
182
  for (c in _) if (f = _[c], c != "children") {
@@ -188,8 +188,8 @@ function zt(t, e, n, o, i, s, a, r, l) {
188
188
  }
189
189
  for (c in b) f = b[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? k = f : c == "checked" ? p = f : r && typeof f != "function" || _[c] === f || re(t, c, f, _[c], i);
190
190
  if (d) r || u && (d.__html == u.__html || d.__html == t.innerHTML) || (t.innerHTML = d.__html), e.__k = [];
191
- else if (u && (t.innerHTML = ""), rt(e.type == "template" ? t.content : t, me(h) ? h : [h], e, n, o, w == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && K(n, 0), r, l), s != null) for (c = s.length; c--; ) ze(s[c]);
192
- r || (c = "value", w == "progress" && k == null ? t.removeAttribute("value") : k != null && (k !== t[c] || w == "progress" && !k || w == "option" && k != _[c]) && re(t, c, k, _[c], i), c = "checked", p != null && p != t[c] && re(t, c, p, _[c], i));
191
+ else if (u && (t.innerHTML = ""), rt(e.type == "template" ? t.content : t, me(h) ? h : [h], e, n, o, C == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && K(n, 0), r, l), s != null) for (c = s.length; c--; ) ze(s[c]);
192
+ r || (c = "value", C == "progress" && k == null ? t.removeAttribute("value") : k != null && (k !== t[c] || C == "progress" && !k || C == "option" && k != _[c]) && re(t, c, k, _[c], i), c = "checked", p != null && p != t[c] && re(t, c, p, _[c], i));
193
193
  }
194
194
  return t;
195
195
  }
@@ -260,7 +260,7 @@ fe = nt.slice, A = { __e: function(t, e, n, o) {
260
260
  this.__v && (this.__e = !0, t && this.__h.push(t), be(this));
261
261
  }, ae.prototype.render = _e, X = [], Ze = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Qe = function(t, e) {
262
262
  return t.__v.__b - e.__v.__b;
263
- }, de.__r = 0, et = /(PointerCapture)$|Capture$/i, Se = 0, Ce = xe(!1), ye = xe(!0), tt = 0;
263
+ }, de.__r = 0, et = /(PointerCapture)$|Capture$/i, Se = 0, we = xe(!1), ye = xe(!0), tt = 0;
264
264
  var Nt = 0;
265
265
  function m(t, e, n, o, i, s) {
266
266
  e || (e = {});
@@ -709,7 +709,7 @@ const xt = (t) => ({
709
709
  gamePlayStateRef: i,
710
710
  resetGame: s,
711
711
  config: a
712
- } = ne(), { i18n: r, levelConfig: l } = a, c = oe(l), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, k = c.getTotalLevels(), [p, _] = U(!1), [b, w] = U(!1), [M, C] = U(!1), z = (D) => {
712
+ } = ne(), { i18n: r, levelConfig: l } = a, c = oe(l), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, k = c.getTotalLevels(), [p, _] = U(!1), [b, C] = U(!1), [M, w] = U(!1), z = (D) => {
713
713
  const I = c.getFirstLevelOfTier(D);
714
714
  c.isLevelUnlocked(I, h) && (e(($) => ({ ...$, currentTier: D })), S(I));
715
715
  }, S = (D) => {
@@ -719,21 +719,21 @@ const xt = (t) => ({
719
719
  }, L = () => {
720
720
  _(!1);
721
721
  }, y = () => {
722
- C(!0);
722
+ w(!0);
723
723
  }, g = () => {
724
- C(!1);
724
+ w(!1);
725
725
  }, v = () => {
726
726
  j.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
727
727
  ...i.current,
728
728
  // need to sync with ref
729
729
  showClue: !i.current.showClue
730
- })), C(!1);
730
+ })), w(!1);
731
731
  }, T = () => {
732
- w(!0);
732
+ C(!0);
733
733
  }, N = () => {
734
- s(), w(!1), j.show(r.resetDoneToast);
734
+ s(), C(!1), j.show(r.resetDoneToast);
735
735
  }, P = () => {
736
- w(!1);
736
+ C(!1);
737
737
  };
738
738
  return /* @__PURE__ */ m("div", { class: "game-panel-container", children: [
739
739
  /* @__PURE__ */ m("div", { className: "game-controls", children: [
@@ -982,7 +982,7 @@ var ln = /* @__PURE__ */ function() {
982
982
  emojis: r,
983
983
  emojiSize: l,
984
984
  canvasWidth: d
985
- }), w = new Ye({
985
+ }), C = new Ye({
986
986
  initialPosition: k,
987
987
  direction: "left",
988
988
  confettiRadius: i,
@@ -992,7 +992,7 @@ var ln = /* @__PURE__ */ function() {
992
992
  emojiSize: l,
993
993
  canvasWidth: d
994
994
  });
995
- p.addShapes(b, w);
995
+ p.addShapes(b, C);
996
996
  }
997
997
  return this.activeConfettiBatches.push(p), this.queueAnimationFrameIfNeeded(), p.getBatchCompletePromise();
998
998
  }
@@ -1008,7 +1008,7 @@ var ln = /* @__PURE__ */ function() {
1008
1008
  }
1009
1009
  }]), t;
1010
1010
  }();
1011
- const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1011
+ const un = new cn(), Ce = 3, dn = ({ onRetry: t }) => {
1012
1012
  const {
1013
1013
  config: e,
1014
1014
  currentScore: n,
@@ -1016,20 +1016,20 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1016
1016
  setGamePlayState: i,
1017
1017
  gameProgress: s,
1018
1018
  setGameProgress: a
1019
- } = ne(), { i18n: r, levelConfig: l } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: k, levelTransitioning: p } = o, { currentLevel: _ } = s, [b, w] = U(!1);
1019
+ } = ne(), { i18n: r, levelConfig: l } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: k, levelTransitioning: p } = o, { currentLevel: _ } = s, [b, C] = U(!1);
1020
1020
  R(() => {
1021
- k && p && (un.addConfetti(), j.show(r.levelCompleteToast), w(!0));
1021
+ k && p && (un.addConfetti(), j.show(r.levelCompleteToast), C(!0));
1022
1022
  }, [k, p]);
1023
- const M = oe(l), C = M.getTotalLevels(), z = Z(() => _ >= C, [_, C]), S = () => {
1024
- w(!1), j.show(r.levelRestartToast), t?.();
1023
+ const M = oe(l), w = M.getTotalLevels(), z = Z(() => _ >= w, [_, w]), S = () => {
1024
+ C(!1), j.show(r.levelRestartToast), t?.();
1025
1025
  }, E = () => {
1026
- w(!1), i((g) => ({
1026
+ C(!1), i((g) => ({
1027
1027
  ...g,
1028
1028
  isGameActive: !0,
1029
1029
  levelTransitioning: !1
1030
1030
  }));
1031
1031
  }, L = () => {
1032
- w(!1);
1032
+ C(!1);
1033
1033
  const g = M.getNextLevelInfo(_);
1034
1034
  if (!g) return;
1035
1035
  const { nextLevel: v, nextTier: T, isTierChange: N } = g;
@@ -1050,7 +1050,7 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1050
1050
  }
1051
1051
  }));
1052
1052
  }, y = () => {
1053
- w(!1), a((g) => {
1053
+ C(!1), a((g) => {
1054
1054
  const v = Math.max(
1055
1055
  Object.values(n).filter(Boolean).length,
1056
1056
  g.levelScores[g.currentLevel] || 0
@@ -1063,11 +1063,11 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1063
1063
  (I, $) => Number(I[0]) - Number($[0])
1064
1064
  );
1065
1065
  for (const [I, $] of D)
1066
- if ($ < we) {
1066
+ if ($ < Ce) {
1067
1067
  N = Number(I), P = M.getTierByLevel(N);
1068
1068
  break;
1069
1069
  }
1070
- return (N > 0 && N !== _ || v < we) && j.show(r.notCompleteLevel), (N === 0 || v < we) && t?.(), {
1070
+ return (N > 0 && N !== _ || v < Ce) && j.show(r.notCompleteLevel), (N === 0 || v < Ce) && t?.(), {
1071
1071
  ...g,
1072
1072
  currentLevel: N || g.currentLevel,
1073
1073
  currentTier: P || g.currentTier,
@@ -1185,11 +1185,11 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1185
1185
  onFirstMove: l
1186
1186
  }) => {
1187
1187
  const c = () => i?.current ?? o ?? 0.03, d = O(!1), u = O(/* @__PURE__ */ new Set()), h = O(!1), f = je(
1188
- (C, z) => {
1188
+ (w, z) => {
1189
1189
  const S = e.current;
1190
1190
  if (!S.maze)
1191
1191
  return { canMove: !1, newCell: null };
1192
- const E = c(), [L, y] = ie[C];
1192
+ const E = c(), [L, y] = ie[w];
1193
1193
  if (Ke(
1194
1194
  z,
1195
1195
  L,
@@ -1210,7 +1210,7 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1210
1210
  },
1211
1211
  [s, c]
1212
1212
  ), k = () => {
1213
- const C = e.current, { row: z, col: S } = C.playerCell, E = s * 2, L = C.foodCells.findIndex((v) => Math.sqrt(
1213
+ const w = e.current, { row: z, col: S } = w.playerCell, E = s * 2, L = w.foodCells.findIndex((v) => Math.sqrt(
1214
1214
  Math.pow(z - v.row, 2) + Math.pow(S - v.col, 2)
1215
1215
  ) < E);
1216
1216
  L !== -1 && a && (a(), e.current = {
@@ -1221,9 +1221,9 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1221
1221
  )
1222
1222
  });
1223
1223
  const g = mn(
1224
- C.playerCell,
1225
- C.exitCell,
1226
- C.maze
1224
+ w.playerCell,
1225
+ w.exitCell,
1226
+ w.maze
1227
1227
  );
1228
1228
  g && !e.current.playerAtExit ? (e.current = {
1229
1229
  ...e.current,
@@ -1242,37 +1242,37 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1242
1242
  isGameActive: !0,
1243
1243
  levelTransitioning: !1
1244
1244
  });
1245
- }, p = (C) => {
1246
- const z = e.current, S = Math.round(C.row), E = Math.round(C.col), L = z.playerPath[z.playerPath.length - 1], y = L.row === S && L.col === E, g = Math.abs(L.row - S), v = Math.abs(L.col - E);
1245
+ }, p = (w) => {
1246
+ const z = e.current, S = Math.round(w.row), E = Math.round(w.col), L = z.playerPath?.[z.playerPath.length - 1], y = L?.row === S && L?.col === E, g = Math.abs(L?.row ?? 0 - S), v = Math.abs(L?.col ?? 0 - E);
1247
1247
  if ((g === 1 && v === 0 || g === 0 && v === 1) && !y) {
1248
- const N = `${L.row},${L.col}-${S},${E}`;
1248
+ const N = `${L?.row},${L?.col}-${S},${E}`;
1249
1249
  e.current = {
1250
1250
  ...e.current,
1251
1251
  playerPath: [
1252
- ...e.current.playerPath,
1252
+ ...e.current.playerPath ?? [],
1253
1253
  { row: S, col: E }
1254
1254
  ],
1255
1255
  visitCounts: {
1256
1256
  ...e.current.visitCounts,
1257
- [N]: (e.current.visitCounts[N] || 0) + 1
1257
+ [N]: (e.current.visitCounts?.[N] || 0) + 1
1258
1258
  }
1259
1259
  };
1260
1260
  }
1261
1261
  }, _ = () => {
1262
1262
  if (d.current || u.current.size === 0) return;
1263
- const C = e.current;
1264
- !C.playerCell || !Array.from(u.current).some(
1263
+ const w = e.current;
1264
+ !w.playerCell || !Array.from(u.current).some(
1265
1265
  (S) => {
1266
1266
  const { canMove: E } = f(
1267
1267
  S,
1268
- C.playerCell
1268
+ w.playerCell
1269
1269
  );
1270
1270
  return E;
1271
1271
  }
1272
1272
  ) || (!h.current && l && (h.current = !0, l()), d.current = !0);
1273
1273
  };
1274
1274
  R(() => {
1275
- const C = (y) => {
1275
+ const w = (y) => {
1276
1276
  if (y.key === "ArrowUp" || y.key === "ArrowDown" || y.key === "ArrowLeft" || y.key === "ArrowRight" || y.key === " ") {
1277
1277
  const g = document.activeElement;
1278
1278
  if (g && (g.tagName === "INPUT" || g.tagName === "TEXTAREA" || g.getAttribute("contenteditable") === "true")) return;
@@ -1287,7 +1287,7 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1287
1287
  const g = y.key;
1288
1288
  if (!(g in ie)) return;
1289
1289
  const v = document.activeElement;
1290
- v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.getAttribute("contenteditable") === "true") || (y.preventDefault(), u.current.delete(g), u.current.size === 0 && w());
1290
+ v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.getAttribute("contenteditable") === "true") || (y.preventDefault(), u.current.delete(g), u.current.size === 0 && C());
1291
1291
  }, E = (y) => {
1292
1292
  y.preventDefault();
1293
1293
  const g = e.current;
@@ -1297,14 +1297,14 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1297
1297
  let N = null;
1298
1298
  T && (T.classList.contains("maze-up") ? N = "ArrowUp" : T.classList.contains("maze-down") ? N = "ArrowDown" : T.classList.contains("maze-left") ? N = "ArrowLeft" : T.classList.contains("maze-right") && (N = "ArrowRight")), N && (u.current.clear(), u.current.add(N), _());
1299
1299
  }, L = () => {
1300
- w();
1300
+ C();
1301
1301
  };
1302
- return window.addEventListener("keydown", C, {
1302
+ return window.addEventListener("keydown", w, {
1303
1303
  capture: !0
1304
1304
  }), window.addEventListener("keydown", z), window.addEventListener("keyup", S), t.current?.addEventListener("touchstart", E, {
1305
1305
  passive: !1
1306
1306
  }), t.current?.addEventListener("touchend", L), () => {
1307
- window.removeEventListener("keydown", C, {
1307
+ window.removeEventListener("keydown", w, {
1308
1308
  capture: !0
1309
1309
  }), window.removeEventListener("keydown", z), window.removeEventListener("keyup", S), t.current?.removeEventListener("touchstart", E), t.current?.removeEventListener("touchend", L);
1310
1310
  };
@@ -1312,7 +1312,7 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1312
1312
  const b = je(() => {
1313
1313
  if (!d.current || u.current.size === 0)
1314
1314
  return e.current.playerCell;
1315
- const C = c(), z = e.current.playerCell;
1315
+ const w = c(), z = e.current.playerCell;
1316
1316
  let S = 0, E = 0, L = 0;
1317
1317
  for (const Y of u.current) {
1318
1318
  const { canMove: ge } = f(Y, z);
@@ -1324,9 +1324,9 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1324
1324
  if (L === 0)
1325
1325
  return e.current.playerCell;
1326
1326
  const y = Math.sqrt(S * S + E * E), g = y > 0 ? S / y : 0, v = y > 0 ? E / y : 0, T = Number(
1327
- (z.row + g * C).toFixed(2)
1327
+ (z.row + g * w).toFixed(2)
1328
1328
  ), N = Number(
1329
- (z.col + v * C).toFixed(2)
1329
+ (z.col + v * w).toFixed(2)
1330
1330
  ), P = T - z.row, D = N - z.col, I = Math.sqrt(P * P + D * D);
1331
1331
  if (I > 0) {
1332
1332
  const Y = P / I, ge = D / I;
@@ -1346,12 +1346,12 @@ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1346
1346
  }, k();
1347
1347
  const $ = z.row < 0 ? 0 : Math.round(z.row), B = z.col < 0 ? 0 : Math.round(z.col), V = T < 0 ? 0 : Math.round(T), G = N < 0 ? 0 : Math.round(N);
1348
1348
  return (V !== $ || G !== B) && p({ row: V, col: G }), e.current.playerCell;
1349
- }, [c, f]), w = () => {
1349
+ }, [c, f]), C = () => {
1350
1350
  d.current = !1, u.current.clear();
1351
1351
  };
1352
1352
  return {
1353
1353
  updatePlayerPos: b,
1354
- resetMovingState: w,
1354
+ resetMovingState: C,
1355
1355
  resetFirstMoveState: () => {
1356
1356
  h.current = !1;
1357
1357
  }
@@ -1439,9 +1439,9 @@ function vt(t, e, n, o, i) {
1439
1439
  padding: _,
1440
1440
  wallWidth: b,
1441
1441
  // need merge with level config when passed here
1442
- wallColor: w,
1442
+ wallColor: C,
1443
1443
  playerColor: M,
1444
- playerRadius: C,
1444
+ playerRadius: w,
1445
1445
  foodColor: z,
1446
1446
  backgroundColor: S,
1447
1447
  clueColor: E,
@@ -1449,10 +1449,10 @@ function vt(t, e, n, o, i) {
1449
1449
  exitWallWidth: y,
1450
1450
  exitDashArray: g
1451
1451
  } = i;
1452
- t.clearRect(0, 0, s, a), t.save(), t.fillStyle = S, t.fillRect(0, 0, s, a), t.restore(), f && Cn({
1452
+ t.clearRect(0, 0, s, a), t.save(), t.fillStyle = S, t.fillRect(0, 0, s, a), t.restore(), f && wn({
1453
1453
  ctx: t,
1454
- playerPath: k,
1455
- visitCounts: p,
1454
+ playerPath: k ?? [],
1455
+ visitCounts: p ?? {},
1456
1456
  cellWidth: r,
1457
1457
  cellHeight: l,
1458
1458
  padding: _,
@@ -1463,7 +1463,7 @@ function vt(t, e, n, o, i) {
1463
1463
  cellWidth: r,
1464
1464
  cellHeight: l,
1465
1465
  padding: _,
1466
- wallColor: w,
1466
+ wallColor: C,
1467
1467
  wallWidth: b
1468
1468
  }), gn({
1469
1469
  ctx: t,
@@ -1485,7 +1485,7 @@ function vt(t, e, n, o, i) {
1485
1485
  }), vn({
1486
1486
  ctx: t,
1487
1487
  playerCell: d,
1488
- playerRadius: C,
1488
+ playerRadius: w,
1489
1489
  cellWidth: r,
1490
1490
  cellHeight: l,
1491
1491
  padding: _,
@@ -1557,10 +1557,10 @@ function pn({
1557
1557
  o,
1558
1558
  i
1559
1559
  );
1560
- wn(t, l, c, a * 1.2, 5, a * 0.6);
1560
+ Cn(t, l, c, a * 1.2, 5, a * 0.6);
1561
1561
  });
1562
1562
  }
1563
- function wn(t, e, n, o, i, s) {
1563
+ function Cn(t, e, n, o, i, s) {
1564
1564
  t.save(), t.beginPath();
1565
1565
  for (let a = 0; a < i * 2; a++) {
1566
1566
  const r = a % 2 === 0 ? o : s, l = Math.PI * a / i;
@@ -1568,7 +1568,7 @@ function wn(t, e, n, o, i, s) {
1568
1568
  }
1569
1569
  t.closePath(), t.fill(), t.restore();
1570
1570
  }
1571
- function Cn({
1571
+ function wn({
1572
1572
  ctx: t,
1573
1573
  playerPath: e,
1574
1574
  visitCounts: n,
@@ -1593,14 +1593,14 @@ function Cn({
1593
1593
  o,
1594
1594
  i,
1595
1595
  s
1596
- ), { x: b, y: w } = he(
1596
+ ), { x: b, y: C } = he(
1597
1597
  c.row,
1598
1598
  c.col,
1599
1599
  o,
1600
1600
  i,
1601
1601
  s
1602
1602
  );
1603
- t.beginPath(), t.moveTo(p, _), t.lineTo(b, w), t.stroke();
1603
+ t.beginPath(), t.moveTo(p, _), t.lineTo(b, C), t.stroke();
1604
1604
  }
1605
1605
  t.restore();
1606
1606
  }
@@ -1893,8 +1893,8 @@ function En() {
1893
1893
  o.currentLevel,
1894
1894
  u.current
1895
1895
  );
1896
- M && t((C) => ({
1897
- ...C,
1896
+ M && t((w) => ({
1897
+ ...w,
1898
1898
  ...M
1899
1899
  }));
1900
1900
  };
@@ -1903,7 +1903,7 @@ function En() {
1903
1903
  }, [o.currentLevel]);
1904
1904
  const _ = () => {
1905
1905
  p();
1906
- }, { updatePlayerPos: b, resetMovingState: w } = _t({
1906
+ }, { updatePlayerPos: b, resetMovingState: C } = _t({
1907
1907
  containerRef: s,
1908
1908
  gamePlayStateRef: n,
1909
1909
  setGamePlayState: t,
@@ -1918,12 +1918,12 @@ function En() {
1918
1918
  }
1919
1919
  });
1920
1920
  return R(() => {
1921
- w();
1922
- }, [o.currentLevel, w]), R(() => {
1923
- let M, C = !document.hidden;
1921
+ C();
1922
+ }, [o.currentLevel, C]), R(() => {
1923
+ let M, w = !document.hidden;
1924
1924
  const z = () => {
1925
1925
  const L = a.current?.getContext("2d"), y = n.current;
1926
- if (!(C && y?.isGameActive && L && y?.maze)) {
1926
+ if (!(w && y?.isGameActive && L && y?.maze)) {
1927
1927
  M = requestAnimationFrame(z);
1928
1928
  return;
1929
1929
  }
@@ -1943,11 +1943,11 @@ function En() {
1943
1943
  };
1944
1944
  h.current = S;
1945
1945
  const E = (L) => {
1946
- const y = C;
1947
- C = !document.hidden && document.visibilityState === "visible" && (!L || L.type !== "blur"), !y && C ? n.current?.levelTransitioning === !1 && t({
1946
+ const y = w;
1947
+ w = !document.hidden && document.visibilityState === "visible" && (!L || L.type !== "blur"), !y && w ? n.current?.levelTransitioning === !1 && t({
1948
1948
  ...n.current,
1949
1949
  isGameActive: !0
1950
- }) : y && !C && t({
1950
+ }) : y && !w && t({
1951
1951
  ...n.current,
1952
1952
  isGameActive: !1
1953
1953
  });
@@ -2014,9 +2014,9 @@ function Mn({ config: t }) {
2014
2014
  i18n: c
2015
2015
  } = t, [d, u] = U({
2016
2016
  ...ke
2017
- }), [h, f] = U(!1), [k, p] = U(!1), [_, b] = U(!1), [w, M] = U(""), C = O(null), z = O(null), S = O(d), E = O(), L = ft(C, () => {
2017
+ }), [h, f] = U(!1), [k, p] = U(!1), [_, b] = U(!1), [C, M] = U(""), w = O(null), z = O(null), S = O(d), E = O(), L = ft(w, () => {
2018
2018
  E.current?.();
2019
- }), y = mt(C, d, s.padding);
2019
+ }), y = mt(w, d, s.padding);
2020
2020
  R(() => {
2021
2021
  S.current = d;
2022
2022
  }, [d]);
@@ -2065,14 +2065,14 @@ function Mn({ config: t }) {
2065
2065
  }, [t]), R(() => {
2066
2066
  let I;
2067
2067
  const $ = !document.hidden, B = () => {
2068
- const G = C.current?.getContext("2d"), q = S.current;
2068
+ const G = w.current?.getContext("2d"), q = S.current;
2069
2069
  if (!($ && q?.isGameActive && G && q?.maze)) {
2070
2070
  I = requestAnimationFrame(B);
2071
2071
  return;
2072
2072
  }
2073
2073
  g(), V(), I = requestAnimationFrame(B);
2074
2074
  }, V = () => {
2075
- const G = C.current?.getContext("2d"), q = S.current;
2075
+ const G = w.current?.getContext("2d"), q = S.current;
2076
2076
  G && q?.maze && vt(
2077
2077
  G,
2078
2078
  q,
@@ -2089,7 +2089,7 @@ function Mn({ config: t }) {
2089
2089
  }, [t, v, T]), h ? /* @__PURE__ */ m("div", { className: "single-maze-loading", children: /* @__PURE__ */ m("div", { children: "Generating maze..." }) }) : d ? /* @__PURE__ */ m("div", { className: "maze-game-container", children: [
2090
2090
  /* @__PURE__ */ m(Nn, { timer: l, onTimeUp: N }),
2091
2091
  /* @__PURE__ */ m("div", { className: "single-maze-canvas-container", ref: z, children: [
2092
- /* @__PURE__ */ m("canvas", { ref: C, className: "maze-game-canvas" }),
2092
+ /* @__PURE__ */ m("canvas", { ref: w, className: "maze-game-canvas" }),
2093
2093
  /* @__PURE__ */ m("div", { className: "maze-touch-area maze-up" }),
2094
2094
  /* @__PURE__ */ m("div", { className: "maze-touch-area maze-down" }),
2095
2095
  /* @__PURE__ */ m("div", { className: "maze-touch-area maze-left" }),
@@ -2099,7 +2099,7 @@ function Mn({ config: t }) {
2099
2099
  Q,
2100
2100
  {
2101
2101
  isOpen: _,
2102
- title: w,
2102
+ title: C,
2103
2103
  noConfirm: !0,
2104
2104
  cancelText: "OK",
2105
2105
  onCancel: D
@@ -2107,7 +2107,7 @@ function Mn({ config: t }) {
2107
2107
  )
2108
2108
  ] }) : /* @__PURE__ */ m("div", { className: "single-maze-error", children: /* @__PURE__ */ m("div", { children: "Failed to generate maze" }) });
2109
2109
  }
2110
- const wt = [
2110
+ const Ct = [
2111
2111
  // Tier 1 (Levels 1-12) - Beginner
2112
2112
  [
2113
2113
  // debug
@@ -2265,7 +2265,7 @@ const wt = [
2265
2265
  { size: 68, seed: 33341, method: "backtracking" }
2266
2266
  // Level 60 - Master
2267
2267
  ]
2268
- ], An = 0.07, Ct = {
2268
+ ], An = 0.07, wt = {
2269
2269
  gridMoveSpeed: An,
2270
2270
  padding: 10,
2271
2271
  wallWidth: 2,
@@ -2326,8 +2326,8 @@ const wt = [
2326
2326
  cluePathDisabled: "Clue Path Disabled",
2327
2327
  useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue."
2328
2328
  },
2329
- renderConfig: Ct,
2330
- levelConfig: wt
2329
+ renderConfig: wt,
2330
+ levelConfig: Ct
2331
2331
  }, ue = {
2332
2332
  i18n: {
2333
2333
  successMsg: "Congratulations! You completed the maze!",
@@ -2338,7 +2338,7 @@ const wt = [
2338
2338
  seed: 12345,
2339
2339
  method: "backtracking",
2340
2340
  foodCount: 3,
2341
- renderConfig: Ct,
2341
+ renderConfig: wt,
2342
2342
  timer: 10 * 60,
2343
2343
  // 10 minutes
2344
2344
  successCallback: () => {
@@ -2352,7 +2352,7 @@ function Pn({ config: t = {} }) {
2352
2352
  const e = { ...ce.i18n, ...t.i18n || {} }, n = {
2353
2353
  ...ce.renderConfig,
2354
2354
  ...t.renderConfig || {}
2355
- }, o = t.levelConfig || wt, i = {
2355
+ }, o = t.levelConfig || Ct, i = {
2356
2356
  ...ce,
2357
2357
  ...t,
2358
2358
  i18n: e,
@@ -2376,12 +2376,12 @@ function In({
2376
2376
  return /* @__PURE__ */ m(Mn, { config: o });
2377
2377
  }
2378
2378
  const xn = {
2379
- root: "https://unpkg.com/@roudanio/maze@0.2.1/dist/",
2379
+ root: "https://unpkg.com/@roudanio/maze@0.2.2/dist/",
2380
2380
  ...ce
2381
2381
  };
2382
2382
  `${JSON.stringify(xn, null, 2)}`;
2383
2383
  const Rn = {
2384
- root: "https://unpkg.com/@roudanio/maze@0.2.1/dist/",
2384
+ root: "https://unpkg.com/@roudanio/maze@0.2.2/dist/",
2385
2385
  ...ue
2386
2386
  };
2387
2387
  `${JSON.stringify(
package/dist/maze.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(B,M){typeof exports=="object"&&typeof module<"u"?module.exports=M():typeof define=="function"&&define.amd?define(M):(B=typeof globalThis<"u"?globalThis:B||self,B.Maze=M())})(this,function(){"use strict";var B,M,Ae,V,Pe,Ie,xe,Re,ge,pe,we,Fe,ee={},De=[],yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function Ce(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function bt(t,e,n){var o,i,s,a={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?B.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)a[s]==null&&(a[s]=t.defaultProps[s]);return se(t,a,o,i,null)}function se(t,e,n,o,i){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ae,__i:-1,__u:0};return i==null&&M.vnode!=null&&M.vnode(s),s}function ae(t){return t.children}function le(t,e){this.props=t,this.context=e}function K(t,e){if(e==null)return t.__?K(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?K(t):null}function Oe(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Oe(t)}}function ye(t){(!t.__d&&(t.__d=!0)&&V.push(t)&&!ce.__r++||Pe!=M.debounceRendering)&&((Pe=M.debounceRendering)||Ie)(ce)}function ce(){for(var t,e,n,o,i,s,a,r=1;V.length;)V.length>r&&V.sort(xe),t=V.shift(),r=V.length,t.__d&&(n=void 0,i=(o=(e=t).__v).__e,s=[],a=[],e.__P&&((n=H({},o)).__v=o.__v+1,M.vnode&&M.vnode(n),be(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[i]:null,s,i??K(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,We(s,n,a),n.__e!=i&&Oe(n)));ce.__r=0}function $e(t,e,n,o,i,s,a,r,l,c,d){var u,h,f,k,p,_,b=o&&o.__k||De,w=e.length;for(l=Tt(n,e,b,l,w),u=0;u<w;u++)(f=n.__k[u])!=null&&(h=f.__i==-1?ee:b[f.__i]||ee,f.__i=u,_=be(t,f,h,i,s,a,r,l,c,d),k=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Te(h.ref,null,f),d.push(f.ref,f.__c||k,f)),p==null&&k!=null&&(p=k),4&f.__u||h.__k===f.__k?l=Ue(f,l,t):typeof f.type=="function"&&_!==void 0?l=_:k&&(l=k.nextSibling),f.__u&=-7);return n.__e=p,l}function Tt(t,e,n,o,i){var s,a,r,l,c,d=n.length,u=d,h=0;for(t.__k=new Array(i),s=0;s<i;s++)(a=e[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(l=s+h,(a=t.__k[s]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?se(null,a,null,null,null):ie(a)?se(ae,{children:a},null,null,null):a.constructor==null&&a.__b>0?se(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,r=null,(c=a.__i=kt(a,n,l,u))!=-1&&(u--,(r=n[c])&&(r.__u|=2)),r==null||r.__v==null?(c==-1&&(i>d?h--:i<d&&h++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,a.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<d;s++)(r=n[s])!=null&&(2&r.__u)==0&&(r.__e==o&&(o=K(r)),He(r,r));return o}function Ue(t,e,n){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Ue(o[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=K(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function kt(t,e,n,o){var i,s,a=t.key,r=t.type,l=e[n];if(l===null&&t.key==null||l&&a==l.key&&r==l.type&&(2&l.__u)==0)return n;if(o>(l!=null&&(2&l.__u)==0?1:0))for(i=n-1,s=n+1;i>=0||s<e.length;){if(i>=0){if((l=e[i])&&(2&l.__u)==0&&a==l.key&&r==l.type)return i;i--}if(s<e.length){if((l=e[s])&&(2&l.__u)==0&&a==l.key&&r==l.type)return s;s++}}return-1}function Ge(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||yt.test(e)?n:n+"px"}function ue(t,e,n,o,i){var s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Ge(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Ge(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Re,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?o?n.u=o.u:(n.u=ge,t.addEventListener(e,s?we:pe,s)):t.removeEventListener(e,s?we:pe,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function je(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ge++;else if(e.t<n.u)return;return n(M.event?M.event(e):e)}}}function be(t,e,n,o,i,s,a,r,l,c){var d,u,h,f,k,p,_,b,w,A,C,z,S,E,L,y,g,v=e.type;if(e.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),s=[r=e.__e=n.__e]),(d=M.__b)&&d(e);e:if(typeof v=="function")try{if(b=e.props,w="prototype"in v&&v.prototype.render,A=(d=v.contextType)&&o[d.__c],C=d?A?A.props.value:d.__:o,n.__c?_=(u=e.__c=n.__c).__=u.__E:(w?e.__c=u=new v(b,C):(e.__c=u=new le(b,C),u.constructor=v,u.render=zt),A&&A.sub(u),u.props=b,u.state||(u.state={}),u.context=C,u.__n=o,h=u.__d=!0,u.__h=[],u._sb=[]),w&&u.__s==null&&(u.__s=u.state),w&&v.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=H({},u.__s)),H(u.__s,v.getDerivedStateFromProps(b,u.__s))),f=u.props,k=u.state,u.__v=e,h)w&&v.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),w&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(w&&v.getDerivedStateFromProps==null&&b!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,C),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,C)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(u.props=b,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(T){T&&(T.__=e)}),z=0;z<u._sb.length;z++)u.__h.push(u._sb[z]);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,C),w&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,k,p)})}if(u.context=C,u.props=b,u.__P=t,u.__e=!1,S=M.__r,E=0,w){for(u.state=u.__s,u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),L=0;L<u._sb.length;L++)u.__h.push(u._sb[L]);u._sb=[]}else do u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++E<25);u.state=u.__s,u.getChildContext!=null&&(o=H(H({},o),u.getChildContext())),w&&!h&&u.getSnapshotBeforeUpdate!=null&&(p=u.getSnapshotBeforeUpdate(f,k)),y=d,d!=null&&d.type===ae&&d.key==null&&(y=qe(d.props.children)),r=$e(t,ie(y)?y:[y],e,n,o,i,s,a,r,l,c),u.base=e.__e,e.__u&=-161,u.__h.length&&a.push(u),_&&(u.__E=u.__=null)}catch(T){if(e.__v=null,l||s!=null)if(T.then){for(e.__u|=l?160:128;r&&r.nodeType==8&&r.nextSibling;)r=r.nextSibling;s[s.indexOf(r)]=null,e.__e=r}else for(g=s.length;g--;)Ce(s[g]);else e.__e=n.__e,e.__k=n.__k;M.__e(T,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):r=e.__e=St(n.__e,e,n,o,i,s,a,l,c);return(d=M.diffed)&&d(e),128&e.__u?void 0:r}function We(t,e,n){for(var o=0;o<n.length;o++)Te(n[o],n[++o],n[++o]);M.__c&&M.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){M.__e(s,i.__v)}})}function qe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:ie(t)?t.map(qe):H({},t)}function St(t,e,n,o,i,s,a,r,l){var c,d,u,h,f,k,p,_=n.props,b=e.props,w=e.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!w&&(w?f.localName==w:f.nodeType==3)){t=f,s[c]=null;break}}if(t==null){if(w==null)return document.createTextNode(b);t=document.createElementNS(i,w,b.is&&b),r&&(M.__m&&M.__m(e,s),r=!1),s=null}if(w==null)_===b||r&&t.data==b||(t.data=b);else{if(s=s&&B.call(t.childNodes),_=n.props||ee,!r&&s!=null)for(_={},c=0;c<t.attributes.length;c++)_[(f=t.attributes[c]).name]=f.value;for(c in _)if(f=_[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=f;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;ue(t,c,null,f,i)}}for(c in b)f=b[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?d=f:c=="value"?k=f:c=="checked"?p=f:r&&typeof f!="function"||_[c]===f||ue(t,c,f,_[c],i);if(d)r||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),$e(e.type=="template"?t.content:t,ie(h)?h:[h],e,n,o,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&K(n,0),r,l),s!=null)for(c=s.length;c--;)Ce(s[c]);r||(c="value",w=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[c]||w=="progress"&&!k||w=="option"&&k!=_[c])&&ue(t,c,k,_[c],i),c="checked",p!=null&&p!=t[c]&&ue(t,c,p,_[c],i))}return t}function Te(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){M.__e(i,n)}}function He(t,e,n){var o,i;if(M.unmount&&M.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||Te(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){M.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&He(o[i],e,n||typeof t.type!="function");n||Ce(t.__e),t.__c=t.__=t.__e=void 0}function zt(t,e,n){return this.constructor(t,n)}function Be(t,e,n){var o,i,s,a;e==document&&(e=document.documentElement),M.__&&M.__(t,e),i=(o=!1)?null:e.__k,s=[],a=[],be(e,t=e.__k=bt(ae,null,[t]),i||ee,ee,e.namespaceURI,i?null:e.firstChild?B.call(e.childNodes):null,s,i?i.__e:e.firstChild,o,a),We(s,t,a)}function Et(t){function e(n){var o,i;return this.getChildContext||(o=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,ye(a)})},this.sub=function(s){o.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),a&&a.call(s)}}),n.children}return e.__c="__cC"+Fe++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,o){return n.children(o)}).contextType=e,e}B=De.slice,M={__e:function(t,e,n,o){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,o||{}),a=i.__d),a)return i.__E=i}catch(r){t=r}throw t}},Ae=0,le.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ye(this))},le.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ye(this))},le.prototype.render=ae,V=[],Ie=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xe=function(t,e){return t.__v.__b-e.__v.__b},ce.__r=0,Re=/(PointerCapture)$|Capture$/i,ge=0,pe=je(!1),we=je(!0),Fe=0;var Lt=0;function m(t,e,n,o,i,s){e||(e={});var a,r,l=e;if("ref"in l)for(r in l={},e)r=="ref"?a=e[r]:l[r]=e[r];var c={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lt,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(a=t.defaultProps))for(r in a)l[r]===void 0&&(l[r]=a[r]);return M.vnode&&M.vnode(c),c}var J,P,ke,Ve,te=0,Xe=[],F=M,Ye=F.__b,Ke=F.__r,Je=F.diffed,Ze=F.__c,Qe=F.unmount,et=F.__;function de(t,e){F.__h&&F.__h(P,t,te||e),te=0;var n=P.__H||(P.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function U(t){return te=1,Nt(rt,t)}function Nt(t,e,n){var o=de(J++,2);if(o.t=t,!o.__c&&(o.__=[rt(void 0,e),function(r){var l=o.__N?o.__N[0]:o.__[0],c=o.t(l,r);l!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=P,!P.__f)){var i=function(r,l,c){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(h){return!!h.__c});if(d.every(function(h){return!h.__N}))return!s||s.call(this,r,l,c);var u=o.__c.props!==r;return d.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(u=!0)}}),s&&s.call(this,r,l,c)||u};P.__f=!0;var s=P.shouldComponentUpdate,a=P.componentWillUpdate;P.componentWillUpdate=function(r,l,c){if(this.__e){var d=s;s=void 0,i(r,l,c),s=d}a&&a.call(this,r,l,c)},P.shouldComponentUpdate=i}return o.__N||o.__}function R(t,e){var n=de(J++,3);!F.__s&&ot(n.__H,e)&&(n.__=t,n.u=e,P.__H.__h.push(n))}function D(t){return te=5,Z(function(){return{current:t}},[])}function Z(t,e){var n=de(J++,7);return ot(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function tt(t,e){return te=8,Z(function(){return t},e)}function Mt(t){var e=P.context[t.__c],n=de(J++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(P)),e.props.value):t.__}function At(){for(var t;t=Xe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(he),t.__H.__h.forEach(Se),t.__H.__h=[]}catch(e){t.__H.__h=[],F.__e(e,t.__v)}}F.__b=function(t){P=null,Ye&&Ye(t)},F.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),et&&et(t,e)},F.__r=function(t){Ke&&Ke(t),J=0;var e=(P=t.__c).__H;e&&(ke===P?(e.__h=[],P.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(he),e.__h.forEach(Se),e.__h=[],J=0)),ke=P},F.diffed=function(t){Je&&Je(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Xe.push(e)!==1&&Ve===F.requestAnimationFrame||((Ve=F.requestAnimationFrame)||Pt)(At)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ke=P=null},F.__c=function(t,e){e.some(function(n){try{n.__h.forEach(he),n.__h=n.__h.filter(function(o){return!o.__||Se(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],F.__e(o,n.__v)}}),Ze&&Ze(t,e)},F.unmount=function(t){Qe&&Qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{he(o)}catch(i){e=i}}),n.__H=void 0,e&&F.__e(e,n.__v))};var nt=typeof requestAnimationFrame=="function";function Pt(t){var e,n=function(){clearTimeout(o),nt&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,100);nt&&(e=requestAnimationFrame(n))}function he(t){var e=P,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),P=e}function Se(t){var e=P;t.__c=t.__(),P=e}function ot(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function rt(t,e){return typeof e=="function"?e(t):e}const It=t=>({saveGameData(e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error("Failed to save maze game data:",n)}},loadGameData(){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset maze game data:",e)}}}),it=Et(void 0),st={currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,levelScores:{},totalScore:0},ze={isGameActive:!0,levelTransitioning:!1,maze:null,playerCell:{row:0,col:0},exitCell:{row:0,col:0},foodCells:[],playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,playerPath:[],visitCounts:{}},xt=({children:t,config:e})=>{const n=It(e.lcPrefix+"progress"),o=n.loadGameData(),[i,s]=U(()=>o||{...st});R(()=>{const u=Object.values(i.levelScores).reduce((h,f)=>h+f,0);s(h=>({...h,totalScore:u}))},[i.levelScores]),R(()=>{n.saveGameData(i)},[i.currentLevel,i.highestUnlockedLevel,i.currentTier,i.highestUnlockedTier,i.levelScores,i.totalScore]);const[a,r]=U({...ze}),l=D(a);R(()=>{l.current=a},[a]);const c=Z(()=>[a.playerAtExit?1:0,a.foodCollected===a.totalFoodCount?1:0,a.showClue?0:1],[a.playerAtExit,a.foodCollected,a.totalFoodCount,a.showClue]),d=()=>{n.resetGameData(),s({...st}),r({...ze})};return m(it.Provider,{value:{gameProgress:i,setGameProgress:s,gamePlayState:a,setGamePlayState:r,gamePlayStateRef:l,currentScore:c,config:e,resetGame:d},children:t})},ne=()=>{const t=Mt(it);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t},oe=t=>Z(()=>{const e=t.map(r=>r.length),n=e.reduce((r,l)=>r+l,0),o=t.length,i=r=>{if(r<1||r>n)return 0;let l=0;for(let c=0;c<e.length;c++)if(l+=e[c],r<=l)return c+1;return 0},s=r=>r<1||r>o?0:e.slice(0,r-1).reduce((l,c)=>l+c,0)+1,a={getTotalLevels:()=>n,getTotalTiers:()=>o,getTierLevelsRange:r=>{if(r<1||r>o)return[0,0];const l=s(r),c=l+e[r-1]-1;return[l,c]},getTierByLevel:i,getFirstLevelOfTier:s,getLevelConfig:r=>{if(r<1||r>n)return null;const l=i(r),c=s(l),d=r-c;return t[l-1][d]},getTierConfig:r=>r<1||r>o?null:t[r-1],isLevelUnlocked:(r,l)=>r<=l,isTierUnlocked:(r,l)=>r<=l,getNextLevelInfo:r=>{if(r>=n)return null;const l=r+1,c=i(r),d=i(l);return{nextLevel:l,nextTier:d,isTierChange:d>c}},getCurrentTierProgress:(r,l)=>{const[c,d]=a.getTierLevelsRange(l),u=r-c+1,h=d-c+1;return{current:u,total:h}},isLastLevelInTier:r=>{const l=i(r),[,c]=a.getTierLevelsRange(l);return r===c},getPreviousLevelInfo:r=>{if(r<=1)return null;const l=r-1,c=i(r),d=i(l);return{prevLevel:l,prevTier:d,isTierChange:d<c}}};return a},[t]),Rt=({onTierChange:t,disabled:e})=>{const{gameProgress:n,config:o}=ne(),{i18n:i,levelConfig:s}=o,{currentTier:a,highestUnlockedTier:r}=n,c=oe(s).getTotalTiers();return m("div",{className:"tier-selector",children:m("select",{value:a,onChange:d=>{d.target&&d.target.value&&t(Number(d.target.value))},disabled:e,className:"tier-dropdown",children:Array.from({length:c},(d,u)=>u+1).map(d=>m("option",{value:d,disabled:d>r,children:i.tier+" "+d},`tier-${d}`))})})},Ft=({onLevelChange:t,disabled:e})=>{const{gameProgress:n,config:o}=ne(),{i18n:i,levelConfig:s}=o,{currentTier:a,levelScores:r,currentLevel:l,highestUnlockedLevel:c}=n,d=oe(s),u=Z(()=>{const[h,f]=d.getTierLevelsRange(a);return Array.from({length:f-h+1},(k,p)=>{const _=h+p,b=r[_]||0;return{level:_,score:b}})},[a,r]);return m("div",{className:"level-selector",children:m("select",{value:l,onChange:h=>{h.target&&h.target.value&&t(Number(h.target.value))},disabled:e,className:"level-dropdown",children:u.map(({level:h,score:f})=>m("option",{value:h,disabled:h>c,children:`${i.level} ${h} ${"★".repeat(f)}`},`level-${h}`))})})},re=({isOpen:t,title:e,className:n="",message:o,children:i,noConfirm:s=!1,noCancel:a=!1,confirmText:r="OK",cancelText:l="Cancel",confirmClass:c="",cancelClass:d="",onConfirm:u,onCancel:h})=>{const f=D(null);return R(()=>{const k=p=>{p.key==="Escape"&&h?.()};return t&&document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[t,h]),m("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:m("div",{className:"maze-dialog "+n,ref:f,children:[m("div",{className:"maze-dialog-title",children:e}),m("div",{className:"maze-dialog-content",children:i||m("div",{className:"maze-dialog-message",children:o})}),(!a||!s)&&m("div",{className:"maze-dialog-buttons",children:[!a&&m("button",{type:"button",className:"maze-dialog-cancel "+d,onClick:h,children:l}),!s&&m("button",{type:"button",className:"maze-dialog-confirm "+c,onClick:u,children:r})]})]})})},G={container:null,attachTo(t){return this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=document.createElement("div"),this.container.className="toast-container position-bottom",t.appendChild(this.container),this.container},currentToast:null,currentTimer:null,show(t,e=2e3){if(!this.container){console.warn("NativeToast: container not initialized, please call attachTo first");return}this.currentToast&&this.container.contains(this.currentToast)&&(this.container.removeChild(this.currentToast),this.currentToast=null),this.currentTimer&&(clearTimeout(this.currentTimer),this.currentTimer=null);const n=document.createElement("div");n.className="toast-message toast-visible",n.textContent=t,this.container.appendChild(n),this.currentToast=n,this.currentTimer=setTimeout(()=>{n.classList.remove("toast-visible"),setTimeout(()=>{this.container&&this.container.contains(n)&&(this.container.removeChild(n),this.currentToast===n&&(this.currentToast=null))},300),this.currentTimer=null},e)},clearAll(){if(this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}},Dt=()=>{const{gameProgress:t,setGameProgress:e,gamePlayState:n,setGamePlayState:o,gamePlayStateRef:i,resetGame:s,config:a}=ne(),{i18n:r,levelConfig:l}=a,c=oe(l),{levelTransitioning:d,showClue:u}=n,{highestUnlockedLevel:h,totalScore:f}=t,k=c.getTotalLevels(),[p,_]=U(!1),[b,w]=U(!1),[A,C]=U(!1),z=O=>{const x=c.getFirstLevelOfTier(O);c.isLevelUnlocked(x,h)&&(e($=>({...$,currentTier:O})),S(x))},S=O=>{c.isLevelUnlocked(O,h)&&(e(x=>({...x,currentLevel:O})),G.show(r.levelGoToast.replace("%LEVEL%",O.toString())))},E=()=>{_(!0)},L=()=>{_(!1)},y=()=>{C(!0)},g=()=>{C(!1)},v=()=>{G.show(u?r.cluePathDisabled:r.cluePathEnabled),o(()=>({...i.current,showClue:!i.current.showClue})),C(!1)},T=()=>{w(!0)},N=()=>{s(),w(!1),G.show(r.resetDoneToast)},I=()=>{w(!1)};return m("div",{class:"game-panel-container",children:[m("div",{className:"game-controls",children:[m("div",{className:"selectors-container",children:[m(Rt,{onTierChange:z,disabled:d}),m(Ft,{onLevelChange:S,disabled:d})]}),m("button",{className:`settings-clue-button ${u?"clue-on":"clue-off"}`,disabled:u,title:"Toggle Clue",onClick:y,children:u?r.clueOn:r.clueOff})]}),m("div",{className:"game-settings",children:m("span",{className:"game-settings-icon",onClick:E,children:"★ "+f})}),m(re,{isOpen:p,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:L,children:[m("div",{className:"settings-stats",children:[m("div",{children:r.levelComplete+`: ${h}/${k}`}),m("div",{children:r.starsCollected+": "+f}),m("div",{children:r.avgStarPerLevel+": "+(f/h).toFixed(2)})]}),m("div",{className:"settings-item-box",children:[m("button",{className:"settings-reset-button",title:"Reset Game",onClick:T,children:r.reset}),m("div",{className:"settings-item-tip",children:r.resetTip})]})]}),m(re,{isOpen:b,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:N,onCancel:I}),m(re,{isOpen:A,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:v,onCancel:g})]})};function Ee(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function Le(t,e,n){return e&&Ot(t.prototype,e),t}function at(t){return+t.replace(/px/,"")}function $t(t){var e=window.devicePixelRatio,n=getComputedStyle(t),o=at(n.getPropertyValue("width")),i=at(n.getPropertyValue("height"));t.setAttribute("width",(o*e).toString()),t.setAttribute("height",(i*e).toString())}function j(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=Math.random()*(e-t)+t;return Math.floor(o*Math.pow(10,n))/Math.pow(10,n)}function lt(t){return t[j(0,t.length)]}var Ut=.00125,Gt=5e-4,jt=9e-4,Wt=1e-5,qt=6,Ht=80,Bt=.9,Vt=1.7,Xt=.2,Yt=.6,Kt=.03,Jt=.07,Zt=15,Qt=82,en=100,tn=250,nn=40,on=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function ct(t){var e=1920;return Math.log(t)/Math.log(e)}var ut=function(){function t(e){Ee(this,t);var n=e.initialPosition,o=e.direction,i=e.confettiRadius,s=e.confettiColors,a=e.emojis,r=e.emojiSize,l=e.canvasWidth,c=j(Bt,Vt,3),d=c*ct(l);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=j(Xt,Yt,3),this.rotationSpeed=a.length?.01:j(Kt,Jt,3)*ct(l),this.dragForceCoefficient=j(Gt,jt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=o==="left"?j(0,.2,3):j(-.2,0,3),this.emojiSize=r,this.emojiRotationAngle=j(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=o==="left"?j(Qt,Zt)*Math.PI/180:j(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var h=j(-150,0),f={x:n.x+(o==="left"?-h:h)*this.absCos,y:n.y-h*this.absSin};this.currentPosition=Object.assign({},f),this.initialPosition=Object.assign({},f),this.color=a.length?null:lt(s),this.emoji=a.length?lt(a):null,this.createdAt=new Date().getTime(),this.direction=o}return Le(t,[{key:"draw",value:function(n){var o=this.currentPosition,i=this.radius,s=this.color,a=this.emoji,r=this.rotationAngle,l=this.emojiRotationAngle,c=this.emojiSize,d=window.devicePixelRatio;s?(n.fillStyle=s,n.beginPath(),n.ellipse(o.x*d,o.y*d,i.x*d,i.y*d,r,0,2*Math.PI),n.fill()):a&&(n.font="".concat(c,"px serif"),n.save(),n.translate(d*o.x,d*o.y),n.rotate(l),n.textAlign="center",n.fillText(a,0,0),n.restore())}},{key:"updatePosition",value:function(n,o){var i=this.confettiSpeed,s=this.dragForceCoefficient,a=this.finalConfettiSpeedX,r=this.radiusYUpdateDirection,l=this.rotationSpeed,c=this.createdAt,d=this.direction,u=o-c;if(i.x>a&&(this.confettiSpeed.x-=s*n),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*n,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+Ut*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:Wt*n,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*n%(2*Math.PI);return}r==="down"?(this.radius.y-=n*l,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=n*l,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(n){return this.currentPosition.y<n+en}}]),t}();function rn(){var t=document.createElement("canvas");return t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.zIndex="1000",t.style.pointerEvents="none",document.body.appendChild(t),t}function sn(t){var e=t.confettiRadius,n=e===void 0?qt:e,o=t.confettiNumber,i=o===void 0?t.confettiesNumber||(t.emojis?nn:tn):o,s=t.confettiColors,a=s===void 0?on:s,r=t.emojis,l=r===void 0?t.emojies||[]:r,c=t.emojiSize,d=c===void 0?Ht:c;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:n,confettiNumber:i,confettiColors:a,emojis:l,emojiSize:d}}var an=function(){function t(e){var n=this;Ee(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(o){return n.resolvePromise=o})}return Le(t,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var n;(n=this.shapes).push.apply(n,arguments)}},{key:"complete",value:function(){var n;return this.shapes.length?!1:((n=this.resolvePromise)===null||n===void 0||n.call(this),!0)}},{key:"processShapes",value:function(n,o,i){var s=this,a=n.timeDelta,r=n.currentTime;this.shapes=this.shapes.filter(function(l){return l.updatePosition(a,r),l.draw(s.canvasContext),i?l.getIsVisibleOnCanvas(o):!0})}}]),t}(),ln=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ee(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||rn(),this.canvasContext=this.canvas.getContext("2d"),this.requestAnimationFrameRequested=!1,this.lastUpdated=new Date().getTime(),this.iterationIndex=0,this.loop=this.loop.bind(this),requestAnimationFrame(this.loop)}return Le(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,$t(this.canvas);var n=new Date().getTime(),o=n-this.lastUpdated,i=this.canvas.offsetHeight,s=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(a){return a.processShapes({timeDelta:o,currentTime:n},i,s),s?!a.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(n)}},{key:"queueAnimationFrameIfNeeded",value:function(n){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=n||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=sn(n),i=o.confettiRadius,s=o.confettiNumber,a=o.confettiColors,r=o.emojis,l=o.emojiSize,c=this.canvas.getBoundingClientRect(),d=c.width,u=c.height,h=u*5/7,f={x:0,y:h},k={x:d,y:h},p=new an(this.canvasContext),_=0;_<s/2;_++){var b=new ut({initialPosition:f,direction:"right",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d}),w=new ut({initialPosition:k,direction:"left",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d});p.addShapes(b,w)}return this.activeConfettiBatches.push(p),this.queueAnimationFrameIfNeeded(),p.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const cn=new ln,Ne=3,un=({onRetry:t})=>{const{config:e,currentScore:n,gamePlayState:o,setGamePlayState:i,gameProgress:s,setGameProgress:a}=ne(),{i18n:r,levelConfig:l}=e,[c,d,u]=n,{foodCollected:h,totalFoodCount:f,playerAtExit:k,levelTransitioning:p}=o,{currentLevel:_}=s,[b,w]=U(!1);R(()=>{k&&p&&(cn.addConfetti(),G.show(r.levelCompleteToast),w(!0))},[k,p]);const A=oe(l),C=A.getTotalLevels(),z=Z(()=>_>=C,[_,C]),S=()=>{w(!1),G.show(r.levelRestartToast),t?.()},E=()=>{w(!1),i(g=>({...g,isGameActive:!0,levelTransitioning:!1}))},L=()=>{w(!1);const g=A.getNextLevelInfo(_);if(!g)return;const{nextLevel:v,nextTier:T,isTierChange:N}=g;N&&G.show(r.tierUnlockedToast.replace("%TIER%",T.toString())),a(I=>({...I,currentLevel:v,currentTier:T,highestUnlockedLevel:Math.max(I.highestUnlockedLevel,v),highestUnlockedTier:Math.max(I.highestUnlockedTier,T),levelScores:{...I.levelScores,[I.currentLevel]:Math.max(Object.values(n).filter(Boolean).length,I.levelScores[I.currentLevel]||0)}}))},y=()=>{w(!1),a(g=>{const v=Math.max(Object.values(n).filter(Boolean).length,g.levelScores[g.currentLevel]||0),T={...g.levelScores,[g.currentLevel]:v};let N=0,I=0;const O=Object.entries(T).sort((x,$)=>Number(x[0])-Number($[0]));for(const[x,$]of O)if($<Ne){N=Number(x),I=A.getTierByLevel(N);break}return(N>0&&N!==_||v<Ne)&&G.show(r.notCompleteLevel),(N===0||v<Ne)&&t?.(),{...g,currentLevel:N||g.currentLevel,currentTier:I||g.currentTier,levelScores:T}})};return R(()=>{const g=document.querySelector(".maze-game-container"),v=T=>{b&&((T.key===" "||T.code==="Space")&&g&&(g.contains(document.activeElement)||document.activeElement===document.body)&&(T.preventDefault(),z?y():L()),(T.key==="r"||T.code==="KeyR")&&S(),(T.key==="c"||T.code==="KeyC")&&E())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b,z]),m(re,{className:"level-complete-dialog",isOpen:b,title:r.congratulations,cancelText:r.retry+" (R)",onCancel:S,noConfirm:!!d,confirmText:r.continue+" (C)",onConfirm:E,confirmClass:"maze-continue-btn",children:[m("div",{className:"maze-summary-message",children:[!!c&&m("div",{children:"★ - "+r.findYourExit}),m("div",{children:u?"★ - "+r.withoutClue:"☆ - "+r.withClue}),m("div",{children:(d?"★ - "+r.collectAllStars:"☆ - "+r.notCollectAllStars)+` (${h}/${f})`})]}),z&&m("div",{className:"all-levels-completed",children:r.allLevelsCompleted}),m("div",{className:"maze-go-next",children:z?m("button",{className:"maze-go-next-btn",type:"button",onClick:y,children:[m("span",{children:r.lastOK}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]}):m("button",{className:"maze-go-next-btn",type:"button",onClick:L,children:[m("span",{children:r.nextLevel}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]})}),!d&&m("div",{className:"not-all-stars-collected",children:r.continueMessage})]})},dt=(t,e)=>{const n=D({canvasWidth:0,canvasHeight:0});return R(()=>{const o=()=>{const s=t.current;if(!s)return;const a=s.parentElement;if(!a)return;const r=a.clientWidth,l=window.devicePixelRatio||1;s.style.width=`${r}px`,s.style.height=`${r}px`;const c=r*l,d=r*l;s.width=c,s.height=d,n.current={canvasWidth:c,canvasHeight:d},e?.()};o();let i=null;return window.ResizeObserver&&t.current&&(i=new ResizeObserver(o),i.observe(t.current.parentElement)),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i?.disconnect()}},[t,e]),n},ht=(t,e,n)=>{const o=D({cellWidth:0,cellHeight:0});return R(()=>{const i=()=>{const a=t.current,r=e.maze;if(!a||!r)return;const{rows:l,cols:c}=r;if(l<=0||c<=0)return;const d=(a.width-n*2)/c,u=(a.height-n*2)/l;o.current={cellWidth:d,cellHeight:u}};i();let s=null;return t.current&&window.ResizeObserver&&(s=new ResizeObserver(i),s.observe(t.current)),()=>{t.current&&s?.disconnect()}},[t,e.maze,n]),o},fe={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},ft=({containerRef:t,gamePlayStateRef:e,setGamePlayState:n,moveSpeed:o,moveSpeedRef:i,playerRadius:s,onFoodCollected:a,onExitReached:r,onFirstMove:l})=>{const c=()=>i?.current??o??.03,d=D(!1),u=D(new Set),h=D(!1),f=tt((C,z)=>{const S=e.current;if(!S.maze)return{canMove:!1,newCell:null};const E=c(),[L,y]=fe[C];if(mt(z,L,y,s,E,S.maze))return{canMove:!1,newCell:null};const{row:v,col:T}=z,N=v+L*E,I=T+y*E,O=-.5,x=S.maze.rows,$=S.maze.cols;if(N<O||N>=x||I<O||I>=$)return{canMove:!1,newCell:null};const X=v<0?0:Math.floor(v),Y=T<0?0:Math.floor(T),W=N<0?0:Math.floor(N),q=I<0?0:Math.floor(I);return W!==X||q!==Y?S.maze.isValid(W,q)?{canMove:!0,newCell:{row:W,col:q}}:{canMove:!1,newCell:null}:{canMove:!0,newCell:null}},[s,c]),k=()=>{const C=e.current,{row:z,col:S}=C.playerCell,E=s*2,L=C.foodCells.findIndex(v=>Math.sqrt(Math.pow(z-v.row,2)+Math.pow(S-v.col,2))<E);L!==-1&&a&&(a(),e.current={...e.current,foodCollected:e.current.foodCollected+1,foodCells:e.current.foodCells.filter((v,T)=>T!==L)});const g=fn(C.playerCell,C.exitCell,C.maze);g&&!e.current.playerAtExit?(e.current={...e.current,playerAtExit:!0,isGameActive:!1,levelTransitioning:!0},r&&r(),requestIdleCallback(()=>{n(()=>({...e.current}))},{timeout:10})):!g&&e.current.playerAtExit&&(e.current={...e.current,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1})},p=C=>{const z=e.current,S=Math.round(C.row),E=Math.round(C.col),L=z.playerPath[z.playerPath.length-1],y=L.row===S&&L.col===E,g=Math.abs(L.row-S),v=Math.abs(L.col-E);if((g===1&&v===0||g===0&&v===1)&&!y){const N=`${L.row},${L.col}-${S},${E}`;e.current={...e.current,playerPath:[...e.current.playerPath,{row:S,col:E}],visitCounts:{...e.current.visitCounts,[N]:(e.current.visitCounts[N]||0)+1}}}},_=()=>{if(d.current||u.current.size===0)return;const C=e.current;!C.playerCell||!Array.from(u.current).some(S=>{const{canMove:E}=f(S,C.playerCell);return E})||(!h.current&&l&&(h.current=!0,l()),d.current=!0)};R(()=>{const C=y=>{if(y.key==="ArrowUp"||y.key==="ArrowDown"||y.key==="ArrowLeft"||y.key==="ArrowRight"||y.key===" "){const g=document.activeElement;if(g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.getAttribute("contenteditable")==="true"))return;y.preventDefault()}},z=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),e.current.isGameActive&&(u.current.has(g)||(u.current.add(g),d.current||_())))},S=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),u.current.delete(g),u.current.size===0&&w())},E=y=>{y.preventDefault();const g=e.current;if(!g.isGameActive||!g.maze||d.current)return;const v=y.touches[0],T=document.elementFromPoint(v.clientX,v.clientY);let N=null;T&&(T.classList.contains("maze-up")?N="ArrowUp":T.classList.contains("maze-down")?N="ArrowDown":T.classList.contains("maze-left")?N="ArrowLeft":T.classList.contains("maze-right")&&(N="ArrowRight")),N&&(u.current.clear(),u.current.add(N),_())},L=()=>{w()};return window.addEventListener("keydown",C,{capture:!0}),window.addEventListener("keydown",z),window.addEventListener("keyup",S),t.current?.addEventListener("touchstart",E,{passive:!1}),t.current?.addEventListener("touchend",L),()=>{window.removeEventListener("keydown",C,{capture:!0}),window.removeEventListener("keydown",z),window.removeEventListener("keyup",S),t.current?.removeEventListener("touchstart",E),t.current?.removeEventListener("touchend",L)}},[]);const b=tt(()=>{if(!d.current||u.current.size===0)return e.current.playerCell;const C=c(),z=e.current.playerCell;let S=0,E=0,L=0;for(const Q of u.current){const{canMove:Me}=f(Q,z);if(Me){const[Ct,xn]=fe[Q];S+=Ct,E+=xn,L++}}if(L===0)return e.current.playerCell;const y=Math.sqrt(S*S+E*E),g=y>0?S/y:0,v=y>0?E/y:0,T=Number((z.row+g*C).toFixed(2)),N=Number((z.col+v*C).toFixed(2)),I=T-z.row,O=N-z.col,x=Math.sqrt(I*I+O*O);if(x>0){const Q=I/x,Me=O/x;if(mt(z,Q,Me,s,x,e.current.maze))return e.current.playerCell}e.current.playerCell={row:T,col:N},k();const $=z.row<0?0:Math.round(z.row),X=z.col<0?0:Math.round(z.col),Y=T<0?0:Math.round(T),W=N<0?0:Math.round(N);return(Y!==$||W!==X)&&p({row:Y,col:W}),e.current.playerCell},[c,f]),w=()=>{d.current=!1,u.current.clear()};return{updatePlayerPos:b,resetMovingState:w,resetFirstMoveState:()=>{h.current=!1}}};function mt(t,e,n,o,i,s){const a=t.row+e*i,r=t.col+n*i,l={row:a,col:r},c=[],d=t.row<0?0:Math.floor(t.row),u=t.col<0?0:Math.floor(t.col);c.push({row:d,col:u});const h=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[f,k]of h){const p=d+f,_=u+k;s.isValid(p,_)&&c.push({row:p,col:_})}for(const f of c){const k=dn(f.row,f.col,s);for(const p of k)if(hn(l,p)<o)return!0}return!1}function dn(t,e,n){const o=[],i=n.grid[t][e];return i.walls.top&&o.push({start:{row:t-.5,col:e-.5},end:{row:t-.5,col:e+.5}}),i.walls.right&&o.push({start:{row:t-.5,col:e+.5},end:{row:t+.5,col:e+.5}}),i.walls.bottom&&o.push({start:{row:t+.5,col:e-.5},end:{row:t+.5,col:e+.5}}),i.walls.left&&o.push({start:{row:t-.5,col:e-.5},end:{row:t+.5,col:e-.5}}),o}function hn(t,e){const{start:n,end:o}=e,i=o.col-n.col,s=o.row-n.row,a=t.col-n.col,r=t.row-n.row,l=i*i+s*s;if(l===0)return Math.sqrt(a*a+r*r);const c=Math.max(0,Math.min(1,(a*i+r*s)/l)),d=n.col+c*i,u=n.row+c*s,h=t.col-d,f=t.row-u;return Math.sqrt(h*h+f*f)}function fn(t,e,n){if(!n.isValid(e.row,e.col))return!1;const o=t.col>=e.col-.5&&t.col<=e.col+.5,i=t.row>=e.row+.5,s=t.row>=e.row-.5;return o&&i&&s}function _t(t,e,n,o,i){if(!t||!e.maze)return;const{canvasWidth:s,canvasHeight:a}=n,{cellWidth:r,cellHeight:l}=o,{maze:c,playerCell:d,exitCell:u,foodCells:h,showClue:f,playerPath:k,visitCounts:p}=e,{padding:_,wallWidth:b,wallColor:w,playerColor:A,playerRadius:C,foodColor:z,backgroundColor:S,clueColor:E,exitColor:L,exitWallWidth:y,exitDashArray:g}=i;t.clearRect(0,0,s,a),t.save(),t.fillStyle=S,t.fillRect(0,0,s,a),t.restore(),f&&wn({ctx:t,playerPath:k,visitCounts:p,cellWidth:r,cellHeight:l,padding:_,clueColor:E}),mn({ctx:t,maze:c,cellWidth:r,cellHeight:l,padding:_,wallColor:w,wallWidth:b}),vn({ctx:t,maze:c,exitCell:u,cellWidth:r,cellHeight:l,padding:_,exitColor:L,exitWallWidth:y,exitDashArray:g}),gn({ctx:t,foodCells:h,cellWidth:r,cellHeight:l,padding:_,foodColor:z}),_n({ctx:t,playerCell:d,playerRadius:C,cellWidth:r,cellHeight:l,padding:_,playerColor:A})}function mn({ctx:t,maze:e,cellWidth:n,cellHeight:o,padding:i,wallColor:s,wallWidth:a}){t.save(),t.strokeStyle=s,t.lineWidth=a,t.lineCap="round",t.beginPath(),Cn(e,n,o,i).forEach(l=>{t.moveTo(l.x1,l.y1),t.lineTo(l.x2,l.y2)}),t.stroke(),t.restore()}function _n({ctx:t,playerCell:e,playerRadius:n,cellWidth:o,cellHeight:i,padding:s,playerColor:a}){const{x:r,y:l}=me(e.row,e.col,o,i,s),c=Math.min(o,i)*Math.min(n,.5);t.save(),t.fillStyle=a,t.beginPath(),t.arc(r,l,c,0,Math.PI*2),t.fill(),t.restore()}function vn({ctx:t,maze:e,exitCell:n,cellWidth:o,cellHeight:i,padding:s,exitColor:a,exitWallWidth:r,exitDashArray:l=[8,12]}){const{row:c,col:d}=n;if(!e.isValid(c,d))return;const u=s+d*o,h=s+c*i;t.save(),t.globalCompositeOperation="destination-out",t.lineWidth=r,t.lineCap="round",t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.globalCompositeOperation="source-over",t.strokeStyle=a,t.lineWidth=r,t.setLineDash(l),t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.restore()}function gn({ctx:t,foodCells:e,cellWidth:n,cellHeight:o,padding:i,foodColor:s}){t.fillStyle=s;const a=Math.min(n,o)*.25;e.forEach(r=>{const{x:l,y:c}=me(r.row,r.col,n,o,i);pn(t,l,c,a*1.2,5,a*.6)})}function pn(t,e,n,o,i,s){t.save(),t.beginPath();for(let a=0;a<i*2;a++){const r=a%2===0?o:s,l=Math.PI*a/i;t.lineTo(e+r*Math.sin(l),n+r*Math.cos(l))}t.closePath(),t.fill(),t.restore()}function wn({ctx:t,playerPath:e,visitCounts:n,cellWidth:o,cellHeight:i,padding:s,clueColor:a}){if(!(!e||e.length<2||!n)){t.save();for(let r=1;r<e.length;r++){const l=e[r-1],c=e[r],d=`${l.row},${l.col}-${c.row},${c.col}`,u=`${c.row},${c.col}-${l.row},${l.col}`,h=(n[d]||0)+(n[u]||0),f=Math.min(.2+h*.1,.9),k=Math.max(3,o*.1)+h*.5;try{t.strokeStyle=a.replace(")",`, ${f})`).replace("rgb(","rgba(")}catch{t.strokeStyle=`rgba(255, 0, 0, ${f})`}t.lineWidth=k,t.lineCap="round",t.lineJoin="round";const{x:p,y:_}=me(l.row,l.col,o,i,s),{x:b,y:w}=me(c.row,c.col,o,i,s);t.beginPath(),t.moveTo(p,_),t.lineTo(b,w),t.stroke()}t.restore()}}function Cn(t,e,n,o){const i=[];for(let s=0;s<t.rows;s++)for(let a=0;a<t.cols;a++){const r=t.grid[s][a],l=o+a*e,c=o+s*n;r.walls.top&&i.push({x1:l,y1:c,x2:l+e,y2:c}),r.walls.right&&i.push({x1:l+e,y1:c,x2:l+e,y2:c+n}),r.walls.bottom&&i.push({x1:l,y1:c+n,x2:l+e,y2:c+n}),r.walls.left&&i.push({x1:l,y1:c,x2:l,y2:c+n})}return i}function me(t,e,n,o,i){return{x:i+e*n+n/2,y:i+t*o+o/2}}function yn(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}class bn{constructor(e,n){this.row=e,this.col=n}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class vt{rows;cols;grid;seed;random;constructor(e,n,o,i,s={row:0,col:0},a={row:e-1,col:n-1}){this.rows=e,this.cols=n,this.seed=i??Math.floor(Math.random()*1e6),this.random=yn(this.seed),this.grid=this.initializeGrid(),this.generate(o,s,a)}initializeGrid(){const e=[];for(let n=0;n<this.rows;n++){e[n]=[];for(let o=0;o<this.cols;o++)e[n][o]=new bn(n,o)}return e}isValid(e,n){return e>=0&&e<this.rows&&n>=0&&n<this.cols}getNeighbors(e,n){const o=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const s of i){const a=e+s.r,r=n+s.c;this.isValid(a,r)&&o.push({row:a,col:r})}return o}getUnvisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>!this.grid[o.row][o.col].visited)}getVisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>this.grid[o.row][o.col].visited)}removeWall(e,n,o,i){const s=this.grid[e][n],a=this.grid[o][i];e===o+1?(s.walls.top=!1,a.walls.bottom=!1):e===o-1?(s.walls.bottom=!1,a.walls.top=!1):n===i+1?(s.walls.left=!1,a.walls.right=!1):n===i-1&&(s.walls.right=!1,a.walls.left=!1)}generate(e,n={row:0,col:0},o={row:this.rows-1,col:this.cols-1}){switch(e){case"backtracking":this.generateWithBacktracking();break;case"prims":this.generateWithPrims();break;default:throw new Error(`Unknown maze generation method: ${e}`)}this.addOpenings(n,o)}generateWithBacktracking(){const e=[],n=this.randomNumber(this.rows),o=this.randomNumber(this.cols);let i={row:n,col:o};for(this.grid[n][o].visited=!0,e.push(i);e.length>0;){i=e[e.length-1];const{row:s,col:a}=i,r=this.getUnvisitedNeighbors(s,a);if(r.length>0){const l=this.randomPick(r),{row:c,col:d}=l;this.removeWall(s,a,c,d),this.grid[c][d].visited=!0,e.push(l)}else e.pop()}}generateWithPrims(){const e=[],n=(s,a)=>{const r=this.getNeighbors(s,a);for(const l of r)!this.grid[l.row][l.col].visited&&!e.some(c=>c.row===l.row&&c.col===l.col)&&e.push(l)},o=this.randomNumber(this.rows),i=this.randomNumber(this.cols);for(this.grid[o][i].visited=!0,n(o,i);e.length>0;){const s=this.randomNumber(e.length),a=e[s],{row:r,col:l}=a,c=this.getVisitedNeighbors(r,l);if(c.length>0){const d=this.randomPick(c);this.removeWall(r,l,d.row,d.col),this.grid[r][l].visited=!0,n(r,l)}e.splice(s,1)}}addOpenings(e,n){this.grid[e.row][e.col].walls.top=!1,this.isValid(n.row,n.col)&&(this.grid[n.row][n.col].walls.bottom=!1)}randomNumber(e){return Math.floor(this.random()*e)}randomPick(e){return e[Math.floor(this.random()*e.length)]}}const gt=(t,e,n)=>{if(!t.isValid(e,n))return!1;const o=t.grid[e][n];return!o.walls.top||!o.walls.right||!o.walls.bottom||!o.walls.left},Tn=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6,kn=(t,e)=>{if(!e)return console.error(`Cannot find Level ${t}'s config.`),null;const{size:n,seed:o,method:i,entry:s,exit:a}=e,r=n,l=n,c=s||{row:0,col:0},d=a||{row:r-1,col:l-1},u=new vt(r,l,i,o,c,d),h=Tn(t),f=[];for(let k=0;k<h;k++){let p;do p={row:Math.floor(u.random()*r),col:Math.floor(u.random()*l)};while(p.row===c.row&&p.col===c.col||p.row===d.row&&p.col===d.col||!gt(u,p.row,p.col)||f.some(_=>_.row===p.row&&_.col===p.col));f.push(p)}return{isGameActive:!0,levelTransitioning:!1,maze:u,playerCell:c,exitCell:d,foodCells:f,playerAtExit:!1,foodCollected:0,totalFoodCount:h,showClue:!1,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1}}},Sn=({size:t,seed:e,method:n,foodCount:o})=>{const i=t,s=t,a={row:0,col:0},r={row:i-1,col:s-1},l=new vt(i,s,n,e,a,r),c=[];for(let d=0;d<o;d++){let u,h=0;do u={row:Math.floor(l.random()*i),col:Math.floor(l.random()*s)},h++;while(h<50&&(u.row===a.row&&u.col===a.col||u.row===r.row&&u.col===r.col||!gt(l,u.row,u.col)||c.some(f=>f.row===u.row&&f.col===u.col)));h<50&&c.push(u)}return{isGameActive:!0,levelTransitioning:!1,maze:l,playerCell:a,exitCell:r,foodCells:c,playerAtExit:!1,foodCollected:0,totalFoodCount:o}};function zn(){const{setGamePlayState:t,gamePlayState:e,gamePlayStateRef:n,gameProgress:o,config:i}=ne(),s=D(null),a=D(null),{i18n:r,levelConfig:l,renderConfig:c}=i,d=oe(l),u=D(d.getLevelConfig(o.currentLevel));R(()=>{s.current&&G.attachTo(s.current)},[]);const h=D(),f=dt(a,()=>{h.current?.()}),k=ht(a,e,c.padding);R(()=>{u.current=d.getLevelConfig(o.currentLevel)},[o.currentLevel]);const p=()=>{const A=kn(o.currentLevel,u.current);A&&t(C=>({...C,...A}))};R(()=>{p()},[o.currentLevel]);const _=()=>{p()},{updatePlayerPos:b,resetMovingState:w}=ft({containerRef:s,gamePlayStateRef:n,setGamePlayState:t,playerRadius:c.playerRadius,moveSpeed:c.gridMoveSpeed,onFoodCollected:()=>{const A=n.current.totalFoodCount-n.current.foodCollected-1;A>0?G.show(r.foodCollectedToast.replace("%NUM%",A.toString()),3e3):G.show(r.allFoodCollectedToast)}});return R(()=>{w()},[o.currentLevel,w]),R(()=>{let A,C=!document.hidden;const z=()=>{const L=a.current?.getContext("2d"),y=n.current;if(!(C&&y?.isGameActive&&L&&y?.maze)){A=requestAnimationFrame(z);return}b(),S(),A=requestAnimationFrame(z)},S=()=>{const L=a.current?.getContext("2d"),y=n.current;if(L&&y?.maze){const g=u.current?.wallWidth||c?.wallWidth,v=u.current?.exitColor||c?.exitColor,T=u.current?.exitWallWidth||c?.exitWallWidth,N=u.current?.exitDashArray||c?.exitDashArray;_t(L,y,f.current,k.current,{...c,wallWidth:g,exitColor:v,exitWallWidth:T,exitDashArray:N})}};h.current=S;const E=L=>{const y=C;C=!document.hidden&&document.visibilityState==="visible"&&(!L||L.type!=="blur"),!y&&C?n.current?.levelTransitioning===!1&&t({...n.current,isGameActive:!0}):y&&!C&&t({...n.current,isGameActive:!1})};return document.addEventListener("visibilitychange",E),window.addEventListener("blur",E),window.addEventListener("focus",E),A=requestAnimationFrame(z),()=>{cancelAnimationFrame(A),document.removeEventListener("visibilitychange",E),window.removeEventListener("blur",E),window.removeEventListener("focus",E)}},[]),R(()=>{G.show(r.useArrowKeyTips,3e3)},[]),m("div",{className:"maze-game-container",children:[m(Dt,{}),m(un,{onRetry:_}),m("div",{className:"maze-canvas-container",ref:s,children:[m("canvas",{ref:a,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]})]})}const En=t=>{const e=Math.floor(t/60),n=t%60;return`${e.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`},Ln=({timer:t,onTimeUp:e})=>{const[n,o]=U(t),i=D(),s=D(!1);return R(()=>{const a=()=>{!s.current&&!i.current&&(s.current=!0,i.current=setInterval(()=>{o(l=>l<=1?(clearInterval(i.current),e(),0):l-1)},1e3))},r=()=>{clearInterval(i.current),i.current=void 0};return window.addEventListener("maze:firstMove",a),window.addEventListener("maze:gameSuccess",r),()=>{window.removeEventListener("maze:firstMove",a),window.removeEventListener("maze:gameSuccess",r),clearInterval(i.current)}},[]),R(()=>{i.current&&(clearInterval(i.current),i.current=void 0),o(t),s.current=!1},[t]),m("div",{className:"single-maze-timer",children:m("span",{className:`maze-timer-text ${n<=10&&s.current?"maze-timer-warning":""}`,children:["⏱️ ",En(n)]})})};function Nn({config:t}){const{size:e,seed:n,method:o,foodCount:i,renderConfig:s,successCallback:a,failCallback:r,timer:l,i18n:c}=t,[d,u]=U({...ze}),[h,f]=U(!1),[k,p]=U(!1),[_,b]=U(!1),[w,A]=U(""),C=D(null),z=D(null),S=D(d),E=D(),L=dt(C,()=>{E.current?.()}),y=ht(C,d,s.padding);R(()=>{S.current=d},[d]);const{updatePlayerPos:g,resetMovingState:v,resetFirstMoveState:T}=ft({containerRef:z,gamePlayStateRef:S,setGamePlayState:u,playerRadius:s.playerRadius,moveSpeed:s.gridMoveSpeed,onFoodCollected:()=>{console.log("Food collected in single maze")},onExitReached:()=>{k||I()},onFirstMove:()=>{window.dispatchEvent(new CustomEvent("maze:firstMove"))}}),N=()=>{p(!0),A(`⏰ ${c.failMsg}`),b(!0),u(x=>({...x,isGameActive:!1})),r&&r()},I=()=>{p(!0),A(`🎉 ${c.successMsg}`),b(!0),window.dispatchEvent(new CustomEvent("maze:gameSuccess")),a&&a()},O=()=>{b(!1)};return R(()=>{(async()=>{f(!0);try{const $=Sn({size:e,seed:n,method:o,foodCount:i});S.current=$,u($)}catch($){console.error("Error generating single maze:",$)}finally{f(!1)}})()},[t]),R(()=>{let x;const $=!document.hidden,X=()=>{const W=C.current?.getContext("2d"),q=S.current;if(!($&&q?.isGameActive&&W&&q?.maze)){x=requestAnimationFrame(X);return}g(),Y(),x=requestAnimationFrame(X)},Y=()=>{const W=C.current?.getContext("2d"),q=S.current;W&&q?.maze&&_t(W,q,L.current,y.current,s)};return E.current=Y,x=requestAnimationFrame(X),()=>{cancelAnimationFrame(x)}},[]),R(()=>{v(),T()},[t,v,T]),h?m("div",{className:"single-maze-loading",children:m("div",{children:"Generating maze..."})}):d?m("div",{className:"maze-game-container",children:[m(Ln,{timer:l,onTimeUp:N}),m("div",{className:"single-maze-canvas-container",ref:z,children:[m("canvas",{ref:C,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]}),m(re,{isOpen:_,title:w,noConfirm:!0,cancelText:"OK",onCancel:O})]}):m("div",{className:"single-maze-error",children:m("div",{children:"Failed to generate maze"})})}const pt=[[{size:8,seed:12345,method:"backtracking",wallWidth:4,exitWallWidth:6,exitDashArray:[8,12]},{size:8,seed:23456,method:"backtracking",exitColor:"#33f",exitWallWidth:4,exitDashArray:[8,16]},{size:8,seed:34567,method:"prims"},{size:8,seed:45678,method:"backtracking"},{size:9,seed:56789,method:"prims"},{size:9,seed:67890,method:"backtracking"},{size:9,seed:78901,method:"prims"},{size:9,seed:89012,method:"backtracking"},{size:10,seed:90123,method:"prims"},{size:11,seed:11111,method:"backtracking"},{size:12,seed:22222,method:"prims"},{size:13,seed:33333,method:"backtracking"}],[{size:12,seed:44444,method:"prims"},{size:12,seed:55555,method:"backtracking"},{size:12,seed:66666,method:"prims"},{size:12,seed:77777,method:"backtracking"},{size:13,seed:88888,method:"prims"},{size:13,seed:99999,method:"backtracking"},{size:13,seed:12121,method:"prims"},{size:14,seed:23232,method:"backtracking"},{size:15,seed:34343,method:"prims"},{size:16,seed:45454,method:"backtracking"},{size:17,seed:56565,method:"prims"},{size:18,seed:67676,method:"backtracking"}],[{size:19,seed:78787,method:"prims"},{size:20,seed:89898,method:"backtracking"},{size:21,seed:90909,method:"prims"},{size:22,seed:10101,method:"backtracking"},{size:23,seed:20202,method:"prims"},{size:25,seed:30303,method:"backtracking"},{size:27,seed:40404,method:"prims"},{size:29,seed:50505,method:"backtracking"},{size:31,seed:60606,method:"prims"},{size:33,seed:70707,method:"backtracking"},{size:37,seed:80808,method:"prims"},{size:40,seed:90909,method:"backtracking"}],[{size:41,seed:10111,method:"prims"},{size:42,seed:11121,method:"backtracking"},{size:43,seed:12131,method:"prims"},{size:44,seed:13141,method:"backtracking"},{size:45,seed:14151,method:"prims"},{size:46,seed:15161,method:"backtracking"},{size:47,seed:16171,method:"prims"},{size:48,seed:17181,method:"backtracking"},{size:49,seed:18191,method:"prims"},{size:50,seed:19201,method:"backtracking"},{size:51,seed:20211,method:"prims"},{size:52,seed:21221,method:"backtracking"}],[{size:53,seed:22231,method:"prims"},{size:54,seed:23241,method:"backtracking"},{size:55,seed:24251,method:"prims"},{size:56,seed:25261,method:"backtracking"},{size:57,seed:26271,method:"prims"},{size:58,seed:27281,method:"backtracking"},{size:59,seed:28291,method:"prims"},{size:60,seed:29301,method:"backtracking"},{size:62,seed:30311,method:"prims"},{size:64,seed:31321,method:"backtracking"},{size:66,seed:32331,method:"prims"},{size:68,seed:33341,method:"backtracking"}]],wt={gridMoveSpeed:.07,padding:10,wallWidth:2,wallColor:"#000000",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerRadius:.2,exitColor:"#F44336",exitWallWidth:4,exitDashArray:[8,12]},_e={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",congratulations:"Congratulations!",findYourExit:"Find your exit!",withoutClue:"Without clue!",withClue:"You used the clue!",collectAllStars:"Collect all stars!",notCollectAllStars:"Not collect all stars.",nextLevel:"Next Level ➤",spacebarTip:"Spacebar",retry:"Retry",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",allLevelsCompleted:"You completed all levels!",lastOK:"OK",notCompleteLevel:"You still have levels not collected all stars! Try again to collect them all!",continueMessage:"You still have levels where you haven't collected all stars. Try again to collect them all!",continue:"Continue",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:wt,levelConfig:pt},ve={i18n:{successMsg:"Congratulations! You completed the maze!",failMsg:"Time is up!",restart:"Restart"},size:8,seed:12345,method:"backtracking",foodCount:3,renderConfig:wt,timer:10*60,successCallback:()=>{console.log("🎉 Single maze completed successfully!")},failCallback:()=>{console.log("⏰ Time is up! Game failed.")}};function Mn({config:t={}}){const e={..._e.i18n,...t.i18n||{}},n={..._e.renderConfig,...t.renderConfig||{}},o=t.levelConfig||pt,i={..._e,...t,i18n:e,levelConfig:o,renderConfig:n};return m(xt,{config:i,children:m(zn,{})})}function An({config:t={}}){const e={...ve.i18n,...t.i18n||{}},n={...ve.renderConfig,...t.renderConfig||{}},o={...ve,...t,i18n:e,renderConfig:n};return m(Nn,{config:o})}const Pn={root:"https://unpkg.com/@roudanio/maze@0.2.1/dist/",..._e};`${JSON.stringify(Pn,null,2)}`;const In={root:"https://unpkg.com/@roudanio/maze@0.2.1/dist/",...ve};return`${JSON.stringify(In,(t,e)=>typeof e=="function"?e.toString():e,2)}`,{showNotice(){console.warn("Cannot find the root element");const t=document.createElement("div");t.style.textAlign="center",t.style.padding="20px",t.innerHTML="Cannot find the root element",document.body.append(t)},addLoadingIndicator(t){const e=document.createElement("div"),n=document.createElement("div");e.style.cssText=`
1
+ (function(B,M){typeof exports=="object"&&typeof module<"u"?module.exports=M():typeof define=="function"&&define.amd?define(M):(B=typeof globalThis<"u"?globalThis:B||self,B.Maze=M())})(this,function(){"use strict";var B,M,Ae,V,Pe,Ie,xe,Re,ge,pe,Ce,Fe,ee={},De=[],yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ie=Array.isArray;function H(t,e){for(var n in e)t[n]=e[n];return t}function we(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function bt(t,e,n){var o,i,s,a={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?B.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)a[s]==null&&(a[s]=t.defaultProps[s]);return se(t,a,o,i,null)}function se(t,e,n,o,i){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ae,__i:-1,__u:0};return i==null&&M.vnode!=null&&M.vnode(s),s}function ae(t){return t.children}function le(t,e){this.props=t,this.context=e}function K(t,e){if(e==null)return t.__?K(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?K(t):null}function Oe(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Oe(t)}}function ye(t){(!t.__d&&(t.__d=!0)&&V.push(t)&&!ce.__r++||Pe!=M.debounceRendering)&&((Pe=M.debounceRendering)||Ie)(ce)}function ce(){for(var t,e,n,o,i,s,a,r=1;V.length;)V.length>r&&V.sort(xe),t=V.shift(),r=V.length,t.__d&&(n=void 0,i=(o=(e=t).__v).__e,s=[],a=[],e.__P&&((n=H({},o)).__v=o.__v+1,M.vnode&&M.vnode(n),be(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[i]:null,s,i??K(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,We(s,n,a),n.__e!=i&&Oe(n)));ce.__r=0}function $e(t,e,n,o,i,s,a,r,l,c,d){var u,h,f,k,p,_,b=o&&o.__k||De,C=e.length;for(l=Tt(n,e,b,l,C),u=0;u<C;u++)(f=n.__k[u])!=null&&(h=f.__i==-1?ee:b[f.__i]||ee,f.__i=u,_=be(t,f,h,i,s,a,r,l,c,d),k=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&Te(h.ref,null,f),d.push(f.ref,f.__c||k,f)),p==null&&k!=null&&(p=k),4&f.__u||h.__k===f.__k?l=Ue(f,l,t):typeof f.type=="function"&&_!==void 0?l=_:k&&(l=k.nextSibling),f.__u&=-7);return n.__e=p,l}function Tt(t,e,n,o,i){var s,a,r,l,c,d=n.length,u=d,h=0;for(t.__k=new Array(i),s=0;s<i;s++)(a=e[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(l=s+h,(a=t.__k[s]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?se(null,a,null,null,null):ie(a)?se(ae,{children:a},null,null,null):a.constructor==null&&a.__b>0?se(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,r=null,(c=a.__i=kt(a,n,l,u))!=-1&&(u--,(r=n[c])&&(r.__u|=2)),r==null||r.__v==null?(c==-1&&(i>d?h--:i<d&&h++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,a.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<d;s++)(r=n[s])!=null&&(2&r.__u)==0&&(r.__e==o&&(o=K(r)),He(r,r));return o}function Ue(t,e,n){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Ue(o[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=K(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function kt(t,e,n,o){var i,s,a=t.key,r=t.type,l=e[n];if(l===null&&t.key==null||l&&a==l.key&&r==l.type&&(2&l.__u)==0)return n;if(o>(l!=null&&(2&l.__u)==0?1:0))for(i=n-1,s=n+1;i>=0||s<e.length;){if(i>=0){if((l=e[i])&&(2&l.__u)==0&&a==l.key&&r==l.type)return i;i--}if(s<e.length){if((l=e[s])&&(2&l.__u)==0&&a==l.key&&r==l.type)return s;s++}}return-1}function Ge(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||yt.test(e)?n:n+"px"}function ue(t,e,n,o,i){var s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Ge(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Ge(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Re,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?o?n.u=o.u:(n.u=ge,t.addEventListener(e,s?Ce:pe,s)):t.removeEventListener(e,s?Ce:pe,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function je(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ge++;else if(e.t<n.u)return;return n(M.event?M.event(e):e)}}}function be(t,e,n,o,i,s,a,r,l,c){var d,u,h,f,k,p,_,b,C,A,w,z,S,E,L,y,g,v=e.type;if(e.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),s=[r=e.__e=n.__e]),(d=M.__b)&&d(e);e:if(typeof v=="function")try{if(b=e.props,C="prototype"in v&&v.prototype.render,A=(d=v.contextType)&&o[d.__c],w=d?A?A.props.value:d.__:o,n.__c?_=(u=e.__c=n.__c).__=u.__E:(C?e.__c=u=new v(b,w):(e.__c=u=new le(b,w),u.constructor=v,u.render=zt),A&&A.sub(u),u.props=b,u.state||(u.state={}),u.context=w,u.__n=o,h=u.__d=!0,u.__h=[],u._sb=[]),C&&u.__s==null&&(u.__s=u.state),C&&v.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=H({},u.__s)),H(u.__s,v.getDerivedStateFromProps(b,u.__s))),f=u.props,k=u.state,u.__v=e,h)C&&v.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),C&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(C&&v.getDerivedStateFromProps==null&&b!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(b,w),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(b,u.__s,w)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(u.props=b,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(T){T&&(T.__=e)}),z=0;z<u._sb.length;z++)u.__h.push(u._sb[z]);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(b,u.__s,w),C&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,k,p)})}if(u.context=w,u.props=b,u.__P=t,u.__e=!1,S=M.__r,E=0,C){for(u.state=u.__s,u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),L=0;L<u._sb.length;L++)u.__h.push(u._sb[L]);u._sb=[]}else do u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++E<25);u.state=u.__s,u.getChildContext!=null&&(o=H(H({},o),u.getChildContext())),C&&!h&&u.getSnapshotBeforeUpdate!=null&&(p=u.getSnapshotBeforeUpdate(f,k)),y=d,d!=null&&d.type===ae&&d.key==null&&(y=qe(d.props.children)),r=$e(t,ie(y)?y:[y],e,n,o,i,s,a,r,l,c),u.base=e.__e,e.__u&=-161,u.__h.length&&a.push(u),_&&(u.__E=u.__=null)}catch(T){if(e.__v=null,l||s!=null)if(T.then){for(e.__u|=l?160:128;r&&r.nodeType==8&&r.nextSibling;)r=r.nextSibling;s[s.indexOf(r)]=null,e.__e=r}else for(g=s.length;g--;)we(s[g]);else e.__e=n.__e,e.__k=n.__k;M.__e(T,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):r=e.__e=St(n.__e,e,n,o,i,s,a,l,c);return(d=M.diffed)&&d(e),128&e.__u?void 0:r}function We(t,e,n){for(var o=0;o<n.length;o++)Te(n[o],n[++o],n[++o]);M.__c&&M.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){M.__e(s,i.__v)}})}function qe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:ie(t)?t.map(qe):H({},t)}function St(t,e,n,o,i,s,a,r,l){var c,d,u,h,f,k,p,_=n.props,b=e.props,C=e.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!C&&(C?f.localName==C:f.nodeType==3)){t=f,s[c]=null;break}}if(t==null){if(C==null)return document.createTextNode(b);t=document.createElementNS(i,C,b.is&&b),r&&(M.__m&&M.__m(e,s),r=!1),s=null}if(C==null)_===b||r&&t.data==b||(t.data=b);else{if(s=s&&B.call(t.childNodes),_=n.props||ee,!r&&s!=null)for(_={},c=0;c<t.attributes.length;c++)_[(f=t.attributes[c]).name]=f.value;for(c in _)if(f=_[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=f;else if(!(c in b)){if(c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b)continue;ue(t,c,null,f,i)}}for(c in b)f=b[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?d=f:c=="value"?k=f:c=="checked"?p=f:r&&typeof f!="function"||_[c]===f||ue(t,c,f,_[c],i);if(d)r||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),$e(e.type=="template"?t.content:t,ie(h)?h:[h],e,n,o,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&K(n,0),r,l),s!=null)for(c=s.length;c--;)we(s[c]);r||(c="value",C=="progress"&&k==null?t.removeAttribute("value"):k!=null&&(k!==t[c]||C=="progress"&&!k||C=="option"&&k!=_[c])&&ue(t,c,k,_[c],i),c="checked",p!=null&&p!=t[c]&&ue(t,c,p,_[c],i))}return t}function Te(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){M.__e(i,n)}}function He(t,e,n){var o,i;if(M.unmount&&M.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||Te(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){M.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&He(o[i],e,n||typeof t.type!="function");n||we(t.__e),t.__c=t.__=t.__e=void 0}function zt(t,e,n){return this.constructor(t,n)}function Be(t,e,n){var o,i,s,a;e==document&&(e=document.documentElement),M.__&&M.__(t,e),i=(o=!1)?null:e.__k,s=[],a=[],be(e,t=e.__k=bt(ae,null,[t]),i||ee,ee,e.namespaceURI,i?null:e.firstChild?B.call(e.childNodes):null,s,i?i.__e:e.firstChild,o,a),We(s,t,a)}function Et(t){function e(n){var o,i;return this.getChildContext||(o=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,ye(a)})},this.sub=function(s){o.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),a&&a.call(s)}}),n.children}return e.__c="__cC"+Fe++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,o){return n.children(o)}).contextType=e,e}B=De.slice,M={__e:function(t,e,n,o){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,o||{}),a=i.__d),a)return i.__E=i}catch(r){t=r}throw t}},Ae=0,le.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=H({},this.state),typeof t=="function"&&(t=t(H({},n),this.props)),t&&H(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ye(this))},le.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ye(this))},le.prototype.render=ae,V=[],Ie=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,xe=function(t,e){return t.__v.__b-e.__v.__b},ce.__r=0,Re=/(PointerCapture)$|Capture$/i,ge=0,pe=je(!1),Ce=je(!0),Fe=0;var Lt=0;function m(t,e,n,o,i,s){e||(e={});var a,r,l=e;if("ref"in l)for(r in l={},e)r=="ref"?a=e[r]:l[r]=e[r];var c={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lt,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(a=t.defaultProps))for(r in a)l[r]===void 0&&(l[r]=a[r]);return M.vnode&&M.vnode(c),c}var J,P,ke,Ve,te=0,Xe=[],F=M,Ye=F.__b,Ke=F.__r,Je=F.diffed,Ze=F.__c,Qe=F.unmount,et=F.__;function de(t,e){F.__h&&F.__h(P,t,te||e),te=0;var n=P.__H||(P.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function U(t){return te=1,Nt(rt,t)}function Nt(t,e,n){var o=de(J++,2);if(o.t=t,!o.__c&&(o.__=[rt(void 0,e),function(r){var l=o.__N?o.__N[0]:o.__[0],c=o.t(l,r);l!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=P,!P.__f)){var i=function(r,l,c){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(h){return!!h.__c});if(d.every(function(h){return!h.__N}))return!s||s.call(this,r,l,c);var u=o.__c.props!==r;return d.forEach(function(h){if(h.__N){var f=h.__[0];h.__=h.__N,h.__N=void 0,f!==h.__[0]&&(u=!0)}}),s&&s.call(this,r,l,c)||u};P.__f=!0;var s=P.shouldComponentUpdate,a=P.componentWillUpdate;P.componentWillUpdate=function(r,l,c){if(this.__e){var d=s;s=void 0,i(r,l,c),s=d}a&&a.call(this,r,l,c)},P.shouldComponentUpdate=i}return o.__N||o.__}function R(t,e){var n=de(J++,3);!F.__s&&ot(n.__H,e)&&(n.__=t,n.u=e,P.__H.__h.push(n))}function D(t){return te=5,Z(function(){return{current:t}},[])}function Z(t,e){var n=de(J++,7);return ot(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function tt(t,e){return te=8,Z(function(){return t},e)}function Mt(t){var e=P.context[t.__c],n=de(J++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(P)),e.props.value):t.__}function At(){for(var t;t=Xe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(he),t.__H.__h.forEach(Se),t.__H.__h=[]}catch(e){t.__H.__h=[],F.__e(e,t.__v)}}F.__b=function(t){P=null,Ye&&Ye(t)},F.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),et&&et(t,e)},F.__r=function(t){Ke&&Ke(t),J=0;var e=(P=t.__c).__H;e&&(ke===P?(e.__h=[],P.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(he),e.__h.forEach(Se),e.__h=[],J=0)),ke=P},F.diffed=function(t){Je&&Je(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Xe.push(e)!==1&&Ve===F.requestAnimationFrame||((Ve=F.requestAnimationFrame)||Pt)(At)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ke=P=null},F.__c=function(t,e){e.some(function(n){try{n.__h.forEach(he),n.__h=n.__h.filter(function(o){return!o.__||Se(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],F.__e(o,n.__v)}}),Ze&&Ze(t,e)},F.unmount=function(t){Qe&&Qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{he(o)}catch(i){e=i}}),n.__H=void 0,e&&F.__e(e,n.__v))};var nt=typeof requestAnimationFrame=="function";function Pt(t){var e,n=function(){clearTimeout(o),nt&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,100);nt&&(e=requestAnimationFrame(n))}function he(t){var e=P,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),P=e}function Se(t){var e=P;t.__c=t.__(),P=e}function ot(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function rt(t,e){return typeof e=="function"?e(t):e}const It=t=>({saveGameData(e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error("Failed to save maze game data:",n)}},loadGameData(){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset maze game data:",e)}}}),it=Et(void 0),st={currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,levelScores:{},totalScore:0},ze={isGameActive:!0,levelTransitioning:!1,maze:null,playerCell:{row:0,col:0},exitCell:{row:0,col:0},foodCells:[],playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,playerPath:[],visitCounts:{}},xt=({children:t,config:e})=>{const n=It(e.lcPrefix+"progress"),o=n.loadGameData(),[i,s]=U(()=>o||{...st});R(()=>{const u=Object.values(i.levelScores).reduce((h,f)=>h+f,0);s(h=>({...h,totalScore:u}))},[i.levelScores]),R(()=>{n.saveGameData(i)},[i.currentLevel,i.highestUnlockedLevel,i.currentTier,i.highestUnlockedTier,i.levelScores,i.totalScore]);const[a,r]=U({...ze}),l=D(a);R(()=>{l.current=a},[a]);const c=Z(()=>[a.playerAtExit?1:0,a.foodCollected===a.totalFoodCount?1:0,a.showClue?0:1],[a.playerAtExit,a.foodCollected,a.totalFoodCount,a.showClue]),d=()=>{n.resetGameData(),s({...st}),r({...ze})};return m(it.Provider,{value:{gameProgress:i,setGameProgress:s,gamePlayState:a,setGamePlayState:r,gamePlayStateRef:l,currentScore:c,config:e,resetGame:d},children:t})},ne=()=>{const t=Mt(it);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t},oe=t=>Z(()=>{const e=t.map(r=>r.length),n=e.reduce((r,l)=>r+l,0),o=t.length,i=r=>{if(r<1||r>n)return 0;let l=0;for(let c=0;c<e.length;c++)if(l+=e[c],r<=l)return c+1;return 0},s=r=>r<1||r>o?0:e.slice(0,r-1).reduce((l,c)=>l+c,0)+1,a={getTotalLevels:()=>n,getTotalTiers:()=>o,getTierLevelsRange:r=>{if(r<1||r>o)return[0,0];const l=s(r),c=l+e[r-1]-1;return[l,c]},getTierByLevel:i,getFirstLevelOfTier:s,getLevelConfig:r=>{if(r<1||r>n)return null;const l=i(r),c=s(l),d=r-c;return t[l-1][d]},getTierConfig:r=>r<1||r>o?null:t[r-1],isLevelUnlocked:(r,l)=>r<=l,isTierUnlocked:(r,l)=>r<=l,getNextLevelInfo:r=>{if(r>=n)return null;const l=r+1,c=i(r),d=i(l);return{nextLevel:l,nextTier:d,isTierChange:d>c}},getCurrentTierProgress:(r,l)=>{const[c,d]=a.getTierLevelsRange(l),u=r-c+1,h=d-c+1;return{current:u,total:h}},isLastLevelInTier:r=>{const l=i(r),[,c]=a.getTierLevelsRange(l);return r===c},getPreviousLevelInfo:r=>{if(r<=1)return null;const l=r-1,c=i(r),d=i(l);return{prevLevel:l,prevTier:d,isTierChange:d<c}}};return a},[t]),Rt=({onTierChange:t,disabled:e})=>{const{gameProgress:n,config:o}=ne(),{i18n:i,levelConfig:s}=o,{currentTier:a,highestUnlockedTier:r}=n,c=oe(s).getTotalTiers();return m("div",{className:"tier-selector",children:m("select",{value:a,onChange:d=>{d.target&&d.target.value&&t(Number(d.target.value))},disabled:e,className:"tier-dropdown",children:Array.from({length:c},(d,u)=>u+1).map(d=>m("option",{value:d,disabled:d>r,children:i.tier+" "+d},`tier-${d}`))})})},Ft=({onLevelChange:t,disabled:e})=>{const{gameProgress:n,config:o}=ne(),{i18n:i,levelConfig:s}=o,{currentTier:a,levelScores:r,currentLevel:l,highestUnlockedLevel:c}=n,d=oe(s),u=Z(()=>{const[h,f]=d.getTierLevelsRange(a);return Array.from({length:f-h+1},(k,p)=>{const _=h+p,b=r[_]||0;return{level:_,score:b}})},[a,r]);return m("div",{className:"level-selector",children:m("select",{value:l,onChange:h=>{h.target&&h.target.value&&t(Number(h.target.value))},disabled:e,className:"level-dropdown",children:u.map(({level:h,score:f})=>m("option",{value:h,disabled:h>c,children:`${i.level} ${h} ${"★".repeat(f)}`},`level-${h}`))})})},re=({isOpen:t,title:e,className:n="",message:o,children:i,noConfirm:s=!1,noCancel:a=!1,confirmText:r="OK",cancelText:l="Cancel",confirmClass:c="",cancelClass:d="",onConfirm:u,onCancel:h})=>{const f=D(null);return R(()=>{const k=p=>{p.key==="Escape"&&h?.()};return t&&document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[t,h]),m("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:m("div",{className:"maze-dialog "+n,ref:f,children:[m("div",{className:"maze-dialog-title",children:e}),m("div",{className:"maze-dialog-content",children:i||m("div",{className:"maze-dialog-message",children:o})}),(!a||!s)&&m("div",{className:"maze-dialog-buttons",children:[!a&&m("button",{type:"button",className:"maze-dialog-cancel "+d,onClick:h,children:l}),!s&&m("button",{type:"button",className:"maze-dialog-confirm "+c,onClick:u,children:r})]})]})})},G={container:null,attachTo(t){return this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=document.createElement("div"),this.container.className="toast-container position-bottom",t.appendChild(this.container),this.container},currentToast:null,currentTimer:null,show(t,e=2e3){if(!this.container){console.warn("NativeToast: container not initialized, please call attachTo first");return}this.currentToast&&this.container.contains(this.currentToast)&&(this.container.removeChild(this.currentToast),this.currentToast=null),this.currentTimer&&(clearTimeout(this.currentTimer),this.currentTimer=null);const n=document.createElement("div");n.className="toast-message toast-visible",n.textContent=t,this.container.appendChild(n),this.currentToast=n,this.currentTimer=setTimeout(()=>{n.classList.remove("toast-visible"),setTimeout(()=>{this.container&&this.container.contains(n)&&(this.container.removeChild(n),this.currentToast===n&&(this.currentToast=null))},300),this.currentTimer=null},e)},clearAll(){if(this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}},Dt=()=>{const{gameProgress:t,setGameProgress:e,gamePlayState:n,setGamePlayState:o,gamePlayStateRef:i,resetGame:s,config:a}=ne(),{i18n:r,levelConfig:l}=a,c=oe(l),{levelTransitioning:d,showClue:u}=n,{highestUnlockedLevel:h,totalScore:f}=t,k=c.getTotalLevels(),[p,_]=U(!1),[b,C]=U(!1),[A,w]=U(!1),z=O=>{const x=c.getFirstLevelOfTier(O);c.isLevelUnlocked(x,h)&&(e($=>({...$,currentTier:O})),S(x))},S=O=>{c.isLevelUnlocked(O,h)&&(e(x=>({...x,currentLevel:O})),G.show(r.levelGoToast.replace("%LEVEL%",O.toString())))},E=()=>{_(!0)},L=()=>{_(!1)},y=()=>{w(!0)},g=()=>{w(!1)},v=()=>{G.show(u?r.cluePathDisabled:r.cluePathEnabled),o(()=>({...i.current,showClue:!i.current.showClue})),w(!1)},T=()=>{C(!0)},N=()=>{s(),C(!1),G.show(r.resetDoneToast)},I=()=>{C(!1)};return m("div",{class:"game-panel-container",children:[m("div",{className:"game-controls",children:[m("div",{className:"selectors-container",children:[m(Rt,{onTierChange:z,disabled:d}),m(Ft,{onLevelChange:S,disabled:d})]}),m("button",{className:`settings-clue-button ${u?"clue-on":"clue-off"}`,disabled:u,title:"Toggle Clue",onClick:y,children:u?r.clueOn:r.clueOff})]}),m("div",{className:"game-settings",children:m("span",{className:"game-settings-icon",onClick:E,children:"★ "+f})}),m(re,{isOpen:p,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:L,children:[m("div",{className:"settings-stats",children:[m("div",{children:r.levelComplete+`: ${h}/${k}`}),m("div",{children:r.starsCollected+": "+f}),m("div",{children:r.avgStarPerLevel+": "+(f/h).toFixed(2)})]}),m("div",{className:"settings-item-box",children:[m("button",{className:"settings-reset-button",title:"Reset Game",onClick:T,children:r.reset}),m("div",{className:"settings-item-tip",children:r.resetTip})]})]}),m(re,{isOpen:b,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:N,onCancel:I}),m(re,{isOpen:A,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:v,onCancel:g})]})};function Ee(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ot(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function Le(t,e,n){return e&&Ot(t.prototype,e),t}function at(t){return+t.replace(/px/,"")}function $t(t){var e=window.devicePixelRatio,n=getComputedStyle(t),o=at(n.getPropertyValue("width")),i=at(n.getPropertyValue("height"));t.setAttribute("width",(o*e).toString()),t.setAttribute("height",(i*e).toString())}function j(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=Math.random()*(e-t)+t;return Math.floor(o*Math.pow(10,n))/Math.pow(10,n)}function lt(t){return t[j(0,t.length)]}var Ut=.00125,Gt=5e-4,jt=9e-4,Wt=1e-5,qt=6,Ht=80,Bt=.9,Vt=1.7,Xt=.2,Yt=.6,Kt=.03,Jt=.07,Zt=15,Qt=82,en=100,tn=250,nn=40,on=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function ct(t){var e=1920;return Math.log(t)/Math.log(e)}var ut=function(){function t(e){Ee(this,t);var n=e.initialPosition,o=e.direction,i=e.confettiRadius,s=e.confettiColors,a=e.emojis,r=e.emojiSize,l=e.canvasWidth,c=j(Bt,Vt,3),d=c*ct(l);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=j(Xt,Yt,3),this.rotationSpeed=a.length?.01:j(Kt,Jt,3)*ct(l),this.dragForceCoefficient=j(Gt,jt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=o==="left"?j(0,.2,3):j(-.2,0,3),this.emojiSize=r,this.emojiRotationAngle=j(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=o==="left"?j(Qt,Zt)*Math.PI/180:j(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var h=j(-150,0),f={x:n.x+(o==="left"?-h:h)*this.absCos,y:n.y-h*this.absSin};this.currentPosition=Object.assign({},f),this.initialPosition=Object.assign({},f),this.color=a.length?null:lt(s),this.emoji=a.length?lt(a):null,this.createdAt=new Date().getTime(),this.direction=o}return Le(t,[{key:"draw",value:function(n){var o=this.currentPosition,i=this.radius,s=this.color,a=this.emoji,r=this.rotationAngle,l=this.emojiRotationAngle,c=this.emojiSize,d=window.devicePixelRatio;s?(n.fillStyle=s,n.beginPath(),n.ellipse(o.x*d,o.y*d,i.x*d,i.y*d,r,0,2*Math.PI),n.fill()):a&&(n.font="".concat(c,"px serif"),n.save(),n.translate(d*o.x,d*o.y),n.rotate(l),n.textAlign="center",n.fillText(a,0,0),n.restore())}},{key:"updatePosition",value:function(n,o){var i=this.confettiSpeed,s=this.dragForceCoefficient,a=this.finalConfettiSpeedX,r=this.radiusYUpdateDirection,l=this.rotationSpeed,c=this.createdAt,d=this.direction,u=o-c;if(i.x>a&&(this.confettiSpeed.x-=s*n),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*n,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+Ut*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:Wt*n,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*n%(2*Math.PI);return}r==="down"?(this.radius.y-=n*l,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=n*l,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(n){return this.currentPosition.y<n+en}}]),t}();function rn(){var t=document.createElement("canvas");return t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.zIndex="1000",t.style.pointerEvents="none",document.body.appendChild(t),t}function sn(t){var e=t.confettiRadius,n=e===void 0?qt:e,o=t.confettiNumber,i=o===void 0?t.confettiesNumber||(t.emojis?nn:tn):o,s=t.confettiColors,a=s===void 0?on:s,r=t.emojis,l=r===void 0?t.emojies||[]:r,c=t.emojiSize,d=c===void 0?Ht:c;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:n,confettiNumber:i,confettiColors:a,emojis:l,emojiSize:d}}var an=function(){function t(e){var n=this;Ee(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(o){return n.resolvePromise=o})}return Le(t,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var n;(n=this.shapes).push.apply(n,arguments)}},{key:"complete",value:function(){var n;return this.shapes.length?!1:((n=this.resolvePromise)===null||n===void 0||n.call(this),!0)}},{key:"processShapes",value:function(n,o,i){var s=this,a=n.timeDelta,r=n.currentTime;this.shapes=this.shapes.filter(function(l){return l.updatePosition(a,r),l.draw(s.canvasContext),i?l.getIsVisibleOnCanvas(o):!0})}}]),t}(),ln=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ee(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||rn(),this.canvasContext=this.canvas.getContext("2d"),this.requestAnimationFrameRequested=!1,this.lastUpdated=new Date().getTime(),this.iterationIndex=0,this.loop=this.loop.bind(this),requestAnimationFrame(this.loop)}return Le(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,$t(this.canvas);var n=new Date().getTime(),o=n-this.lastUpdated,i=this.canvas.offsetHeight,s=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(a){return a.processShapes({timeDelta:o,currentTime:n},i,s),s?!a.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(n)}},{key:"queueAnimationFrameIfNeeded",value:function(n){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=n||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=sn(n),i=o.confettiRadius,s=o.confettiNumber,a=o.confettiColors,r=o.emojis,l=o.emojiSize,c=this.canvas.getBoundingClientRect(),d=c.width,u=c.height,h=u*5/7,f={x:0,y:h},k={x:d,y:h},p=new an(this.canvasContext),_=0;_<s/2;_++){var b=new ut({initialPosition:f,direction:"right",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d}),C=new ut({initialPosition:k,direction:"left",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d});p.addShapes(b,C)}return this.activeConfettiBatches.push(p),this.queueAnimationFrameIfNeeded(),p.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const cn=new ln,Ne=3,un=({onRetry:t})=>{const{config:e,currentScore:n,gamePlayState:o,setGamePlayState:i,gameProgress:s,setGameProgress:a}=ne(),{i18n:r,levelConfig:l}=e,[c,d,u]=n,{foodCollected:h,totalFoodCount:f,playerAtExit:k,levelTransitioning:p}=o,{currentLevel:_}=s,[b,C]=U(!1);R(()=>{k&&p&&(cn.addConfetti(),G.show(r.levelCompleteToast),C(!0))},[k,p]);const A=oe(l),w=A.getTotalLevels(),z=Z(()=>_>=w,[_,w]),S=()=>{C(!1),G.show(r.levelRestartToast),t?.()},E=()=>{C(!1),i(g=>({...g,isGameActive:!0,levelTransitioning:!1}))},L=()=>{C(!1);const g=A.getNextLevelInfo(_);if(!g)return;const{nextLevel:v,nextTier:T,isTierChange:N}=g;N&&G.show(r.tierUnlockedToast.replace("%TIER%",T.toString())),a(I=>({...I,currentLevel:v,currentTier:T,highestUnlockedLevel:Math.max(I.highestUnlockedLevel,v),highestUnlockedTier:Math.max(I.highestUnlockedTier,T),levelScores:{...I.levelScores,[I.currentLevel]:Math.max(Object.values(n).filter(Boolean).length,I.levelScores[I.currentLevel]||0)}}))},y=()=>{C(!1),a(g=>{const v=Math.max(Object.values(n).filter(Boolean).length,g.levelScores[g.currentLevel]||0),T={...g.levelScores,[g.currentLevel]:v};let N=0,I=0;const O=Object.entries(T).sort((x,$)=>Number(x[0])-Number($[0]));for(const[x,$]of O)if($<Ne){N=Number(x),I=A.getTierByLevel(N);break}return(N>0&&N!==_||v<Ne)&&G.show(r.notCompleteLevel),(N===0||v<Ne)&&t?.(),{...g,currentLevel:N||g.currentLevel,currentTier:I||g.currentTier,levelScores:T}})};return R(()=>{const g=document.querySelector(".maze-game-container"),v=T=>{b&&((T.key===" "||T.code==="Space")&&g&&(g.contains(document.activeElement)||document.activeElement===document.body)&&(T.preventDefault(),z?y():L()),(T.key==="r"||T.code==="KeyR")&&S(),(T.key==="c"||T.code==="KeyC")&&E())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[b,z]),m(re,{className:"level-complete-dialog",isOpen:b,title:r.congratulations,cancelText:r.retry+" (R)",onCancel:S,noConfirm:!!d,confirmText:r.continue+" (C)",onConfirm:E,confirmClass:"maze-continue-btn",children:[m("div",{className:"maze-summary-message",children:[!!c&&m("div",{children:"★ - "+r.findYourExit}),m("div",{children:u?"★ - "+r.withoutClue:"☆ - "+r.withClue}),m("div",{children:(d?"★ - "+r.collectAllStars:"☆ - "+r.notCollectAllStars)+` (${h}/${f})`})]}),z&&m("div",{className:"all-levels-completed",children:r.allLevelsCompleted}),m("div",{className:"maze-go-next",children:z?m("button",{className:"maze-go-next-btn",type:"button",onClick:y,children:[m("span",{children:r.lastOK}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]}):m("button",{className:"maze-go-next-btn",type:"button",onClick:L,children:[m("span",{children:r.nextLevel}),m("span",{className:"spacebar-tip",children:`(${r.spacebarTip})`})]})}),!d&&m("div",{className:"not-all-stars-collected",children:r.continueMessage})]})},dt=(t,e)=>{const n=D({canvasWidth:0,canvasHeight:0});return R(()=>{const o=()=>{const s=t.current;if(!s)return;const a=s.parentElement;if(!a)return;const r=a.clientWidth,l=window.devicePixelRatio||1;s.style.width=`${r}px`,s.style.height=`${r}px`;const c=r*l,d=r*l;s.width=c,s.height=d,n.current={canvasWidth:c,canvasHeight:d},e?.()};o();let i=null;return window.ResizeObserver&&t.current&&(i=new ResizeObserver(o),i.observe(t.current.parentElement)),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i?.disconnect()}},[t,e]),n},ht=(t,e,n)=>{const o=D({cellWidth:0,cellHeight:0});return R(()=>{const i=()=>{const a=t.current,r=e.maze;if(!a||!r)return;const{rows:l,cols:c}=r;if(l<=0||c<=0)return;const d=(a.width-n*2)/c,u=(a.height-n*2)/l;o.current={cellWidth:d,cellHeight:u}};i();let s=null;return t.current&&window.ResizeObserver&&(s=new ResizeObserver(i),s.observe(t.current)),()=>{t.current&&s?.disconnect()}},[t,e.maze,n]),o},fe={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},ft=({containerRef:t,gamePlayStateRef:e,setGamePlayState:n,moveSpeed:o,moveSpeedRef:i,playerRadius:s,onFoodCollected:a,onExitReached:r,onFirstMove:l})=>{const c=()=>i?.current??o??.03,d=D(!1),u=D(new Set),h=D(!1),f=tt((w,z)=>{const S=e.current;if(!S.maze)return{canMove:!1,newCell:null};const E=c(),[L,y]=fe[w];if(mt(z,L,y,s,E,S.maze))return{canMove:!1,newCell:null};const{row:v,col:T}=z,N=v+L*E,I=T+y*E,O=-.5,x=S.maze.rows,$=S.maze.cols;if(N<O||N>=x||I<O||I>=$)return{canMove:!1,newCell:null};const X=v<0?0:Math.floor(v),Y=T<0?0:Math.floor(T),W=N<0?0:Math.floor(N),q=I<0?0:Math.floor(I);return W!==X||q!==Y?S.maze.isValid(W,q)?{canMove:!0,newCell:{row:W,col:q}}:{canMove:!1,newCell:null}:{canMove:!0,newCell:null}},[s,c]),k=()=>{const w=e.current,{row:z,col:S}=w.playerCell,E=s*2,L=w.foodCells.findIndex(v=>Math.sqrt(Math.pow(z-v.row,2)+Math.pow(S-v.col,2))<E);L!==-1&&a&&(a(),e.current={...e.current,foodCollected:e.current.foodCollected+1,foodCells:e.current.foodCells.filter((v,T)=>T!==L)});const g=fn(w.playerCell,w.exitCell,w.maze);g&&!e.current.playerAtExit?(e.current={...e.current,playerAtExit:!0,isGameActive:!1,levelTransitioning:!0},r&&r(),requestIdleCallback(()=>{n(()=>({...e.current}))},{timeout:10})):!g&&e.current.playerAtExit&&(e.current={...e.current,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1})},p=w=>{const z=e.current,S=Math.round(w.row),E=Math.round(w.col),L=z.playerPath?.[z.playerPath.length-1],y=L?.row===S&&L?.col===E,g=Math.abs(L?.row??0-S),v=Math.abs(L?.col??0-E);if((g===1&&v===0||g===0&&v===1)&&!y){const N=`${L?.row},${L?.col}-${S},${E}`;e.current={...e.current,playerPath:[...e.current.playerPath??[],{row:S,col:E}],visitCounts:{...e.current.visitCounts,[N]:(e.current.visitCounts?.[N]||0)+1}}}},_=()=>{if(d.current||u.current.size===0)return;const w=e.current;!w.playerCell||!Array.from(u.current).some(S=>{const{canMove:E}=f(S,w.playerCell);return E})||(!h.current&&l&&(h.current=!0,l()),d.current=!0)};R(()=>{const w=y=>{if(y.key==="ArrowUp"||y.key==="ArrowDown"||y.key==="ArrowLeft"||y.key==="ArrowRight"||y.key===" "){const g=document.activeElement;if(g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.getAttribute("contenteditable")==="true"))return;y.preventDefault()}},z=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),e.current.isGameActive&&(u.current.has(g)||(u.current.add(g),d.current||_())))},S=y=>{const g=y.key;if(!(g in fe))return;const v=document.activeElement;v&&(v.tagName==="INPUT"||v.tagName==="TEXTAREA"||v.getAttribute("contenteditable")==="true")||(y.preventDefault(),u.current.delete(g),u.current.size===0&&C())},E=y=>{y.preventDefault();const g=e.current;if(!g.isGameActive||!g.maze||d.current)return;const v=y.touches[0],T=document.elementFromPoint(v.clientX,v.clientY);let N=null;T&&(T.classList.contains("maze-up")?N="ArrowUp":T.classList.contains("maze-down")?N="ArrowDown":T.classList.contains("maze-left")?N="ArrowLeft":T.classList.contains("maze-right")&&(N="ArrowRight")),N&&(u.current.clear(),u.current.add(N),_())},L=()=>{C()};return window.addEventListener("keydown",w,{capture:!0}),window.addEventListener("keydown",z),window.addEventListener("keyup",S),t.current?.addEventListener("touchstart",E,{passive:!1}),t.current?.addEventListener("touchend",L),()=>{window.removeEventListener("keydown",w,{capture:!0}),window.removeEventListener("keydown",z),window.removeEventListener("keyup",S),t.current?.removeEventListener("touchstart",E),t.current?.removeEventListener("touchend",L)}},[]);const b=tt(()=>{if(!d.current||u.current.size===0)return e.current.playerCell;const w=c(),z=e.current.playerCell;let S=0,E=0,L=0;for(const Q of u.current){const{canMove:Me}=f(Q,z);if(Me){const[wt,xn]=fe[Q];S+=wt,E+=xn,L++}}if(L===0)return e.current.playerCell;const y=Math.sqrt(S*S+E*E),g=y>0?S/y:0,v=y>0?E/y:0,T=Number((z.row+g*w).toFixed(2)),N=Number((z.col+v*w).toFixed(2)),I=T-z.row,O=N-z.col,x=Math.sqrt(I*I+O*O);if(x>0){const Q=I/x,Me=O/x;if(mt(z,Q,Me,s,x,e.current.maze))return e.current.playerCell}e.current.playerCell={row:T,col:N},k();const $=z.row<0?0:Math.round(z.row),X=z.col<0?0:Math.round(z.col),Y=T<0?0:Math.round(T),W=N<0?0:Math.round(N);return(Y!==$||W!==X)&&p({row:Y,col:W}),e.current.playerCell},[c,f]),C=()=>{d.current=!1,u.current.clear()};return{updatePlayerPos:b,resetMovingState:C,resetFirstMoveState:()=>{h.current=!1}}};function mt(t,e,n,o,i,s){const a=t.row+e*i,r=t.col+n*i,l={row:a,col:r},c=[],d=t.row<0?0:Math.floor(t.row),u=t.col<0?0:Math.floor(t.col);c.push({row:d,col:u});const h=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[f,k]of h){const p=d+f,_=u+k;s.isValid(p,_)&&c.push({row:p,col:_})}for(const f of c){const k=dn(f.row,f.col,s);for(const p of k)if(hn(l,p)<o)return!0}return!1}function dn(t,e,n){const o=[],i=n.grid[t][e];return i.walls.top&&o.push({start:{row:t-.5,col:e-.5},end:{row:t-.5,col:e+.5}}),i.walls.right&&o.push({start:{row:t-.5,col:e+.5},end:{row:t+.5,col:e+.5}}),i.walls.bottom&&o.push({start:{row:t+.5,col:e-.5},end:{row:t+.5,col:e+.5}}),i.walls.left&&o.push({start:{row:t-.5,col:e-.5},end:{row:t+.5,col:e-.5}}),o}function hn(t,e){const{start:n,end:o}=e,i=o.col-n.col,s=o.row-n.row,a=t.col-n.col,r=t.row-n.row,l=i*i+s*s;if(l===0)return Math.sqrt(a*a+r*r);const c=Math.max(0,Math.min(1,(a*i+r*s)/l)),d=n.col+c*i,u=n.row+c*s,h=t.col-d,f=t.row-u;return Math.sqrt(h*h+f*f)}function fn(t,e,n){if(!n.isValid(e.row,e.col))return!1;const o=t.col>=e.col-.5&&t.col<=e.col+.5,i=t.row>=e.row+.5,s=t.row>=e.row-.5;return o&&i&&s}function _t(t,e,n,o,i){if(!t||!e.maze)return;const{canvasWidth:s,canvasHeight:a}=n,{cellWidth:r,cellHeight:l}=o,{maze:c,playerCell:d,exitCell:u,foodCells:h,showClue:f,playerPath:k,visitCounts:p}=e,{padding:_,wallWidth:b,wallColor:C,playerColor:A,playerRadius:w,foodColor:z,backgroundColor:S,clueColor:E,exitColor:L,exitWallWidth:y,exitDashArray:g}=i;t.clearRect(0,0,s,a),t.save(),t.fillStyle=S,t.fillRect(0,0,s,a),t.restore(),f&&Cn({ctx:t,playerPath:k??[],visitCounts:p??{},cellWidth:r,cellHeight:l,padding:_,clueColor:E}),mn({ctx:t,maze:c,cellWidth:r,cellHeight:l,padding:_,wallColor:C,wallWidth:b}),vn({ctx:t,maze:c,exitCell:u,cellWidth:r,cellHeight:l,padding:_,exitColor:L,exitWallWidth:y,exitDashArray:g}),gn({ctx:t,foodCells:h,cellWidth:r,cellHeight:l,padding:_,foodColor:z}),_n({ctx:t,playerCell:d,playerRadius:w,cellWidth:r,cellHeight:l,padding:_,playerColor:A})}function mn({ctx:t,maze:e,cellWidth:n,cellHeight:o,padding:i,wallColor:s,wallWidth:a}){t.save(),t.strokeStyle=s,t.lineWidth=a,t.lineCap="round",t.beginPath(),wn(e,n,o,i).forEach(l=>{t.moveTo(l.x1,l.y1),t.lineTo(l.x2,l.y2)}),t.stroke(),t.restore()}function _n({ctx:t,playerCell:e,playerRadius:n,cellWidth:o,cellHeight:i,padding:s,playerColor:a}){const{x:r,y:l}=me(e.row,e.col,o,i,s),c=Math.min(o,i)*Math.min(n,.5);t.save(),t.fillStyle=a,t.beginPath(),t.arc(r,l,c,0,Math.PI*2),t.fill(),t.restore()}function vn({ctx:t,maze:e,exitCell:n,cellWidth:o,cellHeight:i,padding:s,exitColor:a,exitWallWidth:r,exitDashArray:l=[8,12]}){const{row:c,col:d}=n;if(!e.isValid(c,d))return;const u=s+d*o,h=s+c*i;t.save(),t.globalCompositeOperation="destination-out",t.lineWidth=r,t.lineCap="round",t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.globalCompositeOperation="source-over",t.strokeStyle=a,t.lineWidth=r,t.setLineDash(l),t.beginPath(),t.moveTo(u,h+i),t.lineTo(u+o,h+i),t.stroke(),t.restore()}function gn({ctx:t,foodCells:e,cellWidth:n,cellHeight:o,padding:i,foodColor:s}){t.fillStyle=s;const a=Math.min(n,o)*.25;e.forEach(r=>{const{x:l,y:c}=me(r.row,r.col,n,o,i);pn(t,l,c,a*1.2,5,a*.6)})}function pn(t,e,n,o,i,s){t.save(),t.beginPath();for(let a=0;a<i*2;a++){const r=a%2===0?o:s,l=Math.PI*a/i;t.lineTo(e+r*Math.sin(l),n+r*Math.cos(l))}t.closePath(),t.fill(),t.restore()}function Cn({ctx:t,playerPath:e,visitCounts:n,cellWidth:o,cellHeight:i,padding:s,clueColor:a}){if(!(!e||e.length<2||!n)){t.save();for(let r=1;r<e.length;r++){const l=e[r-1],c=e[r],d=`${l.row},${l.col}-${c.row},${c.col}`,u=`${c.row},${c.col}-${l.row},${l.col}`,h=(n[d]||0)+(n[u]||0),f=Math.min(.2+h*.1,.9),k=Math.max(3,o*.1)+h*.5;try{t.strokeStyle=a.replace(")",`, ${f})`).replace("rgb(","rgba(")}catch{t.strokeStyle=`rgba(255, 0, 0, ${f})`}t.lineWidth=k,t.lineCap="round",t.lineJoin="round";const{x:p,y:_}=me(l.row,l.col,o,i,s),{x:b,y:C}=me(c.row,c.col,o,i,s);t.beginPath(),t.moveTo(p,_),t.lineTo(b,C),t.stroke()}t.restore()}}function wn(t,e,n,o){const i=[];for(let s=0;s<t.rows;s++)for(let a=0;a<t.cols;a++){const r=t.grid[s][a],l=o+a*e,c=o+s*n;r.walls.top&&i.push({x1:l,y1:c,x2:l+e,y2:c}),r.walls.right&&i.push({x1:l+e,y1:c,x2:l+e,y2:c+n}),r.walls.bottom&&i.push({x1:l,y1:c+n,x2:l+e,y2:c+n}),r.walls.left&&i.push({x1:l,y1:c,x2:l,y2:c+n})}return i}function me(t,e,n,o,i){return{x:i+e*n+n/2,y:i+t*o+o/2}}function yn(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}class bn{constructor(e,n){this.row=e,this.col=n}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class vt{rows;cols;grid;seed;random;constructor(e,n,o,i,s={row:0,col:0},a={row:e-1,col:n-1}){this.rows=e,this.cols=n,this.seed=i??Math.floor(Math.random()*1e6),this.random=yn(this.seed),this.grid=this.initializeGrid(),this.generate(o,s,a)}initializeGrid(){const e=[];for(let n=0;n<this.rows;n++){e[n]=[];for(let o=0;o<this.cols;o++)e[n][o]=new bn(n,o)}return e}isValid(e,n){return e>=0&&e<this.rows&&n>=0&&n<this.cols}getNeighbors(e,n){const o=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const s of i){const a=e+s.r,r=n+s.c;this.isValid(a,r)&&o.push({row:a,col:r})}return o}getUnvisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>!this.grid[o.row][o.col].visited)}getVisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>this.grid[o.row][o.col].visited)}removeWall(e,n,o,i){const s=this.grid[e][n],a=this.grid[o][i];e===o+1?(s.walls.top=!1,a.walls.bottom=!1):e===o-1?(s.walls.bottom=!1,a.walls.top=!1):n===i+1?(s.walls.left=!1,a.walls.right=!1):n===i-1&&(s.walls.right=!1,a.walls.left=!1)}generate(e,n={row:0,col:0},o={row:this.rows-1,col:this.cols-1}){switch(e){case"backtracking":this.generateWithBacktracking();break;case"prims":this.generateWithPrims();break;default:throw new Error(`Unknown maze generation method: ${e}`)}this.addOpenings(n,o)}generateWithBacktracking(){const e=[],n=this.randomNumber(this.rows),o=this.randomNumber(this.cols);let i={row:n,col:o};for(this.grid[n][o].visited=!0,e.push(i);e.length>0;){i=e[e.length-1];const{row:s,col:a}=i,r=this.getUnvisitedNeighbors(s,a);if(r.length>0){const l=this.randomPick(r),{row:c,col:d}=l;this.removeWall(s,a,c,d),this.grid[c][d].visited=!0,e.push(l)}else e.pop()}}generateWithPrims(){const e=[],n=(s,a)=>{const r=this.getNeighbors(s,a);for(const l of r)!this.grid[l.row][l.col].visited&&!e.some(c=>c.row===l.row&&c.col===l.col)&&e.push(l)},o=this.randomNumber(this.rows),i=this.randomNumber(this.cols);for(this.grid[o][i].visited=!0,n(o,i);e.length>0;){const s=this.randomNumber(e.length),a=e[s],{row:r,col:l}=a,c=this.getVisitedNeighbors(r,l);if(c.length>0){const d=this.randomPick(c);this.removeWall(r,l,d.row,d.col),this.grid[r][l].visited=!0,n(r,l)}e.splice(s,1)}}addOpenings(e,n){this.grid[e.row][e.col].walls.top=!1,this.isValid(n.row,n.col)&&(this.grid[n.row][n.col].walls.bottom=!1)}randomNumber(e){return Math.floor(this.random()*e)}randomPick(e){return e[Math.floor(this.random()*e.length)]}}const gt=(t,e,n)=>{if(!t.isValid(e,n))return!1;const o=t.grid[e][n];return!o.walls.top||!o.walls.right||!o.walls.bottom||!o.walls.left},Tn=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6,kn=(t,e)=>{if(!e)return console.error(`Cannot find Level ${t}'s config.`),null;const{size:n,seed:o,method:i,entry:s,exit:a}=e,r=n,l=n,c=s||{row:0,col:0},d=a||{row:r-1,col:l-1},u=new vt(r,l,i,o,c,d),h=Tn(t),f=[];for(let k=0;k<h;k++){let p;do p={row:Math.floor(u.random()*r),col:Math.floor(u.random()*l)};while(p.row===c.row&&p.col===c.col||p.row===d.row&&p.col===d.col||!gt(u,p.row,p.col)||f.some(_=>_.row===p.row&&_.col===p.col));f.push(p)}return{isGameActive:!0,levelTransitioning:!1,maze:u,playerCell:c,exitCell:d,foodCells:f,playerAtExit:!1,foodCollected:0,totalFoodCount:h,showClue:!1,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1}}},Sn=({size:t,seed:e,method:n,foodCount:o})=>{const i=t,s=t,a={row:0,col:0},r={row:i-1,col:s-1},l=new vt(i,s,n,e,a,r),c=[];for(let d=0;d<o;d++){let u,h=0;do u={row:Math.floor(l.random()*i),col:Math.floor(l.random()*s)},h++;while(h<50&&(u.row===a.row&&u.col===a.col||u.row===r.row&&u.col===r.col||!gt(l,u.row,u.col)||c.some(f=>f.row===u.row&&f.col===u.col)));h<50&&c.push(u)}return{isGameActive:!0,levelTransitioning:!1,maze:l,playerCell:a,exitCell:r,foodCells:c,playerAtExit:!1,foodCollected:0,totalFoodCount:o}};function zn(){const{setGamePlayState:t,gamePlayState:e,gamePlayStateRef:n,gameProgress:o,config:i}=ne(),s=D(null),a=D(null),{i18n:r,levelConfig:l,renderConfig:c}=i,d=oe(l),u=D(d.getLevelConfig(o.currentLevel));R(()=>{s.current&&G.attachTo(s.current)},[]);const h=D(),f=dt(a,()=>{h.current?.()}),k=ht(a,e,c.padding);R(()=>{u.current=d.getLevelConfig(o.currentLevel)},[o.currentLevel]);const p=()=>{const A=kn(o.currentLevel,u.current);A&&t(w=>({...w,...A}))};R(()=>{p()},[o.currentLevel]);const _=()=>{p()},{updatePlayerPos:b,resetMovingState:C}=ft({containerRef:s,gamePlayStateRef:n,setGamePlayState:t,playerRadius:c.playerRadius,moveSpeed:c.gridMoveSpeed,onFoodCollected:()=>{const A=n.current.totalFoodCount-n.current.foodCollected-1;A>0?G.show(r.foodCollectedToast.replace("%NUM%",A.toString()),3e3):G.show(r.allFoodCollectedToast)}});return R(()=>{C()},[o.currentLevel,C]),R(()=>{let A,w=!document.hidden;const z=()=>{const L=a.current?.getContext("2d"),y=n.current;if(!(w&&y?.isGameActive&&L&&y?.maze)){A=requestAnimationFrame(z);return}b(),S(),A=requestAnimationFrame(z)},S=()=>{const L=a.current?.getContext("2d"),y=n.current;if(L&&y?.maze){const g=u.current?.wallWidth||c?.wallWidth,v=u.current?.exitColor||c?.exitColor,T=u.current?.exitWallWidth||c?.exitWallWidth,N=u.current?.exitDashArray||c?.exitDashArray;_t(L,y,f.current,k.current,{...c,wallWidth:g,exitColor:v,exitWallWidth:T,exitDashArray:N})}};h.current=S;const E=L=>{const y=w;w=!document.hidden&&document.visibilityState==="visible"&&(!L||L.type!=="blur"),!y&&w?n.current?.levelTransitioning===!1&&t({...n.current,isGameActive:!0}):y&&!w&&t({...n.current,isGameActive:!1})};return document.addEventListener("visibilitychange",E),window.addEventListener("blur",E),window.addEventListener("focus",E),A=requestAnimationFrame(z),()=>{cancelAnimationFrame(A),document.removeEventListener("visibilitychange",E),window.removeEventListener("blur",E),window.removeEventListener("focus",E)}},[]),R(()=>{G.show(r.useArrowKeyTips,3e3)},[]),m("div",{className:"maze-game-container",children:[m(Dt,{}),m(un,{onRetry:_}),m("div",{className:"maze-canvas-container",ref:s,children:[m("canvas",{ref:a,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]})]})}const En=t=>{const e=Math.floor(t/60),n=t%60;return`${e.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`},Ln=({timer:t,onTimeUp:e})=>{const[n,o]=U(t),i=D(),s=D(!1);return R(()=>{const a=()=>{!s.current&&!i.current&&(s.current=!0,i.current=setInterval(()=>{o(l=>l<=1?(clearInterval(i.current),e(),0):l-1)},1e3))},r=()=>{clearInterval(i.current),i.current=void 0};return window.addEventListener("maze:firstMove",a),window.addEventListener("maze:gameSuccess",r),()=>{window.removeEventListener("maze:firstMove",a),window.removeEventListener("maze:gameSuccess",r),clearInterval(i.current)}},[]),R(()=>{i.current&&(clearInterval(i.current),i.current=void 0),o(t),s.current=!1},[t]),m("div",{className:"single-maze-timer",children:m("span",{className:`maze-timer-text ${n<=10&&s.current?"maze-timer-warning":""}`,children:["⏱️ ",En(n)]})})};function Nn({config:t}){const{size:e,seed:n,method:o,foodCount:i,renderConfig:s,successCallback:a,failCallback:r,timer:l,i18n:c}=t,[d,u]=U({...ze}),[h,f]=U(!1),[k,p]=U(!1),[_,b]=U(!1),[C,A]=U(""),w=D(null),z=D(null),S=D(d),E=D(),L=dt(w,()=>{E.current?.()}),y=ht(w,d,s.padding);R(()=>{S.current=d},[d]);const{updatePlayerPos:g,resetMovingState:v,resetFirstMoveState:T}=ft({containerRef:z,gamePlayStateRef:S,setGamePlayState:u,playerRadius:s.playerRadius,moveSpeed:s.gridMoveSpeed,onFoodCollected:()=>{console.log("Food collected in single maze")},onExitReached:()=>{k||I()},onFirstMove:()=>{window.dispatchEvent(new CustomEvent("maze:firstMove"))}}),N=()=>{p(!0),A(`⏰ ${c.failMsg}`),b(!0),u(x=>({...x,isGameActive:!1})),r&&r()},I=()=>{p(!0),A(`🎉 ${c.successMsg}`),b(!0),window.dispatchEvent(new CustomEvent("maze:gameSuccess")),a&&a()},O=()=>{b(!1)};return R(()=>{(async()=>{f(!0);try{const $=Sn({size:e,seed:n,method:o,foodCount:i});S.current=$,u($)}catch($){console.error("Error generating single maze:",$)}finally{f(!1)}})()},[t]),R(()=>{let x;const $=!document.hidden,X=()=>{const W=w.current?.getContext("2d"),q=S.current;if(!($&&q?.isGameActive&&W&&q?.maze)){x=requestAnimationFrame(X);return}g(),Y(),x=requestAnimationFrame(X)},Y=()=>{const W=w.current?.getContext("2d"),q=S.current;W&&q?.maze&&_t(W,q,L.current,y.current,s)};return E.current=Y,x=requestAnimationFrame(X),()=>{cancelAnimationFrame(x)}},[]),R(()=>{v(),T()},[t,v,T]),h?m("div",{className:"single-maze-loading",children:m("div",{children:"Generating maze..."})}):d?m("div",{className:"maze-game-container",children:[m(Ln,{timer:l,onTimeUp:N}),m("div",{className:"single-maze-canvas-container",ref:z,children:[m("canvas",{ref:w,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]}),m(re,{isOpen:_,title:C,noConfirm:!0,cancelText:"OK",onCancel:O})]}):m("div",{className:"single-maze-error",children:m("div",{children:"Failed to generate maze"})})}const pt=[[{size:8,seed:12345,method:"backtracking",wallWidth:4,exitWallWidth:6,exitDashArray:[8,12]},{size:8,seed:23456,method:"backtracking",exitColor:"#33f",exitWallWidth:4,exitDashArray:[8,16]},{size:8,seed:34567,method:"prims"},{size:8,seed:45678,method:"backtracking"},{size:9,seed:56789,method:"prims"},{size:9,seed:67890,method:"backtracking"},{size:9,seed:78901,method:"prims"},{size:9,seed:89012,method:"backtracking"},{size:10,seed:90123,method:"prims"},{size:11,seed:11111,method:"backtracking"},{size:12,seed:22222,method:"prims"},{size:13,seed:33333,method:"backtracking"}],[{size:12,seed:44444,method:"prims"},{size:12,seed:55555,method:"backtracking"},{size:12,seed:66666,method:"prims"},{size:12,seed:77777,method:"backtracking"},{size:13,seed:88888,method:"prims"},{size:13,seed:99999,method:"backtracking"},{size:13,seed:12121,method:"prims"},{size:14,seed:23232,method:"backtracking"},{size:15,seed:34343,method:"prims"},{size:16,seed:45454,method:"backtracking"},{size:17,seed:56565,method:"prims"},{size:18,seed:67676,method:"backtracking"}],[{size:19,seed:78787,method:"prims"},{size:20,seed:89898,method:"backtracking"},{size:21,seed:90909,method:"prims"},{size:22,seed:10101,method:"backtracking"},{size:23,seed:20202,method:"prims"},{size:25,seed:30303,method:"backtracking"},{size:27,seed:40404,method:"prims"},{size:29,seed:50505,method:"backtracking"},{size:31,seed:60606,method:"prims"},{size:33,seed:70707,method:"backtracking"},{size:37,seed:80808,method:"prims"},{size:40,seed:90909,method:"backtracking"}],[{size:41,seed:10111,method:"prims"},{size:42,seed:11121,method:"backtracking"},{size:43,seed:12131,method:"prims"},{size:44,seed:13141,method:"backtracking"},{size:45,seed:14151,method:"prims"},{size:46,seed:15161,method:"backtracking"},{size:47,seed:16171,method:"prims"},{size:48,seed:17181,method:"backtracking"},{size:49,seed:18191,method:"prims"},{size:50,seed:19201,method:"backtracking"},{size:51,seed:20211,method:"prims"},{size:52,seed:21221,method:"backtracking"}],[{size:53,seed:22231,method:"prims"},{size:54,seed:23241,method:"backtracking"},{size:55,seed:24251,method:"prims"},{size:56,seed:25261,method:"backtracking"},{size:57,seed:26271,method:"prims"},{size:58,seed:27281,method:"backtracking"},{size:59,seed:28291,method:"prims"},{size:60,seed:29301,method:"backtracking"},{size:62,seed:30311,method:"prims"},{size:64,seed:31321,method:"backtracking"},{size:66,seed:32331,method:"prims"},{size:68,seed:33341,method:"backtracking"}]],Ct={gridMoveSpeed:.07,padding:10,wallWidth:2,wallColor:"#000000",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerRadius:.2,exitColor:"#F44336",exitWallWidth:4,exitDashArray:[8,12]},_e={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",congratulations:"Congratulations!",findYourExit:"Find your exit!",withoutClue:"Without clue!",withClue:"You used the clue!",collectAllStars:"Collect all stars!",notCollectAllStars:"Not collect all stars.",nextLevel:"Next Level ➤",spacebarTip:"Spacebar",retry:"Retry",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",allLevelsCompleted:"You completed all levels!",lastOK:"OK",notCompleteLevel:"You still have levels not collected all stars! Try again to collect them all!",continueMessage:"You still have levels where you haven't collected all stars. Try again to collect them all!",continue:"Continue",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:Ct,levelConfig:pt},ve={i18n:{successMsg:"Congratulations! You completed the maze!",failMsg:"Time is up!",restart:"Restart"},size:8,seed:12345,method:"backtracking",foodCount:3,renderConfig:Ct,timer:10*60,successCallback:()=>{console.log("🎉 Single maze completed successfully!")},failCallback:()=>{console.log("⏰ Time is up! Game failed.")}};function Mn({config:t={}}){const e={..._e.i18n,...t.i18n||{}},n={..._e.renderConfig,...t.renderConfig||{}},o=t.levelConfig||pt,i={..._e,...t,i18n:e,levelConfig:o,renderConfig:n};return m(xt,{config:i,children:m(zn,{})})}function An({config:t={}}){const e={...ve.i18n,...t.i18n||{}},n={...ve.renderConfig,...t.renderConfig||{}},o={...ve,...t,i18n:e,renderConfig:n};return m(Nn,{config:o})}const Pn={root:"https://unpkg.com/@roudanio/maze@0.2.2/dist/",..._e};`${JSON.stringify(Pn,null,2)}`;const In={root:"https://unpkg.com/@roudanio/maze@0.2.2/dist/",...ve};return`${JSON.stringify(In,(t,e)=>typeof e=="function"?e.toString():e,2)}`,{showNotice(){console.warn("Cannot find the root element");const t=document.createElement("div");t.style.textAlign="center",t.style.padding="20px",t.innerHTML="Cannot find the root element",document.body.append(t)},addLoadingIndicator(t){const e=document.createElement("div"),n=document.createElement("div");e.style.cssText=`
2
2
  height: 30px;
3
3
  width: 100%;
4
4
  border: solid 2px #999;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roudanio/maze",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "js-confetti": "^0.12.0",