astar-visualizer 1.0.6 → 1.0.7

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.
@@ -1,22 +1,22 @@
1
- import { jsx as S, jsxs as y } from "react/jsx-runtime";
2
- import D, { useState as H, useEffect as F } from "react";
1
+ import { jsx as w, jsxs as y } from "react/jsx-runtime";
2
+ import R, { useState as H, useEffect as F, useRef as q } from "react";
3
3
  const P = (e) => {
4
4
  let t;
5
- const r = /* @__PURE__ */ new Set(), s = (i, m) => {
6
- const c = typeof i == "function" ? i(t) : i;
5
+ const r = /* @__PURE__ */ new Set(), a = (u, m) => {
6
+ const c = typeof u == "function" ? u(t) : u;
7
7
  if (!Object.is(c, t)) {
8
- const l = t;
9
- t = m ?? (typeof c != "object" || c === null) ? c : Object.assign({}, t, c), r.forEach((n) => n(t, l));
8
+ const i = t;
9
+ t = m ?? (typeof c != "object" || c === null) ? c : Object.assign({}, t, c), r.forEach((n) => n(t, i));
10
10
  }
11
- }, o = () => t, w = { setState: s, getState: o, getInitialState: () => d, subscribe: (i) => (r.add(i), () => r.delete(i)), destroy: () => {
11
+ }, o = () => t, S = { setState: a, getState: o, getInitialState: () => d, subscribe: (u) => (r.add(u), () => r.delete(u)), destroy: () => {
12
12
  r.clear();
13
- } }, d = t = e(s, o, w);
14
- return w;
15
- }, q = (e) => e ? P(e) : P;
16
- function J(e) {
13
+ } }, d = t = e(a, o, S);
14
+ return S;
15
+ }, J = (e) => e ? P(e) : P;
16
+ function Y(e) {
17
17
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
18
18
  }
19
- var V = { exports: {} }, L = {}, R = { exports: {} }, A = {};
19
+ var M = { exports: {} }, A = {}, L = { exports: {} }, D = {};
20
20
  /**
21
21
  * @license React
22
22
  * use-sync-external-store-shim.production.js
@@ -27,37 +27,37 @@ var V = { exports: {} }, L = {}, R = { exports: {} }, A = {};
27
27
  * LICENSE file in the root directory of this source tree.
28
28
  */
29
29
  var I;
