@roudanio/maze 0.0.8 → 0.0.9
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 +2 -2
- package/dist/maze.js +419 -341
- package/dist/maze.umd.js +2 -2
- package/package.json +1 -1
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 .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 .game-settings{display:flex;align-items:center;justify-content:center}.maze-game-container .game-settings .game-settings-icon{font-size:2rem;cursor:pointer}.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 .link-button{background-color:transparent;color:#4caf50;cursor:pointer;font-size:16px;transition:color .2s}.maze-game-container .link-button:hover{color:#45a049;background-color:transparent}.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 .game-settings{display:flex;align-items:center;justify-content:center}.maze-game-container .game-settings .game-settings-icon{font-size:2rem;cursor:pointer}.maze-game-container .settings-stats{padding-top:20px;padding-bottom:20px;display:flex;flex-direction:column;align-items:start;gap:6px;text-align:left}.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;box-shadow:none;transform:none}.maze-game-container .level-complete-dialog .maze-dialog-buttons{justify-content:space-between}.maze-game-container .level-complete-dialog .maze-dialog-confirm{background-color:#ff9800}.maze-game-container .level-complete-dialog .maze-dialog-confirm:hover{background-color:#e67e00}.maze-game-container .maze-summary-message{width:75%;margin:30px auto;text-align:left}.maze-game-container .go-next-level{margin:30px auto}.maze-game-container .all-levels-completed{margin-top:20px;margin-bottom:20px}.maze-game-container .not-all-stars-collected{padding:10px;background-color:#fff8e1;color:#ff9800;border-radius:5px;text-align:center;font-size:14px}.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;color:#666;line-height:1.5}.maze-game-container .maze-dialog-buttons{margin-top:20px;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,4 +1,4 @@
|
|
|
1
|
-
var Maze=function(){"use strict";var B,w,pe,I,Ce,we,ye,be,oe,ne,ie,ke,j={},Te=[],nt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,q=Array.isArray;function A(t,e){for(var o in e)t[o]=e[o];return t}function re(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function it(t,e,o){var n,i,r,s={};for(r in e)r=="key"?n=e[r]:r=="ref"?i=e[r]:s[r]=e[r];if(arguments.length>2&&(s.children=arguments.length>3?B.call(arguments,2):o),typeof t=="function"&&t.defaultProps!=null)for(r in t.defaultProps)s[r]==null&&(s[r]=t.defaultProps[r]);return V(t,s,n,i,null)}function V(t,e,o,n,i){var r={type:t,props:e,key:o,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++pe,__i:-1,__u:0};return i==null&&w.vnode!=null&&w.vnode(r),r}function X(t){return t.children}function Y(t,e){this.props=t,this.context=e}function $(t,e){if(e==null)return t.__?$(t.__,t.__i+1):null;for(var o;e<t.__k.length;e++)if((o=t.__k[e])!=null&&o.__e!=null)return o.__e;return typeof t.type=="function"?$(t):null}function ze(t){var e,o;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((o=t.__k[e])!=null&&o.__e!=null){t.__e=t.__c.base=o.__e;break}return ze(t)}}function se(t){(!t.__d&&(t.__d=!0)&&I.push(t)&&!J.__r++||Ce!=w.debounceRendering)&&((Ce=w.debounceRendering)||we)(J)}function J(){for(var t,e,o,n,i,r,s,l=1;I.length;)I.length>l&&I.sort(ye),t=I.shift(),l=I.length,t.__d&&(o=void 0,i=(n=(e=t).__v).__e,r=[],s=[],e.__P&&((o=A({},n)).__v=n.__v+1,w.vnode&&w.vnode(o),le(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[i]:null,r,i??$(n),!!(32&n.__u),s),o.__v=n.__v,o.__.__k[o.__i]=o,xe(r,o,s),o.__e!=i&&ze(o)));J.__r=0}function Pe(t,e,o,n,i,r,s,l,c,a,d){var u,_,h,v,g,p,f=n&&n.__k||Te,C=e.length;for(c=rt(o,e,f,c,C),u=0;u<C;u++)(h=o.__k[u])!=null&&(_=h.__i==-1?j:f[h.__i]||j,h.__i=u,p=le(t,h,_,i,r,s,l,c,a,d),v=h.__e,h.ref&&_.ref!=h.ref&&(_.ref&&ae(_.ref,null,h),d.push(h.ref,h.__c||v,h)),g==null&&v!=null&&(g=v),4&h.__u||_.__k===h.__k?c=Le(h,c,t):typeof h.type=="function"&&p!==void 0?c=p:v&&(c=v.nextSibling),h.__u&=-7);return o.__e=g,c}function rt(t,e,o,n,i){var r,s,l,c,a,d=o.length,u=d,_=0;for(t.__k=new Array(i),r=0;r<i;r++)(s=e[r])!=null&&typeof s!="boolean"&&typeof s!="function"?(c=r+_,(s=t.__k[r]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?V(null,s,null,null,null):q(s)?V(X,{children:s},null,null,null):s.constructor==null&&s.__b>0?V(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,l=null,(a=s.__i=st(s,o,c,u))!=-1&&(u--,(l=o[a])&&(l.__u|=2)),l==null||l.__v==null?(a==-1&&(i>d?_--:i<d&&_++),typeof s.type!="function"&&(s.__u|=4)):a!=c&&(a==c-1?_--:a==c+1?_++:(a>c?_--:_++,s.__u|=4))):t.__k[r]=null;if(u)for(r=0;r<d;r++)(l=o[r])!=null&&(2&l.__u)==0&&(l.__e==n&&(n=$(l)),Ee(l,l));return n}function Le(t,e,o){var n,i;if(typeof t.type=="function"){for(n=t.__k,i=0;n&&i<n.length;i++)n[i]&&(n[i].__=t,e=Le(n[i],e,o));return e}t.__e!=e&&(e&&t.type&&!o.contains(e)&&(e=$(t)),o.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function st(t,e,o,n){var i,r,s=t.key,l=t.type,c=e[o];if(c===null&&t.key==null||c&&s==c.key&&l==c.type&&(2&c.__u)==0)return o;if(n>(c!=null&&(2&c.__u)==0?1:0))for(i=o-1,r=o+1;i>=0||r<e.length;){if(i>=0){if((c=e[i])&&(2&c.__u)==0&&s==c.key&&l==c.type)return i;i--}if(r<e.length){if((c=e[r])&&(2&c.__u)==0&&s==c.key&&l==c.type)return r;r++}}return-1}function Se(t,e,o){e[0]=="-"?t.setProperty(e,o??""):t[e]=o==null?"":typeof o!="number"||nt.test(e)?o:o+"px"}function K(t,e,o,n,i){var r;e:if(e=="style")if(typeof o=="string")t.style.cssText=o;else{if(typeof n=="string"&&(t.style.cssText=n=""),n)for(e in n)o&&e in o||Se(t.style,e,"");if(o)for(e in o)n&&o[e]==n[e]||Se(t.style,e,o[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(be,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+r]=o,o?n?o.u=n.u:(o.u=oe,t.addEventListener(e,r?ie:ne,r)):t.removeEventListener(e,r?ie:ne,r);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&o==1?"":o))}}function Ne(t){return function(e){if(this.l){var o=this.l[e.type+t];if(e.t==null)e.t=oe++;else if(e.t<o.u)return;return o(w.event?w.event(e):e)}}}function le(t,e,o,n,i,r,s,l,c,a){var d,u,_,h,v,g,p,f,C,z,k,M,S,N,O,R,W,T=e.type;if(e.constructor!=null)return null;128&o.__u&&(c=!!(32&o.__u),r=[l=e.__e=o.__e]),(d=w.__b)&&d(e);e:if(typeof T=="function")try{if(f=e.props,C="prototype"in T&&T.prototype.render,z=(d=T.contextType)&&n[d.__c],k=d?z?z.props.value:d.__:n,o.__c?p=(u=e.__c=o.__c).__=u.__E:(C?e.__c=u=new T(f,k):(e.__c=u=new Y(f,k),u.constructor=T,u.render=at),z&&z.sub(u),u.props=f,u.state||(u.state={}),u.context=k,u.__n=n,_=u.__d=!0,u.__h=[],u._sb=[]),C&&u.__s==null&&(u.__s=u.state),C&&T.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=A({},u.__s)),A(u.__s,T.getDerivedStateFromProps(f,u.__s))),h=u.props,v=u.state,u.__v=e,_)C&&T.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),C&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(C&&T.getDerivedStateFromProps==null&&f!==h&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(f,k),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(f,u.__s,k)===!1||e.__v==o.__v){for(e.__v!=o.__v&&(u.props=f,u.state=u.__s,u.__d=!1),e.__e=o.__e,e.__k=o.__k,e.__k.some(function(F){F&&(F.__=e)}),M=0;M<u._sb.length;M++)u.__h.push(u._sb[M]);u._sb=[],u.__h.length&&s.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(f,u.__s,k),C&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(h,v,g)})}if(u.context=k,u.props=f,u.__P=t,u.__e=!1,S=w.__r,N=0,C){for(u.state=u.__s,u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),O=0;O<u._sb.length;O++)u.__h.push(u._sb[O]);u._sb=[]}else do u.__d=!1,S&&S(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++N<25);u.state=u.__s,u.getChildContext!=null&&(n=A(A({},n),u.getChildContext())),C&&!_&&u.getSnapshotBeforeUpdate!=null&&(g=u.getSnapshotBeforeUpdate(h,v)),R=d,d!=null&&d.type===X&&d.key==null&&(R=Ae(d.props.children)),l=Pe(t,q(R)?R:[R],e,o,n,i,r,s,l,c,a),u.base=e.__e,e.__u&=-161,u.__h.length&&s.push(u),p&&(u.__E=u.__=null)}catch(F){if(e.__v=null,c||r!=null)if(F.then){for(e.__u|=c?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;r[r.indexOf(l)]=null,e.__e=l}else for(W=r.length;W--;)re(r[W]);else e.__e=o.__e,e.__k=o.__k;w.__e(F,e,o)}else r==null&&e.__v==o.__v?(e.__k=o.__k,e.__e=o.__e):l=e.__e=lt(o.__e,e,o,n,i,r,s,c,a);return(d=w.diffed)&&d(e),128&e.__u?void 0:l}function xe(t,e,o){for(var n=0;n<o.length;n++)ae(o[n],o[++n],o[++n]);w.__c&&w.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(r){r.call(i)})}catch(r){w.__e(r,i.__v)}})}function Ae(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:q(t)?t.map(Ae):A({},t)}function lt(t,e,o,n,i,r,s,l,c){var a,d,u,_,h,v,g,p=o.props,f=e.props,C=e.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),r!=null){for(a=0;a<r.length;a++)if((h=r[a])&&"setAttribute"in h==!!C&&(C?h.localName==C:h.nodeType==3)){t=h,r[a]=null;break}}if(t==null){if(C==null)return document.createTextNode(f);t=document.createElementNS(i,C,f.is&&f),l&&(w.__m&&w.__m(e,r),l=!1),r=null}if(C==null)p===f||l&&t.data==f||(t.data=f);else{if(r=r&&B.call(t.childNodes),p=o.props||j,!l&&r!=null)for(p={},a=0;a<t.attributes.length;a++)p[(h=t.attributes[a]).name]=h.value;for(a in p)if(h=p[a],a!="children"){if(a=="dangerouslySetInnerHTML")u=h;else if(!(a in f)){if(a=="value"&&"defaultValue"in f||a=="checked"&&"defaultChecked"in f)continue;K(t,a,null,h,i)}}for(a in f)h=f[a],a=="children"?_=h:a=="dangerouslySetInnerHTML"?d=h:a=="value"?v=h:a=="checked"?g=h:l&&typeof h!="function"||p[a]===h||K(t,a,h,p[a],i);if(d)l||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),Pe(e.type=="template"?t.content:t,q(_)?_:[_],e,o,n,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,r,s,r?r[0]:o.__k&&$(o,0),l,c),r!=null)for(a=r.length;a--;)re(r[a]);l||(a="value",C=="progress"&&v==null?t.removeAttribute("value"):v!=null&&(v!==t[a]||C=="progress"&&!v||C=="option"&&v!=p[a])&&K(t,a,v,p[a],i),a="checked",g!=null&&g!=t[a]&&K(t,a,g,p[a],i))}return t}function ae(t,e,o){try{if(typeof t=="function"){var n=typeof t.__u=="function";n&&t.__u(),n&&e==null||(t.__u=t(e))}else t.current=e}catch(i){w.__e(i,o)}}function Ee(t,e,o){var n,i;if(w.unmount&&w.unmount(t),(n=t.ref)&&(n.current&&n.current!=t.__e||ae(n,null,e)),(n=t.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(r){w.__e(r,e)}n.base=n.__P=null}if(n=t.__k)for(i=0;i<n.length;i++)n[i]&&Ee(n[i],e,o||typeof t.type!="function");o||re(t.__e),t.__c=t.__=t.__e=void 0}function at(t,e,o){return this.constructor(t,o)}function ct(t,e,o){var n,i,r,s;e==document&&(e=document.documentElement),w.__&&w.__(t,e),i=(n=!1)?null:e.__k,r=[],s=[],le(e,t=e.__k=it(X,null,[t]),i||j,j,e.namespaceURI,i?null:e.firstChild?B.call(e.childNodes):null,r,i?i.__e:e.firstChild,n,s),xe(r,t,s)}function Me(t){function e(o){var n,i;return this.getChildContext||(n=new Set,(i={})[e.__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,se(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 e.__c="__cC"+ke++,e.__=t,e.Provider=e.__l=(e.Consumer=function(o,n){return o.children(n)}).contextType=e,e}B=Te.slice,w={__e:function(t,e,o,n){for(var i,r,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((r=i.constructor)&&r.getDerivedStateFromError!=null&&(i.setState(r.getDerivedStateFromError(t)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,n||{}),s=i.__d),s)return i.__E=i}catch(l){t=l}throw t}},pe=0,Y.prototype.setState=function(t,e){var o;o=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=A({},this.state),typeof t=="function"&&(t=t(A({},o),this.props)),t&&A(o,t),t!=null&&this.__v&&(e&&this._sb.push(e),se(this))},Y.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),se(this))},Y.prototype.render=X,I=[],we=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ye=function(t,e){return t.__v.__b-e.__v.__b},J.__r=0,be=/(PointerCapture)$|Capture$/i,oe=0,ne=Ne(!1),ie=Ne(!0),ke=0;var ut=0;function m(t,e,o,n,i,r){e||(e={});var s,l,c=e;if("ref"in c)for(l in c={},e)l=="ref"?s=e[l]:c[l]=e[l];var a={type:t,props:c,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ut,__i:-1,__u:0,__source:i,__self:r};if(typeof t=="function"&&(s=t.defaultProps))for(l in s)c[l]===void 0&&(c[l]=s[l]);return w.vnode&&w.vnode(a),a}var U,y,ce,Ie,G=0,Re=[],b=w,Fe=b.__b,$e=b.__r,Ue=b.diffed,De=b.__c,Oe=b.unmount,je=b.__;function Z(t,e){b.__h&&b.__h(y,t,G||e),G=0;var o=y.__H||(y.__H={__:[],__h:[]});return t>=o.__.length&&o.__.push({}),o.__[t]}function E(t){return G=1,dt(qe,t)}function dt(t,e,o){var n=Z(U++,2);if(n.t=t,!n.__c&&(n.__=[qe(void 0,e),function(l){var c=n.__N?n.__N[0]:n.__[0],a=n.t(c,l);c!==a&&(n.__N=[a,n.__[1]],n.__c.setState({}))}],n.__c=y,!y.__f)){var i=function(l,c,a){if(!n.__c.__H)return!0;var d=n.__c.__H.__.filter(function(_){return!!_.__c});if(d.every(function(_){return!_.__N}))return!r||r.call(this,l,c,a);var u=n.__c.props!==l;return d.forEach(function(_){if(_.__N){var h=_.__[0];_.__=_.__N,_.__N=void 0,h!==_.__[0]&&(u=!0)}}),r&&r.call(this,l,c,a)||u};y.__f=!0;var r=y.shouldComponentUpdate,s=y.componentWillUpdate;y.componentWillUpdate=function(l,c,a){if(this.__e){var d=r;r=void 0,i(l,c,a),r=d}s&&s.call(this,l,c,a)},y.shouldComponentUpdate=i}return n.__N||n.__}function P(t,e){var o=Z(U++,3);!b.__s&&Be(o.__H,e)&&(o.__=t,o.u=e,y.__H.__h.push(o))}function D(t){return G=5,ue(function(){return{current:t}},[])}function ue(t,e){var o=Z(U++,7);return Be(o.__H,e)&&(o.__=t(),o.__H=e,o.__h=t),o.__}function Ge(t,e){return G=8,ue(function(){return t},e)}function He(t){var e=y.context[t.__c],o=Z(U++,9);return o.c=t,e?(o.__==null&&(o.__=!0,e.sub(y)),e.props.value):t.__}function ht(){for(var t;t=Re.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Q),t.__H.__h.forEach(de),t.__H.__h=[]}catch(e){t.__H.__h=[],b.__e(e,t.__v)}}b.__b=function(t){y=null,Fe&&Fe(t)},b.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},b.__r=function(t){$e&&$e(t),U=0;var e=(y=t.__c).__H;e&&(ce===y?(e.__h=[],y.__h=[],e.__.forEach(function(o){o.__N&&(o.__=o.__N),o.u=o.__N=void 0})):(e.__h.forEach(Q),e.__h.forEach(de),e.__h=[],U=0)),ce=y},b.diffed=function(t){Ue&&Ue(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Re.push(e)!==1&&Ie===b.requestAnimationFrame||((Ie=b.requestAnimationFrame)||_t)(ht)),e.__H.__.forEach(function(o){o.u&&(o.__H=o.u),o.u=void 0})),ce=y=null},b.__c=function(t,e){e.some(function(o){try{o.__h.forEach(Q),o.__h=o.__h.filter(function(n){return!n.__||de(n)})}catch(n){e.some(function(i){i.__h&&(i.__h=[])}),e=[],b.__e(n,o.__v)}}),De&&De(t,e)},b.unmount=function(t){Oe&&Oe(t);var e,o=t.__c;o&&o.__H&&(o.__H.__.forEach(function(n){try{Q(n)}catch(i){e=i}}),o.__H=void 0,e&&b.__e(e,o.__v))};var We=typeof requestAnimationFrame=="function";function _t(t){var e,o=function(){clearTimeout(n),We&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(o,100);We&&(e=requestAnimationFrame(o))}function Q(t){var e=y,o=t.__c;typeof o=="function"&&(t.__c=void 0,o()),y=e}function de(t){var e=y;t.__c=t.__(),y=e}function Be(t,e){return!t||t.length!==e.length||e.some(function(o,n){return o!==t[n]})}function qe(t,e){return typeof e=="function"?e(t):e}const ft=t=>({saveGameData(e){try{const o={highestUnlockedLevel:e.highestUnlockedLevel,levelScores:e.levelScores,totalScore:e.totalScore,currentLevel:e.currentLevel};localStorage.setItem(t,JSON.stringify(o))}catch(o){console.error("Failed to save maze game data:",o)}},loadGameData(){try{const e=localStorage.getItem(t);if(!e)return null;const o=JSON.parse(e);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(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset game state:",e)}}}),Ve=Me(void 0),mt=({children:t,config:e})=>{const o=D(e),n=ft(e.lcPrefix+"score"),i=n.loadGameData(),[r,s]=E({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 l=()=>{n.resetGameData(),s(c=>({...c,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 m(Ve.Provider,{value:{gameState:r,setGameState:s,config:o,resetGame:l},children:t})},he=()=>{const t=He(Ve);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t};function _e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function vt(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function fe(t,e,o){return e&&vt(t.prototype,e),t}function Xe(t){return+t.replace(/px/,"")}function gt(t){var e=window.devicePixelRatio,o=getComputedStyle(t),n=Xe(o.getPropertyValue("width")),i=Xe(o.getPropertyValue("height"));t.setAttribute("width",(n*e).toString()),t.setAttribute("height",(i*e).toString())}function L(t,e){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=Math.random()*(e-t)+t;return Math.floor(n*Math.pow(10,o))/Math.pow(10,o)}function Ye(t){return t[L(0,t.length)]}var pt=.00125,Ct=5e-4,wt=9e-4,yt=1e-5,bt=6,kt=80,Tt=.9,zt=1.7,Pt=.2,Lt=.6,St=.03,Nt=.07,xt=15,At=82,Et=100,Mt=250,It=40,Rt=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function Je(t){var e=1920;return Math.log(t)/Math.log(e)}var Ke=function(){function t(e){_e(this,t);var o=e.initialPosition,n=e.direction,i=e.confettiRadius,r=e.confettiColors,s=e.emojis,l=e.emojiSize,c=e.canvasWidth,a=L(Tt,zt,3),d=a*Je(c);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=L(Pt,Lt,3),this.rotationSpeed=s.length?.01:L(St,Nt,3)*Je(c),this.dragForceCoefficient=L(Ct,wt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=n==="left"?L(0,.2,3):L(-.2,0,3),this.emojiSize=l,this.emojiRotationAngle=L(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=n==="left"?L(At,xt)*Math.PI/180:L(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var _=L(-150,0),h={x:o.x+(n==="left"?-_:_)*this.absCos,y:o.y-_*this.absSin};this.currentPosition=Object.assign({},h),this.initialPosition=Object.assign({},h),this.color=s.length?null:Ye(r),this.emoji=s.length?Ye(s):null,this.createdAt=new Date().getTime(),this.direction=n}return fe(t,[{key:"draw",value:function(o){var n=this.currentPosition,i=this.radius,r=this.color,s=this.emoji,l=this.rotationAngle,c=this.emojiRotationAngle,a=this.emojiSize,d=window.devicePixelRatio;r?(o.fillStyle=r,o.beginPath(),o.ellipse(n.x*d,n.y*d,i.x*d,i.y*d,l,0,2*Math.PI),o.fill()):s&&(o.font="".concat(a,"px serif"),o.save(),o.translate(d*n.x,d*n.y),o.rotate(c),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,l=this.radiusYUpdateDirection,c=this.rotationSpeed,a=this.createdAt,d=this.direction,u=n-a;if(i.x>s&&(this.confettiSpeed.x-=r*o),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*o,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+pt*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:yt*o,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*o%(2*Math.PI);return}l==="down"?(this.radius.y-=o*c,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=o*c,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(o){return this.currentPosition.y<o+Et}}]),t}();function Ft(){var t=document.createElement("canvas");return t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.zIndex="1000",t.style.pointerEvents="none",document.body.appendChild(t),t}function $t(t){var e=t.confettiRadius,o=e===void 0?bt:e,n=t.confettiNumber,i=n===void 0?t.confettiesNumber||(t.emojis?It:Mt):n,r=t.confettiColors,s=r===void 0?Rt:r,l=t.emojis,c=l===void 0?t.emojies||[]:l,a=t.emojiSize,d=a===void 0?kt:a;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:o,confettiNumber:i,confettiColors:s,emojis:c,emojiSize:d}}var Ut=function(){function t(e){var o=this;_e(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(n){return o.resolvePromise=n})}return fe(t,[{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,l=o.currentTime;this.shapes=this.shapes.filter(function(c){return c.updatePosition(s,l),c.draw(r.canvasContext),i?c.getIsVisibleOnCanvas(n):!0})}}]),t}(),Dt=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_e(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||Ft(),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 fe(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,gt(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=$t(o),i=n.confettiRadius,r=n.confettiNumber,s=n.confettiColors,l=n.emojis,c=n.emojiSize,a=this.canvas.getBoundingClientRect(),d=a.width,u=a.height,_=u*5/7,h={x:0,y:_},v={x:d,y:_},g=new Ut(this.canvasContext),p=0;p<r/2;p++){var f=new Ke({initialPosition:h,direction:"right",confettiRadius:i,confettiColors:s,confettiNumber:r,emojis:l,emojiSize:c,canvasWidth:d}),C=new Ke({initialPosition:v,direction:"left",confettiRadius:i,confettiColors:s,confettiNumber:r,emojis:l,emojiSize:c,canvasWidth:d});g.addShapes(f,C)}return this.activeConfettiBatches.push(g),this.queueAnimationFrameIfNeeded(),g.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const Ze=Me(void 0),Ot=({children:t})=>{const[e,o]=E(null),[n,i]=E(!1),[r,s]=E("info"),[l,c]=E(null),a=Ge(()=>{i(!1),l&&(clearTimeout(l),c(null))},[l]),d=Ge((u,_="info",h=3e3)=>{if(n&&a(),o(u),s(_),i(!0),h>0){const v=setTimeout(()=>{i(!1)},h);c(v)}},[n,a]);return m(Ze.Provider,{value:{message:e,visible:n,type:r,showToast:d,hideToast:a},children:t})},me=()=>{const t=He(Ze);if(!t)throw new Error("useToast must be used within a ToastProvider");return t},jt=({i18n:t,totalTiers:e,currentTier:o,highestUnlockedTier:n,onTierChange:i,disabled:r})=>m("div",{className:"tier-selector",children:m("select",{value:o,onChange:s=>{s.target&&s.target.value&&i(Number(s.target.value))},disabled:r,className:"tier-dropdown",children:Array.from({length:e},(s,l)=>l+1).map(s=>m("option",{value:s,disabled:s>n,children:t.tier+" "+s},`tier-${s}`))})}),Gt=({i18n:t,levelsRange:e,currentLevel:o,highestUnlockedLevel:n,onLevelChange:i,disabled:r})=>{const{gameState:s}=he(),c=(([a,d])=>Array.from({length:d-a+1},(u,_)=>{const h=a+_,v=s.levelScores[h]||0;return{level:h,score:v}}))(e);return m("div",{className:"level-selector",children:m("select",{value:o,onChange:a=>{a.target&&a.target.value&&i(Number(a.target.value))},disabled:r,className:"level-dropdown",children:c.map(({level:a,score:d})=>m("option",{value:a,disabled:a>n,children:`${t.level} ${a} ${"★".repeat(d)}`},`level-${a}`))})})},ve=({isOpen:t,title:e,message:o,children:n,noConfirm:i=!1,noCancel:r=!1,confirmText:s="OK",cancelText:l="Cancel",onConfirm:c,onCancel:a})=>{const d=D(null);return P(()=>{const u=_=>{_.key==="Escape"&&a?.()};return t&&document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[t,a]),m("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:m("div",{className:"maze-dialog",ref:d,children:[m("div",{className:"maze-dialog-title",children:e}),m("div",{className:"maze-dialog-content",children:n||m("div",{className:"maze-dialog-message",children:o})}),m("div",{className:"maze-dialog-buttons",children:[!r&&m("button",{className:"maze-dialog-cancel",onClick:a,children:l}),!i&&m("button",{className:"maze-dialog-confirm",onClick:c,children:s})]})]})})};function Ht(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}const ge=[[{size:8,seed:12345,method:"backtracking",wallWidth:4},{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"}]],ee={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",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:2,wallColor:"#000000",exitColor:"#F44336",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerAtExitColor:"#FFD700"},levelConfig:ge},Wt=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6;class Bt{constructor(e,o){this.row=e,this.col=o}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class qt{rows;cols;grid;seed;random;constructor(e,o,n){this.rows=e,this.cols=o,this.seed=n??Math.floor(Math.random()*1e6),this.random=Ht(this.seed),this.grid=this.initializeGrid()}initializeGrid(){const e=[];for(let o=0;o<this.rows;o++){e[o]=[];for(let n=0;n<this.cols;n++)e[o][n]=new Bt(o,n)}return e}isValid(e,o){return e>=0&&e<this.rows&&o>=0&&o<this.cols}getNeighbors(e,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=e+r.r,l=o+r.c;this.isValid(s,l)&&n.push({row:s,col:l})}return n}getUnvisitedNeighbors(e,o){return this.getNeighbors(e,o).filter(n=>!this.grid[n.row][n.col].visited)}getVisitedNeighbors(e,o){return this.getNeighbors(e,o).filter(n=>this.grid[n.row][n.col].visited)}removeWall(e,o,n,i){const r=this.grid[e][o],s=this.grid[n][i];e===n+1?(r.walls.top=!1,s.walls.bottom=!1):e===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 Vt{maze;constructor(e,o,n,i,r={row:0,col:0},s={row:e-1,col:o-1}){switch(this.maze=new qt(e,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 e=[],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,e.push(i);e.length>0;){i=e[e.length-1];const{row:r,col:s}=i,l=this.maze.getUnvisitedNeighbors(r,s);if(l.length>0){const c=this.randomPick(l),{row:a,col:d}=c;this.maze.removeWall(r,s,a,d),this.maze.grid[a][d].visited=!0,e.push(c)}else e.pop()}}runPrims(){const e=[],o=(r,s)=>{const l=this.maze.getNeighbors(r,s);for(const c of l)!this.maze.grid[c.row][c.col].visited&&!e.some(a=>a.row===c.row&&a.col===c.col)&&e.push(c)},n=this.randomNumber(this.maze.rows),i=this.randomNumber(this.maze.cols);for(this.maze.grid[n][i].visited=!0,o(n,i);e.length>0;){const r=this.randomNumber(e.length),s=e[r],{row:l,col:c}=s,a=this.maze.getVisitedNeighbors(l,c);if(a.length>0){const d=this.randomPick(a);this.maze.removeWall(l,c,d.row,d.col),this.maze.grid[l][c].visited=!0,o(l,c)}e.splice(r,1)}}addOpenings(e,o){this.maze.grid[e.row][e.col].walls.top=!1,this.maze.grid[o.row][o.col].walls.bottom=!1}randomNumber(e){return Math.floor(this.maze.random()*e)}randomPick(e){return e[Math.floor(this.maze.random()*e.length)]}}function Xt(t,e,o,n,i,r){return new Vt(t,e,o,n,i,r).getMaze()}const Yt=(t,e,o)=>{if(!t.isValid(e,o))return!1;const n=t.grid[e][o];return!n.walls.top||!n.walls.right||!n.walls.bottom||!n.walls.left},Qe=(t,e=ge.flat())=>{const o=t-1,n=e[o];if(!n)return console.error(`Cannot find Level ${t}'s config.`),null;const i=n.size,r=i,s=i,l=n.seed,c=n.method,a=n.entry||{row:0,col:0},d=n.exit||{row:r-1,col:s-1},u=Xt(r,s,c,l,a,d),_=Wt(t),h=[];for(let v=0;v<_;v++){let g;do g={row:Math.floor(u.random()*r),col:Math.floor(u.random()*s)};while(g.row===a.row&&g.col===a.col||g.row===d.row&&g.col===d.col||!Yt(u,g.row,g.col)||h.some(p=>p.row===g.row&&p.col===g.col));h.push(g)}return{maze:u,playerPosition:a,exitPosition:d,foodPositions:h,totalFoodCount:_,foodCollected:0,playerPath:[a],visitCounts:{[`${a.row},${a.col}`]:1},moveCount:0,currentScore:0,playerAtExit:!1,isGameActive:!0,levelTransitioning:!1}},et=({gameState:t,setGameState:e,config:o})=>({generateCurrentLevelMaze:()=>{const i=Qe(t.currentLevel,o.current.levelConfig.flat());i&&e(r=>({...r,...i}))}}),tt=t=>ue(()=>{const e=t.map(l=>l.length),o=e.reduce((l,c)=>l+c,0),n=t.length,i=l=>{if(l<1||l>o)return 0;let c=0;for(let a=0;a<e.length;a++)if(c+=e[a],l<=c)return a+1;return 0},r=l=>l<1||l>n?0:e.slice(0,l-1).reduce((c,a)=>c+a,0)+1,s={getTotalLevels:()=>o,getTotalTiers:()=>n,getTierLevelsRange:l=>{if(l<1||l>n)return[0,0];const c=r(l),a=c+e[l-1]-1;return[c,a]},getTierByLevel:i,getFirstLevelOfTier:r,getLevelConfig:l=>{if(l<1||l>o)return null;const c=i(l),a=r(c),d=l-a;return t[c-1][d]},getTierConfig:l=>l<1||l>n?null:t[l-1],isLevelUnlocked:(l,c)=>l<=c,isTierUnlocked:(l,c)=>l<=c,getNextLevelInfo:l=>{if(l>=o)return null;const c=l+1,a=i(l),d=i(c);return{nextLevel:c,nextTier:d,isTierChange:d>a}},getCurrentTierProgress:(l,c)=>{const[a,d]=s.getTierLevelsRange(c),u=l-a+1,_=d-a+1;return{current:u,total:_}},isLastLevelInTier:l=>{const c=i(l),[,a]=s.getTierLevelsRange(c);return l===a},getPreviousLevelInfo:l=>{if(l<=1)return null;const c=l-1,a=i(l),d=i(c);return{prevLevel:c,prevTier:d,isTierChange:d<a}}};return s},[t]),Jt=()=>{const{gameState:t,setGameState:e,resetGame:o,config:n}=he(),i=n.current.i18n,r=n.current.levelConfig,s=tt(r),{showToast:l}=me(),{totalScore:c,showClue:a,currentTier:d,currentLevel:u,highestUnlockedTier:_,highestUnlockedLevel:h,levelTransitioning:v}=t,g=s.getTotalLevels(),p=s.getTotalTiers(),[f,C]=E(!1),[z,k]=E(!1),[M,S]=E(!1),[N,O]=E(s.getTierLevelsRange(1)),{generateCurrentLevelMaze:R}=et({gameState:t,setGameState:e,config:n});P(()=>{O(s.getTierLevelsRange(d))},[d]);const W=x=>{const te=s.getFirstLevelOfTier(x);s.isLevelUnlocked(te,h)&&(e(bo=>({...bo,currentTier:x})),T(te))},T=x=>{s.isLevelUnlocked(x,h)&&(e(te=>({...te,currentLevel:x})),R(),l(i.levelGoToast.replace("%LEVEL%",x.toString()),"success"))},F=()=>{C(!0)},mo=()=>{C(!1)},vo=()=>{S(!0)},go=()=>{S(!1)},po=()=>{e(x=>(l(x.showClue?i.cluePathDisabled:i.cluePathEnabled),{...x,showClue:!x.showClue})),S(!1)},Co=()=>{k(!0)},wo=()=>{o(),k(!1),l(i.resetDoneToast)},yo=()=>{k(!1)};return m("div",{class:"game-panel-container",children:[m("div",{className:"game-controls",children:[m("div",{className:"selectors-container",children:[m(jt,{i18n:i,totalTiers:p,currentTier:d,highestUnlockedTier:_,onTierChange:W,disabled:v}),m(Gt,{i18n:i,levelsRange:N,currentLevel:u,highestUnlockedLevel:h,onLevelChange:T,disabled:v})]}),m("button",{className:`settings-clue-button ${a?"clue-on":"clue-off"}`,disabled:a,title:"Toggle Clue",onClick:vo,children:a?i.clueOn:i.clueOff})]}),m("div",{className:"game-settings",children:m("span",{className:"game-settings-icon",onClick:F,children:"★ "+c})}),m(ve,{isOpen:f,title:i.settings,noConfirm:!0,cancelText:i.close,onCancel:mo,children:[m("div",{className:"settings-stats",children:[m("div",{children:i.levelComplete+`: ${h}/${g}`}),m("div",{children:i.starsCollected+": "+c}),m("div",{children:i.avgStarPerLevel+": "+(c/h).toFixed(2)})]}),m("div",{className:"settings-item-box",children:[m("button",{className:"settings-reset-button",title:"Reset Game",onClick:Co,children:i.reset}),m("div",{className:"settings-item-tip",children:i.resetTip})]})]}),m(ve,{isOpen:z,title:i.confirmReset,message:i.confirmResetMessage,confirmText:i.reset,cancelText:i.cancel,onConfirm:wo,onCancel:yo}),m(ve,{isOpen:M,title:i.confirmClue,message:i.confirmClueMessage,confirmText:i.confirm,cancelText:i.cancel,onConfirm:po,onCancel:go})]})},Kt=({message:t,visible:e,duration:o=2e3,onClose:n,position:i="center",type:r="info"})=>t?(P(()=>{let s;return e&&o>0&&n&&(s=setTimeout(()=>{n()},o)),()=>{s&&clearTimeout(s)}},[e,o,n]),m("div",{className:`toast-container position-${i}`,children:m("div",{className:`toast-message type-${r} ${e?"toast-visible":""}`,children:t})})):null,Zt=(t,e,o)=>{P(()=>{const n=()=>{const i=t.current;if(!i)return;const r=i.parentElement;if(!r)return;const s=r.clientWidth,l=window.devicePixelRatio||1;i.style.width=`${s}px`,i.style.height=`${s}px`,i.width=s*l,i.height=s*l,e(t,o.current)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[t])},ot={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},Qt=({containerRef:t,gameState:e,setGameState:o,onFoodCollected:n})=>{P(()=>{const i=l=>{if(!e.isGameActive||!e.maze)return;const[c,a]=ot[l],{row:d,col:u}=e.playerPosition,_=d+c,h=u+a;if(!e.maze.isValid(_,h))return;const v=e.maze.grid[d][u];if(c===-1&&v.walls.top||c===1&&v.walls.bottom||a===-1&&v.walls.left||a===1&&v.walls.right)return;const g={row:_,col:h},p=`${_},${h}`;o(f=>{const C=f.foodPositions.some(N=>N.row===_&&N.col===h);C&&n();const z=`${d},${u}-${_},${h}`,k=_===f.exitPosition.row&&h===f.exitPosition.col,M=C?f.foodCollected+1:f.foodCollected,S=M===f.totalFoodCount;return{...f,playerPosition:g,playerPath:[...f.playerPath,g],foodPositions:f.foodPositions.filter(N=>!(N.row===_&&N.col===h)),foodCollected:M,currentScore:k?[k,!f.showClue,S].filter(Boolean).length:0,visitCounts:{...f.visitCounts,[z]:(f.visitCounts[z]||0)+1,[p]:(f.visitCounts[p]||0)+1},moveCount:f.moveCount+1,playerAtExit:k,isGameActive:!k,levelTransitioning:k}})},r=l=>{if(!e.isGameActive||!e.maze)return;const c=l.key;c in ot&&(l.preventDefault(),i(c))},s=l=>{if(l.preventDefault(),!e.isGameActive||!e.maze)return;const c=l.touches[0],a=document.elementFromPoint(c.clientX,c.clientY);a&&(a.classList.contains("maze-up")?i("ArrowUp"):a.classList.contains("maze-down")?i("ArrowDown"):a.classList.contains("maze-left")?i("ArrowLeft"):a.classList.contains("maze-right")&&i("ArrowRight"))};return window.addEventListener("keydown",r),t.current?.addEventListener("touchstart",s,{passive:!1}),()=>{window.removeEventListener("keydown",r),t.current?.removeEventListener("touchstart",s)}},[e.isGameActive,e.maze,e.playerPosition,e.exitPosition])},eo=({gameState:t,setGameState:e,config:o,onLevelComplete:n,onTierUnlocked:i})=>{P(()=>{if(t.levelTransitioning){n();const l=setTimeout(()=>{s(t.currentScore,o.current.levelConfig)},1e3);return()=>clearTimeout(l)}},[t.levelTransitioning]);const r=tt(o.current.levelConfig),s=(l,c)=>{const a=r.getNextLevelInfo(t.currentLevel);if(!a)return;const{nextLevel:d,nextTier:u,isTierChange:_}=a,h=Qe(d,c.flat());h&&e(v=>{_&&i(u);const g={...v.levelScores};return g[v.currentLevel]=Math.max(l,g[v.currentLevel]||0),{...v,...h,currentLevel:d,currentTier:u,highestUnlockedLevel:Math.max(v.highestUnlockedLevel,d),highestUnlockedTier:Math.max(v.highestUnlockedTier,u),levelScores:g,totalScore:Object.values(g).reduce((p,f)=>p+f,0),showClue:!1,isGameActive:!0,levelTransitioning:!1}})};return{handleLevelComplete:s}};function to(t,e){const{ctx:o,width:n,height:i,maze:r}=t;e.playerColor=t.playerAtExit?e.playerAtExitColor:e.playerColor;const{padding:s,wallWidth:l,wallColor:c,playerColor:a,exitColor:d,foodColor:u,clueColor:_,backgroundColor:h}=e,v=r.cols,g=r.rows,p=(n-s*2)/v,f=(i-s*2)/g;o.clearRect(0,0,n,i),o.save(),o.fillStyle=h,o.fillRect(0,0,n,i),o.restore(),t.showClue&&t.playerPath&&t.playerPath.length>0&&lo(t,{cellWidth:p,cellHeight:f,padding:s,clueColor:_}),oo(t,{cellWidth:p,cellHeight:f,padding:s,wallColor:c,wallWidth:l}),ro(t,{cellWidth:p,cellHeight:f,padding:s,foodColor:u}),t.playerAtExit||io(t,{cellWidth:p,cellHeight:f,padding:s,exitColor:d}),no(t,{cellWidth:p,cellHeight:f,padding:s,playerColor:a})}function oo(t,e){const{ctx:o,maze:n}=t,{cellWidth:i,cellHeight:r,padding:s,wallColor:l,wallWidth:c}=e;o.save(),o.strokeStyle=l,o.lineWidth=c,o.lineCap="round",o.beginPath();for(let a=0;a<n.rows;a++)for(let d=0;d<n.cols;d++){const u=n.grid[a][d],_=s+d*i,h=s+a*r;u.walls.top&&(o.moveTo(_,h),o.lineTo(_+i,h)),u.walls.right&&(o.moveTo(_+i,h),o.lineTo(_+i,h+r)),u.walls.bottom&&(o.moveTo(_+i,h+r),o.lineTo(_,h+r)),u.walls.left&&(o.moveTo(_,h+r),o.lineTo(_,h))}o.stroke(),o.restore()}function no(t,e){const{ctx:o,playerPosition:n}=t,{cellWidth:i,cellHeight:r,padding:s,playerColor:l}=e,{x:c,y:a}=H(n.row,n.col,i,r,s),d=Math.min(i,r)*.35;o.save(),o.fillStyle=l,o.beginPath(),o.arc(c,a,d,0,Math.PI*2),o.fill(),o.restore()}function io(t,e){const{ctx:o,exitPosition:n}=t,{cellWidth:i,cellHeight:r,padding:s,exitColor:l}=e,{x:c,y:a}=H(n.row,n.col,i,r,s),d=Math.min(i,r)*.35;o.save(),o.fillStyle=l,o.beginPath(),o.arc(c,a,d,0,Math.PI*2),o.fill(),o.restore()}function ro(t,e){const{ctx:o,foodPositions:n}=t,{cellWidth:i,cellHeight:r,padding:s,foodColor:l}=e;o.fillStyle=l;const c=Math.min(i,r)*.25;n.forEach(a=>{const{x:d,y:u}=H(a.row,a.col,i,r,s);so(o,d,u,c*1.2,5,c*.6)})}function so(t,e,o,n,i,r){t.save(),t.beginPath();for(let s=0;s<i*2;s++){const l=s%2===0?n:r,c=Math.PI*s/i;t.lineTo(e+l*Math.sin(c),o+l*Math.cos(c))}t.closePath(),t.fill(),t.restore()}function lo(t,e){const{ctx:o,playerPath:n,visitCounts:i}=t,{cellWidth:r,cellHeight:s,padding:l,clueColor:c}=e;if(!(!n||n.length<2||!i)){o.save();for(let a=1;a<n.length;a++){const d=n[a-1],u=n[a],_=`${d.row},${d.col}-${u.row},${u.col}`,h=`${u.row},${u.col}-${d.row},${d.col}`,v=(i[_]||0)+(i[h]||0),g=Math.min(.2+v*.1,.9),p=Math.max(3,r*.1)+v*.5;try{o.strokeStyle=c.replace(")",`, ${g})`).replace("rgb(","rgba(")}catch{o.strokeStyle=`rgba(255, 0, 0, ${g})`}o.lineWidth=p,o.lineCap="round",o.lineJoin="round";const{x:f,y:C}=H(d.row,d.col,r,s,l),{x:z,y:k}=H(u.row,u.col,r,s,l);o.beginPath(),o.moveTo(f,C),o.lineTo(z,k),o.stroke()}o.restore()}}function H(t,e,o,n,i){return{x:i+e*o+o/2,y:i+t*n+n/2}}const ao=new Dt,co=()=>{const{message:t,visible:e,type:o,hideToast:n}=me();return m(Kt,{message:t,visible:e,type:o,onClose:n,position:"top"})},uo=()=>{const{gameState:t,setGameState:e,config:o}=he(),n=D(null),i=D(null),r=D(t),s=o.current.i18n,{showToast:l}=me(),c=D(!1);P(()=>{r.current=t},[t]);const a=()=>{const _=t.totalFoodCount-t.foodCollected-1;if(_>0){l(s.foodCollectedToast.replace("%NUM%",_.toString()),"success");return}l(s.allFoodCollectedToast,"success")},d=(_,h)=>{const v=_.current?.getContext("2d");if(!v||!h.maze||c.current)return;c.current=!0;const g={...o.current.renderConfig||{}},f=o.current.levelConfig.flat()[h.currentLevel-1];g.wallWidth=f.wallWidth||g.wallWidth,to({ctx:v,width:_.current.width,height:_.current.height,maze:h.maze,playerPosition:h.playerPosition,exitPosition:h.exitPosition,foodPositions:h.foodPositions,showClue:h.showClue,playerPath:h.playerPath,visitCounts:h.visitCounts,playerAtExit:h.playerAtExit},g),requestAnimationFrame(()=>{c.current=!1})};P(()=>{l(s.useArrowKeyTips,"info",3e3)},[]),Zt(i,d,r);const{generateCurrentLevelMaze:u}=et({gameState:t,setGameState:e,config:o});return Qt({containerRef:n,gameState:t,setGameState:e,onFoodCollected:a}),eo({gameState:t,setGameState:e,config:o,onLevelComplete:()=>{ao.addConfetti(),l(s.levelCompleteToast,"success")},onTierUnlocked:_=>{l(s.tierUnlockedToast.replace("%TIER%",_.toString()),"success")}}),P(()=>{t.isGameActive&&!t.levelTransitioning&&u()},[t.currentLevel,t.isGameActive,t.levelTransitioning]),P(()=>{i.current&&t.maze&&d(i,t)},[t.maze,t.playerPosition,t.exitPosition,t.foodPositions,t.showClue,t.playerPath,t.visitCounts,t.playerAtExit]),m("div",{className:"maze-game-container",children:[m(co,{}),m(Jt,{}),m("div",{className:"maze-canvas-container",ref:n,children:[m("canvas",{ref:i,className:"maze-game-canvas"}),m("div",{className:"maze-touch-area maze-up"}),m("div",{className:"maze-touch-area maze-down"}),m("div",{className:"maze-touch-area maze-left"}),m("div",{className:"maze-touch-area maze-right"})]})]})};function ho(){return m(Ot,{children:m(uo,{})})}function _o({config:t={}}){const e={...ee.i18n,...t.i18n||{}},o={...ee.renderConfig,...t.renderConfig||{}},n=t.levelConfig||ge;return t={...ee,...t,i18n:e,levelConfig:n,renderConfig:o},m(mt,{config:t,children:m(ho,{})})}const fo={root:"https://unpkg.com/@roudanio/maze@0.0.8/dist/",...ee};return`${JSON.stringify(fo,null,2)}`,{async init(t,e){const o=typeof t=="string"?document.querySelector(t):t;if(!o){console.warn("Cannot find the root element");const c=document.createElement("div");c.style.textAlign="center",c.style.padding="20px",c.innerHTML="Cannot find the root element",document.body.append(c);return}let{root:n=location.origin}=e;n.at(-1)!=="/"&&(n+="/");const i=document.createElement("div"),r=document.createElement("div");i.style.cssText=`
|
|
1
|
+
var Maze=function(){"use strict";var q,w,pe,R,Ce,we,ye,be,ie,re,se,ke,G={},Te=[],nt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function I(t,e){for(var o in e)t[o]=e[o];return t}function le(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function it(t,e,o){var n,i,r,s={};for(r in e)r=="key"?n=e[r]:r=="ref"?i=e[r]:s[r]=e[r];if(arguments.length>2&&(s.children=arguments.length>3?q.call(arguments,2):o),typeof t=="function"&&t.defaultProps!=null)for(r in t.defaultProps)s[r]==null&&(s[r]=t.defaultProps[r]);return Y(t,s,n,i,null)}function Y(t,e,o,n,i){var r={type:t,props:e,key:o,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++pe,__i:-1,__u:0};return i==null&&w.vnode!=null&&w.vnode(r),r}function X(t){return t.children}function J(t,e){this.props=t,this.context=e}function O(t,e){if(e==null)return t.__?O(t.__,t.__i+1):null;for(var o;e<t.__k.length;e++)if((o=t.__k[e])!=null&&o.__e!=null)return o.__e;return typeof t.type=="function"?O(t):null}function ze(t){var e,o;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((o=t.__k[e])!=null&&o.__e!=null){t.__e=t.__c.base=o.__e;break}return ze(t)}}function ae(t){(!t.__d&&(t.__d=!0)&&R.push(t)&&!K.__r++||Ce!=w.debounceRendering)&&((Ce=w.debounceRendering)||we)(K)}function K(){for(var t,e,o,n,i,r,s,l=1;R.length;)R.length>l&&R.sort(ye),t=R.shift(),l=R.length,t.__d&&(o=void 0,i=(n=(e=t).__v).__e,r=[],s=[],e.__P&&((o=I({},n)).__v=n.__v+1,w.vnode&&w.vnode(o),ce(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[i]:null,r,i??O(n),!!(32&n.__u),s),o.__v=n.__v,o.__.__k[o.__i]=o,xe(r,o,s),o.__e!=i&&ze(o)));K.__r=0}function Le(t,e,o,n,i,r,s,l,c,a,d){var u,_,h,v,g,p,m=n&&n.__k||Te,C=e.length;for(c=rt(o,e,m,c,C),u=0;u<C;u++)(h=o.__k[u])!=null&&(_=h.__i==-1?G:m[h.__i]||G,h.__i=u,p=ce(t,h,_,i,r,s,l,c,a,d),v=h.__e,h.ref&&_.ref!=h.ref&&(_.ref&&ue(_.ref,null,h),d.push(h.ref,h.__c||v,h)),g==null&&v!=null&&(g=v),4&h.__u||_.__k===h.__k?c=Pe(h,c,t):typeof h.type=="function"&&p!==void 0?c=p:v&&(c=v.nextSibling),h.__u&=-7);return o.__e=g,c}function rt(t,e,o,n,i){var r,s,l,c,a,d=o.length,u=d,_=0;for(t.__k=new Array(i),r=0;r<i;r++)(s=e[r])!=null&&typeof s!="boolean"&&typeof s!="function"?(c=r+_,(s=t.__k[r]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?Y(null,s,null,null,null):V(s)?Y(X,{children:s},null,null,null):s.constructor==null&&s.__b>0?Y(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,l=null,(a=s.__i=st(s,o,c,u))!=-1&&(u--,(l=o[a])&&(l.__u|=2)),l==null||l.__v==null?(a==-1&&(i>d?_--:i<d&&_++),typeof s.type!="function"&&(s.__u|=4)):a!=c&&(a==c-1?_--:a==c+1?_++:(a>c?_--:_++,s.__u|=4))):t.__k[r]=null;if(u)for(r=0;r<d;r++)(l=o[r])!=null&&(2&l.__u)==0&&(l.__e==n&&(n=O(l)),Ee(l,l));return n}function Pe(t,e,o){var n,i;if(typeof t.type=="function"){for(n=t.__k,i=0;n&&i<n.length;i++)n[i]&&(n[i].__=t,e=Pe(n[i],e,o));return e}t.__e!=e&&(e&&t.type&&!o.contains(e)&&(e=O(t)),o.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function st(t,e,o,n){var i,r,s=t.key,l=t.type,c=e[o];if(c===null&&t.key==null||c&&s==c.key&&l==c.type&&(2&c.__u)==0)return o;if(n>(c!=null&&(2&c.__u)==0?1:0))for(i=o-1,r=o+1;i>=0||r<e.length;){if(i>=0){if((c=e[i])&&(2&c.__u)==0&&s==c.key&&l==c.type)return i;i--}if(r<e.length){if((c=e[r])&&(2&c.__u)==0&&s==c.key&&l==c.type)return r;r++}}return-1}function Se(t,e,o){e[0]=="-"?t.setProperty(e,o??""):t[e]=o==null?"":typeof o!="number"||nt.test(e)?o:o+"px"}function Z(t,e,o,n,i){var r;e:if(e=="style")if(typeof o=="string")t.style.cssText=o;else{if(typeof n=="string"&&(t.style.cssText=n=""),n)for(e in n)o&&e in o||Se(t.style,e,"");if(o)for(e in o)n&&o[e]==n[e]||Se(t.style,e,o[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(be,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+r]=o,o?n?o.u=n.u:(o.u=ie,t.addEventListener(e,r?se:re,r)):t.removeEventListener(e,r?se:re,r);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=o??"";break e}catch{}typeof o=="function"||(o==null||o===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&o==1?"":o))}}function Ne(t){return function(e){if(this.l){var o=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<o.u)return;return o(w.event?w.event(e):e)}}}function ce(t,e,o,n,i,r,s,l,c,a){var d,u,_,h,v,g,p,m,C,P,k,A,b,T,F,E,j,L=e.type;if(e.constructor!=null)return null;128&o.__u&&(c=!!(32&o.__u),r=[l=e.__e=o.__e]),(d=w.__b)&&d(e);e:if(typeof L=="function")try{if(m=e.props,C="prototype"in L&&L.prototype.render,P=(d=L.contextType)&&n[d.__c],k=d?P?P.props.value:d.__:n,o.__c?p=(u=e.__c=o.__c).__=u.__E:(C?e.__c=u=new L(m,k):(e.__c=u=new J(m,k),u.constructor=L,u.render=at),P&&P.sub(u),u.props=m,u.state||(u.state={}),u.context=k,u.__n=n,_=u.__d=!0,u.__h=[],u._sb=[]),C&&u.__s==null&&(u.__s=u.state),C&&L.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=I({},u.__s)),I(u.__s,L.getDerivedStateFromProps(m,u.__s))),h=u.props,v=u.state,u.__v=e,_)C&&L.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),C&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(C&&L.getDerivedStateFromProps==null&&m!==h&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(m,k),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(m,u.__s,k)===!1||e.__v==o.__v){for(e.__v!=o.__v&&(u.props=m,u.state=u.__s,u.__d=!1),e.__e=o.__e,e.__k=o.__k,e.__k.some(function($){$&&($.__=e)}),A=0;A<u._sb.length;A++)u.__h.push(u._sb[A]);u._sb=[],u.__h.length&&s.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(m,u.__s,k),C&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(h,v,g)})}if(u.context=k,u.props=m,u.__P=t,u.__e=!1,b=w.__r,T=0,C){for(u.state=u.__s,u.__d=!1,b&&b(e),d=u.render(u.props,u.state,u.context),F=0;F<u._sb.length;F++)u.__h.push(u._sb[F]);u._sb=[]}else do u.__d=!1,b&&b(e),d=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++T<25);u.state=u.__s,u.getChildContext!=null&&(n=I(I({},n),u.getChildContext())),C&&!_&&u.getSnapshotBeforeUpdate!=null&&(g=u.getSnapshotBeforeUpdate(h,v)),E=d,d!=null&&d.type===X&&d.key==null&&(E=Ae(d.props.children)),l=Le(t,V(E)?E:[E],e,o,n,i,r,s,l,c,a),u.base=e.__e,e.__u&=-161,u.__h.length&&s.push(u),p&&(u.__E=u.__=null)}catch($){if(e.__v=null,c||r!=null)if($.then){for(e.__u|=c?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;r[r.indexOf(l)]=null,e.__e=l}else for(j=r.length;j--;)le(r[j]);else e.__e=o.__e,e.__k=o.__k;w.__e($,e,o)}else r==null&&e.__v==o.__v?(e.__k=o.__k,e.__e=o.__e):l=e.__e=lt(o.__e,e,o,n,i,r,s,c,a);return(d=w.diffed)&&d(e),128&e.__u?void 0:l}function xe(t,e,o){for(var n=0;n<o.length;n++)ue(o[n],o[++n],o[++n]);w.__c&&w.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(r){r.call(i)})}catch(r){w.__e(r,i.__v)}})}function Ae(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:V(t)?t.map(Ae):I({},t)}function lt(t,e,o,n,i,r,s,l,c){var a,d,u,_,h,v,g,p=o.props,m=e.props,C=e.type;if(C=="svg"?i="http://www.w3.org/2000/svg":C=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),r!=null){for(a=0;a<r.length;a++)if((h=r[a])&&"setAttribute"in h==!!C&&(C?h.localName==C:h.nodeType==3)){t=h,r[a]=null;break}}if(t==null){if(C==null)return document.createTextNode(m);t=document.createElementNS(i,C,m.is&&m),l&&(w.__m&&w.__m(e,r),l=!1),r=null}if(C==null)p===m||l&&t.data==m||(t.data=m);else{if(r=r&&q.call(t.childNodes),p=o.props||G,!l&&r!=null)for(p={},a=0;a<t.attributes.length;a++)p[(h=t.attributes[a]).name]=h.value;for(a in p)if(h=p[a],a!="children"){if(a=="dangerouslySetInnerHTML")u=h;else if(!(a in m)){if(a=="value"&&"defaultValue"in m||a=="checked"&&"defaultChecked"in m)continue;Z(t,a,null,h,i)}}for(a in m)h=m[a],a=="children"?_=h:a=="dangerouslySetInnerHTML"?d=h:a=="value"?v=h:a=="checked"?g=h:l&&typeof h!="function"||p[a]===h||Z(t,a,h,p[a],i);if(d)l||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),Le(e.type=="template"?t.content:t,V(_)?_:[_],e,o,n,C=="foreignObject"?"http://www.w3.org/1999/xhtml":i,r,s,r?r[0]:o.__k&&O(o,0),l,c),r!=null)for(a=r.length;a--;)le(r[a]);l||(a="value",C=="progress"&&v==null?t.removeAttribute("value"):v!=null&&(v!==t[a]||C=="progress"&&!v||C=="option"&&v!=p[a])&&Z(t,a,v,p[a],i),a="checked",g!=null&&g!=t[a]&&Z(t,a,g,p[a],i))}return t}function ue(t,e,o){try{if(typeof t=="function"){var n=typeof t.__u=="function";n&&t.__u(),n&&e==null||(t.__u=t(e))}else t.current=e}catch(i){w.__e(i,o)}}function Ee(t,e,o){var n,i;if(w.unmount&&w.unmount(t),(n=t.ref)&&(n.current&&n.current!=t.__e||ue(n,null,e)),(n=t.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(r){w.__e(r,e)}n.base=n.__P=null}if(n=t.__k)for(i=0;i<n.length;i++)n[i]&&Ee(n[i],e,o||typeof t.type!="function");o||le(t.__e),t.__c=t.__=t.__e=void 0}function at(t,e,o){return this.constructor(t,o)}function ct(t,e,o){var n,i,r,s;e==document&&(e=document.documentElement),w.__&&w.__(t,e),i=(n=!1)?null:e.__k,r=[],s=[],ce(e,t=e.__k=it(X,null,[t]),i||G,G,e.namespaceURI,i?null:e.firstChild?q.call(e.childNodes):null,r,i?i.__e:e.firstChild,n,s),xe(r,t,s)}function Me(t){function e(o){var n,i;return this.getChildContext||(n=new Set,(i={})[e.__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,ae(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 e.__c="__cC"+ke++,e.__=t,e.Provider=e.__l=(e.Consumer=function(o,n){return o.children(n)}).contextType=e,e}q=Te.slice,w={__e:function(t,e,o,n){for(var i,r,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((r=i.constructor)&&r.getDerivedStateFromError!=null&&(i.setState(r.getDerivedStateFromError(t)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,n||{}),s=i.__d),s)return i.__E=i}catch(l){t=l}throw t}},pe=0,J.prototype.setState=function(t,e){var o;o=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=I({},this.state),typeof t=="function"&&(t=t(I({},o),this.props)),t&&I(o,t),t!=null&&this.__v&&(e&&this._sb.push(e),ae(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ae(this))},J.prototype.render=X,R=[],we=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ye=function(t,e){return t.__v.__b-e.__v.__b},K.__r=0,be=/(PointerCapture)$|Capture$/i,ie=0,re=Ne(!1),se=Ne(!0),ke=0;var ut=0;function f(t,e,o,n,i,r){e||(e={});var s,l,c=e;if("ref"in c)for(l in c={},e)l=="ref"?s=e[l]:c[l]=e[l];var a={type:t,props:c,key:o,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ut,__i:-1,__u:0,__source:i,__self:r};if(typeof t=="function"&&(s=t.defaultProps))for(l in s)c[l]===void 0&&(c[l]=s[l]);return w.vnode&&w.vnode(a),a}var U,y,de,Ie,H=0,Fe=[],z=w,Re=z.__b,$e=z.__r,Oe=z.diffed,Ue=z.__c,De=z.unmount,je=z.__;function Q(t,e){z.__h&&z.__h(y,t,H||e),H=0;var o=y.__H||(y.__H={__:[],__h:[]});return t>=o.__.length&&o.__.push({}),o.__[t]}function M(t){return H=1,dt(qe,t)}function dt(t,e,o){var n=Q(U++,2);if(n.t=t,!n.__c&&(n.__=[qe(void 0,e),function(l){var c=n.__N?n.__N[0]:n.__[0],a=n.t(c,l);c!==a&&(n.__N=[a,n.__[1]],n.__c.setState({}))}],n.__c=y,!y.__f)){var i=function(l,c,a){if(!n.__c.__H)return!0;var d=n.__c.__H.__.filter(function(_){return!!_.__c});if(d.every(function(_){return!_.__N}))return!r||r.call(this,l,c,a);var u=n.__c.props!==l;return d.forEach(function(_){if(_.__N){var h=_.__[0];_.__=_.__N,_.__N=void 0,h!==_.__[0]&&(u=!0)}}),r&&r.call(this,l,c,a)||u};y.__f=!0;var r=y.shouldComponentUpdate,s=y.componentWillUpdate;y.componentWillUpdate=function(l,c,a){if(this.__e){var d=r;r=void 0,i(l,c,a),r=d}s&&s.call(this,l,c,a)},y.shouldComponentUpdate=i}return n.__N||n.__}function N(t,e){var o=Q(U++,3);!z.__s&&Be(o.__H,e)&&(o.__=t,o.u=e,y.__H.__h.push(o))}function D(t){return H=5,W(function(){return{current:t}},[])}function W(t,e){var o=Q(U++,7);return Be(o.__H,e)&&(o.__=t(),o.__H=e,o.__h=t),o.__}function Ge(t,e){return H=8,W(function(){return t},e)}function He(t){var e=y.context[t.__c],o=Q(U++,9);return o.c=t,e?(o.__==null&&(o.__=!0,e.sub(y)),e.props.value):t.__}function ht(){for(var t;t=Fe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(he),t.__H.__h=[]}catch(e){t.__H.__h=[],z.__e(e,t.__v)}}z.__b=function(t){y=null,Re&&Re(t)},z.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},z.__r=function(t){$e&&$e(t),U=0;var e=(y=t.__c).__H;e&&(de===y?(e.__h=[],y.__h=[],e.__.forEach(function(o){o.__N&&(o.__=o.__N),o.u=o.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(he),e.__h=[],U=0)),de=y},z.diffed=function(t){Oe&&Oe(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Fe.push(e)!==1&&Ie===z.requestAnimationFrame||((Ie=z.requestAnimationFrame)||_t)(ht)),e.__H.__.forEach(function(o){o.u&&(o.__H=o.u),o.u=void 0})),de=y=null},z.__c=function(t,e){e.some(function(o){try{o.__h.forEach(ee),o.__h=o.__h.filter(function(n){return!n.__||he(n)})}catch(n){e.some(function(i){i.__h&&(i.__h=[])}),e=[],z.__e(n,o.__v)}}),Ue&&Ue(t,e)},z.unmount=function(t){De&&De(t);var e,o=t.__c;o&&o.__H&&(o.__H.__.forEach(function(n){try{ee(n)}catch(i){e=i}}),o.__H=void 0,e&&z.__e(e,o.__v))};var We=typeof requestAnimationFrame=="function";function _t(t){var e,o=function(){clearTimeout(n),We&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(o,100);We&&(e=requestAnimationFrame(o))}function ee(t){var e=y,o=t.__c;typeof o=="function"&&(t.__c=void 0,o()),y=e}function he(t){var e=y;t.__c=t.__(),y=e}function Be(t,e){return!t||t.length!==e.length||e.some(function(o,n){return o!==t[n]})}function qe(t,e){return typeof e=="function"?e(t):e}const ft=t=>({saveGameData(e){try{const o={highestUnlockedLevel:e.highestUnlockedLevel,levelScores:e.levelScores,totalScore:e.totalScore,currentLevel:e.currentLevel};localStorage.setItem(t,JSON.stringify(o))}catch(o){console.error("Failed to save maze game data:",o)}},loadGameData(){try{const e=localStorage.getItem(t);if(!e)return null;const o=JSON.parse(e);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(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset game state:",e)}}}),Ve=Me(void 0),mt=({children:t,config:e})=>{const o=ft(e.lcPrefix+"score"),n=o.loadGameData(),[i,r]=M({currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:{atExit:!1,allFood:!1,noClue:!0},totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,maze:null,playerPosition:{row:0,col:0},exitPosition:{row:0,col:0},foodPositions:[],playerPath:[],visitCounts:{},playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,...n||{}});N(()=>{o.saveGameData(i)},[i.highestUnlockedLevel,i.levelScores,i.totalScore,i.currentLevel]);const s=()=>{o.resetGameData(),r(l=>({...l,currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,currentScore:{atExit:!1,allFood:!1,noClue:!0},totalScore:0,levelScores:{},isGameActive:!0,levelTransitioning:!1,playerPath:[],visitCounts:{},foodCollected:0,showClue:!1}))};return f(Ve.Provider,{value:{gameState:i,setGameState:r,config:e,resetGame:s},children:t})},_e=()=>{const t=He(Ve);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t};function fe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function vt(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function me(t,e,o){return e&&vt(t.prototype,e),t}function Ye(t){return+t.replace(/px/,"")}function gt(t){var e=window.devicePixelRatio,o=getComputedStyle(t),n=Ye(o.getPropertyValue("width")),i=Ye(o.getPropertyValue("height"));t.setAttribute("width",(n*e).toString()),t.setAttribute("height",(i*e).toString())}function x(t,e){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=Math.random()*(e-t)+t;return Math.floor(n*Math.pow(10,o))/Math.pow(10,o)}function Xe(t){return t[x(0,t.length)]}var pt=.00125,Ct=5e-4,wt=9e-4,yt=1e-5,bt=6,kt=80,Tt=.9,zt=1.7,Lt=.2,Pt=.6,St=.03,Nt=.07,xt=15,At=82,Et=100,Mt=250,It=40,Ft=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function Je(t){var e=1920;return Math.log(t)/Math.log(e)}var Ke=function(){function t(e){fe(this,t);var o=e.initialPosition,n=e.direction,i=e.confettiRadius,r=e.confettiColors,s=e.emojis,l=e.emojiSize,c=e.canvasWidth,a=x(Tt,zt,3),d=a*Je(c);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=x(Lt,Pt,3),this.rotationSpeed=s.length?.01:x(St,Nt,3)*Je(c),this.dragForceCoefficient=x(Ct,wt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=n==="left"?x(0,.2,3):x(-.2,0,3),this.emojiSize=l,this.emojiRotationAngle=x(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=n==="left"?x(At,xt)*Math.PI/180:x(-15,-82)*Math.PI/180;this.absCos=Math.abs(Math.cos(u)),this.absSin=Math.abs(Math.sin(u));var _=x(-150,0),h={x:o.x+(n==="left"?-_:_)*this.absCos,y:o.y-_*this.absSin};this.currentPosition=Object.assign({},h),this.initialPosition=Object.assign({},h),this.color=s.length?null:Xe(r),this.emoji=s.length?Xe(s):null,this.createdAt=new Date().getTime(),this.direction=n}return me(t,[{key:"draw",value:function(o){var n=this.currentPosition,i=this.radius,r=this.color,s=this.emoji,l=this.rotationAngle,c=this.emojiRotationAngle,a=this.emojiSize,d=window.devicePixelRatio;r?(o.fillStyle=r,o.beginPath(),o.ellipse(n.x*d,n.y*d,i.x*d,i.y*d,l,0,2*Math.PI),o.fill()):s&&(o.font="".concat(a,"px serif"),o.save(),o.translate(d*n.x,d*n.y),o.rotate(c),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,l=this.radiusYUpdateDirection,c=this.rotationSpeed,a=this.createdAt,d=this.direction,u=n-a;if(i.x>s&&(this.confettiSpeed.x-=r*o),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*o,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+pt*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:yt*o,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*o%(2*Math.PI);return}l==="down"?(this.radius.y-=o*c,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=o*c,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(o){return this.currentPosition.y<o+Et}}]),t}();function Rt(){var t=document.createElement("canvas");return t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.zIndex="1000",t.style.pointerEvents="none",document.body.appendChild(t),t}function $t(t){var e=t.confettiRadius,o=e===void 0?bt:e,n=t.confettiNumber,i=n===void 0?t.confettiesNumber||(t.emojis?It:Mt):n,r=t.confettiColors,s=r===void 0?Ft:r,l=t.emojis,c=l===void 0?t.emojies||[]:l,a=t.emojiSize,d=a===void 0?kt:a;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:o,confettiNumber:i,confettiColors:s,emojis:c,emojiSize:d}}var Ot=function(){function t(e){var o=this;fe(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(n){return o.resolvePromise=n})}return me(t,[{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,l=o.currentTime;this.shapes=this.shapes.filter(function(c){return c.updatePosition(s,l),c.draw(r.canvasContext),i?c.getIsVisibleOnCanvas(n):!0})}}]),t}(),Ut=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};fe(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||Rt(),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 me(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,gt(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=$t(o),i=n.confettiRadius,r=n.confettiNumber,s=n.confettiColors,l=n.emojis,c=n.emojiSize,a=this.canvas.getBoundingClientRect(),d=a.width,u=a.height,_=u*5/7,h={x:0,y:_},v={x:d,y:_},g=new Ot(this.canvasContext),p=0;p<r/2;p++){var m=new Ke({initialPosition:h,direction:"right",confettiRadius:i,confettiColors:s,confettiNumber:r,emojis:l,emojiSize:c,canvasWidth:d}),C=new Ke({initialPosition:v,direction:"left",confettiRadius:i,confettiColors:s,confettiNumber:r,emojis:l,emojiSize:c,canvasWidth:d});g.addShapes(m,C)}return this.activeConfettiBatches.push(g),this.queueAnimationFrameIfNeeded(),g.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const Ze=Me(void 0),Dt=({children:t})=>{const[e,o]=M(null),[n,i]=M(!1),[r,s]=M("info"),[l,c]=M(null),a=Ge(()=>{i(!1),l&&(clearTimeout(l),c(null))},[l]),d=Ge((u,_="info",h=3e3)=>{if(n&&a(),o(u),s(_),i(!0),h>0){const v=setTimeout(()=>{i(!1)},h);c(v)}},[n,a]);return f(Ze.Provider,{value:{message:e,visible:n,type:r,showToast:d,hideToast:a},children:t})},ve=()=>{const t=He(Ze);if(!t)throw new Error("useToast must be used within a ToastProvider");return t},jt=({i18n:t,totalTiers:e,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:e},(s,l)=>l+1).map(s=>f("option",{value:s,disabled:s>n,children:t.tier+" "+s},`tier-${s}`))})}),Gt=({i18n:t,levelsRange:e,currentLevel:o,highestUnlockedLevel:n,onLevelChange:i,disabled:r})=>{const{gameState:s}=_e(),c=(([a,d])=>Array.from({length:d-a+1},(u,_)=>{const h=a+_,v=s.levelScores[h]||0;return{level:h,score:v}}))(e);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:c.map(({level:a,score:d})=>f("option",{value:a,disabled:a>n,children:`${t.level} ${a} ${"★".repeat(d)}`},`level-${a}`))})})},te=({isOpen:t,title:e,className:o="",message:n,children:i,noConfirm:r=!1,noCancel:s=!1,confirmText:l="OK",cancelText:c="Cancel",onConfirm:a,onCancel:d})=>{const u=D(null);return N(()=>{const _=h=>{h.key==="Escape"&&d?.()};return t&&document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[t,d]),f("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:f("div",{className:"maze-dialog "+o,ref:u,children:[f("div",{className:"maze-dialog-title",children:e}),f("div",{className:"maze-dialog-content",children:i||f("div",{className:"maze-dialog-message",children:n})}),(!s||!r)&&f("div",{className:"maze-dialog-buttons",children:[!s&&f("button",{type:"button",className:"maze-dialog-cancel",onClick:d,children:c}),!r&&f("button",{type:"button",className:"maze-dialog-confirm",onClick:a,children:l})]})]})})};function Ht(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}const ge=[[{size:8,seed:12345,method:"backtracking",wallWidth:4},{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"}]],oe={lcPrefix:"maze-",i18n:{reset:"Reset",resetTip:"Reset all game data and highest score.",confirmReset:"Confirm Reset",confirmResetMessage:"Are you sure you want to reset the game? All progress will be lost.",cancel:"Cancel",close:"Close",confirm:"Confirm",resetDoneToast:"Game reset! Starting from Level 1...",confirmClue:"Confirm to turn on clue?",confirmClueMessage:"Are you sure you want to turn on clue? Your will lose 1 ★.",level:"Level",tier:"Tier",settings:"Settings",clueOn:"Clue: ON",clueOff:"Clue: OFF",foodCollectedToast:"Food collected! %NUM% remaining.",allFoodCollectedToast:"All food collected! Head to the exit.",congratulations:"Congratulations!",findYourExit:"Find your exit!",withoutClue:"Without clue!",withClue:"You used the clue!",collectAllStars:"Collect all stars!",notCollectAllStars:"Not collect all stars.",nextLevel:"Next Level ➤",retry:"Retry",levelComplete:"Level Complete",starsCollected:"Stars Collected",avgStarPerLevel:"Avg. Stars per Level",levelCompleteToast:"Level completed! 🎉",tierUnlockedToast:"Tier %TIER% unlocked! 🎉",levelGoToast:"Level %LEVEL% - Go!",levelRestartToast:"Level restarted",allLevelsCompleted:"You completed all levels!",continueMessage:"You haven't collected all stars. You can click 'Continue' button to collect all stars.",continue:"Continue",cluePathEnabled:"Clue Path Enabled",cluePathDisabled:"Clue Path Disabled",useArrowKeyTips:"Use arrow keys to navigate the maze. Press'C' to toggle path clue."},renderConfig:{padding:10,wallWidth:2,wallColor:"#000000",exitColor:"#F44336",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerAtExitColor:"#FFD700"},levelConfig:ge},Wt=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6;class Bt{constructor(e,o){this.row=e,this.col=o}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class qt{rows;cols;grid;seed;random;constructor(e,o,n){this.rows=e,this.cols=o,this.seed=n??Math.floor(Math.random()*1e6),this.random=Ht(this.seed),this.grid=this.initializeGrid()}initializeGrid(){const e=[];for(let o=0;o<this.rows;o++){e[o]=[];for(let n=0;n<this.cols;n++)e[o][n]=new Bt(o,n)}return e}isValid(e,o){return e>=0&&e<this.rows&&o>=0&&o<this.cols}getNeighbors(e,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=e+r.r,l=o+r.c;this.isValid(s,l)&&n.push({row:s,col:l})}return n}getUnvisitedNeighbors(e,o){return this.getNeighbors(e,o).filter(n=>!this.grid[n.row][n.col].visited)}getVisitedNeighbors(e,o){return this.getNeighbors(e,o).filter(n=>this.grid[n.row][n.col].visited)}removeWall(e,o,n,i){const r=this.grid[e][o],s=this.grid[n][i];e===n+1?(r.walls.top=!1,s.walls.bottom=!1):e===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 Vt{maze;constructor(e,o,n,i,r={row:0,col:0},s={row:e-1,col:o-1}){switch(this.maze=new qt(e,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 e=[],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,e.push(i);e.length>0;){i=e[e.length-1];const{row:r,col:s}=i,l=this.maze.getUnvisitedNeighbors(r,s);if(l.length>0){const c=this.randomPick(l),{row:a,col:d}=c;this.maze.removeWall(r,s,a,d),this.maze.grid[a][d].visited=!0,e.push(c)}else e.pop()}}runPrims(){const e=[],o=(r,s)=>{const l=this.maze.getNeighbors(r,s);for(const c of l)!this.maze.grid[c.row][c.col].visited&&!e.some(a=>a.row===c.row&&a.col===c.col)&&e.push(c)},n=this.randomNumber(this.maze.rows),i=this.randomNumber(this.maze.cols);for(this.maze.grid[n][i].visited=!0,o(n,i);e.length>0;){const r=this.randomNumber(e.length),s=e[r],{row:l,col:c}=s,a=this.maze.getVisitedNeighbors(l,c);if(a.length>0){const d=this.randomPick(a);this.maze.removeWall(l,c,d.row,d.col),this.maze.grid[l][c].visited=!0,o(l,c)}e.splice(r,1)}}addOpenings(e,o){this.maze.grid[e.row][e.col].walls.top=!1,this.maze.grid[o.row][o.col].walls.bottom=!1}randomNumber(e){return Math.floor(this.maze.random()*e)}randomPick(e){return e[Math.floor(this.maze.random()*e.length)]}}function Yt(t,e,o,n,i,r){return new Vt(t,e,o,n,i,r).getMaze()}const Xt=(t,e,o)=>{if(!t.isValid(e,o))return!1;const n=t.grid[e][o];return!n.walls.top||!n.walls.right||!n.walls.bottom||!n.walls.left},Qe=(t,e=ge.flat())=>{const o=t-1,n=e[o];if(!n)return console.error(`Cannot find Level ${t}'s config.`),null;const i=n.size,r=i,s=i,l=n.seed,c=n.method,a=n.entry||{row:0,col:0},d=n.exit||{row:r-1,col:s-1},u=Yt(r,s,c,l,a,d),_=Wt(t),h=[];for(let v=0;v<_;v++){let g;do g={row:Math.floor(u.random()*r),col:Math.floor(u.random()*s)};while(g.row===a.row&&g.col===a.col||g.row===d.row&&g.col===d.col||!Xt(u,g.row,g.col)||h.some(p=>p.row===g.row&&p.col===g.col));h.push(g)}return{maze:u,playerPosition:a,exitPosition:d,foodPositions:h,totalFoodCount:_,foodCollected:0,playerPath:[a],visitCounts:{[`${a.row},${a.col}`]:1},currentScore:{atExit:!1,allFood:!1,noClue:!0},playerAtExit:!1,isGameActive:!0,levelTransitioning:!1}},et=({gameState:t,setGameState:e,config:o})=>({generateCurrentLevelMaze:()=>{const i=Qe(t.currentLevel,o.levelConfig.flat());i&&e(r=>({...r,...i}))}}),tt=t=>W(()=>{const e=t.map(l=>l.length),o=e.reduce((l,c)=>l+c,0),n=t.length,i=l=>{if(l<1||l>o)return 0;let c=0;for(let a=0;a<e.length;a++)if(c+=e[a],l<=c)return a+1;return 0},r=l=>l<1||l>n?0:e.slice(0,l-1).reduce((c,a)=>c+a,0)+1,s={getTotalLevels:()=>o,getTotalTiers:()=>n,getTierLevelsRange:l=>{if(l<1||l>n)return[0,0];const c=r(l),a=c+e[l-1]-1;return[c,a]},getTierByLevel:i,getFirstLevelOfTier:r,getLevelConfig:l=>{if(l<1||l>o)return null;const c=i(l),a=r(c),d=l-a;return t[c-1][d]},getTierConfig:l=>l<1||l>n?null:t[l-1],isLevelUnlocked:(l,c)=>l<=c,isTierUnlocked:(l,c)=>l<=c,getNextLevelInfo:l=>{if(l>=o)return null;const c=l+1,a=i(l),d=i(c);return{nextLevel:c,nextTier:d,isTierChange:d>a}},getCurrentTierProgress:(l,c)=>{const[a,d]=s.getTierLevelsRange(c),u=l-a+1,_=d-a+1;return{current:u,total:_}},isLastLevelInTier:l=>{const c=i(l),[,a]=s.getTierLevelsRange(c);return l===a},getPreviousLevelInfo:l=>{if(l<=1)return null;const c=l-1,a=i(l),d=i(c);return{prevLevel:c,prevTier:d,isTierChange:d<a}}};return s},[t]),Jt=()=>{const{gameState:t,setGameState:e,resetGame:o,config:n}=_e(),i=n.i18n,r=n.levelConfig,s=tt(r),{showToast:l}=ve(),{totalScore:c,showClue:a,currentTier:d,currentLevel:u,highestUnlockedTier:_,highestUnlockedLevel:h,levelTransitioning:v}=t,g=s.getTotalLevels(),p=s.getTotalTiers(),[m,C]=M(!1),[P,k]=M(!1),[A,b]=M(!1),[T,F]=M(s.getTierLevelsRange(1)),{generateCurrentLevelMaze:E}=et({gameState:t,setGameState:e,config:n});N(()=>{F(s.getTierLevelsRange(d))},[d]);const j=S=>{const ne=s.getFirstLevelOfTier(S);s.isLevelUnlocked(ne,h)&&(e(bo=>({...bo,currentTier:S})),L(ne))},L=S=>{s.isLevelUnlocked(S,h)&&(e(ne=>({...ne,currentLevel:S})),E(),l(i.levelGoToast.replace("%LEVEL%",S.toString()),"success"))},$=()=>{C(!0)},mo=()=>{C(!1)},vo=()=>{b(!0)},go=()=>{b(!1)},po=()=>{e(S=>(l(S.showClue?i.cluePathDisabled:i.cluePathEnabled),{...S,currentScore:{...S.currentScore,noClue:S.showClue},showClue:!S.showClue})),b(!1)},Co=()=>{k(!0)},wo=()=>{o(),k(!1),l(i.resetDoneToast)},yo=()=>{k(!1)};return f("div",{class:"game-panel-container",children:[f("div",{className:"game-controls",children:[f("div",{className:"selectors-container",children:[f(jt,{i18n:i,totalTiers:p,currentTier:d,highestUnlockedTier:_,onTierChange:j,disabled:v}),f(Gt,{i18n:i,levelsRange:T,currentLevel:u,highestUnlockedLevel:h,onLevelChange:L,disabled:v})]}),f("button",{className:`settings-clue-button ${a?"clue-on":"clue-off"}`,disabled:a,title:"Toggle Clue",onClick:vo,children:a?i.clueOn:i.clueOff})]}),f("div",{className:"game-settings",children:f("span",{className:"game-settings-icon",onClick:$,children:"★ "+c})}),f(te,{isOpen:m,title:i.settings,noConfirm:!0,cancelText:i.close,onCancel:mo,children:[f("div",{className:"settings-stats",children:[f("div",{children:i.levelComplete+`: ${h}/${g}`}),f("div",{children:i.starsCollected+": "+c}),f("div",{children:i.avgStarPerLevel+": "+(c/h).toFixed(2)})]}),f("div",{className:"settings-item-box",children:[f("button",{className:"settings-reset-button",title:"Reset Game",onClick:Co,children:i.reset}),f("div",{className:"settings-item-tip",children:i.resetTip})]})]}),f(te,{isOpen:P,title:i.confirmReset,message:i.confirmResetMessage,confirmText:i.reset,cancelText:i.cancel,onConfirm:wo,onCancel:yo}),f(te,{isOpen:A,title:i.confirmClue,message:i.confirmClueMessage,confirmText:i.confirm,cancelText:i.cancel,onConfirm:po,onCancel:go})]})},Kt=({message:t,visible:e,duration:o=2e3,onClose:n,position:i="center",type:r="info"})=>t?(N(()=>{let s;return e&&o>0&&n&&(s=setTimeout(()=>{n()},o)),()=>{s&&clearTimeout(s)}},[e,o,n]),f("div",{className:`toast-container position-${i}`,children:f("div",{className:`toast-message type-${r} ${e?"toast-visible":""}`,children:t})})):null,Zt=(t,e,o)=>{N(()=>{const n=()=>{const i=t.current;if(!i)return;const r=i.parentElement;if(!r)return;const s=r.clientWidth,l=window.devicePixelRatio||1;i.style.width=`${s}px`,i.style.height=`${s}px`,i.width=s*l,i.height=s*l,e(t,o.current)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[t])},ot={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},Qt=({containerRef:t,gameState:e,setGameState:o,onFoodCollected:n})=>{N(()=>{const i=l=>{if(!e.isGameActive||!e.maze)return;const[c,a]=ot[l],{row:d,col:u}=e.playerPosition,_=d+c,h=u+a;if(!e.maze.isValid(_,h))return;const v=e.maze.grid[d][u];if(c===-1&&v.walls.top||c===1&&v.walls.bottom||a===-1&&v.walls.left||a===1&&v.walls.right)return;const g={row:_,col:h},p=`${_},${h}`;o(m=>{const C=m.foodPositions.some(T=>T.row===_&&T.col===h);C&&n();const P=`${d},${u}-${_},${h}`,k=_===m.exitPosition.row&&h===m.exitPosition.col,A=C?m.foodCollected+1:m.foodCollected,b=A===m.totalFoodCount;return{...m,playerPosition:g,playerPath:[...m.playerPath,g],foodPositions:m.foodPositions.filter(T=>!(T.row===_&&T.col===h)),foodCollected:A,currentScore:{atExit:k,allFood:b,noClue:!m.showClue},visitCounts:{...m.visitCounts,[P]:(m.visitCounts[P]||0)+1,[p]:(m.visitCounts[p]||0)+1},playerAtExit:k,isGameActive:!k,levelTransitioning:k}})},r=l=>{if(!e.isGameActive||!e.maze)return;const c=l.key;c in ot&&(l.preventDefault(),i(c))},s=l=>{if(l.preventDefault(),!e.isGameActive||!e.maze)return;const c=l.touches[0],a=document.elementFromPoint(c.clientX,c.clientY);a&&(a.classList.contains("maze-up")?i("ArrowUp"):a.classList.contains("maze-down")?i("ArrowDown"):a.classList.contains("maze-left")?i("ArrowLeft"):a.classList.contains("maze-right")&&i("ArrowRight"))};return window.addEventListener("keydown",r),t.current?.addEventListener("touchstart",s,{passive:!1}),()=>{window.removeEventListener("keydown",r),t.current?.removeEventListener("touchstart",s)}},[e.isGameActive,e.maze,e.playerPosition,e.exitPosition])},eo=({gameState:t,setGameState:e,config:o,onLevelComplete:n,onTierUnlocked:i})=>{N(()=>{t.levelTransitioning&&n()},[t.levelTransitioning]);const r=o.levelConfig,s=tt(r);return{goNextLevel:()=>{const a=s.getNextLevelInfo(t.currentLevel);if(!a)return;const{nextLevel:d,nextTier:u,isTierChange:_}=a,h=Qe(d,r.flat());h&&e(v=>{_&&i(u);const g={...v.levelScores};return g[v.currentLevel]=Math.max(Object.values(v.currentScore).filter(Boolean).length,g[v.currentLevel]||0),{...v,...h,currentLevel:d,currentTier:u,highestUnlockedLevel:Math.max(v.highestUnlockedLevel,d),highestUnlockedTier:Math.max(v.highestUnlockedTier,u),levelScores:g,totalScore:Object.values(g).reduce((p,m)=>p+m,0),showClue:!1,isGameActive:!0,levelTransitioning:!1}})},isLastLevel:()=>{const a=s.getTotalLevels();return t.currentLevel>=a}}};function to(t,e){const{ctx:o,width:n,height:i,maze:r}=t;e.playerColor=t.playerAtExit?e.playerAtExitColor:e.playerColor;const{padding:s,wallWidth:l,wallColor:c,playerColor:a,exitColor:d,foodColor:u,clueColor:_,backgroundColor:h}=e,v=r.cols,g=r.rows,p=(n-s*2)/v,m=(i-s*2)/g;o.clearRect(0,0,n,i),o.save(),o.fillStyle=h,o.fillRect(0,0,n,i),o.restore(),t.showClue&&t.playerPath&&t.playerPath.length>0&&lo(t,{cellWidth:p,cellHeight:m,padding:s,clueColor:_}),oo(t,{cellWidth:p,cellHeight:m,padding:s,wallColor:c,wallWidth:l}),ro(t,{cellWidth:p,cellHeight:m,padding:s,foodColor:u}),t.playerAtExit||io(t,{cellWidth:p,cellHeight:m,padding:s,exitColor:d}),no(t,{cellWidth:p,cellHeight:m,padding:s,playerColor:a})}function oo(t,e){const{ctx:o,maze:n}=t,{cellWidth:i,cellHeight:r,padding:s,wallColor:l,wallWidth:c}=e;o.save(),o.strokeStyle=l,o.lineWidth=c,o.lineCap="round",o.beginPath();for(let a=0;a<n.rows;a++)for(let d=0;d<n.cols;d++){const u=n.grid[a][d],_=s+d*i,h=s+a*r;u.walls.top&&(o.moveTo(_,h),o.lineTo(_+i,h)),u.walls.right&&(o.moveTo(_+i,h),o.lineTo(_+i,h+r)),u.walls.bottom&&(o.moveTo(_+i,h+r),o.lineTo(_,h+r)),u.walls.left&&(o.moveTo(_,h+r),o.lineTo(_,h))}o.stroke(),o.restore()}function no(t,e){const{ctx:o,playerPosition:n}=t,{cellWidth:i,cellHeight:r,padding:s,playerColor:l}=e,{x:c,y:a}=B(n.row,n.col,i,r,s),d=Math.min(i,r)*.35;o.save(),o.fillStyle=l,o.beginPath(),o.arc(c,a,d,0,Math.PI*2),o.fill(),o.restore()}function io(t,e){const{ctx:o,exitPosition:n}=t,{cellWidth:i,cellHeight:r,padding:s,exitColor:l}=e,{x:c,y:a}=B(n.row,n.col,i,r,s),d=Math.min(i,r)*.35;o.save(),o.fillStyle=l,o.beginPath(),o.arc(c,a,d,0,Math.PI*2),o.fill(),o.restore()}function ro(t,e){const{ctx:o,foodPositions:n}=t,{cellWidth:i,cellHeight:r,padding:s,foodColor:l}=e;o.fillStyle=l;const c=Math.min(i,r)*.25;n.forEach(a=>{const{x:d,y:u}=B(a.row,a.col,i,r,s);so(o,d,u,c*1.2,5,c*.6)})}function so(t,e,o,n,i,r){t.save(),t.beginPath();for(let s=0;s<i*2;s++){const l=s%2===0?n:r,c=Math.PI*s/i;t.lineTo(e+l*Math.sin(c),o+l*Math.cos(c))}t.closePath(),t.fill(),t.restore()}function lo(t,e){const{ctx:o,playerPath:n,visitCounts:i}=t,{cellWidth:r,cellHeight:s,padding:l,clueColor:c}=e;if(!(!n||n.length<2||!i)){o.save();for(let a=1;a<n.length;a++){const d=n[a-1],u=n[a],_=`${d.row},${d.col}-${u.row},${u.col}`,h=`${u.row},${u.col}-${d.row},${d.col}`,v=(i[_]||0)+(i[h]||0),g=Math.min(.2+v*.1,.9),p=Math.max(3,r*.1)+v*.5;try{o.strokeStyle=c.replace(")",`, ${g})`).replace("rgb(","rgba(")}catch{o.strokeStyle=`rgba(255, 0, 0, ${g})`}o.lineWidth=p,o.lineCap="round",o.lineJoin="round";const{x:m,y:C}=B(d.row,d.col,r,s,l),{x:P,y:k}=B(u.row,u.col,r,s,l);o.beginPath(),o.moveTo(m,C),o.lineTo(P,k),o.stroke()}o.restore()}}function B(t,e,o,n,i){return{x:i+e*o+o/2,y:i+t*n+n/2}}const ao=new Ut,co=()=>{const{message:t,visible:e,type:o,hideToast:n}=ve();return f(Kt,{message:t,visible:e,type:o,onClose:n,position:"top"})},uo=()=>{const{gameState:t,setGameState:e,config:o}=_e(),n=D(null),i=D(null),r=D(t),s=o.i18n,{showToast:l}=ve(),c=D(!1),a=D(!1),[d,u]=M(!1);N(()=>{r.current=t},[t]);const _=()=>{const b=t.totalFoodCount-t.foodCollected-1;if(b>0){l(s.foodCollectedToast.replace("%NUM%",b.toString()),"success");return}l(s.allFoodCollectedToast,"success")},h=(b,T)=>{const F=b.current?.getContext("2d");if(!F||!T.maze||c.current)return;c.current=!0;const E={...o.renderConfig||{}},L=o.levelConfig.flat()[T.currentLevel-1];E.wallWidth=L.wallWidth||E.wallWidth,to({ctx:F,width:b.current.width,height:b.current.height,maze:T.maze,playerPosition:T.playerPosition,exitPosition:T.exitPosition,foodPositions:T.foodPositions,showClue:T.showClue,playerPath:T.playerPath,visitCounts:T.visitCounts,playerAtExit:T.playerAtExit},E),requestAnimationFrame(()=>{c.current=!1})};N(()=>{l(s.useArrowKeyTips,"info",3e3)},[]),Zt(i,h,r);const{generateCurrentLevelMaze:v}=et({gameState:t,setGameState:e,config:o});Qt({containerRef:n,gameState:t,setGameState:e,onFoodCollected:_});const{goNextLevel:g,isLastLevel:p}=eo({gameState:t,setGameState:e,config:o,onLevelComplete:()=>{ao.addConfetti(),l(s.levelCompleteToast,"success"),u(!0)},onTierUnlocked:b=>{l(s.tierUnlockedToast.replace("%TIER%",b.toString()),"success")}}),m=W(()=>p(),[t.currentLevel]),C=W(()=>t.foodCollected===t.totalFoodCount,[t.foodCollected,t.totalFoodCount]),P=()=>{a.current=!1,u(!1),g()},k=()=>{a.current=!1,u(!1),v(),l(s.levelRestartToast,"info")},A=()=>{a.current=!0,u(!1),e(b=>({...b,isGameActive:!0,levelTransitioning:!1}))};return N(()=>{t.isGameActive&&!t.levelTransitioning&&!a.current&&v()},[t.currentLevel,t.isGameActive,t.levelTransitioning]),N(()=>{i.current&&t.maze&&h(i,t)},[t.maze,t.playerPosition,t.exitPosition,t.foodPositions,t.showClue,t.playerPath,t.visitCounts,t.playerAtExit]),f("div",{className:"maze-game-container",children:[f(co,{}),f(Jt,{}),f(te,{className:"level-complete-dialog",isOpen:d,title:s.congratulations,cancelText:s.retry,onCancel:k,noConfirm:C,confirmText:s.continue,onConfirm:A,children:[f("div",{className:"maze-summary-message",children:[t.currentScore.atExit&&f("div",{children:"★ - "+s.findYourExit}),f("div",{children:t.currentScore.noClue?"★ - "+s.withoutClue:"☆ - "+s.withClue}),f("div",{children:(t.currentScore.allFood?"★ - "+s.collectAllStars:"☆ - "+s.notCollectAllStars)+` (${t.foodCollected}/${t.totalFoodCount})`})]}),m&&f("div",{className:"all-levels-completed",children:s.allLevelsCompleted}),f("div",{className:"go-next-level",children:m?"OK":f("button",{type:"button",onClick:P,children:s.nextLevel})}),!C&&f("div",{className:"not-all-stars-collected",children:s.continueMessage})]}),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 ho(){return f(Dt,{children:f(uo,{})})}function _o({config:t={}}){const e={...oe.i18n,...t.i18n||{}},o={...oe.renderConfig,...t.renderConfig||{}},n=t.levelConfig||ge;return t={...oe,...t,i18n:e,levelConfig:n,renderConfig:o},f(mt,{config:t,children:f(ho,{})})}const fo={root:"https://unpkg.com/@roudanio/maze@0.0.9/dist/",...oe};return`${JSON.stringify(fo,null,2)}`,{async init(t,e){const o=typeof t=="string"?document.querySelector(t):t;if(!o){console.warn("Cannot find the root element");const c=document.createElement("div");c.style.textAlign="center",c.style.padding="20px",c.innerHTML="Cannot find the root element",document.body.append(c);return}let{root:n=location.origin}=e;n.at(-1)!=="/"&&(n+="/");const i=document.createElement("div"),r=document.createElement("div");i.style.cssText=`
|
|
2
2
|
height: 30px;
|
|
3
3
|
width: 100%;
|
|
4
4
|
border: solid 2px #999;
|
|
@@ -14,4 +14,4 @@ var Maze=function(){"use strict";var B,w,pe,I,Ce,we,ye,be,oe,ne,ie,ke,j={},Te=[]
|
|
|
14
14
|
@keyframes loading {
|
|
15
15
|
0% { width: 0%; }
|
|
16
16
|
100% { width: 99%; }
|
|
17
|
-
}`,document.head.appendChild(s),await(async c=>new Promise((a,d)=>{const u=document.createElement("link");u.rel="stylesheet",u.type="text/css",u.href=c,u.onload=a,u.onerror=d,document.head.appendChild(u)}))(n+"maze.css"),ct(
|
|
17
|
+
}`,document.head.appendChild(s),await(async c=>new Promise((a,d)=>{const u=document.createElement("link");u.rel="stylesheet",u.type="text/css",u.href=c,u.onload=a,u.onerror=d,document.head.appendChild(u)}))(n+"maze.css"),ct(f(_o,{config:e}),o)}}}();
|