astar-visualizer 1.0.9 → 1.1.0
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/astar-visualizer.js +705 -597
- package/dist/astar-visualizer.umd.cjs +5 -5
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/astar-visualizer.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
const
|
|
1
|
+
import { jsx as l, jsxs as w, Fragment as V } from "react/jsx-runtime";
|
|
2
|
+
import L, { useState as j, useEffect as se, useRef as re } from "react";
|
|
3
|
+
const J = (e) => {
|
|
4
4
|
let t;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
if (!Object.is(
|
|
5
|
+
const n = /* @__PURE__ */ new Set(), r = (f, u) => {
|
|
6
|
+
const m = typeof f == "function" ? f(t) : f;
|
|
7
|
+
if (!Object.is(m, t)) {
|
|
8
8
|
const h = t;
|
|
9
|
-
t =
|
|
9
|
+
t = u ?? (typeof m != "object" || m === null) ? m : Object.assign({}, t, m), n.forEach((g) => g(t, h));
|
|
10
10
|
}
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
} }, i = t = e(
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
function
|
|
11
|
+
}, s = () => t, v = { setState: r, getState: s, getInitialState: () => i, subscribe: (f) => (n.add(f), () => n.delete(f)), destroy: () => {
|
|
12
|
+
n.clear();
|
|
13
|
+
} }, i = t = e(r, s, v);
|
|
14
|
+
return v;
|
|
15
|
+
}, oe = (e) => e ? J(e) : J;
|
|
16
|
+
function ie(e) {
|
|
17
17
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
18
18
|
}
|
|
19
|
-
var B = { exports: {} },
|
|
19
|
+
var B = { exports: {} }, z = {}, P = { exports: {} }, W = {};
|
|
20
20
|
/**
|
|
21
21
|
* @license React
|
|
22
22
|
* use-sync-external-store-shim.production.js
|
|
@@ -26,49 +26,49 @@ var B = { exports: {} }, k = {}, V = { exports: {} }, W = {};
|
|
|
26
26
|
* This source code is licensed under the MIT license found in the
|
|
27
27
|
* LICENSE file in the root directory of this source tree.
|
|
28
28
|
*/
|
|
29
|
-
var
|
|
29
|
+
var Y;
|
|
30
30
|
function le() {
|
|
31
|
-
if (
|
|
31
|
+
if (Y)
|
|
32
32
|
return W;
|
|
33
|
-
|
|
34
|
-
var e =
|
|
35
|
-
function t(
|
|
36
|
-
return
|
|
33
|
+
Y = 1;
|
|
34
|
+
var e = L;
|
|
35
|
+
function t(u, m) {
|
|
36
|
+
return u === m && (u !== 0 || 1 / u === 1 / m) || u !== u && m !== m;
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
function p(
|
|
40
|
-
var h =
|
|
41
|
-
return
|
|
38
|
+
var n = typeof Object.is == "function" ? Object.is : t, r = e.useState, s = e.useEffect, a = e.useLayoutEffect, c = e.useDebugValue;
|
|
39
|
+
function p(u, m) {
|
|
40
|
+
var h = m(), g = r({ inst: { value: h, getSnapshot: m } }), d = g[0].inst, y = g[1];
|
|
41
|
+
return a(
|
|
42
42
|
function() {
|
|
43
|
-
d.value = h, d.getSnapshot =
|
|
43
|
+
d.value = h, d.getSnapshot = m, v(d) && y({ inst: d });
|
|
44
44
|
},
|
|
45
|
-
[
|
|
46
|
-
),
|
|
45
|
+
[u, h, m]
|
|
46
|
+
), s(
|
|
47
47
|
function() {
|
|
48
|
-
return
|
|
49
|
-
|
|
48
|
+
return v(d) && y({ inst: d }), u(function() {
|
|
49
|
+
v(d) && y({ inst: d });
|
|
50
50
|
});
|
|
51
51
|
},
|
|
52
|
-
[
|
|
53
|
-
),
|
|
52
|
+
[u]
|
|
53
|
+
), c(h), h;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
var
|
|
57
|
-
|
|
55
|
+
function v(u) {
|
|
56
|
+
var m = u.getSnapshot;
|
|
57
|
+
u = u.value;
|
|
58
58
|
try {
|
|
59
|
-
var h =
|
|
60
|
-
return !
|
|
59
|
+
var h = m();
|
|
60
|
+
return !n(u, h);
|
|
61
61
|
} catch {
|
|
62
62
|
return !0;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
function i(
|
|
66
|
-
return
|
|
65
|
+
function i(u, m) {
|
|
66
|
+
return m();
|
|
67
67
|
}
|
|
68
68
|
var f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? i : p;
|
|
69
69
|
return W.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : f, W;
|
|
70
70
|
}
|
|
71
|
-
var
|
|
71
|
+
var x = {};
|
|
72
72
|
/**
|
|
73
73
|
* @license React
|
|
74
74
|
* use-sync-external-store-shim.development.js
|
|
@@ -78,62 +78,62 @@ var P = {};
|
|
|
78
78
|
* This source code is licensed under the MIT license found in the
|
|
79
79
|
* LICENSE file in the root directory of this source tree.
|
|
80
80
|
*/
|
|
81
|
-
var
|
|
82
|
-
function
|
|
83
|
-
return
|
|
84
|
-
function e(h,
|
|
85
|
-
return h ===
|
|
81
|
+
var Q;
|
|
82
|
+
function ce() {
|
|
83
|
+
return Q || (Q = 1, process.env.NODE_ENV !== "production" && function() {
|
|
84
|
+
function e(h, g) {
|
|
85
|
+
return h === g && (h !== 0 || 1 / h === 1 / g) || h !== h && g !== g;
|
|
86
86
|
}
|
|
87
|
-
function t(h,
|
|
88
|
-
f ||
|
|
87
|
+
function t(h, g) {
|
|
88
|
+
f || s.startTransition === void 0 || (f = !0, console.error(
|
|
89
89
|
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
90
90
|
));
|
|
91
|
-
var d =
|
|
92
|
-
if (!
|
|
93
|
-
var
|
|
94
|
-
|
|
91
|
+
var d = g();
|
|
92
|
+
if (!u) {
|
|
93
|
+
var y = g();
|
|
94
|
+
a(d, y) || (console.error(
|
|
95
95
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
96
|
-
),
|
|
96
|
+
), u = !0);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
inst: { value: d, getSnapshot:
|
|
98
|
+
y = c({
|
|
99
|
+
inst: { value: d, getSnapshot: g }
|
|
100
100
|
});
|
|
101
|
-
var E =
|
|
102
|
-
return
|
|
101
|
+
var E = y[0].inst, _ = y[1];
|
|
102
|
+
return v(
|
|
103
103
|
function() {
|
|
104
|
-
E.value = d, E.getSnapshot =
|
|
104
|
+
E.value = d, E.getSnapshot = g, n(E) && _({ inst: E });
|
|
105
105
|
},
|
|
106
|
-
[h, d,
|
|
106
|
+
[h, d, g]
|
|
107
107
|
), p(
|
|
108
108
|
function() {
|
|
109
|
-
return
|
|
110
|
-
|
|
109
|
+
return n(E) && _({ inst: E }), h(function() {
|
|
110
|
+
n(E) && _({ inst: E });
|
|
111
111
|
});
|
|
112
112
|
},
|
|
113
113
|
[h]
|
|
114
114
|
), i(d), d;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
var
|
|
116
|
+
function n(h) {
|
|
117
|
+
var g = h.getSnapshot;
|
|
118
118
|
h = h.value;
|
|
119
119
|
try {
|
|
120
|
-
var d =
|
|
121
|
-
return !
|
|
120
|
+
var d = g();
|
|
121
|
+
return !a(h, d);
|
|
122
122
|
} catch {
|
|
123
123
|
return !0;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
return
|
|
126
|
+
function r(h, g) {
|
|
127
|
+
return g();
|
|
128
128
|
}
|
|
129
129
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
}()),
|
|
130
|
+
var s = L, a = typeof Object.is == "function" ? Object.is : e, c = s.useState, p = s.useEffect, v = s.useLayoutEffect, i = s.useDebugValue, f = !1, u = !1, m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : t;
|
|
131
|
+
x.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : m, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
132
|
+
}()), x;
|
|
133
133
|
}
|
|
134
|
-
var
|
|
135
|
-
function
|
|
136
|
-
return
|
|
134
|
+
var X;
|
|
135
|
+
function ne() {
|
|
136
|
+
return X || (X = 1, process.env.NODE_ENV === "production" ? P.exports = le() : P.exports = ce()), P.exports;
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* @license React
|
|
@@ -144,59 +144,59 @@ function re() {
|
|
|
144
144
|
* This source code is licensed under the MIT license found in the
|
|
145
145
|
* LICENSE file in the root directory of this source tree.
|
|
146
146
|
*/
|
|
147
|
-
var
|
|
148
|
-
function
|
|
149
|
-
if (
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
var e =
|
|
153
|
-
function
|
|
147
|
+
var Z;
|
|
148
|
+
function ue() {
|
|
149
|
+
if (Z)
|
|
150
|
+
return z;
|
|
151
|
+
Z = 1;
|
|
152
|
+
var e = L, t = ne();
|
|
153
|
+
function n(i, f) {
|
|
154
154
|
return i === f && (i !== 0 || 1 / i === 1 / f) || i !== i && f !== f;
|
|
155
155
|
}
|
|
156
|
-
var
|
|
157
|
-
return
|
|
158
|
-
var
|
|
159
|
-
if (
|
|
156
|
+
var r = typeof Object.is == "function" ? Object.is : n, s = t.useSyncExternalStore, a = e.useRef, c = e.useEffect, p = e.useMemo, v = e.useDebugValue;
|
|
157
|
+
return z.useSyncExternalStoreWithSelector = function(i, f, u, m, h) {
|
|
158
|
+
var g = a(null);
|
|
159
|
+
if (g.current === null) {
|
|
160
160
|
var d = { hasValue: !1, value: null };
|
|
161
|
-
|
|
161
|
+
g.current = d;
|
|
162
162
|
} else
|
|
163
|
-
d =
|
|
164
|
-
|
|
163
|
+
d = g.current;
|
|
164
|
+
g = p(
|
|
165
165
|
function() {
|
|
166
|
-
function E(
|
|
167
|
-
if (!
|
|
168
|
-
if (
|
|
169
|
-
var
|
|
170
|
-
if (h(
|
|
171
|
-
return M =
|
|
166
|
+
function E(S) {
|
|
167
|
+
if (!_) {
|
|
168
|
+
if (_ = !0, b = S, S = m(S), h !== void 0 && d.hasValue) {
|
|
169
|
+
var O = d.value;
|
|
170
|
+
if (h(O, S))
|
|
171
|
+
return M = O;
|
|
172
172
|
}
|
|
173
|
-
return M =
|
|
173
|
+
return M = S;
|
|
174
174
|
}
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
var
|
|
178
|
-
return h !== void 0 && h(
|
|
175
|
+
if (O = M, r(b, S))
|
|
176
|
+
return O;
|
|
177
|
+
var C = m(S);
|
|
178
|
+
return h !== void 0 && h(O, C) ? (b = S, O) : (b = S, M = C);
|
|
179
179
|
}
|
|
180
|
-
var
|
|
180
|
+
var _ = !1, b, M, N = u === void 0 ? null : u;
|
|
181
181
|
return [
|
|
182
182
|
function() {
|
|
183
183
|
return E(f());
|
|
184
184
|
},
|
|
185
|
-
|
|
186
|
-
return E(
|
|
185
|
+
N === null ? void 0 : function() {
|
|
186
|
+
return E(N());
|
|
187
187
|
}
|
|
188
188
|
];
|
|
189
189
|
},
|
|
190
|
-
[f,
|
|
190
|
+
[f, u, m, h]
|
|
191
191
|
);
|
|
192
|
-
var
|
|
193
|
-
return
|
|
192
|
+
var y = s(i, g[0], g[1]);
|
|
193
|
+
return c(
|
|
194
194
|
function() {
|
|
195
|
-
d.hasValue = !0, d.value =
|
|
195
|
+
d.hasValue = !0, d.value = y;
|
|
196
196
|
},
|
|
197
|
-
[
|
|
198
|
-
),
|
|
199
|
-
},
|
|
197
|
+
[y]
|
|
198
|
+
), v(y), y;
|
|
199
|
+
}, z;
|
|
200
200
|
}
|
|
201
201
|
var I = {};
|
|
202
202
|
/**
|
|
@@ -208,152 +208,152 @@ var I = {};
|
|
|
208
208
|
* This source code is licensed under the MIT license found in the
|
|
209
209
|
* LICENSE file in the root directory of this source tree.
|
|
210
210
|
*/
|
|
211
|
-
var
|
|
212
|
-
function
|
|
213
|
-
return
|
|
211
|
+
var ee;
|
|
212
|
+
function de() {
|
|
213
|
+
return ee || (ee = 1, process.env.NODE_ENV !== "production" && function() {
|
|
214
214
|
function e(i, f) {
|
|
215
215
|
return i === f && (i !== 0 || 1 / i === 1 / f) || i !== i && f !== f;
|
|
216
216
|
}
|
|
217
217
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
218
|
-
var t =
|
|
219
|
-
I.useSyncExternalStoreWithSelector = function(i, f,
|
|
220
|
-
var
|
|
221
|
-
if (
|
|
218
|
+
var t = L, n = ne(), r = typeof Object.is == "function" ? Object.is : e, s = n.useSyncExternalStore, a = t.useRef, c = t.useEffect, p = t.useMemo, v = t.useDebugValue;
|
|
219
|
+
I.useSyncExternalStoreWithSelector = function(i, f, u, m, h) {
|
|
220
|
+
var g = a(null);
|
|
221
|
+
if (g.current === null) {
|
|
222
222
|
var d = { hasValue: !1, value: null };
|
|
223
|
-
|
|
223
|
+
g.current = d;
|
|
224
224
|
} else
|
|
225
|
-
d =
|
|
226
|
-
|
|
225
|
+
d = g.current;
|
|
226
|
+
g = p(
|
|
227
227
|
function() {
|
|
228
|
-
function E(
|
|
229
|
-
if (!
|
|
230
|
-
if (
|
|
231
|
-
var
|
|
232
|
-
if (h(
|
|
233
|
-
return M =
|
|
228
|
+
function E(S) {
|
|
229
|
+
if (!_) {
|
|
230
|
+
if (_ = !0, b = S, S = m(S), h !== void 0 && d.hasValue) {
|
|
231
|
+
var O = d.value;
|
|
232
|
+
if (h(O, S))
|
|
233
|
+
return M = O;
|
|
234
234
|
}
|
|
235
|
-
return M =
|
|
235
|
+
return M = S;
|
|
236
236
|
}
|
|
237
|
-
if (
|
|
238
|
-
return
|
|
239
|
-
var
|
|
240
|
-
return h !== void 0 && h(
|
|
237
|
+
if (O = M, r(b, S))
|
|
238
|
+
return O;
|
|
239
|
+
var C = m(S);
|
|
240
|
+
return h !== void 0 && h(O, C) ? (b = S, O) : (b = S, M = C);
|
|
241
241
|
}
|
|
242
|
-
var
|
|
242
|
+
var _ = !1, b, M, N = u === void 0 ? null : u;
|
|
243
243
|
return [
|
|
244
244
|
function() {
|
|
245
245
|
return E(f());
|
|
246
246
|
},
|
|
247
|
-
|
|
248
|
-
return E(
|
|
247
|
+
N === null ? void 0 : function() {
|
|
248
|
+
return E(N());
|
|
249
249
|
}
|
|
250
250
|
];
|
|
251
251
|
},
|
|
252
|
-
[f,
|
|
252
|
+
[f, u, m, h]
|
|
253
253
|
);
|
|
254
|
-
var
|
|
255
|
-
return
|
|
254
|
+
var y = s(i, g[0], g[1]);
|
|
255
|
+
return c(
|
|
256
256
|
function() {
|
|
257
|
-
d.hasValue = !0, d.value =
|
|
257
|
+
d.hasValue = !0, d.value = y;
|
|
258
258
|
},
|
|
259
|
-
[
|
|
260
|
-
),
|
|
259
|
+
[y]
|
|
260
|
+
), v(y), y;
|
|
261
261
|
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
262
262
|
}()), I;
|
|
263
263
|
}
|
|
264
|
-
process.env.NODE_ENV === "production" ? B.exports =
|
|
265
|
-
var
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
function
|
|
269
|
-
const
|
|
264
|
+
process.env.NODE_ENV === "production" ? B.exports = ue() : B.exports = de();
|
|
265
|
+
var me = B.exports;
|
|
266
|
+
const he = /* @__PURE__ */ ie(me), { useDebugValue: fe } = L, { useSyncExternalStoreWithSelector: pe } = he;
|
|
267
|
+
const ve = (e) => e;
|
|
268
|
+
function ge(e, t = ve, n) {
|
|
269
|
+
const r = pe(
|
|
270
270
|
e.subscribe,
|
|
271
271
|
e.getState,
|
|
272
272
|
e.getServerState || e.getInitialState,
|
|
273
273
|
t,
|
|
274
|
-
|
|
274
|
+
n
|
|
275
275
|
);
|
|
276
|
-
return
|
|
276
|
+
return fe(r), r;
|
|
277
277
|
}
|
|
278
|
-
const
|
|
279
|
-
const t = typeof e == "function" ?
|
|
280
|
-
return Object.assign(
|
|
281
|
-
},
|
|
282
|
-
var
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
return Math.floor(10 * Math.sqrt(
|
|
286
|
-
},
|
|
278
|
+
const te = (e) => {
|
|
279
|
+
const t = typeof e == "function" ? oe(e) : e, n = (r, s) => ge(t, r, s);
|
|
280
|
+
return Object.assign(n, t), n;
|
|
281
|
+
}, be = (e) => e ? te(e) : te;
|
|
282
|
+
var o = /* @__PURE__ */ ((e) => (e[e.Empty = 0] = "Empty", e[e.Start = 1] = "Start", e[e.End = 2] = "End", e[e.Obstacle = 3] = "Obstacle", e[e.Visited = 4] = "Visited", e[e.Path = 5] = "Path", e[e.Water = 6] = "Water", e[e.Forest = 7] = "Forest", e[e.Mountain = 8] = "Mountain", e))(o || {}), A = /* @__PURE__ */ ((e) => (e.Classic = "classic", e.Medieval = "medieval", e))(A || {});
|
|
283
|
+
const F = (e, t) => {
|
|
284
|
+
const n = Math.abs(e.row - t.row), r = Math.abs(e.col - t.col);
|
|
285
|
+
return Math.floor(10 * Math.sqrt(n * n + r * r));
|
|
286
|
+
}, we = (e, t) => ({
|
|
287
287
|
row: e.row,
|
|
288
288
|
col: e.col,
|
|
289
289
|
g: 0,
|
|
290
|
-
h:
|
|
291
|
-
f:
|
|
290
|
+
h: F(e, t),
|
|
291
|
+
f: F(e, t),
|
|
292
292
|
parent: null
|
|
293
|
-
}),
|
|
294
|
-
const
|
|
293
|
+
}), Se = (e, t, n) => {
|
|
294
|
+
const r = [
|
|
295
295
|
{ row: e.row - 1, col: e.col },
|
|
296
296
|
{ row: e.row + 1, col: e.col },
|
|
297
297
|
{ row: e.row, col: e.col - 1 },
|
|
298
298
|
{ row: e.row, col: e.col + 1 }
|
|
299
299
|
];
|
|
300
|
-
|
|
300
|
+
n && r.push(
|
|
301
301
|
{ row: e.row - 1, col: e.col - 1 },
|
|
302
302
|
{ row: e.row - 1, col: e.col + 1 },
|
|
303
303
|
{ row: e.row + 1, col: e.col - 1 },
|
|
304
304
|
{ row: e.row + 1, col: e.col + 1 }
|
|
305
305
|
);
|
|
306
|
-
const
|
|
307
|
-
return
|
|
308
|
-
row:
|
|
309
|
-
col:
|
|
310
|
-
state: t[
|
|
306
|
+
const s = [o.Obstacle, o.Water, o.Mountain];
|
|
307
|
+
return r.filter((a) => a.row >= 0 && a.row < t.length && a.col >= 0 && a.col < t[0].length && !s.includes(t[a.row][a.col].state)).map((a) => ({
|
|
308
|
+
row: a.row,
|
|
309
|
+
col: a.col,
|
|
310
|
+
state: t[a.row][a.col].state
|
|
311
311
|
}));
|
|
312
|
-
}, Ee = (e, t,
|
|
313
|
-
const
|
|
314
|
-
return { g:
|
|
315
|
-
},
|
|
312
|
+
}, Ee = (e, t, n) => {
|
|
313
|
+
const r = Math.abs(e.row - t.row), s = Math.abs(e.col - t.col), a = e.g + (r === 0 || s === 0 ? 10 : 14), c = F(t, n), p = a + c;
|
|
314
|
+
return { g: a, h: c, f: p };
|
|
315
|
+
}, Ne = (e) => {
|
|
316
316
|
const t = [];
|
|
317
|
-
let
|
|
318
|
-
for (;
|
|
319
|
-
t.push(
|
|
317
|
+
let n = e;
|
|
318
|
+
for (; n; )
|
|
319
|
+
t.push(n), n = n.parent;
|
|
320
320
|
return t.reverse();
|
|
321
|
-
},
|
|
322
|
-
const
|
|
323
|
-
for (
|
|
324
|
-
|
|
325
|
-
const p =
|
|
326
|
-
if (p.row ===
|
|
327
|
-
return
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
for (const i of
|
|
331
|
-
if (
|
|
321
|
+
}, ye = (e, t, n, r) => {
|
|
322
|
+
const s = [], a = [], c = we(t, n);
|
|
323
|
+
for (s.push(c); s.length > 0; ) {
|
|
324
|
+
s.sort((i, f) => i.f - f.f);
|
|
325
|
+
const p = s.shift();
|
|
326
|
+
if (p.row === n.row && p.col === n.col)
|
|
327
|
+
return a.push(p), { path: Ne(p), visitedNodes: a };
|
|
328
|
+
a.push(p);
|
|
329
|
+
const v = Se(p, e, r);
|
|
330
|
+
for (const i of v) {
|
|
331
|
+
if (a.some((g) => g.row === i.row && g.col === i.col))
|
|
332
332
|
continue;
|
|
333
|
-
const { g: f, h:
|
|
334
|
-
(
|
|
333
|
+
const { g: f, h: u, f: m } = Ee(p, i, n), h = s.find(
|
|
334
|
+
(g) => g.row === i.row && g.col === i.col
|
|
335
335
|
);
|
|
336
336
|
if (!h || f < h.g) {
|
|
337
|
-
const
|
|
337
|
+
const g = {
|
|
338
338
|
row: i.row,
|
|
339
339
|
col: i.col,
|
|
340
340
|
g: f,
|
|
341
|
-
h:
|
|
342
|
-
f:
|
|
341
|
+
h: u,
|
|
342
|
+
f: m,
|
|
343
343
|
parent: p
|
|
344
344
|
};
|
|
345
|
-
h ? (h.g = f, h.f =
|
|
345
|
+
h ? (h.g = f, h.f = m, h.parent = p) : s.push(g);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
-
return { path: [], visitedNodes:
|
|
350
|
-
},
|
|
349
|
+
return { path: [], visitedNodes: a };
|
|
350
|
+
}, _e = (e) => ({
|
|
351
351
|
cells: Array.from(
|
|
352
352
|
{ length: 8 },
|
|
353
|
-
(t,
|
|
354
|
-
row:
|
|
355
|
-
col:
|
|
356
|
-
state:
|
|
353
|
+
(t, n) => Array.from({ length: 12 }, (r, s) => ({
|
|
354
|
+
row: n,
|
|
355
|
+
col: s,
|
|
356
|
+
state: o.Empty
|
|
357
357
|
}))
|
|
358
358
|
),
|
|
359
359
|
rows: 8,
|
|
@@ -364,73 +364,73 @@ const x = (e, t) => {
|
|
|
364
364
|
path: [],
|
|
365
365
|
visitedNodes: [],
|
|
366
366
|
setNumberOfColumns: (t) => {
|
|
367
|
-
e((
|
|
368
|
-
const
|
|
369
|
-
...
|
|
367
|
+
e((n) => {
|
|
368
|
+
const r = n.cells.map((s) => t > n.columns ? [
|
|
369
|
+
...s,
|
|
370
370
|
...Array.from(
|
|
371
|
-
{ length: t -
|
|
372
|
-
(
|
|
373
|
-
row:
|
|
374
|
-
col:
|
|
375
|
-
state:
|
|
371
|
+
{ length: t - n.columns },
|
|
372
|
+
(a, c) => ({
|
|
373
|
+
row: s[0].row,
|
|
374
|
+
col: n.columns + c,
|
|
375
|
+
state: o.Empty
|
|
376
376
|
})
|
|
377
377
|
)
|
|
378
|
-
] :
|
|
378
|
+
] : s.slice(0, t));
|
|
379
379
|
return {
|
|
380
|
-
...
|
|
380
|
+
...n,
|
|
381
381
|
columns: t,
|
|
382
|
-
cells:
|
|
382
|
+
cells: r
|
|
383
383
|
};
|
|
384
384
|
});
|
|
385
385
|
},
|
|
386
386
|
setNumberOfRows: (t) => {
|
|
387
|
-
e((
|
|
388
|
-
let
|
|
389
|
-
return t >
|
|
390
|
-
...
|
|
387
|
+
e((n) => {
|
|
388
|
+
let r = [...n.cells];
|
|
389
|
+
return t > n.rows ? r = [
|
|
390
|
+
...r,
|
|
391
391
|
...Array.from(
|
|
392
|
-
{ length: t -
|
|
393
|
-
(
|
|
394
|
-
row:
|
|
392
|
+
{ length: t - n.rows },
|
|
393
|
+
(s, a) => Array.from({ length: n.columns }, (c, p) => ({
|
|
394
|
+
row: n.rows + a,
|
|
395
395
|
col: p,
|
|
396
|
-
state:
|
|
396
|
+
state: o.Empty
|
|
397
397
|
}))
|
|
398
398
|
)
|
|
399
|
-
] :
|
|
400
|
-
...
|
|
399
|
+
] : r = r.slice(0, t), {
|
|
400
|
+
...n,
|
|
401
401
|
rows: t,
|
|
402
|
-
cells:
|
|
402
|
+
cells: r
|
|
403
403
|
};
|
|
404
404
|
});
|
|
405
405
|
},
|
|
406
|
-
setCellState: (t,
|
|
407
|
-
e((
|
|
408
|
-
const
|
|
406
|
+
setCellState: (t, n, r) => {
|
|
407
|
+
e((s) => {
|
|
408
|
+
const a = s.cells.map(
|
|
409
409
|
(i) => i.map((f) => ({ ...f }))
|
|
410
410
|
);
|
|
411
|
-
let
|
|
412
|
-
switch (
|
|
413
|
-
case
|
|
414
|
-
|
|
411
|
+
let c = s.startTile, p = s.endTile, v = [...s.obstacleTiles];
|
|
412
|
+
switch (r === o.Start && s.startTile && (a[s.startTile.row][s.startTile.col].state = o.Empty, c = null), r === o.End && s.endTile && (a[s.endTile.row][s.endTile.col].state = o.Empty, p = null), a[t][n].state = r, r) {
|
|
413
|
+
case o.Start:
|
|
414
|
+
c = { row: t, col: n };
|
|
415
415
|
break;
|
|
416
|
-
case
|
|
417
|
-
p = { row: t, col:
|
|
416
|
+
case o.End:
|
|
417
|
+
p = { row: t, col: n };
|
|
418
418
|
break;
|
|
419
|
-
case
|
|
420
|
-
|
|
419
|
+
case o.Obstacle:
|
|
420
|
+
v.some((i) => i.row === t && i.col === n) || v.push({ row: t, col: n });
|
|
421
421
|
break;
|
|
422
|
-
case
|
|
423
|
-
|
|
424
|
-
(i) => !(i.row === t && i.col ===
|
|
422
|
+
case o.Empty:
|
|
423
|
+
v = v.filter(
|
|
424
|
+
(i) => !(i.row === t && i.col === n)
|
|
425
425
|
);
|
|
426
426
|
break;
|
|
427
427
|
}
|
|
428
428
|
return {
|
|
429
|
-
...
|
|
430
|
-
cells:
|
|
431
|
-
startTile:
|
|
429
|
+
...s,
|
|
430
|
+
cells: a,
|
|
431
|
+
startTile: c,
|
|
432
432
|
endTile: p,
|
|
433
|
-
obstacleTiles:
|
|
433
|
+
obstacleTiles: v
|
|
434
434
|
};
|
|
435
435
|
});
|
|
436
436
|
},
|
|
@@ -438,9 +438,9 @@ const x = (e, t) => {
|
|
|
438
438
|
e((t) => ({
|
|
439
439
|
...t,
|
|
440
440
|
cells: t.cells.map(
|
|
441
|
-
(
|
|
442
|
-
...
|
|
443
|
-
state:
|
|
441
|
+
(n) => n.map((r) => ({
|
|
442
|
+
...r,
|
|
443
|
+
state: o.Empty
|
|
444
444
|
}))
|
|
445
445
|
),
|
|
446
446
|
startTile: null,
|
|
@@ -451,169 +451,182 @@ const x = (e, t) => {
|
|
|
451
451
|
}));
|
|
452
452
|
},
|
|
453
453
|
handleFindPath: (t) => {
|
|
454
|
-
e((
|
|
455
|
-
const
|
|
456
|
-
if (
|
|
457
|
-
const
|
|
454
|
+
e((n) => {
|
|
455
|
+
const r = n.cells.flat().find((a) => a.state === o.Start), s = n.cells.flat().find((a) => a.state === o.End);
|
|
456
|
+
if (r && s) {
|
|
457
|
+
const a = n.cells.map(
|
|
458
458
|
(i) => i.map((f) => ({
|
|
459
459
|
row: f.row,
|
|
460
460
|
col: f.col,
|
|
461
461
|
state: f.state
|
|
462
462
|
}))
|
|
463
|
-
), { path:
|
|
463
|
+
), { path: c, visitedNodes: p } = ye(a, r, s, t);
|
|
464
464
|
return (async (i, f) => {
|
|
465
|
-
for (let
|
|
466
|
-
await new Promise((
|
|
467
|
-
const h =
|
|
468
|
-
(
|
|
465
|
+
for (let u of f)
|
|
466
|
+
await new Promise((m) => setTimeout(m, 100)), e((m) => {
|
|
467
|
+
const h = m.cells.map(
|
|
468
|
+
(g) => g.map((d) => ({
|
|
469
469
|
...d,
|
|
470
|
-
state:
|
|
470
|
+
state: u.row === d.row && u.col === d.col && d.state === o.Empty ? o.Visited : d.state
|
|
471
471
|
}))
|
|
472
472
|
);
|
|
473
473
|
return {
|
|
474
|
-
...
|
|
474
|
+
...m,
|
|
475
475
|
cells: h,
|
|
476
|
-
visitedNodes: [...
|
|
476
|
+
visitedNodes: [...m.visitedNodes, u]
|
|
477
477
|
};
|
|
478
478
|
});
|
|
479
|
-
for (let
|
|
480
|
-
await new Promise((
|
|
481
|
-
const h =
|
|
482
|
-
(
|
|
479
|
+
for (let u of i)
|
|
480
|
+
await new Promise((m) => setTimeout(m, 250)), e((m) => {
|
|
481
|
+
const h = m.cells.map(
|
|
482
|
+
(g) => g.map((d) => ({
|
|
483
483
|
...d,
|
|
484
|
-
state:
|
|
484
|
+
state: u.row === d.row && u.col === d.col ? o.Path : d.state
|
|
485
485
|
}))
|
|
486
486
|
);
|
|
487
487
|
return {
|
|
488
|
-
...
|
|
488
|
+
...m,
|
|
489
489
|
cells: h,
|
|
490
|
-
path: [...
|
|
490
|
+
path: [...m.path, u]
|
|
491
491
|
};
|
|
492
492
|
});
|
|
493
|
-
})(
|
|
493
|
+
})(c, p), { ...n, path: [], visitedNodes: [] };
|
|
494
494
|
}
|
|
495
|
-
return
|
|
495
|
+
return n;
|
|
496
496
|
});
|
|
497
497
|
},
|
|
498
498
|
setPath: (t) => {
|
|
499
|
-
e((
|
|
500
|
-
const
|
|
501
|
-
(
|
|
502
|
-
...
|
|
503
|
-
state: t.some((
|
|
499
|
+
e((n) => {
|
|
500
|
+
const r = n.cells.map(
|
|
501
|
+
(s) => s.map((a) => ({
|
|
502
|
+
...a,
|
|
503
|
+
state: t.some((c) => c.row === a.row && c.col === a.col) ? o.Path : a.state
|
|
504
504
|
}))
|
|
505
505
|
);
|
|
506
506
|
return {
|
|
507
|
-
...
|
|
508
|
-
cells:
|
|
507
|
+
...n,
|
|
508
|
+
cells: r
|
|
509
509
|
};
|
|
510
510
|
});
|
|
511
511
|
},
|
|
512
512
|
setVisitedNodes: (t) => {
|
|
513
|
-
e((
|
|
514
|
-
const
|
|
515
|
-
(
|
|
516
|
-
...
|
|
517
|
-
state: t.some((
|
|
513
|
+
e((n) => {
|
|
514
|
+
const r = n.cells.map(
|
|
515
|
+
(s) => s.map((a) => ({
|
|
516
|
+
...a,
|
|
517
|
+
state: t.some((c) => c.row === a.row && c.col === a.col) && a.state === o.Empty ? o.Visited : a.state
|
|
518
518
|
}))
|
|
519
519
|
);
|
|
520
520
|
return {
|
|
521
|
-
...
|
|
522
|
-
cells:
|
|
521
|
+
...n,
|
|
522
|
+
cells: r
|
|
523
523
|
};
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
526
|
}), Oe = (e) => ({
|
|
527
|
-
activeButton:
|
|
527
|
+
activeButton: o.Start,
|
|
528
528
|
setSelectedButtonState: (t) => e({ activeButton: t }),
|
|
529
529
|
canTravelDiagonally: !0,
|
|
530
530
|
setCanTravelDiagonally: (t) => e({ canTravelDiagonally: t })
|
|
531
|
-
}),
|
|
532
|
-
visualTheme:
|
|
531
|
+
}), Me = (e) => ({
|
|
532
|
+
visualTheme: A.Medieval,
|
|
533
533
|
showCosts: !1,
|
|
534
534
|
setVisualTheme: (t) => e({ visualTheme: t }),
|
|
535
535
|
setShowCosts: (t) => e({ showCosts: t })
|
|
536
|
-
}),
|
|
537
|
-
|
|
536
|
+
}), Te = (e) => ({
|
|
537
|
+
currentRun: null,
|
|
538
|
+
isAnimating: !1,
|
|
539
|
+
isPaused: !1,
|
|
540
|
+
animationSpeed: 1,
|
|
541
|
+
startAnimation: () => e({ isAnimating: !0, isPaused: !1 }),
|
|
542
|
+
stopAnimation: () => e({ isAnimating: !1, isPaused: !1 }),
|
|
543
|
+
pauseAnimation: () => e({ isPaused: !0 }),
|
|
544
|
+
resumeAnimation: () => e({ isPaused: !1 }),
|
|
545
|
+
setAnimationSpeed: (t) => e({ animationSpeed: t }),
|
|
546
|
+
setCurrentRun: (t) => e({ currentRun: t }),
|
|
547
|
+
clearCurrentRun: () => e({ currentRun: null })
|
|
548
|
+
}), D = be((e, t, n) => ({
|
|
549
|
+
..._e(e),
|
|
538
550
|
...Oe(e),
|
|
539
|
-
...
|
|
540
|
-
|
|
541
|
-
|
|
551
|
+
...Me(e),
|
|
552
|
+
...Te(e)
|
|
553
|
+
})), Ce = {
|
|
554
|
+
id: A.Classic,
|
|
542
555
|
name: "Classic",
|
|
543
556
|
startIcon: "●",
|
|
544
557
|
endIcon: "●",
|
|
545
558
|
terrains: {
|
|
546
|
-
[
|
|
559
|
+
[o.Obstacle]: { name: "Wall", icon: "■", passable: !1 }
|
|
547
560
|
},
|
|
548
561
|
presets: [
|
|
549
|
-
{ id: "random", name: "Random", icon: "
|
|
550
|
-
{ id: "maze", name: "Maze", icon: "
|
|
562
|
+
{ id: "random", name: "Random", icon: "" },
|
|
563
|
+
{ id: "maze", name: "Maze", icon: "" }
|
|
551
564
|
]
|
|
552
|
-
},
|
|
553
|
-
id:
|
|
565
|
+
}, Re = {
|
|
566
|
+
id: A.Medieval,
|
|
554
567
|
name: "Medieval",
|
|
555
568
|
startIcon: "⚔️",
|
|
556
569
|
endIcon: "🏰",
|
|
557
570
|
terrains: {
|
|
558
|
-
[
|
|
559
|
-
[
|
|
560
|
-
[
|
|
561
|
-
[
|
|
571
|
+
[o.Obstacle]: { name: "Wall", icon: "🧱", passable: !1 },
|
|
572
|
+
[o.Water]: { name: "Water", icon: "🌊", passable: !1 },
|
|
573
|
+
[o.Forest]: { name: "Forest", icon: "🌲", passable: !0 },
|
|
574
|
+
[o.Mountain]: { name: "Mountain", icon: "⛰️", passable: !1 }
|
|
562
575
|
},
|
|
563
576
|
presets: [
|
|
564
|
-
{ id: "river", name: "River Crossing", icon: "
|
|
565
|
-
{ id: "mountains", name: "Mountain Range", icon: "
|
|
566
|
-
{ id: "maze", name: "Castle Maze", icon: "
|
|
567
|
-
{ id: "random", name: "Random Forest", icon: "
|
|
577
|
+
{ id: "river", name: "River Crossing", icon: "" },
|
|
578
|
+
{ id: "mountains", name: "Mountain Range", icon: "" },
|
|
579
|
+
{ id: "maze", name: "Castle Maze", icon: "" },
|
|
580
|
+
{ id: "random", name: "Random Forest", icon: "" }
|
|
568
581
|
]
|
|
569
|
-
},
|
|
570
|
-
[
|
|
571
|
-
[
|
|
572
|
-
},
|
|
573
|
-
const t =
|
|
574
|
-
return Object.entries(t.terrains).map(([
|
|
575
|
-
state: Number(
|
|
576
|
-
config:
|
|
582
|
+
}, ae = {
|
|
583
|
+
[A.Classic]: Ce,
|
|
584
|
+
[A.Medieval]: Re
|
|
585
|
+
}, $ = (e) => ae[e], Ae = (e) => {
|
|
586
|
+
const t = $(e);
|
|
587
|
+
return Object.entries(t.terrains).map(([n, r]) => ({
|
|
588
|
+
state: Number(n),
|
|
589
|
+
config: r
|
|
577
590
|
}));
|
|
578
591
|
};
|
|
579
|
-
const
|
|
580
|
-
var
|
|
581
|
-
const { cells: e, activeButton: t, setCellState:
|
|
582
|
-
|
|
592
|
+
const Le = () => {
|
|
593
|
+
var y;
|
|
594
|
+
const { cells: e, activeButton: t, setCellState: n, setSelectedButtonState: r, visitedNodes: s, path: a, visualTheme: c, showCosts: p } = D(), v = $(c), [i, f] = j({ width: 0, height: 0 }), u = L.useRef(null);
|
|
595
|
+
se(() => {
|
|
583
596
|
const E = () => {
|
|
584
|
-
if (
|
|
585
|
-
const
|
|
586
|
-
f({ width:
|
|
597
|
+
if (u.current) {
|
|
598
|
+
const _ = u.current.getBoundingClientRect();
|
|
599
|
+
f({ width: _.width, height: _.height });
|
|
587
600
|
}
|
|
588
601
|
};
|
|
589
602
|
return E(), window.addEventListener("resize", E), () => window.removeEventListener("resize", E);
|
|
590
603
|
}, []);
|
|
591
|
-
const
|
|
592
|
-
switch (
|
|
593
|
-
case
|
|
594
|
-
|
|
604
|
+
const m = (E, _) => {
|
|
605
|
+
switch (n(E, _, t), t) {
|
|
606
|
+
case o.Start:
|
|
607
|
+
r(o.End);
|
|
595
608
|
break;
|
|
596
|
-
case
|
|
597
|
-
|
|
609
|
+
case o.End:
|
|
610
|
+
r(o.Obstacle);
|
|
598
611
|
break;
|
|
599
612
|
}
|
|
600
|
-
}, h = (E,
|
|
601
|
-
const b =
|
|
613
|
+
}, h = (E, _) => {
|
|
614
|
+
const b = s.find((M) => M.row === E && M.col === _);
|
|
602
615
|
return b ? { g: b.g, h: b.h, f: b.f } : { g: null, h: null, f: null };
|
|
603
616
|
}, d = (() => {
|
|
604
|
-
var
|
|
617
|
+
var R;
|
|
605
618
|
if (!i.width || !i.height)
|
|
606
619
|
return 20;
|
|
607
|
-
const E = ((
|
|
608
|
-
return Math.max(15, Math.min(
|
|
620
|
+
const E = ((R = e[0]) == null ? void 0 : R.length) || 1, _ = e.length || 1, b = 20, M = E + _, N = i.width - b - M, S = i.height - b - M, O = N / E, C = S / _, k = Math.min(O, C);
|
|
621
|
+
return Math.max(15, Math.min(k, 60));
|
|
609
622
|
})();
|
|
610
|
-
return /* @__PURE__ */
|
|
623
|
+
return /* @__PURE__ */ l("div", { className: "grid-wrapper", ref: u, children: /* @__PURE__ */ l(
|
|
611
624
|
"div",
|
|
612
625
|
{
|
|
613
626
|
className: "grid-container",
|
|
614
627
|
style: {
|
|
615
628
|
display: "grid",
|
|
616
|
-
gridTemplateColumns: `repeat(${((
|
|
629
|
+
gridTemplateColumns: `repeat(${((y = e[0]) == null ? void 0 : y.length) || 1}, ${d}px)`,
|
|
617
630
|
gridTemplateRows: `repeat(${e.length || 1}, ${d}px)`,
|
|
618
631
|
gap: "1px",
|
|
619
632
|
padding: "8px",
|
|
@@ -623,23 +636,23 @@ const Re = () => {
|
|
|
623
636
|
border: "1px solid var(--border-color)"
|
|
624
637
|
},
|
|
625
638
|
children: e.map(
|
|
626
|
-
(E,
|
|
627
|
-
var
|
|
628
|
-
const
|
|
629
|
-
let
|
|
630
|
-
if (
|
|
631
|
-
const T =
|
|
632
|
-
T === 0 ?
|
|
639
|
+
(E, _) => E.map((b, M) => {
|
|
640
|
+
var G, H, K, U;
|
|
641
|
+
const N = a.some((T) => T.row === b.row && T.col === b.col), S = s.some((T) => T.row === b.row && T.col === b.col), { g: O, h: C, f: k } = h(b.row, b.col);
|
|
642
|
+
let R = De(b, S);
|
|
643
|
+
if (N) {
|
|
644
|
+
const T = a.findIndex((q) => q.row === b.row && q.col === b.col);
|
|
645
|
+
T === 0 ? R = "var(--cell-start)" : T === a.length - 1 ? R = "var(--cell-end)" : R = "var(--cell-path)";
|
|
633
646
|
}
|
|
634
|
-
return /* @__PURE__ */
|
|
647
|
+
return /* @__PURE__ */ w(
|
|
635
648
|
"div",
|
|
636
649
|
{
|
|
637
650
|
className: "grid-cell",
|
|
638
|
-
onClick: () =>
|
|
651
|
+
onClick: () => m(_, M),
|
|
639
652
|
style: {
|
|
640
653
|
width: d,
|
|
641
654
|
height: d,
|
|
642
|
-
backgroundColor:
|
|
655
|
+
backgroundColor: R,
|
|
643
656
|
border: "1px solid var(--cell-border)",
|
|
644
657
|
cursor: "pointer",
|
|
645
658
|
transition: "all 0.15s ease",
|
|
@@ -650,373 +663,468 @@ const Re = () => {
|
|
|
650
663
|
borderRadius: "2px"
|
|
651
664
|
},
|
|
652
665
|
onMouseEnter: (T) => {
|
|
653
|
-
b.state ===
|
|
666
|
+
b.state === o.Empty && (T.currentTarget.style.backgroundColor = "var(--bg-tertiary)", T.currentTarget.style.transform = "scale(1.02)");
|
|
654
667
|
},
|
|
655
668
|
onMouseLeave: (T) => {
|
|
656
|
-
b.state ===
|
|
669
|
+
b.state === o.Empty && (T.currentTarget.style.backgroundColor = R, T.currentTarget.style.transform = "scale(1)");
|
|
657
670
|
},
|
|
658
671
|
children: [
|
|
659
|
-
|
|
660
|
-
/* @__PURE__ */
|
|
672
|
+
S && p && /* @__PURE__ */ w("div", { className: "cell-values", children: [
|
|
673
|
+
/* @__PURE__ */ w("div", { className: "value-h", children: [
|
|
661
674
|
"h",
|
|
662
|
-
|
|
675
|
+
C
|
|
663
676
|
] }),
|
|
664
|
-
/* @__PURE__ */
|
|
677
|
+
/* @__PURE__ */ w("div", { className: "value-f", children: [
|
|
665
678
|
"f",
|
|
666
|
-
|
|
679
|
+
k
|
|
667
680
|
] }),
|
|
668
|
-
/* @__PURE__ */
|
|
681
|
+
/* @__PURE__ */ w("div", { className: "value-g", children: [
|
|
669
682
|
"g",
|
|
670
|
-
|
|
683
|
+
O
|
|
671
684
|
] })
|
|
672
685
|
] }),
|
|
673
|
-
b.state ===
|
|
674
|
-
b.state ===
|
|
675
|
-
b.state ===
|
|
676
|
-
b.state ===
|
|
677
|
-
b.state ===
|
|
678
|
-
b.state ===
|
|
686
|
+
b.state === o.Start && /* @__PURE__ */ l("div", { className: "cell-indicator start", style: { fontSize: d * 0.7 }, children: v.startIcon }),
|
|
687
|
+
b.state === o.End && /* @__PURE__ */ l("div", { className: "cell-indicator end", style: { fontSize: d * 0.7 }, children: v.endIcon }),
|
|
688
|
+
b.state === o.Obstacle && /* @__PURE__ */ l("div", { className: "cell-indicator obstacle", style: { fontSize: d * 0.7 }, children: ((G = v.terrains[o.Obstacle]) == null ? void 0 : G.icon) || "■" }),
|
|
689
|
+
b.state === o.Water && /* @__PURE__ */ l("div", { className: "cell-indicator water", style: { fontSize: d * 0.7 }, children: ((H = v.terrains[o.Water]) == null ? void 0 : H.icon) || "🌊" }),
|
|
690
|
+
b.state === o.Forest && /* @__PURE__ */ l("div", { className: "cell-indicator forest", style: { fontSize: d * 0.7 }, children: ((K = v.terrains[o.Forest]) == null ? void 0 : K.icon) || "🌲" }),
|
|
691
|
+
b.state === o.Mountain && /* @__PURE__ */ l("div", { className: "cell-indicator mountain", style: { fontSize: d * 0.7 }, children: ((U = v.terrains[o.Mountain]) == null ? void 0 : U.icon) || "⛰️" })
|
|
679
692
|
]
|
|
680
693
|
},
|
|
681
|
-
`${
|
|
694
|
+
`${_}-${M}`
|
|
682
695
|
);
|
|
683
696
|
})
|
|
684
697
|
)
|
|
685
698
|
}
|
|
686
699
|
) });
|
|
687
|
-
},
|
|
700
|
+
}, De = (e, t) => {
|
|
688
701
|
if (t)
|
|
689
|
-
return e.state ===
|
|
702
|
+
return e.state === o.Start ? "var(--cell-start)" : e.state === o.End ? "var(--cell-end)" : "var(--cell-visited)";
|
|
690
703
|
switch (e.state) {
|
|
691
|
-
case
|
|
704
|
+
case o.Start:
|
|
692
705
|
return "var(--cell-start)";
|
|
693
|
-
case
|
|
706
|
+
case o.End:
|
|
694
707
|
return "var(--cell-end)";
|
|
695
|
-
case
|
|
708
|
+
case o.Obstacle:
|
|
696
709
|
return "var(--cell-obstacle)";
|
|
697
|
-
case
|
|
710
|
+
case o.Water:
|
|
698
711
|
return "var(--cell-water)";
|
|
699
|
-
case
|
|
712
|
+
case o.Forest:
|
|
700
713
|
return "var(--cell-forest)";
|
|
701
|
-
case
|
|
714
|
+
case o.Mountain:
|
|
702
715
|
return "var(--cell-mountain)";
|
|
703
|
-
case
|
|
716
|
+
case o.Empty:
|
|
704
717
|
return "var(--cell-empty)";
|
|
705
718
|
default:
|
|
706
719
|
return "var(--cell-empty)";
|
|
707
720
|
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
721
|
+
};
|
|
722
|
+
const Pe = () => {
|
|
723
|
+
const {
|
|
724
|
+
activeButton: e,
|
|
725
|
+
setSelectedButtonState: t,
|
|
726
|
+
handleFindPath: n,
|
|
727
|
+
canTravelDiagonally: r,
|
|
728
|
+
resetCells: s
|
|
729
|
+
} = D(), a = [
|
|
730
|
+
{ label: "Start", state: o.Start, className: "start" },
|
|
731
|
+
{ label: "End", state: o.End, className: "end" },
|
|
732
|
+
{ label: "Wall", state: o.Obstacle, className: "wall" },
|
|
733
|
+
{ label: "Erase", state: o.Empty, className: "erase" }
|
|
734
|
+
], c = () => {
|
|
735
|
+
n(r);
|
|
736
|
+
}, p = () => {
|
|
737
|
+
s(), t(o.Start);
|
|
738
|
+
};
|
|
739
|
+
return /* @__PURE__ */ w("div", { className: "toolbar", children: [
|
|
740
|
+
/* @__PURE__ */ l("div", { className: "toolbar-section tools", children: a.map(({ label: v, state: i, className: f }) => /* @__PURE__ */ l(
|
|
741
|
+
"button",
|
|
742
|
+
{
|
|
743
|
+
className: `toolbar-button ${f} ${e === i ? "active" : ""}`,
|
|
744
|
+
onClick: () => t(i),
|
|
745
|
+
children: v
|
|
746
|
+
},
|
|
747
|
+
v
|
|
748
|
+
)) }),
|
|
749
|
+
/* @__PURE__ */ l("div", { className: "toolbar-divider" }),
|
|
750
|
+
/* @__PURE__ */ l(
|
|
751
|
+
"button",
|
|
752
|
+
{
|
|
753
|
+
className: "toolbar-button reset",
|
|
754
|
+
onClick: p,
|
|
755
|
+
children: "Clear All"
|
|
756
|
+
}
|
|
757
|
+
),
|
|
758
|
+
/* @__PURE__ */ l("div", { className: "toolbar-spacer" }),
|
|
759
|
+
/* @__PURE__ */ l(
|
|
760
|
+
"button",
|
|
761
|
+
{
|
|
762
|
+
className: "toolbar-button primary find-path",
|
|
763
|
+
onClick: c,
|
|
764
|
+
children: "Find Path"
|
|
765
|
+
}
|
|
766
|
+
)
|
|
767
|
+
] });
|
|
768
|
+
};
|
|
769
|
+
const ke = () => {
|
|
770
|
+
var v;
|
|
771
|
+
const { currentRun: e, isAnimating: t, visitedNodes: n, path: r } = D(), s = (e == null ? void 0 : e.nodesExplored) ?? n.length, a = (e == null ? void 0 : e.pathLength) ?? r.length, c = a > 0 && s > 0 ? (a / s * 100).toFixed(1) : null, p = ((v = e == null ? void 0 : e.executionTimeMs) == null ? void 0 : v.toFixed(0)) ?? null;
|
|
772
|
+
return s === 0 && a === 0 && !t ? null : /* @__PURE__ */ l("div", { className: "stats-panel", children: /* @__PURE__ */ w("div", { className: "stats-container", children: [
|
|
773
|
+
/* @__PURE__ */ w("div", { className: "stat-item", children: [
|
|
774
|
+
/* @__PURE__ */ l("span", { className: "stat-label", children: "Nodes Explored" }),
|
|
775
|
+
/* @__PURE__ */ l("span", { className: "stat-value", children: s })
|
|
776
|
+
] }),
|
|
777
|
+
/* @__PURE__ */ l("div", { className: "stat-divider" }),
|
|
778
|
+
/* @__PURE__ */ w("div", { className: "stat-item", children: [
|
|
779
|
+
/* @__PURE__ */ l("span", { className: "stat-label", children: "Path Length" }),
|
|
780
|
+
/* @__PURE__ */ l("span", { className: "stat-value", children: a > 0 ? a : "—" })
|
|
781
|
+
] }),
|
|
782
|
+
c && /* @__PURE__ */ w(V, { children: [
|
|
783
|
+
/* @__PURE__ */ l("div", { className: "stat-divider" }),
|
|
784
|
+
/* @__PURE__ */ w("div", { className: "stat-item", children: [
|
|
785
|
+
/* @__PURE__ */ l("span", { className: "stat-label", children: "Efficiency" }),
|
|
786
|
+
/* @__PURE__ */ w("span", { className: "stat-value", children: [
|
|
787
|
+
c,
|
|
788
|
+
"%"
|
|
789
|
+
] })
|
|
790
|
+
] })
|
|
791
|
+
] }),
|
|
792
|
+
p && /* @__PURE__ */ w(V, { children: [
|
|
793
|
+
/* @__PURE__ */ l("div", { className: "stat-divider" }),
|
|
794
|
+
/* @__PURE__ */ w("div", { className: "stat-item", children: [
|
|
795
|
+
/* @__PURE__ */ l("span", { className: "stat-label", children: "Time" }),
|
|
796
|
+
/* @__PURE__ */ w("span", { className: "stat-value", children: [
|
|
797
|
+
p,
|
|
798
|
+
"ms"
|
|
799
|
+
] })
|
|
800
|
+
] })
|
|
801
|
+
] }),
|
|
802
|
+
t && /* @__PURE__ */ w(V, { children: [
|
|
803
|
+
/* @__PURE__ */ l("div", { className: "stat-divider" }),
|
|
804
|
+
/* @__PURE__ */ l("div", { className: "stat-item status", children: /* @__PURE__ */ l("span", { className: "stat-status animating", children: "Running..." }) })
|
|
805
|
+
] })
|
|
806
|
+
] }) });
|
|
807
|
+
}, Ve = (e, t) => {
|
|
808
|
+
const n = [], r = Math.floor(e / 2), s = Math.max(2, Math.floor(t / 6)), a = [];
|
|
809
|
+
for (let c = 0; c < s; c++) {
|
|
810
|
+
const p = Math.floor(t / (s + 1) * (c + 1));
|
|
811
|
+
a.push(p);
|
|
713
812
|
}
|
|
714
|
-
for (let
|
|
715
|
-
|
|
716
|
-
for (let
|
|
717
|
-
|
|
718
|
-
return
|
|
719
|
-
},
|
|
720
|
-
const
|
|
813
|
+
for (let c = 0; c < t; c++)
|
|
814
|
+
a.includes(c) || (n.push({ row: r, col: c, state: o.Water }), r + 1 < e && n.push({ row: r + 1, col: c, state: o.Water }));
|
|
815
|
+
for (let c = 0; c < t; c += 3)
|
|
816
|
+
r - 1 >= 0 && Math.random() > 0.5 && n.push({ row: r - 1, col: c, state: o.Forest }), r + 2 < e && Math.random() > 0.5 && n.push({ row: r + 2, col: c, state: o.Forest });
|
|
817
|
+
return n;
|
|
818
|
+
}, ze = (e, t) => {
|
|
819
|
+
const n = [], r = Math.floor(e * 0.2), s = Math.floor(t * 0.1), a = Math.floor(e * 0.8), c = Math.floor(t * 0.9), p = Math.max(2, Math.floor(Math.min(e, t) / 5)), v = [];
|
|
721
820
|
for (let i = 0; i < p; i++)
|
|
722
|
-
|
|
723
|
-
for (let i =
|
|
724
|
-
const f = (i -
|
|
725
|
-
|
|
821
|
+
v.push(Math.floor((c - s) / (p + 1) * (i + 1)) + s);
|
|
822
|
+
for (let i = s; i <= c; i++) {
|
|
823
|
+
const f = (i - s) / (c - s), u = Math.floor(r + (a - r) * f);
|
|
824
|
+
v.some((m) => Math.abs(i - m) <= 1) || (u >= 0 && u < e && n.push({ row: u, col: i, state: o.Mountain }), u + 1 < e && Math.random() > 0.3 && n.push({ row: u + 1, col: i, state: o.Mountain }), u - 1 >= 0 && Math.random() > 0.3 && n.push({ row: u - 1, col: i, state: o.Mountain }));
|
|
726
825
|
}
|
|
727
|
-
for (const i of [...
|
|
728
|
-
if (i.state ===
|
|
826
|
+
for (const i of [...n])
|
|
827
|
+
if (i.state === o.Mountain) {
|
|
729
828
|
const f = [
|
|
730
829
|
{ row: i.row - 2, col: i.col },
|
|
731
830
|
{ row: i.row + 2, col: i.col },
|
|
732
831
|
{ row: i.row, col: i.col - 2 },
|
|
733
832
|
{ row: i.row, col: i.col + 2 }
|
|
734
833
|
];
|
|
735
|
-
for (const
|
|
736
|
-
|
|
834
|
+
for (const u of f)
|
|
835
|
+
u.row >= 0 && u.row < e && u.col >= 0 && u.col < t && Math.random() > 0.7 && (n.some((m) => m.row === u.row && m.col === u.col) || n.push({ row: u.row, col: u.col, state: o.Forest }));
|
|
737
836
|
}
|
|
738
|
-
return
|
|
739
|
-
},
|
|
740
|
-
const
|
|
741
|
-
for (let
|
|
742
|
-
for (let
|
|
743
|
-
const
|
|
744
|
-
(
|
|
837
|
+
return n;
|
|
838
|
+
}, We = (e, t) => {
|
|
839
|
+
const n = [];
|
|
840
|
+
for (let s = 0; s < e; s++)
|
|
841
|
+
for (let a = 0; a < t; a++) {
|
|
842
|
+
const c = s % 3 === 1, p = a % 3 === 1;
|
|
843
|
+
(c || p) && Math.random() > 0.35 && n.push({ row: s, col: a, state: o.Obstacle });
|
|
745
844
|
}
|
|
746
|
-
const
|
|
747
|
-
return
|
|
748
|
-
const
|
|
749
|
-
return !
|
|
845
|
+
const r = 2;
|
|
846
|
+
return n.filter((s) => {
|
|
847
|
+
const a = s.row < r && s.col < r, c = s.row >= e - r && s.col >= t - r;
|
|
848
|
+
return !a && !c;
|
|
750
849
|
});
|
|
751
|
-
},
|
|
752
|
-
const
|
|
753
|
-
for (let
|
|
754
|
-
for (let
|
|
755
|
-
if (!(
|
|
850
|
+
}, xe = (e, t, n = 0.25) => {
|
|
851
|
+
const r = [];
|
|
852
|
+
for (let s = 0; s < e; s++)
|
|
853
|
+
for (let a = 0; a < t; a++)
|
|
854
|
+
if (!(s < 2 && a < 2 || s >= e - 2 && a >= t - 2) && Math.random() < n) {
|
|
756
855
|
const p = Math.random();
|
|
757
|
-
let
|
|
758
|
-
p < 0.4 ?
|
|
856
|
+
let v;
|
|
857
|
+
p < 0.4 ? v = o.Forest : p < 0.6 ? v = o.Obstacle : p < 0.8 ? v = o.Water : v = o.Mountain, r.push({ row: s, col: a, state: v });
|
|
759
858
|
}
|
|
760
|
-
return
|
|
761
|
-
},
|
|
762
|
-
const s = [];
|
|
763
|
-
for (let n = 0; n < e; n++)
|
|
764
|
-
for (let o = 0; o < t; o++)
|
|
765
|
-
!(n < 2 && o < 2 || n >= e - 2 && o >= t - 2) && Math.random() < r && s.push({ row: n, col: o, state: a.Obstacle });
|
|
766
|
-
return s;
|
|
767
|
-
}, We = (e, t) => {
|
|
859
|
+
return r;
|
|
860
|
+
}, Ie = (e, t, n = 0.2) => {
|
|
768
861
|
const r = [];
|
|
769
|
-
for (let
|
|
770
|
-
for (let
|
|
771
|
-
|
|
772
|
-
|
|
862
|
+
for (let s = 0; s < e; s++)
|
|
863
|
+
for (let a = 0; a < t; a++)
|
|
864
|
+
!(s < 2 && a < 2 || s >= e - 2 && a >= t - 2) && Math.random() < n && r.push({ row: s, col: a, state: o.Obstacle });
|
|
865
|
+
return r;
|
|
866
|
+
}, Be = (e, t) => {
|
|
867
|
+
const n = [];
|
|
868
|
+
for (let s = 0; s < e; s++)
|
|
869
|
+
for (let a = 0; a < t; a++) {
|
|
870
|
+
const c = s % 3 === 1, p = a % 3 === 1;
|
|
871
|
+
(c || p) && Math.random() > 0.35 && n.push({ row: s, col: a, state: o.Obstacle });
|
|
773
872
|
}
|
|
774
|
-
const
|
|
775
|
-
return
|
|
776
|
-
const
|
|
777
|
-
return !
|
|
873
|
+
const r = 2;
|
|
874
|
+
return n.filter((s) => {
|
|
875
|
+
const a = s.row < r && s.col < r, c = s.row >= e - r && s.col >= t - r;
|
|
876
|
+
return !a && !c;
|
|
778
877
|
});
|
|
779
878
|
};
|
|
780
|
-
const
|
|
781
|
-
const {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
setNumberOfColumns: w,
|
|
789
|
-
handleFindPath: i,
|
|
879
|
+
const Fe = ({ isDarkMode: e, setIsDarkMode: t }) => {
|
|
880
|
+
const [n, r] = j(!1), {
|
|
881
|
+
rows: s,
|
|
882
|
+
columns: a,
|
|
883
|
+
setNumberOfRows: c,
|
|
884
|
+
setNumberOfColumns: p,
|
|
885
|
+
visualTheme: v,
|
|
886
|
+
setVisualTheme: i,
|
|
790
887
|
canTravelDiagonally: f,
|
|
791
|
-
setCanTravelDiagonally:
|
|
792
|
-
visualTheme: u,
|
|
793
|
-
setVisualTheme: h,
|
|
888
|
+
setCanTravelDiagonally: u,
|
|
794
889
|
showCosts: m,
|
|
795
|
-
setShowCosts:
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
], R = (g) => {
|
|
806
|
-
g === null ? _() : s(g);
|
|
807
|
-
}, _ = () => {
|
|
808
|
-
n(), s(a.Start);
|
|
809
|
-
}, C = () => {
|
|
810
|
-
i(f);
|
|
811
|
-
}, L = (g) => {
|
|
812
|
-
n();
|
|
813
|
-
let O;
|
|
814
|
-
if (u === z.Medieval)
|
|
815
|
-
switch (g) {
|
|
890
|
+
setShowCosts: h,
|
|
891
|
+
activeButton: g,
|
|
892
|
+
setSelectedButtonState: d,
|
|
893
|
+
setCellState: y,
|
|
894
|
+
resetCells: E
|
|
895
|
+
} = D(), _ = $(v), b = Ae(v), M = (N) => {
|
|
896
|
+
E();
|
|
897
|
+
let S;
|
|
898
|
+
if (v === A.Medieval)
|
|
899
|
+
switch (N) {
|
|
816
900
|
case "river":
|
|
817
|
-
|
|
901
|
+
S = Ve(s, a);
|
|
818
902
|
break;
|
|
819
903
|
case "mountains":
|
|
820
|
-
|
|
904
|
+
S = ze(s, a);
|
|
821
905
|
break;
|
|
822
906
|
case "maze":
|
|
823
|
-
|
|
907
|
+
S = We(s, a);
|
|
824
908
|
break;
|
|
825
909
|
case "random":
|
|
826
|
-
|
|
910
|
+
S = xe(s, a);
|
|
827
911
|
break;
|
|
828
912
|
default:
|
|
829
913
|
return;
|
|
830
914
|
}
|
|
831
915
|
else
|
|
832
|
-
switch (
|
|
916
|
+
switch (N) {
|
|
833
917
|
case "random":
|
|
834
|
-
|
|
918
|
+
S = Ie(s, a);
|
|
835
919
|
break;
|
|
836
920
|
case "maze":
|
|
837
|
-
|
|
921
|
+
S = Be(s, a);
|
|
838
922
|
break;
|
|
839
923
|
default:
|
|
840
924
|
return;
|
|
841
925
|
}
|
|
842
|
-
for (const
|
|
843
|
-
|
|
844
|
-
|
|
926
|
+
for (const O of S)
|
|
927
|
+
y(O.row, O.col, O.state);
|
|
928
|
+
y(0, 0, o.Start), y(s - 1, a - 1, o.End), d(o.Obstacle);
|
|
845
929
|
};
|
|
846
|
-
return /* @__PURE__ */
|
|
847
|
-
/* @__PURE__ */
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
O
|
|
889
|
-
)) })
|
|
890
|
-
] }),
|
|
891
|
-
u === z.Medieval && /* @__PURE__ */ N("div", { className: "control-group terrain", children: [
|
|
892
|
-
/* @__PURE__ */ v("h3", { className: "group-title", children: "Terrain" }),
|
|
893
|
-
/* @__PURE__ */ v("div", { className: "button-group", children: y.filter(({ state: g }) => g !== a.Obstacle).map(({ state: g, config: O }) => /* @__PURE__ */ N(
|
|
894
|
-
"button",
|
|
895
|
-
{
|
|
896
|
-
className: `control-button terrain-btn ${O.name.toLowerCase()} ${r === g ? "active" : ""}`,
|
|
897
|
-
onClick: () => s(g),
|
|
898
|
-
title: O.passable ? "Passable terrain" : "Impassable terrain",
|
|
899
|
-
children: [
|
|
900
|
-
O.icon,
|
|
901
|
-
" ",
|
|
902
|
-
O.name
|
|
903
|
-
]
|
|
904
|
-
},
|
|
905
|
-
g
|
|
906
|
-
)) })
|
|
907
|
-
] }),
|
|
908
|
-
/* @__PURE__ */ N("div", { className: "control-group presets", children: [
|
|
909
|
-
/* @__PURE__ */ v("h3", { className: "group-title", children: "Generate Map" }),
|
|
910
|
-
/* @__PURE__ */ v("div", { className: "button-group", children: E.presets.map((g) => /* @__PURE__ */ N(
|
|
911
|
-
"button",
|
|
912
|
-
{
|
|
913
|
-
className: "control-button preset-btn",
|
|
914
|
-
onClick: () => L(g.id),
|
|
915
|
-
children: [
|
|
916
|
-
g.icon,
|
|
917
|
-
" ",
|
|
918
|
-
g.name
|
|
919
|
-
]
|
|
920
|
-
},
|
|
921
|
-
g.id
|
|
922
|
-
)) })
|
|
923
|
-
] }),
|
|
924
|
-
/* @__PURE__ */ N("div", { className: "control-group actions", children: [
|
|
925
|
-
/* @__PURE__ */ v("h3", { className: "group-title", children: "Actions" }),
|
|
926
|
-
/* @__PURE__ */ N("div", { className: "button-group", children: [
|
|
927
|
-
/* @__PURE__ */ v(
|
|
928
|
-
"button",
|
|
929
|
-
{
|
|
930
|
-
className: "control-button find-path",
|
|
931
|
-
onClick: C,
|
|
932
|
-
children: "Find Path"
|
|
933
|
-
}
|
|
934
|
-
),
|
|
935
|
-
/* @__PURE__ */ v(
|
|
936
|
-
"button",
|
|
937
|
-
{
|
|
938
|
-
className: `control-button diagonal ${f ? "active" : ""}`,
|
|
939
|
-
onClick: () => c(!f),
|
|
940
|
-
children: f ? "Diagonal On" : "Diagonal Off"
|
|
941
|
-
}
|
|
942
|
-
)
|
|
943
|
-
] })
|
|
944
|
-
] }),
|
|
945
|
-
/* @__PURE__ */ N("div", { className: "control-group size", children: [
|
|
946
|
-
/* @__PURE__ */ v("h3", { className: "group-title", children: "Grid Size" }),
|
|
947
|
-
/* @__PURE__ */ N("div", { className: "size-controls", children: [
|
|
948
|
-
/* @__PURE__ */ N("div", { className: "size-control", children: [
|
|
949
|
-
/* @__PURE__ */ v("label", { className: "size-label", children: "Rows" }),
|
|
950
|
-
/* @__PURE__ */ N("div", { className: "size-buttons", children: [
|
|
951
|
-
/* @__PURE__ */ v(
|
|
930
|
+
return /* @__PURE__ */ w("div", { className: `settings-container ${n ? "open" : ""}`, children: [
|
|
931
|
+
/* @__PURE__ */ w(
|
|
932
|
+
"button",
|
|
933
|
+
{
|
|
934
|
+
className: "settings-toggle",
|
|
935
|
+
onClick: () => r(!n),
|
|
936
|
+
"aria-label": "Toggle settings",
|
|
937
|
+
"aria-expanded": n,
|
|
938
|
+
children: [
|
|
939
|
+
/* @__PURE__ */ l("span", { className: "settings-icon", children: "⚙" }),
|
|
940
|
+
/* @__PURE__ */ l("span", { className: "settings-label", children: "Settings" }),
|
|
941
|
+
/* @__PURE__ */ l("span", { className: `settings-chevron ${n ? "open" : ""}`, children: "▼" })
|
|
942
|
+
]
|
|
943
|
+
}
|
|
944
|
+
),
|
|
945
|
+
n && /* @__PURE__ */ l("div", { className: "settings-panel", children: /* @__PURE__ */ w("div", { className: "settings-content", children: [
|
|
946
|
+
/* @__PURE__ */ w("div", { className: "settings-section", children: [
|
|
947
|
+
/* @__PURE__ */ l("h3", { className: "settings-section-title", children: "Appearance" }),
|
|
948
|
+
/* @__PURE__ */ w("div", { className: "settings-row", children: [
|
|
949
|
+
/* @__PURE__ */ l("label", { children: "Theme" }),
|
|
950
|
+
/* @__PURE__ */ l(
|
|
951
|
+
"select",
|
|
952
|
+
{
|
|
953
|
+
className: "settings-select",
|
|
954
|
+
value: v,
|
|
955
|
+
onChange: (N) => i(N.target.value),
|
|
956
|
+
children: Object.values(ae).map((N) => /* @__PURE__ */ l("option", { value: N.id, children: N.name }, N.id))
|
|
957
|
+
}
|
|
958
|
+
)
|
|
959
|
+
] }),
|
|
960
|
+
/* @__PURE__ */ w("div", { className: "settings-row", children: [
|
|
961
|
+
/* @__PURE__ */ l("label", { children: "Color Mode" }),
|
|
962
|
+
/* @__PURE__ */ w("div", { className: "settings-toggle-group", children: [
|
|
963
|
+
/* @__PURE__ */ l(
|
|
964
|
+
"button",
|
|
965
|
+
{
|
|
966
|
+
className: `settings-toggle-btn ${e ? "" : "active"}`,
|
|
967
|
+
onClick: () => t(!1),
|
|
968
|
+
children: "Light"
|
|
969
|
+
}
|
|
970
|
+
),
|
|
971
|
+
/* @__PURE__ */ l(
|
|
952
972
|
"button",
|
|
953
973
|
{
|
|
954
|
-
className:
|
|
955
|
-
onClick: () =>
|
|
956
|
-
|
|
974
|
+
className: `settings-toggle-btn ${e ? "active" : ""}`,
|
|
975
|
+
onClick: () => t(!0),
|
|
976
|
+
children: "Dark"
|
|
977
|
+
}
|
|
978
|
+
)
|
|
979
|
+
] })
|
|
980
|
+
] })
|
|
981
|
+
] }),
|
|
982
|
+
/* @__PURE__ */ w("div", { className: "settings-section", children: [
|
|
983
|
+
/* @__PURE__ */ l("h3", { className: "settings-section-title", children: "Grid" }),
|
|
984
|
+
/* @__PURE__ */ w("div", { className: "settings-row", children: [
|
|
985
|
+
/* @__PURE__ */ l("label", { children: "Rows" }),
|
|
986
|
+
/* @__PURE__ */ w("div", { className: "settings-stepper", children: [
|
|
987
|
+
/* @__PURE__ */ l(
|
|
988
|
+
"button",
|
|
989
|
+
{
|
|
990
|
+
onClick: () => c(Math.max(5, s - 1)),
|
|
991
|
+
disabled: s <= 5,
|
|
957
992
|
children: "−"
|
|
958
993
|
}
|
|
959
994
|
),
|
|
960
|
-
/* @__PURE__ */
|
|
961
|
-
/* @__PURE__ */
|
|
995
|
+
/* @__PURE__ */ l("span", { className: "stepper-value", children: s }),
|
|
996
|
+
/* @__PURE__ */ l(
|
|
962
997
|
"button",
|
|
963
998
|
{
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
disabled: o >= 50,
|
|
999
|
+
onClick: () => c(Math.min(50, s + 1)),
|
|
1000
|
+
disabled: s >= 50,
|
|
967
1001
|
children: "+"
|
|
968
1002
|
}
|
|
969
1003
|
)
|
|
970
1004
|
] })
|
|
971
1005
|
] }),
|
|
972
|
-
/* @__PURE__ */
|
|
973
|
-
/* @__PURE__ */
|
|
974
|
-
/* @__PURE__ */
|
|
975
|
-
/* @__PURE__ */
|
|
1006
|
+
/* @__PURE__ */ w("div", { className: "settings-row", children: [
|
|
1007
|
+
/* @__PURE__ */ l("label", { children: "Columns" }),
|
|
1008
|
+
/* @__PURE__ */ w("div", { className: "settings-stepper", children: [
|
|
1009
|
+
/* @__PURE__ */ l(
|
|
976
1010
|
"button",
|
|
977
1011
|
{
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
disabled: l <= 5,
|
|
1012
|
+
onClick: () => p(Math.max(5, a - 1)),
|
|
1013
|
+
disabled: a <= 5,
|
|
981
1014
|
children: "−"
|
|
982
1015
|
}
|
|
983
1016
|
),
|
|
984
|
-
/* @__PURE__ */
|
|
985
|
-
/* @__PURE__ */
|
|
1017
|
+
/* @__PURE__ */ l("span", { className: "stepper-value", children: a }),
|
|
1018
|
+
/* @__PURE__ */ l(
|
|
986
1019
|
"button",
|
|
987
1020
|
{
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
disabled: l >= 50,
|
|
1021
|
+
onClick: () => p(Math.min(50, a + 1)),
|
|
1022
|
+
disabled: a >= 50,
|
|
991
1023
|
children: "+"
|
|
992
1024
|
}
|
|
993
1025
|
)
|
|
994
1026
|
] })
|
|
995
1027
|
] })
|
|
1028
|
+
] }),
|
|
1029
|
+
/* @__PURE__ */ w("div", { className: "settings-section", children: [
|
|
1030
|
+
/* @__PURE__ */ l("h3", { className: "settings-section-title", children: "Algorithm" }),
|
|
1031
|
+
/* @__PURE__ */ w("div", { className: "settings-row", children: [
|
|
1032
|
+
/* @__PURE__ */ l("label", { children: "Diagonal Movement" }),
|
|
1033
|
+
/* @__PURE__ */ w("div", { className: "settings-toggle-group", children: [
|
|
1034
|
+
/* @__PURE__ */ l(
|
|
1035
|
+
"button",
|
|
1036
|
+
{
|
|
1037
|
+
className: `settings-toggle-btn ${f ? "" : "active"}`,
|
|
1038
|
+
onClick: () => u(!1),
|
|
1039
|
+
children: "Off"
|
|
1040
|
+
}
|
|
1041
|
+
),
|
|
1042
|
+
/* @__PURE__ */ l(
|
|
1043
|
+
"button",
|
|
1044
|
+
{
|
|
1045
|
+
className: `settings-toggle-btn ${f ? "active" : ""}`,
|
|
1046
|
+
onClick: () => u(!0),
|
|
1047
|
+
children: "On"
|
|
1048
|
+
}
|
|
1049
|
+
)
|
|
1050
|
+
] })
|
|
1051
|
+
] }),
|
|
1052
|
+
/* @__PURE__ */ w("div", { className: "settings-row", children: [
|
|
1053
|
+
/* @__PURE__ */ l("label", { children: "Show Costs" }),
|
|
1054
|
+
/* @__PURE__ */ w("div", { className: "settings-toggle-group", children: [
|
|
1055
|
+
/* @__PURE__ */ l(
|
|
1056
|
+
"button",
|
|
1057
|
+
{
|
|
1058
|
+
className: `settings-toggle-btn ${m ? "" : "active"}`,
|
|
1059
|
+
onClick: () => h(!1),
|
|
1060
|
+
children: "Off"
|
|
1061
|
+
}
|
|
1062
|
+
),
|
|
1063
|
+
/* @__PURE__ */ l(
|
|
1064
|
+
"button",
|
|
1065
|
+
{
|
|
1066
|
+
className: `settings-toggle-btn ${m ? "active" : ""}`,
|
|
1067
|
+
onClick: () => h(!0),
|
|
1068
|
+
children: "On"
|
|
1069
|
+
}
|
|
1070
|
+
)
|
|
1071
|
+
] })
|
|
1072
|
+
] })
|
|
1073
|
+
] }),
|
|
1074
|
+
v === A.Medieval && /* @__PURE__ */ w("div", { className: "settings-section", children: [
|
|
1075
|
+
/* @__PURE__ */ l("h3", { className: "settings-section-title", children: "Terrain Tools" }),
|
|
1076
|
+
/* @__PURE__ */ l("div", { className: "settings-terrain-grid", children: b.filter(({ state: N }) => N !== o.Obstacle).map(({ state: N, config: S }) => /* @__PURE__ */ w(
|
|
1077
|
+
"button",
|
|
1078
|
+
{
|
|
1079
|
+
className: `settings-terrain-btn ${g === N ? "active" : ""}`,
|
|
1080
|
+
onClick: () => d(N),
|
|
1081
|
+
title: S.passable ? "Passable terrain" : "Impassable terrain",
|
|
1082
|
+
children: [
|
|
1083
|
+
S.icon,
|
|
1084
|
+
" ",
|
|
1085
|
+
S.name
|
|
1086
|
+
]
|
|
1087
|
+
},
|
|
1088
|
+
N
|
|
1089
|
+
)) })
|
|
1090
|
+
] }),
|
|
1091
|
+
/* @__PURE__ */ w("div", { className: "settings-section", children: [
|
|
1092
|
+
/* @__PURE__ */ l("h3", { className: "settings-section-title", children: "Generate Map" }),
|
|
1093
|
+
/* @__PURE__ */ l("div", { className: "settings-preset-grid", children: _.presets.map((N) => /* @__PURE__ */ l(
|
|
1094
|
+
"button",
|
|
1095
|
+
{
|
|
1096
|
+
className: "settings-preset-btn",
|
|
1097
|
+
onClick: () => M(N.id),
|
|
1098
|
+
children: N.name
|
|
1099
|
+
},
|
|
1100
|
+
N.id
|
|
1101
|
+
)) })
|
|
996
1102
|
] })
|
|
997
|
-
] })
|
|
998
|
-
] })
|
|
999
|
-
},
|
|
1000
|
-
const t =
|
|
1103
|
+
] }) })
|
|
1104
|
+
] });
|
|
1105
|
+
}, je = ({ defaultDarkMode: e }) => {
|
|
1106
|
+
const t = re(null), { visualTheme: n } = D(), [r, s] = j(() => {
|
|
1001
1107
|
if (e !== void 0)
|
|
1002
1108
|
return e;
|
|
1003
|
-
const
|
|
1004
|
-
return
|
|
1109
|
+
const a = localStorage.getItem("astar-darkMode");
|
|
1110
|
+
return a ? JSON.parse(a) : !1;
|
|
1005
1111
|
});
|
|
1006
|
-
return
|
|
1007
|
-
e === void 0 && localStorage.setItem("astar-darkMode", JSON.stringify(
|
|
1008
|
-
}, [
|
|
1009
|
-
/* @__PURE__ */
|
|
1010
|
-
/* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
1112
|
+
return se(() => {
|
|
1113
|
+
e === void 0 && localStorage.setItem("astar-darkMode", JSON.stringify(r)), t.current && (t.current.setAttribute("data-theme", r ? "dark" : "light"), t.current.setAttribute("data-visual-theme", n));
|
|
1114
|
+
}, [r, e, n]), /* @__PURE__ */ l("div", { ref: t, className: "astar-visualizer-root", "data-theme": r ? "dark" : "light", "data-visual-theme": n, children: /* @__PURE__ */ w("div", { className: "app-container", children: [
|
|
1115
|
+
/* @__PURE__ */ l("header", { className: "app-header", children: /* @__PURE__ */ l("h1", { className: "app-title", children: "A* Pathfinding Visualizer" }) }),
|
|
1116
|
+
/* @__PURE__ */ l(Pe, {}),
|
|
1117
|
+
/* @__PURE__ */ l("main", { className: "app-main", children: /* @__PURE__ */ l(Le, {}) }),
|
|
1118
|
+
/* @__PURE__ */ l(ke, {}),
|
|
1119
|
+
/* @__PURE__ */ l(Fe, { isDarkMode: r, setIsDarkMode: s })
|
|
1012
1120
|
] }) });
|
|
1013
1121
|
};
|
|
1014
|
-
function
|
|
1015
|
-
return /* @__PURE__ */
|
|
1122
|
+
function He({ defaultDarkMode: e }) {
|
|
1123
|
+
return /* @__PURE__ */ l(je, { defaultDarkMode: e });
|
|
1016
1124
|
}
|
|
1017
1125
|
export {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1126
|
+
He as AStarVisualizer,
|
|
1127
|
+
o as CellState,
|
|
1128
|
+
je as Layout,
|
|
1129
|
+
A as VisualTheme
|
|
1022
1130
|
};
|