30
- function Y() {
30
+ function Q() {
31
31
  if (I)
32
- return A;
32
+ return D;
33
33
  I = 1;
34
- var e = D;
34
+ var e = R;
35
35
  function t(m, c) {
36
36
  return m === c && (m !== 0 || 1 / m === 1 / c) || m !== m && c !== c;
37
37
  }
38
- var r = typeof Object.is == "function" ? Object.is : t, s = e.useState, o = e.useEffect, u = e.useLayoutEffect, p = e.useDebugValue;
39
- function E(m, c) {
40
- var l = c(), n = s({ inst: { value: l, getSnapshot: c } }), a = n[0].inst, f = n[1];
41
- return u(
38
+ var r = typeof Object.is == "function" ? Object.is : t, a = e.useState, o = e.useEffect, l = e.useLayoutEffect, p = e.useDebugValue;
39
+ function v(m, c) {
40
+ var i = c(), n = a({ inst: { value: i, getSnapshot: c } }), s = n[0].inst, f = n[1];
41
+ return l(
42
42
  function() {
43
- a.value = l, a.getSnapshot = c, w(a) && f({ inst: a });
43
+ s.value = i, s.getSnapshot = c, S(s) && f({ inst: s });
44
44
  },
45
- [m, l, c]
45
+ [m, i, c]
46
46
  ), o(
47
47
  function() {
48
- return w(a) && f({ inst: a }), m(function() {
49
- w(a) && f({ inst: a });
48
+ return S(s) && f({ inst: s }), m(function() {
49
+ S(s) && f({ inst: s });
50
50
  });
51
51
  },
52
52
  [m]
53
- ), p(l), l;
53
+ ), p(i), i;
54
54
  }
55
- function w(m) {
55
+ function S(m) {
56
56
  var c = m.getSnapshot;
57
57
  m = m.value;
58
58
  try {
59
- var l = c();
60
- return !r(m, l);
59
+ var i = c();
60
+ return !r(m, i);
61
61
  } catch {
62
62
  return !0;
63
63
  }
@@ -65,8 +65,8 @@ function Y() {
65
65
  function d(m, c) {
66
66
  return c();
67
67
  }
68
- var i = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : E;
69
- return A.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : i, A;
68
+ var u = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : v;
69
+ return D.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : u, D;
70
70
  }
71
71
  var z = {};
72
72
  /**
@@ -79,61 +79,61 @@ var z = {};
79
79
  * LICENSE file in the root directory of this source tree.
80
80
  */
81
81
  var x;
82
- function Q() {
82
+ function X() {
83
83
  return x || (x = 1, process.env.NODE_ENV !== "production" && function() {
84
- function e(l, n) {
85
- return l === n && (l !== 0 || 1 / l === 1 / n) || l !== l && n !== n;
84
+ function e(i, n) {
85
+ return i === n && (i !== 0 || 1 / i === 1 / n) || i !== i && n !== n;
86
86
  }
87
- function t(l, n) {
88
- i || o.startTransition === void 0 || (i = !0, console.error(
87
+ function t(i, n) {
88
+ u || o.startTransition === void 0 || (u = !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 a = n();
91
+ var s = n();
92
92
  if (!m) {
93
93
  var f = n();
94
- u(a, f) || (console.error(
94
+ l(s, f) || (console.error(
95
95
  "The result of getSnapshot should be cached to avoid an infinite loop"
96
96
  ), m = !0);
97
97
  }
98
98
  f = p({
99
- inst: { value: a, getSnapshot: n }
99
+ inst: { value: s, getSnapshot: n }
100
100
  });
101
- var v = f[0].inst, O = f[1];
102
- return w(
101
+ var E = f[0].inst, O = f[1];
102
+ return S(
103
103
  function() {
104
- v.value = a, v.getSnapshot = n, r(v) && O({ inst: v });
104
+ E.value = s, E.getSnapshot = n, r(E) && O({ inst: E });
105
105
  },
106
- [l, a, n]
107
- ), E(
106
+ [i, s, n]
107
+ ), v(
108
108
  function() {
109
- return r(v) && O({ inst: v }), l(function() {
110
- r(v) && O({ inst: v });
109
+ return r(E) && O({ inst: E }), i(function() {
110
+ r(E) && O({ inst: E });
111
111
  });
112
112
  },
113
- [l]
114
- ), d(a), a;
113
+ [i]
114
+ ), d(s), s;
115
115
  }
116
- function r(l) {
117
- var n = l.getSnapshot;
118
- l = l.value;
116
+ function r(i) {
117
+ var n = i.getSnapshot;
118
+ i = i.value;
119
119
  try {
120
- var a = n();
121
- return !u(l, a);
120
+ var s = n();
121
+ return !l(i, s);
122
122
  } catch {
123
123
  return !0;
124
124
  }
125
125
  }
126
- function s(l, n) {
126
+ function a(i, n) {
127
127
  return n();
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 o = D, u = typeof Object.is == "function" ? Object.is : e, p = o.useState, E = o.useEffect, w = o.useLayoutEffect, d = o.useDebugValue, i = !1, m = !1, c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : t;
130
+ var o = R, l = typeof Object.is == "function" ? Object.is : e, p = o.useState, v = o.useEffect, S = o.useLayoutEffect, d = o.useDebugValue, u = !1, m = !1, c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? a : t;
131
131
  z.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : c, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
132
132
  }()), z;
133
133
  }
134
134
  var j;
135
135
  function K() {
136
- return j || (j = 1, process.env.NODE_ENV === "production" ? R.exports = Y() : R.exports = Q()), R.exports;
136
+ return j || (j = 1, process.env.NODE_ENV === "production" ? L.exports = Q() : L.exports = X()), L.exports;
137
137
  }
138
138
  /**
139
139
  * @license React
@@ -145,60 +145,60 @@ function K() {
145
145
  * LICENSE file in the root directory of this source tree.
146
146
  */
147
147
  var G;
148
- function X() {
148
+ function Z() {
149
149
  if (G)
150
- return L;
150
+ return A;
151
151
  G = 1;
152
- var e = D, t = K();
153
- function r(d, i) {
154
- return d === i && (d !== 0 || 1 / d === 1 / i) || d !== d && i !== i;
152
+ var e = R, t = K();
153
+ function r(d, u) {
154
+ return d === u && (d !== 0 || 1 / d === 1 / u) || d !== d && u !== u;
155
155
  }
156
- var s = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, u = e.useRef, p = e.useEffect, E = e.useMemo, w = e.useDebugValue;
157
- return L.useSyncExternalStoreWithSelector = function(d, i, m, c, l) {
158
- var n = u(null);
156
+ var a = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, l = e.useRef, p = e.useEffect, v = e.useMemo, S = e.useDebugValue;
157
+ return A.useSyncExternalStoreWithSelector = function(d, u, m, c, i) {
158
+ var n = l(null);
159
159
  if (n.current === null) {
160
- var a = { hasValue: !1, value: null };
161
- n.current = a;
160
+ var s = { hasValue: !1, value: null };
161
+ n.current = s;
162
162
  } else
163
- a = n.current;
164
- n = E(
163
+ s = n.current;
164
+ n = v(
165
165
  function() {
166
- function v(g) {
166
+ function E(g) {
167
167
  if (!O) {
168
- if (O = !0, N = g, g = c(g), l !== void 0 && a.hasValue) {
169
- var b = a.value;
170
- if (l(b, g))
168
+ if (O = !0, N = g, g = c(g), i !== void 0 && s.hasValue) {
169
+ var b = s.value;
170
+ if (i(b, g))
171
171
  return T = b;
172
172
  }
173
173
  return T = g;
174
174
  }
175
- if (b = T, s(N, g))
175
+ if (b = T, a(N, g))
176
176
  return b;
177
177
  var _ = c(g);
178
- return l !== void 0 && l(b, _) ? (N = g, b) : (N = g, T = _);
178
+ return i !== void 0 && i(b, _) ? (N = g, b) : (N = g, T = _);
179
179
  }
180
180
  var O = !1, N, T, C = m === void 0 ? null : m;
181
181
  return [
182
182
  function() {
183
- return v(i());
183
+ return E(u());
184
184
  },
185
185
  C === null ? void 0 : function() {
186
- return v(C());
186
+ return E(C());
187
187
  }
188
188
  ];
189
189
  },
190
- [i, m, c, l]
190
+ [u, m, c, i]
191
191
  );
192
192
  var f = o(d, n[0], n[1]);
193
193
  return p(
194
194
  function() {
195
- a.hasValue = !0, a.value = f;
195
+ s.hasValue = !0, s.value = f;
196
196
  },
197
197
  [f]
198
- ), w(f), f;
199
- }, L;
198
+ ), S(f), f;
199
+ }, A;
200
200
  }
201
- var M = {};
201
+ var V = {};
202
202
  /**
203
203
  * @license React
204
204
  * use-sync-external-store-shim/with-selector.development.js
@@ -209,146 +209,146 @@ var M = {};
209
209
  * LICENSE file in the root directory of this source tree.
210
210
  */
211
211
  var W;
212
- function Z() {
212
+ function ee() {
213
213
  return W || (W = 1, process.env.NODE_ENV !== "production" && function() {
214
- function e(d, i) {
215
- return d === i && (d !== 0 || 1 / d === 1 / i) || d !== d && i !== i;
214
+ function e(d, u) {
215
+ return d === u && (d !== 0 || 1 / d === 1 / u) || d !== d && u !== u;
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 = D, r = K(), s = typeof Object.is == "function" ? Object.is : e, o = r.useSyncExternalStore, u = t.useRef, p = t.useEffect, E = t.useMemo, w = t.useDebugValue;
219
- M.useSyncExternalStoreWithSelector = function(d, i, m, c, l) {
220
- var n = u(null);
218
+ var t = R, r = K(), a = typeof Object.is == "function" ? Object.is : e, o = r.useSyncExternalStore, l = t.useRef, p = t.useEffect, v = t.useMemo, S = t.useDebugValue;
219
+ V.useSyncExternalStoreWithSelector = function(d, u, m, c, i) {
220
+ var n = l(null);
221
221
  if (n.current === null) {
222
- var a = { hasValue: !1, value: null };
223
- n.current = a;
222
+ var s = { hasValue: !1, value: null };
223
+ n.current = s;
224
224
  } else
225
- a = n.current;
226
- n = E(
225
+ s = n.current;
226
+ n = v(
227
227
  function() {
228
- function v(g) {
228
+ function E(g) {
229
229
  if (!O) {
230
- if (O = !0, N = g, g = c(g), l !== void 0 && a.hasValue) {
231
- var b = a.value;
232
- if (l(b, g))
230
+ if (O = !0, N = g, g = c(g), i !== void 0 && s.hasValue) {
231
+ var b = s.value;
232
+ if (i(b, g))
233
233
  return T = b;
234
234
  }
235
235
  return T = g;
236
236
  }
237
- if (b = T, s(N, g))
237
+ if (b = T, a(N, g))
238
238
  return b;
239
239
  var _ = c(g);
240
- return l !== void 0 && l(b, _) ? (N = g, b) : (N = g, T = _);
240
+ return i !== void 0 && i(b, _) ? (N = g, b) : (N = g, T = _);
241
241
  }
242
242
  var O = !1, N, T, C = m === void 0 ? null : m;
243
243
  return [
244
244
  function() {
245
- return v(i());
245
+ return E(u());
246
246
  },
247
247
  C === null ? void 0 : function() {
248
- return v(C());
248
+ return E(C());
249
249
  }
250
250
  ];
251
251
  },
252
- [i, m, c, l]
252
+ [u, m, c, i]
253
253
  );
254
254
  var f = o(d, n[0], n[1]);
255
255
  return p(
256
256
  function() {
257
- a.hasValue = !0, a.value = f;
257
+ s.hasValue = !0, s.value = f;
258
258
  },
259
259
  [f]
260
- ), w(f), f;
260
+ ), S(f), f;
261
261
  }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
262
- }()), M;
262
+ }()), V;
263
263
  }
264
- process.env.NODE_ENV === "production" ? V.exports = X() : V.exports = Z();
265
- var ee = V.exports;
266
- const te = /* @__PURE__ */ J(ee), { useDebugValue: re } = D, { useSyncExternalStoreWithSelector: oe } = te;
267
- const ne = (e) => e;
268
- function se(e, t = ne, r) {
269
- const s = oe(
264
+ process.env.NODE_ENV === "production" ? M.exports = Z() : M.exports = ee();
265
+ var te = M.exports;
266
+ const re = /* @__PURE__ */ Y(te), { useDebugValue: oe } = R, { useSyncExternalStoreWithSelector: ne } = re;
267
+ const se = (e) => e;
268
+ function ae(e, t = se, r) {
269
+ const a = ne(
270
270
  e.subscribe,
271
271
  e.getState,
272
272
  e.getServerState || e.getInitialState,
273
273
  t,
274
274
  r
275
275
  );
276
- return re(s), s;
276
+ return oe(a), a;
277
277
  }
278
278
  const $ = (e) => {
279
- const t = typeof e == "function" ? q(e) : e, r = (s, o) => se(t, s, o);
279
+ const t = typeof e == "function" ? J(e) : e, r = (a, o) => ae(t, a, o);
280
280
  return Object.assign(r, t), r;
281
- }, ae = (e) => e ? $(e) : $;
281
+ }, le = (e) => e ? $(e) : $;
282
282
  var h = /* @__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))(h || {});
283
283
  const k = (e, t) => {
284
- const r = Math.abs(e.row - t.row), s = Math.abs(e.col - t.col);
285
- return Math.floor(10 * Math.sqrt(r * r + s * s));
286
- }, le = (e, t) => ({
284
+ const r = Math.abs(e.row - t.row), a = Math.abs(e.col - t.col);
285
+ return Math.floor(10 * Math.sqrt(r * r + a * a));
286
+ }, ie = (e, t) => ({
287
287
  row: e.row,
288
288
  col: e.col,
289
289
  g: 0,
290
290
  h: k(e, t),
291
291
  f: k(e, t),
292
292
  parent: null
293
- }), ie = (e, t, r) => {
294
- const s = [
293
+ }), ce = (e, t, r) => {
294
+ const a = [
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
- return r && s.push(
300
+ return r && a.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
- ), s.filter((o) => o.row >= 0 && o.row < t.length && o.col >= 0 && o.col < t[0].length && t[o.row][o.col].state !== h.Obstacle).map((o) => ({
305
+ ), a.filter((o) => o.row >= 0 && o.row < t.length && o.col >= 0 && o.col < t[0].length && t[o.row][o.col].state !== h.Obstacle).map((o) => ({
306
306
  row: o.row,
307
307
  col: o.col,
308
308
  state: t[o.row][o.col].state
309
309
  }));
310
- }, ce = (e, t, r) => {
311
- const s = Math.abs(e.row - t.row), o = Math.abs(e.col - t.col), u = e.g + (s === 0 || o === 0 ? 10 : 14), p = k(t, r), E = u + p;
312
- return { g: u, h: p, f: E };
313
- }, ue = (e) => {
310
+ }, ue = (e, t, r) => {
311
+ const a = Math.abs(e.row - t.row), o = Math.abs(e.col - t.col), l = e.g + (a === 0 || o === 0 ? 10 : 14), p = k(t, r), v = l + p;
312
+ return { g: l, h: p, f: v };
313
+ }, de = (e) => {
314
314
  const t = [];
315
315
  let r = e;
316
316
  for (; r; )
317
317
  t.push(r), r = r.parent;
318
318
  return t.reverse();
319
- }, de = (e, t, r, s) => {
320
- const o = [], u = [], p = le(t, r);
319
+ }, fe = (e, t, r, a) => {
320
+ const o = [], l = [], p = ie(t, r);
321
321
  for (o.push(p); o.length > 0; ) {
322
- o.sort((d, i) => d.f - i.f);
323
- const E = o.shift();
324
- if (E.row === r.row && E.col === r.col)
325
- return u.push(E), { path: ue(E), visitedNodes: u };
326
- u.push(E);
327
- const w = ie(E, e, s);
328
- for (const d of w) {
329
- if (u.some((n) => n.row === d.row && n.col === d.col))
322
+ o.sort((d, u) => d.f - u.f);
323
+ const v = o.shift();
324
+ if (v.row === r.row && v.col === r.col)
325
+ return l.push(v), { path: de(v), visitedNodes: l };
326
+ l.push(v);
327
+ const S = ce(v, e, a);
328
+ for (const d of S) {
329
+ if (l.some((n) => n.row === d.row && n.col === d.col))
330
330
  continue;
331
- const { g: i, h: m, f: c } = ce(E, d, r), l = o.find(
331
+ const { g: u, h: m, f: c } = ue(v, d, r), i = o.find(
332
332
  (n) => n.row === d.row && n.col === d.col
333
333
  );
334
- if (!l || i < l.g) {
334
+ if (!i || u < i.g) {
335
335
  const n = {
336
336
  row: d.row,
337
337
  col: d.col,
338
- g: i,
338
+ g: u,
339
339
  h: m,
340
340
  f: c,
341
- parent: E
341
+ parent: v
342
342
  };
343
- l ? (l.g = i, l.f = c, l.parent = E) : o.push(n);
343
+ i ? (i.g = u, i.f = c, i.parent = v) : o.push(n);
344
344
  }
345
345
  }
346
346
  }
347
- return { path: [], visitedNodes: u };
348
- }, fe = (e) => ({
347
+ return { path: [], visitedNodes: l };
348
+ }, he = (e) => ({
349
349
  cells: Array.from(
350
350
  { length: 8 },
351
- (t, r) => Array.from({ length: 12 }, (s, o) => ({
351
+ (t, r) => Array.from({ length: 12 }, (a, o) => ({
352
352
  row: r,
353
353
  col: o,
354
354
  state: h.Empty
@@ -363,11 +363,11 @@ const k = (e, t) => {
363
363
  visitedNodes: [],
364
364
  setNumberOfColumns: (t) => {
365
365
  e((r) => {
366
- const s = r.cells.map((o) => t > r.columns ? [
366
+ const a = r.cells.map((o) => t > r.columns ? [
367
367
  ...o,
368
368
  ...Array.from(
369
369
  { length: t - r.columns },
370
- (u, p) => ({
370
+ (l, p) => ({
371
371
  row: o[0].row,
372
372
  col: r.columns + p,
373
373
  state: h.Empty
@@ -377,58 +377,58 @@ const k = (e, t) => {
377
377
  return {
378
378
  ...r,
379
379
  columns: t,
380
- cells: s
380
+ cells: a
381
381
  };
382
382
  });
383
383
  },
384
384
  setNumberOfRows: (t) => {
385
385
  e((r) => {
386
- let s = [...r.cells];
387
- return t > r.rows ? s = [
388
- ...s,
386
+ let a = [...r.cells];
387
+ return t > r.rows ? a = [
388
+ ...a,
389
389
  ...Array.from(
390
390
  { length: t - r.rows },
391
- (o, u) => Array.from({ length: r.columns }, (p, E) => ({
392
- row: r.rows + u,
393
- col: E,
391
+ (o, l) => Array.from({ length: r.columns }, (p, v) => ({
392
+ row: r.rows + l,
393
+ col: v,
394
394
  state: h.Empty
395
395
  }))
396
396
  )
397
- ] : s = s.slice(0, t), {
397
+ ] : a = a.slice(0, t), {
398
398
  ...r,
399
399
  rows: t,
400
- cells: s
400
+ cells: a
401
401
  };
402
402
  });
403
403
  },
404
- setCellState: (t, r, s) => {
404
+ setCellState: (t, r, a) => {
405
405
  e((o) => {
406
- const u = o.cells.map(
407
- (d) => d.map((i) => ({ ...i }))
406
+ const l = o.cells.map(
407
+ (d) => d.map((u) => ({ ...u }))
408
408
  );
409
- let p = o.startTile, E = o.endTile, w = [...o.obstacleTiles];
410
- switch (s === h.Start && o.startTile && (u[o.startTile.row][o.startTile.col].state = h.Empty, p = null), s === h.End && o.endTile && (u[o.endTile.row][o.endTile.col].state = h.Empty, E = null), u[t][r].state = s, s) {
409
+ let p = o.startTile, v = o.endTile, S = [...o.obstacleTiles];
410
+ switch (a === h.Start && o.startTile && (l[o.startTile.row][o.startTile.col].state = h.Empty, p = null), a === h.End && o.endTile && (l[o.endTile.row][o.endTile.col].state = h.Empty, v = null), l[t][r].state = a, a) {
411
411
  case h.Start:
412
412
  p = { row: t, col: r };
413
413
  break;
414
414
  case h.End:
415
- E = { row: t, col: r };
415
+ v = { row: t, col: r };
416
416
  break;
417
417
  case h.Obstacle:
418
- w.some((d) => d.row === t && d.col === r) || w.push({ row: t, col: r });
418
+ S.some((d) => d.row === t && d.col === r) || S.push({ row: t, col: r });
419
419
  break;
420
420
  case h.Empty:
421
- w = w.filter(
421
+ S = S.filter(
422
422
  (d) => !(d.row === t && d.col === r)
423
423
  );
424
424
  break;
425
425
  }
426
426
  return {
427
427
  ...o,
428
- cells: u,
428
+ cells: l,
429
429
  startTile: p,
430
- endTile: E,
431
- obstacleTiles: w
430
+ endTile: v,
431
+ obstacleTiles: S
432
432
  };
433
433
  });
434
434
  },
@@ -436,8 +436,8 @@ const k = (e, t) => {
436
436
  e((t) => ({
437
437
  ...t,
438
438
  cells: t.cells.map(
439
- (r) => r.map((s) => ({
440
- ...s,
439
+ (r) => r.map((a) => ({
440
+ ...a,
441
441
  state: h.Empty
442
442
  }))
443
443
  ),
@@ -450,124 +450,124 @@ const k = (e, t) => {
450
450
  },
451
451
  handleFindPath: (t) => {
452
452
  e((r) => {
453
- const s = r.cells.flat().find((u) => u.state === h.Start), o = r.cells.flat().find((u) => u.state === h.End);
454
- if (s && o) {
455
- const u = r.cells.map(
456
- (d) => d.map((i) => ({
457
- row: i.row,
458
- col: i.col,
459
- state: i.state
453
+ const a = r.cells.flat().find((l) => l.state === h.Start), o = r.cells.flat().find((l) => l.state === h.End);
454
+ if (a && o) {
455
+ const l = r.cells.map(
456
+ (d) => d.map((u) => ({
457
+ row: u.row,
458
+ col: u.col,
459
+ state: u.state
460
460
  }))
461
- ), { path: p, visitedNodes: E } = de(u, s, o, t);
462
- return (async (d, i) => {
463
- for (let m of i)
461
+ ), { path: p, visitedNodes: v } = fe(l, a, o, t);
462
+ return (async (d, u) => {
463
+ for (let m of u)
464
464
  await new Promise((c) => setTimeout(c, 100)), e((c) => {
465
- const l = c.cells.map(
466
- (n) => n.map((a) => ({
467
- ...a,
468
- state: m.row === a.row && m.col === a.col && a.state === h.Empty ? h.Visited : a.state
465
+ const i = c.cells.map(
466
+ (n) => n.map((s) => ({
467
+ ...s,
468
+ state: m.row === s.row && m.col === s.col && s.state === h.Empty ? h.Visited : s.state
469
469
  }))
470
470
  );
471
471
  return {
472
472
  ...c,
473
- cells: l,
473
+ cells: i,
474
474
  visitedNodes: [...c.visitedNodes, m]
475
475
  };
476
476
  });
477
477
  for (let m of d)
478
478
  await new Promise((c) => setTimeout(c, 250)), e((c) => {
479
- const l = c.cells.map(
480
- (n) => n.map((a) => ({
481
- ...a,
482
- state: m.row === a.row && m.col === a.col ? h.Path : a.state
479
+ const i = c.cells.map(
480
+ (n) => n.map((s) => ({
481
+ ...s,
482
+ state: m.row === s.row && m.col === s.col ? h.Path : s.state
483
483
  }))
484
484
  );
485
485
  return {
486
486
  ...c,
487
- cells: l,
487
+ cells: i,
488
488
  path: [...c.path, m]
489
489
  };
490
490
  });
491
- })(p, E), { ...r, path: [], visitedNodes: [] };
491
+ })(p, v), { ...r, path: [], visitedNodes: [] };
492
492
  }
493
493
  return r;
494
494
  });
495
495
  },
496
496
  setPath: (t) => {
497
497
  e((r) => {
498
- const s = r.cells.map(
499
- (o) => o.map((u) => ({
500
- ...u,
501
- state: t.some((p) => p.row === u.row && p.col === u.col) ? h.Path : u.state
498
+ const a = r.cells.map(
499
+ (o) => o.map((l) => ({
500
+ ...l,
501
+ state: t.some((p) => p.row === l.row && p.col === l.col) ? h.Path : l.state
502
502
  }))
503
503
  );
504
504
  return {
505
505
  ...r,
506
- cells: s
506
+ cells: a
507
507
  };
508
508
  });
509
509
  },
510
510
  setVisitedNodes: (t) => {
511
511
  e((r) => {
512
- const s = r.cells.map(
513
- (o) => o.map((u) => ({
514
- ...u,
515
- state: t.some((p) => p.row === u.row && p.col === u.col) && u.state === h.Empty ? h.Visited : u.state
512
+ const a = r.cells.map(
513
+ (o) => o.map((l) => ({
514
+ ...l,
515
+ state: t.some((p) => p.row === l.row && p.col === l.col) && l.state === h.Empty ? h.Visited : l.state
516
516
  }))
517
517
  );
518
518
  return {
519
519
  ...r,
520
- cells: s
520
+ cells: a
521
521
  };
522
522
  });
523
523
  }
524
- }), he = (e) => ({
524
+ }), me = (e) => ({
525
525
  activeButton: h.Start,
526
526
  setSelectedButtonState: (t) => e({ activeButton: t }),
527
527
  canTravelDiagonally: !0,
528
528
  setCanTravelDiagonally: (t) => e({ canTravelDiagonally: t })
529
- }), U = ae((e, t, r) => ({
530
- ...fe(e),
531
- ...he(e)
529
+ }), U = le((e, t, r) => ({
530
+ ...he(e),
531
+ ...me(e)
532
532
  }));
533
- const me = () => {
534
- var l;
535
- const { cells: e, activeButton: t, setCellState: r, setSelectedButtonState: s, visitedNodes: o, path: u } = U(), [p, E] = H({ width: 0, height: 0 }), w = D.useRef(null);
533
+ const pe = () => {
534
+ var i;
535
+ const { cells: e, activeButton: t, setCellState: r, setSelectedButtonState: a, visitedNodes: o, path: l } = U(), [p, v] = H({ width: 0, height: 0 }), S = R.useRef(null);
536
536
  F(() => {
537
537
  const n = () => {
538
- if (w.current) {
539
- const a = w.current.getBoundingClientRect();
540
- E({ width: a.width, height: a.height });
538
+ if (S.current) {
539
+ const s = S.current.getBoundingClientRect();
540
+ v({ width: s.width, height: s.height });
541
541
  }
542
542
  };
543
543
  return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
544
544
  }, []);
545
- const d = (n, a) => {
546
- switch (r(n, a, t), t) {
545
+ const d = (n, s) => {
546
+ switch (r(n, s, t), t) {
547
547
  case h.Start:
548
- s(h.End);
548
+ a(h.End);
549
549
  break;
550
550
  case h.End:
551
- s(h.Obstacle);
551
+ a(h.Obstacle);
552
552
  break;
553
553
  }
554
- }, i = (n, a) => {
555
- const f = o.find((v) => v.row === n && v.col === a);
554
+ }, u = (n, s) => {
555
+ const f = o.find((E) => E.row === n && E.col === s);
556
556
  return f ? { g: f.g, h: f.h, f: f.f } : { g: null, h: null, f: null };
557
557
  }, c = (() => {
558
558
  var b;
559
559
  if (!p.width || !p.height)
560
560
  return 20;
561
- const n = ((b = e[0]) == null ? void 0 : b.length) || 1, a = e.length || 1, f = 20, v = n + a, O = p.width - f - v, N = p.height - f - v, T = O / n, C = N / a, g = Math.min(T, C);
561
+ const n = ((b = e[0]) == null ? void 0 : b.length) || 1, s = e.length || 1, f = 20, E = n + s, O = p.width - f - E, N = p.height - f - E, T = O / n, C = N / s, g = Math.min(T, C);
562
562
  return Math.max(15, Math.min(g, 60));
563
563
  })();
564
- return /* @__PURE__ */ S("div", { className: "grid-wrapper", ref: w, children: /* @__PURE__ */ S(
564
+ return /* @__PURE__ */ w("div", { className: "grid-wrapper", ref: S, children: /* @__PURE__ */ w(
565
565
  "div",
566
566
  {
567
567
  className: "grid-container",
568
568
  style: {
569
569
  display: "grid",
570
- gridTemplateColumns: `repeat(${((l = e[0]) == null ? void 0 : l.length) || 1}, ${c}px)`,
570
+ gridTemplateColumns: `repeat(${((i = e[0]) == null ? void 0 : i.length) || 1}, ${c}px)`,
571
571
  gridTemplateRows: `repeat(${e.length || 1}, ${c}px)`,
572
572
  gap: "1px",
573
573
  padding: "8px",
@@ -577,18 +577,18 @@ const me = () => {
577
577
  border: "1px solid var(--border-color)"
578
578
  },
579
579
  children: e.map(
580
- (n, a) => n.map((f, v) => {
581
- const O = u.some((_) => _.row === f.row && _.col === f.col), N = o.some((_) => _.row === f.row && _.col === f.col), { g: T, h: C, f: g } = i(f.row, f.col);
582
- let b = pe(f, N);
580
+ (n, s) => n.map((f, E) => {
581
+ const O = l.some((_) => _.row === f.row && _.col === f.col), N = o.some((_) => _.row === f.row && _.col === f.col), { g: T, h: C, f: g } = u(f.row, f.col);
582
+ let b = ve(f, N);
583
583
  if (O) {
584
- const _ = u.findIndex((B) => B.row === f.row && B.col === f.col);
585
- _ === 0 ? b = "var(--cell-start)" : _ === u.length - 1 ? b = "var(--cell-end)" : b = "var(--cell-path)";
584
+ const _ = l.findIndex((B) => B.row === f.row && B.col === f.col);
585
+ _ === 0 ? b = "var(--cell-start)" : _ === l.length - 1 ? b = "var(--cell-end)" : b = "var(--cell-path)";
586
586
  }
587
587
  return /* @__PURE__ */ y(
588
588
  "div",
589
589
  {
590
590
  className: "grid-cell",
591
- onClick: () => d(a, v),
591
+ onClick: () => d(s, E),
592
592
  style: {
593
593
  width: c,
594
594
  height: c,
@@ -623,18 +623,18 @@ const me = () => {
623
623
  T
624
624
  ] })
625
625
  ] }),
626
- f.state === h.Start && /* @__PURE__ */ S("div", { className: "cell-indicator start", children: "●" }),
627
- f.state === h.End && /* @__PURE__ */ S("div", { className: "cell-indicator end", children: "●" }),
628
- f.state === h.Obstacle && /* @__PURE__ */ S("div", { className: "cell-indicator obstacle", children: "■" })
626
+ f.state === h.Start && /* @__PURE__ */ w("div", { className: "cell-indicator start", children: "●" }),
627
+ f.state === h.End && /* @__PURE__ */ w("div", { className: "cell-indicator end", children: "●" }),
628
+ f.state === h.Obstacle && /* @__PURE__ */ w("div", { className: "cell-indicator obstacle", children: "■" })
629
629
  ]
630
630
  },
631
- `${a}-${v}`
631
+ `${s}-${E}`
632
632
  );
633
633
  })
634
634
  )
635
635
  }
636
636
  ) });
637
- }, pe = (e, t) => {
637
+ }, ve = (e, t) => {
638
638
  if (t)
639
639
  return e.state === h.Start ? "var(--cell-start)" : e.state === h.End ? "var(--cell-end)" : "var(--cell-visited)";
640
640
  switch (e.state) {
@@ -650,57 +650,50 @@ const me = () => {
650
650
  return "var(--cell-empty)";
651
651
  }
652
652
  };
653
- const ve = () => {
653
+ const Ee = ({ isDarkMode: e, setIsDarkMode: t }) => {
654
654
  const {
655
- activeButton: e,
656
- setSelectedButtonState: t,
657
- resetCells: r,
658
- rows: s,
659
- columns: o,
660
- setNumberOfRows: u,
661
- setNumberOfColumns: p,
662
- handleFindPath: E,
663
- canTravelDiagonally: w,
664
- setCanTravelDiagonally: d
665
- } = U(), [i, m] = H(() => {
666
- const v = localStorage.getItem("darkMode");
667
- return v ? JSON.parse(v) : !1;
668
- });
669
- F(() => {
670
- localStorage.setItem("darkMode", JSON.stringify(i)), document.documentElement.setAttribute("data-theme", i ? "dark" : "light");
671
- }, [i]);
672
- const c = () => {
673
- m(!i);
674
- }, l = [
655
+ activeButton: r,
656
+ setSelectedButtonState: a,
657
+ resetCells: o,
658
+ rows: l,
659
+ columns: p,
660
+ setNumberOfRows: v,
661
+ setNumberOfColumns: S,
662
+ handleFindPath: d,
663
+ canTravelDiagonally: u,
664
+ setCanTravelDiagonally: m
665
+ } = U(), c = () => {
666
+ t(!e);
667
+ }, i = [
675
668
  { label: "Start", state: h.Start },
676
669
  { label: "End", state: h.End },
677
670
  { label: "Obstacle", state: h.Obstacle },
678
671
  { label: "Clear", state: h.Empty },
679
672
  { label: "Reset", state: null }
680
- ], n = (v) => {
681
- v === null ? a() : t(v);
682
- }, a = () => {
683
- r(), t(h.Start);
673
+ ], n = (E) => {
674
+ E === null ? s() : a(E);
675
+ }, s = () => {
676
+ o(), a(h.Start);
684
677
  }, f = () => {
685
- E(w);
678
+ d(u);
686
679
  };
687
- return /* @__PURE__ */ S("div", { className: "control-panel", children: /* @__PURE__ */ y("div", { className: "control-grid", children: [
680
+ return /* @__PURE__ */ w("div", { className: "control-panel", children: /* @__PURE__ */ y("div", { className: "control-grid", children: [
688
681
  /* @__PURE__ */ y("div", { className: "control-group tools", children: [
689
- /* @__PURE__ */ S("h3", { className: "group-title", children: "Tools" }),
690
- /* @__PURE__ */ S("div", { className: "button-group", children: l.map((v, O) => /* @__PURE__ */ S(
682
+ /* @__PURE__ */ w("h3", { className: "group-title", children: "Tools" }),
683
+ /* @__PURE__ */ w("div", { className: "button-group", children: i.map((E, O) => /* @__PURE__ */ w(
691
684
  "button",
692
685
  {
693
- className: `control-button ${v.label.toLowerCase()} ${e === v.state ? "active" : ""}`,
694
- onClick: () => n(v.state),
695
- children: v.label
686
+ className: `control-button ${E.label.toLowerCase()} ${r === E.state ? "active" : ""}`,
687
+ onClick: () => n(E.state),
688
+ children: E.label
696
689
  },
697
690
  O
698
691
  )) })
699
692
  ] }),
700
693
  /* @__PURE__ */ y("div", { className: "control-group actions", children: [
701
- /* @__PURE__ */ S("h3", { className: "group-title", children: "Actions" }),
694
+ /* @__PURE__ */ w("h3", { className: "group-title", children: "Actions" }),
702
695
  /* @__PURE__ */ y("div", { className: "button-group", children: [
703
- /* @__PURE__ */ S(
696
+ /* @__PURE__ */ w(
704
697
  "button",
705
698
  {
706
699
  className: "control-button find-path",
@@ -708,71 +701,71 @@ const ve = () => {
708
701
  children: "Find Path"
709
702
  }
710
703
  ),
711
- /* @__PURE__ */ S(
704
+ /* @__PURE__ */ w(
712
705
  "button",
713
706
  {
714
- className: `control-button diagonal ${w ? "active" : ""}`,
715
- onClick: () => d(!w),
716
- children: w ? "Diagonal On" : "Diagonal Off"
707
+ className: `control-button diagonal ${u ? "active" : ""}`,
708
+ onClick: () => m(!u),
709
+ children: u ? "Diagonal On" : "Diagonal Off"
717
710
  }
718
711
  ),
719
- /* @__PURE__ */ S(
712
+ /* @__PURE__ */ w(
720
713
  "button",
721
714
  {
722
- className: `control-button theme-toggle ${i ? "active" : ""}`,
715
+ className: `control-button theme-toggle ${e ? "active" : ""}`,
723
716
  onClick: c,
724
- title: i ? "Switch to light mode" : "Switch to dark mode",
725
- children: i ? "☀️ Light" : "🌙 Dark"
717
+ title: e ? "Switch to light mode" : "Switch to dark mode",
718
+ children: e ? "☀️ Light" : "🌙 Dark"
726
719
  }
727
720
  )
728
721
  ] })
729
722
  ] }),
730
723
  /* @__PURE__ */ y("div", { className: "control-group size", children: [
731
- /* @__PURE__ */ S("h3", { className: "group-title", children: "Grid Size" }),
724
+ /* @__PURE__ */ w("h3", { className: "group-title", children: "Grid Size" }),
732
725
  /* @__PURE__ */ y("div", { className: "size-controls", children: [
733
726
  /* @__PURE__ */ y("div", { className: "size-control", children: [
734
- /* @__PURE__ */ S("label", { className: "size-label", children: "Rows" }),
727
+ /* @__PURE__ */ w("label", { className: "size-label", children: "Rows" }),
735
728
  /* @__PURE__ */ y("div", { className: "size-buttons", children: [
736
- /* @__PURE__ */ S(
729
+ /* @__PURE__ */ w(
737
730
  "button",
738
731
  {
739
732
  className: "size-button",
740
- onClick: () => u(Math.max(5, s - 1)),
741
- disabled: s <= 5,
733
+ onClick: () => v(Math.max(5, l - 1)),
734
+ disabled: l <= 5,
742
735
  children: "−"
743
736
  }
744
737
  ),
745
- /* @__PURE__ */ S("span", { className: "size-value", children: s }),
746
- /* @__PURE__ */ S(
738
+ /* @__PURE__ */ w("span", { className: "size-value", children: l }),
739
+ /* @__PURE__ */ w(
747
740
  "button",
748
741
  {
749
742
  className: "size-button",
750
- onClick: () => u(Math.min(50, s + 1)),
751
- disabled: s >= 50,
743
+ onClick: () => v(Math.min(50, l + 1)),
744
+ disabled: l >= 50,
752
745
  children: "+"
753
746
  }
754
747
  )
755
748
  ] })
756
749
  ] }),
757
750
  /* @__PURE__ */ y("div", { className: "size-control", children: [
758
- /* @__PURE__ */ S("label", { className: "size-label", children: "Columns" }),
751
+ /* @__PURE__ */ w("label", { className: "size-label", children: "Columns" }),
759
752
  /* @__PURE__ */ y("div", { className: "size-buttons", children: [
760
- /* @__PURE__ */ S(
753
+ /* @__PURE__ */ w(
761
754
  "button",
762
755
  {
763
756
  className: "size-button",
764
- onClick: () => p(Math.max(5, o - 1)),
765
- disabled: o <= 5,
757
+ onClick: () => S(Math.max(5, p - 1)),
758
+ disabled: p <= 5,
766
759
  children: "−"
767
760
  }
768
761
  ),
769
- /* @__PURE__ */ S("span", { className: "size-value", children: o }),
770
- /* @__PURE__ */ S(
762
+ /* @__PURE__ */ w("span", { className: "size-value", children: p }),
763
+ /* @__PURE__ */ w(
771
764
  "button",
772
765
  {
773
766
  className: "size-button",
774
- onClick: () => p(Math.min(50, o + 1)),
775
- disabled: o >= 50,
767
+ onClick: () => S(Math.min(50, p + 1)),
768
+ disabled: p >= 50,
776
769
  children: "+"
777
770
  }
778
771
  )
@@ -781,16 +774,26 @@ const ve = () => {
781
774
  ] })
782
775
  ] })
783
776
  ] }) });
784
- }, Ee = () => /* @__PURE__ */ S("div", { className: "astar-visualizer-root", children: /* @__PURE__ */ y("div", { className: "app-container", children: [
785
- /* @__PURE__ */ S("header", { className: "app-header", children: /* @__PURE__ */ S("h1", { className: "app-title", children: "A* Pathfinding" }) }),
786
- /* @__PURE__ */ S("main", { className: "app-main", children: /* @__PURE__ */ S(me, {}) }),
787
- /* @__PURE__ */ S("footer", { className: "app-footer", children: /* @__PURE__ */ S(ve, {}) })
788
- ] }) });
789
- function ge() {
790
- return /* @__PURE__ */ S(Ee, {});
777
+ }, we = ({ defaultDarkMode: e }) => {
778
+ const t = q(null), [r, a] = H(() => {
779
+ if (e !== void 0)
780
+ return e;
781
+ const o = localStorage.getItem("astar-darkMode");
782
+ return o ? JSON.parse(o) : !1;
783
+ });
784
+ return F(() => {
785
+ e === void 0 && localStorage.setItem("astar-darkMode", JSON.stringify(r)), t.current && t.current.setAttribute("data-theme", r ? "dark" : "light");
786
+ }, [r, e]), /* @__PURE__ */ w("div", { ref: t, className: "astar-visualizer-root", "data-theme": r ? "dark" : "light", children: /* @__PURE__ */ y("div", { className: "app-container", children: [
787
+ /* @__PURE__ */ w("header", { className: "app-header", children: /* @__PURE__ */ w("h1", { className: "app-title", children: "A* Pathfinding" }) }),
788
+ /* @__PURE__ */ w("main", { className: "app-main", children: /* @__PURE__ */ w(pe, {}) }),
789
+ /* @__PURE__ */ w("footer", { className: "app-footer", children: /* @__PURE__ */ w(Ee, { isDarkMode: r, setIsDarkMode: a }) })
790
+ ] }) });
791
+ };
792
+ function be({ defaultDarkMode: e }) {
793
+ return /* @__PURE__ */ w(we, { defaultDarkMode: e });
791
794
  }
792
795
  export {
793
- ge as AStarVisualizer,
796
+ be as AStarVisualizer,
794
797
  h as CellState,
795
- Ee as Layout
798
+ we as Layout
796
799
  };
@@ -1,4 +1,4 @@
1
- (function(T,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],u):(T=typeof globalThis<"u"?globalThis:T||self,u(T.AStarVisualizer={},T["react/jsx-runtime"],T.React))})(this,function(T,u,C){"use strict";const Ee="",Se="",B=e=>{let t;const r=new Set,s=(c,v)=>{const i=typeof c=="function"?c(t):c;if(!Object.is(i,t)){const l=t;t=v??(typeof i!="object"||i===null)?i:Object.assign({},t,i),r.forEach(n=>n(t,l))}},o=()=>t,w={setState:s,getState:o,getInitialState:()=>f,subscribe:c=>(r.add(c),()=>r.delete(c)),destroy:()=>{r.clear()}},f=t=e(s,o,w);return w},q=e=>e?B(e):B;function J(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var A={exports:{}},z={},L={exports:{}},M={};/**
1
+ (function(C,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],u):(C=typeof globalThis<"u"?globalThis:C||self,u(C.AStarVisualizer={},C["react/jsx-runtime"],C.React))})(this,function(C,u,T){"use strict";const Ee="",Se="",B=e=>{let t;const r=new Set,a=(d,v)=>{const i=typeof d=="function"?d(t):d;if(!Object.is(i,t)){const c=t;t=v??(typeof i!="object"||i===null)?i:Object.assign({},t,i),r.forEach(n=>n(t,c))}},o=()=>t,w={setState:a,getState:o,getInitialState:()=>f,subscribe:d=>(r.add(d),()=>r.delete(d)),destroy:()=>{r.clear()}},f=t=e(a,o,w);return w},J=e=>e?B(e):B;function q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var D={exports:{}},z={},A={exports:{}},V={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var j;function Y(){if(j)return M;j=1;var e=C;function t(v,i){return v===i&&(v!==0||1/v===1/i)||v!==v&&i!==i}var r=typeof Object.is=="function"?Object.is:t,s=e.useState,o=e.useEffect,d=e.useLayoutEffect,m=e.useDebugValue;function S(v,i){var l=i(),n=s({inst:{value:l,getSnapshot:i}}),a=n[0].inst,p=n[1];return d(function(){a.value=l,a.getSnapshot=i,w(a)&&p({inst:a})},[v,l,i]),o(function(){return w(a)&&p({inst:a}),v(function(){w(a)&&p({inst:a})})},[v]),m(l),l}function w(v){var i=v.getSnapshot;v=v.value;try{var l=i();return!r(v,l)}catch{return!0}}function f(v,i){return i()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:S;return M.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,M}var V={};/**
9
+ */var j;function Y(){if(j)return V;j=1;var e=T;function t(v,i){return v===i&&(v!==0||1/v===1/i)||v!==v&&i!==i}var r=typeof Object.is=="function"?Object.is:t,a=e.useState,o=e.useEffect,l=e.useLayoutEffect,m=e.useDebugValue;function E(v,i){var c=i(),n=a({inst:{value:c,getSnapshot:i}}),s=n[0].inst,p=n[1];return l(function(){s.value=c,s.getSnapshot=i,w(s)&&p({inst:s})},[v,c,i]),o(function(){return w(s)&&p({inst:s}),v(function(){w(s)&&p({inst:s})})},[v]),m(c),c}function w(v){var i=v.getSnapshot;v=v.value;try{var c=i();return!r(v,c)}catch{return!0}}function f(v,i){return i()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:E;return V.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,V}var M={};/**
10
10
  * @license React
11
11
  * use-sync-external-store-shim.development.js
12
12
  *
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var x;function Q(){return x||(x=1,process.env.NODE_ENV!=="production"&&function(){function e(l,n){return l===n&&(l!==0||1/l===1/n)||l!==l&&n!==n}function t(l,n){c||o.startTransition===void 0||(c=!0,console.error("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."));var a=n();if(!v){var p=n();d(a,p)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),v=!0)}p=m({inst:{value:a,getSnapshot:n}});var E=p[0].inst,y=p[1];return w(function(){E.value=a,E.getSnapshot=n,r(E)&&y({inst:E})},[l,a,n]),S(function(){return r(E)&&y({inst:E}),l(function(){r(E)&&y({inst:E})})},[l]),f(a),a}function r(l){var n=l.getSnapshot;l=l.value;try{var a=n();return!d(l,a)}catch{return!0}}function s(l,n){return n()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=C,d=typeof Object.is=="function"?Object.is:e,m=o.useState,S=o.useEffect,w=o.useLayoutEffect,f=o.useDebugValue,c=!1,v=!1,i=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?s:t;V.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:i,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),V}var I;function G(){return I||(I=1,process.env.NODE_ENV==="production"?L.exports=Y():L.exports=Q()),L.exports}/**
17
+ */var x;function Q(){return x||(x=1,process.env.NODE_ENV!=="production"&&function(){function e(c,n){return c===n&&(c!==0||1/c===1/n)||c!==c&&n!==n}function t(c,n){d||o.startTransition===void 0||(d=!0,console.error("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."));var s=n();if(!v){var p=n();l(s,p)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),v=!0)}p=m({inst:{value:s,getSnapshot:n}});var S=p[0].inst,y=p[1];return w(function(){S.value=s,S.getSnapshot=n,r(S)&&y({inst:S})},[c,s,n]),E(function(){return r(S)&&y({inst:S}),c(function(){r(S)&&y({inst:S})})},[c]),f(s),s}function r(c){var n=c.getSnapshot;c=c.value;try{var s=n();return!l(c,s)}catch{return!0}}function a(c,n){return n()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=T,l=typeof Object.is=="function"?Object.is:e,m=o.useState,E=o.useEffect,w=o.useLayoutEffect,f=o.useDebugValue,d=!1,v=!1,i=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:t;M.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:i,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),M}var I;function G(){return I||(I=1,process.env.NODE_ENV==="production"?A.exports=Y():A.exports=Q()),A.exports}/**
18
18
  * @license React
19
19
  * use-sync-external-store-shim/with-selector.production.js
20
20
  *
@@ -22,7 +22,7 @@
22
22
  *
23
23
  * This source code is licensed under the MIT license found in the
24
24
  * LICENSE file in the root directory of this source tree.
25
- */var W;function X(){if(W)return z;W=1;var e=C,t=G();function r(f,c){return f===c&&(f!==0||1/f===1/c)||f!==f&&c!==c}var s=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,d=e.useRef,m=e.useEffect,S=e.useMemo,w=e.useDebugValue;return z.useSyncExternalStoreWithSelector=function(f,c,v,i,l){var n=d(null);if(n.current===null){var a={hasValue:!1,value:null};n.current=a}else a=n.current;n=S(function(){function E(g){if(!y){if(y=!0,O=g,g=i(g),l!==void 0&&a.hasValue){var b=a.value;if(l(b,g))return N=b}return N=g}if(b=N,s(O,g))return b;var _=i(g);return l!==void 0&&l(b,_)?(O=g,b):(O=g,N=_)}var y=!1,O,N,D=v===void 0?null:v;return[function(){return E(c())},D===null?void 0:function(){return E(D())}]},[c,v,i,l]);var p=o(f,n[0],n[1]);return m(function(){a.hasValue=!0,a.value=p},[p]),w(p),p},z}var k={};/**
25
+ */var W;function X(){if(W)return z;W=1;var e=T,t=G();function r(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var a=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,l=e.useRef,m=e.useEffect,E=e.useMemo,w=e.useDebugValue;return z.useSyncExternalStoreWithSelector=function(f,d,v,i,c){var n=l(null);if(n.current===null){var s={hasValue:!1,value:null};n.current=s}else s=n.current;n=E(function(){function S(g){if(!y){if(y=!0,O=g,g=i(g),c!==void 0&&s.hasValue){var b=s.value;if(c(b,g))return N=b}return N=g}if(b=N,a(O,g))return b;var _=i(g);return c!==void 0&&c(b,_)?(O=g,b):(O=g,N=_)}var y=!1,O,N,L=v===void 0?null:v;return[function(){return S(d())},L===null?void 0:function(){return S(L())}]},[d,v,i,c]);var p=o(f,n[0],n[1]);return m(function(){s.hasValue=!0,s.value=p},[p]),w(p),p},z}var k={};/**
26
26
  * @license React
27
27
  * use-sync-external-store-shim/with-selector.development.js
28
28
  *
@@ -30,4 +30,4 @@
30
30
  *
31
31
  * This source code is licensed under the MIT license found in the
32
32
  * LICENSE file in the root directory of this source tree.
33
- */var H;function Z(){return H||(H=1,process.env.NODE_ENV!=="production"&&function(){function e(f,c){return f===c&&(f!==0||1/f===1/c)||f!==f&&c!==c}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=C,r=G(),s=typeof Object.is=="function"?Object.is:e,o=r.useSyncExternalStore,d=t.useRef,m=t.useEffect,S=t.useMemo,w=t.useDebugValue;k.useSyncExternalStoreWithSelector=function(f,c,v,i,l){var n=d(null);if(n.current===null){var a={hasValue:!1,value:null};n.current=a}else a=n.current;n=S(function(){function E(g){if(!y){if(y=!0,O=g,g=i(g),l!==void 0&&a.hasValue){var b=a.value;if(l(b,g))return N=b}return N=g}if(b=N,s(O,g))return b;var _=i(g);return l!==void 0&&l(b,_)?(O=g,b):(O=g,N=_)}var y=!1,O,N,D=v===void 0?null:v;return[function(){return E(c())},D===null?void 0:function(){return E(D())}]},[c,v,i,l]);var p=o(f,n[0],n[1]);return m(function(){a.hasValue=!0,a.value=p},[p]),w(p),p},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),k}process.env.NODE_ENV==="production"?A.exports=X():A.exports=Z();var $=A.exports;const ee=J($),{useDebugValue:te}=C,{useSyncExternalStoreWithSelector:re}=ee;let we=!1;const oe=e=>e;function ne(e,t=oe,r){const s=re(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return te(s),s}const F=e=>{const t=typeof e=="function"?q(e):e,r=(s,o)=>ne(t,s,o);return Object.assign(r,t),r},se=e=>e?F(e):F;var h=(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))(h||{});const P=(e,t)=>{const r=Math.abs(e.row-t.row),s=Math.abs(e.col-t.col);return Math.floor(10*Math.sqrt(r*r+s*s))},ae=(e,t)=>({row:e.row,col:e.col,g:0,h:P(e,t),f:P(e,t),parent:null}),le=(e,t,r)=>{const s=[{row:e.row-1,col:e.col},{row:e.row+1,col:e.col},{row:e.row,col:e.col-1},{row:e.row,col:e.col+1}];return r&&s.push({row:e.row-1,col:e.col-1},{row:e.row-1,col:e.col+1},{row:e.row+1,col:e.col-1},{row:e.row+1,col:e.col+1}),s.filter(o=>o.row>=0&&o.row<t.length&&o.col>=0&&o.col<t[0].length&&t[o.row][o.col].state!==h.Obstacle).map(o=>({row:o.row,col:o.col,state:t[o.row][o.col].state}))},ce=(e,t,r)=>{const s=Math.abs(e.row-t.row),o=Math.abs(e.col-t.col),d=e.g+(s===0||o===0?10:14),m=P(t,r),S=d+m;return{g:d,h:m,f:S}},ie=e=>{const t=[];let r=e;for(;r;)t.push(r),r=r.parent;return t.reverse()},ue=(e,t,r,s)=>{const o=[],d=[],m=ae(t,r);for(o.push(m);o.length>0;){o.sort((f,c)=>f.f-c.f);const S=o.shift();if(S.row===r.row&&S.col===r.col)return d.push(S),{path:ie(S),visitedNodes:d};d.push(S);const w=le(S,e,s);for(const f of w){if(d.some(n=>n.row===f.row&&n.col===f.col))continue;const{g:c,h:v,f:i}=ce(S,f,r),l=o.find(n=>n.row===f.row&&n.col===f.col);if(!l||c<l.g){const n={row:f.row,col:f.col,g:c,h:v,f:i,parent:S};l?(l.g=c,l.f=i,l.parent=S):o.push(n)}}}return{path:[],visitedNodes:d}},de=e=>({cells:Array.from({length:8},(t,r)=>Array.from({length:12},(s,o)=>({row:r,col:o,state:h.Empty}))),rows:8,columns:12,startTile:null,endTile:null,obstacleTiles:[],path:[],visitedNodes:[],setNumberOfColumns:t=>{e(r=>{const s=r.cells.map(o=>t>r.columns?[...o,...Array.from({length:t-r.columns},(d,m)=>({row:o[0].row,col:r.columns+m,state:h.Empty}))]:o.slice(0,t));return{...r,columns:t,cells:s}})},setNumberOfRows:t=>{e(r=>{let s=[...r.cells];return t>r.rows?s=[...s,...Array.from({length:t-r.rows},(o,d)=>Array.from({length:r.columns},(m,S)=>({row:r.rows+d,col:S,state:h.Empty})))]:s=s.slice(0,t),{...r,rows:t,cells:s}})},setCellState:(t,r,s)=>{e(o=>{const d=o.cells.map(f=>f.map(c=>({...c})));let m=o.startTile,S=o.endTile,w=[...o.obstacleTiles];switch(s===h.Start&&o.startTile&&(d[o.startTile.row][o.startTile.col].state=h.Empty,m=null),s===h.End&&o.endTile&&(d[o.endTile.row][o.endTile.col].state=h.Empty,S=null),d[t][r].state=s,s){case h.Start:m={row:t,col:r};break;case h.End:S={row:t,col:r};break;case h.Obstacle:w.some(f=>f.row===t&&f.col===r)||w.push({row:t,col:r});break;case h.Empty:w=w.filter(f=>!(f.row===t&&f.col===r));break}return{...o,cells:d,startTile:m,endTile:S,obstacleTiles:w}})},resetCells:()=>{e(t=>({...t,cells:t.cells.map(r=>r.map(s=>({...s,state:h.Empty}))),startTile:null,endTile:null,obstacleTiles:[],path:[],visitedNodes:[]}))},handleFindPath:t=>{e(r=>{const s=r.cells.flat().find(d=>d.state===h.Start),o=r.cells.flat().find(d=>d.state===h.End);if(s&&o){const d=r.cells.map(f=>f.map(c=>({row:c.row,col:c.col,state:c.state}))),{path:m,visitedNodes:S}=ue(d,s,o,t);return(async(f,c)=>{for(let v of c)await new Promise(i=>setTimeout(i,100)),e(i=>{const l=i.cells.map(n=>n.map(a=>({...a,state:v.row===a.row&&v.col===a.col&&a.state===h.Empty?h.Visited:a.state})));return{...i,cells:l,visitedNodes:[...i.visitedNodes,v]}});for(let v of f)await new Promise(i=>setTimeout(i,250)),e(i=>{const l=i.cells.map(n=>n.map(a=>({...a,state:v.row===a.row&&v.col===a.col?h.Path:a.state})));return{...i,cells:l,path:[...i.path,v]}})})(m,S),{...r,path:[],visitedNodes:[]}}return r})},setPath:t=>{e(r=>{const s=r.cells.map(o=>o.map(d=>({...d,state:t.some(m=>m.row===d.row&&m.col===d.col)?h.Path:d.state})));return{...r,cells:s}})},setVisitedNodes:t=>{e(r=>{const s=r.cells.map(o=>o.map(d=>({...d,state:t.some(m=>m.row===d.row&&m.col===d.col)&&d.state===h.Empty?h.Visited:d.state})));return{...r,cells:s}})}}),fe=e=>({activeButton:h.Start,setSelectedButtonState:t=>e({activeButton:t}),canTravelDiagonally:!0,setCanTravelDiagonally:t=>e({canTravelDiagonally:t})}),K=se((e,t,r)=>({...de(e),...fe(e)})),ge="",he=()=>{var l;const{cells:e,activeButton:t,setCellState:r,setSelectedButtonState:s,visitedNodes:o,path:d}=K(),[m,S]=C.useState({width:0,height:0}),w=C.useRef(null);C.useEffect(()=>{const n=()=>{if(w.current){const a=w.current.getBoundingClientRect();S({width:a.width,height:a.height})}};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]);const f=(n,a)=>{switch(r(n,a,t),t){case h.Start:s(h.End);break;case h.End:s(h.Obstacle);break}},c=(n,a)=>{const p=o.find(E=>E.row===n&&E.col===a);return p?{g:p.g,h:p.h,f:p.f}:{g:null,h:null,f:null}},i=(()=>{var b;if(!m.width||!m.height)return 20;const n=((b=e[0])==null?void 0:b.length)||1,a=e.length||1,p=20,E=n+a,y=m.width-p-E,O=m.height-p-E,N=y/n,D=O/a,g=Math.min(N,D);return Math.max(15,Math.min(g,60))})();return u.jsx("div",{className:"grid-wrapper",ref:w,children:u.jsx("div",{className:"grid-container",style:{display:"grid",gridTemplateColumns:`repeat(${((l=e[0])==null?void 0:l.length)||1}, ${i}px)`,gridTemplateRows:`repeat(${e.length||1}, ${i}px)`,gap:"1px",padding:"8px",background:"var(--bg-secondary)",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",border:"1px solid var(--border-color)"},children:e.map((n,a)=>n.map((p,E)=>{const y=d.some(_=>_.row===p.row&&_.col===p.col),O=o.some(_=>_.row===p.row&&_.col===p.col),{g:N,h:D,f:g}=c(p.row,p.col);let b=pe(p,O);if(y){const _=d.findIndex(R=>R.row===p.row&&R.col===p.col);_===0?b="var(--cell-start)":_===d.length-1?b="var(--cell-end)":b="var(--cell-path)"}return u.jsxs("div",{className:"grid-cell",onClick:()=>f(a,E),style:{width:i,height:i,backgroundColor:b,border:"1px solid var(--cell-border)",cursor:"pointer",transition:"all 0.15s ease",position:"relative",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"2px"},onMouseEnter:_=>{p.state===h.Empty&&(_.currentTarget.style.backgroundColor="var(--bg-tertiary)",_.currentTarget.style.transform="scale(1.02)")},onMouseLeave:_=>{p.state===h.Empty&&(_.currentTarget.style.backgroundColor=b,_.currentTarget.style.transform="scale(1)")},children:[O&&u.jsxs("div",{className:"cell-values",children:[u.jsxs("div",{className:"value-h",children:["h",D]}),u.jsxs("div",{className:"value-f",children:["f",g]}),u.jsxs("div",{className:"value-g",children:["g",N]})]}),p.state===h.Start&&u.jsx("div",{className:"cell-indicator start",children:"●"}),p.state===h.End&&u.jsx("div",{className:"cell-indicator end",children:"●"}),p.state===h.Obstacle&&u.jsx("div",{className:"cell-indicator obstacle",children:"■"})]},`${a}-${E}`)}))})})},pe=(e,t)=>{if(t)return e.state===h.Start?"var(--cell-start)":e.state===h.End?"var(--cell-end)":"var(--cell-visited)";switch(e.state){case h.Start:return"var(--cell-start)";case h.End:return"var(--cell-end)";case h.Obstacle:return"var(--cell-obstacle)";case h.Empty:return"var(--cell-empty)";default:return"var(--cell-empty)"}},be="",ve=()=>{const{activeButton:e,setSelectedButtonState:t,resetCells:r,rows:s,columns:o,setNumberOfRows:d,setNumberOfColumns:m,handleFindPath:S,canTravelDiagonally:w,setCanTravelDiagonally:f}=K(),[c,v]=C.useState(()=>{const E=localStorage.getItem("darkMode");return E?JSON.parse(E):!1});C.useEffect(()=>{localStorage.setItem("darkMode",JSON.stringify(c)),document.documentElement.setAttribute("data-theme",c?"dark":"light")},[c]);const i=()=>{v(!c)},l=[{label:"Start",state:h.Start},{label:"End",state:h.End},{label:"Obstacle",state:h.Obstacle},{label:"Clear",state:h.Empty},{label:"Reset",state:null}],n=E=>{E===null?a():t(E)},a=()=>{r(),t(h.Start)},p=()=>{S(w)};return u.jsx("div",{className:"control-panel",children:u.jsxs("div",{className:"control-grid",children:[u.jsxs("div",{className:"control-group tools",children:[u.jsx("h3",{className:"group-title",children:"Tools"}),u.jsx("div",{className:"button-group",children:l.map((E,y)=>u.jsx("button",{className:`control-button ${E.label.toLowerCase()} ${e===E.state?"active":""}`,onClick:()=>n(E.state),children:E.label},y))})]}),u.jsxs("div",{className:"control-group actions",children:[u.jsx("h3",{className:"group-title",children:"Actions"}),u.jsxs("div",{className:"button-group",children:[u.jsx("button",{className:"control-button find-path",onClick:p,children:"Find Path"}),u.jsx("button",{className:`control-button diagonal ${w?"active":""}`,onClick:()=>f(!w),children:w?"Diagonal On":"Diagonal Off"}),u.jsx("button",{className:`control-button theme-toggle ${c?"active":""}`,onClick:i,title:c?"Switch to light mode":"Switch to dark mode",children:c?"☀️ Light":"🌙 Dark"})]})]}),u.jsxs("div",{className:"control-group size",children:[u.jsx("h3",{className:"group-title",children:"Grid Size"}),u.jsxs("div",{className:"size-controls",children:[u.jsxs("div",{className:"size-control",children:[u.jsx("label",{className:"size-label",children:"Rows"}),u.jsxs("div",{className:"size-buttons",children:[u.jsx("button",{className:"size-button",onClick:()=>d(Math.max(5,s-1)),disabled:s<=5,children:"−"}),u.jsx("span",{className:"size-value",children:s}),u.jsx("button",{className:"size-button",onClick:()=>d(Math.min(50,s+1)),disabled:s>=50,children:"+"})]})]}),u.jsxs("div",{className:"size-control",children:[u.jsx("label",{className:"size-label",children:"Columns"}),u.jsxs("div",{className:"size-buttons",children:[u.jsx("button",{className:"size-button",onClick:()=>m(Math.max(5,o-1)),disabled:o<=5,children:"−"}),u.jsx("span",{className:"size-value",children:o}),u.jsx("button",{className:"size-button",onClick:()=>m(Math.min(50,o+1)),disabled:o>=50,children:"+"})]})]})]})]})]})})},U=()=>u.jsx("div",{className:"astar-visualizer-root",children:u.jsxs("div",{className:"app-container",children:[u.jsx("header",{className:"app-header",children:u.jsx("h1",{className:"app-title",children:"A* Pathfinding"})}),u.jsx("main",{className:"app-main",children:u.jsx(he,{})}),u.jsx("footer",{className:"app-footer",children:u.jsx(ve,{})})]})});function me(){return u.jsx(U,{})}T.AStarVisualizer=me,T.CellState=h,T.Layout=U,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
33
+ */var H;function Z(){return H||(H=1,process.env.NODE_ENV!=="production"&&function(){function e(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=T,r=G(),a=typeof Object.is=="function"?Object.is:e,o=r.useSyncExternalStore,l=t.useRef,m=t.useEffect,E=t.useMemo,w=t.useDebugValue;k.useSyncExternalStoreWithSelector=function(f,d,v,i,c){var n=l(null);if(n.current===null){var s={hasValue:!1,value:null};n.current=s}else s=n.current;n=E(function(){function S(g){if(!y){if(y=!0,O=g,g=i(g),c!==void 0&&s.hasValue){var b=s.value;if(c(b,g))return N=b}return N=g}if(b=N,a(O,g))return b;var _=i(g);return c!==void 0&&c(b,_)?(O=g,b):(O=g,N=_)}var y=!1,O,N,L=v===void 0?null:v;return[function(){return S(d())},L===null?void 0:function(){return S(L())}]},[d,v,i,c]);var p=o(f,n[0],n[1]);return m(function(){s.hasValue=!0,s.value=p},[p]),w(p),p},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),k}process.env.NODE_ENV==="production"?D.exports=X():D.exports=Z();var $=D.exports;const ee=q($),{useDebugValue:te}=T,{useSyncExternalStoreWithSelector:re}=ee;let we=!1;const oe=e=>e;function ne(e,t=oe,r){const a=re(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return te(a),a}const F=e=>{const t=typeof e=="function"?J(e):e,r=(a,o)=>ne(t,a,o);return Object.assign(r,t),r},se=e=>e?F(e):F;var h=(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))(h||{});const P=(e,t)=>{const r=Math.abs(e.row-t.row),a=Math.abs(e.col-t.col);return Math.floor(10*Math.sqrt(r*r+a*a))},ae=(e,t)=>({row:e.row,col:e.col,g:0,h:P(e,t),f:P(e,t),parent:null}),le=(e,t,r)=>{const a=[{row:e.row-1,col:e.col},{row:e.row+1,col:e.col},{row:e.row,col:e.col-1},{row:e.row,col:e.col+1}];return r&&a.push({row:e.row-1,col:e.col-1},{row:e.row-1,col:e.col+1},{row:e.row+1,col:e.col-1},{row:e.row+1,col:e.col+1}),a.filter(o=>o.row>=0&&o.row<t.length&&o.col>=0&&o.col<t[0].length&&t[o.row][o.col].state!==h.Obstacle).map(o=>({row:o.row,col:o.col,state:t[o.row][o.col].state}))},ce=(e,t,r)=>{const a=Math.abs(e.row-t.row),o=Math.abs(e.col-t.col),l=e.g+(a===0||o===0?10:14),m=P(t,r),E=l+m;return{g:l,h:m,f:E}},ie=e=>{const t=[];let r=e;for(;r;)t.push(r),r=r.parent;return t.reverse()},ue=(e,t,r,a)=>{const o=[],l=[],m=ae(t,r);for(o.push(m);o.length>0;){o.sort((f,d)=>f.f-d.f);const E=o.shift();if(E.row===r.row&&E.col===r.col)return l.push(E),{path:ie(E),visitedNodes:l};l.push(E);const w=le(E,e,a);for(const f of w){if(l.some(n=>n.row===f.row&&n.col===f.col))continue;const{g:d,h:v,f:i}=ce(E,f,r),c=o.find(n=>n.row===f.row&&n.col===f.col);if(!c||d<c.g){const n={row:f.row,col:f.col,g:d,h:v,f:i,parent:E};c?(c.g=d,c.f=i,c.parent=E):o.push(n)}}}return{path:[],visitedNodes:l}},de=e=>({cells:Array.from({length:8},(t,r)=>Array.from({length:12},(a,o)=>({row:r,col:o,state:h.Empty}))),rows:8,columns:12,startTile:null,endTile:null,obstacleTiles:[],path:[],visitedNodes:[],setNumberOfColumns:t=>{e(r=>{const a=r.cells.map(o=>t>r.columns?[...o,...Array.from({length:t-r.columns},(l,m)=>({row:o[0].row,col:r.columns+m,state:h.Empty}))]:o.slice(0,t));return{...r,columns:t,cells:a}})},setNumberOfRows:t=>{e(r=>{let a=[...r.cells];return t>r.rows?a=[...a,...Array.from({length:t-r.rows},(o,l)=>Array.from({length:r.columns},(m,E)=>({row:r.rows+l,col:E,state:h.Empty})))]:a=a.slice(0,t),{...r,rows:t,cells:a}})},setCellState:(t,r,a)=>{e(o=>{const l=o.cells.map(f=>f.map(d=>({...d})));let m=o.startTile,E=o.endTile,w=[...o.obstacleTiles];switch(a===h.Start&&o.startTile&&(l[o.startTile.row][o.startTile.col].state=h.Empty,m=null),a===h.End&&o.endTile&&(l[o.endTile.row][o.endTile.col].state=h.Empty,E=null),l[t][r].state=a,a){case h.Start:m={row:t,col:r};break;case h.End:E={row:t,col:r};break;case h.Obstacle:w.some(f=>f.row===t&&f.col===r)||w.push({row:t,col:r});break;case h.Empty:w=w.filter(f=>!(f.row===t&&f.col===r));break}return{...o,cells:l,startTile:m,endTile:E,obstacleTiles:w}})},resetCells:()=>{e(t=>({...t,cells:t.cells.map(r=>r.map(a=>({...a,state:h.Empty}))),startTile:null,endTile:null,obstacleTiles:[],path:[],visitedNodes:[]}))},handleFindPath:t=>{e(r=>{const a=r.cells.flat().find(l=>l.state===h.Start),o=r.cells.flat().find(l=>l.state===h.End);if(a&&o){const l=r.cells.map(f=>f.map(d=>({row:d.row,col:d.col,state:d.state}))),{path:m,visitedNodes:E}=ue(l,a,o,t);return(async(f,d)=>{for(let v of d)await new Promise(i=>setTimeout(i,100)),e(i=>{const c=i.cells.map(n=>n.map(s=>({...s,state:v.row===s.row&&v.col===s.col&&s.state===h.Empty?h.Visited:s.state})));return{...i,cells:c,visitedNodes:[...i.visitedNodes,v]}});for(let v of f)await new Promise(i=>setTimeout(i,250)),e(i=>{const c=i.cells.map(n=>n.map(s=>({...s,state:v.row===s.row&&v.col===s.col?h.Path:s.state})));return{...i,cells:c,path:[...i.path,v]}})})(m,E),{...r,path:[],visitedNodes:[]}}return r})},setPath:t=>{e(r=>{const a=r.cells.map(o=>o.map(l=>({...l,state:t.some(m=>m.row===l.row&&m.col===l.col)?h.Path:l.state})));return{...r,cells:a}})},setVisitedNodes:t=>{e(r=>{const a=r.cells.map(o=>o.map(l=>({...l,state:t.some(m=>m.row===l.row&&m.col===l.col)&&l.state===h.Empty?h.Visited:l.state})));return{...r,cells:a}})}}),fe=e=>({activeButton:h.Start,setSelectedButtonState:t=>e({activeButton:t}),canTravelDiagonally:!0,setCanTravelDiagonally:t=>e({canTravelDiagonally:t})}),K=se((e,t,r)=>({...de(e),...fe(e)})),ge="",he=()=>{var c;const{cells:e,activeButton:t,setCellState:r,setSelectedButtonState:a,visitedNodes:o,path:l}=K(),[m,E]=T.useState({width:0,height:0}),w=T.useRef(null);T.useEffect(()=>{const n=()=>{if(w.current){const s=w.current.getBoundingClientRect();E({width:s.width,height:s.height})}};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]);const f=(n,s)=>{switch(r(n,s,t),t){case h.Start:a(h.End);break;case h.End:a(h.Obstacle);break}},d=(n,s)=>{const p=o.find(S=>S.row===n&&S.col===s);return p?{g:p.g,h:p.h,f:p.f}:{g:null,h:null,f:null}},i=(()=>{var b;if(!m.width||!m.height)return 20;const n=((b=e[0])==null?void 0:b.length)||1,s=e.length||1,p=20,S=n+s,y=m.width-p-S,O=m.height-p-S,N=y/n,L=O/s,g=Math.min(N,L);return Math.max(15,Math.min(g,60))})();return u.jsx("div",{className:"grid-wrapper",ref:w,children:u.jsx("div",{className:"grid-container",style:{display:"grid",gridTemplateColumns:`repeat(${((c=e[0])==null?void 0:c.length)||1}, ${i}px)`,gridTemplateRows:`repeat(${e.length||1}, ${i}px)`,gap:"1px",padding:"8px",background:"var(--bg-secondary)",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",border:"1px solid var(--border-color)"},children:e.map((n,s)=>n.map((p,S)=>{const y=l.some(_=>_.row===p.row&&_.col===p.col),O=o.some(_=>_.row===p.row&&_.col===p.col),{g:N,h:L,f:g}=d(p.row,p.col);let b=pe(p,O);if(y){const _=l.findIndex(R=>R.row===p.row&&R.col===p.col);_===0?b="var(--cell-start)":_===l.length-1?b="var(--cell-end)":b="var(--cell-path)"}return u.jsxs("div",{className:"grid-cell",onClick:()=>f(s,S),style:{width:i,height:i,backgroundColor:b,border:"1px solid var(--cell-border)",cursor:"pointer",transition:"all 0.15s ease",position:"relative",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"2px"},onMouseEnter:_=>{p.state===h.Empty&&(_.currentTarget.style.backgroundColor="var(--bg-tertiary)",_.currentTarget.style.transform="scale(1.02)")},onMouseLeave:_=>{p.state===h.Empty&&(_.currentTarget.style.backgroundColor=b,_.currentTarget.style.transform="scale(1)")},children:[O&&u.jsxs("div",{className:"cell-values",children:[u.jsxs("div",{className:"value-h",children:["h",L]}),u.jsxs("div",{className:"value-f",children:["f",g]}),u.jsxs("div",{className:"value-g",children:["g",N]})]}),p.state===h.Start&&u.jsx("div",{className:"cell-indicator start",children:"●"}),p.state===h.End&&u.jsx("div",{className:"cell-indicator end",children:"●"}),p.state===h.Obstacle&&u.jsx("div",{className:"cell-indicator obstacle",children:"■"})]},`${s}-${S}`)}))})})},pe=(e,t)=>{if(t)return e.state===h.Start?"var(--cell-start)":e.state===h.End?"var(--cell-end)":"var(--cell-visited)";switch(e.state){case h.Start:return"var(--cell-start)";case h.End:return"var(--cell-end)";case h.Obstacle:return"var(--cell-obstacle)";case h.Empty:return"var(--cell-empty)";default:return"var(--cell-empty)"}},be="",ve=({isDarkMode:e,setIsDarkMode:t})=>{const{activeButton:r,setSelectedButtonState:a,resetCells:o,rows:l,columns:m,setNumberOfRows:E,setNumberOfColumns:w,handleFindPath:f,canTravelDiagonally:d,setCanTravelDiagonally:v}=K(),i=()=>{t(!e)},c=[{label:"Start",state:h.Start},{label:"End",state:h.End},{label:"Obstacle",state:h.Obstacle},{label:"Clear",state:h.Empty},{label:"Reset",state:null}],n=S=>{S===null?s():a(S)},s=()=>{o(),a(h.Start)},p=()=>{f(d)};return u.jsx("div",{className:"control-panel",children:u.jsxs("div",{className:"control-grid",children:[u.jsxs("div",{className:"control-group tools",children:[u.jsx("h3",{className:"group-title",children:"Tools"}),u.jsx("div",{className:"button-group",children:c.map((S,y)=>u.jsx("button",{className:`control-button ${S.label.toLowerCase()} ${r===S.state?"active":""}`,onClick:()=>n(S.state),children:S.label},y))})]}),u.jsxs("div",{className:"control-group actions",children:[u.jsx("h3",{className:"group-title",children:"Actions"}),u.jsxs("div",{className:"button-group",children:[u.jsx("button",{className:"control-button find-path",onClick:p,children:"Find Path"}),u.jsx("button",{className:`control-button diagonal ${d?"active":""}`,onClick:()=>v(!d),children:d?"Diagonal On":"Diagonal Off"}),u.jsx("button",{className:`control-button theme-toggle ${e?"active":""}`,onClick:i,title:e?"Switch to light mode":"Switch to dark mode",children:e?"☀️ Light":"🌙 Dark"})]})]}),u.jsxs("div",{className:"control-group size",children:[u.jsx("h3",{className:"group-title",children:"Grid Size"}),u.jsxs("div",{className:"size-controls",children:[u.jsxs("div",{className:"size-control",children:[u.jsx("label",{className:"size-label",children:"Rows"}),u.jsxs("div",{className:"size-buttons",children:[u.jsx("button",{className:"size-button",onClick:()=>E(Math.max(5,l-1)),disabled:l<=5,children:"−"}),u.jsx("span",{className:"size-value",children:l}),u.jsx("button",{className:"size-button",onClick:()=>E(Math.min(50,l+1)),disabled:l>=50,children:"+"})]})]}),u.jsxs("div",{className:"size-control",children:[u.jsx("label",{className:"size-label",children:"Columns"}),u.jsxs("div",{className:"size-buttons",children:[u.jsx("button",{className:"size-button",onClick:()=>w(Math.max(5,m-1)),disabled:m<=5,children:"−"}),u.jsx("span",{className:"size-value",children:m}),u.jsx("button",{className:"size-button",onClick:()=>w(Math.min(50,m+1)),disabled:m>=50,children:"+"})]})]})]})]})]})})},U=({defaultDarkMode:e})=>{const t=T.useRef(null),[r,a]=T.useState(()=>{if(e!==void 0)return e;const o=localStorage.getItem("astar-darkMode");return o?JSON.parse(o):!1});return T.useEffect(()=>{e===void 0&&localStorage.setItem("astar-darkMode",JSON.stringify(r)),t.current&&t.current.setAttribute("data-theme",r?"dark":"light")},[r,e]),u.jsx("div",{ref:t,className:"astar-visualizer-root","data-theme":r?"dark":"light",children:u.jsxs("div",{className:"app-container",children:[u.jsx("header",{className:"app-header",children:u.jsx("h1",{className:"app-title",children:"A* Pathfinding"})}),u.jsx("main",{className:"app-main",children:u.jsx(he,{})}),u.jsx("footer",{className:"app-footer",children:u.jsx(ve,{isDarkMode:r,setIsDarkMode:a})})]})})};function me({defaultDarkMode:e}){return u.jsx(U,{defaultDarkMode:e})}C.AStarVisualizer=me,C.CellState=h,C.Layout=U,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- :root{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;line-height:1.5;font-weight:400;--bg-primary: #fafafa;--bg-secondary: #ffffff;--bg-tertiary: #f5f5f5;--text-primary: #1a1a1a;--text-secondary: #666666;--text-muted: #999999;--border-color: #e0e0e0;--border-hover: #d0d0d0;--cell-empty: #ffffff;--cell-start: #4caf50;--cell-end: #f44336;--cell-obstacle: #424242;--cell-visited: #2196f3;--cell-path: #ff9800;--cell-border: #e0e0e0;--primary: #2196f3;--primary-hover: #1976d2;--success: #4caf50;--success-hover: #388e3c;--danger: #f44336;--danger-hover: #d32f2f;--warning: #ff9800;--warning-hover: #f57c00;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}[data-theme=dark]{--bg-primary: #0f0f0f;--bg-secondary: #1a1a1a;--bg-tertiary: #2a2a2a;--text-primary: #ffffff;--text-secondary: #b3b3b3;--text-muted: #808080;--border-color: #404040;--border-hover: #505050;--cell-empty: #2a2a2a;--cell-start: #4caf50;--cell-end: #f44336;--cell-obstacle: #1a1a1a;--cell-visited: #2196f3;--cell-path: #ff9800;--cell-border: #404040;--primary: #2196f3;--primary-hover: #1976d2;--success: #4caf50;--success-hover: #388e3c;--danger: #f44336;--danger-hover: #d32f2f;--warning: #ff9800;--warning-hover: #f57c00}*{box-sizing:border-box;margin:0;padding:0}html,body{margin:0;padding:0;width:100%;height:100%;overflow:hidden}#root{width:100%;height:100%;margin:0;padding:0}*,*:before,*:after{transition:background-color .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.astar-visualizer-root{width:100%;height:100%;display:flex;flex-direction:column;margin:0;padding:0;overflow:hidden;background:var(--bg-primary);color:var(--text-primary);position:relative}.astar-visualizer-root *{box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}.astar-visualizer-root .app-container{display:flex;flex-direction:column;height:100%;width:100%}.astar-visualizer-root .app-header{padding:.5rem 1rem;background:var(--bg-secondary);border-bottom:1px solid var(--border-color);text-align:center;flex-shrink:0}.astar-visualizer-root .app-title{font-size:1.25rem;font-weight:600;margin:0;color:var(--text-primary);letter-spacing:-.025em}.astar-visualizer-root .app-main{flex:1;display:flex;justify-content:center;align-items:center;padding:.5rem;overflow:hidden;min-height:0}.astar-visualizer-root .app-footer{padding:.5rem 1rem;background:var(--bg-secondary);border-top:1px solid var(--border-color);flex-shrink:0;overflow-y:auto;max-height:30%}.astar-visualizer-root button{border:1px solid var(--border-color);border-radius:6px;padding:.5rem 1rem;font-size:.875rem;font-weight:500;font-family:inherit;background:var(--bg-secondary);color:var(--text-primary);cursor:pointer;transition:all .2s ease;outline:none}.astar-visualizer-root button:hover{border-color:var(--border-hover);background:var(--bg-tertiary)}.astar-visualizer-root button:active{transform:translateY(1px)}.astar-visualizer-root button:focus-visible{outline:2px solid var(--primary);outline-offset:2px}@media (max-width: 768px){.astar-visualizer-root .app-header{padding:.75rem 1.5rem}.astar-visualizer-root .app-title{font-size:1.5rem}.astar-visualizer-root .app-main{padding:.25rem}.astar-visualizer-root .app-footer{padding:.75rem 1.5rem}}@media (max-width: 480px){.astar-visualizer-root .app-header{padding:.5rem 1rem}.astar-visualizer-root .app-title{font-size:1.25rem}.astar-visualizer-root .app-main{padding:.125rem}.astar-visualizer-root .app-footer{padding:.5rem 1rem}}@media (max-height: 600px){.astar-visualizer-root .app-header{padding:.5rem 1rem}.astar-visualizer-root .app-title{font-size:1.25rem}.astar-visualizer-root .app-footer{padding:.5rem 1rem}}@media (max-height: 400px){.astar-visualizer-root .app-header{padding:.25rem .5rem}.astar-visualizer-root .app-title{font-size:1rem}.astar-visualizer-root .app-footer{padding:.25rem .5rem}}.astar-visualizer-root #root{width:100%;height:100%;margin:0;padding:0;overflow:hidden;display:flex;flex-direction:column}.astar-visualizer-root .loading{display:flex;justify-content:center;align-items:center;height:100%;font-size:1.5rem;color:var(--text-secondary)}.astar-visualizer-root .error{display:flex;flex-direction:column;justify-content:center;align-items:center;height:100%;padding:2rem;text-align:center}.astar-visualizer-root .error h2{color:var(--danger);margin-bottom:1rem}.astar-visualizer-root .error p{color:var(--text-secondary);max-width:500px}@media (prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}*{transition:none!important}}@media (prefers-contrast: high){:root{--cell-border: #000000;--text-primary: #000000;--text-secondary: #000000;--bg-primary: #ffffff;--bg-secondary: #ffffff}[data-theme=dark]{--cell-border: #ffffff;--text-primary: #ffffff;--text-secondary: #ffffff;--bg-primary: #000000;--bg-secondary: #000000}}@media print{.astar-visualizer-root .app-footer{display:none}.astar-visualizer-root .app-header{background:white!important;color:#000!important}.astar-visualizer-root .grid-container{box-shadow:none!important;border:2px solid black!important}}.astar-visualizer-root .grid-wrapper{display:flex;justify-content:center;align-items:center;width:100%;height:100%;padding:.5rem;box-sizing:border-box;overflow:hidden}.astar-visualizer-root .grid-container{display:grid;gap:1px;padding:4px;background:var(--bg-secondary);border-radius:4px;box-shadow:0 2px 8px #0000001a;border:1px solid var(--border-color);width:fit-content;height:fit-content}.astar-visualizer-root .grid-cell{position:relative;display:flex;justify-content:center;align-items:center;border:1px solid var(--cell-border);cursor:pointer;transition:all .15s ease;border-radius:2px;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.astar-visualizer-root .grid-cell:hover{transform:scale(1.02)}.astar-visualizer-root .grid-cell:active{transform:scale(.98)}.astar-visualizer-root .cell-values{position:absolute;top:0;left:0;right:0;bottom:0;display:grid;grid-template-columns:1fr 1fr 1fr;grid-template-rows:1fr 1fr;font-size:.75rem;font-weight:700;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.9);pointer-events:none}.astar-visualizer-root .value-h{grid-column:1;grid-row:1;display:flex;align-items:center;justify-content:center;font-size:.65rem}.astar-visualizer-root .value-f{grid-column:3;grid-row:1;display:flex;align-items:center;justify-content:center;font-size:.65rem}.astar-visualizer-root .value-g{grid-column:2;grid-row:2;display:flex;align-items:center;justify-content:center;font-size:.65rem}.astar-visualizer-root .cell-indicator{font-size:1.2rem;font-weight:700;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.9)}.astar-visualizer-root .cell-indicator.start,.astar-visualizer-root .cell-indicator.end,.astar-visualizer-root .cell-indicator.obstacle{color:#fff}@media (max-width: 768px){.astar-visualizer-root .cell-values{font-size:.6rem}.astar-visualizer-root .value-h,.astar-visualizer-root .value-f,.astar-visualizer-root .value-g{font-size:.5rem}.astar-visualizer-root .cell-indicator{font-size:1rem}}@media (max-width: 480px){.astar-visualizer-root .cell-values{font-size:.5rem}.astar-visualizer-root .value-h,.astar-visualizer-root .value-f,.astar-visualizer-root .value-g{font-size:.4rem}.astar-visualizer-root .cell-indicator{font-size:.9rem}}.astar-visualizer-root .control-panel{padding:1rem;background:var(--bg-secondary);border-radius:8px;border:1px solid var(--border-color);box-shadow:0 2px 8px #0000001a}.astar-visualizer-root .control-grid{display:grid;grid-template-columns:1fr;gap:1.5rem;align-items:start}.astar-visualizer-root .control-group{display:flex;flex-direction:column;gap:.75rem}.astar-visualizer-root .group-title{font-size:.875rem;font-weight:600;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.05em;margin:0;padding-bottom:.5rem;border-bottom:1px solid var(--border-color)}.astar-visualizer-root .button-group{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;justify-content:center}.astar-visualizer-root .control-button{padding:.5rem 1rem;font-size:.875rem;font-weight:500;color:var(--text-primary);background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:6px;cursor:pointer;transition:all .2s ease;outline:none;min-width:fit-content}.astar-visualizer-root .control-button:hover{border-color:var(--border-hover);background:var(--bg-tertiary)}.astar-visualizer-root .control-button:active{transform:translateY(1px)}.astar-visualizer-root .control-button:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.astar-visualizer-root .control-button.start.active{background:var(--success);border-color:var(--success);color:#fff}.astar-visualizer-root .control-button.end.active{background:var(--danger);border-color:var(--danger);color:#fff}.astar-visualizer-root .control-button.obstacle.active{background:var(--text-primary);border-color:var(--text-primary);color:#fff}.astar-visualizer-root .control-button.clear.active{background:var(--text-muted);border-color:var(--text-muted);color:#fff}.astar-visualizer-root .control-button.reset{background:var(--danger);border-color:var(--danger);color:#fff}.astar-visualizer-root .control-button.reset:hover{background:var(--danger-hover);border-color:var(--danger-hover)}.astar-visualizer-root .control-button.find-path{background:var(--primary);border-color:var(--primary);color:#fff}.astar-visualizer-root .control-button.find-path:hover{background:var(--primary-hover);border-color:var(--primary-hover)}.astar-visualizer-root .control-button.diagonal.active{background:var(--warning);border-color:var(--warning);color:#fff}.astar-visualizer-root .control-button.diagonal:hover{background:var(--warning-hover);border-color:var(--warning-hover)}.astar-visualizer-root .control-button.theme-toggle{background:var(--text-muted);border-color:var(--text-muted);color:#fff}.astar-visualizer-root .control-button.theme-toggle:hover{background:var(--text-secondary);border-color:var(--text-secondary)}.astar-visualizer-root .control-button.theme-toggle.active{background:var(--warning);border-color:var(--warning);color:#fff}.astar-visualizer-root .control-button.theme-toggle.active:hover{background:var(--warning-hover);border-color:var(--warning-hover)}.astar-visualizer-root .size-controls{display:flex;flex-direction:column;gap:.75rem;align-items:center}.astar-visualizer-root .size-control{display:flex;flex-direction:column;gap:.25rem;align-items:center}.astar-visualizer-root .size-label{font-size:.75rem;font-weight:500;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.05em}.astar-visualizer-root .size-buttons{display:flex;align-items:center;gap:.5rem}.astar-visualizer-root .size-button{display:flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;font-size:1rem;font-weight:600;color:var(--text-primary);background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:4px;cursor:pointer;transition:all .2s ease;outline:none}.astar-visualizer-root .size-button:hover:not(:disabled){background:var(--primary);border-color:var(--primary);color:#fff}.astar-visualizer-root .size-button:active:not(:disabled){transform:scale(.95)}.astar-visualizer-root .size-button:disabled{opacity:.4;cursor:not-allowed}.astar-visualizer-root .size-button:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.astar-visualizer-root .size-value{display:flex;align-items:center;justify-content:center;min-width:2.5rem;height:1.75rem;font-size:.875rem;font-weight:600;color:var(--text-primary);background:var(--bg-tertiary);border:1px solid var(--border-color);border-radius:4px}@media (min-width: 1024px){.astar-visualizer-root .control-grid{grid-template-columns:2fr 1fr 1fr;gap:2rem}.astar-visualizer-root .control-group.tools{grid-column:1}.astar-visualizer-root .control-group.actions{grid-column:2}.astar-visualizer-root .control-group.size{grid-column:3}}@media (min-width: 768px) and (max-width: 1023px){.astar-visualizer-root .control-grid{grid-template-columns:1fr 1fr;gap:1.5rem}.astar-visualizer-root .control-group.tools{grid-column:1 / -1}.astar-visualizer-root .control-group.actions{grid-column:1}.astar-visualizer-root .control-group.size{grid-column:2}}@media (max-width: 768px){.astar-visualizer-root .control-panel{padding:.75rem}.astar-visualizer-root .control-grid{gap:1rem}.astar-visualizer-root .button-group{gap:.375rem}.astar-visualizer-root .control-button{padding:.375rem .75rem;font-size:.8125rem}.astar-visualizer-root .size-controls{gap:.5rem}.astar-visualizer-root .size-buttons{gap:.375rem}.astar-visualizer-root .size-button{width:1.5rem;height:1.5rem;font-size:.875rem}.astar-visualizer-root .size-value{min-width:2rem;height:1.5rem;font-size:.8125rem}}@media (max-width: 480px){.astar-visualizer-root .control-panel{padding:.5rem}.astar-visualizer-root .control-grid{gap:.75rem}.astar-visualizer-root .button-group{flex-direction:column;gap:.25rem}.astar-visualizer-root .control-button{width:100%;padding:.5rem;font-size:.75rem}.astar-visualizer-root .size-controls{gap:.375rem}.astar-visualizer-root .size-buttons{gap:.25rem}.astar-visualizer-root .size-button{width:1.25rem;height:1.25rem;font-size:.75rem}.astar-visualizer-root .size-value{min-width:1.75rem;height:1.25rem;font-size:.75rem}}
1
+ :root{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;line-height:1.5;font-weight:400;--bg-primary: #fafafa;--bg-secondary: #ffffff;--bg-tertiary: #f5f5f5;--text-primary: #1a1a1a;--text-secondary: #666666;--text-muted: #999999;--border-color: #e0e0e0;--border-hover: #d0d0d0;--cell-empty: #ffffff;--cell-start: #4caf50;--cell-end: #f44336;--cell-obstacle: #424242;--cell-visited: #2196f3;--cell-path: #ff9800;--cell-border: #e0e0e0;--primary: #2196f3;--primary-hover: #1976d2;--success: #4caf50;--success-hover: #388e3c;--danger: #f44336;--danger-hover: #d32f2f;--warning: #ff9800;--warning-hover: #f57c00;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%}.astar-visualizer-root[data-theme=dark]{--bg-primary: #0f0f0f;--bg-secondary: #1a1a1a;--bg-tertiary: #2a2a2a;--text-primary: #ffffff;--text-secondary: #b3b3b3;--text-muted: #808080;--border-color: #404040;--border-hover: #505050;--cell-empty: #2a2a2a;--cell-start: #4caf50;--cell-end: #f44336;--cell-obstacle: #1a1a1a;--cell-visited: #2196f3;--cell-path: #ff9800;--cell-border: #404040;--primary: #2196f3;--primary-hover: #1976d2;--success: #4caf50;--success-hover: #388e3c;--danger: #f44336;--danger-hover: #d32f2f;--warning: #ff9800;--warning-hover: #f57c00}.astar-visualizer-root,.astar-visualizer-root *,.astar-visualizer-root *:before,.astar-visualizer-root *:after{transition:background-color .3s ease,color .3s ease,border-color .3s ease,box-shadow .3s ease}.astar-visualizer-root{width:100%;height:100%;display:flex;flex-direction:column;margin:0;padding:0;overflow:hidden;background:var(--bg-primary);color:var(--text-primary);position:relative}.astar-visualizer-root *{box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}.astar-visualizer-root .app-container{display:flex;flex-direction:column;height:100%;width:100%}.astar-visualizer-root .app-header{padding:.5rem 1rem;background:var(--bg-secondary);border-bottom:1px solid var(--border-color);text-align:center;flex-shrink:0}.astar-visualizer-root .app-title{font-size:1.25rem;font-weight:600;margin:0;color:var(--text-primary);letter-spacing:-.025em}.astar-visualizer-root .app-main{flex:1;display:flex;justify-content:center;align-items:center;padding:.5rem;overflow:hidden;min-height:0}.astar-visualizer-root .app-footer{padding:.5rem 1rem;background:var(--bg-secondary);border-top:1px solid var(--border-color);flex-shrink:0;overflow-y:auto;max-height:30%}.astar-visualizer-root button{border:1px solid var(--border-color);border-radius:6px;padding:.5rem 1rem;font-size:.875rem;font-weight:500;font-family:inherit;background:var(--bg-secondary);color:var(--text-primary);cursor:pointer;transition:all .2s ease;outline:none}.astar-visualizer-root button:hover{border-color:var(--border-hover);background:var(--bg-tertiary)}.astar-visualizer-root button:active{transform:translateY(1px)}.astar-visualizer-root button:focus-visible{outline:2px solid var(--primary);outline-offset:2px}@media (max-width: 768px){.astar-visualizer-root .app-header{padding:.75rem 1.5rem}.astar-visualizer-root .app-title{font-size:1.5rem}.astar-visualizer-root .app-main{padding:.25rem}.astar-visualizer-root .app-footer{padding:.75rem 1.5rem}}@media (max-width: 480px){.astar-visualizer-root .app-header{padding:.5rem 1rem}.astar-visualizer-root .app-title{font-size:1.25rem}.astar-visualizer-root .app-main{padding:.125rem}.astar-visualizer-root .app-footer{padding:.5rem 1rem}}@media (max-height: 600px){.astar-visualizer-root .app-header{padding:.5rem 1rem}.astar-visualizer-root .app-title{font-size:1.25rem}.astar-visualizer-root .app-footer{padding:.5rem 1rem}}@media (max-height: 400px){.astar-visualizer-root .app-header{padding:.25rem .5rem}.astar-visualizer-root .app-title{font-size:1rem}.astar-visualizer-root .app-footer{padding:.25rem .5rem}}.astar-visualizer-root #root{width:100%;height:100%;margin:0;padding:0;overflow:hidden;display:flex;flex-direction:column}.astar-visualizer-root .loading{display:flex;justify-content:center;align-items:center;height:100%;font-size:1.5rem;color:var(--text-secondary)}.astar-visualizer-root .error{display:flex;flex-direction:column;justify-content:center;align-items:center;height:100%;padding:2rem;text-align:center}.astar-visualizer-root .error h2{color:var(--danger);margin-bottom:1rem}.astar-visualizer-root .error p{color:var(--text-secondary);max-width:500px}@media (prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}*{transition:none!important}}@media (prefers-contrast: high){:root{--cell-border: #000000;--text-primary: #000000;--text-secondary: #000000;--bg-primary: #ffffff;--bg-secondary: #ffffff}[data-theme=dark]{--cell-border: #ffffff;--text-primary: #ffffff;--text-secondary: #ffffff;--bg-primary: #000000;--bg-secondary: #000000}}@media print{.astar-visualizer-root .app-footer{display:none}.astar-visualizer-root .app-header{background:white!important;color:#000!important}.astar-visualizer-root .grid-container{box-shadow:none!important;border:2px solid black!important}}.astar-visualizer-root .grid-wrapper{display:flex;justify-content:center;align-items:center;width:100%;height:100%;padding:.5rem;box-sizing:border-box;overflow:hidden}.astar-visualizer-root .grid-container{display:grid;gap:1px;padding:4px;background:var(--bg-secondary);border-radius:4px;box-shadow:0 2px 8px #0000001a;border:1px solid var(--border-color);width:fit-content;height:fit-content}.astar-visualizer-root .grid-cell{position:relative;display:flex;justify-content:center;align-items:center;border:1px solid var(--cell-border);cursor:pointer;transition:all .15s ease;border-radius:2px;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.astar-visualizer-root .grid-cell:hover{transform:scale(1.02)}.astar-visualizer-root .grid-cell:active{transform:scale(.98)}.astar-visualizer-root .cell-values{position:absolute;top:0;left:0;right:0;bottom:0;display:grid;grid-template-columns:1fr 1fr 1fr;grid-template-rows:1fr 1fr;font-size:.75rem;font-weight:700;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.9);pointer-events:none}.astar-visualizer-root .value-h{grid-column:1;grid-row:1;display:flex;align-items:center;justify-content:center;font-size:.65rem}.astar-visualizer-root .value-f{grid-column:3;grid-row:1;display:flex;align-items:center;justify-content:center;font-size:.65rem}.astar-visualizer-root .value-g{grid-column:2;grid-row:2;display:flex;align-items:center;justify-content:center;font-size:.65rem}.astar-visualizer-root .cell-indicator{font-size:1.2rem;font-weight:700;color:#fff;text-shadow:0 2px 4px rgba(0,0,0,.9)}.astar-visualizer-root .cell-indicator.start,.astar-visualizer-root .cell-indicator.end,.astar-visualizer-root .cell-indicator.obstacle{color:#fff}@media (max-width: 768px){.astar-visualizer-root .cell-values{font-size:.6rem}.astar-visualizer-root .value-h,.astar-visualizer-root .value-f,.astar-visualizer-root .value-g{font-size:.5rem}.astar-visualizer-root .cell-indicator{font-size:1rem}}@media (max-width: 480px){.astar-visualizer-root .cell-values{font-size:.5rem}.astar-visualizer-root .value-h,.astar-visualizer-root .value-f,.astar-visualizer-root .value-g{font-size:.4rem}.astar-visualizer-root .cell-indicator{font-size:.9rem}}.astar-visualizer-root .control-panel{padding:1rem;background:var(--bg-secondary);border-radius:8px;border:1px solid var(--border-color);box-shadow:0 2px 8px #0000001a}.astar-visualizer-root .control-grid{display:grid;grid-template-columns:1fr;gap:1.5rem;align-items:start}.astar-visualizer-root .control-group{display:flex;flex-direction:column;gap:.75rem}.astar-visualizer-root .group-title{font-size:.875rem;font-weight:600;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.05em;margin:0;padding-bottom:.5rem;border-bottom:1px solid var(--border-color)}.astar-visualizer-root .button-group{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;justify-content:center}.astar-visualizer-root .control-button{padding:.5rem 1rem;font-size:.875rem;font-weight:500;color:var(--text-primary);background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:6px;cursor:pointer;transition:all .2s ease;outline:none;min-width:fit-content}.astar-visualizer-root .control-button:hover{border-color:var(--border-hover);background:var(--bg-tertiary)}.astar-visualizer-root .control-button:active{transform:translateY(1px)}.astar-visualizer-root .control-button:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.astar-visualizer-root .control-button.start.active{background:var(--success);border-color:var(--success);color:#fff}.astar-visualizer-root .control-button.end.active{background:var(--danger);border-color:var(--danger);color:#fff}.astar-visualizer-root .control-button.obstacle.active{background:var(--text-primary);border-color:var(--text-primary);color:#fff}.astar-visualizer-root .control-button.clear.active{background:var(--text-muted);border-color:var(--text-muted);color:#fff}.astar-visualizer-root .control-button.reset{background:var(--danger);border-color:var(--danger);color:#fff}.astar-visualizer-root .control-button.reset:hover{background:var(--danger-hover);border-color:var(--danger-hover)}.astar-visualizer-root .control-button.find-path{background:var(--primary);border-color:var(--primary);color:#fff}.astar-visualizer-root .control-button.find-path:hover{background:var(--primary-hover);border-color:var(--primary-hover)}.astar-visualizer-root .control-button.diagonal.active{background:var(--warning);border-color:var(--warning);color:#fff}.astar-visualizer-root .control-button.diagonal:hover{background:var(--warning-hover);border-color:var(--warning-hover)}.astar-visualizer-root .control-button.theme-toggle{background:var(--text-muted);border-color:var(--text-muted);color:#fff}.astar-visualizer-root .control-button.theme-toggle:hover{background:var(--text-secondary);border-color:var(--text-secondary)}.astar-visualizer-root .control-button.theme-toggle.active{background:var(--warning);border-color:var(--warning);color:#fff}.astar-visualizer-root .control-button.theme-toggle.active:hover{background:var(--warning-hover);border-color:var(--warning-hover)}.astar-visualizer-root .size-controls{display:flex;flex-direction:column;gap:.75rem;align-items:center}.astar-visualizer-root .size-control{display:flex;flex-direction:column;gap:.25rem;align-items:center}.astar-visualizer-root .size-label{font-size:.75rem;font-weight:500;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.05em}.astar-visualizer-root .size-buttons{display:flex;align-items:center;gap:.5rem}.astar-visualizer-root .size-button{display:flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;font-size:1rem;font-weight:600;color:var(--text-primary);background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:4px;cursor:pointer;transition:all .2s ease;outline:none}.astar-visualizer-root .size-button:hover:not(:disabled){background:var(--primary);border-color:var(--primary);color:#fff}.astar-visualizer-root .size-button:active:not(:disabled){transform:scale(.95)}.astar-visualizer-root .size-button:disabled{opacity:.4;cursor:not-allowed}.astar-visualizer-root .size-button:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.astar-visualizer-root .size-value{display:flex;align-items:center;justify-content:center;min-width:2.5rem;height:1.75rem;font-size:.875rem;font-weight:600;color:var(--text-primary);background:var(--bg-tertiary);border:1px solid var(--border-color);border-radius:4px}@media (min-width: 1024px){.astar-visualizer-root .control-grid{grid-template-columns:2fr 1fr 1fr;gap:2rem}.astar-visualizer-root .control-group.tools{grid-column:1}.astar-visualizer-root .control-group.actions{grid-column:2}.astar-visualizer-root .control-group.size{grid-column:3}}@media (min-width: 768px) and (max-width: 1023px){.astar-visualizer-root .control-grid{grid-template-columns:1fr 1fr;gap:1.5rem}.astar-visualizer-root .control-group.tools{grid-column:1 / -1}.astar-visualizer-root .control-group.actions{grid-column:1}.astar-visualizer-root .control-group.size{grid-column:2}}@media (max-width: 768px){.astar-visualizer-root .control-panel{padding:.75rem}.astar-visualizer-root .control-grid{gap:1rem}.astar-visualizer-root .button-group{gap:.375rem}.astar-visualizer-root .control-button{padding:.375rem .75rem;font-size:.8125rem}.astar-visualizer-root .size-controls{gap:.5rem}.astar-visualizer-root .size-buttons{gap:.375rem}.astar-visualizer-root .size-button{width:1.5rem;height:1.5rem;font-size:.875rem}.astar-visualizer-root .size-value{min-width:2rem;height:1.5rem;font-size:.8125rem}}@media (max-width: 480px){.astar-visualizer-root .control-panel{padding:.5rem}.astar-visualizer-root .control-grid{gap:.75rem}.astar-visualizer-root .button-group{flex-direction:column;gap:.25rem}.astar-visualizer-root .control-button{width:100%;padding:.5rem;font-size:.75rem}.astar-visualizer-root .size-controls{gap:.375rem}.astar-visualizer-root .size-buttons{gap:.25rem}.astar-visualizer-root .size-button{width:1.25rem;height:1.25rem;font-size:.75rem}.astar-visualizer-root .size-value{min-width:1.75rem;height:1.25rem;font-size:.75rem}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "astar-visualizer",
3
3
  "private": false,
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "type": "module",
6
6
  "description": "A React component for visualizing A* pathfinding algorithm",
7
7
  "main": "./dist/astar-visualizer.umd.cjs",