@roudanio/maze 0.1.8 → 0.2.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 CHANGED
@@ -1,73 +1,73 @@
1
- var ce, A, qe, G, Le, Ve, Xe, Ye, we, ve, pe, Ke, K = {}, Je = [], ut = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, ue = Array.isArray;
2
- function j(t, e) {
1
+ var fe, A, Je, X, Pe, Ze, Qe, et, Se, Ce, ye, tt, ee = {}, nt = [], bt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, me = Array.isArray;
2
+ function H(t, e) {
3
3
  for (var n in e) t[n] = e[n];
4
4
  return t;
5
5
  }
6
- function ye(t) {
6
+ function ze(t) {
7
7
  t && t.parentNode && t.parentNode.removeChild(t);
8
8
  }
9
- function dt(t, e, n) {
9
+ function Tt(t, e, n) {
10
10
  var o, i, s, a = {};
11
11
  for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : a[s] = e[s];
12
- if (arguments.length > 2 && (a.children = arguments.length > 3 ? ce.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) a[s] == null && (a[s] = t.defaultProps[s]);
13
- return ne(t, a, o, i, null);
12
+ if (arguments.length > 2 && (a.children = arguments.length > 3 ? fe.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) a[s] == null && (a[s] = t.defaultProps[s]);
13
+ return se(t, a, o, i, null);
14
14
  }
15
- function ne(t, e, n, o, i) {
16
- var s = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++qe, __i: -1, __u: 0 };
15
+ function se(t, e, n, o, i) {
16
+ var s = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++Je, __i: -1, __u: 0 };
17
17
  return i == null && A.vnode != null && A.vnode(s), s;
18
18
  }
19
- function de(t) {
19
+ function _e(t) {
20
20
  return t.children;
21
21
  }
22
- function oe(t, e) {
22
+ function ae(t, e) {
23
23
  this.props = t, this.context = e;
24
24
  }
25
- function H(t, e) {
26
- if (e == null) return t.__ ? H(t.__, t.__i + 1) : null;
25
+ function K(t, e) {
26
+ if (e == null) return t.__ ? K(t.__, t.__i + 1) : null;
27
27
  for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
28
- return typeof t.type == "function" ? H(t) : null;
28
+ return typeof t.type == "function" ? K(t) : null;
29
29
  }
30
- function Ze(t) {
30
+ function ot(t) {
31
31
  var e, n;
32
32
  if ((t = t.__) != null && t.__c != null) {
33
33
  for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) {
34
34
  t.__e = t.__c.base = n.__e;
35
35
  break;
36
36
  }
37
- return Ze(t);
37
+ return ot(t);
38
38
  }
39
39
  }
40
- function ge(t) {
41
- (!t.__d && (t.__d = !0) && G.push(t) && !le.__r++ || Le != A.debounceRendering) && ((Le = A.debounceRendering) || Ve)(le);
40
+ function be(t) {
41
+ (!t.__d && (t.__d = !0) && X.push(t) && !de.__r++ || Pe != A.debounceRendering) && ((Pe = A.debounceRendering) || Ze)(de);
42
42
  }
43
- function le() {
44
- for (var t, e, n, o, i, s, a, r = 1; G.length; ) G.length > r && G.sort(Xe), t = G.shift(), r = G.length, t.__d && (n = void 0, i = (o = (e = t).__v).__e, s = [], a = [], e.__P && ((n = j({}, o)).__v = o.__v + 1, A.vnode && A.vnode(n), be(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? H(o), !!(32 & o.__u), a), n.__v = o.__v, n.__.__k[n.__i] = n, tt(s, n, a), n.__e != i && Ze(n)));
45
- le.__r = 0;
43
+ function de() {
44
+ for (var t, e, n, o, i, s, a, r = 1; X.length; ) X.length > r && X.sort(Qe), t = X.shift(), r = X.length, t.__d && (n = void 0, i = (o = (e = t).__v).__e, s = [], a = [], e.__P && ((n = H({}, o)).__v = o.__v + 1, A.vnode && A.vnode(n), Ee(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? K(o), !!(32 & o.__u), a), n.__v = o.__v, n.__.__k[n.__i] = n, st(s, n, a), n.__e != i && ot(n)));
45
+ de.__r = 0;
46
46
  }
47
- function Qe(t, e, n, o, i, s, a, r, l, c, d) {
48
- var u, h, f, y, g, p, m = o && o.__k || Je, _ = e.length;
49
- for (l = ht(n, e, m, l, _), u = 0; u < _; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? K : m[f.__i] || K, f.__i = u, p = be(t, f, h, i, s, a, r, l, c, d), y = f.__e, f.ref && h.ref != f.ref && (h.ref && ke(h.ref, null, f), d.push(f.ref, f.__c || y, f)), g == null && y != null && (g = y), 4 & f.__u || h.__k === f.__k ? l = et(f, l, t) : typeof f.type == "function" && p !== void 0 ? l = p : y && (l = y.nextSibling), f.__u &= -7);
50
- return n.__e = g, l;
47
+ function rt(t, e, n, o, i, s, a, r, l, c, d) {
48
+ var u, h, f, k, p, _, b = o && o.__k || nt, w = e.length;
49
+ for (l = kt(n, e, b, l, w), u = 0; u < w; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? ee : b[f.__i] || ee, f.__i = u, _ = Ee(t, f, h, i, s, a, r, l, c, d), k = f.__e, f.ref && h.ref != f.ref && (h.ref && Le(h.ref, null, f), d.push(f.ref, f.__c || k, f)), p == null && k != null && (p = k), 4 & f.__u || h.__k === f.__k ? l = it(f, l, t) : typeof f.type == "function" && _ !== void 0 ? l = _ : k && (l = k.nextSibling), f.__u &= -7);
50
+ return n.__e = p, l;
51
51
  }
52
- function ht(t, e, n, o, i) {
52
+ function kt(t, e, n, o, i) {
53
53
  var s, a, r, l, c, d = n.length, u = d, h = 0;
54
- 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 ? ne(null, a, null, null, null) : ue(a) ? ne(de, { children: a }, null, null, null) : a.constructor == null && a.__b > 0 ? ne(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 = ft(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;
55
- if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = H(r)), ot(r, r));
54
+ for (t.__k = new Array(i), s = 0; s < i; s++) (a = e[s]) != null && typeof a != "boolean" && typeof a != "function" ? (l = s + h, (a = t.__k[s] = typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? se(null, a, null, null, null) : me(a) ? se(_e, { children: a }, null, null, null) : a.constructor == null && a.__b > 0 ? se(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : a).__ = t, a.__b = t.__b + 1, r = null, (c = a.__i = St(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;
55
+ if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = K(r)), lt(r, r));
56
56
  return o;
57
57
  }
58
- function et(t, e, n) {
58
+ function it(t, e, n) {
59
59
  var o, i;
60
60
  if (typeof t.type == "function") {
61
- for (o = t.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = t, e = et(o[i], e, n));
61
+ for (o = t.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = t, e = it(o[i], e, n));
62
62
  return e;
63
63
  }
64
- t.__e != e && (e && t.type && !n.contains(e) && (e = H(t)), n.insertBefore(t.__e, e || null), e = t.__e);
64
+ t.__e != e && (e && t.type && !n.contains(e) && (e = K(t)), n.insertBefore(t.__e, e || null), e = t.__e);
65
65
  do
66
66
  e = e && e.nextSibling;
67
67
  while (e != null && e.nodeType == 8);
68
68
  return e;
69
69
  }
70
- function ft(t, e, n, o) {
70
+ function St(t, e, n, o) {
71
71
  var i, s, a = t.key, r = t.type, l = e[n];
72
72
  if (l === null && t.key == null || l && a == l.key && r == l.type && (2 & l.__u) == 0) return n;
73
73
  if (o > (l != null && (2 & l.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < e.length; ) {
@@ -82,17 +82,17 @@ function ft(t, e, n, o) {
82
82
  }
83
83
  return -1;
84
84
  }
85
- function ze(t, e, n) {
86
- e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || ut.test(e) ? n : n + "px";
85
+ function Ie(t, e, n) {
86
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || bt.test(e) ? n : n + "px";
87
87
  }
88
- function ee(t, e, n, o, i) {
88
+ function re(t, e, n, o, i) {
89
89
  var s;
90
90
  e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
91
91
  else {
92
- if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || ze(t.style, e, "");
93
- if (n) for (e in n) o && n[e] == o[e] || ze(t.style, e, n[e]);
92
+ if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || Ie(t.style, e, "");
93
+ if (n) for (e in n) o && n[e] == o[e] || Ie(t.style, e, n[e]);
94
94
  }
95
- else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(Ye, "$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 = we, t.addEventListener(e, s ? pe : ve, s)) : t.removeEventListener(e, s ? pe : ve, s);
95
+ else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(et, "$1")), e = e.toLowerCase() in t || e == "onFocusOut" || e == "onFocusIn" ? e.toLowerCase().slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + s] = n, n ? o ? n.u = o.u : (n.u = Se, t.addEventListener(e, s ? ye : Ce, s)) : t.removeEventListener(e, s ? ye : Ce, s);
96
96
  else {
97
97
  if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
98
98
  else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
@@ -103,54 +103,54 @@ function ee(t, e, n, o, i) {
103
103
  typeof n == "function" || (n == null || n === !1 && e[4] != "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && n == 1 ? "" : n));
104
104
  }
105
105
  }
106
- function Ne(t) {
106
+ function xe(t) {
107
107
  return function(e) {
108
108
  if (this.l) {
109
109
  var n = this.l[e.type + t];
110
- if (e.t == null) e.t = we++;
110
+ if (e.t == null) e.t = Se++;
111
111
  else if (e.t < n.u) return;
112
112
  return n(A.event ? A.event(e) : e);
113
113
  }
114
114
  };
115
115
  }
116
- function be(t, e, n, o, i, s, a, r, l, c) {
117
- var d, u, h, f, y, g, p, m, _, k, T, L, C, S, w, E, b, z = e.type;
116
+ function Ee(t, e, n, o, i, s, a, r, l, c) {
117
+ var d, u, h, f, k, p, _, b, w, M, C, z, S, E, L, y, g, v = e.type;
118
118
  if (e.constructor != null) return null;
119
119
  128 & n.__u && (l = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d = A.__b) && d(e);
120
- e: if (typeof z == "function") try {
121
- if (m = e.props, _ = "prototype" in z && z.prototype.render, k = (d = z.contextType) && o[d.__c], T = d ? k ? k.props.value : d.__ : o, n.__c ? p = (u = e.__c = n.__c).__ = u.__E : (_ ? e.__c = u = new z(m, T) : (e.__c = u = new oe(m, T), u.constructor = z, u.render = mt), k && k.sub(u), u.props = m, u.state || (u.state = {}), u.context = T, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), _ && u.__s == null && (u.__s = u.state), _ && z.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = j({}, u.__s)), j(u.__s, z.getDerivedStateFromProps(m, u.__s))), f = u.props, y = u.state, u.__v = e, h) _ && z.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), _ && u.componentDidMount != null && u.__h.push(u.componentDidMount);
120
+ e: if (typeof v == "function") try {
121
+ if (b = e.props, w = "prototype" in v && v.prototype.render, M = (d = v.contextType) && o[d.__c], C = d ? M ? M.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (w ? e.__c = u = new v(b, C) : (e.__c = u = new ae(b, C), u.constructor = v, u.render = Et), M && M.sub(u), u.props = b, u.state || (u.state = {}), u.context = C, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), w && u.__s == null && (u.__s = u.state), w && v.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = H({}, u.__s)), H(u.__s, v.getDerivedStateFromProps(b, u.__s))), f = u.props, k = u.state, u.__v = e, h) w && v.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), w && u.componentDidMount != null && u.__h.push(u.componentDidMount);
122
122
  else {
123
- if (_ && z.getDerivedStateFromProps == null && m !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(m, T), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(m, u.__s, T) === !1 || e.__v == n.__v) {
124
- 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(N) {
125
- N && (N.__ = e);
126
- }), L = 0; L < u._sb.length; L++) u.__h.push(u._sb[L]);
123
+ if (w && v.getDerivedStateFromProps == null && b !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(b, C), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(b, u.__s, C) === !1 || e.__v == n.__v) {
124
+ for (e.__v != n.__v && (u.props = b, u.state = u.__s, u.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(T) {
125
+ T && (T.__ = e);
126
+ }), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
127
127
  u._sb = [], u.__h.length && a.push(u);
128
128
  break e;
129
129
  }
130
- u.componentWillUpdate != null && u.componentWillUpdate(m, u.__s, T), _ && u.componentDidUpdate != null && u.__h.push(function() {
131
- u.componentDidUpdate(f, y, g);
130
+ u.componentWillUpdate != null && u.componentWillUpdate(b, u.__s, C), w && u.componentDidUpdate != null && u.__h.push(function() {
131
+ u.componentDidUpdate(f, k, p);
132
132
  });
133
133
  }
134
- if (u.context = T, u.props = m, u.__P = t, u.__e = !1, C = A.__r, S = 0, _) {
135
- for (u.state = u.__s, u.__d = !1, C && C(e), d = u.render(u.props, u.state, u.context), w = 0; w < u._sb.length; w++) u.__h.push(u._sb[w]);
134
+ if (u.context = C, u.props = b, u.__P = t, u.__e = !1, S = A.__r, E = 0, w) {
135
+ for (u.state = u.__s, u.__d = !1, S && S(e), d = u.render(u.props, u.state, u.context), L = 0; L < u._sb.length; L++) u.__h.push(u._sb[L]);
136
136
  u._sb = [];
137
137
  } else do
138
- u.__d = !1, C && C(e), d = u.render(u.props, u.state, u.context), u.state = u.__s;
139
- while (u.__d && ++S < 25);
140
- u.state = u.__s, u.getChildContext != null && (o = j(j({}, o), u.getChildContext())), _ && !h && u.getSnapshotBeforeUpdate != null && (g = u.getSnapshotBeforeUpdate(f, y)), E = d, d != null && d.type === de && d.key == null && (E = nt(d.props.children)), r = Qe(t, ue(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), p && (u.__E = u.__ = null);
141
- } catch (N) {
142
- if (e.__v = null, l || s != null) if (N.then) {
138
+ u.__d = !1, S && S(e), d = u.render(u.props, u.state, u.context), u.state = u.__s;
139
+ while (u.__d && ++E < 25);
140
+ u.state = u.__s, u.getChildContext != null && (o = H(H({}, o), u.getChildContext())), w && !h && u.getSnapshotBeforeUpdate != null && (p = u.getSnapshotBeforeUpdate(f, k)), y = d, d != null && d.type === _e && d.key == null && (y = at(d.props.children)), r = rt(t, me(y) ? y : [y], e, n, o, i, s, a, r, l, c), u.base = e.__e, e.__u &= -161, u.__h.length && a.push(u), _ && (u.__E = u.__ = null);
141
+ } catch (T) {
142
+ if (e.__v = null, l || s != null) if (T.then) {
143
143
  for (e.__u |= l ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
144
144
  s[s.indexOf(r)] = null, e.__e = r;
145
- } else for (b = s.length; b--; ) ye(s[b]);
145
+ } else for (g = s.length; g--; ) ze(s[g]);
146
146
  else e.__e = n.__e, e.__k = n.__k;
147
- A.__e(N, e, n);
147
+ A.__e(T, e, n);
148
148
  }
149
- else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e = _t(n.__e, e, n, o, i, s, a, l, c);
149
+ else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e = zt(n.__e, e, n, o, i, s, a, l, c);
150
150
  return (d = A.diffed) && d(e), 128 & e.__u ? void 0 : r;
151
151
  }
152
- function tt(t, e, n) {
153
- for (var o = 0; o < n.length; o++) ke(n[o], n[++o], n[++o]);
152
+ function st(t, e, n) {
153
+ for (var o = 0; o < n.length; o++) Le(n[o], n[++o], n[++o]);
154
154
  A.__c && A.__c(e, t), t.some(function(i) {
155
155
  try {
156
156
  t = i.__h, i.__h = [], t.some(function(s) {
@@ -161,39 +161,39 @@ function tt(t, e, n) {
161
161
  }
162
162
  });
163
163
  }
164
- function nt(t) {
165
- return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : ue(t) ? t.map(nt) : j({}, t);
164
+ function at(t) {
165
+ return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : me(t) ? t.map(at) : H({}, t);
166
166
  }
167
- function _t(t, e, n, o, i, s, a, r, l) {
168
- var c, d, u, h, f, y, g, p = n.props, m = e.props, _ = e.type;
169
- if (_ == "svg" ? i = "http://www.w3.org/2000/svg" : _ == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
170
- for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!_ && (_ ? f.localName == _ : f.nodeType == 3)) {
167
+ function zt(t, e, n, o, i, s, a, r, l) {
168
+ var c, d, u, h, f, k, p, _ = n.props, b = e.props, w = e.type;
169
+ if (w == "svg" ? i = "http://www.w3.org/2000/svg" : w == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
170
+ for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!w && (w ? f.localName == w : f.nodeType == 3)) {
171
171
  t = f, s[c] = null;
172
172
  break;
173
173
  }
174
174
  }
175
175
  if (t == null) {
176
- if (_ == null) return document.createTextNode(m);
177
- t = document.createElementNS(i, _, m.is && m), r && (A.__m && A.__m(e, s), r = !1), s = null;
176
+ if (w == null) return document.createTextNode(b);
177
+ t = document.createElementNS(i, w, b.is && b), r && (A.__m && A.__m(e, s), r = !1), s = null;
178
178
  }
179
- if (_ == null) p === m || r && t.data == m || (t.data = m);
179
+ if (w == null) _ === b || r && t.data == b || (t.data = b);
180
180
  else {
181
- if (s = s && ce.call(t.childNodes), p = n.props || K, !r && s != null) for (p = {}, c = 0; c < t.attributes.length; c++) p[(f = t.attributes[c]).name] = f.value;
182
- for (c in p) if (f = p[c], c != "children") {
181
+ if (s = s && fe.call(t.childNodes), _ = n.props || ee, !r && s != null) for (_ = {}, c = 0; c < t.attributes.length; c++) _[(f = t.attributes[c]).name] = f.value;
182
+ for (c in _) if (f = _[c], c != "children") {
183
183
  if (c == "dangerouslySetInnerHTML") u = f;
184
- else if (!(c in m)) {
185
- if (c == "value" && "defaultValue" in m || c == "checked" && "defaultChecked" in m) continue;
186
- ee(t, c, null, f, i);
184
+ else if (!(c in b)) {
185
+ if (c == "value" && "defaultValue" in b || c == "checked" && "defaultChecked" in b) continue;
186
+ re(t, c, null, f, i);
187
187
  }
188
188
  }
189
- for (c in m) f = m[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? y = f : c == "checked" ? g = f : r && typeof f != "function" || p[c] === f || ee(t, c, f, p[c], i);
189
+ for (c in b) f = b[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? k = f : c == "checked" ? p = f : r && typeof f != "function" || _[c] === f || re(t, c, f, _[c], i);
190
190
  if (d) r || u && (d.__html == u.__html || d.__html == t.innerHTML) || (t.innerHTML = d.__html), e.__k = [];
191
- else if (u && (t.innerHTML = ""), Qe(e.type == "template" ? t.content : t, ue(h) ? h : [h], e, n, o, _ == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && H(n, 0), r, l), s != null) for (c = s.length; c--; ) ye(s[c]);
192
- r || (c = "value", _ == "progress" && y == null ? t.removeAttribute("value") : y != null && (y !== t[c] || _ == "progress" && !y || _ == "option" && y != p[c]) && ee(t, c, y, p[c], i), c = "checked", g != null && g != t[c] && ee(t, c, g, p[c], i));
191
+ else if (u && (t.innerHTML = ""), rt(e.type == "template" ? t.content : t, me(h) ? h : [h], e, n, o, w == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && K(n, 0), r, l), s != null) for (c = s.length; c--; ) ze(s[c]);
192
+ r || (c = "value", w == "progress" && k == null ? t.removeAttribute("value") : k != null && (k !== t[c] || w == "progress" && !k || w == "option" && k != _[c]) && re(t, c, k, _[c], i), c = "checked", p != null && p != t[c] && re(t, c, p, _[c], i));
193
193
  }
194
194
  return t;
195
195
  }
196
- function ke(t, e, n) {
196
+ function Le(t, e, n) {
197
197
  try {
198
198
  if (typeof t == "function") {
199
199
  var o = typeof t.__u == "function";
@@ -203,9 +203,9 @@ function ke(t, e, n) {
203
203
  A.__e(i, n);
204
204
  }
205
205
  }
206
- function ot(t, e, n) {
206
+ function lt(t, e, n) {
207
207
  var o, i;
208
- if (A.unmount && A.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || ke(o, null, e)), (o = t.__c) != null) {
208
+ if (A.unmount && A.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || Le(o, null, e)), (o = t.__c) != null) {
209
209
  if (o.componentWillUnmount) try {
210
210
  o.componentWillUnmount();
211
211
  } catch (s) {
@@ -213,17 +213,17 @@ function ot(t, e, n) {
213
213
  }
214
214
  o.base = o.__P = null;
215
215
  }
216
- if (o = t.__k) for (i = 0; i < o.length; i++) o[i] && ot(o[i], e, n || typeof t.type != "function");
217
- n || ye(t.__e), t.__c = t.__ = t.__e = void 0;
216
+ if (o = t.__k) for (i = 0; i < o.length; i++) o[i] && lt(o[i], e, n || typeof t.type != "function");
217
+ n || ze(t.__e), t.__c = t.__ = t.__e = void 0;
218
218
  }
219
- function mt(t, e, n) {
219
+ function Et(t, e, n) {
220
220
  return this.constructor(t, n);
221
221
  }
222
- function vt(t, e, n) {
222
+ function Re(t, e, n) {
223
223
  var o, i, s, a;
224
- e == document && (e = document.documentElement), A.__ && A.__(t, e), i = (o = !1) ? null : e.__k, s = [], a = [], be(e, t = e.__k = dt(de, null, [t]), i || K, K, e.namespaceURI, i ? null : e.firstChild ? ce.call(e.childNodes) : null, s, i ? i.__e : e.firstChild, o, a), tt(s, t, a);
224
+ e == document && (e = document.documentElement), A.__ && A.__(t, e), i = (o = !1) ? null : e.__k, s = [], a = [], Ee(e, t = e.__k = Tt(_e, null, [t]), i || ee, ee, e.namespaceURI, i ? null : e.firstChild ? fe.call(e.childNodes) : null, s, i ? i.__e : e.firstChild, o, a), st(s, t, a);
225
225
  }
226
- function pt(t) {
226
+ function Lt(t) {
227
227
  function e(n) {
228
228
  var o, i;
229
229
  return this.getChildContext || (o = /* @__PURE__ */ new Set(), (i = {})[e.__c] = this, this.getChildContext = function() {
@@ -232,7 +232,7 @@ function pt(t) {
232
232
  o = null;
233
233
  }, this.shouldComponentUpdate = function(s) {
234
234
  this.props.value != s.value && o.forEach(function(a) {
235
- a.__e = !0, ge(a);
235
+ a.__e = !0, be(a);
236
236
  });
237
237
  }, this.sub = function(s) {
238
238
  o.add(s);
@@ -242,49 +242,49 @@ function pt(t) {
242
242
  };
243
243
  }), n.children;
244
244
  }
245
- return e.__c = "__cC" + Ke++, e.__ = t, e.Provider = e.__l = (e.Consumer = function(n, o) {
245
+ return e.__c = "__cC" + tt++, e.__ = t, e.Provider = e.__l = (e.Consumer = function(n, o) {
246
246
  return n.children(o);
247
247
  }).contextType = e, e;
248
248
  }
249
- ce = Je.slice, A = { __e: function(t, e, n, o) {
249
+ fe = nt.slice, A = { __e: function(t, e, n, o) {
250
250
  for (var i, s, a; e = e.__; ) if ((i = e.__c) && !i.__) try {
251
251
  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;
252
252
  } catch (r) {
253
253
  t = r;
254
254
  }
255
255
  throw t;
256
- } }, qe = 0, oe.prototype.setState = function(t, e) {
256
+ } }, Je = 0, ae.prototype.setState = function(t, e) {
257
257
  var n;
258
- n = this.__s != null && this.__s != this.state ? this.__s : this.__s = j({}, this.state), typeof t == "function" && (t = t(j({}, n), this.props)), t && j(n, t), t != null && this.__v && (e && this._sb.push(e), ge(this));
259
- }, oe.prototype.forceUpdate = function(t) {
260
- this.__v && (this.__e = !0, t && this.__h.push(t), ge(this));
261
- }, oe.prototype.render = de, G = [], Ve = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Xe = function(t, e) {
258
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = H({}, this.state), typeof t == "function" && (t = t(H({}, n), this.props)), t && H(n, t), t != null && this.__v && (e && this._sb.push(e), be(this));
259
+ }, ae.prototype.forceUpdate = function(t) {
260
+ this.__v && (this.__e = !0, t && this.__h.push(t), be(this));
261
+ }, ae.prototype.render = _e, X = [], Ze = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Qe = function(t, e) {
262
262
  return t.__v.__b - e.__v.__b;
263
- }, le.__r = 0, Ye = /(PointerCapture)$|Capture$/i, we = 0, ve = Ne(!1), pe = Ne(!0), Ke = 0;
264
- var gt = 0;
265
- function v(t, e, n, o, i, s) {
263
+ }, de.__r = 0, et = /(PointerCapture)$|Capture$/i, Se = 0, Ce = xe(!1), ye = xe(!0), tt = 0;
264
+ var Nt = 0;
265
+ function m(t, e, n, o, i, s) {
266
266
  e || (e = {});
267
267
  var a, r, l = e;
268
268
  if ("ref" in l) for (r in l = {}, e) r == "ref" ? a = e[r] : l[r] = e[r];
269
- var c = { type: t, props: l, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --gt, __i: -1, __u: 0, __source: i, __self: s };
269
+ var c = { type: t, props: l, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Nt, __i: -1, __u: 0, __source: i, __self: s };
270
270
  if (typeof t == "function" && (a = t.defaultProps)) for (r in a) l[r] === void 0 && (l[r] = a[r]);
271
271
  return A.vnode && A.vnode(c), c;
272
272
  }
273
- var q, M, _e, Ae, J = 0, rt = [], P = A, Me = P.__b, Pe = P.__r, Ie = P.diffed, xe = P.__c, De = P.unmount, Fe = P.__;
274
- function he(t, e) {
275
- P.__h && P.__h(M, t, J || e), J = 0;
276
- var n = M.__H || (M.__H = { __: [], __h: [] });
273
+ var J, x, pe, Fe, te = 0, ct = [], F = A, De = F.__b, Oe = F.__r, $e = F.diffed, Ue = F.__c, Ge = F.unmount, We = F.__;
274
+ function ve(t, e) {
275
+ F.__h && F.__h(x, t, te || e), te = 0;
276
+ var n = x.__H || (x.__H = { __: [], __h: [] });
277
277
  return t >= n.__.length && n.__.push({}), n.__[t];
278
278
  }
279
- function B(t) {
280
- return J = 1, Ct(st, t);
279
+ function U(t) {
280
+ return te = 1, Mt(dt, t);
281
281
  }
282
- function Ct(t, e, n) {
283
- var o = he(q++, 2);
284
- if (o.t = t, !o.__c && (o.__ = [st(void 0, e), function(r) {
282
+ function Mt(t, e, n) {
283
+ var o = ve(J++, 2);
284
+ if (o.t = t, !o.__c && (o.__ = [dt(void 0, e), function(r) {
285
285
  var l = o.__N ? o.__N[0] : o.__[0], c = o.t(l, r);
286
286
  l !== c && (o.__N = [c, o.__[1]], o.__c.setState({}));
287
- }], o.__c = M, !M.__f)) {
287
+ }], o.__c = x, !x.__f)) {
288
288
  var i = function(r, l, c) {
289
289
  if (!o.__c.__H) return !0;
290
290
  var d = o.__c.__H.__.filter(function(h) {
@@ -301,110 +301,110 @@ function Ct(t, e, n) {
301
301
  }
302
302
  }), s && s.call(this, r, l, c) || u;
303
303
  };
304
- M.__f = !0;
305
- var s = M.shouldComponentUpdate, a = M.componentWillUpdate;
306
- M.componentWillUpdate = function(r, l, c) {
304
+ x.__f = !0;
305
+ var s = x.shouldComponentUpdate, a = x.componentWillUpdate;
306
+ x.componentWillUpdate = function(r, l, c) {
307
307
  if (this.__e) {
308
308
  var d = s;
309
309
  s = void 0, i(r, l, c), s = d;
310
310
  }
311
311
  a && a.call(this, r, l, c);
312
- }, M.shouldComponentUpdate = i;
312
+ }, x.shouldComponentUpdate = i;
313
313
  }
314
314
  return o.__N || o.__;
315
315
  }
316
- function D(t, e) {
317
- var n = he(q++, 3);
318
- !P.__s && it(n.__H, e) && (n.__ = t, n.u = e, M.__H.__h.push(n));
316
+ function R(t, e) {
317
+ var n = ve(J++, 3);
318
+ !F.__s && ut(n.__H, e) && (n.__ = t, n.u = e, x.__H.__h.push(n));
319
319
  }
320
- function W(t) {
321
- return J = 5, V(function() {
320
+ function O(t) {
321
+ return te = 5, Z(function() {
322
322
  return { current: t };
323
323
  }, []);
324
324
  }
325
- function V(t, e) {
326
- var n = he(q++, 7);
327
- return it(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
325
+ function Z(t, e) {
326
+ var n = ve(J++, 7);
327
+ return ut(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
328
328
  }
329
- function Re(t, e) {
330
- return J = 8, V(function() {
329
+ function je(t, e) {
330
+ return te = 8, Z(function() {
331
331
  return t;
332
332
  }, e);
333
333
  }
334
- function wt(t) {
335
- var e = M.context[t.__c], n = he(q++, 9);
336
- return n.c = t, e ? (n.__ == null && (n.__ = !0, e.sub(M)), e.props.value) : t.__;
334
+ function At(t) {
335
+ var e = x.context[t.__c], n = ve(J++, 9);
336
+ return n.c = t, e ? (n.__ == null && (n.__ = !0, e.sub(x)), e.props.value) : t.__;
337
337
  }
338
- function yt() {
339
- for (var t; t = rt.shift(); ) if (t.__P && t.__H) try {
340
- t.__H.__h.forEach(re), t.__H.__h.forEach(Ce), t.__H.__h = [];
338
+ function Pt() {
339
+ for (var t; t = ct.shift(); ) if (t.__P && t.__H) try {
340
+ t.__H.__h.forEach(le), t.__H.__h.forEach(Te), t.__H.__h = [];
341
341
  } catch (e) {
342
- t.__H.__h = [], P.__e(e, t.__v);
342
+ t.__H.__h = [], F.__e(e, t.__v);
343
343
  }
344
344
  }
345
- P.__b = function(t) {
346
- M = null, Me && Me(t);
347
- }, P.__ = function(t, e) {
348
- t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Fe && Fe(t, e);
349
- }, P.__r = function(t) {
350
- Pe && Pe(t), q = 0;
351
- var e = (M = t.__c).__H;
352
- e && (_e === M ? (e.__h = [], M.__h = [], e.__.forEach(function(n) {
345
+ F.__b = function(t) {
346
+ x = null, De && De(t);
347
+ }, F.__ = function(t, e) {
348
+ t && e.__k && e.__k.__m && (t.__m = e.__k.__m), We && We(t, e);
349
+ }, F.__r = function(t) {
350
+ Oe && Oe(t), J = 0;
351
+ var e = (x = t.__c).__H;
352
+ e && (pe === x ? (e.__h = [], x.__h = [], e.__.forEach(function(n) {
353
353
  n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
354
- })) : (e.__h.forEach(re), e.__h.forEach(Ce), e.__h = [], q = 0)), _e = M;
355
- }, P.diffed = function(t) {
356
- Ie && Ie(t);
354
+ })) : (e.__h.forEach(le), e.__h.forEach(Te), e.__h = [], J = 0)), pe = x;
355
+ }, F.diffed = function(t) {
356
+ $e && $e(t);
357
357
  var e = t.__c;
358
- e && e.__H && (e.__H.__h.length && (rt.push(e) !== 1 && Ae === P.requestAnimationFrame || ((Ae = P.requestAnimationFrame) || bt)(yt)), e.__H.__.forEach(function(n) {
358
+ e && e.__H && (e.__H.__h.length && (ct.push(e) !== 1 && Fe === F.requestAnimationFrame || ((Fe = F.requestAnimationFrame) || It)(Pt)), e.__H.__.forEach(function(n) {
359
359
  n.u && (n.__H = n.u), n.u = void 0;
360
- })), _e = M = null;
361
- }, P.__c = function(t, e) {
360
+ })), pe = x = null;
361
+ }, F.__c = function(t, e) {
362
362
  e.some(function(n) {
363
363
  try {
364
- n.__h.forEach(re), n.__h = n.__h.filter(function(o) {
365
- return !o.__ || Ce(o);
364
+ n.__h.forEach(le), n.__h = n.__h.filter(function(o) {
365
+ return !o.__ || Te(o);
366
366
  });
367
367
  } catch (o) {
368
368
  e.some(function(i) {
369
369
  i.__h && (i.__h = []);
370
- }), e = [], P.__e(o, n.__v);
370
+ }), e = [], F.__e(o, n.__v);
371
371
  }
372
- }), xe && xe(t, e);
373
- }, P.unmount = function(t) {
374
- De && De(t);
372
+ }), Ue && Ue(t, e);
373
+ }, F.unmount = function(t) {
374
+ Ge && Ge(t);
375
375
  var e, n = t.__c;
376
376
  n && n.__H && (n.__H.__.forEach(function(o) {
377
377
  try {
378
- re(o);
378
+ le(o);
379
379
  } catch (i) {
380
380
  e = i;
381
381
  }
382
- }), n.__H = void 0, e && P.__e(e, n.__v));
382
+ }), n.__H = void 0, e && F.__e(e, n.__v));
383
383
  };
384
- var Oe = typeof requestAnimationFrame == "function";
385
- function bt(t) {
384
+ var qe = typeof requestAnimationFrame == "function";
385
+ function It(t) {
386
386
  var e, n = function() {
387
- clearTimeout(o), Oe && cancelAnimationFrame(e), setTimeout(t);
387
+ clearTimeout(o), qe && cancelAnimationFrame(e), setTimeout(t);
388
388
  }, o = setTimeout(n, 100);
389
- Oe && (e = requestAnimationFrame(n));
389
+ qe && (e = requestAnimationFrame(n));
390
390
  }
391
- function re(t) {
392
- var e = M, n = t.__c;
393
- typeof n == "function" && (t.__c = void 0, n()), M = e;
391
+ function le(t) {
392
+ var e = x, n = t.__c;
393
+ typeof n == "function" && (t.__c = void 0, n()), x = e;
394
394
  }
395
- function Ce(t) {
396
- var e = M;
397
- t.__c = t.__(), M = e;
395
+ function Te(t) {
396
+ var e = x;
397
+ t.__c = t.__(), x = e;
398
398
  }
399
- function it(t, e) {
399
+ function ut(t, e) {
400
400
  return !t || t.length !== e.length || e.some(function(n, o) {
401
401
  return n !== t[o];
402
402
  });
403
403
  }
404
- function st(t, e) {
404
+ function dt(t, e) {
405
405
  return typeof e == "function" ? e(t) : e;
406
406
  }
407
- const kt = (t) => ({
407
+ const xt = (t) => ({
408
408
  saveGameData(e) {
409
409
  try {
410
410
  localStorage.setItem(t, JSON.stringify(e));
@@ -427,14 +427,14 @@ const kt = (t) => ({
427
427
  console.error("Failed to reset maze game data:", e);
428
428
  }
429
429
  }
430
- }), lt = pt(void 0), $e = {
430
+ }), ht = Lt(void 0), He = {
431
431
  currentLevel: 1,
432
432
  highestUnlockedLevel: 1,
433
433
  currentTier: 1,
434
434
  highestUnlockedTier: 1,
435
435
  levelScores: {},
436
436
  totalScore: 0
437
- }, Ue = {
437
+ }, ke = {
438
438
  isGameActive: !0,
439
439
  levelTransitioning: !1,
440
440
  maze: null,
@@ -447,9 +447,9 @@ const kt = (t) => ({
447
447
  showClue: !1,
448
448
  playerPath: [],
449
449
  visitCounts: {}
450
- }, Tt = ({ children: t, config: e }) => {
451
- const n = kt(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = B(() => o || { ...$e });
452
- D(() => {
450
+ }, Rt = ({ children: t, config: e }) => {
451
+ const n = xt(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = U(() => o || { ...He });
452
+ R(() => {
453
453
  const u = Object.values(i.levelScores).reduce(
454
454
  (h, f) => h + f,
455
455
  0
@@ -458,7 +458,7 @@ const kt = (t) => ({
458
458
  ...h,
459
459
  totalScore: u
460
460
  }));
461
- }, [i.levelScores]), D(() => {
461
+ }, [i.levelScores]), R(() => {
462
462
  n.saveGameData(i);
463
463
  }, [
464
464
  i.currentLevel,
@@ -468,13 +468,13 @@ const kt = (t) => ({
468
468
  i.levelScores,
469
469
  i.totalScore
470
470
  ]);
471
- const [a, r] = B({
472
- ...Ue
473
- }), l = W(a);
474
- D(() => {
471
+ const [a, r] = U({
472
+ ...ke
473
+ }), l = O(a);
474
+ R(() => {
475
475
  l.current = a;
476
476
  }, [a]);
477
- const c = V(() => [
477
+ const c = Z(() => [
478
478
  a.playerAtExit ? 1 : 0,
479
479
  a.foodCollected === a.totalFoodCount ? 1 : 0,
480
480
  a.showClue ? 0 : 1
@@ -485,13 +485,13 @@ const kt = (t) => ({
485
485
  a.showClue
486
486
  ]), d = () => {
487
487
  n.resetGameData(), s({
488
- ...$e
488
+ ...He
489
489
  }), r({
490
- ...Ue
490
+ ...ke
491
491
  });
492
492
  };
493
- return /* @__PURE__ */ v(
494
- lt.Provider,
493
+ return /* @__PURE__ */ m(
494
+ ht.Provider,
495
495
  {
496
496
  value: {
497
497
  gameProgress: i,
@@ -506,12 +506,12 @@ const kt = (t) => ({
506
506
  children: t
507
507
  }
508
508
  );
509
- }, X = () => {
510
- const t = wt(lt);
509
+ }, ne = () => {
510
+ const t = At(ht);
511
511
  if (!t)
512
512
  throw new Error("useGameContext must be used within a GameProvider");
513
513
  return t;
514
- }, Z = (t) => V(() => {
514
+ }, oe = (t) => Z(() => {
515
515
  const e = t.map((r) => r.length), n = e.reduce((r, l) => r + l, 0), o = t.length, i = (r) => {
516
516
  if (r < 1 || r > n) return 0;
517
517
  let l = 0;
@@ -564,9 +564,9 @@ const kt = (t) => ({
564
564
  }
565
565
  };
566
566
  return a;
567
- }, [t]), St = ({ onTierChange: t, disabled: e }) => {
568
- const { gameProgress: n, config: o } = X(), { i18n: i, levelConfig: s } = o, { currentTier: a, highestUnlockedTier: r } = n, c = Z(s).getTotalTiers();
569
- return /* @__PURE__ */ v("div", { className: "tier-selector", children: /* @__PURE__ */ v(
567
+ }, [t]), Ft = ({ onTierChange: t, disabled: e }) => {
568
+ const { gameProgress: n, config: o } = ne(), { i18n: i, levelConfig: s } = o, { currentTier: a, highestUnlockedTier: r } = n, c = oe(s).getTotalTiers();
569
+ return /* @__PURE__ */ m("div", { className: "tier-selector", children: /* @__PURE__ */ m(
570
570
  "select",
571
571
  {
572
572
  value: a,
@@ -575,7 +575,7 @@ const kt = (t) => ({
575
575
  },
576
576
  disabled: e,
577
577
  className: "tier-dropdown",
578
- children: Array.from({ length: c }, (d, u) => u + 1).map((d) => /* @__PURE__ */ v(
578
+ children: Array.from({ length: c }, (d, u) => u + 1).map((d) => /* @__PURE__ */ m(
579
579
  "option",
580
580
  {
581
581
  value: d,
@@ -586,18 +586,18 @@ const kt = (t) => ({
586
586
  ))
587
587
  }
588
588
  ) });
589
- }, Et = ({ onLevelChange: t, disabled: e }) => {
590
- const { gameProgress: n, config: o } = X(), { i18n: i, levelConfig: s } = o, { currentTier: a, levelScores: r, currentLevel: l, highestUnlockedLevel: c } = n, d = Z(s), u = V(() => {
589
+ }, Dt = ({ onLevelChange: t, disabled: e }) => {
590
+ const { gameProgress: n, config: o } = ne(), { i18n: i, levelConfig: s } = o, { currentTier: a, levelScores: r, currentLevel: l, highestUnlockedLevel: c } = n, d = oe(s), u = Z(() => {
591
591
  const [h, f] = d.getTierLevelsRange(a);
592
- return Array.from({ length: f - h + 1 }, (y, g) => {
593
- const p = h + g, m = r[p] || 0;
592
+ return Array.from({ length: f - h + 1 }, (k, p) => {
593
+ const _ = h + p, b = r[_] || 0;
594
594
  return {
595
- level: p,
596
- score: m
595
+ level: _,
596
+ score: b
597
597
  };
598
598
  });
599
599
  }, [a, r]);
600
- return /* @__PURE__ */ v("div", { className: "level-selector", children: /* @__PURE__ */ v(
600
+ return /* @__PURE__ */ m("div", { className: "level-selector", children: /* @__PURE__ */ m(
601
601
  "select",
602
602
  {
603
603
  value: l,
@@ -606,7 +606,7 @@ const kt = (t) => ({
606
606
  },
607
607
  disabled: e,
608
608
  className: "level-dropdown",
609
- children: u.map(({ level: h, score: f }) => /* @__PURE__ */ v(
609
+ children: u.map(({ level: h, score: f }) => /* @__PURE__ */ m(
610
610
  "option",
611
611
  {
612
612
  value: h,
@@ -617,7 +617,7 @@ const kt = (t) => ({
617
617
  ))
618
618
  }
619
619
  ) });
620
- }, ie = ({
620
+ }, Q = ({
621
621
  isOpen: t,
622
622
  title: e,
623
623
  className: n = "",
@@ -632,23 +632,23 @@ const kt = (t) => ({
632
632
  onConfirm: u,
633
633
  onCancel: h
634
634
  }) => {
635
- const f = W(null);
636
- return D(() => {
637
- const y = (g) => {
638
- g.key === "Escape" && h?.();
635
+ const f = O(null);
636
+ return R(() => {
637
+ const k = (p) => {
638
+ p.key === "Escape" && h?.();
639
639
  };
640
- return t && document.addEventListener("keydown", y), () => {
641
- document.removeEventListener("keydown", y);
640
+ return t && document.addEventListener("keydown", k), () => {
641
+ document.removeEventListener("keydown", k);
642
642
  };
643
- }, [t, h]), /* @__PURE__ */ v(
643
+ }, [t, h]), /* @__PURE__ */ m(
644
644
  "div",
645
645
  {
646
646
  className: `maze-dialog-overlay ${t ? "maze-dialog-visible" : ""}`,
647
- children: /* @__PURE__ */ v("div", { className: "maze-dialog " + n, ref: f, children: [
648
- /* @__PURE__ */ v("div", { className: "maze-dialog-title", children: e }),
649
- /* @__PURE__ */ v("div", { className: "maze-dialog-content", children: i || /* @__PURE__ */ v("div", { className: "maze-dialog-message", children: o }) }),
650
- (!a || !s) && /* @__PURE__ */ v("div", { className: "maze-dialog-buttons", children: [
651
- !a && /* @__PURE__ */ v(
647
+ children: /* @__PURE__ */ m("div", { className: "maze-dialog " + n, ref: f, children: [
648
+ /* @__PURE__ */ m("div", { className: "maze-dialog-title", children: e }),
649
+ /* @__PURE__ */ m("div", { className: "maze-dialog-content", children: i || /* @__PURE__ */ m("div", { className: "maze-dialog-message", children: o }) }),
650
+ (!a || !s) && /* @__PURE__ */ m("div", { className: "maze-dialog-buttons", children: [
651
+ !a && /* @__PURE__ */ m(
652
652
  "button",
653
653
  {
654
654
  type: "button",
@@ -657,7 +657,7 @@ const kt = (t) => ({
657
657
  children: l
658
658
  }
659
659
  ),
660
- !s && /* @__PURE__ */ v(
660
+ !s && /* @__PURE__ */ m(
661
661
  "button",
662
662
  {
663
663
  type: "button",
@@ -670,7 +670,7 @@ const kt = (t) => ({
670
670
  ] })
671
671
  }
672
672
  );
673
- }, U = {
673
+ }, j = {
674
674
  container: null,
675
675
  // attach Toast container to element, only need to execute once
676
676
  attachTo(t) {
@@ -700,7 +700,7 @@ const kt = (t) => ({
700
700
  for (; this.container.firstChild; )
701
701
  this.container.removeChild(this.container.firstChild);
702
702
  }
703
- }, Lt = () => {
703
+ }, Ot = () => {
704
704
  const {
705
705
  gameProgress: t,
706
706
  setGameProgress: e,
@@ -709,169 +709,169 @@ const kt = (t) => ({
709
709
  gamePlayStateRef: i,
710
710
  resetGame: s,
711
711
  config: a
712
- } = X(), { i18n: r, levelConfig: l } = a, c = Z(l), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, y = c.getTotalLevels(), [g, p] = B(!1), [m, _] = B(!1), [k, T] = B(!1), L = (R) => {
713
- const F = c.getFirstLevelOfTier(R);
714
- c.isLevelUnlocked(F, h) && (e((O) => ({ ...O, currentTier: R })), C(F));
715
- }, C = (R) => {
716
- c.isLevelUnlocked(R, h) && (e((F) => ({ ...F, currentLevel: R })), U.show(r.levelGoToast.replace("%LEVEL%", R.toString())));
717
- }, S = () => {
718
- p(!0);
719
- }, w = () => {
720
- p(!1);
712
+ } = ne(), { i18n: r, levelConfig: l } = a, c = oe(l), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, k = c.getTotalLevels(), [p, _] = U(!1), [b, w] = U(!1), [M, C] = U(!1), z = (D) => {
713
+ const I = c.getFirstLevelOfTier(D);
714
+ c.isLevelUnlocked(I, h) && (e(($) => ({ ...$, currentTier: D })), S(I));
715
+ }, S = (D) => {
716
+ c.isLevelUnlocked(D, h) && (e((I) => ({ ...I, currentLevel: D })), j.show(r.levelGoToast.replace("%LEVEL%", D.toString())));
721
717
  }, E = () => {
722
- T(!0);
723
- }, b = () => {
724
- T(!1);
725
- }, z = () => {
726
- U.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
718
+ _(!0);
719
+ }, L = () => {
720
+ _(!1);
721
+ }, y = () => {
722
+ C(!0);
723
+ }, g = () => {
724
+ C(!1);
725
+ }, v = () => {
726
+ j.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
727
727
  ...i.current,
728
728
  // need to sync with ref
729
729
  showClue: !i.current.showClue
730
- })), T(!1);
730
+ })), C(!1);
731
+ }, T = () => {
732
+ w(!0);
731
733
  }, N = () => {
732
- _(!0);
733
- }, I = () => {
734
- s(), _(!1), U.show(r.resetDoneToast);
735
- }, x = () => {
736
- _(!1);
734
+ s(), w(!1), j.show(r.resetDoneToast);
735
+ }, P = () => {
736
+ w(!1);
737
737
  };
738
- return /* @__PURE__ */ v("div", { class: "game-panel-container", children: [
739
- /* @__PURE__ */ v("div", { className: "game-controls", children: [
740
- /* @__PURE__ */ v("div", { className: "selectors-container", children: [
741
- /* @__PURE__ */ v(
742
- St,
738
+ return /* @__PURE__ */ m("div", { class: "game-panel-container", children: [
739
+ /* @__PURE__ */ m("div", { className: "game-controls", children: [
740
+ /* @__PURE__ */ m("div", { className: "selectors-container", children: [
741
+ /* @__PURE__ */ m(
742
+ Ft,
743
743
  {
744
- onTierChange: L,
744
+ onTierChange: z,
745
745
  disabled: d
746
746
  }
747
747
  ),
748
- /* @__PURE__ */ v(
749
- Et,
748
+ /* @__PURE__ */ m(
749
+ Dt,
750
750
  {
751
- onLevelChange: C,
751
+ onLevelChange: S,
752
752
  disabled: d
753
753
  }
754
754
  )
755
755
  ] }),
756
- /* @__PURE__ */ v(
756
+ /* @__PURE__ */ m(
757
757
  "button",
758
758
  {
759
759
  className: `settings-clue-button ${u ? "clue-on" : "clue-off"}`,
760
760
  disabled: u,
761
761
  title: "Toggle Clue",
762
- onClick: E,
762
+ onClick: y,
763
763
  children: u ? r.clueOn : r.clueOff
764
764
  }
765
765
  )
766
766
  ] }),
767
- /* @__PURE__ */ v("div", { className: "game-settings", children: /* @__PURE__ */ v("span", { className: "game-settings-icon", onClick: S, children: "★ " + f }) }),
768
- /* @__PURE__ */ v(
769
- ie,
767
+ /* @__PURE__ */ m("div", { className: "game-settings", children: /* @__PURE__ */ m("span", { className: "game-settings-icon", onClick: E, children: "★ " + f }) }),
768
+ /* @__PURE__ */ m(
769
+ Q,
770
770
  {
771
- isOpen: g,
771
+ isOpen: p,
772
772
  title: r.settings,
773
773
  noConfirm: !0,
774
774
  cancelText: r.close,
775
- onCancel: w,
775
+ onCancel: L,
776
776
  children: [
777
- /* @__PURE__ */ v("div", { className: "settings-stats", children: [
778
- /* @__PURE__ */ v("div", { children: r.levelComplete + `: ${h}/${y}` }),
779
- /* @__PURE__ */ v("div", { children: r.starsCollected + ": " + f }),
780
- /* @__PURE__ */ v("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
777
+ /* @__PURE__ */ m("div", { className: "settings-stats", children: [
778
+ /* @__PURE__ */ m("div", { children: r.levelComplete + `: ${h}/${k}` }),
779
+ /* @__PURE__ */ m("div", { children: r.starsCollected + ": " + f }),
780
+ /* @__PURE__ */ m("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
781
781
  ] }),
782
- /* @__PURE__ */ v("div", { className: "settings-item-box", children: [
783
- /* @__PURE__ */ v(
782
+ /* @__PURE__ */ m("div", { className: "settings-item-box", children: [
783
+ /* @__PURE__ */ m(
784
784
  "button",
785
785
  {
786
786
  className: "settings-reset-button",
787
787
  title: "Reset Game",
788
- onClick: N,
788
+ onClick: T,
789
789
  children: r.reset
790
790
  }
791
791
  ),
792
- /* @__PURE__ */ v("div", { className: "settings-item-tip", children: r.resetTip })
792
+ /* @__PURE__ */ m("div", { className: "settings-item-tip", children: r.resetTip })
793
793
  ] })
794
794
  ]
795
795
  }
796
796
  ),
797
- /* @__PURE__ */ v(
798
- ie,
797
+ /* @__PURE__ */ m(
798
+ Q,
799
799
  {
800
- isOpen: m,
800
+ isOpen: b,
801
801
  title: r.confirmReset,
802
802
  message: r.confirmResetMessage,
803
803
  confirmText: r.reset,
804
804
  cancelText: r.cancel,
805
- onConfirm: I,
806
- onCancel: x
805
+ onConfirm: N,
806
+ onCancel: P
807
807
  }
808
808
  ),
809
- /* @__PURE__ */ v(
810
- ie,
809
+ /* @__PURE__ */ m(
810
+ Q,
811
811
  {
812
- isOpen: k,
812
+ isOpen: M,
813
813
  title: r.confirmClue,
814
814
  message: r.confirmClueMessage,
815
815
  confirmText: r.confirm,
816
816
  cancelText: r.cancel,
817
- onConfirm: z,
818
- onCancel: b
817
+ onConfirm: v,
818
+ onCancel: g
819
819
  }
820
820
  )
821
821
  ] });
822
822
  };
823
- function Te(t, e) {
823
+ function Ne(t, e) {
824
824
  if (!(t instanceof e))
825
825
  throw new TypeError("Cannot call a class as a function");
826
826
  }
827
- function zt(t, e) {
827
+ function $t(t, e) {
828
828
  for (var n = 0; n < e.length; n++) {
829
829
  var o = e[n];
830
830
  o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o);
831
831
  }
832
832
  }
833
- function Se(t, e, n) {
834
- return e && zt(t.prototype, e), t;
833
+ function Me(t, e, n) {
834
+ return e && $t(t.prototype, e), t;
835
835
  }
836
- function We(t) {
836
+ function Be(t) {
837
837
  return +t.replace(/px/, "");
838
838
  }
839
- function Nt(t) {
840
- var e = window.devicePixelRatio, n = getComputedStyle(t), o = We(n.getPropertyValue("width")), i = We(n.getPropertyValue("height"));
839
+ function Ut(t) {
840
+ var e = window.devicePixelRatio, n = getComputedStyle(t), o = Be(n.getPropertyValue("width")), i = Be(n.getPropertyValue("height"));
841
841
  t.setAttribute("width", (o * e).toString()), t.setAttribute("height", (i * e).toString());
842
842
  }
843
- function $(t, e) {
843
+ function W(t, e) {
844
844
  var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (e - t) + t;
845
845
  return Math.floor(o * Math.pow(10, n)) / Math.pow(10, n);
846
846
  }
847
- function je(t) {
848
- return t[$(0, t.length)];
847
+ function Ve(t) {
848
+ return t[W(0, t.length)];
849
849
  }
850
- var At = 125e-5, Mt = 5e-4, Pt = 9e-4, It = 1e-5, xt = 6, Dt = 80, Ft = 0.9, Rt = 1.7, Ot = 0.2, $t = 0.6, Ut = 0.03, Wt = 0.07, jt = 15, Gt = 82, Bt = 100, Ht = 250, qt = 40, Vt = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
851
- function Ge(t) {
850
+ var Gt = 125e-5, Wt = 5e-4, jt = 9e-4, qt = 1e-5, Ht = 6, Bt = 80, Vt = 0.9, Xt = 1.7, Yt = 0.2, Kt = 0.6, Jt = 0.03, Zt = 0.07, Qt = 15, en = 82, tn = 100, nn = 250, on = 40, rn = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
851
+ function Xe(t) {
852
852
  var e = 1920;
853
853
  return Math.log(t) / Math.log(e);
854
854
  }
855
- var Be = /* @__PURE__ */ function() {
855
+ var Ye = /* @__PURE__ */ function() {
856
856
  function t(e) {
857
- Te(this, t);
858
- var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors, a = e.emojis, r = e.emojiSize, l = e.canvasWidth, c = $(Ft, Rt, 3), d = c * Ge(l);
857
+ Ne(this, t);
858
+ var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors, a = e.emojis, r = e.emojiSize, l = e.canvasWidth, c = W(Vt, Xt, 3), d = c * Xe(l);
859
859
  this.confettiSpeed = {
860
860
  x: d,
861
861
  y: d
862
- }, this.finalConfettiSpeedX = $(Ot, $t, 3), this.rotationSpeed = a.length ? 0.01 : $(Ut, Wt, 3) * Ge(l), this.dragForceCoefficient = $(Mt, Pt, 6), this.radius = {
862
+ }, this.finalConfettiSpeedX = W(Yt, Kt, 3), this.rotationSpeed = a.length ? 0.01 : W(Jt, Zt, 3) * Xe(l), this.dragForceCoefficient = W(Wt, jt, 6), this.radius = {
863
863
  x: i,
864
864
  y: i
865
- }, this.initialRadius = i, this.rotationAngle = o === "left" ? $(0, 0.2, 3) : $(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = $(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
866
- var u = o === "left" ? $(Gt, jt) * Math.PI / 180 : $(-15, -82) * Math.PI / 180;
865
+ }, this.initialRadius = i, this.rotationAngle = o === "left" ? W(0, 0.2, 3) : W(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = W(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
866
+ var u = o === "left" ? W(en, Qt) * Math.PI / 180 : W(-15, -82) * Math.PI / 180;
867
867
  this.absCos = Math.abs(Math.cos(u)), this.absSin = Math.abs(Math.sin(u));
868
- var h = $(-150, 0), f = {
868
+ var h = W(-150, 0), f = {
869
869
  x: n.x + (o === "left" ? -h : h) * this.absCos,
870
870
  y: n.y - h * this.absSin
871
871
  };
872
- this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = a.length ? null : je(s), this.emoji = a.length ? je(a) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
872
+ this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = a.length ? null : Ve(s), this.emoji = a.length ? Ve(a) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
873
873
  }
874
- return Se(t, [{
874
+ return Me(t, [{
875
875
  key: "draw",
876
876
  value: function(n) {
877
877
  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;
@@ -881,7 +881,7 @@ var Be = /* @__PURE__ */ function() {
881
881
  key: "updatePosition",
882
882
  value: function(n, o) {
883
883
  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;
884
- 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 + At * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : It * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
884
+ 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 + Gt * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : qt * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
885
885
  this.emojiRotationAngle += this.rotationSpeed * n % (2 * Math.PI);
886
886
  return;
887
887
  }
@@ -890,16 +890,16 @@ var Be = /* @__PURE__ */ function() {
890
890
  }, {
891
891
  key: "getIsVisibleOnCanvas",
892
892
  value: function(n) {
893
- return this.currentPosition.y < n + Bt;
893
+ return this.currentPosition.y < n + tn;
894
894
  }
895
895
  }]), t;
896
896
  }();
897
- function Xt() {
897
+ function sn() {
898
898
  var t = document.createElement("canvas");
899
899
  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;
900
900
  }
901
- function Yt(t) {
902
- var e = t.confettiRadius, n = e === void 0 ? xt : e, o = t.confettiNumber, i = o === void 0 ? t.confettiesNumber || (t.emojis ? qt : Ht) : o, s = t.confettiColors, a = s === void 0 ? Vt : s, r = t.emojis, l = r === void 0 ? t.emojies || [] : r, c = t.emojiSize, d = c === void 0 ? Dt : c;
901
+ function an(t) {
902
+ var e = t.confettiRadius, n = e === void 0 ? Ht : e, o = t.confettiNumber, i = o === void 0 ? t.confettiesNumber || (t.emojis ? on : nn) : o, s = t.confettiColors, a = s === void 0 ? rn : s, r = t.emojis, l = r === void 0 ? t.emojies || [] : r, c = t.emojiSize, d = c === void 0 ? Bt : c;
903
903
  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"), {
904
904
  confettiRadius: n,
905
905
  confettiNumber: i,
@@ -908,14 +908,14 @@ function Yt(t) {
908
908
  emojiSize: d
909
909
  };
910
910
  }
911
- var Kt = /* @__PURE__ */ function() {
911
+ var ln = /* @__PURE__ */ function() {
912
912
  function t(e) {
913
913
  var n = this;
914
- Te(this, t), this.canvasContext = e, this.shapes = [], this.promise = new Promise(function(o) {
914
+ Ne(this, t), this.canvasContext = e, this.shapes = [], this.promise = new Promise(function(o) {
915
915
  return n.resolvePromise = o;
916
916
  });
917
917
  }
918
- return Se(t, [{
918
+ return Me(t, [{
919
919
  key: "getBatchCompletePromise",
920
920
  value: function() {
921
921
  return this.promise;
@@ -941,15 +941,15 @@ var Kt = /* @__PURE__ */ function() {
941
941
  });
942
942
  }
943
943
  }]), t;
944
- }(), Jt = /* @__PURE__ */ function() {
944
+ }(), cn = /* @__PURE__ */ function() {
945
945
  function t() {
946
946
  var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
947
- Te(this, t), this.activeConfettiBatches = [], this.canvas = e.canvas || Xt(), this.canvasContext = this.canvas.getContext("2d"), this.requestAnimationFrameRequested = !1, this.lastUpdated = (/* @__PURE__ */ new Date()).getTime(), this.iterationIndex = 0, this.loop = this.loop.bind(this), requestAnimationFrame(this.loop);
947
+ Ne(this, t), this.activeConfettiBatches = [], this.canvas = e.canvas || sn(), this.canvasContext = this.canvas.getContext("2d"), this.requestAnimationFrameRequested = !1, this.lastUpdated = (/* @__PURE__ */ new Date()).getTime(), this.iterationIndex = 0, this.loop = this.loop.bind(this), requestAnimationFrame(this.loop);
948
948
  }
949
- return Se(t, [{
949
+ return Me(t, [{
950
950
  key: "loop",
951
951
  value: function() {
952
- this.requestAnimationFrameRequested = !1, Nt(this.canvas);
952
+ this.requestAnimationFrameRequested = !1, Ut(this.canvas);
953
953
  var n = (/* @__PURE__ */ new Date()).getTime(), o = n - this.lastUpdated, i = this.canvas.offsetHeight, s = this.iterationIndex % 10 === 0;
954
954
  this.activeConfettiBatches = this.activeConfettiBatches.filter(function(a) {
955
955
  return a.processShapes({
@@ -966,14 +966,14 @@ var Kt = /* @__PURE__ */ function() {
966
966
  }, {
967
967
  key: "addConfetti",
968
968
  value: function() {
969
- for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = Yt(n), i = o.confettiRadius, s = o.confettiNumber, a = o.confettiColors, r = o.emojis, l = o.emojiSize, c = this.canvas.getBoundingClientRect(), d = c.width, u = c.height, h = u * 5 / 7, f = {
969
+ for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = an(n), i = o.confettiRadius, s = o.confettiNumber, a = o.confettiColors, r = o.emojis, l = o.emojiSize, c = this.canvas.getBoundingClientRect(), d = c.width, u = c.height, h = u * 5 / 7, f = {
970
970
  x: 0,
971
971
  y: h
972
- }, y = {
972
+ }, k = {
973
973
  x: d,
974
974
  y: h
975
- }, g = new Kt(this.canvasContext), p = 0; p < s / 2; p++) {
976
- var m = new Be({
975
+ }, p = new ln(this.canvasContext), _ = 0; _ < s / 2; _++) {
976
+ var b = new Ye({
977
977
  initialPosition: f,
978
978
  direction: "right",
979
979
  confettiRadius: i,
@@ -982,8 +982,8 @@ var Kt = /* @__PURE__ */ function() {
982
982
  emojis: r,
983
983
  emojiSize: l,
984
984
  canvasWidth: d
985
- }), _ = new Be({
986
- initialPosition: y,
985
+ }), w = new Ye({
986
+ initialPosition: k,
987
987
  direction: "left",
988
988
  confettiRadius: i,
989
989
  confettiColors: a,
@@ -992,9 +992,9 @@ var Kt = /* @__PURE__ */ function() {
992
992
  emojiSize: l,
993
993
  canvasWidth: d
994
994
  });
995
- g.addShapes(m, _);
995
+ p.addShapes(b, w);
996
996
  }
997
- return this.activeConfettiBatches.push(g), this.queueAnimationFrameIfNeeded(), g.getBatchCompletePromise();
997
+ return this.activeConfettiBatches.push(p), this.queueAnimationFrameIfNeeded(), p.getBatchCompletePromise();
998
998
  }
999
999
  }, {
1000
1000
  key: "clearCanvas",
@@ -1008,7 +1008,7 @@ var Kt = /* @__PURE__ */ function() {
1008
1008
  }
1009
1009
  }]), t;
1010
1010
  }();
1011
- const Zt = new Jt(), me = 3, Qt = ({ onRetry: t }) => {
1011
+ const un = new cn(), we = 3, dn = ({ onRetry: t }) => {
1012
1012
  const {
1013
1013
  config: e,
1014
1014
  currentScore: n,
@@ -1016,122 +1016,122 @@ const Zt = new Jt(), me = 3, Qt = ({ onRetry: t }) => {
1016
1016
  setGamePlayState: i,
1017
1017
  gameProgress: s,
1018
1018
  setGameProgress: a
1019
- } = X(), { i18n: r, levelConfig: l } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: y, levelTransitioning: g } = o, { currentLevel: p } = s, [m, _] = B(!1);
1020
- D(() => {
1021
- y && g && (Zt.addConfetti(), U.show(r.levelCompleteToast), _(!0));
1022
- }, [y, g]);
1023
- const k = Z(l), T = k.getTotalLevels(), L = V(() => p >= T, [p, T]), C = () => {
1024
- _(!1), U.show(r.levelRestartToast), t?.();
1025
- }, S = () => {
1026
- _(!1), i((b) => ({
1027
- ...b,
1019
+ } = ne(), { i18n: r, levelConfig: l } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: k, levelTransitioning: p } = o, { currentLevel: _ } = s, [b, w] = U(!1);
1020
+ R(() => {
1021
+ k && p && (un.addConfetti(), j.show(r.levelCompleteToast), w(!0));
1022
+ }, [k, p]);
1023
+ const M = oe(l), C = M.getTotalLevels(), z = Z(() => _ >= C, [_, C]), S = () => {
1024
+ w(!1), j.show(r.levelRestartToast), t?.();
1025
+ }, E = () => {
1026
+ w(!1), i((g) => ({
1027
+ ...g,
1028
1028
  isGameActive: !0,
1029
1029
  levelTransitioning: !1
1030
1030
  }));
1031
- }, w = () => {
1032
- _(!1);
1033
- const b = k.getNextLevelInfo(p);
1034
- if (!b) return;
1035
- const { nextLevel: z, nextTier: N, isTierChange: I } = b;
1036
- I && U.show(
1037
- r.tierUnlockedToast.replace("%TIER%", N.toString())
1038
- ), a((x) => ({
1039
- ...x,
1040
- currentLevel: z,
1041
- currentTier: N,
1042
- highestUnlockedLevel: Math.max(x.highestUnlockedLevel, z),
1043
- highestUnlockedTier: Math.max(x.highestUnlockedTier, N),
1031
+ }, L = () => {
1032
+ w(!1);
1033
+ const g = M.getNextLevelInfo(_);
1034
+ if (!g) return;
1035
+ const { nextLevel: v, nextTier: T, isTierChange: N } = g;
1036
+ N && j.show(
1037
+ r.tierUnlockedToast.replace("%TIER%", T.toString())
1038
+ ), a((P) => ({
1039
+ ...P,
1040
+ currentLevel: v,
1041
+ currentTier: T,
1042
+ highestUnlockedLevel: Math.max(P.highestUnlockedLevel, v),
1043
+ highestUnlockedTier: Math.max(P.highestUnlockedTier, T),
1044
1044
  levelScores: {
1045
- ...x.levelScores,
1046
- [x.currentLevel]: Math.max(
1045
+ ...P.levelScores,
1046
+ [P.currentLevel]: Math.max(
1047
1047
  Object.values(n).filter(Boolean).length,
1048
- x.levelScores[x.currentLevel] || 0
1048
+ P.levelScores[P.currentLevel] || 0
1049
1049
  )
1050
1050
  }
1051
1051
  }));
1052
- }, E = () => {
1053
- _(!1), a((b) => {
1054
- const z = Math.max(
1052
+ }, y = () => {
1053
+ w(!1), a((g) => {
1054
+ const v = Math.max(
1055
1055
  Object.values(n).filter(Boolean).length,
1056
- b.levelScores[b.currentLevel] || 0
1057
- ), N = {
1058
- ...b.levelScores,
1059
- [b.currentLevel]: z
1056
+ g.levelScores[g.currentLevel] || 0
1057
+ ), T = {
1058
+ ...g.levelScores,
1059
+ [g.currentLevel]: v
1060
1060
  };
1061
- let I = 0, x = 0;
1062
- const R = Object.entries(N).sort(
1063
- (F, O) => Number(F[0]) - Number(O[0])
1061
+ let N = 0, P = 0;
1062
+ const D = Object.entries(T).sort(
1063
+ (I, $) => Number(I[0]) - Number($[0])
1064
1064
  );
1065
- for (const [F, O] of R)
1066
- if (O < me) {
1067
- I = Number(F), x = k.getTierByLevel(I);
1065
+ for (const [I, $] of D)
1066
+ if ($ < we) {
1067
+ N = Number(I), P = M.getTierByLevel(N);
1068
1068
  break;
1069
1069
  }
1070
- return (I > 0 && I !== p || z < me) && U.show(r.notCompleteLevel), (I === 0 || z < me) && t?.(), {
1071
- ...b,
1072
- currentLevel: I || b.currentLevel,
1073
- currentTier: x || b.currentTier,
1074
- levelScores: N
1070
+ return (N > 0 && N !== _ || v < we) && j.show(r.notCompleteLevel), (N === 0 || v < we) && t?.(), {
1071
+ ...g,
1072
+ currentLevel: N || g.currentLevel,
1073
+ currentTier: P || g.currentTier,
1074
+ levelScores: T
1075
1075
  };
1076
1076
  });
1077
1077
  };
1078
- return D(() => {
1079
- const b = document.querySelector(".maze-game-container"), z = (N) => {
1080
- m && ((N.key === " " || N.code === "Space") && b && (b.contains(document.activeElement) || document.activeElement === document.body) && (N.preventDefault(), L ? E() : w()), (N.key === "r" || N.code === "KeyR") && C(), (N.key === "c" || N.code === "KeyC") && S());
1078
+ return R(() => {
1079
+ const g = document.querySelector(".maze-game-container"), v = (T) => {
1080
+ b && ((T.key === " " || T.code === "Space") && g && (g.contains(document.activeElement) || document.activeElement === document.body) && (T.preventDefault(), z ? y() : L()), (T.key === "r" || T.code === "KeyR") && S(), (T.key === "c" || T.code === "KeyC") && E());
1081
1081
  };
1082
- return window.addEventListener("keydown", z), () => window.removeEventListener("keydown", z);
1083
- }, [m, L]), /* @__PURE__ */ v(
1084
- ie,
1082
+ return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
1083
+ }, [b, z]), /* @__PURE__ */ m(
1084
+ Q,
1085
1085
  {
1086
1086
  className: "level-complete-dialog",
1087
- isOpen: m,
1087
+ isOpen: b,
1088
1088
  title: r.congratulations,
1089
1089
  cancelText: r.retry + " (R)",
1090
- onCancel: C,
1090
+ onCancel: S,
1091
1091
  noConfirm: !!d,
1092
1092
  confirmText: r.continue + " (C)",
1093
- onConfirm: S,
1093
+ onConfirm: E,
1094
1094
  confirmClass: "maze-continue-btn",
1095
1095
  children: [
1096
- /* @__PURE__ */ v("div", { className: "maze-summary-message", children: [
1097
- !!c && /* @__PURE__ */ v("div", { children: "★ - " + r.findYourExit }),
1098
- /* @__PURE__ */ v("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
1099
- /* @__PURE__ */ v("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
1096
+ /* @__PURE__ */ m("div", { className: "maze-summary-message", children: [
1097
+ !!c && /* @__PURE__ */ m("div", { children: "★ - " + r.findYourExit }),
1098
+ /* @__PURE__ */ m("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
1099
+ /* @__PURE__ */ m("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
1100
1100
  ] }),
1101
- L && /* @__PURE__ */ v("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
1102
- /* @__PURE__ */ v("div", { className: "maze-go-next", children: L ? /* @__PURE__ */ v(
1101
+ z && /* @__PURE__ */ m("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
1102
+ /* @__PURE__ */ m("div", { className: "maze-go-next", children: z ? /* @__PURE__ */ m(
1103
1103
  "button",
1104
1104
  {
1105
1105
  className: "maze-go-next-btn",
1106
1106
  type: "button",
1107
- onClick: E,
1107
+ onClick: y,
1108
1108
  children: [
1109
- /* @__PURE__ */ v("span", { children: r.lastOK }),
1110
- /* @__PURE__ */ v("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
1109
+ /* @__PURE__ */ m("span", { children: r.lastOK }),
1110
+ /* @__PURE__ */ m("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
1111
1111
  ]
1112
1112
  }
1113
- ) : /* @__PURE__ */ v(
1113
+ ) : /* @__PURE__ */ m(
1114
1114
  "button",
1115
1115
  {
1116
1116
  className: "maze-go-next-btn",
1117
1117
  type: "button",
1118
- onClick: w,
1118
+ onClick: L,
1119
1119
  children: [
1120
- /* @__PURE__ */ v("span", { children: r.nextLevel }),
1121
- /* @__PURE__ */ v("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
1120
+ /* @__PURE__ */ m("span", { children: r.nextLevel }),
1121
+ /* @__PURE__ */ m("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
1122
1122
  ]
1123
1123
  }
1124
1124
  ) }),
1125
- !d && /* @__PURE__ */ v("div", { className: "not-all-stars-collected", children: r.continueMessage })
1125
+ !d && /* @__PURE__ */ m("div", { className: "not-all-stars-collected", children: r.continueMessage })
1126
1126
  ]
1127
1127
  }
1128
1128
  );
1129
- }, en = (t, e) => {
1130
- const n = W({
1129
+ }, ft = (t, e) => {
1130
+ const n = O({
1131
1131
  canvasWidth: 0,
1132
1132
  canvasHeight: 0
1133
1133
  });
1134
- return D(() => {
1134
+ return R(() => {
1135
1135
  const o = () => {
1136
1136
  const s = t.current;
1137
1137
  if (!s) return;
@@ -1144,36 +1144,33 @@ const Zt = new Jt(), me = 3, Qt = ({ onRetry: t }) => {
1144
1144
  };
1145
1145
  o();
1146
1146
  let i = null;
1147
- return window.ResizeObserver && (i = new ResizeObserver(o), i.observe(t.current.parentElement)), window.addEventListener("resize", o), () => {
1147
+ return window.ResizeObserver && t.current && (i = new ResizeObserver(o), i.observe(t.current.parentElement)), window.addEventListener("resize", o), () => {
1148
1148
  window.removeEventListener("resize", o), i?.disconnect();
1149
1149
  };
1150
1150
  }, [t, e]), n;
1151
- }, tn = (t) => {
1152
- const {
1153
- config: e,
1154
- gamePlayState: { maze: n }
1155
- } = X(), o = W({ cellWidth: 0, cellHeight: 0 });
1156
- return D(() => {
1157
- const i = e.renderConfig.padding, s = () => {
1158
- const r = t.current;
1159
- if (!r || !n) return;
1160
- const { rows: l, cols: c } = n;
1151
+ }, mt = (t, e, n) => {
1152
+ const o = O({ cellWidth: 0, cellHeight: 0 });
1153
+ return R(() => {
1154
+ const i = () => {
1155
+ const a = t.current, r = e.maze;
1156
+ if (!a || !r) return;
1157
+ const { rows: l, cols: c } = r;
1161
1158
  if (l <= 0 || c <= 0) return;
1162
- const d = (r.width - i * 2) / c, u = (r.height - i * 2) / l;
1159
+ const d = (a.width - n * 2) / c, u = (a.height - n * 2) / l;
1163
1160
  o.current = { cellWidth: d, cellHeight: u };
1164
1161
  };
1165
- s();
1166
- let a = null;
1167
- return t.current && window.ResizeObserver && (a = new ResizeObserver(s), a.observe(t.current)), () => {
1168
- t.current && a?.disconnect();
1162
+ i();
1163
+ let s = null;
1164
+ return t.current && window.ResizeObserver && (s = new ResizeObserver(i), s.observe(t.current)), () => {
1165
+ t.current && s?.disconnect();
1169
1166
  };
1170
- }, [t, n]), o;
1171
- }, te = {
1167
+ }, [t, e.maze, n]), o;
1168
+ }, ie = {
1172
1169
  ArrowUp: [-1, 0],
1173
1170
  ArrowDown: [1, 0],
1174
1171
  ArrowLeft: [0, -1],
1175
1172
  ArrowRight: [0, 1]
1176
- }, nn = ({
1173
+ }, _t = ({
1177
1174
  containerRef: t,
1178
1175
  gamePlayStateRef: e,
1179
1176
  setGamePlayState: n,
@@ -1184,50 +1181,51 @@ const Zt = new Jt(), me = 3, Qt = ({ onRetry: t }) => {
1184
1181
  playerRadius: s,
1185
1182
  // player radius in grid unit, default 0.2
1186
1183
  onFoodCollected: a,
1187
- onExitReached: r
1184
+ onExitReached: r,
1185
+ onFirstMove: l
1188
1186
  }) => {
1189
- const l = () => i?.current ?? o ?? 0.03, c = W(!1), d = W(/* @__PURE__ */ new Set()), u = Re(
1190
- (m, _) => {
1191
- const k = e.current;
1192
- if (!k.maze)
1187
+ const c = () => i?.current ?? o ?? 0.03, d = O(!1), u = O(/* @__PURE__ */ new Set()), h = O(!1), f = je(
1188
+ (C, z) => {
1189
+ const S = e.current;
1190
+ if (!S.maze)
1193
1191
  return { canMove: !1, newCell: null };
1194
- const T = l(), [L, C] = te[m];
1195
- if (He(
1196
- _,
1192
+ const E = c(), [L, y] = ie[C];
1193
+ if (Ke(
1194
+ z,
1197
1195
  L,
1198
- C,
1196
+ y,
1199
1197
  s,
1200
- T,
1201
- k.maze
1198
+ E,
1199
+ S.maze
1202
1200
  ))
1203
1201
  return { canMove: !1, newCell: null };
1204
- const { row: w, col: E } = _, b = w + L * T, z = E + C * T, N = -0.5, I = k.maze.rows, x = k.maze.cols;
1205
- if (b < N || b >= I || z < N || z >= x)
1202
+ const { row: v, col: T } = z, N = v + L * E, P = T + y * E, D = -0.5, I = S.maze.rows, $ = S.maze.cols;
1203
+ if (N < D || N >= I || P < D || P >= $)
1206
1204
  return { canMove: !1, newCell: null };
1207
- const R = w < 0 ? 0 : Math.floor(w), F = E < 0 ? 0 : Math.floor(E), O = b < 0 ? 0 : Math.floor(b), Q = z < 0 ? 0 : Math.floor(z);
1208
- return O !== R || Q !== F ? k.maze.isValid(O, Q) ? {
1205
+ const B = v < 0 ? 0 : Math.floor(v), V = T < 0 ? 0 : Math.floor(T), G = N < 0 ? 0 : Math.floor(N), q = P < 0 ? 0 : Math.floor(P);
1206
+ return G !== B || q !== V ? S.maze.isValid(G, q) ? {
1209
1207
  canMove: !0,
1210
- newCell: { row: O, col: Q }
1208
+ newCell: { row: G, col: q }
1211
1209
  } : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
1212
1210
  },
1213
- [s, l]
1214
- ), h = () => {
1215
- const m = e.current, { row: _, col: k } = m.playerCell, T = s * 2, L = m.foodCells.findIndex((w) => Math.sqrt(
1216
- Math.pow(_ - w.row, 2) + Math.pow(k - w.col, 2)
1217
- ) < T);
1211
+ [s, c]
1212
+ ), k = () => {
1213
+ const C = e.current, { row: z, col: S } = C.playerCell, E = s * 2, L = C.foodCells.findIndex((v) => Math.sqrt(
1214
+ Math.pow(z - v.row, 2) + Math.pow(S - v.col, 2)
1215
+ ) < E);
1218
1216
  L !== -1 && a && (a(), e.current = {
1219
1217
  ...e.current,
1220
1218
  foodCollected: e.current.foodCollected + 1,
1221
1219
  foodCells: e.current.foodCells.filter(
1222
- (w, E) => E !== L
1220
+ (v, T) => T !== L
1223
1221
  )
1224
1222
  });
1225
- const S = sn(
1226
- m.playerCell,
1227
- m.exitCell,
1228
- m.maze
1223
+ const g = mn(
1224
+ C.playerCell,
1225
+ C.exitCell,
1226
+ C.maze
1229
1227
  );
1230
- S && !e.current.playerAtExit ? (e.current = {
1228
+ g && !e.current.playerAtExit ? (e.current = {
1231
1229
  ...e.current,
1232
1230
  playerAtExit: !0,
1233
1231
  isGameActive: !1,
@@ -1238,104 +1236,104 @@ const Zt = new Jt(), me = 3, Qt = ({ onRetry: t }) => {
1238
1236
  n(() => ({ ...e.current }));
1239
1237
  },
1240
1238
  { timeout: 10 }
1241
- )) : !S && e.current.playerAtExit && (e.current = {
1239
+ )) : !g && e.current.playerAtExit && (e.current = {
1242
1240
  ...e.current,
1243
1241
  playerAtExit: !1,
1244
1242
  isGameActive: !0,
1245
1243
  levelTransitioning: !1
1246
1244
  });
1247
- }, f = (m) => {
1248
- const _ = e.current, k = Math.round(m.row), T = Math.round(m.col), L = _.playerPath[_.playerPath.length - 1], C = L.row === k && L.col === T, S = Math.abs(L.row - k), w = Math.abs(L.col - T);
1249
- if ((S === 1 && w === 0 || S === 0 && w === 1) && !C) {
1250
- const b = `${L.row},${L.col}-${k},${T}`;
1245
+ }, p = (C) => {
1246
+ const z = e.current, S = Math.round(C.row), E = Math.round(C.col), L = z.playerPath[z.playerPath.length - 1], y = L.row === S && L.col === E, g = Math.abs(L.row - S), v = Math.abs(L.col - E);
1247
+ if ((g === 1 && v === 0 || g === 0 && v === 1) && !y) {
1248
+ const N = `${L.row},${L.col}-${S},${E}`;
1251
1249
  e.current = {
1252
1250
  ...e.current,
1253
1251
  playerPath: [
1254
1252
  ...e.current.playerPath,
1255
- { row: k, col: T }
1253
+ { row: S, col: E }
1256
1254
  ],
1257
1255
  visitCounts: {
1258
1256
  ...e.current.visitCounts,
1259
- [b]: (e.current.visitCounts[b] || 0) + 1
1257
+ [N]: (e.current.visitCounts[N] || 0) + 1
1260
1258
  }
1261
1259
  };
1262
1260
  }
1263
- }, y = () => {
1264
- if (c.current || d.current.size === 0) return;
1265
- const m = e.current;
1266
- !m.playerCell || !Array.from(d.current).some(
1267
- (k) => {
1268
- const { canMove: T } = u(
1269
- k,
1270
- m.playerCell
1261
+ }, _ = () => {
1262
+ if (d.current || u.current.size === 0) return;
1263
+ const C = e.current;
1264
+ !C.playerCell || !Array.from(u.current).some(
1265
+ (S) => {
1266
+ const { canMove: E } = f(
1267
+ S,
1268
+ C.playerCell
1271
1269
  );
1272
- return T;
1270
+ return E;
1273
1271
  }
1274
- ) || (c.current = !0);
1272
+ ) || (!h.current && l && (h.current = !0, l()), d.current = !0);
1275
1273
  };
1276
- D(() => {
1277
- const m = (C) => {
1278
- if (C.key === "ArrowUp" || C.key === "ArrowDown" || C.key === "ArrowLeft" || C.key === "ArrowRight" || C.key === " ") {
1279
- const S = document.activeElement;
1280
- if (S && (S.tagName === "INPUT" || S.tagName === "TEXTAREA" || S.getAttribute("contenteditable") === "true")) return;
1281
- C.preventDefault();
1274
+ R(() => {
1275
+ const C = (y) => {
1276
+ if (y.key === "ArrowUp" || y.key === "ArrowDown" || y.key === "ArrowLeft" || y.key === "ArrowRight" || y.key === " ") {
1277
+ const g = document.activeElement;
1278
+ if (g && (g.tagName === "INPUT" || g.tagName === "TEXTAREA" || g.getAttribute("contenteditable") === "true")) return;
1279
+ y.preventDefault();
1282
1280
  }
1283
- }, _ = (C) => {
1284
- const S = C.key;
1285
- if (!(S in te)) return;
1286
- const w = document.activeElement;
1287
- w && (w.tagName === "INPUT" || w.tagName === "TEXTAREA" || w.getAttribute("contenteditable") === "true") || (C.preventDefault(), e.current.isGameActive && (d.current.has(S) || (d.current.add(S), c.current || y())));
1288
- }, k = (C) => {
1289
- const S = C.key;
1290
- if (!(S in te)) return;
1291
- const w = document.activeElement;
1292
- w && (w.tagName === "INPUT" || w.tagName === "TEXTAREA" || w.getAttribute("contenteditable") === "true") || (C.preventDefault(), d.current.delete(S), d.current.size === 0 && p());
1293
- }, T = (C) => {
1294
- C.preventDefault();
1295
- const S = e.current;
1296
- if (!S.isGameActive || !S.maze || c.current)
1281
+ }, z = (y) => {
1282
+ const g = y.key;
1283
+ if (!(g in ie)) return;
1284
+ const v = document.activeElement;
1285
+ v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.getAttribute("contenteditable") === "true") || (y.preventDefault(), e.current.isGameActive && (u.current.has(g) || (u.current.add(g), d.current || _())));
1286
+ }, S = (y) => {
1287
+ const g = y.key;
1288
+ if (!(g in ie)) return;
1289
+ const v = document.activeElement;
1290
+ v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.getAttribute("contenteditable") === "true") || (y.preventDefault(), u.current.delete(g), u.current.size === 0 && w());
1291
+ }, E = (y) => {
1292
+ y.preventDefault();
1293
+ const g = e.current;
1294
+ if (!g.isGameActive || !g.maze || d.current)
1297
1295
  return;
1298
- const w = C.touches[0], E = document.elementFromPoint(w.clientX, w.clientY);
1299
- let b = null;
1300
- E && (E.classList.contains("maze-up") ? b = "ArrowUp" : E.classList.contains("maze-down") ? b = "ArrowDown" : E.classList.contains("maze-left") ? b = "ArrowLeft" : E.classList.contains("maze-right") && (b = "ArrowRight")), b && (d.current.clear(), d.current.add(b), y());
1296
+ const v = y.touches[0], T = document.elementFromPoint(v.clientX, v.clientY);
1297
+ let N = null;
1298
+ T && (T.classList.contains("maze-up") ? N = "ArrowUp" : T.classList.contains("maze-down") ? N = "ArrowDown" : T.classList.contains("maze-left") ? N = "ArrowLeft" : T.classList.contains("maze-right") && (N = "ArrowRight")), N && (u.current.clear(), u.current.add(N), _());
1301
1299
  }, L = () => {
1302
- p();
1300
+ w();
1303
1301
  };
1304
- return window.addEventListener("keydown", m, {
1302
+ return window.addEventListener("keydown", C, {
1305
1303
  capture: !0
1306
- }), window.addEventListener("keydown", _), window.addEventListener("keyup", k), t.current?.addEventListener("touchstart", T, {
1304
+ }), window.addEventListener("keydown", z), window.addEventListener("keyup", S), t.current?.addEventListener("touchstart", E, {
1307
1305
  passive: !1
1308
1306
  }), t.current?.addEventListener("touchend", L), () => {
1309
- window.removeEventListener("keydown", m, {
1307
+ window.removeEventListener("keydown", C, {
1310
1308
  capture: !0
1311
- }), window.removeEventListener("keydown", _), window.removeEventListener("keyup", k), t.current?.removeEventListener("touchstart", T), t.current?.removeEventListener("touchend", L);
1309
+ }), window.removeEventListener("keydown", z), window.removeEventListener("keyup", S), t.current?.removeEventListener("touchstart", E), t.current?.removeEventListener("touchend", L);
1312
1310
  };
1313
1311
  }, []);
1314
- const g = Re(() => {
1315
- if (!c.current || d.current.size === 0)
1312
+ const b = je(() => {
1313
+ if (!d.current || u.current.size === 0)
1316
1314
  return e.current.playerCell;
1317
- const m = l(), _ = e.current.playerCell;
1318
- let k = 0, T = 0, L = 0;
1319
- for (const Y of d.current) {
1320
- const { canMove: fe } = u(Y, _);
1321
- if (fe) {
1322
- const [Ee, ct] = te[Y];
1323
- k += Ee, T += ct, L++;
1315
+ const C = c(), z = e.current.playerCell;
1316
+ let S = 0, E = 0, L = 0;
1317
+ for (const Y of u.current) {
1318
+ const { canMove: ge } = f(Y, z);
1319
+ if (ge) {
1320
+ const [Ae, yt] = ie[Y];
1321
+ S += Ae, E += yt, L++;
1324
1322
  }
1325
1323
  }
1326
1324
  if (L === 0)
1327
1325
  return e.current.playerCell;
1328
- const C = Math.sqrt(k * k + T * T), S = C > 0 ? k / C : 0, w = C > 0 ? T / C : 0, E = Number(
1329
- (_.row + S * m).toFixed(2)
1330
- ), b = Number(
1331
- (_.col + w * m).toFixed(2)
1332
- ), z = E - _.row, N = b - _.col, I = Math.sqrt(z * z + N * N);
1326
+ const y = Math.sqrt(S * S + E * E), g = y > 0 ? S / y : 0, v = y > 0 ? E / y : 0, T = Number(
1327
+ (z.row + g * C).toFixed(2)
1328
+ ), N = Number(
1329
+ (z.col + v * C).toFixed(2)
1330
+ ), P = T - z.row, D = N - z.col, I = Math.sqrt(P * P + D * D);
1333
1331
  if (I > 0) {
1334
- const Y = z / I, fe = N / I;
1335
- if (He(
1336
- _,
1332
+ const Y = P / I, ge = D / I;
1333
+ if (Ke(
1334
+ z,
1337
1335
  Y,
1338
- fe,
1336
+ ge,
1339
1337
  s,
1340
1338
  I,
1341
1339
  e.current.maze
@@ -1343,20 +1341,23 @@ const Zt = new Jt(), me = 3, Qt = ({ onRetry: t }) => {
1343
1341
  return e.current.playerCell;
1344
1342
  }
1345
1343
  e.current.playerCell = {
1346
- row: E,
1347
- col: b
1348
- }, h();
1349
- const x = _.row < 0 ? 0 : Math.round(_.row), R = _.col < 0 ? 0 : Math.round(_.col), F = E < 0 ? 0 : Math.round(E), O = b < 0 ? 0 : Math.round(b);
1350
- return (F !== x || O !== R) && f({ row: F, col: O }), e.current.playerCell;
1351
- }, [l, u]), p = () => {
1352
- c.current = !1, d.current.clear();
1344
+ row: T,
1345
+ col: N
1346
+ }, k();
1347
+ const $ = z.row < 0 ? 0 : Math.round(z.row), B = z.col < 0 ? 0 : Math.round(z.col), V = T < 0 ? 0 : Math.round(T), G = N < 0 ? 0 : Math.round(N);
1348
+ return (V !== $ || G !== B) && p({ row: V, col: G }), e.current.playerCell;
1349
+ }, [c, f]), w = () => {
1350
+ d.current = !1, u.current.clear();
1353
1351
  };
1354
1352
  return {
1355
- updatePlayerPos: g,
1356
- resetMovingState: p
1353
+ updatePlayerPos: b,
1354
+ resetMovingState: w,
1355
+ resetFirstMoveState: () => {
1356
+ h.current = !1;
1357
+ }
1357
1358
  };
1358
1359
  };
1359
- function He(t, e, n, o, i, s) {
1360
+ function Ke(t, e, n, o, i, s) {
1360
1361
  const a = t.row + e * i, r = t.col + n * i, l = { row: a, col: r }, c = [], d = t.row < 0 ? 0 : Math.floor(t.row), u = t.col < 0 ? 0 : Math.floor(t.col);
1361
1362
  c.push({ row: d, col: u });
1362
1363
  const h = [
@@ -1377,19 +1378,19 @@ function He(t, e, n, o, i, s) {
1377
1378
  [1, 1]
1378
1379
  // lower right, diagonal
1379
1380
  ];
1380
- for (const [f, y] of h) {
1381
- const g = d + f, p = u + y;
1382
- s.isValid(g, p) && c.push({ row: g, col: p });
1381
+ for (const [f, k] of h) {
1382
+ const p = d + f, _ = u + k;
1383
+ s.isValid(p, _) && c.push({ row: p, col: _ });
1383
1384
  }
1384
1385
  for (const f of c) {
1385
- const y = on(f.row, f.col, s);
1386
- for (const g of y)
1387
- if (rn(l, g) < o)
1386
+ const k = hn(f.row, f.col, s);
1387
+ for (const p of k)
1388
+ if (fn(l, p) < o)
1388
1389
  return !0;
1389
1390
  }
1390
1391
  return !1;
1391
1392
  }
1392
- function on(t, e, n) {
1393
+ function hn(t, e, n) {
1393
1394
  const o = [], i = n.grid[t][e];
1394
1395
  return i.walls.top && o.push({
1395
1396
  start: { row: t - 0.5, col: e - 0.5 },
@@ -1405,7 +1406,7 @@ function on(t, e, n) {
1405
1406
  end: { row: t + 0.5, col: e - 0.5 }
1406
1407
  }), o;
1407
1408
  }
1408
- function rn(t, e) {
1409
+ function fn(t, e) {
1409
1410
  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;
1410
1411
  if (l === 0)
1411
1412
  return Math.sqrt(a * a + r * r);
@@ -1418,12 +1419,12 @@ function rn(t, e) {
1418
1419
  ), d = n.col + c * i, u = n.row + c * s, h = t.col - d, f = t.row - u;
1419
1420
  return Math.sqrt(h * h + f * f);
1420
1421
  }
1421
- function sn(t, e, n) {
1422
+ function mn(t, e, n) {
1422
1423
  if (!n.isValid(e.row, e.col)) return !1;
1423
1424
  const o = t.col >= e.col - 0.5 && t.col <= e.col + 0.5, i = t.row >= e.row + 0.5, s = t.row >= e.row - 0.5;
1424
1425
  return o && i && s;
1425
1426
  }
1426
- function ln(t, e, n, o, i) {
1427
+ function vt(t, e, n, o, i) {
1427
1428
  if (!t || !e.maze) return;
1428
1429
  const { canvasWidth: s, canvasHeight: a } = n, { cellWidth: r, cellHeight: l } = o, {
1429
1430
  maze: c,
@@ -1432,66 +1433,66 @@ function ln(t, e, n, o, i) {
1432
1433
  exitCell: u,
1433
1434
  foodCells: h,
1434
1435
  showClue: f,
1435
- playerPath: y,
1436
- visitCounts: g
1436
+ playerPath: k,
1437
+ visitCounts: p
1437
1438
  } = e, {
1438
- padding: p,
1439
- wallWidth: m,
1439
+ padding: _,
1440
+ wallWidth: b,
1440
1441
  // need merge with level config when passed here
1441
- wallColor: _,
1442
- playerColor: k,
1443
- playerRadius: T,
1444
- foodColor: L,
1445
- backgroundColor: C,
1446
- clueColor: S,
1447
- exitColor: w,
1448
- exitWallWidth: E,
1449
- exitDashArray: b
1442
+ wallColor: w,
1443
+ playerColor: M,
1444
+ playerRadius: C,
1445
+ foodColor: z,
1446
+ backgroundColor: S,
1447
+ clueColor: E,
1448
+ exitColor: L,
1449
+ exitWallWidth: y,
1450
+ exitDashArray: g
1450
1451
  } = i;
1451
- t.clearRect(0, 0, s, a), t.save(), t.fillStyle = C, t.fillRect(0, 0, s, a), t.restore(), f && fn({
1452
+ t.clearRect(0, 0, s, a), t.save(), t.fillStyle = S, t.fillRect(0, 0, s, a), t.restore(), f && Cn({
1452
1453
  ctx: t,
1453
- playerPath: y,
1454
- visitCounts: g,
1454
+ playerPath: k,
1455
+ visitCounts: p,
1455
1456
  cellWidth: r,
1456
1457
  cellHeight: l,
1457
- padding: p,
1458
- clueColor: S
1459
- }), an({
1458
+ padding: _,
1459
+ clueColor: E
1460
+ }), _n({
1460
1461
  ctx: t,
1461
1462
  maze: c,
1462
1463
  cellWidth: r,
1463
1464
  cellHeight: l,
1464
- padding: p,
1465
- wallColor: _,
1466
- wallWidth: m
1467
- }), un({
1465
+ padding: _,
1466
+ wallColor: w,
1467
+ wallWidth: b
1468
+ }), gn({
1468
1469
  ctx: t,
1469
1470
  maze: c,
1470
1471
  exitCell: u,
1471
1472
  cellWidth: r,
1472
1473
  cellHeight: l,
1473
- padding: p,
1474
- exitColor: w,
1475
- exitWallWidth: E,
1476
- exitDashArray: b
1477
- }), dn({
1474
+ padding: _,
1475
+ exitColor: L,
1476
+ exitWallWidth: y,
1477
+ exitDashArray: g
1478
+ }), pn({
1478
1479
  ctx: t,
1479
1480
  foodCells: h,
1480
1481
  cellWidth: r,
1481
1482
  cellHeight: l,
1482
- padding: p,
1483
- foodColor: L
1484
- }), cn({
1483
+ padding: _,
1484
+ foodColor: z
1485
+ }), vn({
1485
1486
  ctx: t,
1486
1487
  playerCell: d,
1487
- playerRadius: T,
1488
+ playerRadius: C,
1488
1489
  cellWidth: r,
1489
1490
  cellHeight: l,
1490
- padding: p,
1491
- playerColor: k
1491
+ padding: _,
1492
+ playerColor: M
1492
1493
  });
1493
1494
  }
1494
- function an({
1495
+ function _n({
1495
1496
  ctx: t,
1496
1497
  maze: e,
1497
1498
  cellWidth: n,
@@ -1500,11 +1501,11 @@ function an({
1500
1501
  wallColor: s,
1501
1502
  wallWidth: a
1502
1503
  }) {
1503
- t.save(), t.strokeStyle = s, t.lineWidth = a, t.lineCap = "round", t.beginPath(), _n(e, n, o, i).forEach((l) => {
1504
+ t.save(), t.strokeStyle = s, t.lineWidth = a, t.lineCap = "round", t.beginPath(), yn(e, n, o, i).forEach((l) => {
1504
1505
  t.moveTo(l.x1, l.y1), t.lineTo(l.x2, l.y2);
1505
1506
  }), t.stroke(), t.restore();
1506
1507
  }
1507
- function cn({
1508
+ function vn({
1508
1509
  ctx: t,
1509
1510
  playerCell: e,
1510
1511
  playerRadius: n,
@@ -1513,7 +1514,7 @@ function cn({
1513
1514
  padding: s,
1514
1515
  playerColor: a
1515
1516
  }) {
1516
- const { x: r, y: l } = ae(
1517
+ const { x: r, y: l } = he(
1517
1518
  e.row,
1518
1519
  e.col,
1519
1520
  o,
@@ -1522,7 +1523,7 @@ function cn({
1522
1523
  ), c = Math.min(o, i) * Math.min(n, 0.5);
1523
1524
  t.save(), t.fillStyle = a, t.beginPath(), t.arc(r, l, c, 0, Math.PI * 2), t.fill(), t.restore();
1524
1525
  }
1525
- function un({
1526
+ function gn({
1526
1527
  ctx: t,
1527
1528
  maze: e,
1528
1529
  exitCell: n,
@@ -1538,7 +1539,7 @@ function un({
1538
1539
  const u = s + d * o, h = s + c * i;
1539
1540
  t.save(), t.globalCompositeOperation = "destination-out", t.lineWidth = r, t.lineCap = "round", t.beginPath(), t.moveTo(u, h + i), t.lineTo(u + o, h + i), t.stroke(), t.globalCompositeOperation = "source-over", t.strokeStyle = a, t.lineWidth = r, t.setLineDash(l), t.beginPath(), t.moveTo(u, h + i), t.lineTo(u + o, h + i), t.stroke(), t.restore();
1540
1541
  }
1541
- function dn({
1542
+ function pn({
1542
1543
  ctx: t,
1543
1544
  foodCells: e,
1544
1545
  cellWidth: n,
@@ -1549,17 +1550,17 @@ function dn({
1549
1550
  t.fillStyle = s;
1550
1551
  const a = Math.min(n, o) * 0.25;
1551
1552
  e.forEach((r) => {
1552
- const { x: l, y: c } = ae(
1553
+ const { x: l, y: c } = he(
1553
1554
  r.row,
1554
1555
  r.col,
1555
1556
  n,
1556
1557
  o,
1557
1558
  i
1558
1559
  );
1559
- hn(t, l, c, a * 1.2, 5, a * 0.6);
1560
+ wn(t, l, c, a * 1.2, 5, a * 0.6);
1560
1561
  });
1561
1562
  }
1562
- function hn(t, e, n, o, i, s) {
1563
+ function wn(t, e, n, o, i, s) {
1563
1564
  t.save(), t.beginPath();
1564
1565
  for (let a = 0; a < i * 2; a++) {
1565
1566
  const r = a % 2 === 0 ? o : s, l = Math.PI * a / i;
@@ -1567,7 +1568,7 @@ function hn(t, e, n, o, i, s) {
1567
1568
  }
1568
1569
  t.closePath(), t.fill(), t.restore();
1569
1570
  }
1570
- function fn({
1571
+ function Cn({
1571
1572
  ctx: t,
1572
1573
  playerPath: e,
1573
1574
  visitCounts: n,
@@ -1579,32 +1580,32 @@ function fn({
1579
1580
  if (!(!e || e.length < 2 || !n)) {
1580
1581
  t.save();
1581
1582
  for (let r = 1; r < e.length; r++) {
1582
- const l = e[r - 1], c = e[r], d = `${l.row},${l.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${l.row},${l.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), y = Math.max(3, o * 0.1) + h * 0.5;
1583
+ const l = e[r - 1], c = e[r], d = `${l.row},${l.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${l.row},${l.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), k = Math.max(3, o * 0.1) + h * 0.5;
1583
1584
  try {
1584
1585
  t.strokeStyle = a.replace(")", `, ${f})`).replace("rgb(", "rgba(");
1585
1586
  } catch {
1586
1587
  t.strokeStyle = `rgba(255, 0, 0, ${f})`;
1587
1588
  }
1588
- t.lineWidth = y, t.lineCap = "round", t.lineJoin = "round";
1589
- const { x: g, y: p } = ae(
1589
+ t.lineWidth = k, t.lineCap = "round", t.lineJoin = "round";
1590
+ const { x: p, y: _ } = he(
1590
1591
  l.row,
1591
1592
  l.col,
1592
1593
  o,
1593
1594
  i,
1594
1595
  s
1595
- ), { x: m, y: _ } = ae(
1596
+ ), { x: b, y: w } = he(
1596
1597
  c.row,
1597
1598
  c.col,
1598
1599
  o,
1599
1600
  i,
1600
1601
  s
1601
1602
  );
1602
- t.beginPath(), t.moveTo(g, p), t.lineTo(m, _), t.stroke();
1603
+ t.beginPath(), t.moveTo(p, _), t.lineTo(b, w), t.stroke();
1603
1604
  }
1604
1605
  t.restore();
1605
1606
  }
1606
1607
  }
1607
- function _n(t, e, n, o) {
1608
+ function yn(t, e, n, o) {
1608
1609
  const i = [];
1609
1610
  for (let s = 0; s < t.rows; s++)
1610
1611
  for (let a = 0; a < t.cols; a++) {
@@ -1633,19 +1634,19 @@ function _n(t, e, n, o) {
1633
1634
  }
1634
1635
  return i;
1635
1636
  }
1636
- function ae(t, e, n, o, i) {
1637
+ function he(t, e, n, o, i) {
1637
1638
  return {
1638
1639
  x: i + e * n + n / 2,
1639
1640
  y: i + t * o + o / 2
1640
1641
  };
1641
1642
  }
1642
- function mn(t) {
1643
+ function bn(t) {
1643
1644
  return function() {
1644
1645
  let e = t += 1831565813;
1645
1646
  return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
1646
1647
  };
1647
1648
  }
1648
- class vn {
1649
+ class Tn {
1649
1650
  // initially all walls exit
1650
1651
  constructor(e, n) {
1651
1652
  this.row = e, this.col = n;
@@ -1653,7 +1654,7 @@ class vn {
1653
1654
  visited = !1;
1654
1655
  walls = { top: !0, right: !0, bottom: !0, left: !0 };
1655
1656
  }
1656
- class pn {
1657
+ class gt {
1657
1658
  rows;
1658
1659
  cols;
1659
1660
  grid;
@@ -1670,7 +1671,7 @@ class pn {
1670
1671
  * @param exit Optional exit cell position
1671
1672
  */
1672
1673
  constructor(e, n, o, i, s = { row: 0, col: 0 }, a = { row: e - 1, col: n - 1 }) {
1673
- this.rows = e, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = mn(this.seed), this.grid = this.initializeGrid(), this.generate(o, s, a);
1674
+ this.rows = e, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = bn(this.seed), this.grid = this.initializeGrid(), this.generate(o, s, a);
1674
1675
  }
1675
1676
  // Initialize the grid with new MazeCell objects
1676
1677
  initializeGrid() {
@@ -1678,7 +1679,7 @@ class pn {
1678
1679
  for (let n = 0; n < this.rows; n++) {
1679
1680
  e[n] = [];
1680
1681
  for (let o = 0; o < this.cols; o++)
1681
- e[n][o] = new vn(n, o);
1682
+ e[n][o] = new Tn(n, o);
1682
1683
  }
1683
1684
  return e;
1684
1685
  }
@@ -1796,26 +1797,26 @@ class pn {
1796
1797
  return e[Math.floor(this.random() * e.length)];
1797
1798
  }
1798
1799
  }
1799
- const gn = (t, e, n) => {
1800
+ const pt = (t, e, n) => {
1800
1801
  if (!t.isValid(e, n)) return !1;
1801
1802
  const o = t.grid[e][n];
1802
1803
  return !o.walls.top || !o.walls.right || !o.walls.bottom || !o.walls.left;
1803
- }, Cn = (t) => t === 1 ? 2 : t >= 2 && t <= 5 ? 3 : t >= 6 && t <= 11 ? 4 : t >= 12 && t <= 15 ? 5 : 6, wn = (t, e) => {
1804
+ }, kn = (t) => t === 1 ? 2 : t >= 2 && t <= 5 ? 3 : t >= 6 && t <= 11 ? 4 : t >= 12 && t <= 15 ? 5 : 6, Sn = (t, e) => {
1804
1805
  if (!e)
1805
1806
  return console.error(`Cannot find Level ${t}'s config.`), null;
1806
1807
  const { size: n, seed: o, method: i, entry: s, exit: a } = e, r = n, l = n, c = s || { row: 0, col: 0 }, d = a || {
1807
1808
  row: r - 1,
1808
1809
  col: l - 1
1809
- }, u = new pn(r, l, i, o, c, d), h = Cn(t), f = [];
1810
- for (let y = 0; y < h; y++) {
1811
- let g;
1810
+ }, u = new gt(r, l, i, o, c, d), h = kn(t), f = [];
1811
+ for (let k = 0; k < h; k++) {
1812
+ let p;
1812
1813
  do
1813
- g = {
1814
+ p = {
1814
1815
  row: Math.floor(u.random() * r),
1815
1816
  col: Math.floor(u.random() * l)
1816
1817
  };
1817
- while (g.row === c.row && g.col === c.col || g.row === d.row && g.col === d.col || !gn(u, g.row, g.col) || f.some((p) => p.row === g.row && p.col === g.col));
1818
- f.push(g);
1818
+ while (p.row === c.row && p.col === c.col || p.row === d.row && p.col === d.col || !pt(u, p.row, p.col) || f.some((_) => _.row === p.row && _.col === p.col));
1819
+ f.push(p);
1819
1820
  }
1820
1821
  return {
1821
1822
  isGameActive: !0,
@@ -1831,104 +1832,282 @@ const gn = (t, e, n) => {
1831
1832
  playerPath: [c],
1832
1833
  visitCounts: { [`${c.row},${c.col}`]: 1 }
1833
1834
  };
1835
+ }, zn = ({
1836
+ size: t,
1837
+ seed: e,
1838
+ method: n,
1839
+ foodCount: o
1840
+ }) => {
1841
+ const i = t, s = t, a = { row: 0, col: 0 }, r = { row: i - 1, col: s - 1 }, l = new gt(i, s, n, e, a, r), c = [];
1842
+ for (let d = 0; d < o; d++) {
1843
+ let u, h = 0;
1844
+ do
1845
+ u = {
1846
+ row: Math.floor(l.random() * i),
1847
+ col: Math.floor(l.random() * s)
1848
+ }, h++;
1849
+ while (h < 50 && (u.row === a.row && u.col === a.col || u.row === r.row && u.col === r.col || !pt(l, u.row, u.col) || c.some(
1850
+ (f) => f.row === u.row && f.col === u.col
1851
+ )));
1852
+ h < 50 && c.push(u);
1853
+ }
1854
+ return {
1855
+ isGameActive: !0,
1856
+ levelTransitioning: !1,
1857
+ maze: l,
1858
+ playerCell: a,
1859
+ exitCell: r,
1860
+ foodCells: c,
1861
+ playerAtExit: !1,
1862
+ foodCollected: 0,
1863
+ totalFoodCount: o
1864
+ };
1834
1865
  };
1835
- function yn() {
1836
- const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } = X(), i = W(null), s = W(null), { i18n: a, levelConfig: r, renderConfig: l } = o, c = Z(r), d = W(
1837
- c.getLevelConfig(n.currentLevel)
1866
+ function En() {
1867
+ const {
1868
+ setGamePlayState: t,
1869
+ gamePlayState: e,
1870
+ gamePlayStateRef: n,
1871
+ gameProgress: o,
1872
+ config: i
1873
+ } = ne(), s = O(null), a = O(null), { i18n: r, levelConfig: l, renderConfig: c } = i, d = oe(l), u = O(
1874
+ d.getLevelConfig(o.currentLevel)
1838
1875
  );
1839
- D(() => {
1840
- i.current && U.attachTo(i.current);
1876
+ R(() => {
1877
+ s.current && j.attachTo(s.current);
1841
1878
  }, []);
1842
- const u = W(), h = en(s, () => {
1843
- u.current?.();
1844
- }), f = tn(s);
1845
- D(() => {
1846
- d.current = c.getLevelConfig(
1847
- n.currentLevel
1879
+ const h = O(), f = ft(a, () => {
1880
+ h.current?.();
1881
+ }), k = mt(
1882
+ a,
1883
+ e,
1884
+ c.padding
1885
+ );
1886
+ R(() => {
1887
+ u.current = d.getLevelConfig(
1888
+ o.currentLevel
1848
1889
  );
1849
- }, [n.currentLevel]);
1850
- const y = () => {
1851
- const _ = wn(
1852
- n.currentLevel,
1853
- d.current
1890
+ }, [o.currentLevel]);
1891
+ const p = () => {
1892
+ const M = Sn(
1893
+ o.currentLevel,
1894
+ u.current
1854
1895
  );
1855
- _ && t((k) => ({
1856
- ...k,
1857
- ..._
1896
+ M && t((C) => ({
1897
+ ...C,
1898
+ ...M
1858
1899
  }));
1859
1900
  };
1860
- D(() => {
1861
- y();
1862
- }, [n.currentLevel]);
1863
- const g = () => {
1864
- y();
1865
- }, { updatePlayerPos: p, resetMovingState: m } = nn({
1866
- containerRef: i,
1867
- gamePlayStateRef: e,
1901
+ R(() => {
1902
+ p();
1903
+ }, [o.currentLevel]);
1904
+ const _ = () => {
1905
+ p();
1906
+ }, { updatePlayerPos: b, resetMovingState: w } = _t({
1907
+ containerRef: s,
1908
+ gamePlayStateRef: n,
1868
1909
  setGamePlayState: t,
1869
- playerRadius: l.playerRadius,
1870
- moveSpeed: l.gridMoveSpeed,
1910
+ playerRadius: c.playerRadius,
1911
+ moveSpeed: c.gridMoveSpeed,
1871
1912
  onFoodCollected: () => {
1872
- const _ = e.current.totalFoodCount - e.current.foodCollected - 1;
1873
- _ > 0 ? U.show(
1874
- a.foodCollectedToast.replace("%NUM%", _.toString()),
1913
+ const M = n.current.totalFoodCount - n.current.foodCollected - 1;
1914
+ M > 0 ? j.show(
1915
+ r.foodCollectedToast.replace("%NUM%", M.toString()),
1875
1916
  3e3
1876
- ) : U.show(a.allFoodCollectedToast);
1917
+ ) : j.show(r.allFoodCollectedToast);
1877
1918
  }
1878
1919
  });
1879
- return D(() => {
1880
- m();
1881
- }, [n.currentLevel, m]), D(() => {
1882
- let _, k = !document.hidden;
1883
- const T = () => {
1884
- const S = s.current?.getContext("2d"), w = e.current;
1885
- if (!(k && w?.isGameActive && S && w?.maze)) {
1886
- _ = requestAnimationFrame(T);
1920
+ return R(() => {
1921
+ w();
1922
+ }, [o.currentLevel, w]), R(() => {
1923
+ let M, C = !document.hidden;
1924
+ const z = () => {
1925
+ const L = a.current?.getContext("2d"), y = n.current;
1926
+ if (!(C && y?.isGameActive && L && y?.maze)) {
1927
+ M = requestAnimationFrame(z);
1887
1928
  return;
1888
1929
  }
1889
- p(), L(), _ = requestAnimationFrame(T);
1890
- }, L = () => {
1891
- const S = s.current?.getContext("2d"), w = e.current;
1892
- if (S && w?.maze) {
1893
- const E = d.current?.wallWidth || l?.wallWidth, b = d.current?.exitColor || l?.exitColor, z = d.current?.exitWallWidth || l?.exitWallWidth, N = d.current?.exitDashArray || l?.exitDashArray;
1894
- ln(S, w, h.current, f.current, {
1895
- ...l,
1896
- wallWidth: E,
1897
- exitColor: b,
1898
- exitWallWidth: z,
1930
+ b(), S(), M = requestAnimationFrame(z);
1931
+ }, S = () => {
1932
+ const L = a.current?.getContext("2d"), y = n.current;
1933
+ if (L && y?.maze) {
1934
+ const g = u.current?.wallWidth || c?.wallWidth, v = u.current?.exitColor || c?.exitColor, T = u.current?.exitWallWidth || c?.exitWallWidth, N = u.current?.exitDashArray || c?.exitDashArray;
1935
+ vt(L, y, f.current, k.current, {
1936
+ ...c,
1937
+ wallWidth: g,
1938
+ exitColor: v,
1939
+ exitWallWidth: T,
1899
1940
  exitDashArray: N
1900
1941
  });
1901
1942
  }
1902
1943
  };
1903
- u.current = L;
1904
- const C = (S) => {
1905
- const w = k;
1906
- k = !document.hidden && document.visibilityState === "visible" && (!S || S.type !== "blur"), !w && k ? e.current?.levelTransitioning === !1 && t({
1907
- ...e.current,
1944
+ h.current = S;
1945
+ const E = (L) => {
1946
+ const y = C;
1947
+ C = !document.hidden && document.visibilityState === "visible" && (!L || L.type !== "blur"), !y && C ? n.current?.levelTransitioning === !1 && t({
1948
+ ...n.current,
1908
1949
  isGameActive: !0
1909
- }) : w && !k && t({
1910
- ...e.current,
1950
+ }) : y && !C && t({
1951
+ ...n.current,
1911
1952
  isGameActive: !1
1912
1953
  });
1913
1954
  };
1914
- return document.addEventListener("visibilitychange", C), window.addEventListener("blur", C), window.addEventListener("focus", C), _ = requestAnimationFrame(T), () => {
1915
- cancelAnimationFrame(_), document.removeEventListener("visibilitychange", C), window.removeEventListener("blur", C), window.removeEventListener("focus", C);
1955
+ return document.addEventListener("visibilitychange", E), window.addEventListener("blur", E), window.addEventListener("focus", E), M = requestAnimationFrame(z), () => {
1956
+ cancelAnimationFrame(M), document.removeEventListener("visibilitychange", E), window.removeEventListener("blur", E), window.removeEventListener("focus", E);
1916
1957
  };
1917
- }, []), D(() => {
1918
- U.show(a.useArrowKeyTips, 3e3);
1919
- }, []), /* @__PURE__ */ v("div", { className: "maze-game-container", children: [
1920
- /* @__PURE__ */ v(Lt, {}),
1921
- /* @__PURE__ */ v(Qt, { onRetry: g }),
1922
- /* @__PURE__ */ v("div", { className: "maze-canvas-container", ref: i, children: [
1923
- /* @__PURE__ */ v("canvas", { ref: s, className: "maze-game-canvas" }),
1924
- /* @__PURE__ */ v("div", { className: "maze-touch-area maze-up" }),
1925
- /* @__PURE__ */ v("div", { className: "maze-touch-area maze-down" }),
1926
- /* @__PURE__ */ v("div", { className: "maze-touch-area maze-left" }),
1927
- /* @__PURE__ */ v("div", { className: "maze-touch-area maze-right" })
1958
+ }, []), R(() => {
1959
+ j.show(r.useArrowKeyTips, 3e3);
1960
+ }, []), /* @__PURE__ */ m("div", { className: "maze-game-container", children: [
1961
+ /* @__PURE__ */ m(Ot, {}),
1962
+ /* @__PURE__ */ m(dn, { onRetry: _ }),
1963
+ /* @__PURE__ */ m("div", { className: "maze-canvas-container", ref: s, children: [
1964
+ /* @__PURE__ */ m("canvas", { ref: a, className: "maze-game-canvas" }),
1965
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-up" }),
1966
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-down" }),
1967
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-left" }),
1968
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-right" })
1928
1969
  ] })
1929
1970
  ] });
1930
1971
  }
1931
- const at = [
1972
+ const Ln = (t) => {
1973
+ const e = Math.floor(t / 60), n = t % 60;
1974
+ return `${e.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}`;
1975
+ }, Nn = ({
1976
+ timer: t,
1977
+ onTimeUp: e
1978
+ }) => {
1979
+ const [n, o] = U(t), i = O(), s = O(!1);
1980
+ return R(() => {
1981
+ const a = () => {
1982
+ !s.current && !i.current && (s.current = !0, i.current = setInterval(() => {
1983
+ o((l) => l <= 1 ? (clearInterval(i.current), e(), 0) : l - 1);
1984
+ }, 1e3));
1985
+ }, r = () => {
1986
+ clearInterval(i.current), i.current = void 0;
1987
+ };
1988
+ return window.addEventListener("maze:firstMove", a), window.addEventListener("maze:gameSuccess", r), () => {
1989
+ window.removeEventListener("maze:firstMove", a), window.removeEventListener("maze:gameSuccess", r), clearInterval(i.current);
1990
+ };
1991
+ }, []), R(() => {
1992
+ i.current && (clearInterval(i.current), i.current = void 0), o(t), s.current = !1;
1993
+ }, [t]), /* @__PURE__ */ m("div", { className: "single-maze-timer", children: /* @__PURE__ */ m(
1994
+ "span",
1995
+ {
1996
+ className: `maze-timer-text ${n <= 10 && s.current ? "maze-timer-warning" : ""}`,
1997
+ children: [
1998
+ "⏱️ ",
1999
+ Ln(n)
2000
+ ]
2001
+ }
2002
+ ) });
2003
+ };
2004
+ function Mn({ config: t }) {
2005
+ const {
2006
+ size: e,
2007
+ seed: n,
2008
+ method: o,
2009
+ foodCount: i,
2010
+ renderConfig: s,
2011
+ successCallback: a,
2012
+ failCallback: r,
2013
+ timer: l,
2014
+ i18n: c
2015
+ } = t, [d, u] = U({
2016
+ ...ke
2017
+ }), [h, f] = U(!1), [k, p] = U(!1), [_, b] = U(!1), [w, M] = U(""), C = O(null), z = O(null), S = O(d), E = O(), L = ft(C, () => {
2018
+ E.current?.();
2019
+ }), y = mt(C, d, s.padding);
2020
+ R(() => {
2021
+ S.current = d;
2022
+ }, [d]);
2023
+ const { updatePlayerPos: g, resetMovingState: v, resetFirstMoveState: T } = _t({
2024
+ containerRef: z,
2025
+ gamePlayStateRef: S,
2026
+ setGamePlayState: u,
2027
+ playerRadius: s.playerRadius,
2028
+ moveSpeed: s.gridMoveSpeed,
2029
+ onFoodCollected: () => {
2030
+ console.log("Food collected in single maze");
2031
+ },
2032
+ onExitReached: () => {
2033
+ k || P();
2034
+ },
2035
+ onFirstMove: () => {
2036
+ window.dispatchEvent(new CustomEvent("maze:firstMove"));
2037
+ }
2038
+ }), N = () => {
2039
+ p(!0), M(`⏰ ${c.failMsg}`), b(!0), u((I) => ({
2040
+ ...I,
2041
+ isGameActive: !1
2042
+ })), r && r();
2043
+ }, P = () => {
2044
+ p(!0), M(`🎉 ${c.successMsg}`), b(!0), window.dispatchEvent(new CustomEvent("maze:gameSuccess")), a && a();
2045
+ }, D = () => {
2046
+ b(!1);
2047
+ };
2048
+ return R(() => {
2049
+ (async () => {
2050
+ f(!0);
2051
+ try {
2052
+ const $ = zn({
2053
+ size: e,
2054
+ seed: n,
2055
+ method: o,
2056
+ foodCount: i
2057
+ });
2058
+ S.current = $, u($);
2059
+ } catch ($) {
2060
+ console.error("Error generating single maze:", $);
2061
+ } finally {
2062
+ f(!1);
2063
+ }
2064
+ })();
2065
+ }, [t]), R(() => {
2066
+ let I;
2067
+ const $ = !document.hidden, B = () => {
2068
+ const G = C.current?.getContext("2d"), q = S.current;
2069
+ if (!($ && q?.isGameActive && G && q?.maze)) {
2070
+ I = requestAnimationFrame(B);
2071
+ return;
2072
+ }
2073
+ g(), V(), I = requestAnimationFrame(B);
2074
+ }, V = () => {
2075
+ const G = C.current?.getContext("2d"), q = S.current;
2076
+ G && q?.maze && vt(
2077
+ G,
2078
+ q,
2079
+ L.current,
2080
+ y.current,
2081
+ s
2082
+ );
2083
+ };
2084
+ return E.current = V, I = requestAnimationFrame(B), () => {
2085
+ cancelAnimationFrame(I);
2086
+ };
2087
+ }, []), R(() => {
2088
+ v(), T();
2089
+ }, [t, v, T]), h ? /* @__PURE__ */ m("div", { className: "single-maze-loading", children: /* @__PURE__ */ m("div", { children: "Generating maze..." }) }) : d ? /* @__PURE__ */ m("div", { className: "maze-game-container", children: [
2090
+ /* @__PURE__ */ m(Nn, { timer: l, onTimeUp: N }),
2091
+ /* @__PURE__ */ m("div", { className: "single-maze-canvas-container", ref: z, children: [
2092
+ /* @__PURE__ */ m("canvas", { ref: C, className: "maze-game-canvas" }),
2093
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-up" }),
2094
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-down" }),
2095
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-left" }),
2096
+ /* @__PURE__ */ m("div", { className: "maze-touch-area maze-right" })
2097
+ ] }),
2098
+ /* @__PURE__ */ m(
2099
+ Q,
2100
+ {
2101
+ isOpen: _,
2102
+ title: w,
2103
+ noConfirm: !0,
2104
+ cancelText: "OK",
2105
+ onCancel: D
2106
+ }
2107
+ )
2108
+ ] }) : /* @__PURE__ */ m("div", { className: "single-maze-error", children: /* @__PURE__ */ m("div", { children: "Failed to generate maze" }) });
2109
+ }
2110
+ const wt = [
1932
2111
  // Tier 1 (Levels 1-12) - Beginner
1933
2112
  [
1934
2113
  // debug
@@ -2086,7 +2265,23 @@ const at = [
2086
2265
  { size: 68, seed: 33341, method: "backtracking" }
2087
2266
  // Level 60 - Master
2088
2267
  ]
2089
- ], bn = 0.07, se = {
2268
+ ], An = 0.07, Ct = {
2269
+ gridMoveSpeed: An,
2270
+ padding: 10,
2271
+ wallWidth: 2,
2272
+ wallColor: "#000000",
2273
+ foodColor: "#4CAF50",
2274
+ clueColor: "rgb(255,0,0)",
2275
+ backgroundColor: "#ffffff",
2276
+ playerColor: "#4CAF50",
2277
+ playerRadius: 0.2,
2278
+ // Exit
2279
+ exitColor: "#F44336",
2280
+ exitWallWidth: 4,
2281
+ // default exit wall width if not specified in level config, should always be a little wider than normal wallWidth
2282
+ exitDashArray: [8, 12]
2283
+ // default dash: 8px dash, 12px gap
2284
+ }, ce = {
2090
2285
  lcPrefix: "maze-",
2091
2286
  i18n: {
2092
2287
  reset: "Reset",
@@ -2131,79 +2326,122 @@ const at = [
2131
2326
  cluePathDisabled: "Clue Path Disabled",
2132
2327
  useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue."
2133
2328
  },
2134
- renderConfig: {
2135
- gridMoveSpeed: bn,
2136
- padding: 10,
2137
- wallWidth: 2,
2138
- wallColor: "#000000",
2139
- foodColor: "#4CAF50",
2140
- clueColor: "rgb(255,0,0)",
2141
- backgroundColor: "#ffffff",
2142
- playerColor: "#4CAF50",
2143
- playerRadius: 0.2,
2144
- // Exit
2145
- exitColor: "#F44336",
2146
- exitWallWidth: 4,
2147
- // default exit wall width if not specified in level config, should always be a little wider than normal wallWidth
2148
- exitDashArray: [8, 12]
2149
- // default dash: 8px dash, 12px gap
2329
+ renderConfig: Ct,
2330
+ levelConfig: wt
2331
+ }, ue = {
2332
+ i18n: {
2333
+ successMsg: "Congratulations! You completed the maze!",
2334
+ failMsg: "Time is up!",
2335
+ restart: "Restart"
2336
+ },
2337
+ size: 8,
2338
+ seed: 12345,
2339
+ method: "backtracking",
2340
+ foodCount: 3,
2341
+ renderConfig: Ct,
2342
+ timer: 10 * 60,
2343
+ // 10 minutes
2344
+ successCallback: () => {
2345
+ console.log("🎉 Single maze completed successfully!");
2150
2346
  },
2151
- levelConfig: at
2347
+ failCallback: () => {
2348
+ console.log("⏰ Time is up! Game failed.");
2349
+ }
2152
2350
  };
2153
- function kn({ config: t = {} }) {
2154
- const e = { ...se.i18n, ...t.i18n || {} }, n = {
2155
- ...se.renderConfig,
2351
+ function Pn({ config: t = {} }) {
2352
+ const e = { ...ce.i18n, ...t.i18n || {} }, n = {
2353
+ ...ce.renderConfig,
2156
2354
  ...t.renderConfig || {}
2157
- }, o = t.levelConfig || at, i = {
2158
- ...se,
2355
+ }, o = t.levelConfig || wt, i = {
2356
+ ...ce,
2159
2357
  ...t,
2160
2358
  i18n: e,
2161
2359
  levelConfig: o,
2162
2360
  renderConfig: n
2163
2361
  };
2164
- return /* @__PURE__ */ v(Tt, { config: i, children: /* @__PURE__ */ v(yn, {}) });
2362
+ return /* @__PURE__ */ m(Rt, { config: i, children: /* @__PURE__ */ m(En, {}) });
2363
+ }
2364
+ function In({
2365
+ config: t = {}
2366
+ }) {
2367
+ const e = { ...ue.i18n, ...t.i18n || {} }, n = {
2368
+ ...ue.renderConfig,
2369
+ ...t.renderConfig || {}
2370
+ }, o = {
2371
+ ...ue,
2372
+ ...t,
2373
+ i18n: e,
2374
+ renderConfig: n
2375
+ };
2376
+ return /* @__PURE__ */ m(Mn, { config: o });
2165
2377
  }
2166
- const Tn = {
2167
- root: "https://unpkg.com/@roudanio/maze@0.1.8/dist/",
2168
- ...se
2378
+ const xn = {
2379
+ root: "https://unpkg.com/@roudanio/maze@0.2.1/dist/",
2380
+ ...ce
2169
2381
  };
2170
- `${JSON.stringify(Tn, null, 2)}`;
2171
- const Sn = {
2172
- async init(t, e) {
2173
- const n = typeof t == "string" ? document.querySelector(t) : t;
2174
- if (!n) {
2175
- console.warn("Cannot find the root element");
2176
- const l = document.createElement("div");
2177
- l.style.textAlign = "center", l.style.padding = "20px", l.innerHTML = "Cannot find the root element", document.body.append(l);
2178
- return;
2179
- }
2180
- let { root: o = location.origin } = e;
2181
- o.at(-1) !== "/" && (o += "/");
2182
- const i = document.createElement("div"), s = document.createElement("div");
2183
- i.style.cssText = `
2382
+ `${JSON.stringify(xn, null, 2)}`;
2383
+ const Rn = {
2384
+ root: "https://unpkg.com/@roudanio/maze@0.2.1/dist/",
2385
+ ...ue
2386
+ };
2387
+ `${JSON.stringify(
2388
+ Rn,
2389
+ (t, e) => typeof e == "function" ? e.toString() : e,
2390
+ 2
2391
+ )}`;
2392
+ const Fn = {
2393
+ showNotice() {
2394
+ console.warn("Cannot find the root element");
2395
+ const t = document.createElement("div");
2396
+ t.style.textAlign = "center", t.style.padding = "20px", t.innerHTML = "Cannot find the root element", document.body.append(t);
2397
+ },
2398
+ addLoadingIndicator(t) {
2399
+ const e = document.createElement("div"), n = document.createElement("div");
2400
+ e.style.cssText = `
2184
2401
  height: 30px;
2185
2402
  width: 100%;
2186
2403
  border: solid 2px #999;
2187
2404
  margin: 20% auto;
2188
- `, s.style.cssText = `
2405
+ `, n.style.cssText = `
2189
2406
  width: 99%;
2190
2407
  height: 100%;
2191
2408
  background: #999;
2192
2409
  animation: loading 1.5s ease-in-out;
2193
2410
  transition: width 1.5s ease-in-out;
2194
- transition: width 1.5s ease-in-out;
2195
- `, i.append(s), n.append(i);
2196
- const a = document.createElement("style");
2197
- a.innerHTML = `
2411
+ `, e.append(n), t.append(e);
2412
+ const o = document.createElement("style");
2413
+ o.innerHTML = `
2198
2414
  @keyframes loading {
2199
2415
  0% { width: 0%; }
2200
2416
  100% { width: 99%; }
2201
- }`, document.head.appendChild(a), await (async (l) => new Promise((c, d) => {
2202
- const u = document.createElement("link");
2203
- u.rel = "stylesheet", u.type = "text/css", u.href = l, u.onload = c, u.onerror = d, document.head.appendChild(u);
2204
- }))(o + "maze.css"), vt(/* @__PURE__ */ v(kn, { config: e }), n);
2417
+ }`, document.head.appendChild(o);
2418
+ },
2419
+ async loadCSS(t) {
2420
+ const e = document.createElement("link");
2421
+ return e.rel = "stylesheet", e.href = "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap", document.head.appendChild(e), new Promise((n, o) => {
2422
+ const i = document.createElement("link");
2423
+ i.rel = "stylesheet", i.type = "text/css", i.href = t, i.onload = n, i.onerror = o, document.head.appendChild(i);
2424
+ });
2425
+ },
2426
+ async init(t, e) {
2427
+ const n = typeof t == "string" ? document.querySelector(t) : t;
2428
+ if (!n) {
2429
+ this.showNotice();
2430
+ return;
2431
+ }
2432
+ let { root: o = location.origin } = e;
2433
+ o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", Re(/* @__PURE__ */ m(Pn, { config: e }), n);
2434
+ },
2435
+ async initSingle(t, e) {
2436
+ const n = typeof t == "string" ? document.querySelector(t) : t;
2437
+ if (!n) {
2438
+ this.showNotice();
2439
+ return;
2440
+ }
2441
+ let { root: o = location.origin } = e;
2442
+ o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", Re(/* @__PURE__ */ m(In, { config: e }), n);
2205
2443
  }
2206
2444
  };
2207
2445
  export {
2208
- Sn as default
2446
+ Fn as default
2209
2447
  };