@roudanio/maze 0.0.1

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.js ADDED
@@ -0,0 +1,1573 @@
1
+ var j, C, xe, G, fe, Le, oe, Ne, le, ne, re, Se, W = {}, Me = [], Je = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, ce = Array.isArray;
2
+ function A(t, e) {
3
+ for (var o in e) t[o] = e[o];
4
+ return t;
5
+ }
6
+ function ae(t) {
7
+ t && t.parentNode && t.parentNode.removeChild(t);
8
+ }
9
+ function Qe(t, e, o) {
10
+ var n, r, s, i = {};
11
+ for (s in e) s == "key" ? n = e[s] : s == "ref" ? r = e[s] : i[s] = e[s];
12
+ if (arguments.length > 2 && (i.children = arguments.length > 3 ? j.call(arguments, 2) : o), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) i[s] === void 0 && (i[s] = t.defaultProps[s]);
13
+ return q(t, i, n, r, null);
14
+ }
15
+ function q(t, e, o, n, r) {
16
+ var s = { type: t, props: e, key: o, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: r ?? ++xe, __i: -1, __u: 0 };
17
+ return r == null && C.vnode != null && C.vnode(s), s;
18
+ }
19
+ function J(t) {
20
+ return t.children;
21
+ }
22
+ function K(t, e) {
23
+ this.props = t, this.context = e;
24
+ }
25
+ function D(t, e) {
26
+ if (e == null) return t.__ ? D(t.__, t.__i + 1) : null;
27
+ for (var o; e < t.__k.length; e++) if ((o = t.__k[e]) != null && o.__e != null) return o.__e;
28
+ return typeof t.type == "function" ? D(t) : null;
29
+ }
30
+ function $e(t) {
31
+ var e, o;
32
+ if ((t = t.__) != null && t.__c != null) {
33
+ for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((o = t.__k[e]) != null && o.__e != null) {
34
+ t.__e = t.__c.base = o.__e;
35
+ break;
36
+ }
37
+ return $e(t);
38
+ }
39
+ }
40
+ function se(t) {
41
+ (!t.__d && (t.__d = !0) && G.push(t) && !X.__r++ || fe !== C.debounceRendering) && ((fe = C.debounceRendering) || Le)(X);
42
+ }
43
+ function X() {
44
+ var t, e, o, n, r, s, i, c;
45
+ for (G.sort(oe); t = G.shift(); ) t.__d && (e = G.length, n = void 0, s = (r = (o = t).__v).__e, i = [], c = [], o.__P && ((n = A({}, r)).__v = r.__v + 1, C.vnode && C.vnode(n), de(o.__P, n, r, o.__n, o.__P.namespaceURI, 32 & r.__u ? [s] : null, i, s ?? D(r), !!(32 & r.__u), c), n.__v = r.__v, n.__.__k[n.__i] = n, Ue(i, n, c), n.__e != s && $e(n)), G.length > e && G.sort(oe));
46
+ X.__r = 0;
47
+ }
48
+ function Ae(t, e, o, n, r, s, i, c, a, d, _) {
49
+ var l, h, u, m, w, g, v = n && n.__k || Me, p = e.length;
50
+ for (a = Ze(o, e, v, a, p), l = 0; l < p; l++) (u = o.__k[l]) != null && (h = u.__i === -1 ? W : v[u.__i] || W, u.__i = l, g = de(t, u, h, r, s, i, c, a, d, _), m = u.__e, u.ref && h.ref != u.ref && (h.ref && _e(h.ref, null, u), _.push(u.ref, u.__c || m, u)), w == null && m != null && (w = m), 4 & u.__u || h.__k === u.__k ? a = Ee(u, a, t) : typeof u.type == "function" && g !== void 0 ? a = g : m && (a = m.nextSibling), u.__u &= -7);
51
+ return o.__e = w, a;
52
+ }
53
+ function Ze(t, e, o, n, r) {
54
+ var s, i, c, a, d, _ = o.length, l = _, h = 0;
55
+ for (t.__k = new Array(r), s = 0; s < r; s++) (i = e[s]) != null && typeof i != "boolean" && typeof i != "function" ? (a = s + h, (i = t.__k[s] = typeof i == "string" || typeof i == "number" || typeof i == "bigint" || i.constructor == String ? q(null, i, null, null, null) : ce(i) ? q(J, { children: i }, null, null, null) : i.constructor === void 0 && i.__b > 0 ? q(i.type, i.props, i.key, i.ref ? i.ref : null, i.__v) : i).__ = t, i.__b = t.__b + 1, c = null, (d = i.__i = et(i, o, a, l)) !== -1 && (l--, (c = o[d]) && (c.__u |= 2)), c == null || c.__v === null ? (d == -1 && h--, typeof i.type != "function" && (i.__u |= 4)) : d != a && (d == a - 1 ? h-- : d == a + 1 ? h++ : (d > a ? h-- : h++, i.__u |= 4))) : t.__k[s] = null;
56
+ if (l) for (s = 0; s < _; s++) (c = o[s]) != null && !(2 & c.__u) && (c.__e == n && (n = D(c)), Fe(c, c));
57
+ return n;
58
+ }
59
+ function Ee(t, e, o) {
60
+ var n, r;
61
+ if (typeof t.type == "function") {
62
+ for (n = t.__k, r = 0; n && r < n.length; r++) n[r] && (n[r].__ = t, e = Ee(n[r], e, o));
63
+ return e;
64
+ }
65
+ t.__e != e && (e && t.type && !o.contains(e) && (e = D(t)), o.insertBefore(t.__e, e || null), e = t.__e);
66
+ do
67
+ e = e && e.nextSibling;
68
+ while (e != null && e.nodeType == 8);
69
+ return e;
70
+ }
71
+ function et(t, e, o, n) {
72
+ var r, s, i = t.key, c = t.type, a = e[o];
73
+ if (a === null || a && i == a.key && c === a.type && !(2 & a.__u)) return o;
74
+ if (n > (a != null && !(2 & a.__u) ? 1 : 0)) for (r = o - 1, s = o + 1; r >= 0 || s < e.length; ) {
75
+ if (r >= 0) {
76
+ if ((a = e[r]) && !(2 & a.__u) && i == a.key && c === a.type) return r;
77
+ r--;
78
+ }
79
+ if (s < e.length) {
80
+ if ((a = e[s]) && !(2 & a.__u) && i == a.key && c === a.type) return s;
81
+ s++;
82
+ }
83
+ }
84
+ return -1;
85
+ }
86
+ function me(t, e, o) {
87
+ e[0] == "-" ? t.setProperty(e, o ?? "") : t[e] = o == null ? "" : typeof o != "number" || Je.test(e) ? o : o + "px";
88
+ }
89
+ function B(t, e, o, n, r) {
90
+ var s;
91
+ e: if (e == "style") if (typeof o == "string") t.style.cssText = o;
92
+ else {
93
+ if (typeof n == "string" && (t.style.cssText = n = ""), n) for (e in n) o && e in o || me(t.style, e, "");
94
+ if (o) for (e in o) n && o[e] === n[e] || me(t.style, e, o[e]);
95
+ }
96
+ else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(Ne, "$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] = o, o ? n ? o.u = n.u : (o.u = le, t.addEventListener(e, s ? re : ne, s)) : t.removeEventListener(e, s ? re : ne, s);
97
+ else {
98
+ if (r == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
99
+ 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 {
100
+ t[e] = o ?? "";
101
+ break e;
102
+ } catch {
103
+ }
104
+ typeof o == "function" || (o == null || o === !1 && e[4] != "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && o == 1 ? "" : o));
105
+ }
106
+ }
107
+ function pe(t) {
108
+ return function(e) {
109
+ if (this.l) {
110
+ var o = this.l[e.type + t];
111
+ if (e.t == null) e.t = le++;
112
+ else if (e.t < o.u) return;
113
+ return o(C.event ? C.event(e) : e);
114
+ }
115
+ };
116
+ }
117
+ function de(t, e, o, n, r, s, i, c, a, d) {
118
+ var _, l, h, u, m, w, g, v, p, b, z, S, P, U, M, $, L, x = e.type;
119
+ if (e.constructor !== void 0) return null;
120
+ 128 & o.__u && (a = !!(32 & o.__u), s = [c = e.__e = o.__e]), (_ = C.__b) && _(e);
121
+ e: if (typeof x == "function") try {
122
+ if (v = e.props, p = "prototype" in x && x.prototype.render, b = (_ = x.contextType) && n[_.__c], z = _ ? b ? b.props.value : _.__ : n, o.__c ? g = (l = e.__c = o.__c).__ = l.__E : (p ? e.__c = l = new x(v, z) : (e.__c = l = new K(v, z), l.constructor = x, l.render = ot), b && b.sub(l), l.props = v, l.state || (l.state = {}), l.context = z, l.__n = n, h = l.__d = !0, l.__h = [], l._sb = []), p && l.__s == null && (l.__s = l.state), p && x.getDerivedStateFromProps != null && (l.__s == l.state && (l.__s = A({}, l.__s)), A(l.__s, x.getDerivedStateFromProps(v, l.__s))), u = l.props, m = l.state, l.__v = e, h) p && x.getDerivedStateFromProps == null && l.componentWillMount != null && l.componentWillMount(), p && l.componentDidMount != null && l.__h.push(l.componentDidMount);
123
+ else {
124
+ if (p && x.getDerivedStateFromProps == null && v !== u && l.componentWillReceiveProps != null && l.componentWillReceiveProps(v, z), !l.__e && (l.shouldComponentUpdate != null && l.shouldComponentUpdate(v, l.__s, z) === !1 || e.__v == o.__v)) {
125
+ for (e.__v != o.__v && (l.props = v, l.state = l.__s, l.__d = !1), e.__e = o.__e, e.__k = o.__k, e.__k.some(function(F) {
126
+ F && (F.__ = e);
127
+ }), S = 0; S < l._sb.length; S++) l.__h.push(l._sb[S]);
128
+ l._sb = [], l.__h.length && i.push(l);
129
+ break e;
130
+ }
131
+ l.componentWillUpdate != null && l.componentWillUpdate(v, l.__s, z), p && l.componentDidUpdate != null && l.__h.push(function() {
132
+ l.componentDidUpdate(u, m, w);
133
+ });
134
+ }
135
+ if (l.context = z, l.props = v, l.__P = t, l.__e = !1, P = C.__r, U = 0, p) {
136
+ for (l.state = l.__s, l.__d = !1, P && P(e), _ = l.render(l.props, l.state, l.context), M = 0; M < l._sb.length; M++) l.__h.push(l._sb[M]);
137
+ l._sb = [];
138
+ } else do
139
+ l.__d = !1, P && P(e), _ = l.render(l.props, l.state, l.context), l.state = l.__s;
140
+ while (l.__d && ++U < 25);
141
+ l.state = l.__s, l.getChildContext != null && (n = A(A({}, n), l.getChildContext())), p && !h && l.getSnapshotBeforeUpdate != null && (w = l.getSnapshotBeforeUpdate(u, m)), c = Ae(t, ce($ = _ != null && _.type === J && _.key == null ? _.props.children : _) ? $ : [$], e, o, n, r, s, i, c, a, d), l.base = e.__e, e.__u &= -161, l.__h.length && i.push(l), g && (l.__E = l.__ = null);
142
+ } catch (F) {
143
+ if (e.__v = null, a || s != null) if (F.then) {
144
+ for (e.__u |= a ? 160 : 128; c && c.nodeType == 8 && c.nextSibling; ) c = c.nextSibling;
145
+ s[s.indexOf(c)] = null, e.__e = c;
146
+ } else for (L = s.length; L--; ) ae(s[L]);
147
+ else e.__e = o.__e, e.__k = o.__k;
148
+ C.__e(F, e, o);
149
+ }
150
+ else s == null && e.__v == o.__v ? (e.__k = o.__k, e.__e = o.__e) : c = e.__e = tt(o.__e, e, o, n, r, s, i, a, d);
151
+ return (_ = C.diffed) && _(e), 128 & e.__u ? void 0 : c;
152
+ }
153
+ function Ue(t, e, o) {
154
+ for (var n = 0; n < o.length; n++) _e(o[n], o[++n], o[++n]);
155
+ C.__c && C.__c(e, t), t.some(function(r) {
156
+ try {
157
+ t = r.__h, r.__h = [], t.some(function(s) {
158
+ s.call(r);
159
+ });
160
+ } catch (s) {
161
+ C.__e(s, r.__v);
162
+ }
163
+ });
164
+ }
165
+ function tt(t, e, o, n, r, s, i, c, a) {
166
+ var d, _, l, h, u, m, w, g = o.props, v = e.props, p = e.type;
167
+ if (p == "svg" ? r = "http://www.w3.org/2000/svg" : p == "math" ? r = "http://www.w3.org/1998/Math/MathML" : r || (r = "http://www.w3.org/1999/xhtml"), s != null) {
168
+ for (d = 0; d < s.length; d++) if ((u = s[d]) && "setAttribute" in u == !!p && (p ? u.localName == p : u.nodeType == 3)) {
169
+ t = u, s[d] = null;
170
+ break;
171
+ }
172
+ }
173
+ if (t == null) {
174
+ if (p == null) return document.createTextNode(v);
175
+ t = document.createElementNS(r, p, v.is && v), c && (C.__m && C.__m(e, s), c = !1), s = null;
176
+ }
177
+ if (p === null) g === v || c && t.data === v || (t.data = v);
178
+ else {
179
+ if (s = s && j.call(t.childNodes), g = o.props || W, !c && s != null) for (g = {}, d = 0; d < t.attributes.length; d++) g[(u = t.attributes[d]).name] = u.value;
180
+ for (d in g) if (u = g[d], d != "children") {
181
+ if (d == "dangerouslySetInnerHTML") l = u;
182
+ else if (!(d in v)) {
183
+ if (d == "value" && "defaultValue" in v || d == "checked" && "defaultChecked" in v) continue;
184
+ B(t, d, null, u, r);
185
+ }
186
+ }
187
+ for (d in v) u = v[d], d == "children" ? h = u : d == "dangerouslySetInnerHTML" ? _ = u : d == "value" ? m = u : d == "checked" ? w = u : c && typeof u != "function" || g[d] === u || B(t, d, u, g[d], r);
188
+ if (_) c || l && (_.__html === l.__html || _.__html === t.innerHTML) || (t.innerHTML = _.__html), e.__k = [];
189
+ else if (l && (t.innerHTML = ""), Ae(t, ce(h) ? h : [h], e, o, n, p == "foreignObject" ? "http://www.w3.org/1999/xhtml" : r, s, i, s ? s[0] : o.__k && D(o, 0), c, a), s != null) for (d = s.length; d--; ) ae(s[d]);
190
+ c || (d = "value", p == "progress" && m == null ? t.removeAttribute("value") : m !== void 0 && (m !== t[d] || p == "progress" && !m || p == "option" && m !== g[d]) && B(t, d, m, g[d], r), d = "checked", w !== void 0 && w !== t[d] && B(t, d, w, g[d], r));
191
+ }
192
+ return t;
193
+ }
194
+ function _e(t, e, o) {
195
+ try {
196
+ if (typeof t == "function") {
197
+ var n = typeof t.__u == "function";
198
+ n && t.__u(), n && e == null || (t.__u = t(e));
199
+ } else t.current = e;
200
+ } catch (r) {
201
+ C.__e(r, o);
202
+ }
203
+ }
204
+ function Fe(t, e, o) {
205
+ var n, r;
206
+ if (C.unmount && C.unmount(t), (n = t.ref) && (n.current && n.current !== t.__e || _e(n, null, e)), (n = t.__c) != null) {
207
+ if (n.componentWillUnmount) try {
208
+ n.componentWillUnmount();
209
+ } catch (s) {
210
+ C.__e(s, e);
211
+ }
212
+ n.base = n.__P = null;
213
+ }
214
+ if (n = t.__k) for (r = 0; r < n.length; r++) n[r] && Fe(n[r], e, o || typeof t.type != "function");
215
+ o || ae(t.__e), t.__c = t.__ = t.__e = void 0;
216
+ }
217
+ function ot(t, e, o) {
218
+ return this.constructor(t, o);
219
+ }
220
+ function nt(t, e, o) {
221
+ var n, r, s, i;
222
+ e == document && (e = document.documentElement), C.__ && C.__(t, e), r = (n = !1) ? null : e.__k, s = [], i = [], de(e, t = e.__k = Qe(J, null, [t]), r || W, W, e.namespaceURI, r ? null : e.firstChild ? j.call(e.childNodes) : null, s, r ? r.__e : e.firstChild, n, i), Ue(s, t, i);
223
+ }
224
+ function Ge(t, e) {
225
+ var o = { __c: e = "__cC" + Se++, __: t, Consumer: function(n, r) {
226
+ return n.children(r);
227
+ }, Provider: function(n) {
228
+ var r, s;
229
+ return this.getChildContext || (r = /* @__PURE__ */ new Set(), (s = {})[e] = this, this.getChildContext = function() {
230
+ return s;
231
+ }, this.componentWillUnmount = function() {
232
+ r = null;
233
+ }, this.shouldComponentUpdate = function(i) {
234
+ this.props.value !== i.value && r.forEach(function(c) {
235
+ c.__e = !0, se(c);
236
+ });
237
+ }, this.sub = function(i) {
238
+ r.add(i);
239
+ var c = i.componentWillUnmount;
240
+ i.componentWillUnmount = function() {
241
+ r && r.delete(i), c && c.call(i);
242
+ };
243
+ }), n.children;
244
+ } };
245
+ return o.Provider.__ = o.Consumer.contextType = o;
246
+ }
247
+ j = Me.slice, C = { __e: function(t, e, o, n) {
248
+ for (var r, s, i; e = e.__; ) if ((r = e.__c) && !r.__) try {
249
+ if ((s = r.constructor) && s.getDerivedStateFromError != null && (r.setState(s.getDerivedStateFromError(t)), i = r.__d), r.componentDidCatch != null && (r.componentDidCatch(t, n || {}), i = r.__d), i) return r.__E = r;
250
+ } catch (c) {
251
+ t = c;
252
+ }
253
+ throw t;
254
+ } }, xe = 0, K.prototype.setState = function(t, e) {
255
+ var o;
256
+ o = this.__s != null && this.__s !== this.state ? this.__s : this.__s = A({}, this.state), typeof t == "function" && (t = t(A({}, o), this.props)), t && A(o, t), t != null && this.__v && (e && this._sb.push(e), se(this));
257
+ }, K.prototype.forceUpdate = function(t) {
258
+ this.__v && (this.__e = !0, t && this.__h.push(t), se(this));
259
+ }, K.prototype.render = J, G = [], Le = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, oe = function(t, e) {
260
+ return t.__v.__b - e.__v.__b;
261
+ }, X.__r = 0, Ne = /(PointerCapture)$|Capture$/i, le = 0, ne = pe(!1), re = pe(!0), Se = 0;
262
+ var rt = 0;
263
+ function f(t, e, o, n, r, s) {
264
+ e || (e = {});
265
+ var i, c, a = e;
266
+ if ("ref" in a) for (c in a = {}, e) c == "ref" ? i = e[c] : a[c] = e[c];
267
+ var d = { type: t, props: a, key: o, ref: i, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --rt, __i: -1, __u: 0, __source: r, __self: s };
268
+ if (typeof t == "function" && (i = t.defaultProps)) for (c in i) a[c] === void 0 && (a[c] = i[c]);
269
+ return C.vnode && C.vnode(d), d;
270
+ }
271
+ var H, y, Z, ve, I = 0, De = [], k = C, ge = k.__b, we = k.__r, Ce = k.diffed, ye = k.__c, ke = k.unmount, be = k.__;
272
+ function Q(t, e) {
273
+ k.__h && k.__h(y, t, I || e), I = 0;
274
+ var o = y.__H || (y.__H = { __: [], __h: [] });
275
+ return t >= o.__.length && o.__.push({}), o.__[t];
276
+ }
277
+ function E(t) {
278
+ return I = 1, st(Ie, t);
279
+ }
280
+ function st(t, e, o) {
281
+ var n = Q(H++, 2);
282
+ if (n.t = t, !n.__c && (n.__ = [Ie(void 0, e), function(c) {
283
+ var a = n.__N ? n.__N[0] : n.__[0], d = n.t(a, c);
284
+ a !== d && (n.__N = [d, n.__[1]], n.__c.setState({}));
285
+ }], n.__c = y, !y.u)) {
286
+ var r = function(c, a, d) {
287
+ if (!n.__c.__H) return !0;
288
+ var _ = n.__c.__H.__.filter(function(h) {
289
+ return !!h.__c;
290
+ });
291
+ if (_.every(function(h) {
292
+ return !h.__N;
293
+ })) return !s || s.call(this, c, a, d);
294
+ var l = n.__c.props !== c;
295
+ return _.forEach(function(h) {
296
+ if (h.__N) {
297
+ var u = h.__[0];
298
+ h.__ = h.__N, h.__N = void 0, u !== h.__[0] && (l = !0);
299
+ }
300
+ }), s && s.call(this, c, a, d) || l;
301
+ };
302
+ y.u = !0;
303
+ var s = y.shouldComponentUpdate, i = y.componentWillUpdate;
304
+ y.componentWillUpdate = function(c, a, d) {
305
+ if (this.__e) {
306
+ var _ = s;
307
+ s = void 0, r(c, a, d), s = _;
308
+ }
309
+ i && i.call(this, c, a, d);
310
+ }, y.shouldComponentUpdate = r;
311
+ }
312
+ return n.__N || n.__;
313
+ }
314
+ function N(t, e) {
315
+ var o = Q(H++, 3);
316
+ !k.__s && We(o.__H, e) && (o.__ = t, o.i = e, y.__H.__h.push(o));
317
+ }
318
+ function R(t) {
319
+ return I = 5, He(function() {
320
+ return { current: t };
321
+ }, []);
322
+ }
323
+ function He(t, e) {
324
+ var o = Q(H++, 7);
325
+ return We(o.__H, e) && (o.__ = t(), o.__H = e, o.__h = t), o.__;
326
+ }
327
+ function ze(t, e) {
328
+ return I = 8, He(function() {
329
+ return t;
330
+ }, e);
331
+ }
332
+ function Re(t) {
333
+ var e = y.context[t.__c], o = Q(H++, 9);
334
+ return o.c = t, e ? (o.__ == null && (o.__ = !0, e.sub(y)), e.props.value) : t.__;
335
+ }
336
+ function it() {
337
+ for (var t; t = De.shift(); ) if (t.__P && t.__H) try {
338
+ t.__H.__h.forEach(Y), t.__H.__h.forEach(ie), t.__H.__h = [];
339
+ } catch (e) {
340
+ t.__H.__h = [], k.__e(e, t.__v);
341
+ }
342
+ }
343
+ k.__b = function(t) {
344
+ y = null, ge && ge(t);
345
+ }, k.__ = function(t, e) {
346
+ t && e.__k && e.__k.__m && (t.__m = e.__k.__m), be && be(t, e);
347
+ }, k.__r = function(t) {
348
+ we && we(t), H = 0;
349
+ var e = (y = t.__c).__H;
350
+ e && (Z === y ? (e.__h = [], y.__h = [], e.__.forEach(function(o) {
351
+ o.__N && (o.__ = o.__N), o.i = o.__N = void 0;
352
+ })) : (e.__h.forEach(Y), e.__h.forEach(ie), e.__h = [], H = 0)), Z = y;
353
+ }, k.diffed = function(t) {
354
+ Ce && Ce(t);
355
+ var e = t.__c;
356
+ e && e.__H && (e.__H.__h.length && (De.push(e) !== 1 && ve === k.requestAnimationFrame || ((ve = k.requestAnimationFrame) || lt)(it)), e.__H.__.forEach(function(o) {
357
+ o.i && (o.__H = o.i), o.i = void 0;
358
+ })), Z = y = null;
359
+ }, k.__c = function(t, e) {
360
+ e.some(function(o) {
361
+ try {
362
+ o.__h.forEach(Y), o.__h = o.__h.filter(function(n) {
363
+ return !n.__ || ie(n);
364
+ });
365
+ } catch (n) {
366
+ e.some(function(r) {
367
+ r.__h && (r.__h = []);
368
+ }), e = [], k.__e(n, o.__v);
369
+ }
370
+ }), ye && ye(t, e);
371
+ }, k.unmount = function(t) {
372
+ ke && ke(t);
373
+ var e, o = t.__c;
374
+ o && o.__H && (o.__H.__.forEach(function(n) {
375
+ try {
376
+ Y(n);
377
+ } catch (r) {
378
+ e = r;
379
+ }
380
+ }), o.__H = void 0, e && k.__e(e, o.__v));
381
+ };
382
+ var Te = typeof requestAnimationFrame == "function";
383
+ function lt(t) {
384
+ var e, o = function() {
385
+ clearTimeout(n), Te && cancelAnimationFrame(e), setTimeout(t);
386
+ }, n = setTimeout(o, 100);
387
+ Te && (e = requestAnimationFrame(o));
388
+ }
389
+ function Y(t) {
390
+ var e = y, o = t.__c;
391
+ typeof o == "function" && (t.__c = void 0, o()), y = e;
392
+ }
393
+ function ie(t) {
394
+ var e = y;
395
+ t.__c = t.__(), y = e;
396
+ }
397
+ function We(t, e) {
398
+ return !t || t.length !== e.length || e.some(function(o, n) {
399
+ return o !== t[n];
400
+ });
401
+ }
402
+ function Ie(t, e) {
403
+ return typeof e == "function" ? e(t) : e;
404
+ }
405
+ const ct = (t) => ({
406
+ saveGameData(e) {
407
+ try {
408
+ const o = {
409
+ highestUnlockedLevel: e.highestUnlockedLevel,
410
+ levelScores: e.levelScores,
411
+ totalScore: e.totalScore,
412
+ currentLevel: e.currentLevel
413
+ };
414
+ localStorage.setItem(t, JSON.stringify(o));
415
+ } catch (o) {
416
+ console.error("Failed to save maze game data:", o);
417
+ }
418
+ },
419
+ loadGameData() {
420
+ try {
421
+ const e = localStorage.getItem(t);
422
+ if (!e) return null;
423
+ const o = JSON.parse(e);
424
+ return {
425
+ highestUnlockedLevel: o.highestUnlockedLevel,
426
+ levelScores: o.levelScores,
427
+ totalScore: o.totalScore,
428
+ currentLevel: o.currentLevel,
429
+ currentTier: Math.ceil(o.currentLevel / 12),
430
+ highestUnlockedTier: Math.ceil(o.highestUnlockedLevel / 12)
431
+ };
432
+ } catch (e) {
433
+ return console.error("Failed to load maze game data:", e), null;
434
+ }
435
+ },
436
+ resetGameData() {
437
+ try {
438
+ localStorage.removeItem(t);
439
+ } catch (e) {
440
+ console.error("Failed to reset game state:", e);
441
+ }
442
+ }
443
+ }), Oe = Ge(void 0), at = ({ children: t, config: e }) => {
444
+ const o = R(e), n = ct(e.lcPrefix + "score"), r = n.loadGameData(), [s, i] = E({
445
+ currentLevel: 1,
446
+ highestUnlockedLevel: 1,
447
+ currentTier: 1,
448
+ highestUnlockedTier: 1,
449
+ currentScore: 0,
450
+ totalScore: 0,
451
+ levelScores: {},
452
+ isGameActive: !0,
453
+ levelTransitioning: !1,
454
+ maze: null,
455
+ playerPosition: { row: 0, col: 0 },
456
+ exitPosition: { row: 0, col: 0 },
457
+ foodPositions: [],
458
+ playerPath: [],
459
+ visitCounts: {},
460
+ moveCount: 0,
461
+ playerAtExit: !1,
462
+ foodCollected: 0,
463
+ totalFoodCount: 0,
464
+ showClue: !1,
465
+ ...r || {}
466
+ });
467
+ N(() => {
468
+ n.saveGameData(s);
469
+ }, [
470
+ s.highestUnlockedLevel,
471
+ s.levelScores,
472
+ s.totalScore,
473
+ s.currentLevel
474
+ ]);
475
+ const c = () => {
476
+ n.resetGameData(), i((a) => ({
477
+ ...a,
478
+ currentLevel: 1,
479
+ highestUnlockedLevel: 1,
480
+ currentTier: 1,
481
+ highestUnlockedTier: 1,
482
+ currentScore: 0,
483
+ totalScore: 0,
484
+ levelScores: {},
485
+ isGameActive: !0,
486
+ levelTransitioning: !1,
487
+ playerPath: [],
488
+ visitCounts: {},
489
+ moveCount: 0,
490
+ foodCollected: 0,
491
+ showClue: !1
492
+ }));
493
+ };
494
+ return /* @__PURE__ */ f(
495
+ Oe.Provider,
496
+ {
497
+ value: {
498
+ gameState: s,
499
+ setGameState: i,
500
+ config: o,
501
+ resetGame: c
502
+ },
503
+ children: t
504
+ }
505
+ );
506
+ }, Ve = () => {
507
+ const t = Re(Oe);
508
+ if (!t)
509
+ throw new Error("useGameContext must be used within a GameProvider");
510
+ return t;
511
+ }, Be = Ge(void 0), dt = ({ children: t }) => {
512
+ const [e, o] = E(null), [n, r] = E(!1), [s, i] = E(
513
+ "info"
514
+ ), [c, a] = E(null), d = ze(() => {
515
+ r(!1), c && (clearTimeout(c), a(null));
516
+ }, [c]), _ = ze(
517
+ (l, h = "info", u = 3e3) => {
518
+ if (n && d(), o(l), i(h), r(!0), u > 0) {
519
+ const m = setTimeout(() => {
520
+ r(!1);
521
+ }, u);
522
+ a(m);
523
+ }
524
+ },
525
+ [n, d]
526
+ );
527
+ return /* @__PURE__ */ f(
528
+ Be.Provider,
529
+ {
530
+ value: { message: e, visible: n, type: s, showToast: _, hideToast: d },
531
+ children: t
532
+ }
533
+ );
534
+ }, ue = () => {
535
+ const t = Re(Be);
536
+ if (!t)
537
+ throw new Error("useToast must be used within a ToastProvider");
538
+ return t;
539
+ }, _t = ({
540
+ i18n: t,
541
+ totalTiers: e,
542
+ currentTier: o,
543
+ highestUnlockedTier: n,
544
+ onTierChange: r,
545
+ disabled: s
546
+ }) => /* @__PURE__ */ f("div", { className: "tier-selector", children: /* @__PURE__ */ f(
547
+ "select",
548
+ {
549
+ value: o,
550
+ onChange: (i) => {
551
+ i.target && i.target.value && r(Number(i.target.value));
552
+ },
553
+ disabled: s,
554
+ className: "tier-dropdown",
555
+ children: Array.from({ length: e }, (i, c) => c + 1).map((i) => /* @__PURE__ */ f(
556
+ "option",
557
+ {
558
+ value: i,
559
+ disabled: i > n,
560
+ children: [
561
+ t.tier,
562
+ " ",
563
+ i
564
+ ]
565
+ },
566
+ `tier-${i}`
567
+ ))
568
+ }
569
+ ) }), ut = ({
570
+ i18n: t,
571
+ levelsPerTier: e,
572
+ currentTier: o,
573
+ currentLevel: n,
574
+ highestUnlockedLevel: r,
575
+ onLevelChange: s,
576
+ disabled: i
577
+ }) => /* @__PURE__ */ f("div", { className: "level-selector", children: /* @__PURE__ */ f(
578
+ "select",
579
+ {
580
+ value: n,
581
+ onChange: (c) => {
582
+ c.target && c.target.value && s(Number(c.target.value));
583
+ },
584
+ disabled: i,
585
+ className: "level-dropdown",
586
+ children: Array.from(
587
+ { length: e },
588
+ (c, a) => (o - 1) * e + a + 1
589
+ ).map((c) => /* @__PURE__ */ f(
590
+ "option",
591
+ {
592
+ value: c,
593
+ disabled: c > r,
594
+ children: [
595
+ t.level,
596
+ " ",
597
+ c
598
+ ]
599
+ },
600
+ `level-${c}`
601
+ ))
602
+ }
603
+ ) }), ee = ({
604
+ isOpen: t,
605
+ title: e,
606
+ message: o,
607
+ children: n,
608
+ noConfirm: r = !1,
609
+ noCancel: s = !1,
610
+ confirmText: i = "OK",
611
+ cancelText: c = "Cancel",
612
+ onConfirm: a,
613
+ onCancel: d
614
+ }) => {
615
+ const _ = R(null);
616
+ return N(() => {
617
+ const l = (h) => {
618
+ h.key === "Escape" && d?.();
619
+ };
620
+ return t && document.addEventListener("keydown", l), () => {
621
+ document.removeEventListener("keydown", l);
622
+ };
623
+ }, [t, d]), /* @__PURE__ */ f(
624
+ "div",
625
+ {
626
+ className: `maze-dialog-overlay ${t ? "maze-dialog-visible" : ""}`,
627
+ children: /* @__PURE__ */ f("div", { className: "maze-dialog", ref: _, children: [
628
+ /* @__PURE__ */ f("div", { className: "maze-dialog-title", children: e }),
629
+ /* @__PURE__ */ f("div", { className: "maze-dialog-content", children: n || /* @__PURE__ */ f("div", { className: "maze-dialog-message", children: o }) }),
630
+ /* @__PURE__ */ f("div", { className: "maze-dialog-buttons", children: [
631
+ !s && /* @__PURE__ */ f("button", { className: "maze-dialog-cancel", onClick: d, children: c }),
632
+ !r && /* @__PURE__ */ f("button", { className: "maze-dialog-confirm", onClick: a, children: i })
633
+ ] })
634
+ ] })
635
+ }
636
+ );
637
+ };
638
+ function ht(t) {
639
+ return function() {
640
+ let e = t += 1831565813;
641
+ return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
642
+ };
643
+ }
644
+ const he = [
645
+ // Tier 1 (Levels 1-12) - Beginner
646
+ { size: 8, seed: 12345, method: "backtracking" },
647
+ // Level 1 - Very easy, small maze
648
+ { size: 8, seed: 23456, method: "backtracking" },
649
+ // Level 2 - Very easy
650
+ { size: 8, seed: 34567, method: "prims" },
651
+ // Level 3 - Very easy
652
+ { size: 8, seed: 45678, method: "backtracking" },
653
+ // Level 4 - Easy
654
+ { size: 9, seed: 56789, method: "prims" },
655
+ // Level 5 - Easy
656
+ { size: 9, seed: 67890, method: "backtracking" },
657
+ // Level 6 - Easy
658
+ { size: 9, seed: 78901, method: "prims" },
659
+ // Level 7 - Easy
660
+ { size: 9, seed: 89012, method: "backtracking" },
661
+ // Level 8 - Easy-medium
662
+ { size: 10, seed: 90123, method: "prims" },
663
+ // Level 9 - Easy-medium
664
+ { size: 11, seed: 11111, method: "backtracking" },
665
+ // Level 10 - Easy-medium
666
+ { size: 12, seed: 22222, method: "prims" },
667
+ // Level 11 - Medium
668
+ { size: 13, seed: 33333, method: "backtracking" },
669
+ // Level 12 - Medium
670
+ // Tier 2 (Levels 13-24) - Intermediate
671
+ { size: 12, seed: 44444, method: "prims" },
672
+ // Level 13 - Medium
673
+ { size: 12, seed: 55555, method: "backtracking" },
674
+ // Level 14 - Medium
675
+ { size: 12, seed: 66666, method: "prims" },
676
+ // Level 15 - Medium
677
+ { size: 12, seed: 77777, method: "backtracking" },
678
+ // Level 16 - Medium-hard
679
+ { size: 13, seed: 88888, method: "prims" },
680
+ // Level 17 - Medium-hard
681
+ { size: 13, seed: 99999, method: "backtracking" },
682
+ // Level 18 - Medium-hard
683
+ { size: 13, seed: 12121, method: "prims" },
684
+ // Level 19 - Medium-hard
685
+ { size: 14, seed: 23232, method: "backtracking" },
686
+ // Level 20 - Medium-hard
687
+ { size: 15, seed: 34343, method: "prims" },
688
+ // Level 21 - Hard
689
+ { size: 16, seed: 45454, method: "backtracking" },
690
+ // Level 22 - Hard
691
+ { size: 17, seed: 56565, method: "prims" },
692
+ // Level 23 - Hard
693
+ { size: 18, seed: 67676, method: "backtracking" },
694
+ // Level 24 - Hard
695
+ // Tier 3 (Levels 25-36) - Advanced
696
+ { size: 19, seed: 78787, method: "prims" },
697
+ // Level 25 - Hard
698
+ { size: 20, seed: 89898, method: "backtracking" },
699
+ // Level 26 - Very hard
700
+ { size: 21, seed: 90909, method: "prims" },
701
+ // Level 27 - Very hard
702
+ { size: 22, seed: 10101, method: "backtracking" },
703
+ // Level 28 - Very hard
704
+ { size: 23, seed: 20202, method: "prims" },
705
+ // Level 29 - Very hard
706
+ { size: 25, seed: 30303, method: "backtracking" },
707
+ // Level 30 - Very hard
708
+ { size: 27, seed: 40404, method: "prims" },
709
+ // Level 31 - Very hard
710
+ { size: 29, seed: 50505, method: "backtracking" },
711
+ // Level 32 - Very hard
712
+ { size: 31, seed: 60606, method: "prims" },
713
+ // Level 33 - Very hard
714
+ { size: 33, seed: 70707, method: "backtracking" },
715
+ // Level 34 - Very hard
716
+ { size: 37, seed: 80808, method: "prims" },
717
+ // Level 35 - Very hard
718
+ { size: 40, seed: 90909, method: "backtracking" },
719
+ // Level 36 - Very hard
720
+ // Tier 4 (Levels 37-48) - Expert
721
+ { size: 41, seed: 10111, method: "prims" },
722
+ // Level 37 - Expert
723
+ { size: 42, seed: 11121, method: "backtracking" },
724
+ // Level 38 - Expert
725
+ { size: 43, seed: 12131, method: "prims" },
726
+ // Level 39 - Expert
727
+ { size: 44, seed: 13141, method: "backtracking" },
728
+ // Level 40 - Expert
729
+ { size: 45, seed: 14151, method: "prims" },
730
+ // Level 41 - Expert
731
+ { size: 46, seed: 15161, method: "backtracking" },
732
+ // Level 42 - Expert
733
+ { size: 47, seed: 16171, method: "prims" },
734
+ // Level 43 - Expert
735
+ { size: 48, seed: 17181, method: "backtracking" },
736
+ // Level 44 - Expert
737
+ { size: 49, seed: 18191, method: "prims" },
738
+ // Level 45 - Expert
739
+ { size: 50, seed: 19201, method: "backtracking" },
740
+ // Level 46 - Expert
741
+ { size: 51, seed: 20211, method: "prims" },
742
+ // Level 47 - Expert
743
+ { size: 52, seed: 21221, method: "backtracking" },
744
+ // Level 48 - Expert
745
+ // Tier 5 (Levels 49-60) - Master
746
+ { size: 53, seed: 22231, method: "prims" },
747
+ // Level 49 - Master
748
+ { size: 54, seed: 23241, method: "backtracking" },
749
+ // Level 50 - Master
750
+ { size: 55, seed: 24251, method: "prims" },
751
+ // Level 51 - Master
752
+ { size: 56, seed: 25261, method: "backtracking" },
753
+ // Level 52 - Master
754
+ { size: 57, seed: 26271, method: "prims" },
755
+ // Level 53 - Master
756
+ { size: 58, seed: 27281, method: "backtracking" },
757
+ // Level 54 - Master
758
+ { size: 59, seed: 28291, method: "prims" },
759
+ // Level 55 - Master
760
+ { size: 60, seed: 29301, method: "backtracking" },
761
+ // Level 56 - Master
762
+ { size: 62, seed: 30311, method: "prims" },
763
+ // Level 57 - Master
764
+ { size: 64, seed: 31321, method: "backtracking" },
765
+ // Level 58 - Master
766
+ { size: 66, seed: 32331, method: "prims" },
767
+ // Level 59 - Master
768
+ { size: 68, seed: 33341, method: "backtracking" }
769
+ // Level 60 - Master
770
+ ], te = {
771
+ lcPrefix: "maze-",
772
+ i18n: {
773
+ reset: "Reset",
774
+ resetTip: "Reset all game data and highest score.",
775
+ total: "Total",
776
+ levelScore: "Level Score",
777
+ bestScore: "Best Score",
778
+ confirmReset: "Confirm Reset",
779
+ confirmResetMessage: "Are you sure you want to reset the game? All progress will be lost.",
780
+ cancel: "Cancel",
781
+ close: "Close",
782
+ confirm: "Confirm",
783
+ resetDoneToast: "Game reset! Starting from Level 1...",
784
+ confirmClue: "Confirm to turn on clue?",
785
+ confirmClueMessage: "Are you sure you want to turn on clue? Your current score will be halved.",
786
+ level: "Level",
787
+ tier: "Tier",
788
+ settings: "Settings",
789
+ clueOn: "Clue: ON",
790
+ clueOff: "Clue: OFF",
791
+ clueTip: "Turn on clue will halve your current score in this level",
792
+ foodCollectedToast: "Food collected! %NUM% remaining.",
793
+ allFoodCollectedToast: "All food collected! Head to the exit.",
794
+ warnNotAllFoodCollectedToast: "Collect all food first! %NUM% remaining.",
795
+ levelCompleteToast: "Level completed! 🎉",
796
+ tierUnlockedToast: "Tier %TIER% unlocked! 🎉",
797
+ levelGoToast: "Level %LEVEL% - Go!",
798
+ levelRestartToast: "Level restarted",
799
+ cluePathEnabled: "Clue Path Enabled",
800
+ cluePathDisabled: "Clue Path Disabled",
801
+ useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue."
802
+ },
803
+ renderConfig: {
804
+ padding: 10,
805
+ wallWidth: 4,
806
+ wallColor: "#000000",
807
+ exitColor: "#F44336",
808
+ foodColor: "#4CAF50",
809
+ clueColor: "rgb(255,0,0)",
810
+ backgroundColor: "#ffffff",
811
+ playerColor: "#4CAF50",
812
+ playerAtExitColor: "#FFD700"
813
+ },
814
+ levelConfig: he,
815
+ levelsPerTier: 12
816
+ }, ft = (t) => t === 1 ? 2 : t >= 2 && t <= 5 ? 3 : t >= 6 && t <= 11 ? 4 : t >= 12 && t <= 15 ? 5 : 6;
817
+ class mt {
818
+ // initially all walls exit
819
+ constructor(e, o) {
820
+ this.row = e, this.col = o;
821
+ }
822
+ visited = !1;
823
+ walls = { top: !0, right: !0, bottom: !0, left: !0 };
824
+ }
825
+ class pt {
826
+ rows;
827
+ cols;
828
+ grid;
829
+ seed;
830
+ random;
831
+ constructor(e, o, n) {
832
+ this.rows = e, this.cols = o, this.seed = n ?? Math.floor(Math.random() * 1e6), this.random = ht(this.seed), this.grid = this.initializeGrid();
833
+ }
834
+ // Initialize the grid with new MazeCell objects
835
+ initializeGrid() {
836
+ const e = [];
837
+ for (let o = 0; o < this.rows; o++) {
838
+ e[o] = [];
839
+ for (let n = 0; n < this.cols; n++)
840
+ e[o][n] = new mt(o, n);
841
+ }
842
+ return e;
843
+ }
844
+ // Check if coordinates are within the grid boundaries
845
+ isValid(e, o) {
846
+ return e >= 0 && e < this.rows && o >= 0 && o < this.cols;
847
+ }
848
+ // Get all valid neighbors (top, right, bottom, left)
849
+ getNeighbors(e, o) {
850
+ const n = [], r = [
851
+ { r: -1, c: 0 },
852
+ // Top
853
+ { r: 0, c: 1 },
854
+ // Right
855
+ { r: 1, c: 0 },
856
+ // Bottom
857
+ { r: 0, c: -1 }
858
+ // Left
859
+ ];
860
+ for (const s of r) {
861
+ const i = e + s.r, c = o + s.c;
862
+ this.isValid(i, c) && n.push({ row: i, col: c });
863
+ }
864
+ return n;
865
+ }
866
+ // Get only neighbors that haven't been visited yet
867
+ getUnvisitedNeighbors(e, o) {
868
+ return this.getNeighbors(e, o).filter(
869
+ (n) => !this.grid[n.row][n.col].visited
870
+ );
871
+ }
872
+ /**
873
+ * Gets neighbors that have already been visited (part of the maze path).
874
+ */
875
+ getVisitedNeighbors(e, o) {
876
+ return this.getNeighbors(e, o).filter(
877
+ (n) => this.grid[n.row][n.col].visited
878
+ );
879
+ }
880
+ // Remove the wall between two adjacent cells
881
+ removeWall(e, o, n, r) {
882
+ const s = this.grid[e][o], i = this.grid[n][r];
883
+ e === n + 1 ? (s.walls.top = !1, i.walls.bottom = !1) : e === n - 1 ? (s.walls.bottom = !1, i.walls.top = !1) : o === r + 1 ? (s.walls.left = !1, i.walls.right = !1) : o === r - 1 && (s.walls.right = !1, i.walls.left = !1);
884
+ }
885
+ }
886
+ class vt {
887
+ maze;
888
+ constructor(e, o, n, r, s = { row: 0, col: 0 }, i = { row: e - 1, col: o - 1 }) {
889
+ switch (this.maze = new pt(e, o, r), n) {
890
+ case "backtracking":
891
+ this.runBacktracking();
892
+ break;
893
+ case "prims":
894
+ this.runPrims();
895
+ break;
896
+ default:
897
+ throw new Error(`Unknown maze generation method: ${n}`);
898
+ }
899
+ this.addOpenings(s, i);
900
+ }
901
+ /**
902
+ * Returns the generated Maze instance.
903
+ */
904
+ getMaze() {
905
+ return this.maze;
906
+ }
907
+ // --- Backtracking Algorithm Implementation ---
908
+ runBacktracking() {
909
+ const e = [], o = this.randomNumber(this.maze.rows), n = this.randomNumber(this.maze.cols);
910
+ let r = { row: o, col: n };
911
+ for (this.maze.grid[o][n].visited = !0, e.push(r); e.length > 0; ) {
912
+ r = e[e.length - 1];
913
+ const { row: s, col: i } = r, c = this.maze.getUnvisitedNeighbors(s, i);
914
+ if (c.length > 0) {
915
+ const a = this.randomPick(c), { row: d, col: _ } = a;
916
+ this.maze.removeWall(s, i, d, _), this.maze.grid[d][_].visited = !0, e.push(a);
917
+ } else
918
+ e.pop();
919
+ }
920
+ }
921
+ // --- Prim's Algorithm Implementation ---
922
+ runPrims() {
923
+ const e = [], o = (s, i) => {
924
+ const c = this.maze.getNeighbors(s, i);
925
+ for (const a of c)
926
+ !this.maze.grid[a.row][a.col].visited && !e.some(
927
+ (d) => d.row === a.row && d.col === a.col
928
+ ) && e.push(a);
929
+ }, n = this.randomNumber(this.maze.rows), r = this.randomNumber(this.maze.cols);
930
+ for (this.maze.grid[n][r].visited = !0, o(n, r); e.length > 0; ) {
931
+ const s = this.randomNumber(e.length), i = e[s], { row: c, col: a } = i, d = this.maze.getVisitedNeighbors(c, a);
932
+ if (d.length > 0) {
933
+ const _ = this.randomPick(d);
934
+ this.maze.removeWall(c, a, _.row, _.col), this.maze.grid[c][a].visited = !0, o(c, a);
935
+ }
936
+ e.splice(s, 1);
937
+ }
938
+ }
939
+ // --- Helper ---
940
+ addOpenings(e, o) {
941
+ this.maze.grid[e.row][e.col].walls.top = !1, this.maze.grid[o.row][o.col].walls.bottom = !1;
942
+ }
943
+ // random number
944
+ randomNumber(e) {
945
+ return Math.floor(this.maze.random() * e);
946
+ }
947
+ // Randomly pick an item from a list
948
+ randomPick(e) {
949
+ return e[Math.floor(this.maze.random() * e.length)];
950
+ }
951
+ }
952
+ function gt(t, e, o, n, r, s) {
953
+ return new vt(t, e, o, n, r, s).getMaze();
954
+ }
955
+ const wt = (t, e, o) => {
956
+ if (!t.isValid(e, o)) return !1;
957
+ const n = t.grid[e][o];
958
+ return !n.walls.top || !n.walls.right || !n.walls.bottom || !n.walls.left;
959
+ }, qe = (t) => {
960
+ const e = t - 1, o = he[e];
961
+ if (!o)
962
+ return console.error(`Cannot find Level ${t}'s config.`), null;
963
+ const n = o.size, r = n, s = n, i = o.seed, c = o.method, a = o.entry || { row: 0, col: 0 }, d = o.exit || { row: r - 1, col: s - 1 }, _ = gt(r, s, c, i, a, d), l = ft(t), h = [];
964
+ for (let u = 0; u < l; u++) {
965
+ let m;
966
+ do
967
+ m = {
968
+ row: Math.floor(_.random() * r),
969
+ col: Math.floor(_.random() * s)
970
+ };
971
+ while (m.row === a.row && m.col === a.col || m.row === d.row && m.col === d.col || !wt(_, m.row, m.col) || h.some(
972
+ (w) => w.row === m.row && w.col === m.col
973
+ ));
974
+ h.push(m);
975
+ }
976
+ return {
977
+ maze: _,
978
+ playerPosition: a,
979
+ exitPosition: d,
980
+ foodPositions: h,
981
+ totalFoodCount: l,
982
+ foodCollected: 0,
983
+ playerPath: [a],
984
+ visitCounts: { [`${a.row},${a.col}`]: 1 },
985
+ moveCount: 0,
986
+ currentScore: _.rows * _.cols,
987
+ playerAtExit: !1,
988
+ isGameActive: !0,
989
+ levelTransitioning: !1
990
+ };
991
+ }, Ke = ({
992
+ gameState: t,
993
+ setGameState: e
994
+ }) => ({
995
+ generateCurrentLevelMaze: () => {
996
+ const n = qe(t.currentLevel);
997
+ n && e((r) => ({
998
+ ...r,
999
+ ...n
1000
+ }));
1001
+ }
1002
+ }), Ct = () => {
1003
+ const { gameState: t, setGameState: e, resetGame: o, config: n } = Ve(), r = n.current.i18n, { showToast: s } = ue(), { currentLevel: i, totalScore: c, levelScores: a, currentScore: d, showClue: _ } = t, l = a[i] || 0, h = n.current.levelsPerTier, u = Math.ceil(n.current.levelConfig.length / h), [m, w] = E(!1), [g, v] = E(!1), [p, b] = E(!1), { generateCurrentLevelMaze: z } = Ke({
1004
+ gameState: t,
1005
+ setGameState: e
1006
+ }), S = (T) => {
1007
+ const V = (T - 1) * h + 1;
1008
+ V <= t.highestUnlockedLevel && (e((je) => ({ ...je, currentTier: T })), P(V));
1009
+ }, P = (T) => {
1010
+ T > 0 && T <= t.highestUnlockedLevel && (e((V) => ({
1011
+ ...V,
1012
+ currentLevel: T,
1013
+ currentTier: Math.ceil(T / h)
1014
+ })), z(), s(
1015
+ r.levelGoToast.replace("%LEVEL%", T.toString()),
1016
+ "success"
1017
+ ));
1018
+ }, U = () => {
1019
+ w(!0);
1020
+ }, M = () => {
1021
+ w(!1);
1022
+ }, $ = () => {
1023
+ b(!0);
1024
+ }, L = () => {
1025
+ b(!1);
1026
+ }, x = () => {
1027
+ e((T) => (s(T.showClue ? r.cluePathDisabled : r.cluePathEnabled), {
1028
+ ...T,
1029
+ showClue: !T.showClue,
1030
+ currentScore: Math.floor(T.currentScore / 2)
1031
+ // half the current score
1032
+ })), b(!1);
1033
+ }, F = () => {
1034
+ v(!0);
1035
+ }, Ye = () => {
1036
+ o(), v(!1), s(r.resetDoneToast);
1037
+ }, Xe = () => {
1038
+ v(!1);
1039
+ };
1040
+ return /* @__PURE__ */ f("div", { class: "game-panel-container", children: [
1041
+ /* @__PURE__ */ f("div", { className: "game-controls", children: [
1042
+ /* @__PURE__ */ f("div", { className: "selectors-container", children: [
1043
+ /* @__PURE__ */ f(
1044
+ _t,
1045
+ {
1046
+ i18n: r,
1047
+ totalTiers: u,
1048
+ currentTier: t.currentTier,
1049
+ highestUnlockedTier: t.highestUnlockedTier,
1050
+ onTierChange: S,
1051
+ disabled: t.levelTransitioning
1052
+ }
1053
+ ),
1054
+ /* @__PURE__ */ f(
1055
+ ut,
1056
+ {
1057
+ i18n: r,
1058
+ levelsPerTier: h,
1059
+ currentTier: t.currentTier,
1060
+ currentLevel: t.currentLevel,
1061
+ highestUnlockedLevel: t.highestUnlockedLevel,
1062
+ onLevelChange: P,
1063
+ disabled: t.levelTransitioning
1064
+ }
1065
+ )
1066
+ ] }),
1067
+ /* @__PURE__ */ f("div", { className: "score-container", children: [
1068
+ /* @__PURE__ */ f("div", { className: "score-box currentscore", children: [
1069
+ /* @__PURE__ */ f("span", { className: "score-label", children: [
1070
+ r.levelScore,
1071
+ ":"
1072
+ ] }),
1073
+ /* @__PURE__ */ f("span", { className: "score-data", children: d })
1074
+ ] }),
1075
+ /* @__PURE__ */ f("div", { className: "score-box bestscore", children: [
1076
+ /* @__PURE__ */ f("span", { className: "score-label", children: [
1077
+ r.bestScore,
1078
+ ":"
1079
+ ] }),
1080
+ /* @__PURE__ */ f("span", { className: "score-data", children: l })
1081
+ ] }),
1082
+ /* @__PURE__ */ f("div", { className: "score-box totalscore", children: [
1083
+ /* @__PURE__ */ f("span", { className: "score-label", children: [
1084
+ r.total,
1085
+ ":"
1086
+ ] }),
1087
+ /* @__PURE__ */ f("span", { className: "score-data", children: c })
1088
+ ] })
1089
+ ] })
1090
+ ] }),
1091
+ /* @__PURE__ */ f("div", { className: "game-settings", children: /* @__PURE__ */ f(
1092
+ "img",
1093
+ {
1094
+ onClick: U,
1095
+ src: "/settings.svg",
1096
+ alt: "Settings",
1097
+ className: "game-settings-icon"
1098
+ }
1099
+ ) }),
1100
+ /* @__PURE__ */ f(
1101
+ ee,
1102
+ {
1103
+ isOpen: m,
1104
+ title: r.settings,
1105
+ noConfirm: !0,
1106
+ cancelText: r.close,
1107
+ onCancel: M,
1108
+ children: [
1109
+ /* @__PURE__ */ f("div", { className: "settings-item-box", children: [
1110
+ /* @__PURE__ */ f("div", {}),
1111
+ /* @__PURE__ */ f(
1112
+ "button",
1113
+ {
1114
+ className: `settings-clue-button ${_ ? "clue-on" : "clue-off"}`,
1115
+ title: "Toggle Clue",
1116
+ onClick: $,
1117
+ children: _ ? r.clueOn : r.clueOff
1118
+ }
1119
+ ),
1120
+ /* @__PURE__ */ f("div", { className: "settings-item-tip", children: r.clueTip })
1121
+ ] }),
1122
+ /* @__PURE__ */ f("div", { className: "settings-item-box", children: [
1123
+ /* @__PURE__ */ f(
1124
+ "button",
1125
+ {
1126
+ className: "settings-reset-button",
1127
+ title: "Reset Game",
1128
+ onClick: F,
1129
+ children: r.reset
1130
+ }
1131
+ ),
1132
+ /* @__PURE__ */ f("div", { className: "settings-item-tip", children: r.resetTip })
1133
+ ] })
1134
+ ]
1135
+ }
1136
+ ),
1137
+ /* @__PURE__ */ f(
1138
+ ee,
1139
+ {
1140
+ isOpen: g,
1141
+ title: r.confirmReset,
1142
+ message: r.confirmResetMessage,
1143
+ confirmText: r.reset,
1144
+ cancelText: r.cancel,
1145
+ onConfirm: Ye,
1146
+ onCancel: Xe
1147
+ }
1148
+ ),
1149
+ /* @__PURE__ */ f(
1150
+ ee,
1151
+ {
1152
+ isOpen: p,
1153
+ title: r.confirmClue,
1154
+ message: r.confirmClueMessage,
1155
+ confirmText: r.confirm,
1156
+ cancelText: r.cancel,
1157
+ onConfirm: x,
1158
+ onCancel: L
1159
+ }
1160
+ )
1161
+ ] });
1162
+ }, yt = ({
1163
+ message: t,
1164
+ visible: e,
1165
+ duration: o = 2e3,
1166
+ onClose: n,
1167
+ position: r = "center",
1168
+ type: s = "info"
1169
+ }) => t ? (N(() => {
1170
+ let i;
1171
+ return e && o > 0 && n && (i = setTimeout(() => {
1172
+ n();
1173
+ }, o)), () => {
1174
+ i && clearTimeout(i);
1175
+ };
1176
+ }, [e, o, n]), /* @__PURE__ */ f("div", { className: `toast-container position-${r}`, children: /* @__PURE__ */ f("div", { className: `toast-message type-${s} ${e ? "toast-visible" : ""}`, children: t }) })) : null, kt = (t, e, o) => {
1177
+ N(() => {
1178
+ const n = () => {
1179
+ const r = t.current;
1180
+ if (!r) return;
1181
+ const s = r.parentElement;
1182
+ if (!s) return;
1183
+ const i = s.clientWidth, c = s.clientHeight, a = Math.min(i, c), d = window.devicePixelRatio || 1;
1184
+ r.style.width = `${a}px`, r.style.height = `${a}px`, r.width = a * d, r.height = a * d, e(t, o.current);
1185
+ };
1186
+ return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
1187
+ }, [t, e, o]);
1188
+ }, Pe = {
1189
+ ArrowUp: [-1, 0],
1190
+ ArrowDown: [1, 0],
1191
+ ArrowLeft: [0, -1],
1192
+ ArrowRight: [0, 1]
1193
+ }, bt = ({
1194
+ containerRef: t,
1195
+ gameState: e,
1196
+ setGameState: o,
1197
+ onFoodCollected: n,
1198
+ onFoodNotAllCollected: r
1199
+ }) => {
1200
+ N(() => {
1201
+ const s = (a) => {
1202
+ if (!e.isGameActive || !e.maze) return;
1203
+ const [d, _] = Pe[a], { row: l, col: h } = e.playerPosition, u = l + d, m = h + _;
1204
+ if (!e.maze.isValid(u, m)) return;
1205
+ const w = e.maze.grid[l][h];
1206
+ if (d === -1 && w.walls.top || d === 1 && w.walls.bottom || _ === -1 && w.walls.left || _ === 1 && w.walls.right)
1207
+ return;
1208
+ const g = { row: u, col: m }, v = `${u},${m}`;
1209
+ o((p) => {
1210
+ const b = p.foodPositions.some(
1211
+ (L) => L.row === u && L.col === m
1212
+ );
1213
+ b && n();
1214
+ const z = Math.max(
1215
+ 0,
1216
+ p.currentScore - 1
1217
+ ), S = `${l},${h}-${u},${m}`, P = u === p.exitPosition.row && m === p.exitPosition.col, U = b ? p.foodCollected + 1 : p.foodCollected, M = U === p.totalFoodCount, $ = P && M;
1218
+ return P && !M && r(), {
1219
+ ...p,
1220
+ playerPosition: g,
1221
+ playerPath: [...p.playerPath, g],
1222
+ foodPositions: p.foodPositions.filter(
1223
+ (L) => !(L.row === u && L.col === m)
1224
+ ),
1225
+ foodCollected: U,
1226
+ currentScore: z,
1227
+ visitCounts: {
1228
+ ...p.visitCounts,
1229
+ [S]: (p.visitCounts[S] || 0) + 1,
1230
+ [v]: (p.visitCounts[v] || 0) + 1
1231
+ },
1232
+ moveCount: p.moveCount + 1,
1233
+ playerAtExit: P,
1234
+ isGameActive: !$,
1235
+ levelTransitioning: $
1236
+ };
1237
+ });
1238
+ }, i = (a) => {
1239
+ if (!e.isGameActive || !e.maze) return;
1240
+ const d = a.key;
1241
+ d in Pe && (a.preventDefault(), s(d));
1242
+ }, c = (a) => {
1243
+ if (a.preventDefault(), !e.isGameActive || !e.maze) return;
1244
+ const d = a.touches[0], _ = document.elementFromPoint(d.clientX, d.clientY);
1245
+ _ && (_.classList.contains("maze-up") ? s("ArrowUp") : _.classList.contains("maze-down") ? s("ArrowDown") : _.classList.contains("maze-left") ? s("ArrowLeft") : _.classList.contains("maze-right") && s("ArrowRight"));
1246
+ };
1247
+ return window.addEventListener("keydown", i), t.current?.addEventListener("touchstart", c, {
1248
+ passive: !1
1249
+ }), () => {
1250
+ window.removeEventListener("keydown", i), t.current?.removeEventListener("touchstart", c);
1251
+ };
1252
+ }, [
1253
+ e.isGameActive,
1254
+ e.maze,
1255
+ e.playerPosition,
1256
+ e.exitPosition
1257
+ ]);
1258
+ }, zt = ({
1259
+ gameState: t,
1260
+ setGameState: e,
1261
+ config: o,
1262
+ onLevelComplete: n,
1263
+ onTierUnlocked: r
1264
+ }) => {
1265
+ N(() => {
1266
+ if (t.levelTransitioning) {
1267
+ n();
1268
+ const i = setTimeout(() => {
1269
+ s(t.currentScore);
1270
+ }, 1e3);
1271
+ return () => clearTimeout(i);
1272
+ }
1273
+ }, [t.levelTransitioning]);
1274
+ const s = (i) => {
1275
+ if (t.currentLevel >= o.current.levelConfig.length) return;
1276
+ const c = t.currentLevel + 1, a = Math.ceil(c / o.current.levelsPerTier), d = qe(c);
1277
+ d && e((_) => {
1278
+ const l = Math.ceil(
1279
+ _.currentLevel / o.current.levelsPerTier
1280
+ );
1281
+ a > l && r(a);
1282
+ const h = { ..._.levelScores };
1283
+ return h[_.currentLevel] = Math.max(
1284
+ i,
1285
+ h[_.currentLevel] || 0
1286
+ ), {
1287
+ ..._,
1288
+ ...d,
1289
+ currentLevel: c,
1290
+ currentTier: a,
1291
+ highestUnlockedLevel: Math.max(_.highestUnlockedLevel, c),
1292
+ highestUnlockedTier: Math.max(_.highestUnlockedTier, a),
1293
+ levelScores: h,
1294
+ totalScore: Object.values(h).reduce((u, m) => u + m, 0),
1295
+ showClue: !1,
1296
+ // reset to false on new level
1297
+ isGameActive: !0,
1298
+ levelTransitioning: !1
1299
+ };
1300
+ });
1301
+ };
1302
+ return {
1303
+ handleLevelComplete: s
1304
+ };
1305
+ };
1306
+ function Tt(t, e) {
1307
+ const { ctx: o, width: n, height: r, maze: s } = t;
1308
+ e.playerColor = t.playerAtExit ? e.playerAtExitColor : e.playerColor;
1309
+ const {
1310
+ padding: i,
1311
+ wallWidth: c,
1312
+ wallColor: a,
1313
+ playerColor: d,
1314
+ exitColor: _,
1315
+ foodColor: l,
1316
+ clueColor: h,
1317
+ backgroundColor: u
1318
+ } = e, m = s.cols, w = s.rows, g = (n - i * 2) / m, v = (r - i * 2) / w;
1319
+ o.clearRect(0, 0, n, r), o.save(), o.fillStyle = u, o.fillRect(0, 0, n, r), o.restore(), t.showClue && t.playerPath && t.playerPath.length > 0 && Mt(t, {
1320
+ cellWidth: g,
1321
+ cellHeight: v,
1322
+ padding: i,
1323
+ clueColor: h
1324
+ }), Pt(t, {
1325
+ cellWidth: g,
1326
+ cellHeight: v,
1327
+ padding: i,
1328
+ wallColor: a,
1329
+ wallWidth: c
1330
+ }), Nt(t, {
1331
+ cellWidth: g,
1332
+ cellHeight: v,
1333
+ padding: i,
1334
+ foodColor: l
1335
+ }), t.playerAtExit || Lt(t, {
1336
+ cellWidth: g,
1337
+ cellHeight: v,
1338
+ padding: i,
1339
+ exitColor: _
1340
+ }), xt(t, {
1341
+ cellWidth: g,
1342
+ cellHeight: v,
1343
+ padding: i,
1344
+ playerColor: d
1345
+ });
1346
+ }
1347
+ function Pt(t, e) {
1348
+ const { ctx: o, maze: n } = t, { cellWidth: r, cellHeight: s, padding: i, wallColor: c, wallWidth: a } = e;
1349
+ o.save(), o.strokeStyle = c, o.lineWidth = a, o.lineCap = "round", o.beginPath();
1350
+ for (let d = 0; d < n.rows; d++)
1351
+ for (let _ = 0; _ < n.cols; _++) {
1352
+ const l = n.grid[d][_], h = i + _ * r, u = i + d * s;
1353
+ l.walls.top && (o.moveTo(h, u), o.lineTo(h + r, u)), l.walls.right && (o.moveTo(h + r, u), o.lineTo(h + r, u + s)), l.walls.bottom && (o.moveTo(h + r, u + s), o.lineTo(h, u + s)), l.walls.left && (o.moveTo(h, u + s), o.lineTo(h, u));
1354
+ }
1355
+ o.stroke(), o.restore();
1356
+ }
1357
+ function xt(t, e) {
1358
+ const { ctx: o, playerPosition: n } = t, { cellWidth: r, cellHeight: s, padding: i, playerColor: c } = e, { x: a, y: d } = O(
1359
+ n.row,
1360
+ n.col,
1361
+ r,
1362
+ s,
1363
+ i
1364
+ ), _ = Math.min(r, s) * 0.35;
1365
+ o.save(), o.fillStyle = c, o.beginPath(), o.arc(a, d, _, 0, Math.PI * 2), o.fill(), o.restore();
1366
+ }
1367
+ function Lt(t, e) {
1368
+ const { ctx: o, exitPosition: n } = t, { cellWidth: r, cellHeight: s, padding: i, exitColor: c } = e, { x: a, y: d } = O(
1369
+ n.row,
1370
+ n.col,
1371
+ r,
1372
+ s,
1373
+ i
1374
+ ), _ = Math.min(r, s) * 0.35;
1375
+ o.save(), o.fillStyle = c, o.beginPath(), o.arc(a, d, _, 0, Math.PI * 2), o.fill(), o.restore();
1376
+ }
1377
+ function Nt(t, e) {
1378
+ const { ctx: o, foodPositions: n } = t, { cellWidth: r, cellHeight: s, padding: i, foodColor: c } = e;
1379
+ o.fillStyle = c;
1380
+ const a = Math.min(r, s) * 0.25;
1381
+ n.forEach((d) => {
1382
+ const { x: _, y: l } = O(
1383
+ d.row,
1384
+ d.col,
1385
+ r,
1386
+ s,
1387
+ i
1388
+ );
1389
+ St(o, _, l, a * 1.2, 5, a * 0.6);
1390
+ });
1391
+ }
1392
+ function St(t, e, o, n, r, s) {
1393
+ t.save(), t.beginPath();
1394
+ for (let i = 0; i < r * 2; i++) {
1395
+ const c = i % 2 === 0 ? n : s, a = Math.PI * i / r;
1396
+ t.lineTo(e + c * Math.sin(a), o + c * Math.cos(a));
1397
+ }
1398
+ t.closePath(), t.fill(), t.restore();
1399
+ }
1400
+ function Mt(t, e) {
1401
+ const { ctx: o, playerPath: n, visitCounts: r } = t, { cellWidth: s, cellHeight: i, padding: c, clueColor: a } = e;
1402
+ if (!(!n || n.length < 2 || !r)) {
1403
+ o.save();
1404
+ for (let d = 1; d < n.length; d++) {
1405
+ const _ = n[d - 1], l = n[d], h = `${_.row},${_.col}-${l.row},${l.col}`, u = `${l.row},${l.col}-${_.row},${_.col}`, m = (r[h] || 0) + (r[u] || 0), w = Math.min(0.2 + m * 0.1, 0.9), g = Math.max(3, s * 0.1) + m * 0.5;
1406
+ try {
1407
+ o.strokeStyle = a.replace(")", `, ${w})`).replace("rgb(", "rgba(");
1408
+ } catch {
1409
+ o.strokeStyle = `rgba(255, 0, 0, ${w})`;
1410
+ }
1411
+ o.lineWidth = g, o.lineCap = "round", o.lineJoin = "round";
1412
+ const { x: v, y: p } = O(_.row, _.col, s, i, c), { x: b, y: z } = O(l.row, l.col, s, i, c);
1413
+ o.beginPath(), o.moveTo(v, p), o.lineTo(b, z), o.stroke();
1414
+ }
1415
+ o.restore();
1416
+ }
1417
+ }
1418
+ function O(t, e, o, n, r) {
1419
+ return {
1420
+ x: r + e * o + o / 2,
1421
+ y: r + t * n + n / 2
1422
+ };
1423
+ }
1424
+ const $t = () => {
1425
+ const { message: t, visible: e, type: o, hideToast: n } = ue();
1426
+ return /* @__PURE__ */ f(
1427
+ yt,
1428
+ {
1429
+ message: t,
1430
+ visible: e,
1431
+ type: o,
1432
+ onClose: n,
1433
+ position: "top"
1434
+ }
1435
+ );
1436
+ }, At = () => {
1437
+ const { gameState: t, setGameState: e, config: o } = Ve(), n = R(null), r = R(null), s = R(t), i = o.current.i18n, { showToast: c } = ue();
1438
+ N(() => {
1439
+ s.current = t;
1440
+ }, [t]);
1441
+ const a = () => {
1442
+ const h = t.totalFoodCount - t.foodCollected - 1;
1443
+ if (h > 0) {
1444
+ c(
1445
+ i.foodCollectedToast.replace("%NUM%", h.toString()),
1446
+ "success"
1447
+ );
1448
+ return;
1449
+ }
1450
+ c(i.allFoodCollectedToast, "success");
1451
+ }, d = () => {
1452
+ const h = t.totalFoodCount - t.foodCollected - 1;
1453
+ c(
1454
+ i.warnNotAllFoodCollectedToast.replace("%NUM%", h.toString()),
1455
+ "warning"
1456
+ );
1457
+ }, _ = (h, u) => {
1458
+ const m = h.current?.getContext("2d");
1459
+ m && u.maze && Tt(
1460
+ {
1461
+ ctx: m,
1462
+ width: h.current.width,
1463
+ height: h.current.height,
1464
+ maze: u.maze,
1465
+ playerPosition: u.playerPosition,
1466
+ exitPosition: u.exitPosition,
1467
+ foodPositions: u.foodPositions,
1468
+ showClue: u.showClue,
1469
+ playerPath: u.playerPath,
1470
+ visitCounts: u.visitCounts,
1471
+ playerAtExit: u.playerAtExit
1472
+ },
1473
+ o.current.renderConfig || {}
1474
+ );
1475
+ };
1476
+ N(() => {
1477
+ c(i.useArrowKeyTips, "info", 3e3);
1478
+ }, []), kt(r, _, s);
1479
+ const { generateCurrentLevelMaze: l } = Ke({
1480
+ gameState: t,
1481
+ setGameState: e
1482
+ });
1483
+ return bt({
1484
+ containerRef: n,
1485
+ gameState: t,
1486
+ setGameState: e,
1487
+ onFoodCollected: a,
1488
+ onFoodNotAllCollected: d
1489
+ }), zt({
1490
+ gameState: t,
1491
+ setGameState: e,
1492
+ config: o,
1493
+ onLevelComplete: () => {
1494
+ c(i.levelCompleteToast, "success");
1495
+ },
1496
+ onTierUnlocked: (h) => {
1497
+ c(
1498
+ i.tierUnlockedToast.replace("%TIER%", h.toString()),
1499
+ "success"
1500
+ );
1501
+ }
1502
+ }), N(() => {
1503
+ t.isGameActive && !t.levelTransitioning && l();
1504
+ }, [
1505
+ t.currentLevel,
1506
+ t.isGameActive,
1507
+ t.levelTransitioning
1508
+ ]), N(() => {
1509
+ r.current && t.maze && _(r, t);
1510
+ }, [t]), /* @__PURE__ */ f("div", { className: "maze-game-container", children: [
1511
+ /* @__PURE__ */ f($t, {}),
1512
+ /* @__PURE__ */ f(Ct, {}),
1513
+ /* @__PURE__ */ f("div", { className: "maze-canvas-container", ref: n, children: [
1514
+ /* @__PURE__ */ f("canvas", { ref: r, className: "maze-game-canvas" }),
1515
+ /* @__PURE__ */ f("div", { className: "maze-touch-area maze-up" }),
1516
+ /* @__PURE__ */ f("div", { className: "maze-touch-area maze-down" }),
1517
+ /* @__PURE__ */ f("div", { className: "maze-touch-area maze-left" }),
1518
+ /* @__PURE__ */ f("div", { className: "maze-touch-area maze-right" })
1519
+ ] })
1520
+ ] });
1521
+ };
1522
+ function Et() {
1523
+ return /* @__PURE__ */ f(dt, { children: /* @__PURE__ */ f(At, {}) });
1524
+ }
1525
+ function Ut({ config: t = {} }) {
1526
+ const e = { ...te.i18n, ...t.i18n || {} }, o = { ...te.renderConfig, ...t.renderConfig || {} }, n = t.levelConfig || he;
1527
+ return t = {
1528
+ ...te,
1529
+ ...t,
1530
+ i18n: e,
1531
+ levelConfig: n,
1532
+ renderConfig: o
1533
+ }, /* @__PURE__ */ f(at, { config: t, children: /* @__PURE__ */ f(Et, {}) });
1534
+ }
1535
+ const Ft = {
1536
+ async init(t, e) {
1537
+ const o = typeof t == "string" ? document.querySelector(t) : t;
1538
+ if (!o) {
1539
+ console.warn("Cannot find the root element");
1540
+ const a = document.createElement("div");
1541
+ a.style.textAlign = "center", a.style.padding = "20px", a.innerHTML = "Cannot find the root element", document.body.append(a);
1542
+ return;
1543
+ }
1544
+ let { root: n = location.origin } = e;
1545
+ n.at(-1) !== "/" && (n += "/");
1546
+ const r = document.createElement("div"), s = document.createElement("div");
1547
+ r.style.cssText = `
1548
+ height: 30px;
1549
+ width: 100%;
1550
+ border: solid 2px #999;
1551
+ margin: 20% auto;
1552
+ `, s.style.cssText = `
1553
+ width: 99%;
1554
+ height: 100%;
1555
+ background: #999;
1556
+ animation: loading 1.5s ease-in-out;
1557
+ transition: width 1.5s ease-in-out;
1558
+ transition: width 1.5s ease-in-out;
1559
+ `, r.append(s), o.append(r);
1560
+ const i = document.createElement("style");
1561
+ i.innerHTML = `
1562
+ @keyframes loading {
1563
+ 0% { width: 0%; }
1564
+ 100% { width: 99%; }
1565
+ }`, document.head.appendChild(i), await (async (a) => new Promise((d, _) => {
1566
+ const l = document.createElement("link");
1567
+ l.rel = "stylesheet", l.type = "text/css", l.href = a, l.onload = d, l.onerror = _, document.head.appendChild(l);
1568
+ }))(n + "maze.css"), nt(/* @__PURE__ */ f(Ut, { config: e }), o);
1569
+ }
1570
+ };
1571
+ export {
1572
+ Ft as default
1573
+ };