@roudanio/maze 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/maze.css +1 -1
- package/dist/maze.iife.js +9 -9
- package/dist/maze.js +945 -748
- package/dist/maze.umd.js +9 -9
- package/package.json +6 -5
package/dist/maze.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.maze-game-container{position:relative;box-sizing:border-box;display:flex;flex-direction:column;width:100%}.maze-game-container button{padding:8px 16px;background-color:#4caf50;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:16px;transition:background-color .2s}.maze-game-container button:hover{background-color:#45a049}.maze-game-container button:disabled{background-color:#ccc;cursor:not-allowed}.maze-game-container .maze-canvas-container{position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;width:100%}.maze-game-container .maze-game-canvas{width:100%;height:100%;aspect-ratio:1 / 1;background-color:#fff;transition:opacity .1s ease}.maze-game-container .maze-touch-area{position:absolute;width:100%;height:100%;opacity:0}.maze-game-container .maze-up{clip-path:polygon(10% 0,90% 0,50% 40%);top:0}.maze-game-container .maze-down{clip-path:polygon(10% 100%,90% 100%,50% 60%);bottom:0}.maze-game-container .maze-left{clip-path:polygon(0 10%,40% 50%,0 90%);top:0;left:0}.maze-game-container .maze-right{clip-path:polygon(100% 10%,60% 50%,100% 90%);top:0;right:0}.maze-game-container .toast-container{position:absolute;pointer-events:none;width:100%;display:flex;justify-content:center;align-items:center;z-index:1000}.maze-game-container .toast-container.position-top{top:10px;left:0;right:0}.maze-game-container .toast-container.position-center{inset:0}.maze-game-container .toast-container.position-bottom{bottom:10px;left:0;right:0}.maze-game-container .toast-message{font-size:16px;font-weight:700;text-align:center;background-color:#f5f5f5;padding:8px 12px;border-radius:8px;box-shadow:0 2px 4px #0003;width:fit-content;max-width:90%;transition:opacity .3s ease,transform .3s ease;opacity:0;transform:translateY(-10px);pointer-events:none}.maze-game-container .toast-message.toast-visible{opacity:1;transform:translateY(0)}.maze-game-container .toast-message.type-success{background-color:#e8f5e9;color:#4caf50}.maze-game-container .toast-message.type-info{background-color:#e3f2fd;color:#2196f3}.maze-game-container .toast-message.type-warning{background-color:#fff8e1;color:#ff9800}.maze-game-container .toast-message.type-error{background-color:#ffebee;color:#f44336}.maze-game-container .game-panel-container{margin-bottom:15px;font-size:16px;background-color:#fff;border-radius:8px;box-shadow:0 4px 8px #0000001a;padding:12px 15px 15px;transition:all .3s ease;display:flex;flex-direction:row;justify-content:space-between;align-items:center}.maze-game-container .game-controls{display:flex;flex-direction:column;align-items:start;gap:12px}.maze-game-container .selectors-container{display:flex;justify-content:center;align-items:center;gap:10px;border-radius:10px}.maze-game-container
|
|
1
|
+
.maze-game-container{position:relative;box-sizing:border-box;display:flex;flex-direction:column;width:100%}.maze-game-container button{padding:8px 16px;background-color:#4caf50;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:16px;transition:background-color .2s}.maze-game-container button:hover{background-color:#45a049}.maze-game-container button:disabled{background-color:#ccc;cursor:not-allowed}.maze-game-container .maze-canvas-container{position:relative;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;width:100%}.maze-game-container .maze-game-canvas{width:100%;height:100%;aspect-ratio:1 / 1;background-color:#fff;transition:opacity .1s ease}.maze-game-container .maze-touch-area{position:absolute;width:100%;height:100%;opacity:0}.maze-game-container .maze-up{clip-path:polygon(10% 0,90% 0,50% 40%);top:0}.maze-game-container .maze-down{clip-path:polygon(10% 100%,90% 100%,50% 60%);bottom:0}.maze-game-container .maze-left{clip-path:polygon(0 10%,40% 50%,0 90%);top:0;left:0}.maze-game-container .maze-right{clip-path:polygon(100% 10%,60% 50%,100% 90%);top:0;right:0}.maze-game-container .toast-container{position:absolute;pointer-events:none;width:100%;display:flex;justify-content:center;align-items:center;z-index:1000}.maze-game-container .toast-container.position-top{top:10px;left:0;right:0}.maze-game-container .toast-container.position-center{inset:0}.maze-game-container .toast-container.position-bottom{bottom:10px;left:0;right:0}.maze-game-container .toast-message{font-size:16px;font-weight:700;text-align:center;background-color:#f5f5f5;padding:8px 12px;border-radius:8px;box-shadow:0 2px 4px #0003;width:fit-content;max-width:90%;transition:opacity .3s ease,transform .3s ease;opacity:0;transform:translateY(-10px);pointer-events:none}.maze-game-container .toast-message.toast-visible{opacity:1;transform:translateY(0)}.maze-game-container .toast-message.type-success{background-color:#e8f5e9;color:#4caf50}.maze-game-container .toast-message.type-info{background-color:#e3f2fd;color:#2196f3}.maze-game-container .toast-message.type-warning{background-color:#fff8e1;color:#ff9800}.maze-game-container .toast-message.type-error{background-color:#ffebee;color:#f44336}.maze-game-container .game-panel-container{margin-bottom:15px;font-size:16px;background-color:#fff;border-radius:8px;box-shadow:0 4px 8px #0000001a;padding:12px 15px 15px;transition:all .3s ease;display:flex;flex-direction:row;justify-content:space-between;align-items:center}.maze-game-container .game-controls{display:flex;flex-direction:column;align-items:start;gap:12px}.maze-game-container .selectors-container{display:flex;justify-content:center;align-items:center;gap:10px;border-radius:10px}.maze-game-container .tier-dropdown,.maze-game-container .level-dropdown{padding:8px 12px;border-radius:8px;border:2px solid #3498db;background-color:#f8f9fa;color:#333;font-size:16px;font-weight:700;cursor:pointer;box-shadow:0 2px 4px #0000001a;appearance:none;background-image:url(data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E);background-repeat:no-repeat;background-position:right 12px top 50%;background-size:10px auto;min-width:120px;transition:all .3s ease;outline:none}.maze-game-container .level-dropdown{border-color:#9b59b6}.maze-game-container .score-container{display:flex;flex-direction:row;gap:6px}.maze-game-container .game-settings{display:flex;align-items:center;justify-content:center}.maze-game-container .game-settings .game-settings-icon{width:32px;height:32px;cursor:pointer}.maze-game-container .maze-dialog-content{margin-bottom:15px}.maze-game-container .settings-item-box{padding-top:20px;padding-bottom:20px;display:flex;flex-direction:column;align-items:start;gap:20px;text-align:left}.maze-game-container .settings-item-tip{color:#555}.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button{background-color:#aaa;color:#fff;cursor:pointer;transition:all .2s;border:none;outline:none;box-shadow:0 1px 3px #0003}:is(.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button):hover{background-color:#d32f2f;box-shadow:0 2px 5px #0000004d}:is(.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button):active{transform:scale(.95)}:is(.maze-game-container .settings-reset-button,.maze-game-container .settings-clue-button):disabled+.settings-item-tip{color:#999}.maze-game-container .settings-clue-button.clue-on{background-color:#ff9800}.maze-game-container .settings-clue-button:hover{background-color:#ff9800;box-shadow:0 2px 5px #0000004d}.maze-game-container .settings-clue-button:active{transform:scale(.95)}.maze-game-container .settings-clue-button:disabled{background-color:#ccc;cursor:not-allowed;pointer-events:none}.maze-game-container .score-box{display:flex;flex-direction:row;align-items:center;gap:8px;padding:4px 10px;border-radius:16px}.maze-game-container .score-box.totalscore{background-color:#f3e5f5}.maze-game-container .score-box.currentscore{background-color:#e8f5e9}.maze-game-container .score-box.bestscore{background-color:#fff3e0}.maze-game-container .score-label{font-weight:700;color:#333;font-size:13px}.maze-game-container .score-data{font-weight:700;font-size:16px}.maze-game-container .totalscore .score-data{color:#9c27b0}.maze-game-container .currentscore .score-data{color:#4caf50}.maze-game-container .bestscore .score-data{color:#ff9800}.maze-game-container .maze-dialog-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#00000080;display:flex;justify-content:center;align-items:center;z-index:1000;opacity:0;visibility:hidden;transition:opacity .3s,visibility .3s}.maze-game-container .maze-dialog-overlay.maze-dialog-visible{opacity:1;visibility:visible}.maze-game-container .maze-dialog-overlay.maze-dialog-visible .maze-dialog{transform:translateY(0)}.maze-game-container .maze-dialog{background-color:#fff;border-radius:8px;box-shadow:0 4px 16px #0003;width:300px;max-width:90%;padding:20px;text-align:center;transform:translateY(-20px);transition:transform .3s}.maze-game-container .maze-dialog-title{font-size:18px;font-weight:700;margin-bottom:10px;color:#333}.maze-game-container .maze-dialog-message{font-size:14px;margin-bottom:20px;color:#666;line-height:1.5}.maze-game-container .maze-dialog-buttons{display:flex;justify-content:center;gap:10px}.maze-game-container .maze-dialog-cancel{background-color:#f1f1f1;color:#333;font-size:14px}.maze-game-container .maze-dialog-cancel:hover{background-color:#e1e1e1}.maze-game-container .maze-dialog-confirm{background-color:#f44336;color:#fff;font-size:14px}.maze-game-container .maze-dialog-confirm:hover{background-color:#d32f2f}
|
package/dist/maze.iife.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
var Maze=function(){"use strict";var q,v,ye,F,we,Ce,ne,ke,re,ie,se,be,W={},ze=[],ft=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,K=Array.isArray;function U(e,t){for(var o in t)e[o]=t[o];return e}function le(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function G(e,t,o){var n,r,i,s={};for(i in t)i=="key"?n=t[i]:i=="ref"?r=t[i]:s[i]=t[i];if(arguments.length>2&&(s.children=arguments.length>3?q.call(arguments,2):o),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)s[i]===void 0&&(s[i]=e.defaultProps[i]);return X(e,s,n,r,null)}function X(e,t,o,n,r){var i={type:e,props:t,key:o,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++ye,__i:-1,__u:0};return r==null&&v.vnode!=null&&v.vnode(i),i}function D(e){return e.children}function S(e,t){this.props=e,this.context=t}function O(e,t){if(t==null)return e.__?O(e.__,e.__i+1):null;for(var o;t<e.__k.length;t++)if((o=e.__k[t])!=null&&o.__e!=null)return o.__e;return typeof e.type=="function"?O(e):null}function Te(e){var t,o;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((o=e.__k[t])!=null&&o.__e!=null){e.__e=e.__c.base=o.__e;break}return Te(e)}}function ae(e){(!e.__d&&(e.__d=!0)&&F.push(e)&&!Y.__r++||we!==v.debounceRendering)&&((we=v.debounceRendering)||Ce)(Y)}function Y(){var e,t,o,n,r,i,s,l;for(F.sort(ne);e=F.shift();)e.__d&&(t=F.length,n=void 0,i=(r=(o=e).__v).__e,s=[],l=[],o.__P&&((n=U({},r)).__v=r.__v+1,v.vnode&&v.vnode(n),ce(o.__P,n,r,o.__n,o.__P.namespaceURI,32&r.__u?[i]:null,s,i??O(r),!!(32&r.__u),l),n.__v=r.__v,n.__.__k[n.__i]=n,Se(s,n,l),n.__e!=i&&Te(n)),F.length>t&&F.sort(ne));Y.__r=0}function Le(e,t,o,n,r,i,s,l,a,c,u){var _,h,d,m,y,w,g=n&&n.__k||ze,p=t.length;for(a=mt(o,t,g,a,p),_=0;_<p;_++)(d=o.__k[_])!=null&&(h=d.__i===-1?W:g[d.__i]||W,d.__i=_,w=ce(e,d,h,r,i,s,l,a,c,u),m=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&_e(h.ref,null,d),u.push(d.ref,d.__c||m,d)),y==null&&m!=null&&(y=m),4&d.__u||h.__k===d.__k?a=Pe(d,a,e):typeof d.type=="function"&&w!==void 0?a=w:m&&(a=m.nextSibling),d.__u&=-7);return o.__e=y,a}function mt(e,t,o,n,r){var i,s,l,a,c,u=o.length,_=u,h=0;for(e.__k=new Array(r),i=0;i<r;i++)(s=t[i])!=null&&typeof s!="boolean"&&typeof s!="function"?(a=i+h,(s=e.__k[i]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?X(null,s,null,null,null):K(s)?X(D,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?X(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,l=null,(c=s.__i=pt(s,o,a,_))!==-1&&(_--,(l=o[c])&&(l.__u|=2)),l==null||l.__v===null?(c==-1&&h--,typeof s.type!="function"&&(s.__u|=4)):c!=a&&(c==a-1?h--:c==a+1?h++:(c>a?h--:h++,s.__u|=4))):e.__k[i]=null;if(_)for(i=0;i<u;i++)(l=o[i])!=null&&!(2&l.__u)&&(l.__e==n&&(n=O(l)),$e(l,l));return n}function Pe(e,t,o){var n,r;if(typeof e.type=="function"){for(n=e.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=e,t=Pe(n[r],t,o));return t}e.__e!=t&&(t&&e.type&&!o.contains(t)&&(t=O(e)),o.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function J(e,t){return t=t||[],e==null||typeof e=="boolean"||(K(e)?e.some(function(o){J(o,t)}):t.push(e)),t}function pt(e,t,o,n){var r,i,s=e.key,l=e.type,a=t[o];if(a===null||a&&s==a.key&&l===a.type&&!(2&a.__u))return o;if(n>(a!=null&&!(2&a.__u)?1:0))for(r=o-1,i=o+1;r>=0||i<t.length;){if(r>=0){if((a=t[r])&&!(2&a.__u)&&s==a.key&&l===a.type)return r;r--}if(i<t.length){if((a=t[i])&&!(2&a.__u)&&s==a.key&&l===a.type)return i;i++}}return-1}function xe(e,t,o){t[0]=="-"?e.setProperty(t,o??""):e[t]=o==null?"":typeof o!="number"||ft.test(t)?o:o+"px"}function Z(e,t,o,n,r){var i;e:if(t=="style")if(typeof o=="string")e.style.cssText=o;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)o&&t in o||xe(e.style,t,"");if(o)for(t in o)n&&o[t]===n[t]||xe(e.style,t,o[t])}else if(t[0]=="o"&&t[1]=="n")i=t!=(t=t.replace(ke,"$1")),t=t.toLowerCase()in e||t=="onFocusOut"||t=="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=o,o?n?o.u=n.u:(o.u=re,e.addEventListener(t,i?se:ie,i)):e.removeEventListener(t,i?se:ie,i);else{if(r=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&o==1?"":o))}}function Ne(e){return function(t){if(this.l){var o=this.l[t.type+e];if(t.t==null)t.t=re++;else if(t.t<o.u)return;return o(v.event?v.event(t):t)}}}function ce(e,t,o,n,r,i,s,l,a,c){var u,_,h,d,m,y,w,g,p,z,b,M,P,R,A,E,x,T=t.type;if(t.constructor!==void 0)return null;128&o.__u&&(a=!!(32&o.__u),i=[l=t.__e=o.__e]),(u=v.__b)&&u(t);e:if(typeof T=="function")try{if(g=t.props,p="prototype"in T&&T.prototype.render,z=(u=T.contextType)&&n[u.__c],b=u?z?z.props.value:u.__:n,o.__c?w=(_=t.__c=o.__c).__=_.__E:(p?t.__c=_=new T(g,b):(t.__c=_=new S(g,b),_.constructor=T,_.render=gt),z&&z.sub(_),_.props=g,_.state||(_.state={}),_.context=b,_.__n=n,h=_.__d=!0,_.__h=[],_._sb=[]),p&&_.__s==null&&(_.__s=_.state),p&&T.getDerivedStateFromProps!=null&&(_.__s==_.state&&(_.__s=U({},_.__s)),U(_.__s,T.getDerivedStateFromProps(g,_.__s))),d=_.props,m=_.state,_.__v=t,h)p&&T.getDerivedStateFromProps==null&&_.componentWillMount!=null&&_.componentWillMount(),p&&_.componentDidMount!=null&&_.__h.push(_.componentDidMount);else{if(p&&T.getDerivedStateFromProps==null&&g!==d&&_.componentWillReceiveProps!=null&&_.componentWillReceiveProps(g,b),!_.__e&&(_.shouldComponentUpdate!=null&&_.shouldComponentUpdate(g,_.__s,b)===!1||t.__v==o.__v)){for(t.__v!=o.__v&&(_.props=g,_.state=_.__s,_.__d=!1),t.__e=o.__e,t.__k=o.__k,t.__k.some(function(H){H&&(H.__=t)}),M=0;M<_._sb.length;M++)_.__h.push(_._sb[M]);_._sb=[],_.__h.length&&s.push(_);break e}_.componentWillUpdate!=null&&_.componentWillUpdate(g,_.__s,b),p&&_.componentDidUpdate!=null&&_.__h.push(function(){_.componentDidUpdate(d,m,y)})}if(_.context=b,_.props=g,_.__P=e,_.__e=!1,P=v.__r,R=0,p){for(_.state=_.__s,_.__d=!1,P&&P(t),u=_.render(_.props,_.state,_.context),A=0;A<_._sb.length;A++)_.__h.push(_._sb[A]);_._sb=[]}else do _.__d=!1,P&&P(t),u=_.render(_.props,_.state,_.context),_.state=_.__s;while(_.__d&&++R<25);_.state=_.__s,_.getChildContext!=null&&(n=U(U({},n),_.getChildContext())),p&&!h&&_.getSnapshotBeforeUpdate!=null&&(y=_.getSnapshotBeforeUpdate(d,m)),l=Le(e,K(E=u!=null&&u.type===D&&u.key==null?u.props.children:u)?E:[E],t,o,n,r,i,s,l,a,c),_.base=t.__e,t.__u&=-161,_.__h.length&&s.push(_),w&&(_.__E=_.__=null)}catch(H){if(t.__v=null,a||i!=null)if(H.then){for(t.__u|=a?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;i[i.indexOf(l)]=null,t.__e=l}else for(x=i.length;x--;)le(i[x]);else t.__e=o.__e,t.__k=o.__k;v.__e(H,t,o)}else i==null&&t.__v==o.__v?(t.__k=o.__k,t.__e=o.__e):l=t.__e=vt(o.__e,t,o,n,r,i,s,a,c);return(u=v.diffed)&&u(t),128&t.__u?void 0:l}function Se(e,t,o){for(var n=0;n<o.length;n++)_e(o[n],o[++n],o[++n]);v.__c&&v.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(i){i.call(r)})}catch(i){v.__e(i,r.__v)}})}function vt(e,t,o,n,r,i,s,l,a){var c,u,_,h,d,m,y,w=o.props,g=t.props,p=t.type;if(p=="svg"?r="http://www.w3.org/2000/svg":p=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),i!=null){for(c=0;c<i.length;c++)if((d=i[c])&&"setAttribute"in d==!!p&&(p?d.localName==p:d.nodeType==3)){e=d,i[c]=null;break}}if(e==null){if(p==null)return document.createTextNode(g);e=document.createElementNS(r,p,g.is&&g),l&&(v.__m&&v.__m(t,i),l=!1),i=null}if(p===null)w===g||l&&e.data===g||(e.data=g);else{if(i=i&&q.call(e.childNodes),w=o.props||W,!l&&i!=null)for(w={},c=0;c<e.attributes.length;c++)w[(d=e.attributes[c]).name]=d.value;for(c in w)if(d=w[c],c!="children"){if(c=="dangerouslySetInnerHTML")_=d;else if(!(c in g)){if(c=="value"&&"defaultValue"in g||c=="checked"&&"defaultChecked"in g)continue;Z(e,c,null,d,r)}}for(c in g)d=g[c],c=="children"?h=d:c=="dangerouslySetInnerHTML"?u=d:c=="value"?m=d:c=="checked"?y=d:l&&typeof d!="function"||w[c]===d||Z(e,c,d,w[c],r);if(u)l||_&&(u.__html===_.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(_&&(e.innerHTML=""),Le(e,K(h)?h:[h],t,o,n,p=="foreignObject"?"http://www.w3.org/1999/xhtml":r,i,s,i?i[0]:o.__k&&O(o,0),l,a),i!=null)for(c=i.length;c--;)le(i[c]);l||(c="value",p=="progress"&&m==null?e.removeAttribute("value"):m!==void 0&&(m!==e[c]||p=="progress"&&!m||p=="option"&&m!==w[c])&&Z(e,c,m,w[c],r),c="checked",y!==void 0&&y!==e[c]&&Z(e,c,y,w[c],r))}return e}function _e(e,t,o){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(r){v.__e(r,o)}}function $e(e,t,o){var n,r;if(v.unmount&&v.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||_e(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(i){v.__e(i,t)}n.base=n.__P=null}if(n=e.__k)for(r=0;r<n.length;r++)n[r]&&$e(n[r],t,o||typeof e.type!="function");o||le(e.__e),e.__c=e.__=e.__e=void 0}function gt(e,t,o){return this.constructor(e,o)}function yt(e,t,o){var n,r,i,s;t==document&&(t=document.documentElement),v.__&&v.__(e,t),r=(n=!1)?null:t.__k,i=[],s=[],ce(t,e=t.__k=G(D,null,[e]),r||W,W,t.namespaceURI,r?null:t.firstChild?q.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,s),Se(i,e,s)}function Me(e,t){var o={__c:t="__cC"+be++,__:e,Consumer:function(n,r){return n.children(r)},Provider:function(n){var r,i;return this.getChildContext||(r=new Set,(i={})[t]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(s){this.props.value!==s.value&&r.forEach(function(l){l.__e=!0,ae(l)})},this.sub=function(s){r.add(s);var l=s.componentWillUnmount;s.componentWillUnmount=function(){r&&r.delete(s),l&&l.call(s)}}),n.children}};return o.Provider.__=o.Consumer.contextType=o}q=ze.slice,v={__e:function(e,t,o,n){for(var r,i,s;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(e)),s=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,n||{}),s=r.__d),s)return r.__E=r}catch(l){e=l}throw e}},ye=0,S.prototype.setState=function(e,t){var o;o=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=U({},this.state),typeof e=="function"&&(e=e(U({},o),this.props)),e&&U(o,e),e!=null&&this.__v&&(t&&this._sb.push(t),ae(this))},S.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ae(this))},S.prototype.render=D,F=[],Ce=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ne=function(e,t){return e.__v.__b-t.__v.__b},Y.__r=0,ke=/(PointerCapture)$|Capture$/i,re=0,ie=Ne(!1),se=Ne(!0),be=0;var wt=0;function f(e,t,o,n,r,i){t||(t={});var s,l,a=t;if("ref"in a)for(l in a={},t)l=="ref"?s=t[l]:a[l]=t[l];var c={type:e,props:a,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--wt,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(s=e.defaultProps))for(l in s)a[l]===void 0&&(a[l]=s[l]);return v.vnode&&v.vnode(c),c}var I,C,ue,Ae,V=0,Ee=[],k=v,Ue=k.__b,Fe=k.__r,Re=k.diffed,He=k.__c,Ge=k.unmount,De=k.__;function Q(e,t){k.__h&&k.__h(C,e,V||t),V=0;var o=C.__H||(C.__H={__:[],__h:[]});return e>=o.__.length&&o.__.push({}),o.__[e]}function $(e){return V=1,Ct(Be,e)}function Ct(e,t,o){var n=Q(I++,2);if(n.t=e,!n.__c&&(n.__=[o?o(t):Be(void 0,t),function(l){var a=n.__N?n.__N[0]:n.__[0],c=n.t(a,l);a!==c&&(n.__N=[c,n.__[1]],n.__c.setState({}))}],n.__c=C,!C.u)){var r=function(l,a,c){if(!n.__c.__H)return!0;var u=n.__c.__H.__.filter(function(h){return!!h.__c});if(u.every(function(h){return!h.__N}))return!i||i.call(this,l,a,c);var _=n.__c.props!==l;return u.forEach(function(h){if(h.__N){var d=h.__[0];h.__=h.__N,h.__N=void 0,d!==h.__[0]&&(_=!0)}}),i&&i.call(this,l,a,c)||_};C.u=!0;var i=C.shouldComponentUpdate,s=C.componentWillUpdate;C.componentWillUpdate=function(l,a,c){if(this.__e){var u=i;i=void 0,r(l,a,c),i=u}s&&s.call(this,l,a,c)},C.shouldComponentUpdate=r}return n.__N||n.__}function L(e,t){var o=Q(I++,3);!k.__s&&Ve(o.__H,t)&&(o.__=e,o.i=t,C.__H.__h.push(o))}function B(e){return V=5,de(function(){return{current:e}},[])}function de(e,t){var o=Q(I++,7);return Ve(o.__H,t)&&(o.__=e(),o.__H=t,o.__h=e),o.__}function Oe(e,t){return V=8,de(function(){return e},t)}function Ie(e){var t=C.context[e.__c],o=Q(I++,9);return o.c=e,t?(o.__==null&&(o.__=!0,t.sub(C)),t.props.value):e.__}function kt(){for(var e;e=Ee.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ee),e.__H.__h.forEach(he),e.__H.__h=[]}catch(t){e.__H.__h=[],k.__e(t,e.__v)}}k.__b=function(e){C=null,Ue&&Ue(e)},k.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),De&&De(e,t)},k.__r=function(e){Fe&&Fe(e),I=0;var t=(C=e.__c).__H;t&&(ue===C?(t.__h=[],C.__h=[],t.__.forEach(function(o){o.__N&&(o.__=o.__N),o.i=o.__N=void 0})):(t.__h.forEach(ee),t.__h.forEach(he),t.__h=[],I=0)),ue=C},k.diffed=function(e){Re&&Re(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ee.push(t)!==1&&Ae===k.requestAnimationFrame||((Ae=k.requestAnimationFrame)||bt)(kt)),t.__H.__.forEach(function(o){o.i&&(o.__H=o.i),o.i=void 0})),ue=C=null},k.__c=function(e,t){t.some(function(o){try{o.__h.forEach(ee),o.__h=o.__h.filter(function(n){return!n.__||he(n)})}catch(n){t.some(function(r){r.__h&&(r.__h=[])}),t=[],k.__e(n,o.__v)}}),He&&He(e,t)},k.unmount=function(e){Ge&&Ge(e);var t,o=e.__c;o&&o.__H&&(o.__H.__.forEach(function(n){try{ee(n)}catch(r){t=r}}),o.__H=void 0,t&&k.__e(t,o.__v))};var We=typeof requestAnimationFrame=="function";function bt(e){var t,o=function(){clearTimeout(n),We&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(o,100);We&&(t=requestAnimationFrame(o))}function ee(e){var t=C,o=e.__c;typeof o=="function"&&(e.__c=void 0,o()),C=t}function he(e){var t=C;e.__c=e.__(),C=t}function Ve(e,t){return!e||e.length!==t.length||t.some(function(o,n){return o!==e[n]})}function Be(e,t){return typeof t=="function"?t(e):t}const zt=e=>({saveGameData(t){try{const o={highestUnlockedLevel:t.highestUnlockedLevel,levelScores:t.levelScores,totalScore:t.totalScore,currentLevel:t.currentLevel};localStorage.setItem(e,JSON.stringify(o))}catch(o){console.error("Failed to save maze game data:",o)}},loadGameData(){try{const t=localStorage.getItem(e);if(!t)return null;const o=JSON.parse(t);return{highestUnlockedLevel:o.highestUnlockedLevel,levelScores:o.levelScores,totalScore:o.totalScore,currentLevel:o.currentLevel,currentTier:Math.ceil(o.currentLevel/12),highestUnlockedTier:Math.ceil(o.highestUnlockedLevel/12)}}catch(t){return console.error("Failed to load maze game data:",t),null}},resetGameData(){try{localStorage.removeItem(e)}catch(t){console.error("Failed to reset game state:",t)}}}),je=Me(void 0),Tt=({children:e,config:t})=>{const o=B(t),n=zt(t.lcPrefix+"score"),r=n.loadGameData(),[i,s]=$({currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:0,totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,maze:null,playerPosition:{row:0,col:0},exitPosition:{row:0,col:0},foodPositions:[],playerPath:[],visitCounts:{},moveCount:0,playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,...r||{}});L(()=>{n.saveGameData(i)},[i.highestUnlockedLevel,i.levelScores,i.totalScore,i.currentLevel]);const l=()=>{n.resetGameData(),s(a=>({...a,currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:0,totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,playerPath:[],visitCounts:{},moveCount:0,foodCollected:0,showClue:!1}))};return f(je.Provider,{value:{gameState:i,setGameState:s,config:o,resetGame:l},children:e})},qe=()=>{const e=Ie(je);if(!e)throw new Error("useGameContext must be used within a GameProvider");return e};function Ke(e,t){for(var o in t)e[o]=t[o];return e}function Xe(e,t){for(var o in e)if(o!=="__source"&&!(o in t))return!0;for(var n in t)if(n!=="__source"&&e[n]!==t[n])return!0;return!1}function Ye(e,t){this.props=e,this.context=t}(Ye.prototype=new S).isPureReactComponent=!0,Ye.prototype.shouldComponentUpdate=function(e,t){return Xe(this.props,e)||Xe(this.state,t)};var Je=v.__b;v.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Je&&Je(e)};var Lt=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function Ze(e){function t(o){var n=Ke({},o);return delete n.ref,e(n,o.ref||null)}return t.$$typeof=Lt,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Pt=v.__e;v.__e=function(e,t,o,n){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=o.__e,t.__k=o.__k),r.__c(e,t)}Pt(e,t,o,n)};var Qe=v.unmount;function et(e,t,o){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(n){typeof n.__c=="function"&&n.__c()}),e.__c.__H=null),(e=Ke({},e)).__c!=null&&(e.__c.__P===o&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map(function(n){return et(n,t,o)})),e}function tt(e,t,o){return e&&o&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(n){return tt(n,t,o)}),e.__c&&e.__c.__P===t&&(e.__e&&o.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=o)),e}function fe(){this.__u=0,this.o=null,this.__b=null}function ot(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function te(){this.i=null,this.l=null}v.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Qe&&Qe(e)},(fe.prototype=new S).__c=function(e,t){var o=t.__c,n=this;n.o==null&&(n.o=[]),n.o.push(o);var r=ot(n.__v),i=!1,s=function(){i||(i=!0,o.__R=null,r?r(l):l())};o.__R=s;var l=function(){if(!--n.__u){if(n.state.__a){var a=n.state.__a;n.__v.__k[0]=tt(a,a.__c.__P,a.__c.__O)}var c;for(n.setState({__a:n.__b=null});c=n.o.pop();)c.forceUpdate()}};n.__u++||32&t.__u||n.setState({__a:n.__b=n.__v.__k[0]}),e.then(s,s)},fe.prototype.componentWillUnmount=function(){this.o=[]},fe.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var o=document.createElement("div"),n=this.__v.__k[0].__c;this.__v.__k[0]=et(this.__b,o,n.__O=n.__P)}this.__b=null}var r=t.__a&&G(D,null,e.fallback);return r&&(r.__u&=-33),[G(D,null,t.__a?null:e.children),r]};var nt=function(e,t,o){if(++o[1]===o[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(o=e.i;o;){for(;o.length>3;)o.pop()();if(o[1]<o[0])break;e.i=o=o[2]}};(te.prototype=new S).__a=function(e){var t=this,o=ot(t.__v),n=t.l.get(e);return n[0]++,function(r){var i=function(){t.props.revealOrder?(n.push(r),nt(t,e,n)):r()};o?o(i):i()}},te.prototype.render=function(e){this.i=null,this.l=new Map;var t=J(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var o=t.length;o--;)this.l.set(t[o],this.i=[1,0,this.i]);return e.children},te.prototype.componentDidUpdate=te.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,o){nt(e,o,t)})};var xt=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Nt=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,St=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,$t=/[A-Z0-9]/g,Mt=typeof document<"u",At=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};S.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(S.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var rt=v.event;function Et(){}function Ut(){return this.cancelBubble}function Ft(){return this.defaultPrevented}v.event=function(e){return rt&&(e=rt(e)),e.persist=Et,e.isPropagationStopped=Ut,e.isDefaultPrevented=Ft,e.nativeEvent=e};var Rt={enumerable:!1,configurable:!0,get:function(){return this.class}},it=v.vnode;v.vnode=function(e){typeof e.type=="string"&&function(t){var o=t.props,n=t.type,r={},i=n.indexOf("-")===-1;for(var s in o){var l=o[s];if(!(s==="value"&&"defaultValue"in o&&l==null||Mt&&s==="children"&&n==="noscript"||s==="class"||s==="className")){var a=s.toLowerCase();s==="defaultValue"&&"value"in o&&o.value==null?s="value":s==="download"&&l===!0?l="":a==="translate"&&l==="no"?l=!1:a[0]==="o"&&a[1]==="n"?a==="ondoubleclick"?s="ondblclick":a!=="onchange"||n!=="input"&&n!=="textarea"||At(o.type)?a==="onfocus"?s="onfocusin":a==="onblur"?s="onfocusout":St.test(s)&&(s=a):a=s="oninput":i&&Nt.test(s)?s=s.replace($t,"-$&").toLowerCase():l===null&&(l=void 0),a==="oninput"&&r[s=a]&&(s="oninputCapture"),r[s]=l}}n=="select"&&r.multiple&&Array.isArray(r.value)&&(r.value=J(o.children).forEach(function(c){c.props.selected=r.value.indexOf(c.props.value)!=-1})),n=="select"&&r.defaultValue!=null&&(r.value=J(o.children).forEach(function(c){c.props.selected=r.multiple?r.defaultValue.indexOf(c.props.value)!=-1:r.defaultValue==c.props.value})),o.class&&!o.className?(r.class=o.class,Object.defineProperty(r,"className",Rt)):(o.className&&!o.class||o.class&&o.className)&&(r.class=r.className=o.className),t.props=r}(e),e.$$typeof=xt,it&&it(e)};var st=v.__r;v.__r=function(e){st&&st(e),e.__c};var lt=v.diffed;v.diffed=function(e){lt&<(e);var t=e.props,o=e.__e;o!=null&&e.type==="textarea"&&"value"in t&&t.value!==o.value&&(o.value=t.value==null?"":t.value)};/**
|
|
1
|
+
var Maze=function(){"use strict";var Y,C,we,F,be,ke,Te,ze,re,se,ae,Pe,W={},Se=[],bt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,B=Array.isArray;function E(e,t){for(var o in t)e[o]=t[o];return e}function le(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function D(e,t,o){var n,i,r,s={};for(r in t)r=="key"?n=t[r]:r=="ref"?i=t[r]:s[r]=t[r];if(arguments.length>2&&(s.children=arguments.length>3?Y.call(arguments,2):o),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)s[r]==null&&(s[r]=e.defaultProps[r]);return J(e,s,n,i,null)}function J(e,t,o,n,i){var r={type:e,props:t,key:o,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++we,__i:-1,__u:0};return i==null&&C.vnode!=null&&C.vnode(r),r}function j(e){return e.children}function M(e,t){this.props=e,this.context=t}function H(e,t){if(t==null)return e.__?H(e.__,e.__i+1):null;for(var o;t<e.__k.length;t++)if((o=e.__k[t])!=null&&o.__e!=null)return o.__e;return typeof e.type=="function"?H(e):null}function Ne(e){var t,o;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((o=e.__k[t])!=null&&o.__e!=null){e.__e=e.__c.base=o.__e;break}return Ne(e)}}function ce(e){(!e.__d&&(e.__d=!0)&&F.push(e)&&!K.__r++||be!=C.debounceRendering)&&((be=C.debounceRendering)||ke)(K)}function K(){for(var e,t,o,n,i,r,s,a=1;F.length;)F.length>a&&F.sort(Te),e=F.shift(),a=F.length,e.__d&&(o=void 0,i=(n=(t=e).__v).__e,r=[],s=[],t.__P&&((o=E({},n)).__v=n.__v+1,C.vnode&&C.vnode(o),ue(t.__P,o,n,t.__n,t.__P.namespaceURI,32&n.__u?[i]:null,r,i??H(n),!!(32&n.__u),s),o.__v=n.__v,o.__.__k[o.__i]=o,Me(r,o,s),o.__e!=i&&Ne(o)));K.__r=0}function Le(e,t,o,n,i,r,s,a,l,c,_){var u,h,d,m,v,y,g=n&&n.__k||Se,p=t.length;for(l=kt(o,t,g,l,p),u=0;u<p;u++)(d=o.__k[u])!=null&&(h=d.__i==-1?W:g[d.__i]||W,d.__i=u,y=ue(e,d,h,i,r,s,a,l,c,_),m=d.__e,d.ref&&h.ref!=d.ref&&(h.ref&&_e(h.ref,null,d),_.push(d.ref,d.__c||m,d)),v==null&&m!=null&&(v=m),4&d.__u||h.__k===d.__k?l=xe(d,l,e):typeof d.type=="function"&&y!==void 0?l=y:m&&(l=m.nextSibling),d.__u&=-7);return o.__e=v,l}function kt(e,t,o,n,i){var r,s,a,l,c,_=o.length,u=_,h=0;for(e.__k=new Array(i),r=0;r<i;r++)(s=t[r])!=null&&typeof s!="boolean"&&typeof s!="function"?(l=r+h,(s=e.__k[r]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?J(null,s,null,null,null):B(s)?J(j,{children:s},null,null,null):s.constructor==null&&s.__b>0?J(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,a=null,(c=s.__i=Tt(s,o,l,u))!=-1&&(u--,(a=o[c])&&(a.__u|=2)),a==null||a.__v==null?(c==-1&&(i>_?h--:i<_&&h++),typeof s.type!="function"&&(s.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,s.__u|=4))):e.__k[r]=null;if(u)for(r=0;r<_;r++)(a=o[r])!=null&&(2&a.__u)==0&&(a.__e==n&&(n=H(a)),$e(a,a));return n}function xe(e,t,o){var n,i;if(typeof e.type=="function"){for(n=e.__k,i=0;n&&i<n.length;i++)n[i]&&(n[i].__=e,t=xe(n[i],t,o));return t}e.__e!=t&&(t&&e.type&&!o.contains(t)&&(t=H(e)),o.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Z(e,t){return t=t||[],e==null||typeof e=="boolean"||(B(e)?e.some(function(o){Z(o,t)}):t.push(e)),t}function Tt(e,t,o,n){var i,r,s=e.key,a=e.type,l=t[o];if(l===null&&e.key==null||l&&s==l.key&&a==l.type&&(2&l.__u)==0)return o;if(n>(l!=null&&(2&l.__u)==0?1:0))for(i=o-1,r=o+1;i>=0||r<t.length;){if(i>=0){if((l=t[i])&&(2&l.__u)==0&&s==l.key&&a==l.type)return i;i--}if(r<t.length){if((l=t[r])&&(2&l.__u)==0&&s==l.key&&a==l.type)return r;r++}}return-1}function Ae(e,t,o){t[0]=="-"?e.setProperty(t,o??""):e[t]=o==null?"":typeof o!="number"||bt.test(t)?o:o+"px"}function Q(e,t,o,n,i){var r;e:if(t=="style")if(typeof o=="string")e.style.cssText=o;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)o&&t in o||Ae(e.style,t,"");if(o)for(t in o)n&&o[t]==n[t]||Ae(e.style,t,o[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(ze,"$1")),t=t.toLowerCase()in e||t=="onFocusOut"||t=="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=o,o?n?o.u=n.u:(o.u=re,e.addEventListener(t,r?ae:se,r)):e.removeEventListener(t,r?ae:se,r);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&o==1?"":o))}}function Ee(e){return function(t){if(this.l){var o=this.l[t.type+e];if(t.t==null)t.t=re++;else if(t.t<o.u)return;return o(C.event?C.event(t):t)}}}function ue(e,t,o,n,i,r,s,a,l,c){var _,u,h,d,m,v,y,g,p,T,k,$,N,U,R,L,x,z=t.type;if(t.constructor!=null)return null;128&o.__u&&(l=!!(32&o.__u),r=[a=t.__e=o.__e]),(_=C.__b)&&_(t);e:if(typeof z=="function")try{if(g=t.props,p="prototype"in z&&z.prototype.render,T=(_=z.contextType)&&n[_.__c],k=_?T?T.props.value:_.__:n,o.__c?y=(u=t.__c=o.__c).__=u.__E:(p?t.__c=u=new z(g,k):(t.__c=u=new M(g,k),u.constructor=z,u.render=Pt),T&&T.sub(u),u.props=g,u.state||(u.state={}),u.context=k,u.__n=n,h=u.__d=!0,u.__h=[],u._sb=[]),p&&u.__s==null&&(u.__s=u.state),p&&z.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=E({},u.__s)),E(u.__s,z.getDerivedStateFromProps(g,u.__s))),d=u.props,m=u.state,u.__v=t,h)p&&z.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),p&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(p&&z.getDerivedStateFromProps==null&&g!==d&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(g,k),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(g,u.__s,k)===!1||t.__v==o.__v){for(t.__v!=o.__v&&(u.props=g,u.state=u.__s,u.__d=!1),t.__e=o.__e,t.__k=o.__k,t.__k.some(function(O){O&&(O.__=t)}),$=0;$<u._sb.length;$++)u.__h.push(u._sb[$]);u._sb=[],u.__h.length&&s.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(g,u.__s,k),p&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(d,m,v)})}if(u.context=k,u.props=g,u.__P=e,u.__e=!1,N=C.__r,U=0,p){for(u.state=u.__s,u.__d=!1,N&&N(t),_=u.render(u.props,u.state,u.context),R=0;R<u._sb.length;R++)u.__h.push(u._sb[R]);u._sb=[]}else do u.__d=!1,N&&N(t),_=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++U<25);u.state=u.__s,u.getChildContext!=null&&(n=E(E({},n),u.getChildContext())),p&&!h&&u.getSnapshotBeforeUpdate!=null&&(v=u.getSnapshotBeforeUpdate(d,m)),L=_,_!=null&&_.type===j&&_.key==null&&(L=Ie(_.props.children)),a=Le(e,B(L)?L:[L],t,o,n,i,r,s,a,l,c),u.base=t.__e,t.__u&=-161,u.__h.length&&s.push(u),y&&(u.__E=u.__=null)}catch(O){if(t.__v=null,l||r!=null)if(O.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;r[r.indexOf(a)]=null,t.__e=a}else for(x=r.length;x--;)le(r[x]);else t.__e=o.__e,t.__k=o.__k;C.__e(O,t,o)}else r==null&&t.__v==o.__v?(t.__k=o.__k,t.__e=o.__e):a=t.__e=zt(o.__e,t,o,n,i,r,s,l,c);return(_=C.diffed)&&_(t),128&t.__u?void 0:a}function Me(e,t,o){for(var n=0;n<o.length;n++)_e(o[n],o[++n],o[++n]);C.__c&&C.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(r){r.call(i)})}catch(r){C.__e(r,i.__v)}})}function Ie(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:B(e)?e.map(Ie):E({},e)}function zt(e,t,o,n,i,r,s,a,l){var c,_,u,h,d,m,v,y=o.props,g=t.props,p=t.type;if(p=="svg"?i="http://www.w3.org/2000/svg":p=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),r!=null){for(c=0;c<r.length;c++)if((d=r[c])&&"setAttribute"in d==!!p&&(p?d.localName==p:d.nodeType==3)){e=d,r[c]=null;break}}if(e==null){if(p==null)return document.createTextNode(g);e=document.createElementNS(i,p,g.is&&g),a&&(C.__m&&C.__m(t,r),a=!1),r=null}if(p==null)y===g||a&&e.data==g||(e.data=g);else{if(r=r&&Y.call(e.childNodes),y=o.props||W,!a&&r!=null)for(y={},c=0;c<e.attributes.length;c++)y[(d=e.attributes[c]).name]=d.value;for(c in y)if(d=y[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=d;else if(!(c in g)){if(c=="value"&&"defaultValue"in g||c=="checked"&&"defaultChecked"in g)continue;Q(e,c,null,d,i)}}for(c in g)d=g[c],c=="children"?h=d:c=="dangerouslySetInnerHTML"?_=d:c=="value"?m=d:c=="checked"?v=d:a&&typeof d!="function"||y[c]===d||Q(e,c,d,y[c],i);if(_)a||u&&(_.__html==u.__html||_.__html==e.innerHTML)||(e.innerHTML=_.__html),t.__k=[];else if(u&&(e.innerHTML=""),Le(t.type=="template"?e.content:e,B(h)?h:[h],t,o,n,p=="foreignObject"?"http://www.w3.org/1999/xhtml":i,r,s,r?r[0]:o.__k&&H(o,0),a,l),r!=null)for(c=r.length;c--;)le(r[c]);a||(c="value",p=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||p=="progress"&&!m||p=="option"&&m!=y[c])&&Q(e,c,m,y[c],i),c="checked",v!=null&&v!=e[c]&&Q(e,c,v,y[c],i))}return e}function _e(e,t,o){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(i){C.__e(i,o)}}function $e(e,t,o){var n,i;if(C.unmount&&C.unmount(e),(n=e.ref)&&(n.current&&n.current!=e.__e||_e(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(r){C.__e(r,t)}n.base=n.__P=null}if(n=e.__k)for(i=0;i<n.length;i++)n[i]&&$e(n[i],t,o||typeof e.type!="function");o||le(e.__e),e.__c=e.__=e.__e=void 0}function Pt(e,t,o){return this.constructor(e,o)}function St(e,t,o){var n,i,r,s;t==document&&(t=document.documentElement),C.__&&C.__(e,t),i=(n=!1)?null:t.__k,r=[],s=[],ue(t,e=t.__k=D(j,null,[e]),i||W,W,t.namespaceURI,i?null:t.firstChild?Y.call(t.childNodes):null,r,i?i.__e:t.firstChild,n,s),Me(r,e,s)}function Re(e){function t(o){var n,i;return this.getChildContext||(n=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(r){this.props.value!=r.value&&n.forEach(function(s){s.__e=!0,ce(s)})},this.sub=function(r){n.add(r);var s=r.componentWillUnmount;r.componentWillUnmount=function(){n&&n.delete(r),s&&s.call(r)}}),o.children}return t.__c="__cC"+Pe++,t.__=e,t.Provider=t.__l=(t.Consumer=function(o,n){return o.children(n)}).contextType=t,t}Y=Se.slice,C={__e:function(e,t,o,n){for(var i,r,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((r=i.constructor)&&r.getDerivedStateFromError!=null&&(i.setState(r.getDerivedStateFromError(e)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,n||{}),s=i.__d),s)return i.__E=i}catch(a){e=a}throw e}},we=0,M.prototype.setState=function(e,t){var o;o=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=E({},this.state),typeof e=="function"&&(e=e(E({},o),this.props)),e&&E(o,e),e!=null&&this.__v&&(t&&this._sb.push(t),ce(this))},M.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ce(this))},M.prototype.render=j,F=[],ke=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Te=function(e,t){return e.__v.__b-t.__v.__b},K.__r=0,ze=/(PointerCapture)$|Capture$/i,re=0,se=Ee(!1),ae=Ee(!0),Pe=0;var Nt=0;function f(e,t,o,n,i,r){t||(t={});var s,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?s=t[a]:l[a]=t[a];var c={type:e,props:l,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Nt,__i:-1,__u:0,__source:i,__self:r};if(typeof e=="function"&&(s=e.defaultProps))for(a in s)l[a]===void 0&&(l[a]=s[a]);return C.vnode&&C.vnode(c),c}var G,w,de,Fe,V=0,Ue=[],b=C,Oe=b.__b,De=b.__r,je=b.diffed,He=b.__c,Ge=b.unmount,We=b.__;function ee(e,t){b.__h&&b.__h(w,e,V||t),V=0;var o=w.__H||(w.__H={__:[],__h:[]});return e>=o.__.length&&o.__.push({}),o.__[e]}function I(e){return V=1,Lt(Ye,e)}function Lt(e,t,o){var n=ee(G++,2);if(n.t=e,!n.__c&&(n.__=[o?o(t):Ye(void 0,t),function(a){var l=n.__N?n.__N[0]:n.__[0],c=n.t(l,a);l!==c&&(n.__N=[c,n.__[1]],n.__c.setState({}))}],n.__c=w,!w.__f)){var i=function(a,l,c){if(!n.__c.__H)return!0;var _=n.__c.__H.__.filter(function(h){return!!h.__c});if(_.every(function(h){return!h.__N}))return!r||r.call(this,a,l,c);var u=n.__c.props!==a;return _.forEach(function(h){if(h.__N){var d=h.__[0];h.__=h.__N,h.__N=void 0,d!==h.__[0]&&(u=!0)}}),r&&r.call(this,a,l,c)||u};w.__f=!0;var r=w.shouldComponentUpdate,s=w.componentWillUpdate;w.componentWillUpdate=function(a,l,c){if(this.__e){var _=r;r=void 0,i(a,l,c),r=_}s&&s.call(this,a,l,c)},w.shouldComponentUpdate=i}return n.__N||n.__}function P(e,t){var o=ee(G++,3);!b.__s&&Xe(o.__H,t)&&(o.__=e,o.u=t,w.__H.__h.push(o))}function q(e){return V=5,he(function(){return{current:e}},[])}function he(e,t){var o=ee(G++,7);return Xe(o.__H,t)&&(o.__=e(),o.__H=t,o.__h=e),o.__}function Be(e,t){return V=8,he(function(){return e},t)}function Ve(e){var t=w.context[e.__c],o=ee(G++,9);return o.c=e,t?(o.__==null&&(o.__=!0,t.sub(w)),t.props.value):e.__}function xt(){for(var e;e=Ue.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(te),e.__H.__h.forEach(fe),e.__H.__h=[]}catch(t){e.__H.__h=[],b.__e(t,e.__v)}}b.__b=function(e){w=null,Oe&&Oe(e)},b.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),We&&We(e,t)},b.__r=function(e){De&&De(e),G=0;var t=(w=e.__c).__H;t&&(de===w?(t.__h=[],w.__h=[],t.__.forEach(function(o){o.__N&&(o.__=o.__N),o.u=o.__N=void 0})):(t.__h.forEach(te),t.__h.forEach(fe),t.__h=[],G=0)),de=w},b.diffed=function(e){je&&je(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ue.push(t)!==1&&Fe===b.requestAnimationFrame||((Fe=b.requestAnimationFrame)||At)(xt)),t.__H.__.forEach(function(o){o.u&&(o.__H=o.u),o.u=void 0})),de=w=null},b.__c=function(e,t){t.some(function(o){try{o.__h.forEach(te),o.__h=o.__h.filter(function(n){return!n.__||fe(n)})}catch(n){t.some(function(i){i.__h&&(i.__h=[])}),t=[],b.__e(n,o.__v)}}),He&&He(e,t)},b.unmount=function(e){Ge&&Ge(e);var t,o=e.__c;o&&o.__H&&(o.__H.__.forEach(function(n){try{te(n)}catch(i){t=i}}),o.__H=void 0,t&&b.__e(t,o.__v))};var qe=typeof requestAnimationFrame=="function";function At(e){var t,o=function(){clearTimeout(n),qe&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(o,100);qe&&(t=requestAnimationFrame(o))}function te(e){var t=w,o=e.__c;typeof o=="function"&&(e.__c=void 0,o()),w=t}function fe(e){var t=w;e.__c=e.__(),w=t}function Xe(e,t){return!e||e.length!==t.length||t.some(function(o,n){return o!==e[n]})}function Ye(e,t){return typeof t=="function"?t(e):t}const Et=e=>({saveGameData(t){try{const o={highestUnlockedLevel:t.highestUnlockedLevel,levelScores:t.levelScores,totalScore:t.totalScore,currentLevel:t.currentLevel};localStorage.setItem(e,JSON.stringify(o))}catch(o){console.error("Failed to save maze game data:",o)}},loadGameData(){try{const t=localStorage.getItem(e);if(!t)return null;const o=JSON.parse(t);return{highestUnlockedLevel:o.highestUnlockedLevel,levelScores:o.levelScores,totalScore:o.totalScore,currentLevel:o.currentLevel,currentTier:Math.ceil(o.currentLevel/12),highestUnlockedTier:Math.ceil(o.highestUnlockedLevel/12)}}catch(t){return console.error("Failed to load maze game data:",t),null}},resetGameData(){try{localStorage.removeItem(e)}catch(t){console.error("Failed to reset game state:",t)}}}),Je=Re(void 0),Mt=({children:e,config:t})=>{const o=q(t),n=Et(t.lcPrefix+"score"),i=n.loadGameData(),[r,s]=I({currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:0,totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,maze:null,playerPosition:{row:0,col:0},exitPosition:{row:0,col:0},foodPositions:[],playerPath:[],visitCounts:{},moveCount:0,playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,...i||{}});P(()=>{n.saveGameData(r)},[r.highestUnlockedLevel,r.levelScores,r.totalScore,r.currentLevel]);const a=()=>{n.resetGameData(),s(l=>({...l,currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:0,totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,playerPath:[],visitCounts:{},moveCount:0,foodCollected:0,showClue:!1}))};return f(Je.Provider,{value:{gameState:r,setGameState:s,config:o,resetGame:a},children:e})},Ke=()=>{const e=Ve(Je);if(!e)throw new Error("useGameContext must be used within a GameProvider");return e};function me(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function It(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function pe(e,t,o){return t&&It(e.prototype,t),e}function Ze(e){return+e.replace(/px/,"")}function $t(e){var t=window.devicePixelRatio,o=getComputedStyle(e),n=Ze(o.getPropertyValue("width")),i=Ze(o.getPropertyValue("height"));e.setAttribute("width",(n*t).toString()),e.setAttribute("height",(i*t).toString())}function S(e,t){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=Math.random()*(t-e)+e;return Math.floor(n*Math.pow(10,o))/Math.pow(10,o)}function Qe(e){return e[S(0,e.length)]}var Rt=.00125,Ft=5e-4,Ut=9e-4,Ot=1e-5,Dt=6,jt=80,Ht=.9,Gt=1.7,Wt=.2,Bt=.6,Vt=.03,qt=.07,Xt=15,Yt=82,Jt=100,Kt=250,Zt=40,Qt=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function et(e){var t=1920;return Math.log(e)/Math.log(t)}var tt=function(){function e(t){me(this,e);var o=t.initialPosition,n=t.direction,i=t.confettiRadius,r=t.confettiColors,s=t.emojis,a=t.emojiSize,l=t.canvasWidth,c=S(Ht,Gt,3),_=c*et(l);this.confettiSpeed={x:_,y:_},this.finalConfettiSpeedX=S(Wt,Bt,3),this.rotationSpeed=s.length?.01:S(Vt,qt,3)*et(l),this.dragForceCoefficient=S(Ft,Ut,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=n==="left"?S(0,.2,3):S(-.2,0,3),this.emojiSize=a,this.emojiRotationAngle=S(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=n==="left"?S(Yt,Xt)*Math.PI/180:S(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var h=S(-150,0),d={x:o.x+(n==="left"?-h:h)*this.absCos,y:o.y-h*this.absSin};this.currentPosition=Object.assign({},d),this.initialPosition=Object.assign({},d),this.color=s.length?null:Qe(r),this.emoji=s.length?Qe(s):null,this.createdAt=new Date().getTime(),this.direction=n}return pe(e,[{key:"draw",value:function(o){var n=this.currentPosition,i=this.radius,r=this.color,s=this.emoji,a=this.rotationAngle,l=this.emojiRotationAngle,c=this.emojiSize,_=window.devicePixelRatio;r?(o.fillStyle=r,o.beginPath(),o.ellipse(n.x*_,n.y*_,i.x*_,i.y*_,a,0,2*Math.PI),o.fill()):s&&(o.font="".concat(c,"px serif"),o.save(),o.translate(_*n.x,_*n.y),o.rotate(l),o.textAlign="center",o.fillText(s,0,0),o.restore())}},{key:"updatePosition",value:function(o,n){var i=this.confettiSpeed,r=this.dragForceCoefficient,s=this.finalConfettiSpeedX,a=this.radiusYUpdateDirection,l=this.rotationSpeed,c=this.createdAt,_=this.direction,u=n-c;if(i.x>s&&(this.confettiSpeed.x-=r*o),this.currentPosition.x+=i.x*(_==="left"?-this.absCos:this.absCos)*o,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+Rt*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:Ot*o,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*o%(2*Math.PI);return}a==="down"?(this.radius.y-=o*l,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=o*l,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(o){return this.currentPosition.y<o+Jt}}]),e}();function eo(){var e=document.createElement("canvas");return e.style.position="fixed",e.style.width="100%",e.style.height="100%",e.style.top="0",e.style.left="0",e.style.zIndex="1000",e.style.pointerEvents="none",document.body.appendChild(e),e}function to(e){var t=e.confettiRadius,o=t===void 0?Dt:t,n=e.confettiNumber,i=n===void 0?e.confettiesNumber||(e.emojis?Zt:Kt):n,r=e.confettiColors,s=r===void 0?Qt:r,a=e.emojis,l=a===void 0?e.emojies||[]:a,c=e.emojiSize,_=c===void 0?jt:c;return e.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),e.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:o,confettiNumber:i,confettiColors:s,emojis:l,emojiSize:_}}var oo=function(){function e(t){var o=this;me(this,e),this.canvasContext=t,this.shapes=[],this.promise=new Promise(function(n){return o.resolvePromise=n})}return pe(e,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var o;(o=this.shapes).push.apply(o,arguments)}},{key:"complete",value:function(){var o;return this.shapes.length?!1:((o=this.resolvePromise)===null||o===void 0||o.call(this),!0)}},{key:"processShapes",value:function(o,n,i){var r=this,s=o.timeDelta,a=o.currentTime;this.shapes=this.shapes.filter(function(l){return l.updatePosition(s,a),l.draw(r.canvasContext),i?l.getIsVisibleOnCanvas(n):!0})}}]),e}(),no=function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};me(this,e),this.activeConfettiBatches=[],this.canvas=t.canvas||eo(),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 pe(e,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,$t(this.canvas);var o=new Date().getTime(),n=o-this.lastUpdated,i=this.canvas.offsetHeight,r=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(s){return s.processShapes({timeDelta:n,currentTime:o},i,r),r?!s.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(o)}},{key:"queueAnimationFrameIfNeeded",value:function(o){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=o||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=to(o),i=n.confettiRadius,r=n.confettiNumber,s=n.confettiColors,a=n.emojis,l=n.emojiSize,c=this.canvas.getBoundingClientRect(),_=c.width,u=c.height,h=u*5/7,d={x:0,y:h},m={x:_,y:h},v=new oo(this.canvasContext),y=0;y<r/2;y++){var g=new tt({initialPosition:d,direction:"right",confettiRadius:i,confettiColors:s,confettiNumber:r,emojis:a,emojiSize:l,canvasWidth:_}),p=new tt({initialPosition:m,direction:"left",confettiRadius:i,confettiColors:s,confettiNumber:r,emojis:a,emojiSize:l,canvasWidth:_});v.addShapes(g,p)}return this.activeConfettiBatches.push(v),this.queueAnimationFrameIfNeeded(),v.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),e}();function ot(e,t){for(var o in t)e[o]=t[o];return e}function nt(e,t){for(var o in e)if(o!=="__source"&&!(o in t))return!0;for(var n in t)if(n!=="__source"&&e[n]!==t[n])return!0;return!1}function it(e,t){this.props=e,this.context=t}(it.prototype=new M).isPureReactComponent=!0,it.prototype.shouldComponentUpdate=function(e,t){return nt(this.props,e)||nt(this.state,t)};var rt=C.__b;C.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),rt&&rt(e)};var io=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function st(e){function t(o){var n=ot({},o);return delete n.ref,e(n,o.ref||null)}return t.$$typeof=io,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var ro=C.__e;C.__e=function(e,t,o,n){if(e.then){for(var i,r=t;r=r.__;)if((i=r.__c)&&i.__c)return t.__e==null&&(t.__e=o.__e,t.__k=o.__k),i.__c(e,t)}ro(e,t,o,n)};var at=C.unmount;function lt(e,t,o){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(n){typeof n.__c=="function"&&n.__c()}),e.__c.__H=null),(e=ot({},e)).__c!=null&&(e.__c.__P===o&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(n){return lt(n,t,o)})),e}function ct(e,t,o){return e&&o&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(n){return ct(n,t,o)}),e.__c&&e.__c.__P===t&&(e.__e&&o.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=o)),e}function ve(){this.__u=0,this.o=null,this.__b=null}function ut(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function oe(){this.i=null,this.l=null}C.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),at&&at(e)},(ve.prototype=new M).__c=function(e,t){var o=t.__c,n=this;n.o==null&&(n.o=[]),n.o.push(o);var i=ut(n.__v),r=!1,s=function(){r||(r=!0,o.__R=null,i?i(a):a())};o.__R=s;var a=function(){if(!--n.__u){if(n.state.__a){var l=n.state.__a;n.__v.__k[0]=ct(l,l.__c.__P,l.__c.__O)}var c;for(n.setState({__a:n.__b=null});c=n.o.pop();)c.forceUpdate()}};n.__u++||32&t.__u||n.setState({__a:n.__b=n.__v.__k[0]}),e.then(s,s)},ve.prototype.componentWillUnmount=function(){this.o=[]},ve.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var o=document.createElement("div"),n=this.__v.__k[0].__c;this.__v.__k[0]=lt(this.__b,o,n.__O=n.__P)}this.__b=null}var i=t.__a&&D(j,null,e.fallback);return i&&(i.__u&=-33),[D(j,null,t.__a?null:e.children),i]};var _t=function(e,t,o){if(++o[1]===o[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(o=e.i;o;){for(;o.length>3;)o.pop()();if(o[1]<o[0])break;e.i=o=o[2]}};(oe.prototype=new M).__a=function(e){var t=this,o=ut(t.__v),n=t.l.get(e);return n[0]++,function(i){var r=function(){t.props.revealOrder?(n.push(i),_t(t,e,n)):i()};o?o(r):r()}},oe.prototype.render=function(e){this.i=null,this.l=new Map;var t=Z(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var o=t.length;o--;)this.l.set(t[o],this.i=[1,0,this.i]);return e.children},oe.prototype.componentDidUpdate=oe.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,o){_t(e,o,t)})};var so=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,ao=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,lo=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,co=/[A-Z0-9]/g,uo=typeof document<"u",_o=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};M.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(M.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var dt=C.event;function ho(){}function fo(){return this.cancelBubble}function mo(){return this.defaultPrevented}C.event=function(e){return dt&&(e=dt(e)),e.persist=ho,e.isPropagationStopped=fo,e.isDefaultPrevented=mo,e.nativeEvent=e};var po={enumerable:!1,configurable:!0,get:function(){return this.class}},ht=C.vnode;C.vnode=function(e){typeof e.type=="string"&&function(t){var o=t.props,n=t.type,i={},r=n.indexOf("-")===-1;for(var s in o){var a=o[s];if(!(s==="value"&&"defaultValue"in o&&a==null||uo&&s==="children"&&n==="noscript"||s==="class"||s==="className")){var l=s.toLowerCase();s==="defaultValue"&&"value"in o&&o.value==null?s="value":s==="download"&&a===!0?a="":l==="translate"&&a==="no"?a=!1:l[0]==="o"&&l[1]==="n"?l==="ondoubleclick"?s="ondblclick":l!=="onchange"||n!=="input"&&n!=="textarea"||_o(o.type)?l==="onfocus"?s="onfocusin":l==="onblur"?s="onfocusout":lo.test(s)&&(s=l):l=s="oninput":r&&ao.test(s)?s=s.replace(co,"-$&").toLowerCase():a===null&&(a=void 0),l==="oninput"&&i[s=l]&&(s="oninputCapture"),i[s]=a}}n=="select"&&i.multiple&&Array.isArray(i.value)&&(i.value=Z(o.children).forEach(function(c){c.props.selected=i.value.indexOf(c.props.value)!=-1})),n=="select"&&i.defaultValue!=null&&(i.value=Z(o.children).forEach(function(c){c.props.selected=i.multiple?i.defaultValue.indexOf(c.props.value)!=-1:i.defaultValue==c.props.value})),o.class&&!o.className?(i.class=o.class,Object.defineProperty(i,"className",po)):(o.className&&!o.class||o.class&&o.className)&&(i.class=i.className=o.className),t.props=i}(e),e.$$typeof=so,ht&&ht(e)};var ft=C.__r;C.__r=function(e){ft&&ft(e),e.__c};var mt=C.diffed;C.diffed=function(e){mt&&mt(e);var t=e.props,o=e.__e;o!=null&&e.type==="textarea"&&"value"in t&&t.value!==o.value&&(o.value=t.value==null?"":t.value)};/**
|
|
2
2
|
* @license lucide-react v0.473.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const vo=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),pt=(...e)=>e.filter((t,o,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===o).join(" ").trim();/**
|
|
7
7
|
* @license lucide-react v0.473.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/var
|
|
11
|
+
*/var go={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
12
12
|
* @license lucide-react v0.473.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const Co=st(({color:e="currentColor",size:t=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:i="",children:r,iconNode:s,...a},l)=>D("svg",{ref:l,...go,width:t,height:t,stroke:e,strokeWidth:n?Number(o)*24/Number(t):o,className:pt("lucide",i),...a},[...s.map(([c,_])=>D(c,_)),...Array.isArray(r)?r:[r]]));/**
|
|
17
17
|
* @license lucide-react v0.473.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const yo=(e,t)=>{const o=st(({className:n,...i},r)=>D(Co,{ref:r,iconNode:t,className:pt(`lucide-${vo(e)}`,n),...i}));return o.displayName=`${e}`,o};/**
|
|
22
22
|
* @license lucide-react v0.473.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const It=Ot("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),ct=Me(void 0),Wt=({children:e})=>{const[t,o]=$(null),[n,r]=$(!1),[i,s]=$("info"),[l,a]=$(null),c=Oe(()=>{r(!1),l&&(clearTimeout(l),a(null))},[l]),u=Oe((_,h="info",d=3e3)=>{if(n&&c(),o(_),s(h),r(!0),d>0){const m=setTimeout(()=>{r(!1)},d);a(m)}},[n,c]);return f(ct.Provider,{value:{message:t,visible:n,type:i,showToast:u,hideToast:c},children:e})},me=()=>{const e=Ie(ct);if(!e)throw new Error("useToast must be used within a ToastProvider");return e},Vt=({i18n:e,totalTiers:t,currentTier:o,highestUnlockedTier:n,onTierChange:r,disabled:i})=>f("div",{className:"tier-selector",children:f("select",{value:o,onChange:s=>{s.target&&s.target.value&&r(Number(s.target.value))},disabled:i,className:"tier-dropdown",children:Array.from({length:t},(s,l)=>l+1).map(s=>f("option",{value:s,disabled:s>n,children:[e.tier," ",s]},`tier-${s}`))})}),Bt=([e,t])=>Array.from({length:t-e+1},(o,n)=>e+n),jt=({i18n:e,levelsRange:t,currentLevel:o,highestUnlockedLevel:n,onLevelChange:r,disabled:i})=>{const s=Bt(t);return f("div",{className:"level-selector",children:f("select",{value:o,onChange:l=>{l.target&&l.target.value&&r(Number(l.target.value))},disabled:i,className:"level-dropdown",children:s.map(l=>f("option",{value:l,disabled:l>n,children:[e.level," ",l]},`level-${l}`))})})},pe=({isOpen:e,title:t,message:o,children:n,noConfirm:r=!1,noCancel:i=!1,confirmText:s="OK",cancelText:l="Cancel",onConfirm:a,onCancel:c})=>{const u=B(null);return L(()=>{const _=h=>{h.key==="Escape"&&c?.()};return e&&document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[e,c]),f("div",{className:`maze-dialog-overlay ${e?"maze-dialog-visible":""}`,children:f("div",{className:"maze-dialog",ref:u,children:[f("div",{className:"maze-dialog-title",children:t}),f("div",{className:"maze-dialog-content",children:n||f("div",{className:"maze-dialog-message",children:o})}),f("div",{className:"maze-dialog-buttons",children:[!i&&f("button",{className:"maze-dialog-cancel",onClick:c,children:l}),!r&&f("button",{className:"maze-dialog-confirm",onClick:a,children:s})]})]})})};function qt(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}const ve=[[{size:8,seed:12345,method:"backtracking"},{size:8,seed:23456,method:"backtracking"},{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"}]],ge={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",total:"Total",levelScore:"Level Score",bestScore:"Best 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 current score will be halved.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",clueTip:"Turn on clue will halve your current score in this level",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",warnNotAllFoodCollectedToast:"Collect all food first! %NUM% remaining.",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:{padding:10,wallWidth:4,wallColor:"#000000",exitColor:"#F44336",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerAtExitColor:"#FFD700"},levelConfig:ve},Kt=e=>e===1?2:e>=2&&e<=5?3:e>=6&&e<=11?4:e>=12&&e<=15?5:6;class Xt{constructor(t,o){this.row=t,this.col=o}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class Yt{rows;cols;grid;seed;random;constructor(t,o,n){this.rows=t,this.cols=o,this.seed=n??Math.floor(Math.random()*1e6),this.random=qt(this.seed),this.grid=this.initializeGrid()}initializeGrid(){const t=[];for(let o=0;o<this.rows;o++){t[o]=[];for(let n=0;n<this.cols;n++)t[o][n]=new Xt(o,n)}return t}isValid(t,o){return t>=0&&t<this.rows&&o>=0&&o<this.cols}getNeighbors(t,o){const n=[],r=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const i of r){const s=t+i.r,l=o+i.c;this.isValid(s,l)&&n.push({row:s,col:l})}return n}getUnvisitedNeighbors(t,o){return this.getNeighbors(t,o).filter(n=>!this.grid[n.row][n.col].visited)}getVisitedNeighbors(t,o){return this.getNeighbors(t,o).filter(n=>this.grid[n.row][n.col].visited)}removeWall(t,o,n,r){const i=this.grid[t][o],s=this.grid[n][r];t===n+1?(i.walls.top=!1,s.walls.bottom=!1):t===n-1?(i.walls.bottom=!1,s.walls.top=!1):o===r+1?(i.walls.left=!1,s.walls.right=!1):o===r-1&&(i.walls.right=!1,s.walls.left=!1)}}class Jt{maze;constructor(t,o,n,r,i={row:0,col:0},s={row:t-1,col:o-1}){switch(this.maze=new Yt(t,o,r),n){case"backtracking":this.runBacktracking();break;case"prims":this.runPrims();break;default:throw new Error(`Unknown maze generation method: ${n}`)}this.addOpenings(i,s)}getMaze(){return this.maze}runBacktracking(){const t=[],o=this.randomNumber(this.maze.rows),n=this.randomNumber(this.maze.cols);let r={row:o,col:n};for(this.maze.grid[o][n].visited=!0,t.push(r);t.length>0;){r=t[t.length-1];const{row:i,col:s}=r,l=this.maze.getUnvisitedNeighbors(i,s);if(l.length>0){const a=this.randomPick(l),{row:c,col:u}=a;this.maze.removeWall(i,s,c,u),this.maze.grid[c][u].visited=!0,t.push(a)}else t.pop()}}runPrims(){const t=[],o=(i,s)=>{const l=this.maze.getNeighbors(i,s);for(const a of l)!this.maze.grid[a.row][a.col].visited&&!t.some(c=>c.row===a.row&&c.col===a.col)&&t.push(a)},n=this.randomNumber(this.maze.rows),r=this.randomNumber(this.maze.cols);for(this.maze.grid[n][r].visited=!0,o(n,r);t.length>0;){const i=this.randomNumber(t.length),s=t[i],{row:l,col:a}=s,c=this.maze.getVisitedNeighbors(l,a);if(c.length>0){const u=this.randomPick(c);this.maze.removeWall(l,a,u.row,u.col),this.maze.grid[l][a].visited=!0,o(l,a)}t.splice(i,1)}}addOpenings(t,o){this.maze.grid[t.row][t.col].walls.top=!1,this.maze.grid[o.row][o.col].walls.bottom=!1}randomNumber(t){return Math.floor(this.maze.random()*t)}randomPick(t){return t[Math.floor(this.maze.random()*t.length)]}}function Zt(e,t,o,n,r,i){return new Jt(e,t,o,n,r,i).getMaze()}const Qt=(e,t,o)=>{if(!e.isValid(t,o))return!1;const n=e.grid[t][o];return!n.walls.top||!n.walls.right||!n.walls.bottom||!n.walls.left},_t=(e,t=ve.flat())=>{const o=e-1,n=t[o];if(!n)return console.error(`Cannot find Level ${e}'s config.`),null;const r=n.size,i=r,s=r,l=n.seed,a=n.method,c=n.entry||{row:0,col:0},u=n.exit||{row:i-1,col:s-1},_=Zt(i,s,a,l,c,u),h=Kt(e),d=[];for(let m=0;m<h;m++){let y;do y={row:Math.floor(_.random()*i),col:Math.floor(_.random()*s)};while(y.row===c.row&&y.col===c.col||y.row===u.row&&y.col===u.col||!Qt(_,y.row,y.col)||d.some(w=>w.row===y.row&&w.col===y.col));d.push(y)}return{maze:_,playerPosition:c,exitPosition:u,foodPositions:d,totalFoodCount:h,foodCollected:0,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1},moveCount:0,currentScore:_.rows*_.cols,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1}},ut=({gameState:e,setGameState:t,config:o})=>({generateCurrentLevelMaze:()=>{const r=_t(e.currentLevel,o.current.levelConfig.flat());r&&t(i=>({...i,...r}))}}),dt=e=>de(()=>{const t=e.map(l=>l.length),o=t.reduce((l,a)=>l+a,0),n=e.length,r=l=>{if(l<1||l>o)return 0;let a=0;for(let c=0;c<t.length;c++)if(a+=t[c],l<=a)return c+1;return 0},i=l=>l<1||l>n?0:t.slice(0,l-1).reduce((a,c)=>a+c,0)+1,s={getTotalLevels:()=>o,getTotalTiers:()=>n,getTierLevelsRange:l=>{if(l<1||l>n)return[0,0];const a=i(l),c=a+t[l-1]-1;return[a,c]},getTierByLevel:r,getFirstLevelOfTier:i,getLevelConfig:l=>{if(l<1||l>o)return null;const a=r(l),c=i(a),u=l-c;return e[a-1][u]},getTierConfig:l=>l<1||l>n?null:e[l-1],isLevelUnlocked:(l,a)=>l<=a,isTierUnlocked:(l,a)=>l<=a,getNextLevelInfo:l=>{if(l>=o)return null;const a=l+1,c=r(l),u=r(a);return{nextLevel:a,nextTier:u,isTierChange:u>c}},getCurrentTierProgress:(l,a)=>{const[c,u]=s.getTierLevelsRange(a),_=l-c+1,h=u-c+1;return{current:_,total:h}},isLastLevelInTier:l=>{const a=r(l),[,c]=s.getTierLevelsRange(a);return l===c},getPreviousLevelInfo:l=>{if(l<=1)return null;const a=l-1,c=r(l),u=r(a);return{prevLevel:a,prevTier:u,isTierChange:u<c}}};return s},[e]),eo=()=>{const{gameState:e,setGameState:t,resetGame:o,config:n}=qe(),r=n.current.i18n,i=n.current.levelConfig,s=dt(i),{showToast:l}=me(),{currentLevel:a,totalScore:c,levelScores:u,currentScore:_,showClue:h}=e,d=u[a]||0,m=s.getTotalTiers(),[y,w]=$(!1),[g,p]=$(!1),[z,b]=$(!1),[M,P]=$(s.getTierLevelsRange(1)),{generateCurrentLevelMaze:R}=ut({gameState:e,setGameState:t,config:n});L(()=>{P(s.getTierLevelsRange(e.currentTier))},[e.currentTier]);const A=N=>{const oe=s.getFirstLevelOfTier(N);s.isLevelUnlocked(oe,e.highestUnlockedLevel)&&(t(ko=>({...ko,currentTier:N})),E(oe))},E=N=>{s.isLevelUnlocked(N,e.highestUnlockedLevel)&&(t(oe=>({...oe,currentLevel:N})),R(),l(r.levelGoToast.replace("%LEVEL%",N.toString()),"success"))},x=()=>{w(!0)},T=()=>{w(!1)},H=()=>{b(!0)},vo=()=>{b(!1)},go=()=>{t(N=>(l(N.showClue?r.cluePathDisabled:r.cluePathEnabled),{...N,showClue:!N.showClue,currentScore:Math.floor(N.currentScore/2)})),b(!1)},yo=()=>{p(!0)},wo=()=>{o(),p(!1),l(r.resetDoneToast)},Co=()=>{p(!1)};return f("div",{class:"game-panel-container",children:[f("div",{className:"game-controls",children:[f("div",{className:"selectors-container",children:[f(Vt,{i18n:r,totalTiers:m,currentTier:e.currentTier,highestUnlockedTier:e.highestUnlockedTier,onTierChange:A,disabled:e.levelTransitioning}),f(jt,{i18n:r,levelsRange:M,currentLevel:e.currentLevel,highestUnlockedLevel:e.highestUnlockedLevel,onLevelChange:E,disabled:e.levelTransitioning})]}),f("div",{className:"score-container",children:[f("div",{className:"score-box currentscore",children:[f("span",{className:"score-label",children:[r.levelScore,":"]}),f("span",{className:"score-data",children:_})]}),f("div",{className:"score-box bestscore",children:[f("span",{className:"score-label",children:[r.bestScore,":"]}),f("span",{className:"score-data",children:d})]}),f("div",{className:"score-box totalscore",children:[f("span",{className:"score-label",children:[r.total,":"]}),f("span",{className:"score-data",children:c})]})]})]}),f("div",{className:"game-settings",children:f(It,{onClick:x,className:"game-settings-icon"})}),f(pe,{isOpen:y,title:r.settings,noConfirm:!0,cancelText:r.close,onCancel:T,children:[f("div",{className:"settings-item-box",children:[f("div",{}),f("button",{className:`settings-clue-button ${h?"clue-on":"clue-off"}`,title:"Toggle Clue",onClick:H,children:h?r.clueOn:r.clueOff}),f("div",{className:"settings-item-tip",children:r.clueTip})]}),f("div",{className:"settings-item-box",children:[f("button",{className:"settings-reset-button",title:"Reset Game",onClick:yo,children:r.reset}),f("div",{className:"settings-item-tip",children:r.resetTip})]})]}),f(pe,{isOpen:g,title:r.confirmReset,message:r.confirmResetMessage,confirmText:r.reset,cancelText:r.cancel,onConfirm:wo,onCancel:Co}),f(pe,{isOpen:z,title:r.confirmClue,message:r.confirmClueMessage,confirmText:r.confirm,cancelText:r.cancel,onConfirm:go,onCancel:vo})]})},to=({message:e,visible:t,duration:o=2e3,onClose:n,position:r="center",type:i="info"})=>e?(L(()=>{let s;return t&&o>0&&n&&(s=setTimeout(()=>{n()},o)),()=>{s&&clearTimeout(s)}},[t,o,n]),f("div",{className:`toast-container position-${r}`,children:f("div",{className:`toast-message type-${i} ${t?"toast-visible":""}`,children:e})})):null,oo=(e,t,o)=>{L(()=>{const n=()=>{const r=e.current;if(!r)return;const i=r.parentElement;if(!i)return;const s=i.clientWidth,l=i.clientHeight,a=Math.min(s,l),c=window.devicePixelRatio||1;r.style.width=`${a}px`,r.style.height=`${a}px`,r.width=a*c,r.height=a*c,t(e,o.current)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e])},ht={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},no=({containerRef:e,gameState:t,setGameState:o,onFoodCollected:n,onFoodNotAllCollected:r})=>{L(()=>{const i=a=>{if(!t.isGameActive||!t.maze)return;const[c,u]=ht[a],{row:_,col:h}=t.playerPosition,d=_+c,m=h+u;if(!t.maze.isValid(d,m))return;const y=t.maze.grid[_][h];if(c===-1&&y.walls.top||c===1&&y.walls.bottom||u===-1&&y.walls.left||u===1&&y.walls.right)return;const w={row:d,col:m},g=`${d},${m}`;o(p=>{const z=p.foodPositions.some(x=>x.row===d&&x.col===m);z&&n();const b=Math.max(0,p.currentScore-1),M=`${_},${h}-${d},${m}`,P=d===p.exitPosition.row&&m===p.exitPosition.col,R=z?p.foodCollected+1:p.foodCollected,A=R===p.totalFoodCount,E=P&&A;return P&&!A&&r(),{...p,playerPosition:w,playerPath:[...p.playerPath,w],foodPositions:p.foodPositions.filter(x=>!(x.row===d&&x.col===m)),foodCollected:R,currentScore:b,visitCounts:{...p.visitCounts,[M]:(p.visitCounts[M]||0)+1,[g]:(p.visitCounts[g]||0)+1},moveCount:p.moveCount+1,playerAtExit:P,isGameActive:!E,levelTransitioning:E}})},s=a=>{if(!t.isGameActive||!t.maze)return;const c=a.key;c in ht&&(a.preventDefault(),i(c))},l=a=>{if(a.preventDefault(),!t.isGameActive||!t.maze)return;const c=a.touches[0],u=document.elementFromPoint(c.clientX,c.clientY);u&&(u.classList.contains("maze-up")?i("ArrowUp"):u.classList.contains("maze-down")?i("ArrowDown"):u.classList.contains("maze-left")?i("ArrowLeft"):u.classList.contains("maze-right")&&i("ArrowRight"))};return window.addEventListener("keydown",s),e.current?.addEventListener("touchstart",l,{passive:!1}),()=>{window.removeEventListener("keydown",s),e.current?.removeEventListener("touchstart",l)}},[t.isGameActive,t.maze,t.playerPosition,t.exitPosition])},ro=({gameState:e,setGameState:t,config:o,onLevelComplete:n,onTierUnlocked:r})=>{L(()=>{if(e.levelTransitioning){n();const l=setTimeout(()=>{s(e.currentScore,o.current.levelConfig)},1e3);return()=>clearTimeout(l)}},[e.levelTransitioning]);const i=dt(o.current.levelConfig),s=(l,a)=>{const c=i.getNextLevelInfo(e.currentLevel);if(!c)return;const{nextLevel:u,nextTier:_,isTierChange:h}=c,d=_t(u,a.flat());d&&t(m=>{h&&r(_);const y={...m.levelScores};return y[m.currentLevel]=Math.max(l,y[m.currentLevel]||0),{...m,...d,currentLevel:u,currentTier:_,highestUnlockedLevel:Math.max(m.highestUnlockedLevel,u),highestUnlockedTier:Math.max(m.highestUnlockedTier,_),levelScores:y,totalScore:Object.values(y).reduce((w,g)=>w+g,0),showClue:!1,isGameActive:!0,levelTransitioning:!1}})};return{handleLevelComplete:s}};function io(e,t){const{ctx:o,width:n,height:r,maze:i}=e;t.playerColor=e.playerAtExit?t.playerAtExitColor:t.playerColor;const{padding:s,wallWidth:l,wallColor:a,playerColor:c,exitColor:u,foodColor:_,clueColor:h,backgroundColor:d}=t,m=i.cols,y=i.rows,w=(n-s*2)/m,g=(r-s*2)/y;o.clearRect(0,0,n,r),o.save(),o.fillStyle=d,o.fillRect(0,0,n,r),o.restore(),e.showClue&&e.playerPath&&e.playerPath.length>0&&uo(e,{cellWidth:w,cellHeight:g,padding:s,clueColor:h}),so(e,{cellWidth:w,cellHeight:g,padding:s,wallColor:a,wallWidth:l}),co(e,{cellWidth:w,cellHeight:g,padding:s,foodColor:_}),e.playerAtExit||ao(e,{cellWidth:w,cellHeight:g,padding:s,exitColor:u}),lo(e,{cellWidth:w,cellHeight:g,padding:s,playerColor:c})}function so(e,t){const{ctx:o,maze:n}=e,{cellWidth:r,cellHeight:i,padding:s,wallColor:l,wallWidth:a}=t;o.save(),o.strokeStyle=l,o.lineWidth=a,o.lineCap="round",o.beginPath();for(let c=0;c<n.rows;c++)for(let u=0;u<n.cols;u++){const _=n.grid[c][u],h=s+u*r,d=s+c*i;_.walls.top&&(o.moveTo(h,d),o.lineTo(h+r,d)),_.walls.right&&(o.moveTo(h+r,d),o.lineTo(h+r,d+i)),_.walls.bottom&&(o.moveTo(h+r,d+i),o.lineTo(h,d+i)),_.walls.left&&(o.moveTo(h,d+i),o.lineTo(h,d))}o.stroke(),o.restore()}function lo(e,t){const{ctx:o,playerPosition:n}=e,{cellWidth:r,cellHeight:i,padding:s,playerColor:l}=t,{x:a,y:c}=j(n.row,n.col,r,i,s),u=Math.min(r,i)*.35;o.save(),o.fillStyle=l,o.beginPath(),o.arc(a,c,u,0,Math.PI*2),o.fill(),o.restore()}function ao(e,t){const{ctx:o,exitPosition:n}=e,{cellWidth:r,cellHeight:i,padding:s,exitColor:l}=t,{x:a,y:c}=j(n.row,n.col,r,i,s),u=Math.min(r,i)*.35;o.save(),o.fillStyle=l,o.beginPath(),o.arc(a,c,u,0,Math.PI*2),o.fill(),o.restore()}function co(e,t){const{ctx:o,foodPositions:n}=e,{cellWidth:r,cellHeight:i,padding:s,foodColor:l}=t;o.fillStyle=l;const a=Math.min(r,i)*.25;n.forEach(c=>{const{x:u,y:_}=j(c.row,c.col,r,i,s);_o(o,u,_,a*1.2,5,a*.6)})}function _o(e,t,o,n,r,i){e.save(),e.beginPath();for(let s=0;s<r*2;s++){const l=s%2===0?n:i,a=Math.PI*s/r;e.lineTo(t+l*Math.sin(a),o+l*Math.cos(a))}e.closePath(),e.fill(),e.restore()}function uo(e,t){const{ctx:o,playerPath:n,visitCounts:r}=e,{cellWidth:i,cellHeight:s,padding:l,clueColor:a}=t;if(!(!n||n.length<2||!r)){o.save();for(let c=1;c<n.length;c++){const u=n[c-1],_=n[c],h=`${u.row},${u.col}-${_.row},${_.col}`,d=`${_.row},${_.col}-${u.row},${u.col}`,m=(r[h]||0)+(r[d]||0),y=Math.min(.2+m*.1,.9),w=Math.max(3,i*.1)+m*.5;try{o.strokeStyle=a.replace(")",`, ${y})`).replace("rgb(","rgba(")}catch{o.strokeStyle=`rgba(255, 0, 0, ${y})`}o.lineWidth=w,o.lineCap="round",o.lineJoin="round";const{x:g,y:p}=j(u.row,u.col,i,s,l),{x:z,y:b}=j(_.row,_.col,i,s,l);o.beginPath(),o.moveTo(g,p),o.lineTo(z,b),o.stroke()}o.restore()}}function j(e,t,o,n,r){return{x:r+t*o+o/2,y:r+e*n+n/2}}const ho=()=>{const{message:e,visible:t,type:o,hideToast:n}=me();return f(to,{message:e,visible:t,type:o,onClose:n,position:"top"})},fo=()=>{const{gameState:e,setGameState:t,config:o}=qe(),n=B(null),r=B(null),i=B(e),s=o.current.i18n,{showToast:l}=me();L(()=>{i.current=e},[e]);const a=()=>{const h=e.totalFoodCount-e.foodCollected-1;if(h>0){l(s.foodCollectedToast.replace("%NUM%",h.toString()),"success");return}l(s.allFoodCollectedToast,"success")},c=()=>{const h=e.totalFoodCount-e.foodCollected-1;l(s.warnNotAllFoodCollectedToast.replace("%NUM%",h.toString()),"warning")},u=(h,d)=>{const m=h.current?.getContext("2d");m&&d.maze&&io({ctx:m,width:h.current.width,height:h.current.height,maze:d.maze,playerPosition:d.playerPosition,exitPosition:d.exitPosition,foodPositions:d.foodPositions,showClue:d.showClue,playerPath:d.playerPath,visitCounts:d.visitCounts,playerAtExit:d.playerAtExit},o.current.renderConfig||{})};L(()=>{l(s.useArrowKeyTips,"info",3e3)},[]),oo(r,u,i);const{generateCurrentLevelMaze:_}=ut({gameState:e,setGameState:t,config:o});return no({containerRef:n,gameState:e,setGameState:t,onFoodCollected:a,onFoodNotAllCollected:c}),ro({gameState:e,setGameState:t,config:o,onLevelComplete:()=>{l(s.levelCompleteToast,"success")},onTierUnlocked:h=>{l(s.tierUnlockedToast.replace("%TIER%",h.toString()),"success")}}),L(()=>{e.isGameActive&&!e.levelTransitioning&&_()},[e.currentLevel,e.isGameActive,e.levelTransitioning]),L(()=>{r.current&&e.maze&&u(r,e)},[e]),f("div",{className:"maze-game-container",children:[f(ho,{}),f(eo,{}),f("div",{className:"maze-canvas-container",ref:n,children:[f("canvas",{ref:r,className:"maze-game-canvas"}),f("div",{className:"maze-touch-area maze-up"}),f("div",{className:"maze-touch-area maze-down"}),f("div",{className:"maze-touch-area maze-left"}),f("div",{className:"maze-touch-area maze-right"})]})]})};function mo(){return f(Wt,{children:f(fo,{})})}function po({config:e={}}){const t={...ge.i18n,...e.i18n||{}},o={...ge.renderConfig,...e.renderConfig||{}},n=e.levelConfig||ve;return e={...ge,...e,i18n:t,levelConfig:n,renderConfig:o},f(Tt,{config:e,children:f(mo,{})})}return{async init(e,t){const o=typeof e=="string"?document.querySelector(e):e;if(!o){console.warn("Cannot find the root element");const a=document.createElement("div");a.style.textAlign="center",a.style.padding="20px",a.innerHTML="Cannot find the root element",document.body.append(a);return}let{root:n=location.origin}=t;n.at(-1)!=="/"&&(n+="/");const r=document.createElement("div"),i=document.createElement("div");r.style.cssText=`
|
|
26
|
+
*/const wo=yo("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),vt=Re(void 0),bo=({children:e})=>{const[t,o]=I(null),[n,i]=I(!1),[r,s]=I("info"),[a,l]=I(null),c=Be(()=>{i(!1),a&&(clearTimeout(a),l(null))},[a]),_=Be((u,h="info",d=3e3)=>{if(n&&c(),o(u),s(h),i(!0),d>0){const m=setTimeout(()=>{i(!1)},d);l(m)}},[n,c]);return f(vt.Provider,{value:{message:t,visible:n,type:r,showToast:_,hideToast:c},children:e})},ge=()=>{const e=Ve(vt);if(!e)throw new Error("useToast must be used within a ToastProvider");return e},ko=({i18n:e,totalTiers:t,currentTier:o,highestUnlockedTier:n,onTierChange:i,disabled:r})=>f("div",{className:"tier-selector",children:f("select",{value:o,onChange:s=>{s.target&&s.target.value&&i(Number(s.target.value))},disabled:r,className:"tier-dropdown",children:Array.from({length:t},(s,a)=>a+1).map(s=>f("option",{value:s,disabled:s>n,children:[e.tier," ",s]},`tier-${s}`))})}),To=([e,t])=>Array.from({length:t-e+1},(o,n)=>e+n),zo=({i18n:e,levelsRange:t,currentLevel:o,highestUnlockedLevel:n,onLevelChange:i,disabled:r})=>{const s=To(t);return f("div",{className:"level-selector",children:f("select",{value:o,onChange:a=>{a.target&&a.target.value&&i(Number(a.target.value))},disabled:r,className:"level-dropdown",children:s.map(a=>f("option",{value:a,disabled:a>n,children:[e.level," ",a]},`level-${a}`))})})},Ce=({isOpen:e,title:t,message:o,children:n,noConfirm:i=!1,noCancel:r=!1,confirmText:s="OK",cancelText:a="Cancel",onConfirm:l,onCancel:c})=>{const _=q(null);return P(()=>{const u=h=>{h.key==="Escape"&&c?.()};return e&&document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[e,c]),f("div",{className:`maze-dialog-overlay ${e?"maze-dialog-visible":""}`,children:f("div",{className:"maze-dialog",ref:_,children:[f("div",{className:"maze-dialog-title",children:t}),f("div",{className:"maze-dialog-content",children:n||f("div",{className:"maze-dialog-message",children:o})}),f("div",{className:"maze-dialog-buttons",children:[!r&&f("button",{className:"maze-dialog-cancel",onClick:c,children:a}),!i&&f("button",{className:"maze-dialog-confirm",onClick:l,children:s})]})]})})};function Po(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}const ye=[[{size:8,seed:12345,method:"backtracking"},{size:8,seed:23456,method:"backtracking"},{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"}]],ne={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",total:"Total",levelScore:"Level Score",bestScore:"Best 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 current score will be halved.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",clueTip:"Turn on clue will halve your current score in this level",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",warnNotAllFoodCollectedToast:"Collect all food first! %NUM% remaining.",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:{padding:10,wallWidth:4,wallColor:"#000000",exitColor:"#F44336",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerAtExitColor:"#FFD700"},levelConfig:ye},So=e=>e===1?2:e>=2&&e<=5?3:e>=6&&e<=11?4:e>=12&&e<=15?5:6;class No{constructor(t,o){this.row=t,this.col=o}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class Lo{rows;cols;grid;seed;random;constructor(t,o,n){this.rows=t,this.cols=o,this.seed=n??Math.floor(Math.random()*1e6),this.random=Po(this.seed),this.grid=this.initializeGrid()}initializeGrid(){const t=[];for(let o=0;o<this.rows;o++){t[o]=[];for(let n=0;n<this.cols;n++)t[o][n]=new No(o,n)}return t}isValid(t,o){return t>=0&&t<this.rows&&o>=0&&o<this.cols}getNeighbors(t,o){const n=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const r of i){const s=t+r.r,a=o+r.c;this.isValid(s,a)&&n.push({row:s,col:a})}return n}getUnvisitedNeighbors(t,o){return this.getNeighbors(t,o).filter(n=>!this.grid[n.row][n.col].visited)}getVisitedNeighbors(t,o){return this.getNeighbors(t,o).filter(n=>this.grid[n.row][n.col].visited)}removeWall(t,o,n,i){const r=this.grid[t][o],s=this.grid[n][i];t===n+1?(r.walls.top=!1,s.walls.bottom=!1):t===n-1?(r.walls.bottom=!1,s.walls.top=!1):o===i+1?(r.walls.left=!1,s.walls.right=!1):o===i-1&&(r.walls.right=!1,s.walls.left=!1)}}class xo{maze;constructor(t,o,n,i,r={row:0,col:0},s={row:t-1,col:o-1}){switch(this.maze=new Lo(t,o,i),n){case"backtracking":this.runBacktracking();break;case"prims":this.runPrims();break;default:throw new Error(`Unknown maze generation method: ${n}`)}this.addOpenings(r,s)}getMaze(){return this.maze}runBacktracking(){const t=[],o=this.randomNumber(this.maze.rows),n=this.randomNumber(this.maze.cols);let i={row:o,col:n};for(this.maze.grid[o][n].visited=!0,t.push(i);t.length>0;){i=t[t.length-1];const{row:r,col:s}=i,a=this.maze.getUnvisitedNeighbors(r,s);if(a.length>0){const l=this.randomPick(a),{row:c,col:_}=l;this.maze.removeWall(r,s,c,_),this.maze.grid[c][_].visited=!0,t.push(l)}else t.pop()}}runPrims(){const t=[],o=(r,s)=>{const a=this.maze.getNeighbors(r,s);for(const l of a)!this.maze.grid[l.row][l.col].visited&&!t.some(c=>c.row===l.row&&c.col===l.col)&&t.push(l)},n=this.randomNumber(this.maze.rows),i=this.randomNumber(this.maze.cols);for(this.maze.grid[n][i].visited=!0,o(n,i);t.length>0;){const r=this.randomNumber(t.length),s=t[r],{row:a,col:l}=s,c=this.maze.getVisitedNeighbors(a,l);if(c.length>0){const _=this.randomPick(c);this.maze.removeWall(a,l,_.row,_.col),this.maze.grid[a][l].visited=!0,o(a,l)}t.splice(r,1)}}addOpenings(t,o){this.maze.grid[t.row][t.col].walls.top=!1,this.maze.grid[o.row][o.col].walls.bottom=!1}randomNumber(t){return Math.floor(this.maze.random()*t)}randomPick(t){return t[Math.floor(this.maze.random()*t.length)]}}function Ao(e,t,o,n,i,r){return new xo(e,t,o,n,i,r).getMaze()}const Eo=(e,t,o)=>{if(!e.isValid(t,o))return!1;const n=e.grid[t][o];return!n.walls.top||!n.walls.right||!n.walls.bottom||!n.walls.left},gt=(e,t=ye.flat())=>{const o=e-1,n=t[o];if(!n)return console.error(`Cannot find Level ${e}'s config.`),null;const i=n.size,r=i,s=i,a=n.seed,l=n.method,c=n.entry||{row:0,col:0},_=n.exit||{row:r-1,col:s-1},u=Ao(r,s,l,a,c,_),h=So(e),d=[];for(let m=0;m<h;m++){let v;do v={row:Math.floor(u.random()*r),col:Math.floor(u.random()*s)};while(v.row===c.row&&v.col===c.col||v.row===_.row&&v.col===_.col||!Eo(u,v.row,v.col)||d.some(y=>y.row===v.row&&y.col===v.col));d.push(v)}return{maze:u,playerPosition:c,exitPosition:_,foodPositions:d,totalFoodCount:h,foodCollected:0,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1},moveCount:0,currentScore:u.rows*u.cols*5,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1}},Ct=({gameState:e,setGameState:t,config:o})=>({generateCurrentLevelMaze:()=>{const i=gt(e.currentLevel,o.current.levelConfig.flat());i&&t(r=>({...r,...i}))}}),yt=e=>he(()=>{const t=e.map(a=>a.length),o=t.reduce((a,l)=>a+l,0),n=e.length,i=a=>{if(a<1||a>o)return 0;let l=0;for(let c=0;c<t.length;c++)if(l+=t[c],a<=l)return c+1;return 0},r=a=>a<1||a>n?0:t.slice(0,a-1).reduce((l,c)=>l+c,0)+1,s={getTotalLevels:()=>o,getTotalTiers:()=>n,getTierLevelsRange:a=>{if(a<1||a>n)return[0,0];const l=r(a),c=l+t[a-1]-1;return[l,c]},getTierByLevel:i,getFirstLevelOfTier:r,getLevelConfig:a=>{if(a<1||a>o)return null;const l=i(a),c=r(l),_=a-c;return e[l-1][_]},getTierConfig:a=>a<1||a>n?null:e[a-1],isLevelUnlocked:(a,l)=>a<=l,isTierUnlocked:(a,l)=>a<=l,getNextLevelInfo:a=>{if(a>=o)return null;const l=a+1,c=i(a),_=i(l);return{nextLevel:l,nextTier:_,isTierChange:_>c}},getCurrentTierProgress:(a,l)=>{const[c,_]=s.getTierLevelsRange(l),u=a-c+1,h=_-c+1;return{current:u,total:h}},isLastLevelInTier:a=>{const l=i(a),[,c]=s.getTierLevelsRange(l);return a===c},getPreviousLevelInfo:a=>{if(a<=1)return null;const l=a-1,c=i(a),_=i(l);return{prevLevel:l,prevTier:_,isTierChange:_<c}}};return s},[e]),Mo=()=>{const{gameState:e,setGameState:t,resetGame:o,config:n}=Ke(),i=n.current.i18n,r=n.current.levelConfig,s=yt(r),{showToast:a}=ge(),{currentLevel:l,totalScore:c,levelScores:_,currentScore:u,showClue:h}=e,d=_[l]||0,m=s.getTotalTiers(),[v,y]=I(!1),[g,p]=I(!1),[T,k]=I(!1),[$,N]=I(s.getTierLevelsRange(1)),{generateCurrentLevelMaze:U}=Ct({gameState:e,setGameState:t,config:n});P(()=>{N(s.getTierLevelsRange(e.currentTier))},[e.currentTier]);const R=A=>{const ie=s.getFirstLevelOfTier(A);s.isLevelUnlocked(ie,e.highestUnlockedLevel)&&(t(on=>({...on,currentTier:A})),L(ie))},L=A=>{s.isLevelUnlocked(A,e.highestUnlockedLevel)&&(t(ie=>({...ie,currentLevel:A})),U(),a(i.levelGoToast.replace("%LEVEL%",A.toString()),"success"))},x=()=>{y(!0)},z=()=>{y(!1)},O=()=>{k(!0)},Ko=()=>{k(!1)},Zo=()=>{t(A=>(a(A.showClue?i.cluePathDisabled:i.cluePathEnabled),{...A,showClue:!A.showClue,currentScore:Math.floor(A.currentScore/2)})),k(!1)},Qo=()=>{p(!0)},en=()=>{o(),p(!1),a(i.resetDoneToast)},tn=()=>{p(!1)};return f("div",{class:"game-panel-container",children:[f("div",{className:"game-controls",children:[f("div",{className:"selectors-container",children:[f(ko,{i18n:i,totalTiers:m,currentTier:e.currentTier,highestUnlockedTier:e.highestUnlockedTier,onTierChange:R,disabled:e.levelTransitioning}),f(zo,{i18n:i,levelsRange:$,currentLevel:e.currentLevel,highestUnlockedLevel:e.highestUnlockedLevel,onLevelChange:L,disabled:e.levelTransitioning})]}),f("div",{className:"score-container",children:[f("div",{className:"score-box currentscore",children:[f("span",{className:"score-label",children:[i.levelScore,":"]}),f("span",{className:"score-data",children:u})]}),f("div",{className:"score-box bestscore",children:[f("span",{className:"score-label",children:[i.bestScore,":"]}),f("span",{className:"score-data",children:d})]}),f("div",{className:"score-box totalscore",children:[f("span",{className:"score-label",children:[i.total,":"]}),f("span",{className:"score-data",children:c})]})]})]}),f("div",{className:"game-settings",children:f(wo,{onClick:x,className:"game-settings-icon"})}),f(Ce,{isOpen:v,title:i.settings,noConfirm:!0,cancelText:i.close,onCancel:z,children:[f("div",{className:"settings-item-box",children:[f("div",{}),f("button",{className:`settings-clue-button ${h?"clue-on":"clue-off"}`,disabled:h,title:"Toggle Clue",onClick:O,children:h?i.clueOn:i.clueOff}),f("div",{className:"settings-item-tip",children:i.clueTip})]}),f("div",{className:"settings-item-box",children:[f("button",{className:"settings-reset-button",title:"Reset Game",onClick:Qo,children:i.reset}),f("div",{className:"settings-item-tip",children:i.resetTip})]})]}),f(Ce,{isOpen:g,title:i.confirmReset,message:i.confirmResetMessage,confirmText:i.reset,cancelText:i.cancel,onConfirm:en,onCancel:tn}),f(Ce,{isOpen:T,title:i.confirmClue,message:i.confirmClueMessage,confirmText:i.confirm,cancelText:i.cancel,onConfirm:Zo,onCancel:Ko})]})},Io=({message:e,visible:t,duration:o=2e3,onClose:n,position:i="center",type:r="info"})=>e?(P(()=>{let s;return t&&o>0&&n&&(s=setTimeout(()=>{n()},o)),()=>{s&&clearTimeout(s)}},[t,o,n]),f("div",{className:`toast-container position-${i}`,children:f("div",{className:`toast-message type-${r} ${t?"toast-visible":""}`,children:e})})):null,$o=(e,t,o)=>{P(()=>{const n=()=>{const i=e.current;if(!i)return;const r=i.parentElement;if(!r)return;const s=r.clientWidth,a=window.devicePixelRatio||1;i.style.width=`${s}px`,i.style.height=`${s}px`,i.width=s*a,i.height=s*a,t(e,o.current)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e])},wt={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},Ro=({containerRef:e,gameState:t,setGameState:o,onFoodCollected:n,onFoodNotAllCollected:i})=>{P(()=>{const r=l=>{if(!t.isGameActive||!t.maze)return;const[c,_]=wt[l],{row:u,col:h}=t.playerPosition,d=u+c,m=h+_;if(!t.maze.isValid(d,m))return;const v=t.maze.grid[u][h];if(c===-1&&v.walls.top||c===1&&v.walls.bottom||_===-1&&v.walls.left||_===1&&v.walls.right)return;const y={row:d,col:m},g=`${d},${m}`;o(p=>{const T=p.foodPositions.some(x=>x.row===d&&x.col===m);T&&n();const k=Math.max(0,p.currentScore-1),$=`${u},${h}-${d},${m}`,N=d===p.exitPosition.row&&m===p.exitPosition.col,U=T?p.foodCollected+1:p.foodCollected,R=U===p.totalFoodCount,L=N&&R;return N&&!R&&i(),{...p,playerPosition:y,playerPath:[...p.playerPath,y],foodPositions:p.foodPositions.filter(x=>!(x.row===d&&x.col===m)),foodCollected:U,currentScore:k,visitCounts:{...p.visitCounts,[$]:(p.visitCounts[$]||0)+1,[g]:(p.visitCounts[g]||0)+1},moveCount:p.moveCount+1,playerAtExit:N,isGameActive:!L,levelTransitioning:L}})},s=l=>{if(!t.isGameActive||!t.maze)return;const c=l.key;c in wt&&(l.preventDefault(),r(c))},a=l=>{if(l.preventDefault(),!t.isGameActive||!t.maze)return;const c=l.touches[0],_=document.elementFromPoint(c.clientX,c.clientY);_&&(_.classList.contains("maze-up")?r("ArrowUp"):_.classList.contains("maze-down")?r("ArrowDown"):_.classList.contains("maze-left")?r("ArrowLeft"):_.classList.contains("maze-right")&&r("ArrowRight"))};return window.addEventListener("keydown",s),e.current?.addEventListener("touchstart",a,{passive:!1}),()=>{window.removeEventListener("keydown",s),e.current?.removeEventListener("touchstart",a)}},[t.isGameActive,t.maze,t.playerPosition,t.exitPosition])},Fo=({gameState:e,setGameState:t,config:o,onLevelComplete:n,onTierUnlocked:i})=>{P(()=>{if(e.levelTransitioning){n();const a=setTimeout(()=>{s(e.currentScore,o.current.levelConfig)},1e3);return()=>clearTimeout(a)}},[e.levelTransitioning]);const r=yt(o.current.levelConfig),s=(a,l)=>{const c=r.getNextLevelInfo(e.currentLevel);if(!c)return;const{nextLevel:_,nextTier:u,isTierChange:h}=c,d=gt(_,l.flat());d&&t(m=>{h&&i(u);const v={...m.levelScores};return v[m.currentLevel]=Math.max(a,v[m.currentLevel]||0),{...m,...d,currentLevel:_,currentTier:u,highestUnlockedLevel:Math.max(m.highestUnlockedLevel,_),highestUnlockedTier:Math.max(m.highestUnlockedTier,u),levelScores:v,totalScore:Object.values(v).reduce((y,g)=>y+g,0),showClue:!1,isGameActive:!0,levelTransitioning:!1}})};return{handleLevelComplete:s}};function Uo(e,t){const{ctx:o,width:n,height:i,maze:r}=e;t.playerColor=e.playerAtExit?t.playerAtExitColor:t.playerColor;const{padding:s,wallWidth:a,wallColor:l,playerColor:c,exitColor:_,foodColor:u,clueColor:h,backgroundColor:d}=t,m=r.cols,v=r.rows,y=(n-s*2)/m,g=(i-s*2)/v;o.clearRect(0,0,n,i),o.save(),o.fillStyle=d,o.fillRect(0,0,n,i),o.restore(),e.showClue&&e.playerPath&&e.playerPath.length>0&&Wo(e,{cellWidth:y,cellHeight:g,padding:s,clueColor:h}),Oo(e,{cellWidth:y,cellHeight:g,padding:s,wallColor:l,wallWidth:a}),Ho(e,{cellWidth:y,cellHeight:g,padding:s,foodColor:u}),e.playerAtExit||jo(e,{cellWidth:y,cellHeight:g,padding:s,exitColor:_}),Do(e,{cellWidth:y,cellHeight:g,padding:s,playerColor:c})}function Oo(e,t){const{ctx:o,maze:n}=e,{cellWidth:i,cellHeight:r,padding:s,wallColor:a,wallWidth:l}=t;o.save(),o.strokeStyle=a,o.lineWidth=l,o.lineCap="round",o.beginPath();for(let c=0;c<n.rows;c++)for(let _=0;_<n.cols;_++){const u=n.grid[c][_],h=s+_*i,d=s+c*r;u.walls.top&&(o.moveTo(h,d),o.lineTo(h+i,d)),u.walls.right&&(o.moveTo(h+i,d),o.lineTo(h+i,d+r)),u.walls.bottom&&(o.moveTo(h+i,d+r),o.lineTo(h,d+r)),u.walls.left&&(o.moveTo(h,d+r),o.lineTo(h,d))}o.stroke(),o.restore()}function Do(e,t){const{ctx:o,playerPosition:n}=e,{cellWidth:i,cellHeight:r,padding:s,playerColor:a}=t,{x:l,y:c}=X(n.row,n.col,i,r,s),_=Math.min(i,r)*.35;o.save(),o.fillStyle=a,o.beginPath(),o.arc(l,c,_,0,Math.PI*2),o.fill(),o.restore()}function jo(e,t){const{ctx:o,exitPosition:n}=e,{cellWidth:i,cellHeight:r,padding:s,exitColor:a}=t,{x:l,y:c}=X(n.row,n.col,i,r,s),_=Math.min(i,r)*.35;o.save(),o.fillStyle=a,o.beginPath(),o.arc(l,c,_,0,Math.PI*2),o.fill(),o.restore()}function Ho(e,t){const{ctx:o,foodPositions:n}=e,{cellWidth:i,cellHeight:r,padding:s,foodColor:a}=t;o.fillStyle=a;const l=Math.min(i,r)*.25;n.forEach(c=>{const{x:_,y:u}=X(c.row,c.col,i,r,s);Go(o,_,u,l*1.2,5,l*.6)})}function Go(e,t,o,n,i,r){e.save(),e.beginPath();for(let s=0;s<i*2;s++){const a=s%2===0?n:r,l=Math.PI*s/i;e.lineTo(t+a*Math.sin(l),o+a*Math.cos(l))}e.closePath(),e.fill(),e.restore()}function Wo(e,t){const{ctx:o,playerPath:n,visitCounts:i}=e,{cellWidth:r,cellHeight:s,padding:a,clueColor:l}=t;if(!(!n||n.length<2||!i)){o.save();for(let c=1;c<n.length;c++){const _=n[c-1],u=n[c],h=`${_.row},${_.col}-${u.row},${u.col}`,d=`${u.row},${u.col}-${_.row},${_.col}`,m=(i[h]||0)+(i[d]||0),v=Math.min(.2+m*.1,.9),y=Math.max(3,r*.1)+m*.5;try{o.strokeStyle=l.replace(")",`, ${v})`).replace("rgb(","rgba(")}catch{o.strokeStyle=`rgba(255, 0, 0, ${v})`}o.lineWidth=y,o.lineCap="round",o.lineJoin="round";const{x:g,y:p}=X(_.row,_.col,r,s,a),{x:T,y:k}=X(u.row,u.col,r,s,a);o.beginPath(),o.moveTo(g,p),o.lineTo(T,k),o.stroke()}o.restore()}}function X(e,t,o,n,i){return{x:i+t*o+o/2,y:i+e*n+n/2}}const Bo=new no,Vo=()=>{const{message:e,visible:t,type:o,hideToast:n}=ge();return f(Io,{message:e,visible:t,type:o,onClose:n,position:"top"})},qo=()=>{const{gameState:e,setGameState:t,config:o}=Ke(),n=q(null),i=q(null),r=q(e),s=o.current.i18n,{showToast:a}=ge();P(()=>{r.current=e},[e]);const l=()=>{const h=e.totalFoodCount-e.foodCollected-1;if(h>0){a(s.foodCollectedToast.replace("%NUM%",h.toString()),"success");return}a(s.allFoodCollectedToast,"success")},c=()=>{const h=e.totalFoodCount-e.foodCollected-1;a(s.warnNotAllFoodCollectedToast.replace("%NUM%",h.toString()),"warning")},_=(h,d)=>{const m=h.current?.getContext("2d");m&&d.maze&&Uo({ctx:m,width:h.current.width,height:h.current.height,maze:d.maze,playerPosition:d.playerPosition,exitPosition:d.exitPosition,foodPositions:d.foodPositions,showClue:d.showClue,playerPath:d.playerPath,visitCounts:d.visitCounts,playerAtExit:d.playerAtExit},o.current.renderConfig||{})};P(()=>{a(s.useArrowKeyTips,"info",3e3)},[]),$o(i,_,r);const{generateCurrentLevelMaze:u}=Ct({gameState:e,setGameState:t,config:o});return Ro({containerRef:n,gameState:e,setGameState:t,onFoodCollected:l,onFoodNotAllCollected:c}),Fo({gameState:e,setGameState:t,config:o,onLevelComplete:()=>{Bo.addConfetti(),a(s.levelCompleteToast,"success")},onTierUnlocked:h=>{a(s.tierUnlockedToast.replace("%TIER%",h.toString()),"success")}}),P(()=>{e.isGameActive&&!e.levelTransitioning&&u()},[e.currentLevel,e.isGameActive,e.levelTransitioning]),P(()=>{i.current&&e.maze&&_(i,e)},[e]),f("div",{className:"maze-game-container",children:[f(Vo,{}),f(Mo,{}),f("div",{className:"maze-canvas-container",ref:n,children:[f("canvas",{ref:i,className:"maze-game-canvas"}),f("div",{className:"maze-touch-area maze-up"}),f("div",{className:"maze-touch-area maze-down"}),f("div",{className:"maze-touch-area maze-left"}),f("div",{className:"maze-touch-area maze-right"})]})]})};function Xo(){return f(bo,{children:f(qo,{})})}function Yo({config:e={}}){const t={...ne.i18n,...e.i18n||{}},o={...ne.renderConfig,...e.renderConfig||{}},n=e.levelConfig||ye;return e={...ne,...e,i18n:t,levelConfig:n,renderConfig:o},f(Mt,{config:e,children:f(Xo,{})})}const Jo={root:"https://unpkg.com/@roudanio/maze@0.0.4/dist/",...ne};return`${JSON.stringify(Jo,null,2)}`,{async init(e,t){const o=typeof e=="string"?document.querySelector(e):e;if(!o){console.warn("Cannot find the root element");const l=document.createElement("div");l.style.textAlign="center",l.style.padding="20px",l.innerHTML="Cannot find the root element",document.body.append(l);return}let{root:n=location.origin}=t;n.at(-1)!=="/"&&(n+="/");const i=document.createElement("div"),r=document.createElement("div");i.style.cssText=`
|
|
27
27
|
height: 30px;
|
|
28
28
|
width: 100%;
|
|
29
29
|
border: solid 2px #999;
|
|
30
30
|
margin: 20% auto;
|
|
31
|
-
`,
|
|
31
|
+
`,r.style.cssText=`
|
|
32
32
|
width: 99%;
|
|
33
33
|
height: 100%;
|
|
34
34
|
background: #999;
|
|
35
35
|
animation: loading 1.5s ease-in-out;
|
|
36
36
|
transition: width 1.5s ease-in-out;
|
|
37
37
|
transition: width 1.5s ease-in-out;
|
|
38
|
-
`,
|
|
38
|
+
`,i.append(r),o.append(i);const s=document.createElement("style");s.innerHTML=`
|
|
39
39
|
@keyframes loading {
|
|
40
40
|
0% { width: 0%; }
|
|
41
41
|
100% { width: 99%; }
|
|
42
|
-
}`,document.head.appendChild(s),await(async
|
|
42
|
+
}`,document.head.appendChild(s),await(async l=>new Promise((c,_)=>{const u=document.createElement("link");u.rel="stylesheet",u.type="text/css",u.href=l,u.onload=c,u.onerror=_,document.head.appendChild(u)}))(n+"maze.css"),St(f(Yo,{config:t}),o)}}}();
|