@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.iife.js +3 -3
- package/dist/maze.js +713 -704
- package/dist/maze.umd.js +3 -3
- package/package.json +1 -1
package/dist/maze.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
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
|
|
6
|
+
function ge(t) {
|
|
7
7
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
var o, i, s,
|
|
11
|
-
for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] :
|
|
12
|
-
if (arguments.length > 2 && (
|
|
13
|
-
return
|
|
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
|
|
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 ?? ++
|
|
17
|
-
return i == null &&
|
|
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
|
|
19
|
+
function ce(t) {
|
|
20
20
|
return t.children;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
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
|
|
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
|
|
37
|
+
return Ye(t);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
(!t.__d && (t.__d = !0) &&
|
|
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
|
|
44
|
-
for (var t, e, n, o, i, s,
|
|
45
|
-
|
|
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
|
|
48
|
-
var u, h, f,
|
|
49
|
-
for (
|
|
50
|
-
return n.__e = g,
|
|
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
|
|
53
|
-
var s,
|
|
54
|
-
for (t.__k = new Array(i), s = 0; s < i; s++) (
|
|
55
|
-
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = G(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
|
|
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 =
|
|
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
|
|
71
|
-
var i, s,
|
|
72
|
-
if (
|
|
73
|
-
if (o > (
|
|
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 ((
|
|
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 ((
|
|
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
|
|
86
|
-
e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" ||
|
|
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
|
|
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 ||
|
|
93
|
-
if (n) for (e in n) o && n[e] == o[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(
|
|
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
|
|
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 =
|
|
110
|
+
if (e.t == null) e.t = pe++;
|
|
111
111
|
else if (e.t < n.u) return;
|
|
112
|
-
return n(
|
|
112
|
+
return n(L.event ? L.event(e) : e);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
var d, u, h, f,
|
|
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 && (
|
|
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 (
|
|
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 (
|
|
124
|
-
for (e.__v != n.__v && (u.props =
|
|
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
|
-
}),
|
|
127
|
-
u._sb = [], u.__h.length &&
|
|
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(
|
|
131
|
-
u.componentDidUpdate(f,
|
|
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 =
|
|
135
|
-
for (u.state = u.__s, u.__d = !1,
|
|
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,
|
|
139
|
-
while (u.__d && ++
|
|
140
|
-
u.state = u.__s, u.getChildContext != null && (o = $($({}, o), u.getChildContext())),
|
|
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,
|
|
143
|
-
for (e.__u |=
|
|
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--; )
|
|
145
|
+
} else for (E = s.length; E--; ) ge(s[E]);
|
|
146
146
|
else e.__e = n.__e, e.__k = n.__k;
|
|
147
|
-
|
|
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 =
|
|
150
|
-
return (d =
|
|
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
|
|
153
|
-
for (var o = 0; o < n.length; o++)
|
|
154
|
-
|
|
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
|
-
|
|
160
|
+
L.__e(s, i.__v);
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
return typeof t != "object" || t == null || t.__b && t.__b > 0 ? 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
|
|
168
|
-
var
|
|
169
|
-
if (
|
|
170
|
-
for (
|
|
171
|
-
t = f, s[
|
|
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 (
|
|
177
|
-
t = document.createElementNS(i,
|
|
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 (
|
|
179
|
+
if (m == null) _ === v || r && t.data == v || (t.data = v);
|
|
180
180
|
else {
|
|
181
|
-
if (s = s &&
|
|
182
|
-
for (
|
|
183
|
-
if (
|
|
184
|
-
else if (!(
|
|
185
|
-
if (
|
|
186
|
-
|
|
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 (
|
|
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 = ""),
|
|
192
|
-
r || (
|
|
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
|
|
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
|
-
|
|
203
|
+
L.__e(i, n);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function Qe(t, e, n) {
|
|
207
207
|
var o, i;
|
|
208
|
-
if (
|
|
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
|
-
|
|
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] &&
|
|
217
|
-
n ||
|
|
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
|
|
219
|
+
function ht(t, e, n) {
|
|
220
220
|
return this.constructor(t, n);
|
|
221
221
|
}
|
|
222
|
-
function
|
|
223
|
-
var o, i, s,
|
|
224
|
-
e == document && (e = document.documentElement),
|
|
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
|
|
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(
|
|
235
|
-
|
|
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
|
|
239
|
+
var c = s.componentWillUnmount;
|
|
240
240
|
s.componentWillUnmount = function() {
|
|
241
|
-
o && o.delete(s),
|
|
241
|
+
o && o.delete(s), c && c.call(s);
|
|
242
242
|
};
|
|
243
243
|
}), n.children;
|
|
244
244
|
}
|
|
245
|
-
return e.__c = "__cC" +
|
|
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
|
-
|
|
250
|
-
for (var i, s,
|
|
251
|
-
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)),
|
|
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
|
-
} },
|
|
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),
|
|
259
|
-
},
|
|
260
|
-
this.__v && (this.__e = !0, t && this.__h.push(t),
|
|
261
|
-
},
|
|
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
|
-
},
|
|
264
|
-
var
|
|
265
|
-
function
|
|
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
|
|
268
|
-
if ("ref" in
|
|
269
|
-
var
|
|
270
|
-
if (typeof t == "function" && (
|
|
271
|
-
return
|
|
272
|
-
}
|
|
273
|
-
var H, A,
|
|
274
|
-
function
|
|
275
|
-
M.__h && M.__h(A, t,
|
|
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
|
|
280
|
+
return K = 1, vt(nt, t);
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
var o =
|
|
284
|
-
if (o.t = t, !o.__c && (o.__ = [
|
|
285
|
-
var
|
|
286
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
302
|
+
}), s && s.call(this, r, l, a) || u;
|
|
303
303
|
};
|
|
304
304
|
A.__f = !0;
|
|
305
|
-
var s = A.shouldComponentUpdate,
|
|
306
|
-
A.componentWillUpdate = function(r,
|
|
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,
|
|
309
|
+
s = void 0, i(r, l, a), s = d;
|
|
310
310
|
}
|
|
311
|
-
|
|
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 =
|
|
318
|
-
!M.__s &&
|
|
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
|
|
321
|
-
return
|
|
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 =
|
|
327
|
-
return
|
|
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
|
|
330
|
-
return
|
|
329
|
+
function pt(t, e) {
|
|
330
|
+
return K = 8, q(function() {
|
|
331
331
|
return t;
|
|
332
332
|
}, e);
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
var e = A.context[t.__c], n =
|
|
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
|
|
339
|
-
for (var t; t =
|
|
340
|
-
t.__H.__h.forEach(
|
|
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,
|
|
346
|
+
A = null, Ne && Ne(t);
|
|
347
347
|
}, M.__ = function(t, e) {
|
|
348
|
-
t && e.__k && e.__k.__m && (t.__m = e.__k.__m),
|
|
348
|
+
t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Ie && Ie(t, e);
|
|
349
349
|
}, M.__r = function(t) {
|
|
350
|
-
|
|
350
|
+
Ae && Ae(t), H = 0;
|
|
351
351
|
var e = (A = t.__c).__H;
|
|
352
|
-
e && (
|
|
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(
|
|
354
|
+
})) : (e.__h.forEach(ne), e.__h.forEach(ve), e.__h = [], H = 0)), he = A;
|
|
355
355
|
}, M.diffed = function(t) {
|
|
356
|
-
|
|
356
|
+
Ee && Ee(t);
|
|
357
357
|
var e = t.__c;
|
|
358
|
-
e && e.__H && (e.__H.__h.length && (
|
|
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
|
-
})),
|
|
360
|
+
})), he = A = null;
|
|
361
361
|
}, M.__c = function(t, e) {
|
|
362
362
|
e.some(function(n) {
|
|
363
363
|
try {
|
|
364
|
-
n.__h.forEach(
|
|
365
|
-
return !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
|
-
}),
|
|
372
|
+
}), Me && Me(t, e);
|
|
373
373
|
}, M.unmount = function(t) {
|
|
374
|
-
|
|
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
|
-
|
|
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
|
|
385
|
-
function
|
|
384
|
+
var xe = typeof requestAnimationFrame == "function";
|
|
385
|
+
function wt(t) {
|
|
386
386
|
var e, n = function() {
|
|
387
|
-
clearTimeout(o),
|
|
387
|
+
clearTimeout(o), xe && cancelAnimationFrame(e), setTimeout(t);
|
|
388
388
|
}, o = setTimeout(n, 100);
|
|
389
|
-
|
|
389
|
+
xe && (e = requestAnimationFrame(n));
|
|
390
390
|
}
|
|
391
|
-
function
|
|
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
|
|
395
|
+
function ve(t) {
|
|
396
396
|
var e = A;
|
|
397
397
|
t.__c = t.__(), A = e;
|
|
398
398
|
}
|
|
399
|
-
function
|
|
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
|
|
404
|
+
function nt(t, e) {
|
|
405
405
|
return typeof e == "function" ? e(t) : e;
|
|
406
406
|
}
|
|
407
|
-
const
|
|
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
|
-
}),
|
|
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
|
-
},
|
|
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
|
-
},
|
|
451
|
-
const n =
|
|
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 [
|
|
472
|
-
...
|
|
473
|
-
}),
|
|
471
|
+
const [c, r] = j({
|
|
472
|
+
...Fe
|
|
473
|
+
}), l = F(c);
|
|
474
474
|
x(() => {
|
|
475
|
-
|
|
476
|
-
}, [
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
482
|
+
c.playerAtExit,
|
|
483
|
+
c.foodCollected,
|
|
484
|
+
c.totalFoodCount,
|
|
485
|
+
c.showClue
|
|
486
486
|
]), d = () => {
|
|
487
487
|
n.resetGameData(), s({
|
|
488
|
-
...
|
|
488
|
+
...De
|
|
489
489
|
}), r({
|
|
490
|
-
...
|
|
490
|
+
...Fe
|
|
491
491
|
});
|
|
492
492
|
};
|
|
493
|
-
return /* @__PURE__ */
|
|
494
|
-
|
|
493
|
+
return /* @__PURE__ */ p(
|
|
494
|
+
ot.Provider,
|
|
495
495
|
{
|
|
496
496
|
value: {
|
|
497
497
|
gameProgress: i,
|
|
498
498
|
setGameProgress: s,
|
|
499
|
-
gamePlayState:
|
|
499
|
+
gamePlayState: c,
|
|
500
500
|
setGamePlayState: r,
|
|
501
|
-
gamePlayStateRef:
|
|
502
|
-
currentScore:
|
|
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 =
|
|
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
|
-
},
|
|
515
|
-
const e = t.map((r) => r.length), n = e.reduce((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
|
|
518
|
-
for (let
|
|
519
|
-
if (
|
|
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((
|
|
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
|
|
527
|
-
return [
|
|
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
|
|
534
|
-
return t[
|
|
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,
|
|
538
|
-
isTierUnlocked: (r,
|
|
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
|
|
541
|
+
const l = r + 1, a = i(r), d = i(l);
|
|
542
542
|
return {
|
|
543
|
-
nextLevel:
|
|
543
|
+
nextLevel: l,
|
|
544
544
|
nextTier: d,
|
|
545
|
-
isTierChange: d >
|
|
545
|
+
isTierChange: d > a
|
|
546
546
|
};
|
|
547
547
|
},
|
|
548
|
-
getCurrentTierProgress: (r,
|
|
549
|
-
const [
|
|
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
|
|
554
|
-
return r ===
|
|
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
|
|
558
|
+
const l = r - 1, a = i(r), d = i(l);
|
|
559
559
|
return {
|
|
560
|
-
prevLevel:
|
|
560
|
+
prevLevel: l,
|
|
561
561
|
prevTier: d,
|
|
562
|
-
isTierChange: d <
|
|
562
|
+
isTierChange: d < a
|
|
563
563
|
};
|
|
564
564
|
}
|
|
565
565
|
};
|
|
566
|
-
return
|
|
567
|
-
}, [t]),
|
|
568
|
-
const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier:
|
|
569
|
-
return /* @__PURE__ */
|
|
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:
|
|
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:
|
|
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
|
-
},
|
|
590
|
-
const { gameProgress: n, config: o } = B(), { i18n: i, levelConfig: s } = o, { currentTier:
|
|
591
|
-
const [h, f] = d.getTierLevelsRange(
|
|
592
|
-
return Array.from({ length: f - h + 1 }, (
|
|
593
|
-
const _ = h + g,
|
|
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:
|
|
596
|
+
score: v
|
|
597
597
|
};
|
|
598
598
|
});
|
|
599
|
-
}, [
|
|
600
|
-
return /* @__PURE__ */
|
|
599
|
+
}, [c, r]);
|
|
600
|
+
return /* @__PURE__ */ p("div", { className: "level-selector", children: /* @__PURE__ */ p(
|
|
601
601
|
"select",
|
|
602
602
|
{
|
|
603
|
-
value:
|
|
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__ */
|
|
609
|
+
children: u.map(({ level: h, score: f }) => /* @__PURE__ */ p(
|
|
610
610
|
"option",
|
|
611
611
|
{
|
|
612
612
|
value: h,
|
|
613
|
-
disabled: h >
|
|
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
|
-
},
|
|
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:
|
|
627
|
+
noCancel: c = !1,
|
|
628
628
|
confirmText: r = "OK",
|
|
629
|
-
cancelText:
|
|
630
|
-
onConfirm:
|
|
629
|
+
cancelText: l = "Cancel",
|
|
630
|
+
onConfirm: a,
|
|
631
631
|
onCancel: d
|
|
632
632
|
}) => {
|
|
633
|
-
const u =
|
|
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__ */
|
|
641
|
+
}, [t, d]), /* @__PURE__ */ p(
|
|
642
642
|
"div",
|
|
643
643
|
{
|
|
644
644
|
className: `maze-dialog-overlay ${t ? "maze-dialog-visible" : ""}`,
|
|
645
|
-
children: /* @__PURE__ */
|
|
646
|
-
/* @__PURE__ */
|
|
647
|
-
/* @__PURE__ */
|
|
648
|
-
(!
|
|
649
|
-
!
|
|
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:
|
|
655
|
+
children: l
|
|
656
656
|
}
|
|
657
657
|
),
|
|
658
|
-
!s && /* @__PURE__ */
|
|
658
|
+
!s && /* @__PURE__ */ p(
|
|
659
659
|
"button",
|
|
660
660
|
{
|
|
661
661
|
type: "button",
|
|
662
662
|
className: "maze-dialog-confirm",
|
|
663
|
-
onClick:
|
|
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
|
-
},
|
|
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:
|
|
710
|
-
} = B(), { i18n: r, levelConfig:
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
},
|
|
714
|
-
|
|
715
|
-
r.levelGoToast.replace("%LEVEL%",
|
|
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
|
-
},
|
|
723
|
-
|
|
722
|
+
}, b = () => {
|
|
723
|
+
C(!0);
|
|
724
724
|
}, E = () => {
|
|
725
|
-
|
|
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
|
-
})),
|
|
731
|
+
})), C(!1);
|
|
732
732
|
}, P = () => {
|
|
733
|
-
|
|
733
|
+
m(!0);
|
|
734
734
|
}, I = () => {
|
|
735
|
-
s(),
|
|
736
|
-
},
|
|
737
|
-
|
|
735
|
+
s(), m(!1), R.show(r.resetDoneToast);
|
|
736
|
+
}, V = () => {
|
|
737
|
+
m(!1);
|
|
738
738
|
};
|
|
739
|
-
return /* @__PURE__ */
|
|
740
|
-
/* @__PURE__ */
|
|
741
|
-
/* @__PURE__ */
|
|
742
|
-
/* @__PURE__ */
|
|
743
|
-
|
|
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:
|
|
745
|
+
onTierChange: k,
|
|
746
746
|
disabled: d
|
|
747
747
|
}
|
|
748
748
|
),
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
-
|
|
749
|
+
/* @__PURE__ */ p(
|
|
750
|
+
Tt,
|
|
751
751
|
{
|
|
752
|
-
onLevelChange:
|
|
752
|
+
onLevelChange: T,
|
|
753
753
|
disabled: d
|
|
754
754
|
}
|
|
755
755
|
)
|
|
756
756
|
] }),
|
|
757
|
-
/* @__PURE__ */
|
|
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:
|
|
763
|
+
onClick: b,
|
|
764
764
|
children: u ? r.clueOn : r.clueOff
|
|
765
765
|
}
|
|
766
766
|
)
|
|
767
767
|
] }),
|
|
768
|
-
/* @__PURE__ */
|
|
769
|
-
/* @__PURE__ */
|
|
770
|
-
|
|
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:
|
|
776
|
+
onCancel: S,
|
|
777
777
|
children: [
|
|
778
|
-
/* @__PURE__ */
|
|
779
|
-
/* @__PURE__ */
|
|
780
|
-
/* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
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__ */
|
|
784
|
-
/* @__PURE__ */
|
|
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__ */
|
|
793
|
+
/* @__PURE__ */ p("div", { className: "settings-item-tip", children: r.resetTip })
|
|
794
794
|
] })
|
|
795
795
|
]
|
|
796
796
|
}
|
|
797
797
|
),
|
|
798
|
-
/* @__PURE__ */
|
|
799
|
-
|
|
798
|
+
/* @__PURE__ */ p(
|
|
799
|
+
oe,
|
|
800
800
|
{
|
|
801
|
-
isOpen:
|
|
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:
|
|
807
|
+
onCancel: V
|
|
808
808
|
}
|
|
809
809
|
),
|
|
810
|
-
/* @__PURE__ */
|
|
811
|
-
|
|
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
|
|
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
|
|
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
|
|
835
|
-
return e &&
|
|
834
|
+
function be(t, e, n) {
|
|
835
|
+
return e && zt(t.prototype, e), t;
|
|
836
836
|
}
|
|
837
|
-
function
|
|
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 =
|
|
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
|
|
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
|
|
856
|
+
var Ue = /* @__PURE__ */ function() {
|
|
857
857
|
function t(e) {
|
|
858
|
-
|
|
859
|
-
var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors,
|
|
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 =
|
|
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" ?
|
|
867
|
-
var u = o === "left" ?
|
|
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 =
|
|
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 =
|
|
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
|
|
875
|
+
return be(t, [{
|
|
876
876
|
key: "draw",
|
|
877
877
|
value: function(n) {
|
|
878
|
-
var o = this.currentPosition, i = this.radius, s = this.color,
|
|
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()) :
|
|
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,
|
|
885
|
-
if (i.x >
|
|
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 *
|
|
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 +
|
|
894
|
+
return this.currentPosition.y < n + jt;
|
|
895
895
|
}
|
|
896
896
|
}]), t;
|
|
897
897
|
}();
|
|
898
|
-
function
|
|
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
|
|
903
|
-
var e = t.confettiRadius, n = e === void 0 ?
|
|
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:
|
|
908
|
-
emojis:
|
|
907
|
+
confettiColors: c,
|
|
908
|
+
emojis: l,
|
|
909
909
|
emojiSize: d
|
|
910
910
|
};
|
|
911
911
|
}
|
|
912
|
-
var
|
|
912
|
+
var Yt = /* @__PURE__ */ function() {
|
|
913
913
|
function t(e) {
|
|
914
914
|
var n = this;
|
|
915
|
-
|
|
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
|
|
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,
|
|
940
|
-
this.shapes = this.shapes.filter(function(
|
|
941
|
-
return
|
|
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
|
-
}(),
|
|
945
|
+
}(), Xt = /* @__PURE__ */ function() {
|
|
946
946
|
function t() {
|
|
947
947
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
948
|
-
|
|
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
|
|
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(
|
|
956
|
-
return
|
|
955
|
+
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(c) {
|
|
956
|
+
return c.processShapes({
|
|
957
957
|
timeDelta: o,
|
|
958
958
|
currentTime: n
|
|
959
|
-
}, i, s), s ? !
|
|
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 =
|
|
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
|
-
},
|
|
973
|
+
}, w = {
|
|
974
974
|
x: d,
|
|
975
975
|
y: h
|
|
976
|
-
}, g = new
|
|
977
|
-
var
|
|
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:
|
|
981
|
+
confettiColors: c,
|
|
982
982
|
confettiNumber: s,
|
|
983
983
|
emojis: r,
|
|
984
|
-
emojiSize:
|
|
984
|
+
emojiSize: l,
|
|
985
985
|
canvasWidth: d
|
|
986
|
-
}),
|
|
987
|
-
initialPosition:
|
|
986
|
+
}), m = new Ue({
|
|
987
|
+
initialPosition: w,
|
|
988
988
|
direction: "left",
|
|
989
989
|
confettiRadius: i,
|
|
990
|
-
confettiColors:
|
|
990
|
+
confettiColors: c,
|
|
991
991
|
confettiNumber: s,
|
|
992
992
|
emojis: r,
|
|
993
|
-
emojiSize:
|
|
993
|
+
emojiSize: l,
|
|
994
994
|
canvasWidth: d
|
|
995
995
|
});
|
|
996
|
-
g.addShapes(
|
|
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
|
|
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:
|
|
1020
|
-
} = B(), { i18n: r, levelConfig:
|
|
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
|
-
|
|
1023
|
-
}, [
|
|
1024
|
-
const y =
|
|
1025
|
-
|
|
1026
|
-
},
|
|
1027
|
-
|
|
1028
|
-
...
|
|
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
|
-
},
|
|
1033
|
-
|
|
1034
|
-
const
|
|
1035
|
-
if (!
|
|
1036
|
-
const { nextLevel: E, nextTier: N, isTierChange: P } =
|
|
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
|
-
),
|
|
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__ */
|
|
1056
|
-
|
|
1055
|
+
return /* @__PURE__ */ p(
|
|
1056
|
+
oe,
|
|
1057
1057
|
{
|
|
1058
1058
|
className: "level-complete-dialog",
|
|
1059
|
-
isOpen:
|
|
1059
|
+
isOpen: v,
|
|
1060
1060
|
title: r.congratulations,
|
|
1061
1061
|
cancelText: r.retry,
|
|
1062
|
-
onCancel:
|
|
1062
|
+
onCancel: T,
|
|
1063
1063
|
noConfirm: !!d,
|
|
1064
1064
|
confirmText: r.continue,
|
|
1065
|
-
onConfirm:
|
|
1065
|
+
onConfirm: z,
|
|
1066
1066
|
children: [
|
|
1067
|
-
/* @__PURE__ */
|
|
1068
|
-
!!
|
|
1069
|
-
/* @__PURE__ */
|
|
1070
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
1073
|
-
/* @__PURE__ */
|
|
1074
|
-
!d && /* @__PURE__ */
|
|
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
|
-
},
|
|
1079
|
-
const n =
|
|
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
|
|
1088
|
-
if (!
|
|
1089
|
-
const r =
|
|
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
|
|
1092
|
-
s.width =
|
|
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
|
-
},
|
|
1100
|
+
}, Qt = (t) => {
|
|
1101
1101
|
const {
|
|
1102
1102
|
config: e,
|
|
1103
1103
|
gamePlayState: { maze: n }
|
|
1104
|
-
} = B(), o =
|
|
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:
|
|
1110
|
-
if (
|
|
1111
|
-
const d = (r.width - i * 2) /
|
|
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
|
|
1116
|
-
return t.current && window.ResizeObserver && (
|
|
1117
|
-
t.current &&
|
|
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
|
-
},
|
|
1120
|
+
}, Q = {
|
|
1121
1121
|
ArrowUp: [-1, 0],
|
|
1122
1122
|
ArrowDown: [1, 0],
|
|
1123
1123
|
ArrowLeft: [0, -1],
|
|
1124
1124
|
ArrowRight: [0, 1]
|
|
1125
|
-
},
|
|
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
|
-
|
|
1133
|
+
exitWallWidth: s,
|
|
1134
|
+
getCellSizeInPixels: c,
|
|
1135
|
+
onFoodCollected: r
|
|
1134
1136
|
}) => {
|
|
1135
|
-
const l =
|
|
1136
|
-
const
|
|
1137
|
-
if (!
|
|
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 [
|
|
1140
|
-
if (
|
|
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
|
-
|
|
1148
|
+
m.maze
|
|
1147
1149
|
))
|
|
1148
1150
|
return { canMove: !1, newCell: null };
|
|
1149
|
-
const { row:
|
|
1150
|
-
return
|
|
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:
|
|
1154
|
+
newCell: { row: P, col: I }
|
|
1153
1155
|
} : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
|
|
1154
|
-
},
|
|
1155
|
-
const
|
|
1156
|
-
Math.pow(
|
|
1157
|
-
) <
|
|
1158
|
-
|
|
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
|
-
(
|
|
1164
|
+
(z, S) => S !== C
|
|
1163
1165
|
)
|
|
1164
1166
|
});
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
i
|
|
1167
|
+
const T = nn(
|
|
1168
|
+
_.playerCell,
|
|
1169
|
+
_.exitCell,
|
|
1170
|
+
_.maze,
|
|
1171
|
+
i,
|
|
1172
|
+
s,
|
|
1173
|
+
c
|
|
1170
1174
|
);
|
|
1171
|
-
|
|
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
|
-
)) : !
|
|
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
|
-
},
|
|
1189
|
-
const
|
|
1190
|
-
if ((
|
|
1191
|
-
const
|
|
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:
|
|
1200
|
+
{ row: m, col: y }
|
|
1197
1201
|
],
|
|
1198
1202
|
visitCounts: {
|
|
1199
1203
|
...e.current.visitCounts,
|
|
1200
|
-
[
|
|
1204
|
+
[b]: (e.current.visitCounts[b] || 0) + 1
|
|
1201
1205
|
}
|
|
1202
1206
|
};
|
|
1203
1207
|
}
|
|
1204
|
-
},
|
|
1205
|
-
if (l.current ||
|
|
1206
|
-
const
|
|
1207
|
-
!
|
|
1208
|
-
(
|
|
1209
|
-
const { canMove:
|
|
1210
|
-
|
|
1211
|
-
|
|
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
|
|
1217
|
+
return y;
|
|
1214
1218
|
}
|
|
1215
1219
|
) || (l.current = !0);
|
|
1216
1220
|
};
|
|
1217
1221
|
x(() => {
|
|
1218
|
-
const
|
|
1219
|
-
(
|
|
1220
|
-
},
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
},
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1226
|
-
},
|
|
1227
|
-
|
|
1228
|
-
const
|
|
1229
|
-
if (!
|
|
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
|
|
1232
|
-
let
|
|
1233
|
-
|
|
1234
|
-
},
|
|
1235
|
-
|
|
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",
|
|
1241
|
+
return window.addEventListener("keydown", _, {
|
|
1238
1242
|
capture: !0
|
|
1239
|
-
}), window.addEventListener("keydown",
|
|
1243
|
+
}), window.addEventListener("keydown", v), window.addEventListener("keyup", m), t.current?.addEventListener("touchstart", y, {
|
|
1240
1244
|
passive: !1
|
|
1241
|
-
}), t.current?.addEventListener("touchend",
|
|
1242
|
-
window.removeEventListener("keydown",
|
|
1245
|
+
}), t.current?.addEventListener("touchend", C), () => {
|
|
1246
|
+
window.removeEventListener("keydown", _, {
|
|
1243
1247
|
capture: !0
|
|
1244
|
-
}), window.removeEventListener("keydown",
|
|
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
|
|
1248
|
-
if (!l.current ||
|
|
1251
|
+
const w = pt(() => {
|
|
1252
|
+
if (!l.current || a.current.size === 0)
|
|
1249
1253
|
return e.current.playerCell;
|
|
1250
|
-
const
|
|
1251
|
-
let
|
|
1252
|
-
for (const
|
|
1253
|
-
const { canMove:
|
|
1254
|
-
if (
|
|
1255
|
-
const [
|
|
1256
|
-
|
|
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 (
|
|
1263
|
+
if (y === 0)
|
|
1260
1264
|
return e.current.playerCell;
|
|
1261
|
-
const
|
|
1262
|
-
(
|
|
1263
|
-
),
|
|
1264
|
-
(
|
|
1265
|
-
),
|
|
1266
|
-
if (
|
|
1267
|
-
const
|
|
1268
|
-
if (
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
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
|
-
|
|
1277
|
+
N,
|
|
1274
1278
|
e.current.maze
|
|
1275
1279
|
))
|
|
1276
1280
|
return e.current.playerCell;
|
|
1277
1281
|
}
|
|
1278
1282
|
e.current.playerCell = {
|
|
1279
|
-
row:
|
|
1280
|
-
col:
|
|
1281
|
-
},
|
|
1282
|
-
const
|
|
1283
|
-
return (
|
|
1284
|
-
}, [o]),
|
|
1285
|
-
l.current = !1,
|
|
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:
|
|
1289
|
-
resetMovingState:
|
|
1292
|
+
updatePlayerPos: w,
|
|
1293
|
+
resetMovingState: g
|
|
1290
1294
|
};
|
|
1291
1295
|
};
|
|
1292
|
-
function
|
|
1293
|
-
const
|
|
1294
|
-
|
|
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,
|
|
1314
|
-
const g = d + f, _ = u +
|
|
1315
|
-
s.isValid(g, _) &&
|
|
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
|
|
1318
|
-
const
|
|
1319
|
-
for (const g of
|
|
1320
|
-
if (
|
|
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
|
|
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
|
|
1342
|
-
const { start: n, end: o } = e, i = o.col - n.col, s = o.row - n.row,
|
|
1343
|
-
if (
|
|
1344
|
-
return Math.sqrt(
|
|
1345
|
-
const
|
|
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
|
-
(
|
|
1353
|
+
(c * i + r * s) / l
|
|
1350
1354
|
)
|
|
1351
|
-
), d = n.col +
|
|
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
|
|
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
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
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
|
-
|
|
1365
|
-
)
|
|
1366
|
-
|
|
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
|
|
1381
|
+
function on(t, e, n, o, i) {
|
|
1375
1382
|
if (!t || !e.maze) return;
|
|
1376
|
-
const { canvasWidth: s, canvasHeight:
|
|
1377
|
-
maze:
|
|
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:
|
|
1390
|
+
playerPath: w,
|
|
1384
1391
|
visitCounts: g
|
|
1385
1392
|
} = e, {
|
|
1386
1393
|
padding: _,
|
|
1387
|
-
wallWidth:
|
|
1394
|
+
wallWidth: v,
|
|
1388
1395
|
// need merge with level config when passed here
|
|
1389
|
-
wallColor:
|
|
1396
|
+
wallColor: m,
|
|
1390
1397
|
playerColor: y,
|
|
1391
|
-
playerRadius:
|
|
1392
|
-
foodColor:
|
|
1393
|
-
backgroundColor:
|
|
1394
|
-
clueColor:
|
|
1395
|
-
exitColor:
|
|
1396
|
-
exitWallWidth:
|
|
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,
|
|
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:
|
|
1408
|
+
playerPath: w,
|
|
1402
1409
|
visitCounts: g,
|
|
1403
1410
|
cellWidth: r,
|
|
1404
|
-
cellHeight:
|
|
1411
|
+
cellHeight: l,
|
|
1405
1412
|
padding: _,
|
|
1406
|
-
clueColor:
|
|
1407
|
-
}),
|
|
1413
|
+
clueColor: z
|
|
1414
|
+
}), rn({
|
|
1408
1415
|
ctx: t,
|
|
1409
|
-
maze:
|
|
1416
|
+
maze: a,
|
|
1410
1417
|
cellWidth: r,
|
|
1411
|
-
cellHeight:
|
|
1418
|
+
cellHeight: l,
|
|
1412
1419
|
padding: _,
|
|
1413
|
-
wallColor:
|
|
1414
|
-
wallWidth:
|
|
1415
|
-
}),
|
|
1420
|
+
wallColor: m,
|
|
1421
|
+
wallWidth: v
|
|
1422
|
+
}), ln({
|
|
1416
1423
|
ctx: t,
|
|
1417
|
-
maze:
|
|
1424
|
+
maze: a,
|
|
1418
1425
|
exitCell: u,
|
|
1419
1426
|
cellWidth: r,
|
|
1420
|
-
cellHeight:
|
|
1427
|
+
cellHeight: l,
|
|
1421
1428
|
padding: _,
|
|
1422
|
-
exitColor:
|
|
1423
|
-
exitWallWidth:
|
|
1429
|
+
exitColor: S,
|
|
1430
|
+
exitWallWidth: b,
|
|
1424
1431
|
exitDashArray: E
|
|
1425
|
-
}),
|
|
1432
|
+
}), an({
|
|
1426
1433
|
ctx: t,
|
|
1427
1434
|
foodCells: h,
|
|
1428
1435
|
cellWidth: r,
|
|
1429
|
-
cellHeight:
|
|
1436
|
+
cellHeight: l,
|
|
1430
1437
|
padding: _,
|
|
1431
|
-
foodColor:
|
|
1432
|
-
}),
|
|
1438
|
+
foodColor: k
|
|
1439
|
+
}), sn({
|
|
1433
1440
|
ctx: t,
|
|
1434
1441
|
playerCell: d,
|
|
1435
|
-
playerRadius:
|
|
1442
|
+
playerRadius: C,
|
|
1436
1443
|
cellWidth: r,
|
|
1437
|
-
cellHeight:
|
|
1444
|
+
cellHeight: l,
|
|
1438
1445
|
padding: _,
|
|
1439
1446
|
playerColor: y
|
|
1440
1447
|
});
|
|
1441
1448
|
}
|
|
1442
|
-
function
|
|
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:
|
|
1456
|
+
wallWidth: c
|
|
1450
1457
|
}) {
|
|
1451
|
-
t.save(), t.strokeStyle = s, t.lineWidth =
|
|
1452
|
-
t.moveTo(
|
|
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
|
|
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:
|
|
1469
|
+
playerColor: c
|
|
1463
1470
|
}) {
|
|
1464
|
-
const { x: r, y:
|
|
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
|
-
),
|
|
1471
|
-
t.save(), t.fillStyle =
|
|
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
|
|
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:
|
|
1487
|
+
exitColor: c,
|
|
1481
1488
|
exitWallWidth: r,
|
|
1482
|
-
exitDashArray:
|
|
1489
|
+
exitDashArray: l = [8, 12]
|
|
1483
1490
|
}) {
|
|
1484
|
-
const { row:
|
|
1485
|
-
if (!e.isValid(
|
|
1486
|
-
const u = e.grid[
|
|
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 =
|
|
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
|
|
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
|
|
1505
|
+
const c = Math.min(n, o) * 0.25;
|
|
1499
1506
|
e.forEach((r) => {
|
|
1500
|
-
const { x:
|
|
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
|
-
|
|
1514
|
+
cn(t, l, a, c * 1.2, 5, c * 0.6);
|
|
1508
1515
|
});
|
|
1509
1516
|
}
|
|
1510
|
-
function
|
|
1517
|
+
function cn(t, e, n, o, i, s) {
|
|
1511
1518
|
t.save(), t.beginPath();
|
|
1512
|
-
for (let
|
|
1513
|
-
const r =
|
|
1514
|
-
t.lineTo(e + r * Math.sin(
|
|
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
|
|
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:
|
|
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
|
|
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 =
|
|
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 =
|
|
1537
|
-
const { x: g, y: _ } =
|
|
1538
|
-
|
|
1539
|
-
|
|
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:
|
|
1544
|
-
|
|
1545
|
-
|
|
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(
|
|
1557
|
+
t.beginPath(), t.moveTo(g, _), t.lineTo(v, m), t.stroke();
|
|
1551
1558
|
}
|
|
1552
1559
|
t.restore();
|
|
1553
1560
|
}
|
|
1554
1561
|
}
|
|
1555
|
-
function
|
|
1562
|
+
function dn(t, e, n, o) {
|
|
1556
1563
|
const i = [];
|
|
1557
1564
|
for (let s = 0; s < t.rows; s++)
|
|
1558
|
-
for (let
|
|
1559
|
-
const r = t.grid[s][
|
|
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:
|
|
1562
|
-
y1:
|
|
1563
|
-
x2:
|
|
1564
|
-
y2:
|
|
1568
|
+
x1: l,
|
|
1569
|
+
y1: a,
|
|
1570
|
+
x2: l + e,
|
|
1571
|
+
y2: a
|
|
1565
1572
|
}), r.walls.right && i.push({
|
|
1566
|
-
x1:
|
|
1567
|
-
y1:
|
|
1568
|
-
x2:
|
|
1569
|
-
y2:
|
|
1573
|
+
x1: l + e,
|
|
1574
|
+
y1: a,
|
|
1575
|
+
x2: l + e,
|
|
1576
|
+
y2: a + n
|
|
1570
1577
|
}), r.walls.bottom && i.push({
|
|
1571
|
-
x1:
|
|
1572
|
-
y1:
|
|
1573
|
-
x2:
|
|
1574
|
-
y2:
|
|
1578
|
+
x1: l,
|
|
1579
|
+
y1: a + n,
|
|
1580
|
+
x2: l + e,
|
|
1581
|
+
y2: a + n
|
|
1575
1582
|
}), r.walls.left && i.push({
|
|
1576
|
-
x1:
|
|
1577
|
-
y1:
|
|
1578
|
-
x2:
|
|
1579
|
-
y2:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
1651
|
-
this.isValid(
|
|
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],
|
|
1672
|
-
e === o + 1 ? (s.walls.top = !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:
|
|
1708
|
+
const { row: s, col: c } = i, r = this.getUnvisitedNeighbors(s, c);
|
|
1702
1709
|
if (r.length > 0) {
|
|
1703
|
-
const
|
|
1704
|
-
this.removeWall(s,
|
|
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,
|
|
1712
|
-
const r = this.getNeighbors(s,
|
|
1713
|
-
for (const
|
|
1714
|
-
!this.grid[
|
|
1715
|
-
(
|
|
1716
|
-
) && e.push(
|
|
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),
|
|
1720
|
-
if (
|
|
1721
|
-
const d = this.randomPick(
|
|
1722
|
-
this.removeWall(r,
|
|
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
|
|
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
|
-
},
|
|
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:
|
|
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:
|
|
1757
|
-
}, u = new
|
|
1758
|
-
for (let
|
|
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() *
|
|
1770
|
+
col: Math.floor(u.random() * l)
|
|
1764
1771
|
};
|
|
1765
|
-
while (g.row ===
|
|
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:
|
|
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: [
|
|
1780
|
-
visitCounts: { [`${
|
|
1786
|
+
playerPath: [a],
|
|
1787
|
+
visitCounts: { [`${a.row},${a.col}`]: 1 }
|
|
1781
1788
|
};
|
|
1782
1789
|
};
|
|
1783
|
-
function
|
|
1784
|
-
const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } = B(), i =
|
|
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 =
|
|
1797
|
+
const h = F(), f = Zt(c, () => {
|
|
1791
1798
|
h.current?.();
|
|
1792
|
-
}),
|
|
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 =
|
|
1806
|
+
const y = pn(
|
|
1800
1807
|
n.currentLevel,
|
|
1801
1808
|
u.current
|
|
1802
1809
|
);
|
|
1803
|
-
y && t((
|
|
1804
|
-
...
|
|
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:
|
|
1820
|
+
}, { updatePlayerPos: v, resetMovingState: m } = en({
|
|
1814
1821
|
containerRef: s,
|
|
1815
1822
|
gamePlayStateRef: e,
|
|
1816
1823
|
setGamePlayState: t,
|
|
1817
|
-
playerRadius:
|
|
1818
|
-
moveSpeed:
|
|
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
|
-
|
|
1830
|
-
}, [n.currentLevel,
|
|
1831
|
-
let y,
|
|
1832
|
-
const
|
|
1833
|
-
const
|
|
1834
|
-
if (!(
|
|
1835
|
-
y = requestAnimationFrame(
|
|
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
|
-
|
|
1839
|
-
},
|
|
1840
|
-
const
|
|
1841
|
-
if (
|
|
1842
|
-
const E = u.current?.wallWidth ||
|
|
1843
|
-
|
|
1844
|
-
...
|
|
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 =
|
|
1853
|
-
const
|
|
1854
|
-
const
|
|
1855
|
-
|
|
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
|
-
}) :
|
|
1867
|
+
}) : b && !C && t({
|
|
1859
1868
|
...e.current,
|
|
1860
1869
|
isGameActive: !1
|
|
1861
1870
|
});
|
|
1862
1871
|
};
|
|
1863
|
-
return document.addEventListener("visibilitychange",
|
|
1864
|
-
cancelAnimationFrame(y), document.removeEventListener("visibilitychange",
|
|
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__ */
|
|
1869
|
-
/* @__PURE__ */
|
|
1870
|
-
/* @__PURE__ */
|
|
1871
|
-
/* @__PURE__ */
|
|
1872
|
-
/* @__PURE__ */
|
|
1873
|
-
/* @__PURE__ */
|
|
1874
|
-
/* @__PURE__ */
|
|
1875
|
-
/* @__PURE__ */
|
|
1876
|
-
/* @__PURE__ */
|
|
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
|
|
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:
|
|
1889
|
-
// exitWallWidth:
|
|
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
|
-
],
|
|
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:
|
|
2106
|
+
levelConfig: it
|
|
2098
2107
|
};
|
|
2099
|
-
function
|
|
2100
|
-
const e = { ...
|
|
2101
|
-
...
|
|
2108
|
+
function Cn({ config: t = {} }) {
|
|
2109
|
+
const e = { ...re.i18n, ...t.i18n || {} }, n = {
|
|
2110
|
+
...re.renderConfig,
|
|
2102
2111
|
...t.renderConfig || {}
|
|
2103
|
-
}, o = t.levelConfig ||
|
|
2104
|
-
...
|
|
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__ */
|
|
2119
|
+
return /* @__PURE__ */ p(bt, { config: i, children: /* @__PURE__ */ p(gn, {}) });
|
|
2111
2120
|
}
|
|
2112
|
-
const
|
|
2113
|
-
root: "https://unpkg.com/@roudanio/maze@0.1.
|
|
2114
|
-
...
|
|
2121
|
+
const wn = {
|
|
2122
|
+
root: "https://unpkg.com/@roudanio/maze@0.1.2/dist/",
|
|
2123
|
+
...re
|
|
2115
2124
|
};
|
|
2116
|
-
`${JSON.stringify(
|
|
2117
|
-
const
|
|
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
|
|
2123
|
-
|
|
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
|
|
2143
|
-
|
|
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(
|
|
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 =
|
|
2150
|
-
}))(o + "maze.css"),
|
|
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
|
-
|
|
2163
|
+
yn as default
|
|
2155
2164
|
};
|