@roudanio/maze 0.1.0 → 0.1.2

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,25 +1,25 @@
1
- var se, S, Ue, W, be, We, je, Ge, me, de, he, He, V = {}, qe = [], it = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, le = Array.isArray;
1
+ var le, L, je, U, Te, Ge, He, qe, pe, fe, _e, Be, X = {}, Ve = [], lt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, ae = Array.isArray;
2
2
  function $(t, e) {
3
3
  for (var n in e) t[n] = e[n];
4
4
  return t;
5
5
  }
6
- function ve(t) {
6
+ function ge(t) {
7
7
  t && t.parentNode && t.parentNode.removeChild(t);
8
8
  }
9
- function st(t, e, n) {
10
- var o, i, s, l = {};
11
- for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : l[s] = e[s];
12
- if (arguments.length > 2 && (l.children = arguments.length > 3 ? se.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) l[s] == null && (l[s] = t.defaultProps[s]);
13
- return Q(t, l, o, i, null);
9
+ function at(t, e, n) {
10
+ var o, i, s, c = {};
11
+ for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : c[s] = e[s];
12
+ if (arguments.length > 2 && (c.children = arguments.length > 3 ? le.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) c[s] == null && (c[s] = t.defaultProps[s]);
13
+ return ee(t, c, o, i, null);
14
14
  }
15
- function Q(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 ?? ++Ue, __i: -1, __u: 0 };
17
- return i == null && S.vnode != null && S.vnode(s), s;
15
+ function ee(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
+ return i == null && L.vnode != null && L.vnode(s), s;
18
18
  }
19
- function ae(t) {
19
+ function ce(t) {
20
20
  return t.children;
21
21
  }
22
- function ee(t, e) {
22
+ function te(t, e) {
23
23
  this.props = t, this.context = e;
24
24
  }
25
25
  function G(t, e) {
@@ -27,38 +27,38 @@ function G(t, e) {
27
27
  for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
28
28
  return typeof t.type == "function" ? G(t) : null;
29
29
  }
30
- function Be(t) {
30
+ function Ye(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 Be(t);
37
+ return Ye(t);
38
38
  }
39
39
  }
40
- function fe(t) {
41
- (!t.__d && (t.__d = !0) && W.push(t) && !re.__r++ || be != S.debounceRendering) && ((be = S.debounceRendering) || We)(re);
40
+ function me(t) {
41
+ (!t.__d && (t.__d = !0) && U.push(t) && !ie.__r++ || Te != L.debounceRendering) && ((Te = L.debounceRendering) || Ge)(ie);
42
42
  }
43
- function re() {
44
- for (var t, e, n, o, i, s, l, r = 1; W.length; ) W.length > r && W.sort(je), t = W.shift(), r = W.length, t.__d && (n = void 0, i = (o = (e = t).__v).__e, s = [], l = [], e.__P && ((n = $({}, o)).__v = o.__v + 1, S.vnode && S.vnode(n), ge(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? G(o), !!(32 & o.__u), l), n.__v = o.__v, n.__.__k[n.__i] = n, Xe(s, n, l), n.__e != i && Be(n)));
45
- re.__r = 0;
43
+ function ie() {
44
+ for (var t, e, n, o, i, s, c, r = 1; U.length; ) U.length > r && U.sort(He), t = U.shift(), r = U.length, t.__d && (n = void 0, i = (o = (e = t).__v).__e, s = [], c = [], e.__P && ((n = $({}, o)).__v = o.__v + 1, L.vnode && L.vnode(n), Ce(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? G(o), !!(32 & o.__u), c), n.__v = o.__v, n.__.__k[n.__i] = n, Je(s, n, c), n.__e != i && Ye(n)));
45
+ ie.__r = 0;
46
46
  }
47
- function Ve(t, e, n, o, i, s, l, r, a, c, d) {
48
- var u, h, f, m, g, _, p = o && o.__k || qe, v = e.length;
49
- for (a = lt(n, e, p, a, v), u = 0; u < v; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? V : p[f.__i] || V, f.__i = u, _ = ge(t, f, h, i, s, l, r, a, c, d), m = f.__e, f.ref && h.ref != f.ref && (h.ref && pe(h.ref, null, f), d.push(f.ref, f.__c || m, f)), g == null && m != null && (g = m), 4 & f.__u || h.__k === f.__k ? a = Ye(f, a, t) : typeof f.type == "function" && _ !== void 0 ? a = _ : m && (a = m.nextSibling), f.__u &= -7);
50
- return n.__e = g, a;
47
+ function Xe(t, e, n, o, i, s, c, r, l, a, d) {
48
+ var u, h, f, w, g, _, v = o && o.__k || Ve, m = e.length;
49
+ for (l = ct(n, e, v, l, m), u = 0; u < m; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? X : v[f.__i] || X, f.__i = u, _ = Ce(t, f, h, i, s, c, r, l, a, d), w = f.__e, f.ref && h.ref != f.ref && (h.ref && we(h.ref, null, f), d.push(f.ref, f.__c || w, f)), g == null && w != null && (g = w), 4 & f.__u || h.__k === f.__k ? l = Ke(f, l, t) : typeof f.type == "function" && _ !== void 0 ? l = _ : w && (l = w.nextSibling), f.__u &= -7);
50
+ return n.__e = g, l;
51
51
  }
52
- function lt(t, e, n, o, i) {
53
- var s, l, r, a, c, d = n.length, u = d, h = 0;
54
- for (t.__k = new Array(i), s = 0; s < i; s++) (l = e[s]) != null && typeof l != "boolean" && typeof l != "function" ? (a = s + h, (l = t.__k[s] = typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? Q(null, l, null, null, null) : le(l) ? Q(ae, { children: l }, null, null, null) : l.constructor == null && l.__b > 0 ? Q(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : l).__ = t, l.__b = t.__b + 1, r = null, (c = l.__i = at(l, n, a, u)) != -1 && (u--, (r = n[c]) && (r.__u |= 2)), r == null || r.__v == null ? (c == -1 && (i > d ? h-- : i < d && h++), typeof l.type != "function" && (l.__u |= 4)) : c != a && (c == a - 1 ? h-- : c == a + 1 ? h++ : (c > a ? h-- : h++, l.__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 = G(r)), Je(r, r));
52
+ function ct(t, e, n, o, i) {
53
+ var s, c, r, l, a, d = n.length, u = d, h = 0;
54
+ for (t.__k = new Array(i), s = 0; s < i; s++) (c = e[s]) != null && typeof c != "boolean" && typeof c != "function" ? (l = s + h, (c = t.__k[s] = typeof c == "string" || typeof c == "number" || typeof c == "bigint" || c.constructor == String ? ee(null, c, null, null, null) : ae(c) ? ee(ce, { children: c }, null, null, null) : c.constructor == null && c.__b > 0 ? ee(c.type, c.props, c.key, c.ref ? c.ref : null, c.__v) : c).__ = t, c.__b = t.__b + 1, r = null, (a = c.__i = ut(c, n, l, u)) != -1 && (u--, (r = n[a]) && (r.__u |= 2)), r == null || r.__v == null ? (a == -1 && (i > d ? h-- : i < d && h++), typeof c.type != "function" && (c.__u |= 4)) : a != l && (a == l - 1 ? h-- : a == l + 1 ? h++ : (a > l ? h-- : h++, c.__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 = G(r)), Qe(r, r));
56
56
  return o;
57
57
  }
58
- function Ye(t, e, n) {
58
+ function Ke(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 = Ye(o[i], e, n));
61
+ for (o = t.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = t, e = Ke(o[i], e, n));
62
62
  return e;
63
63
  }
64
64
  t.__e != e && (e && t.type && !n.contains(e) && (e = G(t)), n.insertBefore(t.__e, e || null), e = t.__e);
@@ -67,32 +67,32 @@ function Ye(t, e, n) {
67
67
  while (e != null && e.nodeType == 8);
68
68
  return e;
69
69
  }
70
- function at(t, e, n, o) {
71
- var i, s, l = t.key, r = t.type, a = e[n];
72
- if (a === null && t.key == null || a && l == a.key && r == a.type && (2 & a.__u) == 0) return n;
73
- if (o > (a != null && (2 & a.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < e.length; ) {
70
+ function ut(t, e, n, o) {
71
+ var i, s, c = t.key, r = t.type, l = e[n];
72
+ if (l === null && t.key == null || l && c == l.key && r == l.type && (2 & l.__u) == 0) return n;
73
+ if (o > (l != null && (2 & l.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < e.length; ) {
74
74
  if (i >= 0) {
75
- if ((a = e[i]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return i;
75
+ if ((l = e[i]) && (2 & l.__u) == 0 && c == l.key && r == l.type) return i;
76
76
  i--;
77
77
  }
78
78
  if (s < e.length) {
79
- if ((a = e[s]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return s;
79
+ if ((l = e[s]) && (2 & l.__u) == 0 && c == l.key && r == l.type) return s;
80
80
  s++;
81
81
  }
82
82
  }
83
83
  return -1;
84
84
  }
85
- function ke(t, e, n) {
86
- e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || it.test(e) ? n : n + "px";
85
+ function Se(t, e, n) {
86
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || lt.test(e) ? n : n + "px";
87
87
  }
88
- function J(t, e, n, o, i) {
88
+ function Z(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 || ke(t.style, e, "");
93
- if (n) for (e in n) o && n[e] == o[e] || ke(t.style, e, n[e]);
92
+ if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || Se(t.style, e, "");
93
+ if (n) for (e in n) o && n[e] == o[e] || Se(t.style, e, n[e]);
94
94
  }
95
- else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(Ge, "$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 = me, t.addEventListener(e, s ? he : de, s)) : t.removeEventListener(e, s ? he : de, s);
95
+ else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(qe, "$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 = pe, t.addEventListener(e, s ? _e : fe, s)) : t.removeEventListener(e, s ? _e : fe, 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,127 +103,127 @@ function J(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 Te(t) {
106
+ function ze(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 = me++;
110
+ if (e.t == null) e.t = pe++;
111
111
  else if (e.t < n.u) return;
112
- return n(S.event ? S.event(e) : e);
112
+ return n(L.event ? L.event(e) : e);
113
113
  }
114
114
  };
115
115
  }
116
- function ge(t, e, n, o, i, s, l, r, a, c) {
117
- var d, u, h, f, m, g, _, p, v, y, w, b, k, T, z, L, E, N = e.type;
116
+ function Ce(t, e, n, o, i, s, c, r, l, a) {
117
+ var d, u, h, f, w, g, _, v, m, y, C, k, T, z, S, b, E, N = e.type;
118
118
  if (e.constructor != null) return null;
119
- 128 & n.__u && (a = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d = S.__b) && d(e);
119
+ 128 & n.__u && (l = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d = L.__b) && d(e);
120
120
  e: if (typeof N == "function") try {
121
- if (p = e.props, v = "prototype" in N && N.prototype.render, y = (d = N.contextType) && o[d.__c], w = d ? y ? y.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (v ? e.__c = u = new N(p, w) : (e.__c = u = new ee(p, w), u.constructor = N, u.render = ut), y && y.sub(u), u.props = p, u.state || (u.state = {}), u.context = w, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), v && u.__s == null && (u.__s = u.state), v && N.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = $({}, u.__s)), $(u.__s, N.getDerivedStateFromProps(p, u.__s))), f = u.props, m = u.state, u.__v = e, h) v && N.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), v && u.componentDidMount != null && u.__h.push(u.componentDidMount);
121
+ if (v = e.props, m = "prototype" in N && N.prototype.render, y = (d = N.contextType) && o[d.__c], C = d ? y ? y.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (m ? e.__c = u = new N(v, C) : (e.__c = u = new te(v, C), u.constructor = N, u.render = ht), y && y.sub(u), u.props = v, u.state || (u.state = {}), u.context = C, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), m && u.__s == null && (u.__s = u.state), m && N.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = $({}, u.__s)), $(u.__s, N.getDerivedStateFromProps(v, u.__s))), f = u.props, w = u.state, u.__v = e, h) m && N.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), m && u.componentDidMount != null && u.__h.push(u.componentDidMount);
122
122
  else {
123
- if (v && N.getDerivedStateFromProps == null && p !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(p, w), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(p, u.__s, w) === !1 || e.__v == n.__v) {
124
- for (e.__v != n.__v && (u.props = p, u.state = u.__s, u.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(P) {
123
+ if (m && N.getDerivedStateFromProps == null && v !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(v, C), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(v, u.__s, C) === !1 || e.__v == n.__v) {
124
+ for (e.__v != n.__v && (u.props = v, u.state = u.__s, u.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(P) {
125
125
  P && (P.__ = e);
126
- }), b = 0; b < u._sb.length; b++) u.__h.push(u._sb[b]);
127
- u._sb = [], u.__h.length && l.push(u);
126
+ }), k = 0; k < u._sb.length; k++) u.__h.push(u._sb[k]);
127
+ u._sb = [], u.__h.length && c.push(u);
128
128
  break e;
129
129
  }
130
- u.componentWillUpdate != null && u.componentWillUpdate(p, u.__s, w), v && u.componentDidUpdate != null && u.__h.push(function() {
131
- u.componentDidUpdate(f, m, g);
130
+ u.componentWillUpdate != null && u.componentWillUpdate(v, u.__s, C), m && u.componentDidUpdate != null && u.__h.push(function() {
131
+ u.componentDidUpdate(f, w, g);
132
132
  });
133
133
  }
134
- if (u.context = w, u.props = p, u.__P = t, u.__e = !1, k = S.__r, T = 0, v) {
135
- for (u.state = u.__s, u.__d = !1, k && k(e), d = u.render(u.props, u.state, u.context), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
134
+ if (u.context = C, u.props = v, u.__P = t, u.__e = !1, T = L.__r, z = 0, m) {
135
+ for (u.state = u.__s, u.__d = !1, T && T(e), d = u.render(u.props, u.state, u.context), S = 0; S < u._sb.length; S++) u.__h.push(u._sb[S]);
136
136
  u._sb = [];
137
137
  } else do
138
- u.__d = !1, k && k(e), d = u.render(u.props, u.state, u.context), u.state = u.__s;
139
- while (u.__d && ++T < 25);
140
- u.state = u.__s, u.getChildContext != null && (o = $($({}, o), u.getChildContext())), v && !h && u.getSnapshotBeforeUpdate != null && (g = u.getSnapshotBeforeUpdate(f, m)), L = d, d != null && d.type === ae && d.key == null && (L = Ke(d.props.children)), r = Ve(t, le(L) ? L : [L], e, n, o, i, s, l, r, a, c), u.base = e.__e, e.__u &= -161, u.__h.length && l.push(u), _ && (u.__E = u.__ = null);
138
+ u.__d = !1, T && T(e), d = u.render(u.props, u.state, u.context), u.state = u.__s;
139
+ while (u.__d && ++z < 25);
140
+ u.state = u.__s, u.getChildContext != null && (o = $($({}, o), u.getChildContext())), m && !h && u.getSnapshotBeforeUpdate != null && (g = u.getSnapshotBeforeUpdate(f, w)), b = d, d != null && d.type === ce && d.key == null && (b = Ze(d.props.children)), r = Xe(t, ae(b) ? b : [b], e, n, o, i, s, c, r, l, a), u.base = e.__e, e.__u &= -161, u.__h.length && c.push(u), _ && (u.__E = u.__ = null);
141
141
  } catch (P) {
142
- if (e.__v = null, a || s != null) if (P.then) {
143
- for (e.__u |= a ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
142
+ if (e.__v = null, l || s != null) if (P.then) {
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 (E = s.length; E--; ) ve(s[E]);
145
+ } else for (E = s.length; E--; ) ge(s[E]);
146
146
  else e.__e = n.__e, e.__k = n.__k;
147
- S.__e(P, e, n);
147
+ L.__e(P, e, n);
148
148
  }
149
- else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e = ct(n.__e, e, n, o, i, s, l, a, c);
150
- return (d = S.diffed) && d(e), 128 & e.__u ? void 0 : r;
149
+ else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e = dt(n.__e, e, n, o, i, s, c, l, a);
150
+ return (d = L.diffed) && d(e), 128 & e.__u ? void 0 : r;
151
151
  }
152
- function Xe(t, e, n) {
153
- for (var o = 0; o < n.length; o++) pe(n[o], n[++o], n[++o]);
154
- S.__c && S.__c(e, t), t.some(function(i) {
152
+ function Je(t, e, n) {
153
+ for (var o = 0; o < n.length; o++) we(n[o], n[++o], n[++o]);
154
+ L.__c && L.__c(e, t), t.some(function(i) {
155
155
  try {
156
156
  t = i.__h, i.__h = [], t.some(function(s) {
157
157
  s.call(i);
158
158
  });
159
159
  } catch (s) {
160
- S.__e(s, i.__v);
160
+ L.__e(s, i.__v);
161
161
  }
162
162
  });
163
163
  }
164
- function Ke(t) {
165
- return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : le(t) ? t.map(Ke) : $({}, t);
164
+ function Ze(t) {
165
+ return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : ae(t) ? t.map(Ze) : $({}, t);
166
166
  }
167
- function ct(t, e, n, o, i, s, l, r, a) {
168
- var c, d, u, h, f, m, g, _ = n.props, p = e.props, v = e.type;
169
- if (v == "svg" ? i = "http://www.w3.org/2000/svg" : v == "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 == !!v && (v ? f.localName == v : f.nodeType == 3)) {
171
- t = f, s[c] = null;
167
+ function dt(t, e, n, o, i, s, c, r, l) {
168
+ var a, d, u, h, f, w, g, _ = n.props, v = e.props, m = e.type;
169
+ if (m == "svg" ? i = "http://www.w3.org/2000/svg" : m == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
170
+ for (a = 0; a < s.length; a++) if ((f = s[a]) && "setAttribute" in f == !!m && (m ? f.localName == m : f.nodeType == 3)) {
171
+ t = f, s[a] = null;
172
172
  break;
173
173
  }
174
174
  }
175
175
  if (t == null) {
176
- if (v == null) return document.createTextNode(p);
177
- t = document.createElementNS(i, v, p.is && p), r && (S.__m && S.__m(e, s), r = !1), s = null;
176
+ if (m == null) return document.createTextNode(v);
177
+ t = document.createElementNS(i, m, v.is && v), r && (L.__m && L.__m(e, s), r = !1), s = null;
178
178
  }
179
- if (v == null) _ === p || r && t.data == p || (t.data = p);
179
+ if (m == null) _ === v || r && t.data == v || (t.data = v);
180
180
  else {
181
- if (s = s && se.call(t.childNodes), _ = n.props || V, !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
- if (c == "dangerouslySetInnerHTML") u = f;
184
- else if (!(c in p)) {
185
- if (c == "value" && "defaultValue" in p || c == "checked" && "defaultChecked" in p) continue;
186
- J(t, c, null, f, i);
181
+ if (s = s && le.call(t.childNodes), _ = n.props || X, !r && s != null) for (_ = {}, a = 0; a < t.attributes.length; a++) _[(f = t.attributes[a]).name] = f.value;
182
+ for (a in _) if (f = _[a], a != "children") {
183
+ if (a == "dangerouslySetInnerHTML") u = f;
184
+ else if (!(a in v)) {
185
+ if (a == "value" && "defaultValue" in v || a == "checked" && "defaultChecked" in v) continue;
186
+ Z(t, a, null, f, i);
187
187
  }
188
188
  }
189
- for (c in p) f = p[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? m = f : c == "checked" ? g = f : r && typeof f != "function" || _[c] === f || J(t, c, f, _[c], i);
189
+ for (a in v) f = v[a], a == "children" ? h = f : a == "dangerouslySetInnerHTML" ? d = f : a == "value" ? w = f : a == "checked" ? g = f : r && typeof f != "function" || _[a] === f || Z(t, a, f, _[a], 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 = ""), Ve(e.type == "template" ? t.content : t, le(h) ? h : [h], e, n, o, v == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, l, s ? s[0] : n.__k && G(n, 0), r, a), s != null) for (c = s.length; c--; ) ve(s[c]);
192
- r || (c = "value", v == "progress" && m == null ? t.removeAttribute("value") : m != null && (m !== t[c] || v == "progress" && !m || v == "option" && m != _[c]) && J(t, c, m, _[c], i), c = "checked", g != null && g != t[c] && J(t, c, g, _[c], i));
191
+ else if (u && (t.innerHTML = ""), Xe(e.type == "template" ? t.content : t, ae(h) ? h : [h], e, n, o, m == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, c, s ? s[0] : n.__k && G(n, 0), r, l), s != null) for (a = s.length; a--; ) ge(s[a]);
192
+ r || (a = "value", m == "progress" && w == null ? t.removeAttribute("value") : w != null && (w !== t[a] || m == "progress" && !w || m == "option" && w != _[a]) && Z(t, a, w, _[a], i), a = "checked", g != null && g != t[a] && Z(t, a, g, _[a], i));
193
193
  }
194
194
  return t;
195
195
  }
196
- function pe(t, e, n) {
196
+ function we(t, e, n) {
197
197
  try {
198
198
  if (typeof t == "function") {
199
199
  var o = typeof t.__u == "function";
200
200
  o && t.__u(), o && e == null || (t.__u = t(e));
201
201
  } else t.current = e;
202
202
  } catch (i) {
203
- S.__e(i, n);
203
+ L.__e(i, n);
204
204
  }
205
205
  }
206
- function Je(t, e, n) {
206
+ function Qe(t, e, n) {
207
207
  var o, i;
208
- if (S.unmount && S.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || pe(o, null, e)), (o = t.__c) != null) {
208
+ if (L.unmount && L.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || we(o, null, e)), (o = t.__c) != null) {
209
209
  if (o.componentWillUnmount) try {
210
210
  o.componentWillUnmount();
211
211
  } catch (s) {
212
- S.__e(s, e);
212
+ L.__e(s, e);
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] && Je(o[i], e, n || typeof t.type != "function");
217
- n || ve(t.__e), t.__c = t.__ = t.__e = void 0;
216
+ if (o = t.__k) for (i = 0; i < o.length; i++) o[i] && Qe(o[i], e, n || typeof t.type != "function");
217
+ n || ge(t.__e), t.__c = t.__ = t.__e = void 0;
218
218
  }
219
- function ut(t, e, n) {
219
+ function ht(t, e, n) {
220
220
  return this.constructor(t, n);
221
221
  }
222
- function dt(t, e, n) {
223
- var o, i, s, l;
224
- e == document && (e = document.documentElement), S.__ && S.__(t, e), i = (o = !1) ? null : e.__k, s = [], l = [], ge(e, t = e.__k = st(ae, null, [t]), i || V, V, e.namespaceURI, i ? null : e.firstChild ? se.call(e.childNodes) : null, s, i ? i.__e : e.firstChild, o, l), Xe(s, t, l);
222
+ function ft(t, e, n) {
223
+ var o, i, s, c;
224
+ e == document && (e = document.documentElement), L.__ && L.__(t, e), i = (o = !1) ? null : e.__k, s = [], c = [], Ce(e, t = e.__k = at(ce, null, [t]), i || X, X, e.namespaceURI, i ? null : e.firstChild ? le.call(e.childNodes) : null, s, i ? i.__e : e.firstChild, o, c), Je(s, t, c);
225
225
  }
226
- function ht(t) {
226
+ function _t(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() {
@@ -231,180 +231,180 @@ function ht(t) {
231
231
  }, this.componentWillUnmount = function() {
232
232
  o = null;
233
233
  }, this.shouldComponentUpdate = function(s) {
234
- this.props.value != s.value && o.forEach(function(l) {
235
- l.__e = !0, fe(l);
234
+ this.props.value != s.value && o.forEach(function(c) {
235
+ c.__e = !0, me(c);
236
236
  });
237
237
  }, this.sub = function(s) {
238
238
  o.add(s);
239
- var l = s.componentWillUnmount;
239
+ var c = s.componentWillUnmount;
240
240
  s.componentWillUnmount = function() {
241
- o && o.delete(s), l && l.call(s);
241
+ o && o.delete(s), c && c.call(s);
242
242
  };
243
243
  }), n.children;
244
244
  }
245
- return e.__c = "__cC" + He++, e.__ = t, e.Provider = e.__l = (e.Consumer = function(n, o) {
245
+ return e.__c = "__cC" + Be++, 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
- se = qe.slice, S = { __e: function(t, e, n, o) {
250
- for (var i, s, l; e = e.__; ) if ((i = e.__c) && !i.__) try {
251
- if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), l = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, o || {}), l = i.__d), l) return i.__E = i;
249
+ le = Ve.slice, L = { __e: function(t, e, n, o) {
250
+ for (var i, s, c; e = e.__; ) if ((i = e.__c) && !i.__) try {
251
+ if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), c = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, o || {}), c = i.__d), c) return i.__E = i;
252
252
  } catch (r) {
253
253
  t = r;
254
254
  }
255
255
  throw t;
256
- } }, Ue = 0, ee.prototype.setState = function(t, e) {
256
+ } }, je = 0, te.prototype.setState = function(t, e) {
257
257
  var n;
258
- n = this.__s != null && this.__s != this.state ? this.__s : this.__s = $({}, this.state), typeof t == "function" && (t = t($({}, n), this.props)), t && $(n, t), t != null && this.__v && (e && this._sb.push(e), fe(this));
259
- }, ee.prototype.forceUpdate = function(t) {
260
- this.__v && (this.__e = !0, t && this.__h.push(t), fe(this));
261
- }, ee.prototype.render = ae, W = [], We = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, je = function(t, e) {
258
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = $({}, this.state), typeof t == "function" && (t = t($({}, n), this.props)), t && $(n, t), t != null && this.__v && (e && this._sb.push(e), me(this));
259
+ }, te.prototype.forceUpdate = function(t) {
260
+ this.__v && (this.__e = !0, t && this.__h.push(t), me(this));
261
+ }, te.prototype.render = ce, U = [], Ge = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, He = function(t, e) {
262
262
  return t.__v.__b - e.__v.__b;
263
- }, re.__r = 0, Ge = /(PointerCapture)$|Capture$/i, me = 0, de = Te(!1), he = Te(!0), He = 0;
264
- var ft = 0;
265
- function C(t, e, n, o, i, s) {
263
+ }, ie.__r = 0, qe = /(PointerCapture)$|Capture$/i, pe = 0, fe = ze(!1), _e = ze(!0), Be = 0;
264
+ var mt = 0;
265
+ function p(t, e, n, o, i, s) {
266
266
  e || (e = {});
267
- var l, r, a = e;
268
- if ("ref" in a) for (r in a = {}, e) r == "ref" ? l = e[r] : a[r] = e[r];
269
- var c = { type: t, props: a, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --ft, __i: -1, __u: 0, __source: i, __self: s };
270
- if (typeof t == "function" && (l = t.defaultProps)) for (r in l) a[r] === void 0 && (a[r] = l[r]);
271
- return S.vnode && S.vnode(c), c;
272
- }
273
- var H, A, ue, Le, Y = 0, Ze = [], M = S, Se = M.__b, ze = M.__r, Ne = M.diffed, Ae = M.__c, Ee = M.unmount, Me = M.__;
274
- function ce(t, e) {
275
- M.__h && M.__h(A, t, Y || e), Y = 0;
267
+ var c, r, l = e;
268
+ if ("ref" in l) for (r in l = {}, e) r == "ref" ? c = e[r] : l[r] = e[r];
269
+ var a = { type: t, props: l, key: n, ref: c, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --mt, __i: -1, __u: 0, __source: i, __self: s };
270
+ if (typeof t == "function" && (c = t.defaultProps)) for (r in c) l[r] === void 0 && (l[r] = c[r]);
271
+ return L.vnode && L.vnode(a), a;
272
+ }
273
+ var H, A, he, Le, K = 0, et = [], M = L, Ne = M.__b, Ae = M.__r, Ee = M.diffed, Me = M.__c, Pe = M.unmount, Ie = M.__;
274
+ function ue(t, e) {
275
+ M.__h && M.__h(A, t, K || e), K = 0;
276
276
  var n = A.__H || (A.__H = { __: [], __h: [] });
277
277
  return t >= n.__.length && n.__.push({}), n.__[t];
278
278
  }
279
279
  function j(t) {
280
- return Y = 1, _t(et, t);
280
+ return K = 1, vt(nt, t);
281
281
  }
282
- function _t(t, e, n) {
283
- var o = ce(H++, 2);
284
- if (o.t = t, !o.__c && (o.__ = [et(void 0, e), function(r) {
285
- var a = o.__N ? o.__N[0] : o.__[0], c = o.t(a, r);
286
- a !== c && (o.__N = [c, o.__[1]], o.__c.setState({}));
282
+ function vt(t, e, n) {
283
+ var o = ue(H++, 2);
284
+ if (o.t = t, !o.__c && (o.__ = [nt(void 0, e), function(r) {
285
+ var l = o.__N ? o.__N[0] : o.__[0], a = o.t(l, r);
286
+ l !== a && (o.__N = [a, o.__[1]], o.__c.setState({}));
287
287
  }], o.__c = A, !A.__f)) {
288
- var i = function(r, a, c) {
288
+ var i = function(r, l, a) {
289
289
  if (!o.__c.__H) return !0;
290
290
  var d = o.__c.__H.__.filter(function(h) {
291
291
  return !!h.__c;
292
292
  });
293
293
  if (d.every(function(h) {
294
294
  return !h.__N;
295
- })) return !s || s.call(this, r, a, c);
295
+ })) return !s || s.call(this, r, l, a);
296
296
  var u = o.__c.props !== r;
297
297
  return d.forEach(function(h) {
298
298
  if (h.__N) {
299
299
  var f = h.__[0];
300
300
  h.__ = h.__N, h.__N = void 0, f !== h.__[0] && (u = !0);
301
301
  }
302
- }), s && s.call(this, r, a, c) || u;
302
+ }), s && s.call(this, r, l, a) || u;
303
303
  };
304
304
  A.__f = !0;
305
- var s = A.shouldComponentUpdate, l = A.componentWillUpdate;
306
- A.componentWillUpdate = function(r, a, c) {
305
+ var s = A.shouldComponentUpdate, c = A.componentWillUpdate;
306
+ A.componentWillUpdate = function(r, l, a) {
307
307
  if (this.__e) {
308
308
  var d = s;
309
- s = void 0, i(r, a, c), s = d;
309
+ s = void 0, i(r, l, a), s = d;
310
310
  }
311
- l && l.call(this, r, a, c);
311
+ c && c.call(this, r, l, a);
312
312
  }, A.shouldComponentUpdate = i;
313
313
  }
314
314
  return o.__N || o.__;
315
315
  }
316
316
  function x(t, e) {
317
- var n = ce(H++, 3);
318
- !M.__s && Qe(n.__H, e) && (n.__ = t, n.u = e, A.__H.__h.push(n));
317
+ var n = ue(H++, 3);
318
+ !M.__s && tt(n.__H, e) && (n.__ = t, n.u = e, A.__H.__h.push(n));
319
319
  }
320
- function O(t) {
321
- return Y = 5, q(function() {
320
+ function F(t) {
321
+ return K = 5, q(function() {
322
322
  return { current: t };
323
323
  }, []);
324
324
  }
325
325
  function q(t, e) {
326
- var n = ce(H++, 7);
327
- return Qe(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
326
+ var n = ue(H++, 7);
327
+ return tt(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
328
328
  }
329
- function mt(t, e) {
330
- return Y = 8, q(function() {
329
+ function pt(t, e) {
330
+ return K = 8, q(function() {
331
331
  return t;
332
332
  }, e);
333
333
  }
334
- function vt(t) {
335
- var e = A.context[t.__c], n = ce(H++, 9);
334
+ function gt(t) {
335
+ var e = A.context[t.__c], n = ue(H++, 9);
336
336
  return n.c = t, e ? (n.__ == null && (n.__ = !0, e.sub(A)), e.props.value) : t.__;
337
337
  }
338
- function gt() {
339
- for (var t; t = Ze.shift(); ) if (t.__P && t.__H) try {
340
- t.__H.__h.forEach(te), t.__H.__h.forEach(_e), t.__H.__h = [];
338
+ function Ct() {
339
+ for (var t; t = et.shift(); ) if (t.__P && t.__H) try {
340
+ t.__H.__h.forEach(ne), t.__H.__h.forEach(ve), t.__H.__h = [];
341
341
  } catch (e) {
342
342
  t.__H.__h = [], M.__e(e, t.__v);
343
343
  }
344
344
  }
345
345
  M.__b = function(t) {
346
- A = null, Se && Se(t);
346
+ A = null, Ne && Ne(t);
347
347
  }, M.__ = function(t, e) {
348
- t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Me && Me(t, e);
348
+ t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Ie && Ie(t, e);
349
349
  }, M.__r = function(t) {
350
- ze && ze(t), H = 0;
350
+ Ae && Ae(t), H = 0;
351
351
  var e = (A = t.__c).__H;
352
- e && (ue === A ? (e.__h = [], A.__h = [], e.__.forEach(function(n) {
352
+ e && (he === A ? (e.__h = [], A.__h = [], e.__.forEach(function(n) {
353
353
  n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
354
- })) : (e.__h.forEach(te), e.__h.forEach(_e), e.__h = [], H = 0)), ue = A;
354
+ })) : (e.__h.forEach(ne), e.__h.forEach(ve), e.__h = [], H = 0)), he = A;
355
355
  }, M.diffed = function(t) {
356
- Ne && Ne(t);
356
+ Ee && Ee(t);
357
357
  var e = t.__c;
358
- e && e.__H && (e.__H.__h.length && (Ze.push(e) !== 1 && Le === M.requestAnimationFrame || ((Le = M.requestAnimationFrame) || pt)(gt)), e.__H.__.forEach(function(n) {
358
+ e && e.__H && (e.__H.__h.length && (et.push(e) !== 1 && Le === M.requestAnimationFrame || ((Le = M.requestAnimationFrame) || wt)(Ct)), e.__H.__.forEach(function(n) {
359
359
  n.u && (n.__H = n.u), n.u = void 0;
360
- })), ue = A = null;
360
+ })), he = A = null;
361
361
  }, M.__c = function(t, e) {
362
362
  e.some(function(n) {
363
363
  try {
364
- n.__h.forEach(te), n.__h = n.__h.filter(function(o) {
365
- return !o.__ || _e(o);
364
+ n.__h.forEach(ne), n.__h = n.__h.filter(function(o) {
365
+ return !o.__ || ve(o);
366
366
  });
367
367
  } catch (o) {
368
368
  e.some(function(i) {
369
369
  i.__h && (i.__h = []);
370
370
  }), e = [], M.__e(o, n.__v);
371
371
  }
372
- }), Ae && Ae(t, e);
372
+ }), Me && Me(t, e);
373
373
  }, M.unmount = function(t) {
374
- Ee && Ee(t);
374
+ Pe && Pe(t);
375
375
  var e, n = t.__c;
376
376
  n && n.__H && (n.__H.__.forEach(function(o) {
377
377
  try {
378
- te(o);
378
+ ne(o);
379
379
  } catch (i) {
380
380
  e = i;
381
381
  }
382
382
  }), n.__H = void 0, e && M.__e(e, n.__v));
383
383
  };
384
- var Pe = typeof requestAnimationFrame == "function";
385
- function pt(t) {
384
+ var xe = typeof requestAnimationFrame == "function";
385
+ function wt(t) {
386
386
  var e, n = function() {
387
- clearTimeout(o), Pe && cancelAnimationFrame(e), setTimeout(t);
387
+ clearTimeout(o), xe && cancelAnimationFrame(e), setTimeout(t);
388
388
  }, o = setTimeout(n, 100);
389
- Pe && (e = requestAnimationFrame(n));
389
+ xe && (e = requestAnimationFrame(n));
390
390
  }
391
- function te(t) {
391
+ function ne(t) {
392
392
  var e = A, n = t.__c;
393
393
  typeof n == "function" && (t.__c = void 0, n()), A = e;
394
394
  }
395
- function _e(t) {
395
+ function ve(t) {
396
396
  var e = A;
397
397
  t.__c = t.__(), A = e;
398
398
  }
399
- function Qe(t, e) {
399
+ function tt(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 et(t, e) {
404
+ function nt(t, e) {
405
405
  return typeof e == "function" ? e(t) : e;
406
406
  }
407
- const Ct = (t) => ({
407
+ const yt = (t) => ({
408
408
  saveGameData(e) {
409
409
  try {
410
410
  localStorage.setItem(t, JSON.stringify(e));
@@ -427,14 +427,14 @@ const Ct = (t) => ({
427
427
  console.error("Failed to reset maze game data:", e);
428
428
  }
429
429
  }
430
- }), tt = ht(void 0), Ie = {
430
+ }), ot = _t(void 0), De = {
431
431
  currentLevel: 1,
432
432
  highestUnlockedLevel: 1,
433
433
  currentTier: 1,
434
434
  highestUnlockedTier: 1,
435
435
  levelScores: {},
436
436
  totalScore: 0
437
- }, xe = {
437
+ }, Fe = {
438
438
  isGameActive: !0,
439
439
  levelTransitioning: !1,
440
440
  maze: null,
@@ -447,8 +447,8 @@ const Ct = (t) => ({
447
447
  showClue: !1,
448
448
  playerPath: [],
449
449
  visitCounts: {}
450
- }, wt = ({ children: t, config: e }) => {
451
- const n = Ct(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = j(() => o || { ...Ie });
450
+ }, bt = ({ children: t, config: e }) => {
451
+ const n = yt(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = j(() => o || { ...De });
452
452
  x(() => {
453
453
  const u = Object.values(i.levelScores).reduce(
454
454
  (h, f) => h + f,
@@ -468,38 +468,38 @@ const Ct = (t) => ({
468
468
  i.levelScores,
469
469
  i.totalScore
470
470
  ]);
471
- const [l, r] = j({
472
- ...xe
473
- }), a = O(l);
471
+ const [c, r] = j({
472
+ ...Fe
473
+ }), l = F(c);
474
474
  x(() => {
475
- a.current = l;
476
- }, [l]);
477
- const c = q(() => [
478
- l.playerAtExit ? 1 : 0,
479
- l.foodCollected === l.totalFoodCount ? 1 : 0,
480
- l.showClue ? 0 : 1
475
+ l.current = c;
476
+ }, [c]);
477
+ const a = q(() => [
478
+ c.playerAtExit ? 1 : 0,
479
+ c.foodCollected === c.totalFoodCount ? 1 : 0,
480
+ c.showClue ? 0 : 1
481
481
  ], [
482
- l.playerAtExit,
483
- l.foodCollected,
484
- l.totalFoodCount,
485
- l.showClue
482
+ c.playerAtExit,
483
+ c.foodCollected,
484
+ c.totalFoodCount,
485
+ c.showClue
486
486
  ]), d = () => {
487
487
  n.resetGameData(), s({
488
- ...Ie
488
+ ...De
489
489
  }), r({
490
- ...xe
490
+ ...Fe
491
491
  });
492
492
  };
493
- return /* @__PURE__ */ C(
494
- tt.Provider,
493
+ return /* @__PURE__ */ p(
494
+ ot.Provider,
495
495
  {
496
496
  value: {
497
497
  gameProgress: i,
498
498
  setGameProgress: s,
499
- gamePlayState: l,
499
+ gamePlayState: c,
500
500
  setGamePlayState: r,
501
- gamePlayStateRef: a,
502
- currentScore: c,
501
+ gamePlayStateRef: l,
502
+ currentScore: a,
503
503
  config: e,
504
504
  resetGame: d
505
505
  },
@@ -507,75 +507,75 @@ const Ct = (t) => ({
507
507
  }
508
508
  );
509
509
  }, B = () => {
510
- const t = vt(tt);
510
+ const t = gt(ot);
511
511
  if (!t)
512
512
  throw new Error("useGameContext must be used within a GameProvider");
513
513
  return t;
514
- }, X = (t) => q(() => {
515
- const e = t.map((r) => r.length), n = e.reduce((r, a) => r + a, 0), o = t.length, i = (r) => {
514
+ }, J = (t) => q(() => {
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
- let a = 0;
518
- for (let c = 0; c < e.length; c++)
519
- if (a += e[c], r <= a) return c + 1;
517
+ let l = 0;
518
+ for (let a = 0; a < e.length; a++)
519
+ if (l += e[a], r <= l) return a + 1;
520
520
  return 0;
521
- }, s = (r) => r < 1 || r > o ? 0 : e.slice(0, r - 1).reduce((a, c) => a + c, 0) + 1, l = {
521
+ }, s = (r) => r < 1 || r > o ? 0 : e.slice(0, r - 1).reduce((l, a) => l + a, 0) + 1, c = {
522
522
  getTotalLevels: () => n,
523
523
  getTotalTiers: () => o,
524
524
  getTierLevelsRange: (r) => {
525
525
  if (r < 1 || r > o) return [0, 0];
526
- const a = s(r), c = a + e[r - 1] - 1;
527
- return [a, c];
526
+ const l = s(r), a = l + e[r - 1] - 1;
527
+ return [l, a];
528
528
  },
529
529
  getTierByLevel: i,
530
530
  getFirstLevelOfTier: s,
531
531
  getLevelConfig: (r) => {
532
532
  if (r < 1 || r > n) return null;
533
- const a = i(r), c = s(a), d = r - c;
534
- return t[a - 1][d];
533
+ const l = i(r), a = s(l), d = r - a;
534
+ return t[l - 1][d];
535
535
  },
536
536
  getTierConfig: (r) => r < 1 || r > o ? null : t[r - 1],
537
- isLevelUnlocked: (r, a) => r <= a,
538
- isTierUnlocked: (r, a) => r <= a,
537
+ isLevelUnlocked: (r, l) => r <= l,
538
+ isTierUnlocked: (r, l) => r <= l,
539
539
  getNextLevelInfo: (r) => {
540
540
  if (r >= n) return null;
541
- const a = r + 1, c = i(r), d = i(a);
541
+ const l = r + 1, a = i(r), d = i(l);
542
542
  return {
543
- nextLevel: a,
543
+ nextLevel: l,
544
544
  nextTier: d,
545
- isTierChange: d > c
545
+ isTierChange: d > a
546
546
  };
547
547
  },
548
- getCurrentTierProgress: (r, a) => {
549
- const [c, d] = l.getTierLevelsRange(a), u = r - c + 1, h = d - c + 1;
548
+ getCurrentTierProgress: (r, l) => {
549
+ const [a, d] = c.getTierLevelsRange(l), u = r - a + 1, h = d - a + 1;
550
550
  return { current: u, total: h };
551
551
  },
552
552
  isLastLevelInTier: (r) => {
553
- const a = i(r), [, c] = l.getTierLevelsRange(a);
554
- return r === c;
553
+ const l = i(r), [, a] = c.getTierLevelsRange(l);
554
+ return r === a;
555
555
  },
556
556
  getPreviousLevelInfo: (r) => {
557
557
  if (r <= 1) return null;
558
- const a = r - 1, c = i(r), d = i(a);
558
+ const l = r - 1, a = i(r), d = i(l);
559
559
  return {
560
- prevLevel: a,
560
+ prevLevel: l,
561
561
  prevTier: d,
562
- isTierChange: d < c
562
+ isTierChange: d < a
563
563
  };
564
564
  }
565
565
  };
566
- return l;
567
- }, [t]), yt = ({ onTierChange: t, disabled: e }) => {
568
- const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier: l, highestUnlockedTier: r } = n, c = X(s).getTotalTiers();
569
- return /* @__PURE__ */ C("div", { className: "tier-selector", children: /* @__PURE__ */ C(
566
+ return c;
567
+ }, [t]), kt = ({ onTierChange: t, disabled: e }) => {
568
+ const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier: c, highestUnlockedTier: r } = n, a = J(s).getTotalTiers();
569
+ return /* @__PURE__ */ p("div", { className: "tier-selector", children: /* @__PURE__ */ p(
570
570
  "select",
571
571
  {
572
- value: l,
572
+ value: c,
573
573
  onChange: (d) => {
574
574
  d.target && d.target.value && t(Number(d.target.value));
575
575
  },
576
576
  disabled: e,
577
577
  className: "tier-dropdown",
578
- children: Array.from({ length: c }, (d, u) => u + 1).map((d) => /* @__PURE__ */ C(
578
+ children: Array.from({ length: a }, (d, u) => u + 1).map((d) => /* @__PURE__ */ p(
579
579
  "option",
580
580
  {
581
581
  value: d,
@@ -586,51 +586,51 @@ const Ct = (t) => ({
586
586
  ))
587
587
  }
588
588
  ) });
589
- }, bt = ({ onLevelChange: t, disabled: e }) => {
590
- const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier: l, levelScores: r, currentLevel: a, highestUnlockedLevel: c } = n, d = X(s), u = q(() => {
591
- const [h, f] = d.getTierLevelsRange(l);
592
- return Array.from({ length: f - h + 1 }, (m, g) => {
593
- const _ = h + g, p = r[_] || 0;
589
+ }, Tt = ({ onLevelChange: t, disabled: e }) => {
590
+ const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier: c, levelScores: r, currentLevel: l, highestUnlockedLevel: a } = n, d = J(s), u = q(() => {
591
+ const [h, f] = d.getTierLevelsRange(c);
592
+ return Array.from({ length: f - h + 1 }, (w, g) => {
593
+ const _ = h + g, v = r[_] || 0;
594
594
  return {
595
595
  level: _,
596
- score: p
596
+ score: v
597
597
  };
598
598
  });
599
- }, [l, r]);
600
- return /* @__PURE__ */ C("div", { className: "level-selector", children: /* @__PURE__ */ C(
599
+ }, [c, r]);
600
+ return /* @__PURE__ */ p("div", { className: "level-selector", children: /* @__PURE__ */ p(
601
601
  "select",
602
602
  {
603
- value: a,
603
+ value: l,
604
604
  onChange: (h) => {
605
605
  h.target && h.target.value && t(Number(h.target.value));
606
606
  },
607
607
  disabled: e,
608
608
  className: "level-dropdown",
609
- children: u.map(({ level: h, score: f }) => /* @__PURE__ */ C(
609
+ children: u.map(({ level: h, score: f }) => /* @__PURE__ */ p(
610
610
  "option",
611
611
  {
612
612
  value: h,
613
- disabled: h > c,
613
+ disabled: h > a,
614
614
  children: `${i.level} ${h} ${"★".repeat(f)}`
615
615
  },
616
616
  `level-${h}`
617
617
  ))
618
618
  }
619
619
  ) });
620
- }, ne = ({
620
+ }, oe = ({
621
621
  isOpen: t,
622
622
  title: e,
623
623
  className: n = "",
624
624
  message: o,
625
625
  children: i,
626
626
  noConfirm: s = !1,
627
- noCancel: l = !1,
627
+ noCancel: c = !1,
628
628
  confirmText: r = "OK",
629
- cancelText: a = "Cancel",
630
- onConfirm: c,
629
+ cancelText: l = "Cancel",
630
+ onConfirm: a,
631
631
  onCancel: d
632
632
  }) => {
633
- const u = O(null);
633
+ const u = F(null);
634
634
  return x(() => {
635
635
  const h = (f) => {
636
636
  f.key === "Escape" && d?.();
@@ -638,29 +638,29 @@ const Ct = (t) => ({
638
638
  return t && document.addEventListener("keydown", h), () => {
639
639
  document.removeEventListener("keydown", h);
640
640
  };
641
- }, [t, d]), /* @__PURE__ */ C(
641
+ }, [t, d]), /* @__PURE__ */ p(
642
642
  "div",
643
643
  {
644
644
  className: `maze-dialog-overlay ${t ? "maze-dialog-visible" : ""}`,
645
- children: /* @__PURE__ */ C("div", { className: "maze-dialog " + n, ref: u, children: [
646
- /* @__PURE__ */ C("div", { className: "maze-dialog-title", children: e }),
647
- /* @__PURE__ */ C("div", { className: "maze-dialog-content", children: i || /* @__PURE__ */ C("div", { className: "maze-dialog-message", children: o }) }),
648
- (!l || !s) && /* @__PURE__ */ C("div", { className: "maze-dialog-buttons", children: [
649
- !l && /* @__PURE__ */ C(
645
+ children: /* @__PURE__ */ p("div", { className: "maze-dialog " + n, ref: u, children: [
646
+ /* @__PURE__ */ p("div", { className: "maze-dialog-title", children: e }),
647
+ /* @__PURE__ */ p("div", { className: "maze-dialog-content", children: i || /* @__PURE__ */ p("div", { className: "maze-dialog-message", children: o }) }),
648
+ (!c || !s) && /* @__PURE__ */ p("div", { className: "maze-dialog-buttons", children: [
649
+ !c && /* @__PURE__ */ p(
650
650
  "button",
651
651
  {
652
652
  type: "button",
653
653
  className: "maze-dialog-cancel",
654
654
  onClick: d,
655
- children: a
655
+ children: l
656
656
  }
657
657
  ),
658
- !s && /* @__PURE__ */ C(
658
+ !s && /* @__PURE__ */ p(
659
659
  "button",
660
660
  {
661
661
  type: "button",
662
662
  className: "maze-dialog-confirm",
663
- onClick: c,
663
+ onClick: a,
664
664
  children: r
665
665
  }
666
666
  )
@@ -698,7 +698,7 @@ const Ct = (t) => ({
698
698
  for (; this.container.firstChild; )
699
699
  this.container.removeChild(this.container.firstChild);
700
700
  }
701
- }, kt = () => {
701
+ }, St = () => {
702
702
  const {
703
703
  gameProgress: t,
704
704
  setGameProgress: e,
@@ -706,82 +706,82 @@ const Ct = (t) => ({
706
706
  setGamePlayState: o,
707
707
  gamePlayStateRef: i,
708
708
  resetGame: s,
709
- config: l
710
- } = B(), { i18n: r, levelConfig: a } = l, c = X(a), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, m = c.getTotalLevels(), [g, _] = j(!1), [p, v] = j(!1), [y, w] = j(!1), b = (D) => {
711
- const U = c.getFirstLevelOfTier(D);
712
- c.isLevelUnlocked(U, h) && (e((K) => ({ ...K, currentTier: D })), k(U));
713
- }, k = (D) => {
714
- c.isLevelUnlocked(D, h) && (e((U) => ({ ...U, currentLevel: D })), R.show(
715
- r.levelGoToast.replace("%LEVEL%", D.toString()),
709
+ config: c
710
+ } = B(), { i18n: r, levelConfig: l } = c, a = J(l), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, w = a.getTotalLevels(), [g, _] = j(!1), [v, m] = j(!1), [y, C] = j(!1), k = (O) => {
711
+ const Y = a.getFirstLevelOfTier(O);
712
+ a.isLevelUnlocked(Y, h) && (e((W) => ({ ...W, currentTier: O })), T(Y));
713
+ }, T = (O) => {
714
+ a.isLevelUnlocked(O, h) && (e((Y) => ({ ...Y, currentLevel: O })), R.show(
715
+ r.levelGoToast.replace("%LEVEL%", O.toString()),
716
716
  "success"
717
717
  ));
718
- }, T = () => {
719
- _(!0);
720
718
  }, z = () => {
719
+ _(!0);
720
+ }, S = () => {
721
721
  _(!1);
722
- }, L = () => {
723
- w(!0);
722
+ }, b = () => {
723
+ C(!0);
724
724
  }, E = () => {
725
- w(!1);
725
+ C(!1);
726
726
  }, N = () => {
727
727
  R.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
728
728
  ...i.current,
729
729
  // need to sync with ref
730
730
  showClue: !i.current.showClue
731
- })), w(!1);
731
+ })), C(!1);
732
732
  }, P = () => {
733
- v(!0);
733
+ m(!0);
734
734
  }, I = () => {
735
- s(), v(!1), R.show(r.resetDoneToast);
736
- }, ye = () => {
737
- v(!1);
735
+ s(), m(!1), R.show(r.resetDoneToast);
736
+ }, V = () => {
737
+ m(!1);
738
738
  };
739
- return /* @__PURE__ */ C("div", { class: "game-panel-container", children: [
740
- /* @__PURE__ */ C("div", { className: "game-controls", children: [
741
- /* @__PURE__ */ C("div", { className: "selectors-container", children: [
742
- /* @__PURE__ */ C(
743
- yt,
739
+ return /* @__PURE__ */ p("div", { class: "game-panel-container", children: [
740
+ /* @__PURE__ */ p("div", { className: "game-controls", children: [
741
+ /* @__PURE__ */ p("div", { className: "selectors-container", children: [
742
+ /* @__PURE__ */ p(
743
+ kt,
744
744
  {
745
- onTierChange: b,
745
+ onTierChange: k,
746
746
  disabled: d
747
747
  }
748
748
  ),
749
- /* @__PURE__ */ C(
750
- bt,
749
+ /* @__PURE__ */ p(
750
+ Tt,
751
751
  {
752
- onLevelChange: k,
752
+ onLevelChange: T,
753
753
  disabled: d
754
754
  }
755
755
  )
756
756
  ] }),
757
- /* @__PURE__ */ C(
757
+ /* @__PURE__ */ p(
758
758
  "button",
759
759
  {
760
760
  className: `settings-clue-button ${u ? "clue-on" : "clue-off"}`,
761
761
  disabled: u,
762
762
  title: "Toggle Clue",
763
- onClick: L,
763
+ onClick: b,
764
764
  children: u ? r.clueOn : r.clueOff
765
765
  }
766
766
  )
767
767
  ] }),
768
- /* @__PURE__ */ C("div", { className: "game-settings", children: /* @__PURE__ */ C("span", { className: "game-settings-icon", onClick: T, children: "★ " + f }) }),
769
- /* @__PURE__ */ C(
770
- ne,
768
+ /* @__PURE__ */ p("div", { className: "game-settings", children: /* @__PURE__ */ p("span", { className: "game-settings-icon", onClick: z, children: "★ " + f }) }),
769
+ /* @__PURE__ */ p(
770
+ oe,
771
771
  {
772
772
  isOpen: g,
773
773
  title: r.settings,
774
774
  noConfirm: !0,
775
775
  cancelText: r.close,
776
- onCancel: z,
776
+ onCancel: S,
777
777
  children: [
778
- /* @__PURE__ */ C("div", { className: "settings-stats", children: [
779
- /* @__PURE__ */ C("div", { children: r.levelComplete + `: ${h}/${m}` }),
780
- /* @__PURE__ */ C("div", { children: r.starsCollected + ": " + f }),
781
- /* @__PURE__ */ C("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
778
+ /* @__PURE__ */ p("div", { className: "settings-stats", children: [
779
+ /* @__PURE__ */ p("div", { children: r.levelComplete + `: ${h}/${w}` }),
780
+ /* @__PURE__ */ p("div", { children: r.starsCollected + ": " + f }),
781
+ /* @__PURE__ */ p("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
782
782
  ] }),
783
- /* @__PURE__ */ C("div", { className: "settings-item-box", children: [
784
- /* @__PURE__ */ C(
783
+ /* @__PURE__ */ p("div", { className: "settings-item-box", children: [
784
+ /* @__PURE__ */ p(
785
785
  "button",
786
786
  {
787
787
  className: "settings-reset-button",
@@ -790,25 +790,25 @@ const Ct = (t) => ({
790
790
  children: r.reset
791
791
  }
792
792
  ),
793
- /* @__PURE__ */ C("div", { className: "settings-item-tip", children: r.resetTip })
793
+ /* @__PURE__ */ p("div", { className: "settings-item-tip", children: r.resetTip })
794
794
  ] })
795
795
  ]
796
796
  }
797
797
  ),
798
- /* @__PURE__ */ C(
799
- ne,
798
+ /* @__PURE__ */ p(
799
+ oe,
800
800
  {
801
- isOpen: p,
801
+ isOpen: v,
802
802
  title: r.confirmReset,
803
803
  message: r.confirmResetMessage,
804
804
  confirmText: r.reset,
805
805
  cancelText: r.cancel,
806
806
  onConfirm: I,
807
- onCancel: ye
807
+ onCancel: V
808
808
  }
809
809
  ),
810
- /* @__PURE__ */ C(
811
- ne,
810
+ /* @__PURE__ */ p(
811
+ oe,
812
812
  {
813
813
  isOpen: y,
814
814
  title: r.confirmClue,
@@ -821,102 +821,102 @@ const Ct = (t) => ({
821
821
  )
822
822
  ] });
823
823
  };
824
- function Ce(t, e) {
824
+ function ye(t, e) {
825
825
  if (!(t instanceof e))
826
826
  throw new TypeError("Cannot call a class as a function");
827
827
  }
828
- function Tt(t, e) {
828
+ function zt(t, e) {
829
829
  for (var n = 0; n < e.length; n++) {
830
830
  var o = e[n];
831
831
  o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o);
832
832
  }
833
833
  }
834
- function we(t, e, n) {
835
- return e && Tt(t.prototype, e), t;
834
+ function be(t, e, n) {
835
+ return e && zt(t.prototype, e), t;
836
836
  }
837
- function De(t) {
837
+ function Re(t) {
838
838
  return +t.replace(/px/, "");
839
839
  }
840
840
  function Lt(t) {
841
- var e = window.devicePixelRatio, n = getComputedStyle(t), o = De(n.getPropertyValue("width")), i = De(n.getPropertyValue("height"));
841
+ var e = window.devicePixelRatio, n = getComputedStyle(t), o = Re(n.getPropertyValue("width")), i = Re(n.getPropertyValue("height"));
842
842
  t.setAttribute("width", (o * e).toString()), t.setAttribute("height", (i * e).toString());
843
843
  }
844
- function F(t, e) {
844
+ function D(t, e) {
845
845
  var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (e - t) + t;
846
846
  return Math.floor(o * Math.pow(10, n)) / Math.pow(10, n);
847
847
  }
848
- function Fe(t) {
849
- return t[F(0, t.length)];
850
- }
851
- var St = 125e-5, zt = 5e-4, Nt = 9e-4, At = 1e-5, Et = 6, Mt = 80, Pt = 0.9, It = 1.7, xt = 0.2, Dt = 0.6, Ft = 0.03, Ot = 0.07, Rt = 15, $t = 82, Ut = 100, Wt = 250, jt = 40, Gt = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
852
848
  function Oe(t) {
849
+ return t[D(0, t.length)];
850
+ }
851
+ var Nt = 125e-5, At = 5e-4, Et = 9e-4, Mt = 1e-5, Pt = 6, It = 80, xt = 0.9, Dt = 1.7, Ft = 0.2, Rt = 0.6, Ot = 0.03, $t = 0.07, Ut = 15, Wt = 82, jt = 100, Gt = 250, Ht = 40, qt = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
852
+ function $e(t) {
853
853
  var e = 1920;
854
854
  return Math.log(t) / Math.log(e);
855
855
  }
856
- var Re = /* @__PURE__ */ function() {
856
+ var Ue = /* @__PURE__ */ function() {
857
857
  function t(e) {
858
- Ce(this, t);
859
- var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors, l = e.emojis, r = e.emojiSize, a = e.canvasWidth, c = F(Pt, It, 3), d = c * Oe(a);
858
+ ye(this, t);
859
+ var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors, c = e.emojis, r = e.emojiSize, l = e.canvasWidth, a = D(xt, Dt, 3), d = a * $e(l);
860
860
  this.confettiSpeed = {
861
861
  x: d,
862
862
  y: d
863
- }, this.finalConfettiSpeedX = F(xt, Dt, 3), this.rotationSpeed = l.length ? 0.01 : F(Ft, Ot, 3) * Oe(a), this.dragForceCoefficient = F(zt, Nt, 6), this.radius = {
863
+ }, this.finalConfettiSpeedX = D(Ft, Rt, 3), this.rotationSpeed = c.length ? 0.01 : D(Ot, $t, 3) * $e(l), this.dragForceCoefficient = D(At, Et, 6), this.radius = {
864
864
  x: i,
865
865
  y: i
866
- }, this.initialRadius = i, this.rotationAngle = o === "left" ? F(0, 0.2, 3) : F(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = F(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
867
- var u = o === "left" ? F($t, Rt) * Math.PI / 180 : F(-15, -82) * Math.PI / 180;
866
+ }, this.initialRadius = i, this.rotationAngle = o === "left" ? D(0, 0.2, 3) : D(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = D(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
867
+ var u = o === "left" ? D(Wt, Ut) * Math.PI / 180 : D(-15, -82) * Math.PI / 180;
868
868
  this.absCos = Math.abs(Math.cos(u)), this.absSin = Math.abs(Math.sin(u));
869
- var h = F(-150, 0), f = {
869
+ var h = D(-150, 0), f = {
870
870
  x: n.x + (o === "left" ? -h : h) * this.absCos,
871
871
  y: n.y - h * this.absSin
872
872
  };
873
- this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = l.length ? null : Fe(s), this.emoji = l.length ? Fe(l) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
873
+ this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = c.length ? null : Oe(s), this.emoji = c.length ? Oe(c) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
874
874
  }
875
- return we(t, [{
875
+ return be(t, [{
876
876
  key: "draw",
877
877
  value: function(n) {
878
- var o = this.currentPosition, i = this.radius, s = this.color, l = this.emoji, r = this.rotationAngle, a = this.emojiRotationAngle, c = this.emojiSize, d = window.devicePixelRatio;
879
- s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) : l && (n.font = "".concat(c, "px serif"), n.save(), n.translate(d * o.x, d * o.y), n.rotate(a), n.textAlign = "center", n.fillText(l, 0, 0), n.restore());
878
+ var o = this.currentPosition, i = this.radius, s = this.color, c = this.emoji, r = this.rotationAngle, l = this.emojiRotationAngle, a = this.emojiSize, d = window.devicePixelRatio;
879
+ s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) : c && (n.font = "".concat(a, "px serif"), n.save(), n.translate(d * o.x, d * o.y), n.rotate(l), n.textAlign = "center", n.fillText(c, 0, 0), n.restore());
880
880
  }
881
881
  }, {
882
882
  key: "updatePosition",
883
883
  value: function(n, o) {
884
- var i = this.confettiSpeed, s = this.dragForceCoefficient, l = this.finalConfettiSpeedX, r = this.radiusYUpdateDirection, a = this.rotationSpeed, c = this.createdAt, d = this.direction, u = o - c;
885
- if (i.x > l && (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 + St * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : At * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
884
+ var i = this.confettiSpeed, s = this.dragForceCoefficient, c = this.finalConfettiSpeedX, r = this.radiusYUpdateDirection, l = this.rotationSpeed, a = this.createdAt, d = this.direction, u = o - a;
885
+ if (i.x > c && (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 + Nt * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : Mt * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
886
886
  this.emojiRotationAngle += this.rotationSpeed * n % (2 * Math.PI);
887
887
  return;
888
888
  }
889
- r === "down" ? (this.radius.y -= n * a, this.radius.y <= 0 && (this.radius.y = 0, this.radiusYUpdateDirection = "up")) : (this.radius.y += n * a, this.radius.y >= this.initialRadius && (this.radius.y = this.initialRadius, this.radiusYUpdateDirection = "down"));
889
+ r === "down" ? (this.radius.y -= n * l, this.radius.y <= 0 && (this.radius.y = 0, this.radiusYUpdateDirection = "up")) : (this.radius.y += n * l, this.radius.y >= this.initialRadius && (this.radius.y = this.initialRadius, this.radiusYUpdateDirection = "down"));
890
890
  }
891
891
  }, {
892
892
  key: "getIsVisibleOnCanvas",
893
893
  value: function(n) {
894
- return this.currentPosition.y < n + Ut;
894
+ return this.currentPosition.y < n + jt;
895
895
  }
896
896
  }]), t;
897
897
  }();
898
- function Ht() {
898
+ function Bt() {
899
899
  var t = document.createElement("canvas");
900
900
  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;
901
901
  }
902
- function qt(t) {
903
- var e = t.confettiRadius, n = e === void 0 ? Et : e, o = t.confettiNumber, i = o === void 0 ? t.confettiesNumber || (t.emojis ? jt : Wt) : o, s = t.confettiColors, l = s === void 0 ? Gt : s, r = t.emojis, a = r === void 0 ? t.emojies || [] : r, c = t.emojiSize, d = c === void 0 ? Mt : c;
902
+ function Vt(t) {
903
+ var e = t.confettiRadius, n = e === void 0 ? Pt : e, o = t.confettiNumber, i = o === void 0 ? t.confettiesNumber || (t.emojis ? Ht : Gt) : o, s = t.confettiColors, c = s === void 0 ? qt : s, r = t.emojis, l = r === void 0 ? t.emojies || [] : r, a = t.emojiSize, d = a === void 0 ? It : a;
904
904
  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"), {
905
905
  confettiRadius: n,
906
906
  confettiNumber: i,
907
- confettiColors: l,
908
- emojis: a,
907
+ confettiColors: c,
908
+ emojis: l,
909
909
  emojiSize: d
910
910
  };
911
911
  }
912
- var Bt = /* @__PURE__ */ function() {
912
+ var Yt = /* @__PURE__ */ function() {
913
913
  function t(e) {
914
914
  var n = this;
915
- Ce(this, t), this.canvasContext = e, this.shapes = [], this.promise = new Promise(function(o) {
915
+ ye(this, t), this.canvasContext = e, this.shapes = [], this.promise = new Promise(function(o) {
916
916
  return n.resolvePromise = o;
917
917
  });
918
918
  }
919
- return we(t, [{
919
+ return be(t, [{
920
920
  key: "getBatchCompletePromise",
921
921
  value: function() {
922
922
  return this.promise;
@@ -936,27 +936,27 @@ var Bt = /* @__PURE__ */ function() {
936
936
  }, {
937
937
  key: "processShapes",
938
938
  value: function(n, o, i) {
939
- var s = this, l = n.timeDelta, r = n.currentTime;
940
- this.shapes = this.shapes.filter(function(a) {
941
- return a.updatePosition(l, r), a.draw(s.canvasContext), i ? a.getIsVisibleOnCanvas(o) : !0;
939
+ var s = this, c = n.timeDelta, r = n.currentTime;
940
+ this.shapes = this.shapes.filter(function(l) {
941
+ return l.updatePosition(c, r), l.draw(s.canvasContext), i ? l.getIsVisibleOnCanvas(o) : !0;
942
942
  });
943
943
  }
944
944
  }]), t;
945
- }(), Vt = /* @__PURE__ */ function() {
945
+ }(), Xt = /* @__PURE__ */ function() {
946
946
  function t() {
947
947
  var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
948
- Ce(this, t), this.activeConfettiBatches = [], this.canvas = e.canvas || Ht(), 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
+ ye(this, t), this.activeConfettiBatches = [], this.canvas = e.canvas || Bt(), 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);
949
949
  }
950
- return we(t, [{
950
+ return be(t, [{
951
951
  key: "loop",
952
952
  value: function() {
953
953
  this.requestAnimationFrameRequested = !1, Lt(this.canvas);
954
954
  var n = (/* @__PURE__ */ new Date()).getTime(), o = n - this.lastUpdated, i = this.canvas.offsetHeight, s = this.iterationIndex % 10 === 0;
955
- this.activeConfettiBatches = this.activeConfettiBatches.filter(function(l) {
956
- return l.processShapes({
955
+ this.activeConfettiBatches = this.activeConfettiBatches.filter(function(c) {
956
+ return c.processShapes({
957
957
  timeDelta: o,
958
958
  currentTime: n
959
- }, i, s), s ? !l.complete() : !0;
959
+ }, i, s), s ? !c.complete() : !0;
960
960
  }), this.iterationIndex++, this.queueAnimationFrameIfNeeded(n);
961
961
  }
962
962
  }, {
@@ -967,33 +967,33 @@ var Bt = /* @__PURE__ */ function() {
967
967
  }, {
968
968
  key: "addConfetti",
969
969
  value: function() {
970
- for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = qt(n), i = o.confettiRadius, s = o.confettiNumber, l = o.confettiColors, r = o.emojis, a = o.emojiSize, c = this.canvas.getBoundingClientRect(), d = c.width, u = c.height, h = u * 5 / 7, f = {
970
+ for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = Vt(n), i = o.confettiRadius, s = o.confettiNumber, c = o.confettiColors, r = o.emojis, l = o.emojiSize, a = this.canvas.getBoundingClientRect(), d = a.width, u = a.height, h = u * 5 / 7, f = {
971
971
  x: 0,
972
972
  y: h
973
- }, m = {
973
+ }, w = {
974
974
  x: d,
975
975
  y: h
976
- }, g = new Bt(this.canvasContext), _ = 0; _ < s / 2; _++) {
977
- var p = new Re({
976
+ }, g = new Yt(this.canvasContext), _ = 0; _ < s / 2; _++) {
977
+ var v = new Ue({
978
978
  initialPosition: f,
979
979
  direction: "right",
980
980
  confettiRadius: i,
981
- confettiColors: l,
981
+ confettiColors: c,
982
982
  confettiNumber: s,
983
983
  emojis: r,
984
- emojiSize: a,
984
+ emojiSize: l,
985
985
  canvasWidth: d
986
- }), v = new Re({
987
- initialPosition: m,
986
+ }), m = new Ue({
987
+ initialPosition: w,
988
988
  direction: "left",
989
989
  confettiRadius: i,
990
- confettiColors: l,
990
+ confettiColors: c,
991
991
  confettiNumber: s,
992
992
  emojis: r,
993
- emojiSize: a,
993
+ emojiSize: l,
994
994
  canvasWidth: d
995
995
  });
996
- g.addShapes(p, v);
996
+ g.addShapes(v, m);
997
997
  }
998
998
  return this.activeConfettiBatches.push(g), this.queueAnimationFrameIfNeeded(), g.getBatchCompletePromise();
999
999
  }
@@ -1009,35 +1009,35 @@ var Bt = /* @__PURE__ */ function() {
1009
1009
  }
1010
1010
  }]), t;
1011
1011
  }();
1012
- const Yt = new Vt(), Xt = ({ onRetry: t }) => {
1012
+ const Kt = new Xt(), Jt = ({ onRetry: t }) => {
1013
1013
  const {
1014
1014
  config: e,
1015
1015
  currentScore: n,
1016
1016
  gamePlayState: o,
1017
1017
  setGamePlayState: i,
1018
1018
  gameProgress: s,
1019
- setGameProgress: l
1020
- } = B(), { i18n: r, levelConfig: a } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: m, levelTransitioning: g } = o, { currentLevel: _ } = s, [p, v] = j(!1);
1019
+ setGameProgress: c
1020
+ } = B(), { i18n: r, levelConfig: l } = e, [a, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: w, levelTransitioning: g } = o, { currentLevel: _ } = s, [v, m] = j(!1);
1021
1021
  x(() => {
1022
- m && g && (Yt.addConfetti(), R.show(r.levelCompleteToast, "success"), v(!0));
1023
- }, [m, g]);
1024
- const y = X(a), w = y.getTotalLevels(), b = q(() => _ >= w, [_, w]), k = () => {
1025
- v(!1), R.show(r.levelRestartToast, "info"), t?.();
1026
- }, T = () => {
1027
- v(!1), i((L) => ({
1028
- ...L,
1022
+ w && g && (Kt.addConfetti(), R.show(r.levelCompleteToast, "success"), m(!0));
1023
+ }, [w, g]);
1024
+ const y = J(l), C = y.getTotalLevels(), k = q(() => _ >= C, [_, C]), T = () => {
1025
+ m(!1), R.show(r.levelRestartToast, "info"), t?.();
1026
+ }, z = () => {
1027
+ m(!1), i((b) => ({
1028
+ ...b,
1029
1029
  isGameActive: !0,
1030
1030
  levelTransitioning: !1
1031
1031
  }));
1032
- }, z = () => {
1033
- v(!1);
1034
- const L = y.getNextLevelInfo(_);
1035
- if (!L) return;
1036
- const { nextLevel: E, nextTier: N, isTierChange: P } = L;
1032
+ }, S = () => {
1033
+ m(!1);
1034
+ const b = y.getNextLevelInfo(_);
1035
+ if (!b) return;
1036
+ const { nextLevel: E, nextTier: N, isTierChange: P } = b;
1037
1037
  P && R.show(
1038
1038
  r.tierUnlockedToast.replace("%TIER%", N.toString()),
1039
1039
  "success"
1040
- ), l((I) => ({
1040
+ ), c((I) => ({
1041
1041
  ...I,
1042
1042
  currentLevel: E,
1043
1043
  currentTier: N,
@@ -1052,31 +1052,31 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
1052
1052
  }
1053
1053
  }));
1054
1054
  };
1055
- return /* @__PURE__ */ C(
1056
- ne,
1055
+ return /* @__PURE__ */ p(
1056
+ oe,
1057
1057
  {
1058
1058
  className: "level-complete-dialog",
1059
- isOpen: p,
1059
+ isOpen: v,
1060
1060
  title: r.congratulations,
1061
1061
  cancelText: r.retry,
1062
- onCancel: k,
1062
+ onCancel: T,
1063
1063
  noConfirm: !!d,
1064
1064
  confirmText: r.continue,
1065
- onConfirm: T,
1065
+ onConfirm: z,
1066
1066
  children: [
1067
- /* @__PURE__ */ C("div", { className: "maze-summary-message", children: [
1068
- !!c && /* @__PURE__ */ C("div", { children: "★ - " + r.findYourExit }),
1069
- /* @__PURE__ */ C("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
1070
- /* @__PURE__ */ C("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
1067
+ /* @__PURE__ */ p("div", { className: "maze-summary-message", children: [
1068
+ !!a && /* @__PURE__ */ p("div", { children: "★ - " + r.findYourExit }),
1069
+ /* @__PURE__ */ p("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
1070
+ /* @__PURE__ */ p("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
1071
1071
  ] }),
1072
- b && /* @__PURE__ */ C("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
1073
- /* @__PURE__ */ C("div", { className: "go-next-level", children: b ? "OK" : /* @__PURE__ */ C("button", { type: "button", onClick: z, children: r.nextLevel }) }),
1074
- !d && /* @__PURE__ */ C("div", { className: "not-all-stars-collected", children: r.continueMessage })
1072
+ k && /* @__PURE__ */ p("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
1073
+ /* @__PURE__ */ p("div", { className: "go-next-level", children: k ? "OK" : /* @__PURE__ */ p("button", { type: "button", onClick: S, children: r.nextLevel }) }),
1074
+ !d && /* @__PURE__ */ p("div", { className: "not-all-stars-collected", children: r.continueMessage })
1075
1075
  ]
1076
1076
  }
1077
1077
  );
1078
- }, Kt = (t, e) => {
1079
- const n = O({
1078
+ }, Zt = (t, e) => {
1079
+ const n = F({
1080
1080
  canvasWidth: 0,
1081
1081
  canvasHeight: 0
1082
1082
  });
@@ -1084,12 +1084,12 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
1084
1084
  const o = () => {
1085
1085
  const s = t.current;
1086
1086
  if (!s) return;
1087
- const l = s.parentElement;
1088
- if (!l) return;
1089
- const r = l.clientWidth, a = window.devicePixelRatio || 1;
1087
+ const c = s.parentElement;
1088
+ if (!c) return;
1089
+ const r = c.clientWidth, l = window.devicePixelRatio || 1;
1090
1090
  s.style.width = `${r}px`, s.style.height = `${r}px`;
1091
- const c = r * a, d = r * a;
1092
- s.width = c, s.height = d, n.current = { canvasWidth: c, canvasHeight: d }, e?.();
1091
+ const a = r * l, d = r * l;
1092
+ s.width = a, s.height = d, n.current = { canvasWidth: a, canvasHeight: d }, e?.();
1093
1093
  };
1094
1094
  o();
1095
1095
  let i = null;
@@ -1097,32 +1097,32 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
1097
1097
  window.removeEventListener("resize", o), i?.disconnect();
1098
1098
  };
1099
1099
  }, [t, e]), n;
1100
- }, Jt = (t) => {
1100
+ }, Qt = (t) => {
1101
1101
  const {
1102
1102
  config: e,
1103
1103
  gamePlayState: { maze: n }
1104
- } = B(), o = O({ cellWidth: 0, cellHeight: 0 });
1104
+ } = B(), o = F({ cellWidth: 0, cellHeight: 0 });
1105
1105
  return x(() => {
1106
1106
  const i = e.renderConfig.padding, s = () => {
1107
1107
  const r = t.current;
1108
1108
  if (!r || !n) return;
1109
- const { rows: a, cols: c } = n;
1110
- if (a <= 0 || c <= 0) return;
1111
- const d = (r.width - i * 2) / c, u = (r.height - i * 2) / a;
1109
+ const { rows: l, cols: a } = n;
1110
+ if (l <= 0 || a <= 0) return;
1111
+ const d = (r.width - i * 2) / a, u = (r.height - i * 2) / l;
1112
1112
  o.current = { cellWidth: d, cellHeight: u };
1113
1113
  };
1114
1114
  s();
1115
- let l = null;
1116
- return t.current && window.ResizeObserver && (l = new ResizeObserver(s), l.observe(t.current)), () => {
1117
- t.current && l?.disconnect();
1115
+ let c = null;
1116
+ return t.current && window.ResizeObserver && (c = new ResizeObserver(s), c.observe(t.current)), () => {
1117
+ t.current && c?.disconnect();
1118
1118
  };
1119
1119
  }, [t, n]), o;
1120
- }, Z = {
1120
+ }, Q = {
1121
1121
  ArrowUp: [-1, 0],
1122
1122
  ArrowDown: [1, 0],
1123
1123
  ArrowLeft: [0, -1],
1124
1124
  ArrowRight: [0, 1]
1125
- }, Zt = ({
1125
+ }, en = ({
1126
1126
  containerRef: t,
1127
1127
  gamePlayStateRef: e,
1128
1128
  setGamePlayState: n,
@@ -1130,45 +1130,49 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
1130
1130
  // move X grid units per frame, default 0.03
1131
1131
  playerRadius: i,
1132
1132
  // player radius in grid unit, default 0.2
1133
- onFoodCollected: s
1133
+ exitWallWidth: s,
1134
+ getCellSizeInPixels: c,
1135
+ onFoodCollected: r
1134
1136
  }) => {
1135
- const l = O(!1), r = O(/* @__PURE__ */ new Set()), a = (m, g) => {
1136
- const _ = e.current;
1137
- if (!_.maze)
1137
+ const l = F(!1), a = F(/* @__PURE__ */ new Set()), d = (_, v) => {
1138
+ const m = e.current;
1139
+ if (!m.maze)
1138
1140
  return { canMove: !1, newCell: null };
1139
- const [p, v] = Z[m];
1140
- if ($e(
1141
- g,
1142
- p,
1141
+ const [y, C] = Q[_];
1142
+ if (We(
1143
1143
  v,
1144
+ y,
1145
+ C,
1144
1146
  i,
1145
1147
  o,
1146
- _.maze
1148
+ m.maze
1147
1149
  ))
1148
1150
  return { canMove: !1, newCell: null };
1149
- const { row: w, col: b } = g, k = w + p * o, T = b + v * o, z = Math.floor(w), L = Math.floor(b), E = Math.floor(k), N = Math.floor(T);
1150
- return E !== z || N !== L ? _.maze.isValid(E, N) ? {
1151
+ const { row: T, col: z } = v, S = T + y * o, b = z + C * o, E = Math.floor(T), N = Math.floor(z), P = Math.floor(S), I = Math.floor(b);
1152
+ return P !== E || I !== N ? m.maze.isValid(P, I) ? {
1151
1153
  canMove: !0,
1152
- newCell: { row: E, col: N }
1154
+ newCell: { row: P, col: I }
1153
1155
  } : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
1154
- }, c = () => {
1155
- const m = e.current, { row: g, col: _ } = m.playerCell, p = i * 2, v = m.foodCells.findIndex((b) => Math.sqrt(
1156
- Math.pow(g - b.row, 2) + Math.pow(_ - b.col, 2)
1157
- ) < p);
1158
- v !== -1 && s && (s(), e.current = {
1156
+ }, u = () => {
1157
+ const _ = e.current, { row: v, col: m } = _.playerCell, y = i * 2, C = _.foodCells.findIndex((z) => Math.sqrt(
1158
+ Math.pow(v - z.row, 2) + Math.pow(m - z.col, 2)
1159
+ ) < y);
1160
+ C !== -1 && r && (r(), e.current = {
1159
1161
  ...e.current,
1160
1162
  foodCollected: e.current.foodCollected + 1,
1161
1163
  foodCells: e.current.foodCells.filter(
1162
- (b, k) => k !== v
1164
+ (z, S) => S !== C
1163
1165
  )
1164
1166
  });
1165
- const w = en(
1166
- m.playerCell,
1167
- m.exitCell,
1168
- m.maze,
1169
- i
1167
+ const T = nn(
1168
+ _.playerCell,
1169
+ _.exitCell,
1170
+ _.maze,
1171
+ i,
1172
+ s,
1173
+ c
1170
1174
  );
1171
- w && !e.current.playerAtExit ? (e.current = {
1175
+ T && !e.current.playerAtExit ? (e.current = {
1172
1176
  ...e.current,
1173
1177
  playerAtExit: !0,
1174
1178
  isGameActive: !1,
@@ -1179,119 +1183,119 @@ const Yt = new Vt(), Xt = ({ onRetry: t }) => {
1179
1183
  n(() => ({ ...e.current }));
1180
1184
  },
1181
1185
  { timeout: 10 }
1182
- )) : !w && e.current.playerAtExit && (e.current = {
1186
+ )) : !T && e.current.playerAtExit && (e.current = {
1183
1187
  ...e.current,
1184
1188
  playerAtExit: !1,
1185
1189
  isGameActive: !0,
1186
1190
  levelTransitioning: !1
1187
1191
  });
1188
- }, d = (m) => {
1189
- const g = e.current, _ = Math.round(m.row), p = Math.round(m.col), v = g.playerPath[g.playerPath.length - 1], y = v.row === _ && v.col === p, w = Math.abs(v.row - _), b = Math.abs(v.col - p);
1190
- if ((w === 1 && b === 0 || w === 0 && b === 1) && !y) {
1191
- const T = `${v.row},${v.col}-${_},${p}`;
1192
+ }, h = (_) => {
1193
+ const v = e.current, m = Math.round(_.row), y = Math.round(_.col), C = v.playerPath[v.playerPath.length - 1], k = C.row === m && C.col === y, T = Math.abs(C.row - m), z = Math.abs(C.col - y);
1194
+ if ((T === 1 && z === 0 || T === 0 && z === 1) && !k) {
1195
+ const b = `${C.row},${C.col}-${m},${y}`;
1192
1196
  e.current = {
1193
1197
  ...e.current,
1194
1198
  playerPath: [
1195
1199
  ...e.current.playerPath,
1196
- { row: _, col: p }
1200
+ { row: m, col: y }
1197
1201
  ],
1198
1202
  visitCounts: {
1199
1203
  ...e.current.visitCounts,
1200
- [T]: (e.current.visitCounts[T] || 0) + 1
1204
+ [b]: (e.current.visitCounts[b] || 0) + 1
1201
1205
  }
1202
1206
  };
1203
1207
  }
1204
- }, u = () => {
1205
- if (l.current || r.current.size === 0) return;
1206
- const m = e.current;
1207
- !m.playerCell || !Array.from(r.current).some(
1208
- (_) => {
1209
- const { canMove: p } = a(
1210
- _,
1211
- m.playerCell
1208
+ }, f = () => {
1209
+ if (l.current || a.current.size === 0) return;
1210
+ const _ = e.current;
1211
+ !_.playerCell || !Array.from(a.current).some(
1212
+ (m) => {
1213
+ const { canMove: y } = d(
1214
+ m,
1215
+ _.playerCell
1212
1216
  );
1213
- return p;
1217
+ return y;
1214
1218
  }
1215
1219
  ) || (l.current = !0);
1216
1220
  };
1217
1221
  x(() => {
1218
- const m = (y) => {
1219
- (y.key === "ArrowUp" || y.key === "ArrowDown" || y.key === "ArrowLeft" || y.key === "ArrowRight" || y.key === " ") && y.preventDefault();
1220
- }, g = (y) => {
1221
- const w = y.key;
1222
- w in Z && (y.preventDefault(), e.current.isGameActive && (r.current.has(w) || (r.current.add(w), l.current || u())));
1223
- }, _ = (y) => {
1224
- const w = y.key;
1225
- w in Z && (y.preventDefault(), r.current.delete(w), r.current.size === 0 && f());
1226
- }, p = (y) => {
1227
- y.preventDefault();
1228
- const w = e.current;
1229
- if (!w.isGameActive || !w.maze || l.current)
1222
+ const _ = (k) => {
1223
+ (k.key === "ArrowUp" || k.key === "ArrowDown" || k.key === "ArrowLeft" || k.key === "ArrowRight" || k.key === " ") && k.preventDefault();
1224
+ }, v = (k) => {
1225
+ const T = k.key;
1226
+ T in Q && (k.preventDefault(), e.current.isGameActive && (a.current.has(T) || (a.current.add(T), l.current || f())));
1227
+ }, m = (k) => {
1228
+ const T = k.key;
1229
+ T in Q && (k.preventDefault(), a.current.delete(T), a.current.size === 0 && g());
1230
+ }, y = (k) => {
1231
+ k.preventDefault();
1232
+ const T = e.current;
1233
+ if (!T.isGameActive || !T.maze || l.current)
1230
1234
  return;
1231
- const b = y.touches[0], k = document.elementFromPoint(b.clientX, b.clientY);
1232
- let T = null;
1233
- k && (k.classList.contains("maze-up") ? T = "ArrowUp" : k.classList.contains("maze-down") ? T = "ArrowDown" : k.classList.contains("maze-left") ? T = "ArrowLeft" : k.classList.contains("maze-right") && (T = "ArrowRight")), T && (r.current.clear(), r.current.add(T), u());
1234
- }, v = () => {
1235
- f();
1235
+ const z = k.touches[0], S = document.elementFromPoint(z.clientX, z.clientY);
1236
+ let b = null;
1237
+ S && (S.classList.contains("maze-up") ? b = "ArrowUp" : S.classList.contains("maze-down") ? b = "ArrowDown" : S.classList.contains("maze-left") ? b = "ArrowLeft" : S.classList.contains("maze-right") && (b = "ArrowRight")), b && (a.current.clear(), a.current.add(b), f());
1238
+ }, C = () => {
1239
+ g();
1236
1240
  };
1237
- return window.addEventListener("keydown", m, {
1241
+ return window.addEventListener("keydown", _, {
1238
1242
  capture: !0
1239
- }), window.addEventListener("keydown", g), window.addEventListener("keyup", _), t.current?.addEventListener("touchstart", p, {
1243
+ }), window.addEventListener("keydown", v), window.addEventListener("keyup", m), t.current?.addEventListener("touchstart", y, {
1240
1244
  passive: !1
1241
- }), t.current?.addEventListener("touchend", v), () => {
1242
- window.removeEventListener("keydown", m, {
1245
+ }), t.current?.addEventListener("touchend", C), () => {
1246
+ window.removeEventListener("keydown", _, {
1243
1247
  capture: !0
1244
- }), window.removeEventListener("keydown", g), window.removeEventListener("keyup", _), t.current?.removeEventListener("touchstart", p), t.current?.removeEventListener("touchend", v);
1248
+ }), window.removeEventListener("keydown", v), window.removeEventListener("keyup", m), t.current?.removeEventListener("touchstart", y), t.current?.removeEventListener("touchend", C);
1245
1249
  };
1246
1250
  }, []);
1247
- const h = mt(() => {
1248
- if (!l.current || r.current.size === 0)
1251
+ const w = pt(() => {
1252
+ if (!l.current || a.current.size === 0)
1249
1253
  return e.current.playerCell;
1250
- const m = e.current.playerCell;
1251
- let g = 0, _ = 0, p = 0;
1252
- for (const D of r.current) {
1253
- const { canMove: U } = a(D, m);
1254
- if (U) {
1255
- const [K, rt] = Z[D];
1256
- g += K, _ += rt, p++;
1254
+ const _ = e.current.playerCell;
1255
+ let v = 0, m = 0, y = 0;
1256
+ for (const W of a.current) {
1257
+ const { canMove: de } = d(W, _);
1258
+ if (de) {
1259
+ const [ke, st] = Q[W];
1260
+ v += ke, m += st, y++;
1257
1261
  }
1258
1262
  }
1259
- if (p === 0)
1263
+ if (y === 0)
1260
1264
  return e.current.playerCell;
1261
- const v = Math.sqrt(g * g + _ * _), y = v > 0 ? g / v : 0, w = v > 0 ? _ / v : 0, b = Number(
1262
- (m.row + y * o).toFixed(2)
1263
- ), k = Number(
1264
- (m.col + w * o).toFixed(2)
1265
- ), T = b - m.row, z = k - m.col, L = Math.sqrt(T * T + z * z);
1266
- if (L > 0) {
1267
- const D = T / L, U = z / L;
1268
- if ($e(
1269
- m,
1270
- D,
1271
- U,
1265
+ const C = Math.sqrt(v * v + m * m), k = C > 0 ? v / C : 0, T = C > 0 ? m / C : 0, z = Number(
1266
+ (_.row + k * o).toFixed(2)
1267
+ ), S = Number(
1268
+ (_.col + T * o).toFixed(2)
1269
+ ), b = z - _.row, E = S - _.col, N = Math.sqrt(b * b + E * E);
1270
+ if (N > 0) {
1271
+ const W = b / N, de = E / N;
1272
+ if (We(
1273
+ _,
1274
+ W,
1275
+ de,
1272
1276
  i,
1273
- L,
1277
+ N,
1274
1278
  e.current.maze
1275
1279
  ))
1276
1280
  return e.current.playerCell;
1277
1281
  }
1278
1282
  e.current.playerCell = {
1279
- row: b,
1280
- col: k
1281
- }, c();
1282
- const E = Math.round(m.row), N = Math.round(m.col), P = Math.round(b), I = Math.round(k);
1283
- return (P !== E || I !== N) && d({ row: P, col: I }), e.current.playerCell;
1284
- }, [o]), f = () => {
1285
- l.current = !1, r.current.clear();
1283
+ row: z,
1284
+ col: S
1285
+ }, u();
1286
+ const P = Math.round(_.row), I = Math.round(_.col), V = Math.round(z), O = Math.round(S);
1287
+ return (V !== P || O !== I) && h({ row: V, col: O }), e.current.playerCell;
1288
+ }, [o]), g = () => {
1289
+ l.current = !1, a.current.clear();
1286
1290
  };
1287
1291
  return {
1288
- updatePlayerPos: h,
1289
- resetMovingState: f
1292
+ updatePlayerPos: w,
1293
+ resetMovingState: g
1290
1294
  };
1291
1295
  };
1292
- function $e(t, e, n, o, i, s) {
1293
- const l = t.row + e * i, r = t.col + n * i, a = { row: l, col: r }, c = [], d = Math.floor(t.row), u = Math.floor(t.col);
1294
- c.push({ row: d, col: u });
1296
+ function We(t, e, n, o, i, s) {
1297
+ const c = t.row + e * i, r = t.col + n * i, l = { row: c, col: r }, a = [], d = Math.floor(t.row), u = Math.floor(t.col);
1298
+ a.push({ row: d, col: u });
1295
1299
  const h = [
1296
1300
  [-1, 0],
1297
1301
  // up
@@ -1310,19 +1314,19 @@ function $e(t, e, n, o, i, s) {
1310
1314
  [1, 1]
1311
1315
  // lower right, diagonal
1312
1316
  ];
1313
- for (const [f, m] of h) {
1314
- const g = d + f, _ = u + m;
1315
- s.isValid(g, _) && c.push({ row: g, col: _ });
1317
+ for (const [f, w] of h) {
1318
+ const g = d + f, _ = u + w;
1319
+ s.isValid(g, _) && a.push({ row: g, col: _ });
1316
1320
  }
1317
- for (const f of c) {
1318
- const m = Qt(f.row, f.col, s);
1319
- for (const g of m)
1320
- if (nt(a, g) < o)
1321
+ for (const f of a) {
1322
+ const w = tn(f.row, f.col, s);
1323
+ for (const g of w)
1324
+ if (rt(l, g) < o)
1321
1325
  return !0;
1322
1326
  }
1323
1327
  return !1;
1324
1328
  }
1325
- function Qt(t, e, n) {
1329
+ function tn(t, e, n) {
1326
1330
  const o = [], i = n.grid[t][e];
1327
1331
  return i.walls.top && o.push({
1328
1332
  start: { row: t - 0.5, col: e - 0.5 },
@@ -1338,155 +1342,158 @@ function Qt(t, e, n) {
1338
1342
  end: { row: t + 0.5, col: e - 0.5 }
1339
1343
  }), o;
1340
1344
  }
1341
- function nt(t, e) {
1342
- const { start: n, end: o } = e, i = o.col - n.col, s = o.row - n.row, l = t.col - n.col, r = t.row - n.row, a = i * i + s * s;
1343
- if (a === 0)
1344
- return Math.sqrt(l * l + r * r);
1345
- const c = Math.max(
1345
+ function rt(t, e) {
1346
+ const { start: n, end: o } = e, i = o.col - n.col, s = o.row - n.row, c = t.col - n.col, r = t.row - n.row, l = i * i + s * s;
1347
+ if (l === 0)
1348
+ return Math.sqrt(c * c + r * r);
1349
+ const a = Math.max(
1346
1350
  0,
1347
1351
  Math.min(
1348
1352
  1,
1349
- (l * i + r * s) / a
1353
+ (c * i + r * s) / l
1350
1354
  )
1351
- ), d = n.col + c * i, u = n.row + c * s, h = t.col - d, f = t.row - u;
1355
+ ), d = n.col + a * i, u = n.row + a * s, h = t.col - d, f = t.row - u;
1352
1356
  return Math.sqrt(h * h + f * f);
1353
1357
  }
1354
- function en(t, e, n, o) {
1358
+ function nn(t, e, n, o, i, s) {
1355
1359
  if (Math.sqrt(
1356
1360
  Math.pow(t.row - e.row, 2) + Math.pow(t.col - e.col, 2)
1357
1361
  ) > 1.5 || !n.isValid(e.row, e.col)) return !1;
1358
1362
  if (n.grid[e.row][e.col].walls.bottom) {
1359
- const l = {
1360
- start: { row: e.row + 0.5, col: e.col - 0.5 },
1361
- end: { row: e.row + 0.5, col: e.col + 0.5 }
1362
- }, r = nt(
1363
+ let l = 0;
1364
+ if (s && i) {
1365
+ const h = s();
1366
+ l = i / h;
1367
+ } else
1368
+ l = (i || 3) / 100;
1369
+ const a = l * 0.5, d = {
1370
+ start: { row: e.row + 0.5 - a, col: e.col - 0.5 },
1371
+ end: { row: e.row + 0.5 - a, col: e.col + 0.5 }
1372
+ };
1373
+ if (rt(
1363
1374
  t,
1364
- l
1365
- ), a = 0.05;
1366
- if (console.log("Distance between player point to exit wall: ", r), console.log(
1367
- "collision condition: playerRadius + COLLISION_TOLERANCE: ",
1368
- o + a
1369
- ), r <= o + a)
1370
- return console.log("collision true: ", o + a), !0;
1375
+ d
1376
+ ) <= o * 1.5)
1377
+ return !0;
1371
1378
  }
1372
1379
  return !1;
1373
1380
  }
1374
- function tn(t, e, n, o, i) {
1381
+ function on(t, e, n, o, i) {
1375
1382
  if (!t || !e.maze) return;
1376
- const { canvasWidth: s, canvasHeight: l } = n, { cellWidth: r, cellHeight: a } = o, {
1377
- maze: c,
1383
+ const { canvasWidth: s, canvasHeight: c } = n, { cellWidth: r, cellHeight: l } = o, {
1384
+ maze: a,
1378
1385
  playerCell: d,
1379
1386
  // row, col, but floating allowed
1380
1387
  exitCell: u,
1381
1388
  foodCells: h,
1382
1389
  showClue: f,
1383
- playerPath: m,
1390
+ playerPath: w,
1384
1391
  visitCounts: g
1385
1392
  } = e, {
1386
1393
  padding: _,
1387
- wallWidth: p,
1394
+ wallWidth: v,
1388
1395
  // need merge with level config when passed here
1389
- wallColor: v,
1396
+ wallColor: m,
1390
1397
  playerColor: y,
1391
- playerRadius: w,
1392
- foodColor: b,
1393
- backgroundColor: k,
1394
- clueColor: T,
1395
- exitColor: z,
1396
- exitWallWidth: L,
1398
+ playerRadius: C,
1399
+ foodColor: k,
1400
+ backgroundColor: T,
1401
+ clueColor: z,
1402
+ exitColor: S,
1403
+ exitWallWidth: b,
1397
1404
  exitDashArray: E
1398
1405
  } = i;
1399
- t.clearRect(0, 0, s, l), t.save(), t.fillStyle = k, t.fillRect(0, 0, s, l), t.restore(), f && an({
1406
+ t.clearRect(0, 0, s, c), t.save(), t.fillStyle = T, t.fillRect(0, 0, s, c), t.restore(), f && un({
1400
1407
  ctx: t,
1401
- playerPath: m,
1408
+ playerPath: w,
1402
1409
  visitCounts: g,
1403
1410
  cellWidth: r,
1404
- cellHeight: a,
1411
+ cellHeight: l,
1405
1412
  padding: _,
1406
- clueColor: T
1407
- }), nn({
1413
+ clueColor: z
1414
+ }), rn({
1408
1415
  ctx: t,
1409
- maze: c,
1416
+ maze: a,
1410
1417
  cellWidth: r,
1411
- cellHeight: a,
1418
+ cellHeight: l,
1412
1419
  padding: _,
1413
- wallColor: v,
1414
- wallWidth: p
1415
- }), rn({
1420
+ wallColor: m,
1421
+ wallWidth: v
1422
+ }), ln({
1416
1423
  ctx: t,
1417
- maze: c,
1424
+ maze: a,
1418
1425
  exitCell: u,
1419
1426
  cellWidth: r,
1420
- cellHeight: a,
1427
+ cellHeight: l,
1421
1428
  padding: _,
1422
- exitColor: z,
1423
- exitWallWidth: L,
1429
+ exitColor: S,
1430
+ exitWallWidth: b,
1424
1431
  exitDashArray: E
1425
- }), sn({
1432
+ }), an({
1426
1433
  ctx: t,
1427
1434
  foodCells: h,
1428
1435
  cellWidth: r,
1429
- cellHeight: a,
1436
+ cellHeight: l,
1430
1437
  padding: _,
1431
- foodColor: b
1432
- }), on({
1438
+ foodColor: k
1439
+ }), sn({
1433
1440
  ctx: t,
1434
1441
  playerCell: d,
1435
- playerRadius: w,
1442
+ playerRadius: C,
1436
1443
  cellWidth: r,
1437
- cellHeight: a,
1444
+ cellHeight: l,
1438
1445
  padding: _,
1439
1446
  playerColor: y
1440
1447
  });
1441
1448
  }
1442
- function nn({
1449
+ function rn({
1443
1450
  ctx: t,
1444
1451
  maze: e,
1445
1452
  cellWidth: n,
1446
1453
  cellHeight: o,
1447
1454
  padding: i,
1448
1455
  wallColor: s,
1449
- wallWidth: l
1456
+ wallWidth: c
1450
1457
  }) {
1451
- t.save(), t.strokeStyle = s, t.lineWidth = l, t.lineCap = "round", t.beginPath(), cn(e, n, o, i).forEach((a) => {
1452
- t.moveTo(a.x1, a.y1), t.lineTo(a.x2, a.y2);
1458
+ t.save(), t.strokeStyle = s, t.lineWidth = c, t.lineCap = "round", t.beginPath(), dn(e, n, o, i).forEach((l) => {
1459
+ t.moveTo(l.x1, l.y1), t.lineTo(l.x2, l.y2);
1453
1460
  }), t.stroke(), t.restore();
1454
1461
  }
1455
- function on({
1462
+ function sn({
1456
1463
  ctx: t,
1457
1464
  playerCell: e,
1458
1465
  playerRadius: n,
1459
1466
  cellWidth: o,
1460
1467
  cellHeight: i,
1461
1468
  padding: s,
1462
- playerColor: l
1469
+ playerColor: c
1463
1470
  }) {
1464
- const { x: r, y: a } = ie(
1471
+ const { x: r, y: l } = se(
1465
1472
  e.row,
1466
1473
  e.col,
1467
1474
  o,
1468
1475
  i,
1469
1476
  s
1470
- ), c = Math.min(o, i) * Math.min(n, 0.5);
1471
- t.save(), t.fillStyle = l, t.beginPath(), t.arc(r, a, c, 0, Math.PI * 2), t.fill(), t.restore();
1477
+ ), a = Math.min(o, i) * Math.min(n, 0.5);
1478
+ t.save(), t.fillStyle = c, t.beginPath(), t.arc(r, l, a, 0, Math.PI * 2), t.fill(), t.restore();
1472
1479
  }
1473
- function rn({
1480
+ function ln({
1474
1481
  ctx: t,
1475
1482
  maze: e,
1476
1483
  exitCell: n,
1477
1484
  cellWidth: o,
1478
1485
  cellHeight: i,
1479
1486
  padding: s,
1480
- exitColor: l,
1487
+ exitColor: c,
1481
1488
  exitWallWidth: r,
1482
- exitDashArray: a = [8, 12]
1489
+ exitDashArray: l = [8, 12]
1483
1490
  }) {
1484
- const { row: c, col: d } = n;
1485
- if (!e.isValid(c, d)) return;
1486
- const u = e.grid[c][d], h = s + d * o, f = s + c * i;
1487
- t.save(), t.globalCompositeOperation = "destination-out", t.lineWidth = r, t.lineCap = "round", t.beginPath(), u.walls.bottom && (t.moveTo(h, f + i), t.lineTo(h + o, f + i)), t.stroke(), t.globalCompositeOperation = "source-over", t.strokeStyle = l, t.lineWidth = r, t.setLineDash(a), t.beginPath(), u.walls.bottom && (t.moveTo(h, f + i), t.lineTo(h + o, f + i)), t.stroke(), t.restore();
1491
+ const { row: a, col: d } = n;
1492
+ if (!e.isValid(a, d)) return;
1493
+ const u = e.grid[a][d], h = s + d * o, f = s + a * i;
1494
+ t.save(), t.globalCompositeOperation = "destination-out", t.lineWidth = r, t.lineCap = "round", t.beginPath(), u.walls.bottom && (t.moveTo(h, f + i), t.lineTo(h + o, f + i)), t.stroke(), t.globalCompositeOperation = "source-over", t.strokeStyle = c, t.lineWidth = r, t.setLineDash(l), t.beginPath(), u.walls.bottom && (t.moveTo(h, f + i), t.lineTo(h + o, f + i)), t.stroke(), t.restore();
1488
1495
  }
1489
- function sn({
1496
+ function an({
1490
1497
  ctx: t,
1491
1498
  foodCells: e,
1492
1499
  cellWidth: n,
@@ -1495,105 +1502,105 @@ function sn({
1495
1502
  foodColor: s
1496
1503
  }) {
1497
1504
  t.fillStyle = s;
1498
- const l = Math.min(n, o) * 0.25;
1505
+ const c = Math.min(n, o) * 0.25;
1499
1506
  e.forEach((r) => {
1500
- const { x: a, y: c } = ie(
1507
+ const { x: l, y: a } = se(
1501
1508
  r.row,
1502
1509
  r.col,
1503
1510
  n,
1504
1511
  o,
1505
1512
  i
1506
1513
  );
1507
- ln(t, a, c, l * 1.2, 5, l * 0.6);
1514
+ cn(t, l, a, c * 1.2, 5, c * 0.6);
1508
1515
  });
1509
1516
  }
1510
- function ln(t, e, n, o, i, s) {
1517
+ function cn(t, e, n, o, i, s) {
1511
1518
  t.save(), t.beginPath();
1512
- for (let l = 0; l < i * 2; l++) {
1513
- const r = l % 2 === 0 ? o : s, a = Math.PI * l / i;
1514
- t.lineTo(e + r * Math.sin(a), n + r * Math.cos(a));
1519
+ for (let c = 0; c < i * 2; c++) {
1520
+ const r = c % 2 === 0 ? o : s, l = Math.PI * c / i;
1521
+ t.lineTo(e + r * Math.sin(l), n + r * Math.cos(l));
1515
1522
  }
1516
1523
  t.closePath(), t.fill(), t.restore();
1517
1524
  }
1518
- function an({
1525
+ function un({
1519
1526
  ctx: t,
1520
1527
  playerPath: e,
1521
1528
  visitCounts: n,
1522
1529
  cellWidth: o,
1523
1530
  cellHeight: i,
1524
1531
  padding: s,
1525
- clueColor: l
1532
+ clueColor: c
1526
1533
  }) {
1527
1534
  if (!(!e || e.length < 2 || !n)) {
1528
1535
  t.save();
1529
1536
  for (let r = 1; r < e.length; r++) {
1530
- const a = e[r - 1], c = e[r], d = `${a.row},${a.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${a.row},${a.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), m = Math.max(3, o * 0.1) + h * 0.5;
1537
+ const l = e[r - 1], a = e[r], d = `${l.row},${l.col}-${a.row},${a.col}`, u = `${a.row},${a.col}-${l.row},${l.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), w = Math.max(3, o * 0.1) + h * 0.5;
1531
1538
  try {
1532
- t.strokeStyle = l.replace(")", `, ${f})`).replace("rgb(", "rgba(");
1539
+ t.strokeStyle = c.replace(")", `, ${f})`).replace("rgb(", "rgba(");
1533
1540
  } catch {
1534
1541
  t.strokeStyle = `rgba(255, 0, 0, ${f})`;
1535
1542
  }
1536
- t.lineWidth = m, t.lineCap = "round", t.lineJoin = "round";
1537
- const { x: g, y: _ } = ie(
1538
- a.row,
1539
- a.col,
1543
+ t.lineWidth = w, t.lineCap = "round", t.lineJoin = "round";
1544
+ const { x: g, y: _ } = se(
1545
+ l.row,
1546
+ l.col,
1540
1547
  o,
1541
1548
  i,
1542
1549
  s
1543
- ), { x: p, y: v } = ie(
1544
- c.row,
1545
- c.col,
1550
+ ), { x: v, y: m } = se(
1551
+ a.row,
1552
+ a.col,
1546
1553
  o,
1547
1554
  i,
1548
1555
  s
1549
1556
  );
1550
- t.beginPath(), t.moveTo(g, _), t.lineTo(p, v), t.stroke();
1557
+ t.beginPath(), t.moveTo(g, _), t.lineTo(v, m), t.stroke();
1551
1558
  }
1552
1559
  t.restore();
1553
1560
  }
1554
1561
  }
1555
- function cn(t, e, n, o) {
1562
+ function dn(t, e, n, o) {
1556
1563
  const i = [];
1557
1564
  for (let s = 0; s < t.rows; s++)
1558
- for (let l = 0; l < t.cols; l++) {
1559
- const r = t.grid[s][l], a = o + l * e, c = o + s * n;
1565
+ for (let c = 0; c < t.cols; c++) {
1566
+ const r = t.grid[s][c], l = o + c * e, a = o + s * n;
1560
1567
  r.walls.top && i.push({
1561
- x1: a,
1562
- y1: c,
1563
- x2: a + e,
1564
- y2: c
1568
+ x1: l,
1569
+ y1: a,
1570
+ x2: l + e,
1571
+ y2: a
1565
1572
  }), r.walls.right && i.push({
1566
- x1: a + e,
1567
- y1: c,
1568
- x2: a + e,
1569
- y2: c + n
1573
+ x1: l + e,
1574
+ y1: a,
1575
+ x2: l + e,
1576
+ y2: a + n
1570
1577
  }), r.walls.bottom && i.push({
1571
- x1: a,
1572
- y1: c + n,
1573
- x2: a + e,
1574
- y2: c + n
1578
+ x1: l,
1579
+ y1: a + n,
1580
+ x2: l + e,
1581
+ y2: a + n
1575
1582
  }), r.walls.left && i.push({
1576
- x1: a,
1577
- y1: c,
1578
- x2: a,
1579
- y2: c + n
1583
+ x1: l,
1584
+ y1: a,
1585
+ x2: l,
1586
+ y2: a + n
1580
1587
  });
1581
1588
  }
1582
1589
  return i;
1583
1590
  }
1584
- function ie(t, e, n, o, i) {
1591
+ function se(t, e, n, o, i) {
1585
1592
  return {
1586
1593
  x: i + e * n + n / 2,
1587
1594
  y: i + t * o + o / 2
1588
1595
  };
1589
1596
  }
1590
- function un(t) {
1597
+ function hn(t) {
1591
1598
  return function() {
1592
1599
  let e = t += 1831565813;
1593
1600
  return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
1594
1601
  };
1595
1602
  }
1596
- class dn {
1603
+ class fn {
1597
1604
  // initially all walls exit
1598
1605
  constructor(e, n) {
1599
1606
  this.row = e, this.col = n;
@@ -1601,7 +1608,7 @@ class dn {
1601
1608
  visited = !1;
1602
1609
  walls = { top: !0, right: !0, bottom: !0, left: !0 };
1603
1610
  }
1604
- class hn {
1611
+ class _n {
1605
1612
  rows;
1606
1613
  cols;
1607
1614
  grid;
@@ -1618,7 +1625,7 @@ class hn {
1618
1625
  * @param exit Optional exit cell position
1619
1626
  */
1620
1627
  constructor(e, n, o, i, s = { row: 0, col: 0 }) {
1621
- this.rows = e, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = un(this.seed), this.grid = this.initializeGrid(), this.generate(o, s);
1628
+ this.rows = e, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = hn(this.seed), this.grid = this.initializeGrid(), this.generate(o, s);
1622
1629
  }
1623
1630
  // Initialize the grid with new MazeCell objects
1624
1631
  initializeGrid() {
@@ -1626,7 +1633,7 @@ class hn {
1626
1633
  for (let n = 0; n < this.rows; n++) {
1627
1634
  e[n] = [];
1628
1635
  for (let o = 0; o < this.cols; o++)
1629
- e[n][o] = new dn(n, o);
1636
+ e[n][o] = new fn(n, o);
1630
1637
  }
1631
1638
  return e;
1632
1639
  }
@@ -1647,8 +1654,8 @@ class hn {
1647
1654
  // Left
1648
1655
  ];
1649
1656
  for (const s of i) {
1650
- const l = e + s.r, r = n + s.c;
1651
- this.isValid(l, r) && o.push({ row: l, col: r });
1657
+ const c = e + s.r, r = n + s.c;
1658
+ this.isValid(c, r) && o.push({ row: c, col: r });
1652
1659
  }
1653
1660
  return o;
1654
1661
  }
@@ -1668,8 +1675,8 @@ class hn {
1668
1675
  }
1669
1676
  // Remove the wall between two adjacent cells
1670
1677
  removeWall(e, n, o, i) {
1671
- const s = this.grid[e][n], l = this.grid[o][i];
1672
- e === o + 1 ? (s.walls.top = !1, l.walls.bottom = !1) : e === o - 1 ? (s.walls.bottom = !1, l.walls.top = !1) : n === i + 1 ? (s.walls.left = !1, l.walls.right = !1) : n === i - 1 && (s.walls.right = !1, l.walls.left = !1);
1678
+ const s = this.grid[e][n], c = this.grid[o][i];
1679
+ e === o + 1 ? (s.walls.top = !1, c.walls.bottom = !1) : e === o - 1 ? (s.walls.bottom = !1, c.walls.top = !1) : n === i + 1 ? (s.walls.left = !1, c.walls.right = !1) : n === i - 1 && (s.walls.right = !1, c.walls.left = !1);
1673
1680
  }
1674
1681
  // --- Generation Methods ---
1675
1682
  /**
@@ -1698,28 +1705,28 @@ class hn {
1698
1705
  let i = { row: n, col: o };
1699
1706
  for (this.grid[n][o].visited = !0, e.push(i); e.length > 0; ) {
1700
1707
  i = e[e.length - 1];
1701
- const { row: s, col: l } = i, r = this.getUnvisitedNeighbors(s, l);
1708
+ const { row: s, col: c } = i, r = this.getUnvisitedNeighbors(s, c);
1702
1709
  if (r.length > 0) {
1703
- const a = this.randomPick(r), { row: c, col: d } = a;
1704
- this.removeWall(s, l, c, d), this.grid[c][d].visited = !0, e.push(a);
1710
+ const l = this.randomPick(r), { row: a, col: d } = l;
1711
+ this.removeWall(s, c, a, d), this.grid[a][d].visited = !0, e.push(l);
1705
1712
  } else
1706
1713
  e.pop();
1707
1714
  }
1708
1715
  }
1709
1716
  // --- Prim's Algorithm Implementation ---
1710
1717
  generateWithPrims() {
1711
- const e = [], n = (s, l) => {
1712
- const r = this.getNeighbors(s, l);
1713
- for (const a of r)
1714
- !this.grid[a.row][a.col].visited && !e.some(
1715
- (c) => c.row === a.row && c.col === a.col
1716
- ) && e.push(a);
1718
+ const e = [], n = (s, c) => {
1719
+ const r = this.getNeighbors(s, c);
1720
+ for (const l of r)
1721
+ !this.grid[l.row][l.col].visited && !e.some(
1722
+ (a) => a.row === l.row && a.col === l.col
1723
+ ) && e.push(l);
1717
1724
  }, o = this.randomNumber(this.rows), i = this.randomNumber(this.cols);
1718
1725
  for (this.grid[o][i].visited = !0, n(o, i); e.length > 0; ) {
1719
- const s = this.randomNumber(e.length), l = e[s], { row: r, col: a } = l, c = this.getVisitedNeighbors(r, a);
1720
- if (c.length > 0) {
1721
- const d = this.randomPick(c);
1722
- this.removeWall(r, a, d.row, d.col), this.grid[r][a].visited = !0, n(r, a);
1726
+ const s = this.randomNumber(e.length), c = e[s], { row: r, col: l } = c, a = this.getVisitedNeighbors(r, l);
1727
+ if (a.length > 0) {
1728
+ const d = this.randomPick(a);
1729
+ this.removeWall(r, l, d.row, d.col), this.grid[r][l].visited = !0, n(r, l);
1723
1730
  }
1724
1731
  e.splice(s, 1);
1725
1732
  }
@@ -1744,64 +1751,64 @@ class hn {
1744
1751
  return e[Math.floor(this.random() * e.length)];
1745
1752
  }
1746
1753
  }
1747
- const fn = (t, e, n) => {
1754
+ const mn = (t, e, n) => {
1748
1755
  if (!t.isValid(e, n)) return !1;
1749
1756
  const o = t.grid[e][n];
1750
1757
  return !o.walls.top || !o.walls.right || !o.walls.bottom || !o.walls.left;
1751
- }, _n = (t) => t === 1 ? 2 : t >= 2 && t <= 5 ? 3 : t >= 6 && t <= 11 ? 4 : t >= 12 && t <= 15 ? 5 : 6, mn = (t, e) => {
1758
+ }, vn = (t) => t === 1 ? 2 : t >= 2 && t <= 5 ? 3 : t >= 6 && t <= 11 ? 4 : t >= 12 && t <= 15 ? 5 : 6, pn = (t, e) => {
1752
1759
  if (!e)
1753
1760
  return console.error(`Cannot find Level ${t}'s config.`), null;
1754
- const { size: n, seed: o, method: i, entry: s, exit: l } = e, r = n, a = n, c = s || { row: 0, col: 0 }, d = l || {
1761
+ const { size: n, seed: o, method: i, entry: s, exit: c } = e, r = n, l = n, a = s || { row: 0, col: 0 }, d = c || {
1755
1762
  row: r - 1,
1756
- col: a - 1
1757
- }, u = new hn(r, a, i, o, s), h = _n(t), f = [];
1758
- for (let m = 0; m < h; m++) {
1763
+ col: l - 1
1764
+ }, u = new _n(r, l, i, o, s), h = vn(t), f = [];
1765
+ for (let w = 0; w < h; w++) {
1759
1766
  let g;
1760
1767
  do
1761
1768
  g = {
1762
1769
  row: Math.floor(u.random() * r),
1763
- col: Math.floor(u.random() * a)
1770
+ col: Math.floor(u.random() * l)
1764
1771
  };
1765
- while (g.row === c.row && g.col === c.col || g.row === d.row && g.col === d.col || !fn(u, g.row, g.col) || f.some((_) => _.row === g.row && _.col === g.col));
1772
+ while (g.row === a.row && g.col === a.col || g.row === d.row && g.col === d.col || !mn(u, g.row, g.col) || f.some((_) => _.row === g.row && _.col === g.col));
1766
1773
  f.push(g);
1767
1774
  }
1768
1775
  return {
1769
1776
  isGameActive: !0,
1770
1777
  levelTransitioning: !1,
1771
1778
  maze: u,
1772
- playerCell: c,
1779
+ playerCell: a,
1773
1780
  exitCell: d,
1774
1781
  foodCells: f,
1775
1782
  playerAtExit: !1,
1776
1783
  foodCollected: 0,
1777
1784
  totalFoodCount: h,
1778
1785
  showClue: !1,
1779
- playerPath: [c],
1780
- visitCounts: { [`${c.row},${c.col}`]: 1 }
1786
+ playerPath: [a],
1787
+ visitCounts: { [`${a.row},${a.col}`]: 1 }
1781
1788
  };
1782
1789
  };
1783
- function vn() {
1784
- const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } = B(), i = O(null), s = O(null), l = O(null), { i18n: r, levelConfig: a, renderConfig: c } = o, d = X(a), u = O(
1790
+ function gn() {
1791
+ const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } = B(), i = F(null), s = F(null), c = F(null), { i18n: r, levelConfig: l, renderConfig: a } = o, d = J(l), u = F(
1785
1792
  d.getLevelConfig(n.currentLevel)
1786
1793
  );
1787
1794
  x(() => {
1788
1795
  i.current && R.attachTo(i.current);
1789
1796
  }, []);
1790
- const h = O(), f = Kt(l, () => {
1797
+ const h = F(), f = Zt(c, () => {
1791
1798
  h.current?.();
1792
- }), m = Jt(l);
1799
+ }), w = Qt(c);
1793
1800
  x(() => {
1794
1801
  u.current = d.getLevelConfig(
1795
1802
  n.currentLevel
1796
1803
  );
1797
1804
  }, [n.currentLevel]);
1798
1805
  const g = () => {
1799
- const y = mn(
1806
+ const y = pn(
1800
1807
  n.currentLevel,
1801
1808
  u.current
1802
1809
  );
1803
- y && t((w) => ({
1804
- ...w,
1810
+ y && t((C) => ({
1811
+ ...C,
1805
1812
  ...y
1806
1813
  }));
1807
1814
  };
@@ -1810,12 +1817,14 @@ function vn() {
1810
1817
  }, [n.currentLevel]);
1811
1818
  const _ = () => {
1812
1819
  g();
1813
- }, { updatePlayerPos: p, resetMovingState: v } = Zt({
1820
+ }, { updatePlayerPos: v, resetMovingState: m } = en({
1814
1821
  containerRef: s,
1815
1822
  gamePlayStateRef: e,
1816
1823
  setGamePlayState: t,
1817
- playerRadius: c.playerRadius,
1818
- moveSpeed: c.gridMoveSpeed,
1824
+ playerRadius: a.playerRadius,
1825
+ moveSpeed: a.gridMoveSpeed,
1826
+ exitWallWidth: u.current?.exitWallWidth || a?.exitWallWidth,
1827
+ getCellSizeInPixels: () => w.current.cellWidth,
1819
1828
  onFoodCollected: () => {
1820
1829
  const y = e.current.totalFoodCount - e.current.foodCollected - 1;
1821
1830
  y > 0 ? R.show(
@@ -1826,22 +1835,22 @@ function vn() {
1826
1835
  }
1827
1836
  });
1828
1837
  return x(() => {
1829
- v();
1830
- }, [n.currentLevel, v]), x(() => {
1831
- let y, w = !document.hidden;
1832
- const b = () => {
1833
- const z = l.current?.getContext("2d"), L = e.current;
1834
- if (!(w && L?.isGameActive && z && L?.maze)) {
1835
- y = requestAnimationFrame(b);
1838
+ m();
1839
+ }, [n.currentLevel, m]), x(() => {
1840
+ let y, C = !document.hidden;
1841
+ const k = () => {
1842
+ const S = c.current?.getContext("2d"), b = e.current;
1843
+ if (!(C && b?.isGameActive && S && b?.maze)) {
1844
+ y = requestAnimationFrame(k);
1836
1845
  return;
1837
1846
  }
1838
- p(), k(), y = requestAnimationFrame(b);
1839
- }, k = () => {
1840
- const z = l.current?.getContext("2d"), L = e.current;
1841
- if (z && L?.maze) {
1842
- const E = u.current?.wallWidth || c?.wallWidth, N = u.current?.exitColor || c?.exitColor, P = u.current?.exitWallWidth || c?.exitWallWidth, I = u.current?.exitDashArray || c?.exitDashArray;
1843
- tn(z, L, f.current, m.current, {
1844
- ...c,
1847
+ v(), T(), y = requestAnimationFrame(k);
1848
+ }, T = () => {
1849
+ const S = c.current?.getContext("2d"), b = e.current;
1850
+ if (S && b?.maze) {
1851
+ const E = u.current?.wallWidth || a?.wallWidth, N = u.current?.exitColor || a?.exitColor, P = u.current?.exitWallWidth || a?.exitWallWidth, I = u.current?.exitDashArray || a?.exitDashArray;
1852
+ on(S, b, f.current, w.current, {
1853
+ ...a,
1845
1854
  wallWidth: E,
1846
1855
  exitColor: N,
1847
1856
  exitWallWidth: P,
@@ -1849,35 +1858,35 @@ function vn() {
1849
1858
  });
1850
1859
  }
1851
1860
  };
1852
- h.current = k;
1853
- const T = (z) => {
1854
- const L = w;
1855
- w = !document.hidden && document.visibilityState === "visible" && (!z || z.type !== "blur"), !L && w ? e.current?.levelTransitioning === !1 && t({
1861
+ h.current = T;
1862
+ const z = (S) => {
1863
+ const b = C;
1864
+ C = !document.hidden && document.visibilityState === "visible" && (!S || S.type !== "blur"), !b && C ? e.current?.levelTransitioning === !1 && t({
1856
1865
  ...e.current,
1857
1866
  isGameActive: !0
1858
- }) : L && !w && t({
1867
+ }) : b && !C && t({
1859
1868
  ...e.current,
1860
1869
  isGameActive: !1
1861
1870
  });
1862
1871
  };
1863
- return document.addEventListener("visibilitychange", T), window.addEventListener("blur", T), window.addEventListener("focus", T), y = requestAnimationFrame(b), () => {
1864
- cancelAnimationFrame(y), document.removeEventListener("visibilitychange", T), window.removeEventListener("blur", T), window.removeEventListener("focus", T);
1872
+ return document.addEventListener("visibilitychange", z), window.addEventListener("blur", z), window.addEventListener("focus", z), y = requestAnimationFrame(k), () => {
1873
+ cancelAnimationFrame(y), document.removeEventListener("visibilitychange", z), window.removeEventListener("blur", z), window.removeEventListener("focus", z);
1865
1874
  };
1866
1875
  }, []), x(() => {
1867
1876
  R.show(r.useArrowKeyTips, "info", 3e3);
1868
- }, []), /* @__PURE__ */ C("div", { className: "maze-game-container", ref: i, children: [
1869
- /* @__PURE__ */ C(kt, {}),
1870
- /* @__PURE__ */ C(Xt, { onRetry: _ }),
1871
- /* @__PURE__ */ C("div", { className: "maze-canvas-container", ref: s, children: [
1872
- /* @__PURE__ */ C("canvas", { ref: l, className: "maze-game-canvas" }),
1873
- /* @__PURE__ */ C("div", { className: "maze-touch-area maze-up" }),
1874
- /* @__PURE__ */ C("div", { className: "maze-touch-area maze-down" }),
1875
- /* @__PURE__ */ C("div", { className: "maze-touch-area maze-left" }),
1876
- /* @__PURE__ */ C("div", { className: "maze-touch-area maze-right" })
1877
+ }, []), /* @__PURE__ */ p("div", { className: "maze-game-container", ref: i, children: [
1878
+ /* @__PURE__ */ p(St, {}),
1879
+ /* @__PURE__ */ p(Jt, { onRetry: _ }),
1880
+ /* @__PURE__ */ p("div", { className: "maze-canvas-container", ref: s, children: [
1881
+ /* @__PURE__ */ p("canvas", { ref: c, className: "maze-game-canvas" }),
1882
+ /* @__PURE__ */ p("div", { className: "maze-touch-area maze-up" }),
1883
+ /* @__PURE__ */ p("div", { className: "maze-touch-area maze-down" }),
1884
+ /* @__PURE__ */ p("div", { className: "maze-touch-area maze-left" }),
1885
+ /* @__PURE__ */ p("div", { className: "maze-touch-area maze-right" })
1877
1886
  ] })
1878
1887
  ] });
1879
1888
  }
1880
- const ot = [
1889
+ const it = [
1881
1890
  // Tier 1 (Levels 1-12) - Beginner
1882
1891
  [
1883
1892
  // debug
@@ -1885,8 +1894,8 @@ const ot = [
1885
1894
  // size: 38,
1886
1895
  // seed: 1248,
1887
1896
  // method: 'backtracking',
1888
- // wallWidth: 1,
1889
- // exitWallWidth: 3,
1897
+ // wallWidth: 2,
1898
+ // exitWallWidth: 22,
1890
1899
  // },
1891
1900
  {
1892
1901
  size: 8,
@@ -2035,7 +2044,7 @@ const ot = [
2035
2044
  { size: 68, seed: 33341, method: "backtracking" }
2036
2045
  // Level 60 - Master
2037
2046
  ]
2038
- ], oe = {
2047
+ ], re = {
2039
2048
  lcPrefix: "maze-",
2040
2049
  i18n: {
2041
2050
  reset: "Reset",
@@ -2094,33 +2103,33 @@ const ot = [
2094
2103
  exitDashArray: [8, 12]
2095
2104
  // default dash: 8px dash, 12px gap
2096
2105
  },
2097
- levelConfig: ot
2106
+ levelConfig: it
2098
2107
  };
2099
- function gn({ config: t = {} }) {
2100
- const e = { ...oe.i18n, ...t.i18n || {} }, n = {
2101
- ...oe.renderConfig,
2108
+ function Cn({ config: t = {} }) {
2109
+ const e = { ...re.i18n, ...t.i18n || {} }, n = {
2110
+ ...re.renderConfig,
2102
2111
  ...t.renderConfig || {}
2103
- }, o = t.levelConfig || ot, i = {
2104
- ...oe,
2112
+ }, o = t.levelConfig || it, i = {
2113
+ ...re,
2105
2114
  ...t,
2106
2115
  i18n: e,
2107
2116
  levelConfig: o,
2108
2117
  renderConfig: n
2109
2118
  };
2110
- return /* @__PURE__ */ C(wt, { config: i, children: /* @__PURE__ */ C(vn, {}) });
2119
+ return /* @__PURE__ */ p(bt, { config: i, children: /* @__PURE__ */ p(gn, {}) });
2111
2120
  }
2112
- const pn = {
2113
- root: "https://unpkg.com/@roudanio/maze@0.1.0/dist/",
2114
- ...oe
2121
+ const wn = {
2122
+ root: "https://unpkg.com/@roudanio/maze@0.1.2/dist/",
2123
+ ...re
2115
2124
  };
2116
- `${JSON.stringify(pn, null, 2)}`;
2117
- const Cn = {
2125
+ `${JSON.stringify(wn, null, 2)}`;
2126
+ const yn = {
2118
2127
  async init(t, e) {
2119
2128
  const n = typeof t == "string" ? document.querySelector(t) : t;
2120
2129
  if (!n) {
2121
2130
  console.warn("Cannot find the root element");
2122
- const a = document.createElement("div");
2123
- a.style.textAlign = "center", a.style.padding = "20px", a.innerHTML = "Cannot find the root element", document.body.append(a);
2131
+ const l = document.createElement("div");
2132
+ l.style.textAlign = "center", l.style.padding = "20px", l.innerHTML = "Cannot find the root element", document.body.append(l);
2124
2133
  return;
2125
2134
  }
2126
2135
  let { root: o = location.origin } = e;
@@ -2139,17 +2148,17 @@ const Cn = {
2139
2148
  transition: width 1.5s ease-in-out;
2140
2149
  transition: width 1.5s ease-in-out;
2141
2150
  `, i.append(s), n.append(i);
2142
- const l = document.createElement("style");
2143
- l.innerHTML = `
2151
+ const c = document.createElement("style");
2152
+ c.innerHTML = `
2144
2153
  @keyframes loading {
2145
2154
  0% { width: 0%; }
2146
2155
  100% { width: 99%; }
2147
- }`, document.head.appendChild(l), await (async (a) => new Promise((c, d) => {
2156
+ }`, document.head.appendChild(c), await (async (l) => new Promise((a, d) => {
2148
2157
  const u = document.createElement("link");
2149
- u.rel = "stylesheet", u.type = "text/css", u.href = a, u.onload = c, u.onerror = d, document.head.appendChild(u);
2150
- }))(o + "maze.css"), dt(/* @__PURE__ */ C(gn, { config: e }), n);
2158
+ u.rel = "stylesheet", u.type = "text/css", u.href = l, u.onload = a, u.onerror = d, document.head.appendChild(u);
2159
+ }))(o + "maze.css"), ft(/* @__PURE__ */ p(Cn, { config: e }), n);
2151
2160
  }
2152
2161
  };
2153
2162
  export {
2154
- Cn as default
2163
+ yn as default
2155
2164
  };