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