@roudanio/maze 0.0.9 → 0.0.11
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 +4 -4
- package/dist/maze.js +1555 -1419
- package/dist/maze.umd.js +4 -4
- 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 .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:
|
|
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:translate(0,-10px,0);pointer-events:none;will-change:opacity,transform}.maze-game-container .toast-message.toast-visible{opacity:1;transform:translate(0,0,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,17 +1,17 @@
|
|
|
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=`
|
|
1
|
+
var Maze=function(){"use strict";var J,k,we,O,ye,be,ke,Te,ce,ue,de,Se,B={},ze=[],et=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Z=Array.isArray;function D(t,e){for(var n in e)t[n]=e[n];return t}function he(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function tt(t,e,n){var o,i,s,a={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?J.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)a[s]==null&&(a[s]=t.defaultProps[s]);return Q(t,a,o,i,null)}function Q(t,e,n,o,i){var s={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++we,__i:-1,__u:0};return i==null&&k.vnode!=null&&k.vnode(s),s}function ee(t){return t.children}function te(t,e){this.props=t,this.context=e}function j(t,e){if(e==null)return t.__?j(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?j(t):null}function Le(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Le(t)}}function _e(t){(!t.__d&&(t.__d=!0)&&O.push(t)&&!ne.__r++||ye!=k.debounceRendering)&&((ye=k.debounceRendering)||be)(ne)}function ne(){for(var t,e,n,o,i,s,a,r=1;O.length;)O.length>r&&O.sort(ke),t=O.shift(),r=O.length,t.__d&&(n=void 0,i=(o=(e=t).__v).__e,s=[],a=[],e.__P&&((n=D({},o)).__v=o.__v+1,k.vnode&&k.vnode(n),fe(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[i]:null,s,i??j(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,Ae(s,n,a),n.__e!=i&&Le(n)));ne.__r=0}function Ne(t,e,n,o,i,s,a,r,l,c,d){var u,h,_,p,g,v,m=o&&o.__k||ze,f=e.length;for(l=nt(n,e,m,l,f),u=0;u<f;u++)(_=n.__k[u])!=null&&(h=_.__i==-1?B:m[_.__i]||B,_.__i=u,v=fe(t,_,h,i,s,a,r,l,c,d),p=_.__e,_.ref&&h.ref!=_.ref&&(h.ref&&me(h.ref,null,_),d.push(_.ref,_.__c||p,_)),g==null&&p!=null&&(g=p),4&_.__u||h.__k===_.__k?l=Ee(_,l,t):typeof _.type=="function"&&v!==void 0?l=v:p&&(l=p.nextSibling),_.__u&=-7);return n.__e=g,l}function nt(t,e,n,o,i){var s,a,r,l,c,d=n.length,u=d,h=0;for(t.__k=new Array(i),s=0;s<i;s++)(a=e[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(l=s+h,(a=t.__k[s]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Q(null,a,null,null,null):Z(a)?Q(ee,{children:a},null,null,null):a.constructor==null&&a.__b>0?Q(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=t,a.__b=t.__b+1,r=null,(c=a.__i=ot(a,n,l,u))!=-1&&(u--,(r=n[c])&&(r.__u|=2)),r==null||r.__v==null?(c==-1&&(i>d?h--:i<d&&h++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?h--:c==l+1?h++:(c>l?h--:h++,a.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<d;s++)(r=n[s])!=null&&(2&r.__u)==0&&(r.__e==o&&(o=j(r)),Ie(r,r));return o}function Ee(t,e,n){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,e=Ee(o[i],e,n));return e}t.__e!=e&&(e&&t.type&&!n.contains(e)&&(e=j(t)),n.insertBefore(t.__e,e||null),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ot(t,e,n,o){var i,s,a=t.key,r=t.type,l=e[n];if(l===null&&t.key==null||l&&a==l.key&&r==l.type&&(2&l.__u)==0)return n;if(o>(l!=null&&(2&l.__u)==0?1:0))for(i=n-1,s=n+1;i>=0||s<e.length;){if(i>=0){if((l=e[i])&&(2&l.__u)==0&&a==l.key&&r==l.type)return i;i--}if(s<e.length){if((l=e[s])&&(2&l.__u)==0&&a==l.key&&r==l.type)return s;s++}}return-1}function Pe(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||et.test(e)?n:n+"px"}function oe(t,e,n,o,i){var s;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||Pe(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||Pe(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Te,"$1")),e=e.toLowerCase()in t||e=="onFocusOut"||e=="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=n,n?o?n.u=o.u:(n.u=ce,t.addEventListener(e,s?de:ue,s)):t.removeEventListener(e,s?de:ue,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function Me(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ce++;else if(e.t<n.u)return;return n(k.event?k.event(e):e)}}}function fe(t,e,n,o,i,s,a,r,l,c){var d,u,h,_,p,g,v,m,f,w,y,T,b,S,A,E,P,N=e.type;if(e.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),s=[r=e.__e=n.__e]),(d=k.__b)&&d(e);e:if(typeof N=="function")try{if(m=e.props,f="prototype"in N&&N.prototype.render,w=(d=N.contextType)&&o[d.__c],y=d?w?w.props.value:d.__:o,n.__c?v=(u=e.__c=n.__c).__=u.__E:(f?e.__c=u=new N(m,y):(e.__c=u=new te(m,y),u.constructor=N,u.render=it),w&&w.sub(u),u.props=m,u.state||(u.state={}),u.context=y,u.__n=o,h=u.__d=!0,u.__h=[],u._sb=[]),f&&u.__s==null&&(u.__s=u.state),f&&N.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=D({},u.__s)),D(u.__s,N.getDerivedStateFromProps(m,u.__s))),_=u.props,p=u.state,u.__v=e,h)f&&N.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),f&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(f&&N.getDerivedStateFromProps==null&&m!==_&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(m,y),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(m,u.__s,y)===!1||e.__v==n.__v){for(e.__v!=n.__v&&(u.props=m,u.state=u.__s,u.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(R){R&&(R.__=e)}),T=0;T<u._sb.length;T++)u.__h.push(u._sb[T]);u._sb=[],u.__h.length&&a.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(m,u.__s,y),f&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(_,p,g)})}if(u.context=y,u.props=m,u.__P=t,u.__e=!1,b=k.__r,S=0,f){for(u.state=u.__s,u.__d=!1,b&&b(e),d=u.render(u.props,u.state,u.context),A=0;A<u._sb.length;A++)u.__h.push(u._sb[A]);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&&++S<25);u.state=u.__s,u.getChildContext!=null&&(o=D(D({},o),u.getChildContext())),f&&!h&&u.getSnapshotBeforeUpdate!=null&&(g=u.getSnapshotBeforeUpdate(_,p)),E=d,d!=null&&d.type===ee&&d.key==null&&(E=xe(d.props.children)),r=Ne(t,Z(E)?E:[E],e,n,o,i,s,a,r,l,c),u.base=e.__e,e.__u&=-161,u.__h.length&&a.push(u),v&&(u.__E=u.__=null)}catch(R){if(e.__v=null,l||s!=null)if(R.then){for(e.__u|=l?160:128;r&&r.nodeType==8&&r.nextSibling;)r=r.nextSibling;s[s.indexOf(r)]=null,e.__e=r}else for(P=s.length;P--;)he(s[P]);else e.__e=n.__e,e.__k=n.__k;k.__e(R,e,n)}else s==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):r=e.__e=rt(n.__e,e,n,o,i,s,a,l,c);return(d=k.diffed)&&d(e),128&e.__u?void 0:r}function Ae(t,e,n){for(var o=0;o<n.length;o++)me(n[o],n[++o],n[++o]);k.__c&&k.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){k.__e(s,i.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Z(t)?t.map(xe):D({},t)}function rt(t,e,n,o,i,s,a,r,l){var c,d,u,h,_,p,g,v=n.props,m=e.props,f=e.type;if(f=="svg"?i="http://www.w3.org/2000/svg":f=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((_=s[c])&&"setAttribute"in _==!!f&&(f?_.localName==f:_.nodeType==3)){t=_,s[c]=null;break}}if(t==null){if(f==null)return document.createTextNode(m);t=document.createElementNS(i,f,m.is&&m),r&&(k.__m&&k.__m(e,s),r=!1),s=null}if(f==null)v===m||r&&t.data==m||(t.data=m);else{if(s=s&&J.call(t.childNodes),v=n.props||B,!r&&s!=null)for(v={},c=0;c<t.attributes.length;c++)v[(_=t.attributes[c]).name]=_.value;for(c in v)if(_=v[c],c!="children"){if(c=="dangerouslySetInnerHTML")u=_;else if(!(c in m)){if(c=="value"&&"defaultValue"in m||c=="checked"&&"defaultChecked"in m)continue;oe(t,c,null,_,i)}}for(c in m)_=m[c],c=="children"?h=_:c=="dangerouslySetInnerHTML"?d=_:c=="value"?p=_:c=="checked"?g=_:r&&typeof _!="function"||v[c]===_||oe(t,c,_,v[c],i);if(d)r||u&&(d.__html==u.__html||d.__html==t.innerHTML)||(t.innerHTML=d.__html),e.__k=[];else if(u&&(t.innerHTML=""),Ne(e.type=="template"?t.content:t,Z(h)?h:[h],e,n,o,f=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&j(n,0),r,l),s!=null)for(c=s.length;c--;)he(s[c]);r||(c="value",f=="progress"&&p==null?t.removeAttribute("value"):p!=null&&(p!==t[c]||f=="progress"&&!p||f=="option"&&p!=v[c])&&oe(t,c,p,v[c],i),c="checked",g!=null&&g!=t[c]&&oe(t,c,g,v[c],i))}return t}function me(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){k.__e(i,n)}}function Ie(t,e,n){var o,i;if(k.unmount&&k.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||me(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){k.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&Ie(o[i],e,n||typeof t.type!="function");n||he(t.__e),t.__c=t.__=t.__e=void 0}function it(t,e,n){return this.constructor(t,n)}function st(t,e,n){var o,i,s,a;e==document&&(e=document.documentElement),k.__&&k.__(t,e),i=(o=!1)?null:e.__k,s=[],a=[],fe(e,t=e.__k=tt(ee,null,[t]),i||B,B,e.namespaceURI,i?null:e.firstChild?J.call(e.childNodes):null,s,i?i.__e:e.firstChild,o,a),Ae(s,t,a)}function lt(t){function e(n){var o,i;return this.getChildContext||(o=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,_e(a)})},this.sub=function(s){o.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),a&&a.call(s)}}),n.children}return e.__c="__cC"+Se++,e.__=t,e.Provider=e.__l=(e.Consumer=function(n,o){return n.children(o)}).contextType=e,e}J=ze.slice,k={__e:function(t,e,n,o){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,o||{}),a=i.__d),a)return i.__E=i}catch(r){t=r}throw t}},we=0,te.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=D({},this.state),typeof t=="function"&&(t=t(D({},n),this.props)),t&&D(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),_e(this))},te.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),_e(this))},te.prototype.render=ee,O=[],be=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ke=function(t,e){return t.__v.__b-e.__v.__b},ne.__r=0,Te=/(PointerCapture)$|Capture$/i,ce=0,ue=Me(!1),de=Me(!0),Se=0;var at=0;function C(t,e,n,o,i,s){e||(e={});var a,r,l=e;if("ref"in l)for(r in l={},e)r=="ref"?a=e[r]:l[r]=e[r];var c={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--at,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(a=t.defaultProps))for(r in a)l[r]===void 0&&(l[r]=a[r]);return k.vnode&&k.vnode(c),c}var G,z,ve,Fe,V=0,Re=[],L=k,De=L.__b,$e=L.__r,Oe=L.diffed,Ue=L.__c,je=L.unmount,Ge=L.__;function re(t,e){L.__h&&L.__h(z,t,V||e),V=0;var n=z.__H||(z.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function W(t){return V=1,ct(qe,t)}function ct(t,e,n){var o=re(G++,2);if(o.t=t,!o.__c&&(o.__=[qe(void 0,e),function(r){var l=o.__N?o.__N[0]:o.__[0],c=o.t(l,r);l!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=z,!z.__f)){var i=function(r,l,c){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(h){return!!h.__c});if(d.every(function(h){return!h.__N}))return!s||s.call(this,r,l,c);var u=o.__c.props!==r;return d.forEach(function(h){if(h.__N){var _=h.__[0];h.__=h.__N,h.__N=void 0,_!==h.__[0]&&(u=!0)}}),s&&s.call(this,r,l,c)||u};z.__f=!0;var s=z.shouldComponentUpdate,a=z.componentWillUpdate;z.componentWillUpdate=function(r,l,c){if(this.__e){var d=s;s=void 0,i(r,l,c),s=d}a&&a.call(this,r,l,c)},z.shouldComponentUpdate=i}return o.__N||o.__}function M(t,e){var n=re(G++,3);!L.__s&&He(n.__H,e)&&(n.__=t,n.u=e,z.__H.__h.push(n))}function I(t){return V=5,U(function(){return{current:t}},[])}function U(t,e){var n=re(G++,7);return He(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ut(t,e){return V=8,U(function(){return t},e)}function dt(t){var e=z.context[t.__c],n=re(G++,9);return n.c=t,e?(n.__==null&&(n.__=!0,e.sub(z)),e.props.value):t.__}function ht(){for(var t;t=Re.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ie),t.__H.__h.forEach(pe),t.__H.__h=[]}catch(e){t.__H.__h=[],L.__e(e,t.__v)}}L.__b=function(t){z=null,De&&De(t)},L.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),Ge&&Ge(t,e)},L.__r=function(t){$e&&$e(t),G=0;var e=(z=t.__c).__H;e&&(ve===z?(e.__h=[],z.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ie),e.__h.forEach(pe),e.__h=[],G=0)),ve=z},L.diffed=function(t){Oe&&Oe(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Re.push(e)!==1&&Fe===L.requestAnimationFrame||((Fe=L.requestAnimationFrame)||_t)(ht)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ve=z=null},L.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ie),n.__h=n.__h.filter(function(o){return!o.__||pe(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],L.__e(o,n.__v)}}),Ue&&Ue(t,e)},L.unmount=function(t){je&&je(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ie(o)}catch(i){e=i}}),n.__H=void 0,e&&L.__e(e,n.__v))};var We=typeof requestAnimationFrame=="function";function _t(t){var e,n=function(){clearTimeout(o),We&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,100);We&&(e=requestAnimationFrame(n))}function ie(t){var e=z,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),z=e}function pe(t){var e=z;t.__c=t.__(),z=e}function He(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function qe(t,e){return typeof e=="function"?e(t):e}const ft=t=>({saveGameData(e){try{localStorage.setItem(t,JSON.stringify(e))}catch(n){console.error("Failed to save maze game data:",n)}},loadGameData(){try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch(e){return console.error("Failed to load maze game data:",e),null}},resetGameData(){try{localStorage.removeItem(t)}catch(e){console.error("Failed to reset maze game data:",e)}}}),Be=lt(void 0),Ve={currentLevel:1,highestUnlockedLevel:1,currentTier:1,highestUnlockedTier:1,levelScores:{}},Ye={isGameActive:!0,levelTransitioning:!1,maze:null,playerCell:{row:0,col:0},exitCell:{row:0,col:0},foodCells:[],playerAtExit:!1,foodCollected:0,totalFoodCount:0,showClue:!1,playerPath:[],visitCounts:{}},mt=({children:t,config:e})=>{const n=ft(e.lcPrefix+"progress"),o=n.loadGameData(),[i,s]=W(()=>o||{...Ve});M(()=>{n.saveGameData(i)},[i.currentLevel,i.highestUnlockedLevel,i.currentTier,i.highestUnlockedTier,i.levelScores]);const a=U(()=>Object.values(i.levelScores).reduce((h,_)=>h+_,0),[i.levelScores]),[r,l]=W({...Ye}),c=I(r);M(()=>{c.current=r},[r]);const d=U(()=>[r.playerAtExit?1:0,r.foodCollected===r.totalFoodCount?1:0,r.showClue?0:1],[r.playerAtExit,r.foodCollected,r.totalFoodCount,r.showClue]),u=()=>{n.resetGameData(),s({...Ve}),l({...Ye})};return C(Be.Provider,{value:{gameProgress:i,setGameProgress:s,gamePlayState:r,setGamePlayState:l,gamePlayStateRef:c,currentScore:d,totalScore:a,config:e,resetGame:u},children:t})},H=()=>{const t=dt(Be);if(!t)throw new Error("useGameContext must be used within a GameProvider");return t},Y=t=>U(()=>{const e=t.map(r=>r.length),n=e.reduce((r,l)=>r+l,0),o=t.length,i=r=>{if(r<1||r>n)return 0;let l=0;for(let c=0;c<e.length;c++)if(l+=e[c],r<=l)return c+1;return 0},s=r=>r<1||r>o?0:e.slice(0,r-1).reduce((l,c)=>l+c,0)+1,a={getTotalLevels:()=>n,getTotalTiers:()=>o,getTierLevelsRange:r=>{if(r<1||r>o)return[0,0];const l=s(r),c=l+e[r-1]-1;return[l,c]},getTierByLevel:i,getFirstLevelOfTier:s,getLevelConfig:r=>{if(r<1||r>n)return null;const l=i(r),c=s(l),d=r-c;return t[l-1][d]},getTierConfig:r=>r<1||r>o?null:t[r-1],isLevelUnlocked:(r,l)=>r<=l,isTierUnlocked:(r,l)=>r<=l,getNextLevelInfo:r=>{if(r>=n)return null;const l=r+1,c=i(r),d=i(l);return{nextLevel:l,nextTier:d,isTierChange:d>c}},getCurrentTierProgress:(r,l)=>{const[c,d]=a.getTierLevelsRange(l),u=r-c+1,h=d-c+1;return{current:u,total:h}},isLastLevelInTier:r=>{const l=i(r),[,c]=a.getTierLevelsRange(l);return r===c},getPreviousLevelInfo:r=>{if(r<=1)return null;const l=r-1,c=i(r),d=i(l);return{prevLevel:l,prevTier:d,isTierChange:d<c}}};return a},[t]),vt=({onTierChange:t,disabled:e})=>{const{gameProgress:n,config:o}=H(),{i18n:i,levelConfig:s}=o,{currentTier:a,highestUnlockedTier:r}=n,c=Y(s).getTotalTiers();return C("div",{className:"tier-selector",children:C("select",{value:a,onChange:d=>{d.target&&d.target.value&&t(Number(d.target.value))},disabled:e,className:"tier-dropdown",children:Array.from({length:c},(d,u)=>u+1).map(d=>C("option",{value:d,disabled:d>r,children:i.tier+" "+d},`tier-${d}`))})})},pt=({onLevelChange:t,disabled:e})=>{const{gameProgress:n,config:o}=H(),{i18n:i,levelConfig:s}=o,{currentTier:a,levelScores:r,currentLevel:l,highestUnlockedLevel:c}=n,d=Y(s),u=U(()=>{const[h,_]=d.getTierLevelsRange(a);return Array.from({length:_-h+1},(p,g)=>{const v=h+g,m=r[v]||0;return{level:v,score:m}})},[a,r]);return C("div",{className:"level-selector",children:C("select",{value:l,onChange:h=>{h.target&&h.target.value&&t(Number(h.target.value))},disabled:e,className:"level-dropdown",children:u.map(({level:h,score:_})=>C("option",{value:h,disabled:h>c,children:`${i.level} ${h} ${"★".repeat(_)}`},`level-${h}`))})})},se=({isOpen:t,title:e,className:n="",message:o,children:i,noConfirm:s=!1,noCancel:a=!1,confirmText:r="OK",cancelText:l="Cancel",onConfirm:c,onCancel:d})=>{const u=I(null);return M(()=>{const h=_=>{_.key==="Escape"&&d?.()};return t&&document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[t,d]),C("div",{className:`maze-dialog-overlay ${t?"maze-dialog-visible":""}`,children:C("div",{className:"maze-dialog "+n,ref:u,children:[C("div",{className:"maze-dialog-title",children:e}),C("div",{className:"maze-dialog-content",children:i||C("div",{className:"maze-dialog-message",children:o})}),(!a||!s)&&C("div",{className:"maze-dialog-buttons",children:[!a&&C("button",{type:"button",className:"maze-dialog-cancel",onClick:d,children:l}),!s&&C("button",{type:"button",className:"maze-dialog-confirm",onClick:c,children:r})]})]})})},F={container:null,attachTo(t){return this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=document.createElement("div"),this.container.className="toast-container position-top",t.appendChild(this.container),this.container},currentToast:null,currentTimer:null,show(t,e="info",n=2e3){if(!this.container){console.warn("NativeToast: container not initialized, please call attachTo first");return}this.currentToast&&this.container.contains(this.currentToast)&&(this.container.removeChild(this.currentToast),this.currentToast=null),this.currentTimer&&(clearTimeout(this.currentTimer),this.currentTimer=null);const o=document.createElement("div");o.className=`toast-message type-${e} toast-visible`,o.textContent=t,this.container.appendChild(o),this.currentToast=o,this.currentTimer=setTimeout(()=>{o.classList.remove("toast-visible"),setTimeout(()=>{this.container&&this.container.contains(o)&&(this.container.removeChild(o),this.currentToast===o&&(this.currentToast=null))},300),this.currentTimer=null},n)},clearAll(){if(this.container)for(;this.container.firstChild;)this.container.removeChild(this.container.firstChild)}},gt=()=>{const{gameProgress:t,setGameProgress:e,gamePlayState:n,setGamePlayState:o,gamePlayStateRef:i,totalScore:s,resetGame:a,config:r}=H(),{i18n:l,levelConfig:c}=r,d=Y(c),{levelTransitioning:u,showClue:h}=n,{highestUnlockedLevel:_}=t,p=d.getTotalLevels(),[g,v]=W(!1),[m,f]=W(!1),[w,y]=W(!1),T=q=>{const ae=d.getFirstLevelOfTier(q);d.isLevelUnlocked(ae,_)&&(e(vn=>({...vn,currentTier:q})),b(ae))},b=q=>{d.isLevelUnlocked(q,_)&&(e(ae=>({...ae,currentLevel:q})),F.show(l.levelGoToast.replace("%LEVEL%",q.toString()),"success"))},S=()=>{v(!0)},A=()=>{v(!1)},E=()=>{y(!0)},P=()=>{y(!1)},N=()=>{F.show(h?l.cluePathDisabled:l.cluePathEnabled),o(()=>({...i.current,showClue:!i.current.showClue})),y(!1)},R=()=>{f(!0)},$=()=>{a(),f(!1),F.show(l.resetDoneToast)},mn=()=>{f(!1)};return C("div",{class:"game-panel-container",children:[C("div",{className:"game-controls",children:[C("div",{className:"selectors-container",children:[C(vt,{onTierChange:T,disabled:u}),C(pt,{onLevelChange:b,disabled:u})]}),C("button",{className:`settings-clue-button ${h?"clue-on":"clue-off"}`,disabled:h,title:"Toggle Clue",onClick:E,children:h?l.clueOn:l.clueOff})]}),C("div",{className:"game-settings",children:C("span",{className:"game-settings-icon",onClick:S,children:"★ "+s})}),C(se,{isOpen:g,title:l.settings,noConfirm:!0,cancelText:l.close,onCancel:A,children:[C("div",{className:"settings-stats",children:[C("div",{children:l.levelComplete+`: ${_}/${p}`}),C("div",{children:l.starsCollected+": "+s}),C("div",{children:l.avgStarPerLevel+": "+(s/_).toFixed(2)})]}),C("div",{className:"settings-item-box",children:[C("button",{className:"settings-reset-button",title:"Reset Game",onClick:R,children:l.reset}),C("div",{className:"settings-item-tip",children:l.resetTip})]})]}),C(se,{isOpen:m,title:l.confirmReset,message:l.confirmResetMessage,confirmText:l.reset,cancelText:l.cancel,onConfirm:$,onCancel:mn}),C(se,{isOpen:w,title:l.confirmClue,message:l.confirmClueMessage,confirmText:l.confirm,cancelText:l.cancel,onConfirm:N,onCancel:P})]})};function ge(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ct(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function Ce(t,e,n){return e&&Ct(t.prototype,e),t}function Xe(t){return+t.replace(/px/,"")}function wt(t){var e=window.devicePixelRatio,n=getComputedStyle(t),o=Xe(n.getPropertyValue("width")),i=Xe(n.getPropertyValue("height"));t.setAttribute("width",(o*e).toString()),t.setAttribute("height",(i*e).toString())}function x(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=Math.random()*(e-t)+t;return Math.floor(o*Math.pow(10,n))/Math.pow(10,n)}function Ke(t){return t[x(0,t.length)]}var yt=.00125,bt=5e-4,kt=9e-4,Tt=1e-5,St=6,zt=80,Lt=.9,Nt=1.7,Et=.2,Pt=.6,Mt=.03,At=.07,xt=15,It=82,Ft=100,Rt=250,Dt=40,$t=["#fcf403","#62fc03","#f4fc03","#03e7fc","#03fca5","#a503fc","#fc03ad","#fc03c2"];function Je(t){var e=1920;return Math.log(t)/Math.log(e)}var Ze=function(){function t(e){ge(this,t);var n=e.initialPosition,o=e.direction,i=e.confettiRadius,s=e.confettiColors,a=e.emojis,r=e.emojiSize,l=e.canvasWidth,c=x(Lt,Nt,3),d=c*Je(l);this.confettiSpeed={x:d,y:d},this.finalConfettiSpeedX=x(Et,Pt,3),this.rotationSpeed=a.length?.01:x(Mt,At,3)*Je(l),this.dragForceCoefficient=x(bt,kt,6),this.radius={x:i,y:i},this.initialRadius=i,this.rotationAngle=o==="left"?x(0,.2,3):x(-.2,0,3),this.emojiSize=r,this.emojiRotationAngle=x(0,2*Math.PI),this.radiusYUpdateDirection="down";var u=o==="left"?x(It,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 h=x(-150,0),_={x:n.x+(o==="left"?-h:h)*this.absCos,y:n.y-h*this.absSin};this.currentPosition=Object.assign({},_),this.initialPosition=Object.assign({},_),this.color=a.length?null:Ke(s),this.emoji=a.length?Ke(a):null,this.createdAt=new Date().getTime(),this.direction=o}return Ce(t,[{key:"draw",value:function(n){var o=this.currentPosition,i=this.radius,s=this.color,a=this.emoji,r=this.rotationAngle,l=this.emojiRotationAngle,c=this.emojiSize,d=window.devicePixelRatio;s?(n.fillStyle=s,n.beginPath(),n.ellipse(o.x*d,o.y*d,i.x*d,i.y*d,r,0,2*Math.PI),n.fill()):a&&(n.font="".concat(c,"px serif"),n.save(),n.translate(d*o.x,d*o.y),n.rotate(l),n.textAlign="center",n.fillText(a,0,0),n.restore())}},{key:"updatePosition",value:function(n,o){var i=this.confettiSpeed,s=this.dragForceCoefficient,a=this.finalConfettiSpeedX,r=this.radiusYUpdateDirection,l=this.rotationSpeed,c=this.createdAt,d=this.direction,u=o-c;if(i.x>a&&(this.confettiSpeed.x-=s*n),this.currentPosition.x+=i.x*(d==="left"?-this.absCos:this.absCos)*n,this.currentPosition.y=this.initialPosition.y-i.y*this.absSin*u+yt*Math.pow(u,2)/2,this.rotationSpeed-=this.emoji?1e-4:Tt*n,this.rotationSpeed<0&&(this.rotationSpeed=0),this.emoji){this.emojiRotationAngle+=this.rotationSpeed*n%(2*Math.PI);return}r==="down"?(this.radius.y-=n*l,this.radius.y<=0&&(this.radius.y=0,this.radiusYUpdateDirection="up")):(this.radius.y+=n*l,this.radius.y>=this.initialRadius&&(this.radius.y=this.initialRadius,this.radiusYUpdateDirection="down"))}},{key:"getIsVisibleOnCanvas",value:function(n){return this.currentPosition.y<n+Ft}}]),t}();function Ot(){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 Ut(t){var e=t.confettiRadius,n=e===void 0?St:e,o=t.confettiNumber,i=o===void 0?t.confettiesNumber||(t.emojis?Dt:Rt):o,s=t.confettiColors,a=s===void 0?$t:s,r=t.emojis,l=r===void 0?t.emojies||[]:r,c=t.emojiSize,d=c===void 0?zt:c;return t.emojies&&console.error("emojies argument is deprecated, please use emojis instead"),t.confettiesNumber&&console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"),{confettiRadius:n,confettiNumber:i,confettiColors:a,emojis:l,emojiSize:d}}var jt=function(){function t(e){var n=this;ge(this,t),this.canvasContext=e,this.shapes=[],this.promise=new Promise(function(o){return n.resolvePromise=o})}return Ce(t,[{key:"getBatchCompletePromise",value:function(){return this.promise}},{key:"addShapes",value:function(){var n;(n=this.shapes).push.apply(n,arguments)}},{key:"complete",value:function(){var n;return this.shapes.length?!1:((n=this.resolvePromise)===null||n===void 0||n.call(this),!0)}},{key:"processShapes",value:function(n,o,i){var s=this,a=n.timeDelta,r=n.currentTime;this.shapes=this.shapes.filter(function(l){return l.updatePosition(a,r),l.draw(s.canvasContext),i?l.getIsVisibleOnCanvas(o):!0})}}]),t}(),Gt=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ge(this,t),this.activeConfettiBatches=[],this.canvas=e.canvas||Ot(),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 Ce(t,[{key:"loop",value:function(){this.requestAnimationFrameRequested=!1,wt(this.canvas);var n=new Date().getTime(),o=n-this.lastUpdated,i=this.canvas.offsetHeight,s=this.iterationIndex%10===0;this.activeConfettiBatches=this.activeConfettiBatches.filter(function(a){return a.processShapes({timeDelta:o,currentTime:n},i,s),s?!a.complete():!0}),this.iterationIndex++,this.queueAnimationFrameIfNeeded(n)}},{key:"queueAnimationFrameIfNeeded",value:function(n){this.requestAnimationFrameRequested||this.activeConfettiBatches.length<1||(this.requestAnimationFrameRequested=!0,this.lastUpdated=n||new Date().getTime(),requestAnimationFrame(this.loop))}},{key:"addConfetti",value:function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=Ut(n),i=o.confettiRadius,s=o.confettiNumber,a=o.confettiColors,r=o.emojis,l=o.emojiSize,c=this.canvas.getBoundingClientRect(),d=c.width,u=c.height,h=u*5/7,_={x:0,y:h},p={x:d,y:h},g=new jt(this.canvasContext),v=0;v<s/2;v++){var m=new Ze({initialPosition:_,direction:"right",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d}),f=new Ze({initialPosition:p,direction:"left",confettiRadius:i,confettiColors:a,confettiNumber:s,emojis:r,emojiSize:l,canvasWidth:d});g.addShapes(m,f)}return this.activeConfettiBatches.push(g),this.queueAnimationFrameIfNeeded(),g.getBatchCompletePromise()}},{key:"clearCanvas",value:function(){this.activeConfettiBatches=[]}},{key:"destroyCanvas",value:function(){this.canvas.remove()}}]),t}();const Wt=new Gt,Ht=({onRetry:t})=>{const{config:e,currentScore:n,gamePlayState:o,setGamePlayState:i,gameProgress:s,setGameProgress:a}=H(),{i18n:r,levelConfig:l}=e,[c,d,u]=n,{foodCollected:h,totalFoodCount:_,playerAtExit:p,levelTransitioning:g}=o,{currentLevel:v}=s,[m,f]=W(!1);M(()=>{p&&g&&(Wt.addConfetti(),F.show(r.levelCompleteToast,"success"),f(!0))},[p,g]);const w=Y(l),y=w.getTotalLevels(),T=U(()=>v>=y,[v,y]),b=()=>{f(!1),F.show(r.levelRestartToast,"info"),t?.()},S=()=>{f(!1),i(E=>({...E,levelTransitioning:!1}))},A=()=>{f(!1);const E=w.getNextLevelInfo(v);if(!E)return;const{nextLevel:P,nextTier:N,isTierChange:R}=E;R&&F.show(r.tierUnlockedToast.replace("%TIER%",N.toString()),"success"),a($=>({...$,currentLevel:P,currentTier:N,highestUnlockedLevel:Math.max($.highestUnlockedLevel,P),highestUnlockedTier:Math.max($.highestUnlockedTier,N),levelScores:{...$.levelScores,[$.currentLevel]:Math.max(Object.values(n).filter(Boolean).length,$.levelScores[$.currentLevel]||0)}}))};return C(se,{className:"level-complete-dialog",isOpen:m,title:r.congratulations,cancelText:r.retry,onCancel:b,noConfirm:!!d,confirmText:r.continue,onConfirm:S,children:[C("div",{className:"maze-summary-message",children:[!!c&&C("div",{children:"★ - "+r.findYourExit}),C("div",{children:u?"★ - "+r.withoutClue:"☆ - "+r.withClue}),C("div",{children:(d?"★ - "+r.collectAllStars:"☆ - "+r.notCollectAllStars)+` (${h}/${_})`})]}),T&&C("div",{className:"all-levels-completed",children:r.allLevelsCompleted}),C("div",{className:"go-next-level",children:T?"OK":C("button",{type:"button",onClick:A,children:r.nextLevel})}),!d&&C("div",{className:"not-all-stars-collected",children:r.continueMessage})]})},qt=(t,e)=>{const n=I({canvasWidth:0,canvasHeight:0});return M(()=>{const o=()=>{const s=t.current;if(!s)return;const a=s.parentElement;if(!a)return;const r=a.clientWidth,l=window.devicePixelRatio||1;s.style.width=`${r}px`,s.style.height=`${r}px`;const c=r*l,d=r*l;s.width=c,s.height=d,n.current={canvasWidth:c,canvasHeight:d}};o();let i=null;return window.ResizeObserver&&(i=new ResizeObserver(o),i.observe(t.current.parentElement)),window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),i?.disconnect()}},[t,e]),n},Bt=t=>{const{config:e,gamePlayState:{maze:n}}=H(),o=I({cellWidth:0,cellHeight:0});return M(()=>{const i=e.renderConfig.padding,s=()=>{const r=t.current;if(!r||!n)return;const{rows:l,cols:c}=n;if(l<=0||c<=0)return;const d=(r.width-i*2)/c,u=(r.height-i*2)/l;o.current={cellWidth:d,cellHeight:u}};s();let a=null;return t.current&&window.ResizeObserver&&(a=new ResizeObserver(s),a.observe(t.current)),()=>{t.current&&a?.disconnect()}},[t,n]),o},X={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]},Vt=({containerRef:t,gamePlayStateRef:e,setGamePlayState:n,moveSpeed:o,playerRadius:i,onFoodCollected:s})=>{const a=I(!1),r=I(null),l=(p,g)=>{const v=e.current;if(!v.maze)return{canMove:!1,newCell:null};if(Yt(g,p,i,o,v.maze))return{canMove:!1,newCell:null};const[f,w]=X[p],{row:y,col:T}=g,b=y+f*o,S=T+w*o,A=Math.floor(y),E=Math.floor(T),P=Math.floor(b),N=Math.floor(S);return P!==A||N!==E?v.maze.isValid(P,N)?{canMove:!0,newCell:{row:P,col:N}}:{canMove:!1,newCell:null}:{canMove:!0,newCell:null}},c=()=>{const p=e.current,{row:g,col:v}=p.playerCell,m=i*2,f=p.foodCells.findIndex(b=>Math.sqrt(Math.pow(g-b.row,2)+Math.pow(v-b.col,2))<m);f!==-1&&s&&(s(),e.current={...e.current,foodCollected:e.current.foodCollected+1,foodCells:e.current.foodCells.filter((b,S)=>S!==f)}),Math.sqrt(Math.pow(g-p.exitCell.row,2)+Math.pow(v-p.exitCell.col,2))<m&&!e.current.playerAtExit&&(e.current={...e.current,playerAtExit:!0,isGameActive:!1,levelTransitioning:!0},requestIdleCallback(()=>{n(()=>({...e.current}))},{timeout:10}))},d=p=>{const g=e.current,v=Math.round(p.row),m=Math.round(p.col),f=g.playerPath[g.playerPath.length-1],w=f.row===v&&f.col===m,y=Math.abs(f.row-v),T=Math.abs(f.col-m);if((y===1&&T===0||y===0&&T===1)&&!w){const S=`${f.row},${f.col}-${v},${m}`;e.current={...e.current,playerPath:[...e.current.playerPath,{row:v,col:m}],visitCounts:{...e.current.visitCounts,[S]:(e.current.visitCounts[S]||0)+1}}}},u=()=>{if(a.current||!r.current)return;const p=e.current;if(!p.playerCell)return;const{canMove:g}=l(r.current,p.playerCell);g&&(a.current=!0)};M(()=>{const p=w=>{(w.key==="ArrowUp"||w.key==="ArrowDown"||w.key==="ArrowLeft"||w.key==="ArrowRight"||w.key===" ")&&w.preventDefault()},g=w=>{const y=w.key;y in X&&(w.preventDefault(),!a.current&&(r.current=y,u()))},v=w=>{w.key in X&&(w.preventDefault(),_())},m=w=>{w.preventDefault();const y=e.current;if(!y.isGameActive||!y.maze||a.current)return;const T=w.touches[0],b=document.elementFromPoint(T.clientX,T.clientY);let S=null;b&&(b.classList.contains("maze-up")?S="ArrowUp":b.classList.contains("maze-down")?S="ArrowDown":b.classList.contains("maze-left")?S="ArrowLeft":b.classList.contains("maze-right")&&(S="ArrowRight")),S&&(r.current=S,u())},f=()=>{_()};return window.addEventListener("keydown",p,{capture:!0}),window.addEventListener("keydown",g),window.addEventListener("keyup",v),t.current?.addEventListener("touchstart",m,{passive:!1}),t.current?.addEventListener("touchend",f),()=>{window.removeEventListener("keydown",p,{capture:!0}),window.removeEventListener("keydown",g),window.removeEventListener("keyup",v),t.current?.removeEventListener("touchstart",m),t.current?.removeEventListener("touchend",f)}},[]);const h=ut(()=>{if(!a.current||!r.current)return e.current.playerCell;const[p,g]=X[r.current],v=e.current.playerCell,m=Number((v.row+p*o).toFixed(2)),f=Number((v.col+g*o).toFixed(2)),{canMove:w}=l(r.current,v);if(!w)return e.current.playerCell;e.current.playerCell={row:m,col:f},c();const y=Math.round(v.row),T=Math.round(v.col),b=Math.round(m),S=Math.round(f);return(b!==y||S!==T)&&d({row:b,col:S}),e.current.playerCell},[o]),_=()=>{a.current=!1,r.current=null};return{updatePlayerPos:h,resetMovingState:_}};function Yt(t,e,n,o,i){const{row:s,col:a}=t,[r,l]=X[e],c=s+r*o,d=a+l*o,u={row:c,col:d},h=[],_=Math.floor(s),p=Math.floor(a);h.push({row:_,col:p});const v=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]].map(([m,f])=>({row:_+m,col:p+f}));for(const m of v)i.isValid(m.row,m.col)&&h.push(m);for(const m of h){const f=Xt(m.row,m.col,i);for(const w of f)if(Kt(u,w)<n)return!0}return!1}function Xt(t,e,n){const o=[],i=n.grid[t][e];return i.walls.top&&o.push({start:{row:t-.5,col:e-.5},end:{row:t-.5,col:e+.5}}),i.walls.right&&o.push({start:{row:t-.5,col:e+.5},end:{row:t+.5,col:e+.5}}),i.walls.bottom&&o.push({start:{row:t+.5,col:e-.5},end:{row:t+.5,col:e+.5}}),i.walls.left&&o.push({start:{row:t-.5,col:e-.5},end:{row:t+.5,col:e-.5}}),o}function Kt(t,e){const{start:n,end:o}=e,i=o.col-n.col,s=o.row-n.row,a=t.col-n.col,r=t.row-n.row,l=i*i+s*s;if(l===0)return Math.sqrt(a*a+r*r);const c=Math.max(0,Math.min(1,(a*i+r*s)/l)),d=n.col+c*i,u=n.row+c*s,h=t.col-d,_=t.row-u;return Math.sqrt(h*h+_*_)}function Jt(t,e,n,o,i){if(!t||!e.maze)return;const{canvasWidth:s,canvasHeight:a}=n,{cellWidth:r,cellHeight:l}=o,{maze:c,playerCell:d,exitCell:u,foodCells:h,showClue:_,playerPath:p,visitCounts:g,playerAtExit:v}=e,{padding:m,wallWidth:f,wallColor:w,playerColor:y,playerRadius:T,playerAtExitColor:b,exitColor:S,foodColor:A,backgroundColor:E,clueColor:P}=i;t.clearRect(0,0,s,a),t.save(),t.fillStyle=E,t.fillRect(0,0,s,a),t.restore(),_&&on({ctx:t,playerPath:p,visitCounts:g,cellWidth:r,cellHeight:l,padding:m,clueColor:P}),Zt({ctx:t,maze:c,cellWidth:r,cellHeight:l,padding:m,wallColor:w,wallWidth:f}),tn({ctx:t,foodCells:h,cellWidth:r,cellHeight:l,padding:m,foodColor:A}),v||en({ctx:t,exitCell:u,cellWidth:r,cellHeight:l,padding:m,playerRadius:T,exitColor:S}),Qt({ctx:t,playerCell:d,playerRadius:T,cellWidth:r,cellHeight:l,padding:m,playerColor:v?b:y})}function Zt({ctx:t,maze:e,cellWidth:n,cellHeight:o,padding:i,wallColor:s,wallWidth:a}){t.save(),t.strokeStyle=s,t.lineWidth=a,t.lineCap="round",t.beginPath(),rn(e,n,o,i).forEach(l=>{t.moveTo(l.x1,l.y1),t.lineTo(l.x2,l.y2)}),t.stroke(),t.restore()}function Qt({ctx:t,playerCell:e,playerRadius:n,cellWidth:o,cellHeight:i,padding:s,playerColor:a}){const{x:r,y:l}=K(e.row,e.col,o,i,s),c=Math.min(o,i)*Math.min(n,.5);t.save(),t.fillStyle=a,t.beginPath(),t.arc(r,l,c,0,Math.PI*2),t.fill(),t.restore()}function en({ctx:t,exitCell:e,cellWidth:n,cellHeight:o,padding:i,playerRadius:s,exitColor:a}){const{x:r,y:l}=K(e.row,e.col,n,o,i),c=Math.min(n,o)*Math.min(s,.5);t.save(),t.fillStyle=a,t.beginPath(),t.arc(r,l,c,0,Math.PI*2),t.fill(),t.restore()}function tn({ctx:t,foodCells:e,cellWidth:n,cellHeight:o,padding:i,foodColor:s}){t.fillStyle=s;const a=Math.min(n,o)*.25;e.forEach(r=>{const{x:l,y:c}=K(r.row,r.col,n,o,i);nn(t,l,c,a*1.2,5,a*.6)})}function nn(t,e,n,o,i,s){t.save(),t.beginPath();for(let a=0;a<i*2;a++){const r=a%2===0?o:s,l=Math.PI*a/i;t.lineTo(e+r*Math.sin(l),n+r*Math.cos(l))}t.closePath(),t.fill(),t.restore()}function on({ctx:t,playerPath:e,visitCounts:n,cellWidth:o,cellHeight:i,padding:s,clueColor:a}){if(!(!e||e.length<2||!n)){t.save();for(let r=1;r<e.length;r++){const l=e[r-1],c=e[r],d=`${l.row},${l.col}-${c.row},${c.col}`,u=`${c.row},${c.col}-${l.row},${l.col}`,h=(n[d]||0)+(n[u]||0),_=Math.min(.2+h*.1,.9),p=Math.max(3,o*.1)+h*.5;try{t.strokeStyle=a.replace(")",`, ${_})`).replace("rgb(","rgba(")}catch{t.strokeStyle=`rgba(255, 0, 0, ${_})`}t.lineWidth=p,t.lineCap="round",t.lineJoin="round";const{x:g,y:v}=K(l.row,l.col,o,i,s),{x:m,y:f}=K(c.row,c.col,o,i,s);t.beginPath(),t.moveTo(g,v),t.lineTo(m,f),t.stroke()}t.restore()}}function rn(t,e,n,o){const i=[];for(let s=0;s<t.rows;s++)for(let a=0;a<t.cols;a++){const r=t.grid[s][a],l=o+a*e,c=o+s*n;r.walls.top&&i.push({x1:l,y1:c,x2:l+e,y2:c}),r.walls.right&&i.push({x1:l+e,y1:c,x2:l+e,y2:c+n}),r.walls.bottom&&i.push({x1:l,y1:c+n,x2:l+e,y2:c+n}),r.walls.left&&i.push({x1:l,y1:c,x2:l,y2:c+n})}return i}function K(t,e,n,o,i){return{x:i+e*n+n/2,y:i+t*o+o/2}}function sn(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}class ln{constructor(e,n){this.row=e,this.col=n}visited=!1;walls={top:!0,right:!0,bottom:!0,left:!0}}class an{rows;cols;grid;seed;random;constructor(e,n,o,i,s={row:0,col:0},a={row:e-1,col:n-1}){this.rows=e,this.cols=n,this.seed=i??Math.floor(Math.random()*1e6),this.random=sn(this.seed),this.grid=this.initializeGrid(),this.generate(o,s,a)}initializeGrid(){const e=[];for(let n=0;n<this.rows;n++){e[n]=[];for(let o=0;o<this.cols;o++)e[n][o]=new ln(n,o)}return e}isValid(e,n){return e>=0&&e<this.rows&&n>=0&&n<this.cols}getNeighbors(e,n){const o=[],i=[{r:-1,c:0},{r:0,c:1},{r:1,c:0},{r:0,c:-1}];for(const s of i){const a=e+s.r,r=n+s.c;this.isValid(a,r)&&o.push({row:a,col:r})}return o}getUnvisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>!this.grid[o.row][o.col].visited)}getVisitedNeighbors(e,n){return this.getNeighbors(e,n).filter(o=>this.grid[o.row][o.col].visited)}removeWall(e,n,o,i){const s=this.grid[e][n],a=this.grid[o][i];e===o+1?(s.walls.top=!1,a.walls.bottom=!1):e===o-1?(s.walls.bottom=!1,a.walls.top=!1):n===i+1?(s.walls.left=!1,a.walls.right=!1):n===i-1&&(s.walls.right=!1,a.walls.left=!1)}generate(e,n={row:0,col:0},o={row:this.rows-1,col:this.cols-1}){switch(e){case"backtracking":this.generateWithBacktracking();break;case"prims":this.generateWithPrims();break;default:throw new Error(`Unknown maze generation method: ${e}`)}this.addOpenings(n,o)}generateWithBacktracking(){const e=[],n=this.randomNumber(this.rows),o=this.randomNumber(this.cols);let i={row:n,col:o};for(this.grid[n][o].visited=!0,e.push(i);e.length>0;){i=e[e.length-1];const{row:s,col:a}=i,r=this.getUnvisitedNeighbors(s,a);if(r.length>0){const l=this.randomPick(r),{row:c,col:d}=l;this.removeWall(s,a,c,d),this.grid[c][d].visited=!0,e.push(l)}else e.pop()}}generateWithPrims(){const e=[],n=(s,a)=>{const r=this.getNeighbors(s,a);for(const l of r)!this.grid[l.row][l.col].visited&&!e.some(c=>c.row===l.row&&c.col===l.col)&&e.push(l)},o=this.randomNumber(this.rows),i=this.randomNumber(this.cols);for(this.grid[o][i].visited=!0,n(o,i);e.length>0;){const s=this.randomNumber(e.length),a=e[s],{row:r,col:l}=a,c=this.getVisitedNeighbors(r,l);if(c.length>0){const d=this.randomPick(c);this.removeWall(r,l,d.row,d.col),this.grid[r][l].visited=!0,n(r,l)}e.splice(s,1)}}addOpenings(e,n){this.grid[e.row][e.col].walls.top=!1,this.grid[n.row][n.col].walls.bottom=!1}randomNumber(e){return Math.floor(this.random()*e)}randomPick(e){return e[Math.floor(this.random()*e.length)]}}const cn=(t,e,n)=>{if(!t.isValid(e,n))return!1;const o=t.grid[e][n];return!o.walls.top||!o.walls.right||!o.walls.bottom||!o.walls.left},un=t=>t===1?2:t>=2&&t<=5?3:t>=6&&t<=11?4:t>=12&&t<=15?5:6,dn=(t,e)=>{if(!e)return console.error(`Cannot find Level ${t}'s config.`),null;const{size:n,seed:o,method:i,entry:s,exit:a}=e,r=n,l=n,c=s||{row:0,col:0},d=a||{row:r-1,col:l-1},u=new an(r,l,i,o,s,a),h=un(t),_=[];for(let p=0;p<h;p++){let g;do g={row:Math.floor(u.random()*r),col:Math.floor(u.random()*l)};while(g.row===c.row&&g.col===c.col||g.row===d.row&&g.col===d.col||!cn(u,g.row,g.col)||_.some(v=>v.row===g.row&&v.col===g.col));_.push(g)}return{isGameActive:!0,levelTransitioning:!1,maze:u,playerCell:c,exitCell:d,foodCells:_,playerAtExit:!1,foodCollected:0,totalFoodCount:h,showClue:!1,playerPath:[c],visitCounts:{[`${c.row},${c.col}`]:1}}};function hn(){const{setGamePlayState:t,gamePlayStateRef:e,gameProgress:n,config:o}=H(),i=I(null),s=I(null),a=I(null),{i18n:r,levelConfig:l,renderConfig:c}=o,d=Y(l),u=I(d.getLevelConfig(n.currentLevel));M(()=>{i.current&&F.attachTo(i.current)},[]);const h=qt(a),_=Bt(a);M(()=>{u.current=d.getLevelConfig(n.currentLevel)},[n.currentLevel]);const p=()=>{const f=dn(n.currentLevel,u.current);f&&t(w=>({...w,...f}))};M(()=>{p()},[n.currentLevel]);const g=()=>{p()},{updatePlayerPos:v,resetMovingState:m}=Vt({containerRef:s,gamePlayStateRef:e,setGamePlayState:t,playerRadius:c.playerRadius,moveSpeed:c.gridMoveSpeed,onFoodCollected:()=>{const f=e.current.totalFoodCount-e.current.foodCollected-1;f>0?F.show(r.foodCollectedToast.replace("%NUM%",f.toString()),"success",3e3):F.show(r.allFoodCollectedToast,"success")}});return M(()=>{m()},[n.currentLevel,m]),M(()=>{let f;const w=()=>{const y=a.current?.getContext("2d");if(!y||!e.current?.maze){f=requestAnimationFrame(w);return}const T=u.current?.wallWidth||c?.wallWidth;v(),Jt(y,e.current,h.current,_.current,{...c,wallWidth:T}),f=requestAnimationFrame(w)};return f=requestAnimationFrame(w),()=>{cancelAnimationFrame(f)}},[]),M(()=>{F.show(r.useArrowKeyTips,"info",3e3)},[]),C("div",{className:"maze-game-container",ref:i,children:[C(gt,{}),C(Ht,{onRetry:g}),C("div",{className:"maze-canvas-container",ref:s,children:[C("canvas",{ref:a,className:"maze-game-canvas"}),C("div",{className:"maze-touch-area maze-up"}),C("div",{className:"maze-touch-area maze-down"}),C("div",{className:"maze-touch-area maze-left"}),C("div",{className:"maze-touch-area maze-right"})]})]})}const Qe=[[{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"}]],le={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:{gridMoveSpeed:.03,padding:10,wallWidth:2,wallColor:"#000000",exitColor:"#F44336",foodColor:"#4CAF50",clueColor:"rgb(255,0,0)",backgroundColor:"#ffffff",playerColor:"#4CAF50",playerAtExitColor:"#FFD700",playerRadius:.2},levelConfig:Qe};function _n({config:t={}}){const e={...le.i18n,...t.i18n||{}},n={...le.renderConfig,...t.renderConfig||{}},o=t.levelConfig||Qe,i={...le,...t,i18n:e,levelConfig:o,renderConfig:n};return C(mt,{config:i,children:C(hn,{})})}const fn={root:"https://unpkg.com/@roudanio/maze@0.0.11/dist/",...le};return`${JSON.stringify(fn,null,2)}`,{async init(t,e){const n=typeof t=="string"?document.querySelector(t):t;if(!n){console.warn("Cannot find the root element");const l=document.createElement("div");l.style.textAlign="center",l.style.padding="20px",l.innerHTML="Cannot find the root element",document.body.append(l);return}let{root:o=location.origin}=e;o.at(-1)!=="/"&&(o+="/");const i=document.createElement("div"),s=document.createElement("div");i.style.cssText=`
|
|
2
2
|
height: 30px;
|
|
3
3
|
width: 100%;
|
|
4
4
|
border: solid 2px #999;
|
|
5
5
|
margin: 20% auto;
|
|
6
|
-
`,
|
|
6
|
+
`,s.style.cssText=`
|
|
7
7
|
width: 99%;
|
|
8
8
|
height: 100%;
|
|
9
9
|
background: #999;
|
|
10
10
|
animation: loading 1.5s ease-in-out;
|
|
11
11
|
transition: width 1.5s ease-in-out;
|
|
12
12
|
transition: width 1.5s ease-in-out;
|
|
13
|
-
`,i.append(
|
|
13
|
+
`,i.append(s),n.append(i);const a=document.createElement("style");a.innerHTML=`
|
|
14
14
|
@keyframes loading {
|
|
15
15
|
0% { width: 0%; }
|
|
16
16
|
100% { width: 99%; }
|
|
17
|
-
}`,document.head.appendChild(
|
|
17
|
+
}`,document.head.appendChild(a),await(async l=>new Promise((c,d)=>{const u=document.createElement("link");u.rel="stylesheet",u.type="text/css",u.href=l,u.onload=c,u.onerror=d,document.head.appendChild(u)}))(o+"maze.css"),st(C(_n,{config:e}),n)}}}();
|