@dxos/react-ui-gameboard 0.8.4-main.fd6878d → 0.8.4-staging.ac66bdf99f

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.
Files changed (32) hide show
  1. package/README.md +2 -0
  2. package/dist/lib/browser/index.mjs +643 -730
  3. package/dist/lib/browser/index.mjs.map +3 -3
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +643 -730
  6. package/dist/lib/node-esm/index.mjs.map +3 -3
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/Chessboard/Chessboard.d.ts +9 -4
  9. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
  10. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +21 -18
  11. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Chessboard/chess.d.ts +15 -8
  13. package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -1
  14. package/dist/types/src/components/Chessboard/chess.test.d.ts +2 -0
  15. package/dist/types/src/components/Chessboard/chess.test.d.ts.map +1 -0
  16. package/dist/types/src/components/Gameboard/Gameboard.d.ts +6 -6
  17. package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -1
  18. package/dist/types/src/components/Gameboard/Piece.d.ts +1 -1
  19. package/dist/types/src/components/Gameboard/Piece.d.ts.map +1 -1
  20. package/dist/types/src/components/Gameboard/Square.d.ts.map +1 -1
  21. package/dist/types/src/components/Gameboard/types.d.ts +3 -3
  22. package/dist/types/src/components/Gameboard/types.d.ts.map +1 -1
  23. package/dist/types/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +26 -23
  25. package/src/components/Chessboard/Chessboard.stories.tsx +20 -18
  26. package/src/components/Chessboard/Chessboard.tsx +44 -30
  27. package/src/components/Chessboard/chess.test.ts +19 -0
  28. package/src/components/Chessboard/chess.ts +111 -59
  29. package/src/components/Gameboard/Gameboard.tsx +8 -8
  30. package/src/components/Gameboard/Piece.tsx +13 -8
  31. package/src/components/Gameboard/Square.tsx +5 -3
  32. package/src/components/Gameboard/types.ts +3 -3
@@ -25,15 +25,13 @@ var getRelativeBounds = (container, element) => {
25
25
  };
26
26
 
27
27
  // src/components/Gameboard/Gameboard.tsx
28
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
29
28
  import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
30
29
  import { createContext } from "@radix-ui/react-context";
31
30
  import React3, { forwardRef, useCallback, useEffect as useEffect3, useState as useState3 } from "react";
32
31
  import { log as log3 } from "@dxos/log";
33
- import { mx as mx3 } from "@dxos/react-ui-theme";
32
+ import { mx as mx3 } from "@dxos/ui-theme";
34
33
 
35
34
  // src/components/Gameboard/Piece.tsx
36
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
37
35
  import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
38
36
  import { centerUnderPointer } from "@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer";
39
37
  import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
@@ -41,219 +39,205 @@ import React, { memo, useEffect, useRef, useState } from "react";
41
39
  import { createPortal } from "react-dom";
42
40
  import { invariant } from "@dxos/invariant";
43
41
  import { log } from "@dxos/log";
44
- import { useDynamicRef, useTrackProps } from "@dxos/react-ui";
45
- import { mx } from "@dxos/react-ui-theme";
42
+ import { useDynamicRef } from "@dxos/react-ui";
43
+ import { mx } from "@dxos/ui-theme";
46
44
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Piece.tsx";
47
- var Piece = /* @__PURE__ */ memo(({ classNames, Component, piece, orientation, bounds, label, onClick }) => {
48
- var _effect = _useSignals();
49
- try {
50
- useTrackProps({
51
- classNames,
52
- Component,
53
- piece,
54
- orientation,
55
- bounds,
56
- label
57
- }, Piece.displayName, false);
58
- const { model, dragging: isDragging, promoting } = useGameboardContext(Piece.displayName);
59
- const promotingRef = useDynamicRef(promoting);
60
- const [dragging, setDragging] = useState(false);
61
- const [preview, setPreview] = useState();
62
- const [current, setCurrent] = useState({});
63
- const ref = useRef(null);
64
- useEffect(() => {
65
- const el = ref.current;
66
- invariant(el, void 0, {
67
- F: __dxlog_file,
68
- L: 42,
69
- S: void 0,
70
- A: [
71
- "el",
72
- ""
73
- ]
74
- });
75
- return draggable({
76
- element: el,
77
- getInitialData: () => ({
78
- piece
79
- }),
80
- onGenerateDragPreview: ({ nativeSetDragImage, source }) => {
81
- log("onGenerateDragPreview", {
82
- source: source.data
83
- }, {
84
- F: __dxlog_file,
85
- L: 48,
86
- S: void 0,
87
- C: (f, a) => f(...a)
88
- });
89
- setCustomNativeDragPreview({
90
- getOffset: centerUnderPointer,
91
- render: ({ container }) => {
92
- setPreview(container);
93
- const { width, height } = el.getBoundingClientRect();
94
- container.style.width = width + "px";
95
- container.style.height = height + "px";
96
- return () => {
97
- setPreview(void 0);
98
- };
99
- },
100
- nativeSetDragImage
101
- });
102
- },
103
- canDrag: () => !promotingRef.current && model?.turn === piece.side,
104
- onDragStart: () => setDragging(true),
105
- onDrop: ({ location: { current: current2 } }) => {
106
- try {
107
- const location = current2.dropTargets[0]?.data.location;
108
- if (isLocation(location)) {
109
- setCurrent((current3) => ({
110
- ...current3,
111
- location
112
- }));
113
- }
114
- } catch {
45
+ var PIECE_NAME = "Piece";
46
+ var Piece = /* @__PURE__ */ memo(({ classNames, Component, piece, bounds, label, onClick }) => {
47
+ const { model, dragging: isDragging, promoting } = useGameboardContext(PIECE_NAME);
48
+ const promotingRef = useDynamicRef(promoting);
49
+ const [dragging, setDragging] = useState(false);
50
+ const [preview, setPreview] = useState();
51
+ const [current, setCurrent] = useState({});
52
+ const ref = useRef(null);
53
+ useEffect(() => {
54
+ if (!model) {
55
+ return;
56
+ }
57
+ const el = ref.current;
58
+ invariant(el, void 0, {
59
+ F: __dxlog_file,
60
+ L: 47,
61
+ S: void 0,
62
+ A: [
63
+ "el",
64
+ ""
65
+ ]
66
+ });
67
+ return draggable({
68
+ element: el,
69
+ getInitialData: () => ({
70
+ piece
71
+ }),
72
+ onGenerateDragPreview: ({ nativeSetDragImage, source }) => {
73
+ log("onGenerateDragPreview", {
74
+ source: source.data
75
+ }, {
76
+ F: __dxlog_file,
77
+ L: 53,
78
+ S: void 0,
79
+ C: (f, a) => f(...a)
80
+ });
81
+ setCustomNativeDragPreview({
82
+ getOffset: centerUnderPointer,
83
+ render: ({ container }) => {
84
+ setPreview(container);
85
+ const { width, height } = el.getBoundingClientRect();
86
+ container.style.width = width + "px";
87
+ container.style.height = height + "px";
88
+ return () => {
89
+ setPreview(void 0);
90
+ };
91
+ },
92
+ nativeSetDragImage
93
+ });
94
+ },
95
+ canDrag: () => !promotingRef.current && !model.readonly && model.turn === piece.side,
96
+ onDragStart: () => setDragging(true),
97
+ onDrop: ({ location: { current: current2 } }) => {
98
+ try {
99
+ const location = current2.dropTargets[0]?.data.location;
100
+ if (isLocation(location)) {
101
+ setCurrent((current3) => ({
102
+ ...current3,
103
+ location
104
+ }));
115
105
  }
116
- setDragging(false);
117
- }
118
- });
119
- }, [
120
- model,
121
- piece
122
- ]);
123
- useEffect(() => {
124
- requestAnimationFrame(() => {
125
- if (!ref.current || !bounds) {
126
- return;
127
- }
128
- if (!current.location || !isEqualLocation(current.location, piece.location)) {
129
- ref.current.style.transition = "top 400ms ease-out, left 400ms ease-out";
130
- ref.current.style.top = bounds.top + "px";
131
- ref.current.style.left = bounds.left + "px";
132
- setCurrent({
133
- location: piece.location,
134
- bounds
135
- });
136
- } else if (current.bounds !== bounds) {
137
- ref.current.style.transition = "none";
138
- ref.current.style.top = bounds.top + "px";
139
- ref.current.style.left = bounds.left + "px";
140
- setCurrent({
141
- location: piece.location,
142
- bounds
143
- });
106
+ } catch {
144
107
  }
145
- });
146
- }, [
147
- current,
148
- piece.location,
149
- bounds
150
- ]);
151
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
152
- ref,
153
- style: {
154
- width: bounds?.width,
155
- height: bounds?.height
156
- },
157
- className: mx("absolute", classNames, dragging && "opacity-20", isDragging && "pointer-events-none"),
158
- onClick
159
- }, /* @__PURE__ */ React.createElement(Component, {
160
- className: "grow"
161
- }), label && /* @__PURE__ */ React.createElement("div", {
162
- className: "absolute inset-1 text-xs text-black"
163
- }, label)), preview && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement("div", {
164
- className: mx(classNames)
165
- }, /* @__PURE__ */ React.createElement(Component, {
166
- className: "grow"
167
- })), preview));
168
- } finally {
169
- _effect.f();
170
- }
108
+ setDragging(false);
109
+ }
110
+ });
111
+ }, [
112
+ model,
113
+ piece
114
+ ]);
115
+ useEffect(() => {
116
+ requestAnimationFrame(() => {
117
+ if (!ref.current || !bounds) {
118
+ return;
119
+ }
120
+ if (!current.location || !isEqualLocation(current.location, piece.location)) {
121
+ ref.current.style.transition = "top 250ms ease-out, left 250ms ease-out";
122
+ ref.current.style.top = bounds.top + "px";
123
+ ref.current.style.left = bounds.left + "px";
124
+ setCurrent({
125
+ location: piece.location,
126
+ bounds
127
+ });
128
+ } else if (current.bounds !== bounds) {
129
+ ref.current.style.transition = "none";
130
+ ref.current.style.top = bounds.top + "px";
131
+ ref.current.style.left = bounds.left + "px";
132
+ setCurrent({
133
+ location: piece.location,
134
+ bounds
135
+ });
136
+ }
137
+ });
138
+ }, [
139
+ current,
140
+ piece.location,
141
+ bounds
142
+ ]);
143
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
144
+ ref,
145
+ style: {
146
+ width: bounds?.width,
147
+ height: bounds?.height
148
+ },
149
+ className: mx("absolute", classNames, dragging && "opacity-20", isDragging && "pointer-events-none"),
150
+ onClick
151
+ }, /* @__PURE__ */ React.createElement(Component, {
152
+ className: "grow"
153
+ }), label && /* @__PURE__ */ React.createElement("div", {
154
+ className: "absolute inset-1 text-xs text-black"
155
+ }, label)), preview && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement("div", {
156
+ className: mx(classNames)
157
+ }, /* @__PURE__ */ React.createElement(Component, {
158
+ className: "grow"
159
+ })), preview));
171
160
  });
172
- Piece.displayName = "Piece";
161
+ Piece.displayName = PIECE_NAME;
173
162
 
174
163
  // src/components/Gameboard/Square.tsx
175
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
176
164
  import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
177
165
  import React2, { memo as memo2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
178
166
  import { invariant as invariant2 } from "@dxos/invariant";
179
167
  import { log as log2 } from "@dxos/log";
180
- import { mx as mx2 } from "@dxos/react-ui-theme";
168
+ import { mx as mx2 } from "@dxos/ui-theme";
181
169
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Square.tsx";
170
+ var SQUARE_NAME = "Square";
182
171
  var Square = /* @__PURE__ */ memo2(({ location, bounds, label, classNames }) => {
183
- var _effect = _useSignals2();
184
- try {
185
- const ref = useRef2(null);
186
- const [state, setState] = useState2("idle");
187
- const { model } = useGameboardContext(Square.displayName);
188
- useEffect2(() => {
189
- const el = ref.current;
190
- invariant2(el, void 0, {
191
- F: __dxlog_file2,
192
- L: 32,
193
- S: void 0,
194
- A: [
195
- "el",
196
- ""
197
- ]
198
- });
199
- return dropTargetForElements({
200
- element: el,
201
- getData: () => ({
202
- location
203
- }),
204
- canDrop: ({ source }) => {
205
- log2("canDrop", {
206
- source: source.data
207
- }, {
208
- F: __dxlog_file2,
209
- L: 38,
210
- S: void 0,
211
- C: (f, a) => f(...a)
212
- });
213
- return true;
214
- },
215
- onDragEnter: ({ source }) => {
216
- log2("onDragEnter", {
217
- source: source.data
218
- }, {
219
- F: __dxlog_file2,
220
- L: 42,
221
- S: void 0,
222
- C: (f, a) => f(...a)
223
- });
224
- const piece = source.data.piece;
225
- if (!isPiece(piece)) {
226
- return;
227
- }
228
- if (model?.isValidMove({
229
- from: piece.location,
230
- to: location,
231
- piece: piece.type
232
- })) {
233
- setState("validMove");
234
- } else {
235
- setState("invalidMove");
236
- }
237
- },
238
- onDragLeave: () => setState("idle"),
239
- onDrop: () => setState("idle")
240
- });
241
- }, [
242
- model,
243
- location
244
- ]);
245
- return /* @__PURE__ */ React2.createElement("div", {
246
- ref,
247
- style: bounds,
248
- className: mx2("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
249
- }, label && /* @__PURE__ */ React2.createElement("div", {
250
- className: mx2("absolute bottom-1 left-1 text-xs text-neutral-500")
251
- }, label));
252
- } finally {
253
- _effect.f();
254
- }
172
+ const ref = useRef2(null);
173
+ const [state, setState] = useState2("idle");
174
+ const { model } = useGameboardContext(SQUARE_NAME);
175
+ useEffect2(() => {
176
+ const el = ref.current;
177
+ invariant2(el, void 0, {
178
+ F: __dxlog_file2,
179
+ L: 34,
180
+ S: void 0,
181
+ A: [
182
+ "el",
183
+ ""
184
+ ]
185
+ });
186
+ return dropTargetForElements({
187
+ element: el,
188
+ getData: () => ({
189
+ location
190
+ }),
191
+ canDrop: ({ source }) => {
192
+ log2("canDrop", {
193
+ source: source.data
194
+ }, {
195
+ F: __dxlog_file2,
196
+ L: 40,
197
+ S: void 0,
198
+ C: (f, a) => f(...a)
199
+ });
200
+ return true;
201
+ },
202
+ onDragEnter: ({ source }) => {
203
+ log2("onDragEnter", {
204
+ source: source.data
205
+ }, {
206
+ F: __dxlog_file2,
207
+ L: 44,
208
+ S: void 0,
209
+ C: (f, a) => f(...a)
210
+ });
211
+ const piece = source.data.piece;
212
+ if (!isPiece(piece)) {
213
+ return;
214
+ }
215
+ if (model?.isValidMove({
216
+ from: piece.location,
217
+ to: location,
218
+ piece: piece.type
219
+ })) {
220
+ setState("validMove");
221
+ } else {
222
+ setState("invalidMove");
223
+ }
224
+ },
225
+ onDragLeave: () => setState("idle"),
226
+ onDrop: () => setState("idle")
227
+ });
228
+ }, [
229
+ model,
230
+ location
231
+ ]);
232
+ return /* @__PURE__ */ React2.createElement("div", {
233
+ ref,
234
+ style: bounds,
235
+ className: mx2("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
236
+ }, label && /* @__PURE__ */ React2.createElement("div", {
237
+ className: mx2("absolute bottom-1 left-1 text-xs text-neutral-500")
238
+ }, label));
255
239
  });
256
- Square.displayName = "Square";
240
+ Square.displayName = SQUARE_NAME;
257
241
 
258
242
  // src/components/Gameboard/Gameboard.tsx
259
243
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Gameboard.tsx";
@@ -262,102 +246,92 @@ var useGameboardContext = (consumerName) => {
262
246
  return useRadixGameboardContext(consumerName);
263
247
  };
264
248
  var GameboardRoot = ({ children, model, onDrop }) => {
265
- var _effect = _useSignals3();
266
- try {
267
- const [dragging, setDragging] = useState3(false);
268
- const [promoting, setPromoting] = useState3();
269
- const handlePromotion = useCallback((move) => {
270
- log3("onPromotion", {
271
- move
272
- }, {
273
- F: __dxlog_file3,
274
- L: 47,
275
- S: void 0,
276
- C: (f, a) => f(...a)
277
- });
278
- setPromoting(void 0);
279
- onDrop?.(move);
280
- }, []);
281
- useEffect3(() => {
282
- if (!model) {
283
- return;
284
- }
285
- return monitorForElements({
286
- onDragStart: ({ source }) => {
287
- log3("onDragStart", {
288
- source
289
- }, {
290
- F: __dxlog_file3,
291
- L: 60,
292
- S: void 0,
293
- C: (f, a) => f(...a)
294
- });
295
- setDragging(true);
296
- },
297
- onDrop: ({ source, location }) => {
298
- log3("onDrop", {
299
- source,
300
- location
301
- }, {
302
- F: __dxlog_file3,
303
- L: 64,
304
- S: void 0,
305
- C: (f, a) => f(...a)
306
- });
307
- const target = location.current.dropTargets[0];
308
- if (!target) {
309
- return;
310
- }
311
- const targetLocation = target.data.location;
312
- const piece = source.data.piece;
313
- if (!isLocation(targetLocation) || !isPiece(piece)) {
314
- return;
315
- }
316
- const move = {
317
- from: piece.location,
318
- to: targetLocation,
319
- piece: piece.type
320
- };
321
- if (model.isValidMove(move)) {
322
- if (model.canPromote?.(move)) {
323
- setPromoting({
324
- ...piece,
325
- location: targetLocation
326
- });
327
- } else {
328
- onDrop?.(move);
329
- }
249
+ const [dragging, setDragging] = useState3(false);
250
+ const [promoting, setPromoting] = useState3();
251
+ const handlePromotion = useCallback((move) => {
252
+ log3("onPromotion", {
253
+ move
254
+ }, {
255
+ F: __dxlog_file3,
256
+ L: 47,
257
+ S: void 0,
258
+ C: (f, a) => f(...a)
259
+ });
260
+ setPromoting(void 0);
261
+ onDrop?.(move);
262
+ }, []);
263
+ useEffect3(() => {
264
+ if (!model) {
265
+ return;
266
+ }
267
+ return monitorForElements({
268
+ onDragStart: ({ source }) => {
269
+ log3("onDragStart", {
270
+ source
271
+ }, {
272
+ F: __dxlog_file3,
273
+ L: 60,
274
+ S: void 0,
275
+ C: (f, a) => f(...a)
276
+ });
277
+ setDragging(true);
278
+ },
279
+ onDrop: ({ source, location }) => {
280
+ log3("onDrop", {
281
+ source,
282
+ location
283
+ }, {
284
+ F: __dxlog_file3,
285
+ L: 64,
286
+ S: void 0,
287
+ C: (f, a) => f(...a)
288
+ });
289
+ const target = location.current.dropTargets[0];
290
+ if (!target) {
291
+ return;
292
+ }
293
+ const targetLocation = target.data.location;
294
+ const piece = source.data.piece;
295
+ if (!isLocation(targetLocation) || !isPiece(piece)) {
296
+ return;
297
+ }
298
+ const move = {
299
+ from: piece.location,
300
+ to: targetLocation,
301
+ piece: piece.type
302
+ };
303
+ if (model.isValidMove(move)) {
304
+ if (model.canPromote?.(move)) {
305
+ setPromoting({
306
+ ...piece,
307
+ location: targetLocation
308
+ });
309
+ } else {
310
+ onDrop?.(move);
330
311
  }
331
- setDragging(false);
332
312
  }
333
- });
334
- }, [
335
- model
336
- ]);
337
- return /* @__PURE__ */ React3.createElement(GameboardContextProvider, {
338
- model,
339
- dragging,
340
- promoting,
341
- onPromotion: handlePromotion
342
- }, children);
343
- } finally {
344
- _effect.f();
345
- }
313
+ setDragging(false);
314
+ }
315
+ });
316
+ }, [
317
+ model
318
+ ]);
319
+ return /* @__PURE__ */ React3.createElement(GameboardContextProvider, {
320
+ model,
321
+ dragging,
322
+ promoting,
323
+ onPromotion: handlePromotion
324
+ }, children);
346
325
  };
347
326
  GameboardRoot.displayName = "Gameboard.Root";
348
327
  var GameboardContent = /* @__PURE__ */ forwardRef(({ children, classNames, grow, contain }, forwardedRef) => {
349
- var _effect = _useSignals3();
350
- try {
351
- return /* @__PURE__ */ React3.createElement("div", {
352
- role: "none",
353
- className: mx3(grow && "grid is-full bs-full size-container place-content-center", classNames),
354
- ref: forwardedRef
355
- }, contain ? /* @__PURE__ */ React3.createElement("div", {
356
- className: "is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]"
357
- }, children) : children);
358
- } finally {
359
- _effect.f();
360
- }
328
+ return /* @__PURE__ */ React3.createElement("div", {
329
+ role: "none",
330
+ className: mx3(grow && "dx-size-container dx-expander grid place-content-center", classNames),
331
+ ref: forwardedRef
332
+ }, contain ? /* @__PURE__ */ React3.createElement("div", {
333
+ className: "w-[min(100cqw,100cqh)] h-[min(100cqw,100cqh)]"
334
+ }, children) : children);
361
335
  });
362
336
  GameboardContent.displayName = "Gameboard.Content";
363
337
  var Gameboard = {
@@ -368,8 +342,9 @@ var Gameboard = {
368
342
  };
369
343
 
370
344
  // src/components/Chessboard/chess.ts
371
- import { signal } from "@preact/signals-core";
345
+ import { Atom } from "@effect-atom/atom-react";
372
346
  import { Chess as ChessJS } from "chess.js";
347
+ import { invariant as invariant3 } from "@dxos/invariant";
373
348
  import { log as log4 } from "@dxos/log";
374
349
 
375
350
  // src/gen/pieces/chess/alpha/index.ts
@@ -390,276 +365,180 @@ __export(alpha_exports, {
390
365
  });
391
366
 
392
367
  // src/gen/pieces/chess/alpha/bB.tsx
393
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
394
368
  import * as React4 from "react";
395
- var SvgBB = (props) => {
396
- var _effect = _useSignals4();
397
- try {
398
- return /* @__PURE__ */ React4.createElement("svg", {
399
- xmlns: "http://www.w3.org/2000/svg",
400
- viewBox: "0 0 2048 2048",
401
- ...props
402
- }, /* @__PURE__ */ React4.createElement("path", {
403
- fill: "#f9f9f9",
404
- d: "M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z"
405
- }), /* @__PURE__ */ React4.createElement("path", {
406
- fill: "#101010",
407
- d: "M768 1365q-5 39-26 82h564q-18-36-26-82zm495-73 46-73q-142-49-285-47-144-2-285 47l46 73q118-40 239-38 120-2 239 38m-432 227H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-207l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60zm146-701h-95v89h95v165h94V907h95v-89h-95V714h-94z"
408
- }));
409
- } finally {
410
- _effect.f();
411
- }
412
- };
369
+ var SvgBB = (props) => /* @__PURE__ */ React4.createElement("svg", {
370
+ xmlns: "http://www.w3.org/2000/svg",
371
+ viewBox: "0 0 2048 2048",
372
+ ...props
373
+ }, /* @__PURE__ */ React4.createElement("path", {
374
+ fill: "#f9f9f9",
375
+ d: "M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z"
376
+ }), /* @__PURE__ */ React4.createElement("path", {
377
+ fill: "#101010",
378
+ d: "M768 1365q-5 39-26 82h564q-18-36-26-82zm495-73 46-73q-142-49-285-47-144-2-285 47l46 73q118-40 239-38 120-2 239 38m-432 227H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-207l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60zm146-701h-95v89h95v165h94V907h95v-89h-95V714h-94z"
379
+ }));
413
380
  var bB_default = SvgBB;
414
381
 
415
382
  // src/gen/pieces/chess/alpha/bK.tsx
416
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
417
383
  import * as React5 from "react";
418
- var SvgBK = (props) => {
419
- var _effect = _useSignals5();
420
- try {
421
- return /* @__PURE__ */ React5.createElement("svg", {
422
- xmlns: "http://www.w3.org/2000/svg",
423
- viewBox: "0 0 2048 2048",
424
- ...props
425
- }, /* @__PURE__ */ React5.createElement("path", {
426
- fill: "#f9f9f9",
427
- d: "m553 1485-55 320 1048 5-48-335s324-313 330-467c7-153-35-331-241-406-183-67-372 121-372 121l-182-161-190 160S658 586 587 592a373 373 0 0 0-362 333c10 331 328 560 328 560"
428
- }), /* @__PURE__ */ React5.createElement("path", {
429
- fill: "#101010",
430
- d: "M1024 1769h489l-12-73H547l-12 73zm0-921q-25-60-62-111 31-48 62-65 30 17 62 65-38 51-62 111m-97 454q-154 11-303 58-123-108-200-213t-77-202q0-89 74-159t148-70q67 0 135 63t102 130q30 54 75 175t46 218m-350 217-26 156 145-84zm447-907q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m0 775q-1-126-42-267t-84-227l-14-27-12-23q-28-43-48-69-51-63-120-105t-134-42q-103 0-208 93T257 949q0 120 99 255t249 259q201-74 419-76m0 456H448l61-365q-325-280-326-535-1-159 125-274t267-116q78 0 159 47t142 119q61 74 99 165t49 150q12-60 49-150t99-165q61-72 142-119t159-47q140 0 266 116t126 274q-2 255-326 535l61 365zm97-541q0-97 45-218t76-175q34-68 102-130t135-63q74 0 148 70t74 159q0 96-77 202t-200 213q-150-47-303-58m350 217-119 72 145 84zm-447-132q217 2 419 76 150-125 249-259t99-255q0-136-105-229t-208-93q-66 0-135 42t-119 105q-21 26-48 69l-12 23-14 27q-44 85-85 227t-41 267m-139 159 139 86 139-84-139-86zm92-1248v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95z"
431
- }));
432
- } finally {
433
- _effect.f();
434
- }
435
- };
384
+ var SvgBK = (props) => /* @__PURE__ */ React5.createElement("svg", {
385
+ xmlns: "http://www.w3.org/2000/svg",
386
+ viewBox: "0 0 2048 2048",
387
+ ...props
388
+ }, /* @__PURE__ */ React5.createElement("path", {
389
+ fill: "#f9f9f9",
390
+ d: "m553 1485-55 320 1048 5-48-335s324-313 330-467c7-153-35-331-241-406-183-67-372 121-372 121l-182-161-190 160S658 586 587 592a373 373 0 0 0-362 333c10 331 328 560 328 560"
391
+ }), /* @__PURE__ */ React5.createElement("path", {
392
+ fill: "#101010",
393
+ d: "M1024 1769h489l-12-73H547l-12 73zm0-921q-25-60-62-111 31-48 62-65 30 17 62 65-38 51-62 111m-97 454q-154 11-303 58-123-108-200-213t-77-202q0-89 74-159t148-70q67 0 135 63t102 130q30 54 75 175t46 218m-350 217-26 156 145-84zm447-907q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m0 775q-1-126-42-267t-84-227l-14-27-12-23q-28-43-48-69-51-63-120-105t-134-42q-103 0-208 93T257 949q0 120 99 255t249 259q201-74 419-76m0 456H448l61-365q-325-280-326-535-1-159 125-274t267-116q78 0 159 47t142 119q61 74 99 165t49 150q12-60 49-150t99-165q61-72 142-119t159-47q140 0 266 116t126 274q-2 255-326 535l61 365zm97-541q0-97 45-218t76-175q34-68 102-130t135-63q74 0 148 70t74 159q0 96-77 202t-200 213q-150-47-303-58m350 217-119 72 145 84zm-447-132q217 2 419 76 150-125 249-259t99-255q0-136-105-229t-208-93q-66 0-135 42t-119 105q-21 26-48 69l-12 23-14 27q-44 85-85 227t-41 267m-139 159 139 86 139-84-139-86zm92-1248v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95z"
394
+ }));
436
395
  var bK_default = SvgBK;
437
396
 
438
397
  // src/gen/pieces/chess/alpha/bN.tsx
439
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
440
398
  import * as React6 from "react";
441
- var SvgBN = (props) => {
442
- var _effect = _useSignals6();
443
- try {
444
- return /* @__PURE__ */ React6.createElement("svg", {
445
- xmlns: "http://www.w3.org/2000/svg",
446
- viewBox: "0 0 2048 2048",
447
- ...props
448
- }, /* @__PURE__ */ React6.createElement("path", {
449
- fill: "#f9f9f9",
450
- d: "M1658 1806c-408-301-71-920-452-1343l60-16s296 167 320 257c182 468 41 691 135 1077zM972 523l120 176-312-3zM498 981l-93-41 42-93 127 28z"
451
- }), /* @__PURE__ */ React6.createElement("path", {
452
- fill: "#101010",
453
- d: "m502 868-52 1-26 64 69 21 46-55zm536-187q34 1-16-68t-80-42L826 680zm-338-98q6-39 116-107t220-144l115-154 96 217q342 172 433 418t47 603q-18 128 5 236t57 190l-1242 1q-9-178 39-301t183-238q50-11 83-39t53-59l63-1 138-29 139-97 66-207q0-17-8-34t-12-37q-62 228-161 289t-191 58q-236-42-292 60l-56 102-217-121 115-82-51-50-122 86-12-297zm981 1192q-102-130-85-308t27-363-50-351-316-276q220 164 253 342t16 351-12 329 167 276"
454
- }));
455
- } finally {
456
- _effect.f();
457
- }
458
- };
399
+ var SvgBN = (props) => /* @__PURE__ */ React6.createElement("svg", {
400
+ xmlns: "http://www.w3.org/2000/svg",
401
+ viewBox: "0 0 2048 2048",
402
+ ...props
403
+ }, /* @__PURE__ */ React6.createElement("path", {
404
+ fill: "#f9f9f9",
405
+ d: "M1658 1806c-408-301-71-920-452-1343l60-16s296 167 320 257c182 468 41 691 135 1077zM972 523l120 176-312-3zM498 981l-93-41 42-93 127 28z"
406
+ }), /* @__PURE__ */ React6.createElement("path", {
407
+ fill: "#101010",
408
+ d: "m502 868-52 1-26 64 69 21 46-55zm536-187q34 1-16-68t-80-42L826 680zm-338-98q6-39 116-107t220-144l115-154 96 217q342 172 433 418t47 603q-18 128 5 236t57 190l-1242 1q-9-178 39-301t183-238q50-11 83-39t53-59l63-1 138-29 139-97 66-207q0-17-8-34t-12-37q-62 228-161 289t-191 58q-236-42-292 60l-56 102-217-121 115-82-51-50-122 86-12-297zm981 1192q-102-130-85-308t27-363-50-351-316-276q220 164 253 342t16 351-12 329 167 276"
409
+ }));
459
410
  var bN_default = SvgBN;
460
411
 
461
412
  // src/gen/pieces/chess/alpha/bP.tsx
462
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
463
413
  import * as React7 from "react";
464
- var SvgBP = (props) => {
465
- var _effect = _useSignals7();
466
- try {
467
- return /* @__PURE__ */ React7.createElement("svg", {
468
- xmlns: "http://www.w3.org/2000/svg",
469
- viewBox: "0 0 2048 2048",
470
- ...props
471
- }, /* @__PURE__ */ React7.createElement("path", {
472
- fill: "#101010",
473
- d: "M1024 1843H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74z"
474
- }));
475
- } finally {
476
- _effect.f();
477
- }
478
- };
414
+ var SvgBP = (props) => /* @__PURE__ */ React7.createElement("svg", {
415
+ xmlns: "http://www.w3.org/2000/svg",
416
+ viewBox: "0 0 2048 2048",
417
+ ...props
418
+ }, /* @__PURE__ */ React7.createElement("path", {
419
+ fill: "#101010",
420
+ d: "M1024 1843H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74z"
421
+ }));
479
422
  var bP_default = SvgBP;
480
423
 
481
424
  // src/gen/pieces/chess/alpha/bQ.tsx
482
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
483
425
  import * as React8 from "react";
484
- var SvgBQ = (props) => {
485
- var _effect = _useSignals8();
486
- try {
487
- return /* @__PURE__ */ React8.createElement("svg", {
488
- xmlns: "http://www.w3.org/2000/svg",
489
- viewBox: "0 0 2048 2048",
490
- ...props
491
- }, /* @__PURE__ */ React8.createElement("path", {
492
- fill: "#f9f9f9",
493
- d: "m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z"
494
- }), /* @__PURE__ */ React8.createElement("path", {
495
- fill: "#101010",
496
- d: "M590 1519q4 72-15 158l134-86zm434 324H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zm0-450q109 0 222 28.5t213 67.5q2-41 11-89-108-42-221.5-68t-224.5-26-225 26-221 68q8 48 11 89 99-39 212-67.5t223-28.5m0 376h478q-15-34-24-73H570q-10 39-24 73zm434-250-119 72 134 86q-20-86-15-158m-573 47 139 87 139-84-139-86z"
497
- }));
498
- } finally {
499
- _effect.f();
500
- }
501
- };
426
+ var SvgBQ = (props) => /* @__PURE__ */ React8.createElement("svg", {
427
+ xmlns: "http://www.w3.org/2000/svg",
428
+ viewBox: "0 0 2048 2048",
429
+ ...props
430
+ }, /* @__PURE__ */ React8.createElement("path", {
431
+ fill: "#f9f9f9",
432
+ d: "m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z"
433
+ }), /* @__PURE__ */ React8.createElement("path", {
434
+ fill: "#101010",
435
+ d: "M590 1519q4 72-15 158l134-86zm434 324H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zm0-450q109 0 222 28.5t213 67.5q2-41 11-89-108-42-221.5-68t-224.5-26-225 26-221 68q8 48 11 89 99-39 212-67.5t223-28.5m0 376h478q-15-34-24-73H570q-10 39-24 73zm434-250-119 72 134 86q-20-86-15-158m-573 47 139 87 139-84-139-86z"
436
+ }));
502
437
  var bQ_default = SvgBQ;
503
438
 
504
439
  // src/gen/pieces/chess/alpha/bR.tsx
505
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
506
440
  import * as React9 from "react";
507
- var SvgBR = (props) => {
508
- var _effect = _useSignals9();
509
- try {
510
- return /* @__PURE__ */ React9.createElement("svg", {
511
- xmlns: "http://www.w3.org/2000/svg",
512
- viewBox: "0 0 2048 2048",
513
- ...props
514
- }, /* @__PURE__ */ React9.createElement("path", {
515
- fill: "#f9f9f9",
516
- d: "m674 732-76 807 851 14-75-833z"
517
- }), /* @__PURE__ */ React9.createElement("path", {
518
- fill: "#101010",
519
- d: "M1024 1843H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-989h333l-6-88H697l-6 88zm0 647h381l-6-87H649l-6 87z"
520
- }));
521
- } finally {
522
- _effect.f();
523
- }
524
- };
441
+ var SvgBR = (props) => /* @__PURE__ */ React9.createElement("svg", {
442
+ xmlns: "http://www.w3.org/2000/svg",
443
+ viewBox: "0 0 2048 2048",
444
+ ...props
445
+ }, /* @__PURE__ */ React9.createElement("path", {
446
+ fill: "#f9f9f9",
447
+ d: "m674 732-76 807 851 14-75-833z"
448
+ }), /* @__PURE__ */ React9.createElement("path", {
449
+ fill: "#101010",
450
+ d: "M1024 1843H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-989h333l-6-88H697l-6 88zm0 647h381l-6-87H649l-6 87z"
451
+ }));
525
452
  var bR_default = SvgBR;
526
453
 
527
454
  // src/gen/pieces/chess/alpha/wB.tsx
528
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
529
455
  import * as React10 from "react";
530
- var SvgWB = (props) => {
531
- var _effect = _useSignals10();
532
- try {
533
- return /* @__PURE__ */ React10.createElement("svg", {
534
- xmlns: "http://www.w3.org/2000/svg",
535
- viewBox: "0 0 2048 2048",
536
- ...props
537
- }, /* @__PURE__ */ React10.createElement("path", {
538
- fill: "#f9f9f9",
539
- d: "m948 366 1-139 148-7 1 147zM564 860c114-267 456-443 456-443s392 176 476 502c-9 209-183 332-183 332l27 221-653 6 46-233s-230-171-169-385m-101 790c175 6 355 23 425-142h92s0 190-88 246c-163 103-625 38-625 38s-15-146 196-142m631 37-36-185 102 5s22 153 315 131c381-17 318 153 318 153l-483 5z"
540
- }), /* @__PURE__ */ React10.createElement("path", {
541
- fill: "#101010",
542
- d: "M1024 356q66 0 64-66 1-55-64-55-66 0-64 55-3 66 64 66m0 1204q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60l10-16h76q-7 21-3 13-45 105-109 125t-146 19H409q-52 0-86 40t-34 53h424q66 0 159-65t93-185H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-341q0 120 93 185t159 65h424q0-13-34-53t-86-40h-240q-83 0-146-19t-109-125q4 8-3-13h76l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199m0-114h283q-28-84-29-154-120-41-254-38-135-3-254 38-2 70-29 154zm0-267q159-1 285 42 189-180 142-346-60-193-427-431-368 238-427 431-48 166 142 346 125-43 285-42m-47-361V714h94v104h95v89h-95v165h-94V907h-95v-89z"
543
- }));
544
- } finally {
545
- _effect.f();
546
- }
547
- };
456
+ var SvgWB = (props) => /* @__PURE__ */ React10.createElement("svg", {
457
+ xmlns: "http://www.w3.org/2000/svg",
458
+ viewBox: "0 0 2048 2048",
459
+ ...props
460
+ }, /* @__PURE__ */ React10.createElement("path", {
461
+ fill: "#f9f9f9",
462
+ d: "m948 366 1-139 148-7 1 147zM564 860c114-267 456-443 456-443s392 176 476 502c-9 209-183 332-183 332l27 221-653 6 46-233s-230-171-169-385m-101 790c175 6 355 23 425-142h92s0 190-88 246c-163 103-625 38-625 38s-15-146 196-142m631 37-36-185 102 5s22 153 315 131c381-17 318 153 318 153l-483 5z"
463
+ }), /* @__PURE__ */ React10.createElement("path", {
464
+ fill: "#101010",
465
+ d: "M1024 356q66 0 64-66 1-55-64-55-66 0-64 55-3 66 64 66m0 1204q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60l10-16h76q-7 21-3 13-45 105-109 125t-146 19H409q-52 0-86 40t-34 53h424q66 0 159-65t93-185H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-341q0 120 93 185t159 65h424q0-13-34-53t-86-40h-240q-83 0-146-19t-109-125q4 8-3-13h76l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199m0-114h283q-28-84-29-154-120-41-254-38-135-3-254 38-2 70-29 154zm0-267q159-1 285 42 189-180 142-346-60-193-427-431-368 238-427 431-48 166 142 346 125-43 285-42m-47-361V714h94v104h95v89h-95v165h-94V907h-95v-89z"
466
+ }));
548
467
  var wB_default = SvgWB;
549
468
 
550
469
  // src/gen/pieces/chess/alpha/wK.tsx
551
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
552
470
  import * as React11 from "react";
553
- var SvgWK = (props) => {
554
- var _effect = _useSignals11();
555
- try {
556
- return /* @__PURE__ */ React11.createElement("svg", {
557
- xmlns: "http://www.w3.org/2000/svg",
558
- viewBox: "0 0 2048 2048",
559
- ...props
560
- }, /* @__PURE__ */ React11.createElement("path", {
561
- fill: "#f9f9f9",
562
- d: "m501.6 1811 48.4-354.4-260-269.2s-166.4-288.2 29.9-481C582.2 448.7 826 727.2 826 727.2l195.6-165.7 184 165.7s216.4-232.5 430.4-76 255.4 317.6 117.4 531.6c-138.1 214-250.9 280.7-250.9 280.7L1558 1811z"
563
- }), /* @__PURE__ */ React11.createElement("path", {
564
- fill: "#101010",
565
- d: "M977 298v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95zm47 314q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m-447 907-26 156 145-84zm410-206q-1-147-36.5-274.5T870 845q-45-88-131.5-153T570 627q-103 0-208 93T257 949q0 109 86.5 236T546 1408q212-88 441-95m37 530H448l61-365q-325-280-326-535-1-159 125-274.5T575 553q78 0 158.5 47T876 719q61 74 98.5 164.5T1024 1034q12-60 49-150.5t99-164.5q61-72 142-119t159-47q140 0 266 115.5T1865 943q-2 255-326 535l61 365zm0-74h489l-50-298q-216-84-439-84t-439 84l-50 298zm447-250 26 156-145-84zm-410-206q229 7 441 95 115-96 202-223t87-236q0-136-105.5-229T1478 627q-83 0-169.5 65T1178 845q-46 66-81.5 193.5T1061 1313m-176 233 141-84 137 86-141 84z"
566
- }));
567
- } finally {
568
- _effect.f();
569
- }
570
- };
471
+ var SvgWK = (props) => /* @__PURE__ */ React11.createElement("svg", {
472
+ xmlns: "http://www.w3.org/2000/svg",
473
+ viewBox: "0 0 2048 2048",
474
+ ...props
475
+ }, /* @__PURE__ */ React11.createElement("path", {
476
+ fill: "#f9f9f9",
477
+ d: "m501.6 1811 48.4-354.4-260-269.2s-166.4-288.2 29.9-481C582.2 448.7 826 727.2 826 727.2l195.6-165.7 184 165.7s216.4-232.5 430.4-76 255.4 317.6 117.4 531.6c-138.1 214-250.9 280.7-250.9 280.7L1558 1811z"
478
+ }), /* @__PURE__ */ React11.createElement("path", {
479
+ fill: "#101010",
480
+ d: "M977 298v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95zm47 314q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m-447 907-26 156 145-84zm410-206q-1-147-36.5-274.5T870 845q-45-88-131.5-153T570 627q-103 0-208 93T257 949q0 109 86.5 236T546 1408q212-88 441-95m37 530H448l61-365q-325-280-326-535-1-159 125-274.5T575 553q78 0 158.5 47T876 719q61 74 98.5 164.5T1024 1034q12-60 49-150.5t99-164.5q61-72 142-119t159-47q140 0 266 115.5T1865 943q-2 255-326 535l61 365zm0-74h489l-50-298q-216-84-439-84t-439 84l-50 298zm447-250 26 156-145-84zm-410-206q229 7 441 95 115-96 202-223t87-236q0-136-105.5-229T1478 627q-83 0-169.5 65T1178 845q-46 66-81.5 193.5T1061 1313m-176 233 141-84 137 86-141 84z"
481
+ }));
571
482
  var wK_default = SvgWK;
572
483
 
573
484
  // src/gen/pieces/chess/alpha/wN.tsx
574
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
575
485
  import * as React12 from "react";
576
- var SvgWN = (props) => {
577
- var _effect = _useSignals12();
578
- try {
579
- return /* @__PURE__ */ React12.createElement("svg", {
580
- xmlns: "http://www.w3.org/2000/svg",
581
- viewBox: "0 0 2048 2048",
582
- ...props
583
- }, /* @__PURE__ */ React12.createElement("path", {
584
- fill: "#f9f9f9",
585
- d: "m352 861 787-569 94 148s336 103 398 388c63 286 51 974 51 974l-1088 9s-37-290 184-460c221-171 221-212 221-212s-226-71-295-16-117 138-117 138l-129-67 74-85-88-97-94 56z"
586
- }), /* @__PURE__ */ React12.createElement("path", {
587
- fill: "#101010",
588
- d: "m1151 178-115 154c-74 50-147 98-220 144-73 45-112 81-116 107L304 846l12 297 122-86 51 50-115 82 217 121 56-102c37-68 135-88 292-60l-55 85c-25 37-63 60-115 71a608 608 0 0 0-183 238c-32 82-45 182-39 301h1242c-23-55-42-118-57-190-15-73-17-152-5-237 29-239 13-440-47-603-61-164-205-303-433-418zm-17 145 59 133a664 664 0 0 1 262 188c55 72 100 150 134 234 27 97 40 181 41 253 0 71-3 140-9 205-7 65-11 131-13 199-2 67 9 145 32 234H621c-4-84 12-158 48-223s85-124 146-177c78-22 129-56 152-102s53-90 90-131c13-10 27-15 38-15 10-1 21 0 33-2 52-7 95-36 129-85 33-49 51-104 52-165l-19-67c-37 159-99 245-188 257l-45 6c-16 1-33 10-52 26-41-25-87-35-138-31q-111 9-165 27l-108 73-39 45-47-28 78-65-138-144-64 41-4-125 366-241c15-34 58-74 131-120l208-131zM960 564c-6 0-12 2-18 7L826 671l212 2c23 0 17-21-16-63-24-31-44-46-62-46M502 868l-33 4-33 56 57 26 46-55z"
589
- }));
590
- } finally {
591
- _effect.f();
592
- }
593
- };
486
+ var SvgWN = (props) => /* @__PURE__ */ React12.createElement("svg", {
487
+ xmlns: "http://www.w3.org/2000/svg",
488
+ viewBox: "0 0 2048 2048",
489
+ ...props
490
+ }, /* @__PURE__ */ React12.createElement("path", {
491
+ fill: "#f9f9f9",
492
+ d: "m352 861 787-569 94 148s336 103 398 388c63 286 51 974 51 974l-1088 9s-37-290 184-460c221-171 221-212 221-212s-226-71-295-16-117 138-117 138l-129-67 74-85-88-97-94 56z"
493
+ }), /* @__PURE__ */ React12.createElement("path", {
494
+ fill: "#101010",
495
+ d: "m1151 178-115 154c-74 50-147 98-220 144-73 45-112 81-116 107L304 846l12 297 122-86 51 50-115 82 217 121 56-102c37-68 135-88 292-60l-55 85c-25 37-63 60-115 71a608 608 0 0 0-183 238c-32 82-45 182-39 301h1242c-23-55-42-118-57-190-15-73-17-152-5-237 29-239 13-440-47-603-61-164-205-303-433-418zm-17 145 59 133a664 664 0 0 1 262 188c55 72 100 150 134 234 27 97 40 181 41 253 0 71-3 140-9 205-7 65-11 131-13 199-2 67 9 145 32 234H621c-4-84 12-158 48-223s85-124 146-177c78-22 129-56 152-102s53-90 90-131c13-10 27-15 38-15 10-1 21 0 33-2 52-7 95-36 129-85 33-49 51-104 52-165l-19-67c-37 159-99 245-188 257l-45 6c-16 1-33 10-52 26-41-25-87-35-138-31q-111 9-165 27l-108 73-39 45-47-28 78-65-138-144-64 41-4-125 366-241c15-34 58-74 131-120l208-131zM960 564c-6 0-12 2-18 7L826 671l212 2c23 0 17-21-16-63-24-31-44-46-62-46M502 868l-33 4-33 56 57 26 46-55z"
496
+ }));
594
497
  var wN_default = SvgWN;
595
498
 
596
499
  // src/gen/pieces/chess/alpha/wP.tsx
597
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
598
500
  import * as React13 from "react";
599
- var SvgWP = (props) => {
600
- var _effect = _useSignals13();
601
- try {
602
- return /* @__PURE__ */ React13.createElement("svg", {
603
- xmlns: "http://www.w3.org/2000/svg",
604
- viewBox: "0 0 2048 2048",
605
- ...props
606
- }, /* @__PURE__ */ React13.createElement("path", {
607
- fill: "#f9f9f9",
608
- d: "m734 981 196-193s-189-82-79-288c79-149 303-114 361 50 63 179-113 240-113 240l226 197Zm-235 799s-8-107 50-154c196-173 338-386 371-599l210 2c33 206 182 447 321 561 101 59 99 199 99 199z"
609
- }), /* @__PURE__ */ React13.createElement("path", {
610
- fill: "#101010",
611
- d: "M520 1769h1008q8-97-132-182-132-101-196-239t-80-309H928q-15 170-79 309t-197 239q-141 85-132 182m504 74H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74zM756 974h536l-225-191q134-31 134-171 0-76-52-126t-125-51q-73 0-125 51t-52 126q0 140 134 171z"
612
- }));
613
- } finally {
614
- _effect.f();
615
- }
616
- };
501
+ var SvgWP = (props) => /* @__PURE__ */ React13.createElement("svg", {
502
+ xmlns: "http://www.w3.org/2000/svg",
503
+ viewBox: "0 0 2048 2048",
504
+ ...props
505
+ }, /* @__PURE__ */ React13.createElement("path", {
506
+ fill: "#f9f9f9",
507
+ d: "m734 981 196-193s-189-82-79-288c79-149 303-114 361 50 63 179-113 240-113 240l226 197Zm-235 799s-8-107 50-154c196-173 338-386 371-599l210 2c33 206 182 447 321 561 101 59 99 199 99 199z"
508
+ }), /* @__PURE__ */ React13.createElement("path", {
509
+ fill: "#101010",
510
+ d: "M520 1769h1008q8-97-132-182-132-101-196-239t-80-309H928q-15 170-79 309t-197 239q-141 85-132 182m504 74H446v-74q-4-80 42-137t125-108q117-91 172-217t78-268H576l284-239q-86-74-86-188 0-103 73-177t177-74q103 0 177 74t73 177q0 114-86 188l284 239h-287q23 141 78 268t172 217q79 51 125 108t42 137v74zM756 974h536l-225-191q134-31 134-171 0-76-52-126t-125-51q-73 0-125 51t-52 126q0 140 134 171z"
511
+ }));
617
512
  var wP_default = SvgWP;
618
513
 
619
514
  // src/gen/pieces/chess/alpha/wQ.tsx
620
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
621
515
  import * as React14 from "react";
622
- var SvgWQ = (props) => {
623
- var _effect = _useSignals14();
624
- try {
625
- return /* @__PURE__ */ React14.createElement("svg", {
626
- xmlns: "http://www.w3.org/2000/svg",
627
- viewBox: "0 0 2048 2048",
628
- ...props
629
- }, /* @__PURE__ */ React14.createElement("path", {
630
- fill: "#f9f9f9",
631
- d: "m508.5 1815.6 48.4-356.7-216.3-554.6-135.8-20.7-16.1-126.5 112.7-43.8 78.3 73.7-18.4 99 246.2 197.8 112.8-568.3L635 428l78.3-108 112.8 43.7-23 161 223.2 474 244-490-66.8-105.9 92-92 105.9 73.6L1337 534l103.5 529.2 260-161-16-142.7 131-46 57.6 131.1-207 103.6-175 529.2 48.4 308.4z"
632
- }), /* @__PURE__ */ React14.createElement("path", {
633
- fill: "#101010",
634
- d: "M1024 1769h478q-53-130-43-280-100-39-213-67.5t-222-28.5q-110 0-223 28.5T589 1489q9 150-43 280zm0-450q111 0 223.5 26.5T1468 1413q17-105 60.5-212.5T1634 988l-220 155-123-601-267 555-267-555-123 601-220-155q61 105 104.5 212.5T580 1413q108-41 220.5-67.5T1024 1319m0 524H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zM276 746q-62 0-62 62t62 62q63 0 63-62t-63-62m466-394q-62 0-62 62t62 62 62-62-62-62M590 1519l119 72-134 86q19-86 15-158m1182-773q-63 0-63 62t63 62q62 0 62-62t-62-62m-466-394q-62 0-62 62t62 62 62-62-62-62m152 1167-119 72 134 86q-20-86-15-158m-573 47 139-83 139 86-139 84z"
635
- }));
636
- } finally {
637
- _effect.f();
638
- }
639
- };
516
+ var SvgWQ = (props) => /* @__PURE__ */ React14.createElement("svg", {
517
+ xmlns: "http://www.w3.org/2000/svg",
518
+ viewBox: "0 0 2048 2048",
519
+ ...props
520
+ }, /* @__PURE__ */ React14.createElement("path", {
521
+ fill: "#f9f9f9",
522
+ d: "m508.5 1815.6 48.4-356.7-216.3-554.6-135.8-20.7-16.1-126.5 112.7-43.8 78.3 73.7-18.4 99 246.2 197.8 112.8-568.3L635 428l78.3-108 112.8 43.7-23 161 223.2 474 244-490-66.8-105.9 92-92 105.9 73.6L1337 534l103.5 529.2 260-161-16-142.7 131-46 57.6 131.1-207 103.6-175 529.2 48.4 308.4z"
523
+ }), /* @__PURE__ */ React14.createElement("path", {
524
+ fill: "#101010",
525
+ d: "M1024 1769h478q-53-130-43-280-100-39-213-67.5t-222-28.5q-110 0-223 28.5T589 1489q9 150-43 280zm0-450q111 0 223.5 26.5T1468 1413q17-105 60.5-212.5T1634 988l-220 155-123-601-267 555-267-555-123 601-220-155q61 105 104.5 212.5T580 1413q108-41 220.5-67.5T1024 1319m0 524H441q114-231 57.5-456.5T296 937q-12 2-19 2-54 0-92.5-38.5T146 808t38.5-92.5T277 677t92.5 38.5T408 808q0 20-6 38-4 14-15 33l196 139 100-486q-64-31-72-103-5-44 29-91t88-53q54-5 96 29t48 88q7 68-46 114l198 412 198-412q-54-46-46-114 6-54 48-88t96-29q54 6 87.5 53t29.5 91q-9 72-72 103l100 486 196-139q-12-19-15-33-6-18-6-38 0-54 38.5-92.5T1771 677t92.5 38.5T1902 808t-38.5 92.5T1771 939q-7 0-19-2-147 224-203 449.5t58 456.5zM276 746q-62 0-62 62t62 62q63 0 63-62t-63-62m466-394q-62 0-62 62t62 62 62-62-62-62M590 1519l119 72-134 86q19-86 15-158m1182-773q-63 0-63 62t63 62q62 0 62-62t-62-62m-466-394q-62 0-62 62t62 62 62-62-62-62m152 1167-119 72 134 86q-20-86-15-158m-573 47 139-83 139 86-139 84z"
526
+ }));
640
527
  var wQ_default = SvgWQ;
641
528
 
642
529
  // src/gen/pieces/chess/alpha/wR.tsx
643
- import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
644
530
  import * as React15 from "react";
645
- var SvgWR = (props) => {
646
- var _effect = _useSignals15();
647
- try {
648
- return /* @__PURE__ */ React15.createElement("svg", {
649
- xmlns: "http://www.w3.org/2000/svg",
650
- viewBox: "0 0 2048 2048",
651
- ...props
652
- }, /* @__PURE__ */ React15.createElement("path", {
653
- fill: "#f9f9f9",
654
- d: "m435 1804 16-212 152-115 51-688-148-115-7-276 210-2 4 138 198 2 7-140 212-3 14 145 193-4 5-138h204l-7 285-145 106 42 693 172 124 19 207z"
655
- }), /* @__PURE__ */ React15.createElement("path", {
656
- fill: "#101010",
657
- d: "M1024 1501H643l5-74h752l5 74zm0-661H692l5-74h654l5 74zm0 1003H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-74h557l-15-149-161-119-54-735 152-109 13-230h-138v148h-285V427H955v148H670V427H532l13 230 152 109-54 735-161 119-15 149z"
658
- }));
659
- } finally {
660
- _effect.f();
661
- }
662
- };
531
+ var SvgWR = (props) => /* @__PURE__ */ React15.createElement("svg", {
532
+ xmlns: "http://www.w3.org/2000/svg",
533
+ viewBox: "0 0 2048 2048",
534
+ ...props
535
+ }, /* @__PURE__ */ React15.createElement("path", {
536
+ fill: "#f9f9f9",
537
+ d: "m435 1804 16-212 152-115 51-688-148-115-7-276 210-2 4 138 198 2 7-140 212-3 14 145 193-4 5-138h204l-7 285-145 106 42 693 172 124 19 207z"
538
+ }), /* @__PURE__ */ React15.createElement("path", {
539
+ fill: "#101010",
540
+ d: "M1024 1501H643l5-74h752l5 74zm0-661H692l5-74h654l5 74zm0 1003H383l29-264 159-118 50-659-149-107-17-341h289v147h137V354h286v147h137V354h289l-17 341-149 107 50 659 159 118 29 264zm0-74h557l-15-149-161-119-54-735 152-109 13-230h-138v148h-285V427H955v148H670V427H532l13 230 152 109-54 735-161 119-15 149z"
541
+ }));
663
542
  var wR_default = SvgWR;
664
543
 
665
544
  // src/components/Chessboard/chess.ts
@@ -676,6 +555,9 @@ var posToLocation = (pos) => {
676
555
  var locationToPos = ([row, col]) => {
677
556
  return String.fromCharCode(col + "a".charCodeAt(0)) + (row + 1);
678
557
  };
558
+ var getRawPgn = (pgn) => {
559
+ return pgn.replace(/\[.*?\]/g, "").trim();
560
+ };
679
561
  var styles = {
680
562
  neutral: {
681
563
  black: "bg-neutral-50",
@@ -710,7 +592,7 @@ var createChess = (pgn) => {
710
592
  } catch {
711
593
  log4.warn(pgn, void 0, {
712
594
  F: __dxlog_file4,
713
- L: 71,
595
+ L: 76,
714
596
  S: void 0,
715
597
  C: (f, a) => f(...a)
716
598
  });
@@ -718,37 +600,32 @@ var createChess = (pgn) => {
718
600
  }
719
601
  return chess;
720
602
  };
721
- var tryMove = (chess, move) => {
722
- const from = locationToPos(move.from);
723
- const to = locationToPos(move.to);
724
- try {
725
- const promotion = move.promotion ? move.promotion[1].toLowerCase() : "q";
726
- chess.move({
727
- from,
728
- to,
729
- promotion
730
- }, {
731
- strict: false
732
- });
733
- return chess;
734
- } catch {
735
- return null;
736
- }
737
- };
738
603
  var ChessModel = class {
604
+ _registry;
739
605
  _chess = new ChessJS();
740
- _pieces = signal({});
741
- constructor(pgn) {
606
+ _pieces = Atom.make({});
607
+ _moveIndex = Atom.make(0);
608
+ constructor(_registry, pgn) {
609
+ this._registry = _registry;
742
610
  this.update(pgn);
743
611
  }
612
+ get readonly() {
613
+ return this._registry.get(this._moveIndex) !== this._chess.history().length;
614
+ }
744
615
  get turn() {
745
616
  return this._chess.turn() === "w" ? "white" : "black";
746
617
  }
618
+ get game() {
619
+ return this._chess;
620
+ }
747
621
  get pieces() {
748
622
  return this._pieces;
749
623
  }
750
- get game() {
751
- return this._chess;
624
+ get moveIndex() {
625
+ return this._moveIndex;
626
+ }
627
+ get fen() {
628
+ return this._chess.fen();
752
629
  }
753
630
  /**
754
631
  * PGN with headers.
@@ -763,10 +640,17 @@ var ChessModel = class {
763
640
  */
764
641
  // TODO(burdon): Update headers.
765
642
  get pgn() {
766
- return this._chess.pgn();
643
+ return getRawPgn(this._chess.pgn());
767
644
  }
768
- get fen() {
769
- return this._chess.fen();
645
+ setMoveIndex(index) {
646
+ const temp = new ChessJS();
647
+ const history = this._chess.history({
648
+ verbose: true
649
+ });
650
+ for (let i = 0; i < index && i < history.length; i++) {
651
+ temp.move(history[i]);
652
+ }
653
+ this._updateBoard(temp);
770
654
  }
771
655
  update(pgn = "") {
772
656
  const previous = this._chess.history();
@@ -778,9 +662,9 @@ var ChessModel = class {
778
662
  }
779
663
  const current = this._chess.history();
780
664
  if (!isValidNextMove(previous, current)) {
781
- this._pieces.value = {};
665
+ this._registry.set(this._pieces, {});
782
666
  }
783
- this._update();
667
+ this._updateBoard(this._chess);
784
668
  }
785
669
  isValidMove(move) {
786
670
  return tryMove(new ChessJS(this._chess.fen()), move) !== null;
@@ -795,7 +679,7 @@ var ChessModel = class {
795
679
  if (!game) {
796
680
  return false;
797
681
  }
798
- this._update();
682
+ this._updateBoard(this._chess);
799
683
  return true;
800
684
  }
801
685
  makeRandomMove() {
@@ -805,29 +689,32 @@ var ChessModel = class {
805
689
  }
806
690
  const move = moves[Math.floor(Math.random() * moves.length)];
807
691
  this._chess.move(move);
808
- this._update();
692
+ this._updateBoard(this._chess);
809
693
  return true;
810
694
  }
811
695
  /**
812
696
  * Update pieces preserving identity.
813
697
  */
814
- _update() {
815
- const pieces = {};
816
- this._chess.board().flatMap((row) => row.forEach((record) => {
817
- if (!record) {
818
- return;
819
- }
820
- const { square, type, color } = record;
821
- const pieceType = `${color.toUpperCase()}${type.toUpperCase()}`;
822
- const location = posToLocation(square);
823
- pieces[locationToString(location)] = {
824
- id: `${square}-${pieceType}`,
825
- type: pieceType,
826
- side: color === "w" ? "white" : "black",
827
- location
828
- };
829
- }));
830
- this._pieces.value = mapPieces(this._pieces.value, pieces);
698
+ _updateBoard(chess) {
699
+ this._registry.set(this._pieces, createPieceMap(chess));
700
+ this._registry.set(this._moveIndex, chess.history().length);
701
+ }
702
+ };
703
+ var tryMove = (chess, move) => {
704
+ const from = locationToPos(move.from);
705
+ const to = locationToPos(move.to);
706
+ try {
707
+ const promotion = move.promotion ? move.promotion[1].toLowerCase() : "q";
708
+ chess.move({
709
+ from,
710
+ to,
711
+ promotion
712
+ }, {
713
+ strict: false
714
+ });
715
+ return chess;
716
+ } catch {
717
+ return null;
831
718
  }
832
719
  };
833
720
  var isValidNextMove = (previous, current) => {
@@ -841,7 +728,51 @@ var isValidNextMove = (previous, current) => {
841
728
  }
842
729
  return true;
843
730
  };
844
- var mapPieces = (before, after) => {
731
+ var createPieceMap = (chess) => {
732
+ const temp = new ChessJS();
733
+ let pieces = _createPieceMap(temp);
734
+ const history = chess.history({
735
+ verbose: true
736
+ });
737
+ for (let i = 0; i < history.length; i++) {
738
+ const move = history[i];
739
+ temp.move(move);
740
+ pieces = _diffPieces(pieces, _createPieceMap(temp));
741
+ const test = /* @__PURE__ */ new Set();
742
+ Object.values(pieces).forEach((piece) => {
743
+ invariant3(!test.has(piece.id), "Duplicate: " + piece.id, {
744
+ F: __dxlog_file4,
745
+ L: 255,
746
+ S: void 0,
747
+ A: [
748
+ "!test.has(piece.id)",
749
+ "'Duplicate: ' + piece.id"
750
+ ]
751
+ });
752
+ test.add(piece.id);
753
+ });
754
+ }
755
+ return pieces;
756
+ };
757
+ var _createPieceMap = (chess) => {
758
+ const pieces = {};
759
+ chess.board().flatMap((row) => row.forEach((record) => {
760
+ if (!record) {
761
+ return;
762
+ }
763
+ const { square, type, color } = record;
764
+ const pieceType = `${color.toUpperCase()}${type.toUpperCase()}`;
765
+ const location = posToLocation(square);
766
+ pieces[locationToString(location)] = {
767
+ id: `${square}-${pieceType}`,
768
+ type: pieceType,
769
+ side: color === "w" ? "white" : "black",
770
+ location
771
+ };
772
+ }));
773
+ return pieces;
774
+ };
775
+ var _diffPieces = (before, after) => {
845
776
  const difference = {
846
777
  removed: {},
847
778
  added: {}
@@ -864,180 +795,161 @@ var mapPieces = (before, after) => {
864
795
  piece.id = previous.id;
865
796
  }
866
797
  }
867
- log4("delta", {
868
- before: Object.keys(before).length,
869
- after: Object.keys(after).length,
870
- removed: Object.keys(difference.removed).length,
871
- added: Object.keys(difference.added).length
872
- }, {
873
- F: __dxlog_file4,
874
- L: 263,
875
- S: void 0,
876
- C: (f, a) => f(...a)
877
- });
878
798
  return after;
879
799
  };
880
800
  var createDate = (date = /* @__PURE__ */ new Date()) => date.toISOString().slice(0, 10).replace(/-/g, ".");
881
801
 
882
802
  // src/components/Chessboard/Chessboard.tsx
883
- import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
884
- import React16, { memo as memo3, useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState4 } from "react";
803
+ import { Atom as Atom2, useAtomValue } from "@effect-atom/atom-react";
804
+ import React16, { forwardRef as forwardRef2, memo as memo3, useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState4 } from "react";
885
805
  import { useResizeDetector } from "react-resize-detector";
886
- import { useTrackProps as useTrackProps2 } from "@dxos/react-ui";
887
- import { mx as mx4 } from "@dxos/react-ui-theme";
888
- import { isNotFalsy } from "@dxos/util";
889
- var Chessboard = /* @__PURE__ */ memo3(({ orientation, showLabels, debug, rows = 8, cols = 8, classNames }) => {
890
- var _effect = _useSignals16();
891
- try {
892
- useTrackProps2({
893
- orientation,
894
- showLabels,
895
- debug
896
- }, Chessboard.displayName, false);
897
- const { ref: containerRef, width, height } = useResizeDetector({
898
- refreshRate: 200
899
- });
900
- const { model, promoting, onPromotion } = useGameboardContext(Chessboard.displayName);
901
- const locations = useMemo(() => {
902
- return Array.from({
903
- length: rows
904
- }, (_, i) => orientation === "black" ? i : rows - 1 - i).flatMap((row) => Array.from({
905
- length: cols
906
- }).map((_, col) => [
907
- row,
908
- col
909
- ]));
910
- }, [
911
- orientation,
912
- rows,
913
- cols
914
- ]);
915
- const layout = useMemo(() => {
916
- return locations.map((location) => {
917
- return /* @__PURE__ */ React16.createElement("div", {
918
- key: locationToString(location),
919
- ["data-location"]: locationToString(location)
920
- });
806
+ import { useForwardedRef } from "@dxos/react-ui";
807
+ import { mx as mx4 } from "@dxos/ui-theme";
808
+ import { isNonNullable } from "@dxos/util";
809
+ var EMPTY_PIECES_ATOM = Atom2.make({});
810
+ var CHESSBOARD_NAME = "Chessboard";
811
+ var ChessboardComponent = /* @__PURE__ */ forwardRef2(({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
812
+ const targetRef = useForwardedRef(forwardedRef);
813
+ const { width, height } = useResizeDetector({
814
+ targetRef,
815
+ refreshRate: 200
816
+ });
817
+ const { model, promoting, onPromotion } = useGameboardContext(CHESSBOARD_NAME);
818
+ const pieces = useAtomValue(model?.pieces ?? EMPTY_PIECES_ATOM);
819
+ const squares = useMemo(() => {
820
+ return Array.from({
821
+ length: rows
822
+ }, (_, i) => orientation === "black" ? i : rows - 1 - i).flatMap((row) => Array.from({
823
+ length: cols
824
+ }).map((_, col) => [
825
+ row,
826
+ col
827
+ ]));
828
+ }, [
829
+ orientation,
830
+ rows,
831
+ cols
832
+ ]);
833
+ const layout = useMemo(() => {
834
+ return squares.map((location) => {
835
+ return /* @__PURE__ */ React16.createElement("div", {
836
+ key: locationToString(location),
837
+ "data-location": locationToString(location)
921
838
  });
922
- }, [
923
- locations
924
- ]);
925
- const [grid, setGrid] = useState4({});
926
- const gridRef = useRef3(null);
927
- useEffect4(() => {
928
- setGrid(locations.reduce((acc, location) => {
929
- const square = getSquareLocation(gridRef.current, location);
930
- const bounds = getRelativeBounds(gridRef.current, square);
931
- return {
932
- ...acc,
933
- [locationToString(location)]: bounds
934
- };
935
- }, {}));
936
- }, [
937
- locations,
938
- width,
939
- height
940
- ]);
941
- const positions = useMemo(() => {
942
- if (!gridRef.current) {
943
- return [];
944
- }
945
- return Object.values(model?.pieces.value ?? {}).map((piece) => {
946
- if (piece.id === promoting?.id) {
947
- return null;
948
- }
949
- const bounds = grid[locationToString(piece.location)];
950
- return {
951
- piece,
952
- bounds
953
- };
954
- }).filter(isNotFalsy);
955
- }, [
956
- grid,
957
- model?.pieces.value,
958
- promoting
959
- ]);
960
- return /* @__PURE__ */ React16.createElement("div", {
961
- ref: containerRef,
962
- className: mx4("relative", classNames)
963
- }, /* @__PURE__ */ React16.createElement("div", {
964
- ref: gridRef,
965
- className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
966
- }, layout), /* @__PURE__ */ React16.createElement("div", null, locations.map((location) => /* @__PURE__ */ React16.createElement(Gameboard.Square, {
967
- key: locationToString(location),
968
- location,
969
- label: showLabels ? locationToPos(location) : void 0,
970
- bounds: grid[locationToString(location)],
971
- classNames: getSquareColor(location)
972
- }))), /* @__PURE__ */ React16.createElement("div", {
973
- className: mx4(promoting && "opacity-50")
974
- }, positions.map(({ bounds, piece }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
975
- key: piece.id,
976
- piece,
977
- bounds,
978
- label: debug ? piece.id : void 0,
979
- orientation,
980
- Component: ChessPieces[piece.type]
981
- }))), promoting && /* @__PURE__ */ React16.createElement(PromotionSelector, {
982
- grid,
983
- piece: promoting,
984
- onSelect: (piece) => {
985
- onPromotion({
986
- from: Object.values(model.pieces.value).find((p) => p.id === promoting.id).location,
987
- to: piece.location,
988
- piece: promoting.type,
989
- promotion: piece.type
990
- });
839
+ });
840
+ }, [
841
+ squares
842
+ ]);
843
+ const [grid, setGrid] = useState4({});
844
+ const gridRef = useRef3(null);
845
+ useEffect4(() => {
846
+ setGrid(squares.reduce((acc, location) => {
847
+ const square = getSquareLocation(gridRef.current, location);
848
+ const bounds = getRelativeBounds(gridRef.current, square);
849
+ return {
850
+ ...acc,
851
+ [locationToString(location)]: bounds
852
+ };
853
+ }, {}));
854
+ }, [
855
+ squares,
856
+ width,
857
+ height
858
+ ]);
859
+ const positions = useMemo(() => {
860
+ if (!gridRef.current) {
861
+ return [];
862
+ }
863
+ return Object.values(pieces).map((piece) => {
864
+ if (piece.id === promoting?.id) {
865
+ return null;
991
866
  }
992
- }));
993
- } finally {
994
- _effect.f();
995
- }
996
- });
997
- Chessboard.displayName = "Chessboard";
998
- var getSquareLocation = (container, location) => {
999
- return container.querySelector(`[data-location="${locationToString(location)}"]`);
1000
- };
1001
- var PromotionSelector = ({ grid, piece, onSelect }) => {
1002
- var _effect = _useSignals16();
1003
- try {
1004
- const positions = [
1005
- "Q",
1006
- "N",
1007
- "R",
1008
- "B"
1009
- ].map((pieceType, i) => {
1010
- const location = [
1011
- piece.location[0] + (piece.location[0] === 0 ? i : -i),
1012
- piece.location[1]
1013
- ];
867
+ const bounds = grid[locationToString(piece.location)];
1014
868
  return {
1015
- piece: {
1016
- id: `promotion-${pieceType}`,
1017
- type: (piece.side === "black" ? "B" : "W") + pieceType,
1018
- side: piece.side,
1019
- location
1020
- },
1021
- bounds: grid[locationToString(location)]
869
+ piece,
870
+ bounds
1022
871
  };
1023
- });
1024
- const handleSelect = (selected) => {
1025
- onSelect({
1026
- ...piece,
1027
- type: selected.type
872
+ }).filter(isNonNullable);
873
+ }, [
874
+ grid,
875
+ pieces,
876
+ promoting
877
+ ]);
878
+ return /* @__PURE__ */ React16.createElement("div", {
879
+ ref: targetRef,
880
+ tabIndex: 0,
881
+ className: mx4("dx-expander relative outline-hidden", classNames)
882
+ }, /* @__PURE__ */ React16.createElement("div", {
883
+ ref: gridRef,
884
+ className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
885
+ }, layout), /* @__PURE__ */ React16.createElement("div", null, squares.map((location) => /* @__PURE__ */ React16.createElement(Gameboard.Square, {
886
+ key: locationToString(location),
887
+ location,
888
+ label: showLabels ? locationToPos(location) : void 0,
889
+ bounds: grid[locationToString(location)],
890
+ classNames: getSquareColor(location)
891
+ }))), /* @__PURE__ */ React16.createElement("div", {
892
+ className: mx4(promoting && "opacity-50")
893
+ }, positions.map(({ bounds, piece }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
894
+ key: piece.id,
895
+ piece,
896
+ bounds,
897
+ label: debug ? piece.id : void 0,
898
+ orientation,
899
+ Component: ChessPieces[piece.type]
900
+ }))), promoting && /* @__PURE__ */ React16.createElement(PromotionSelector, {
901
+ grid,
902
+ piece: promoting,
903
+ onSelect: (piece) => {
904
+ onPromotion({
905
+ from: Object.values(pieces).find((p) => p.id === promoting.id).location,
906
+ to: piece.location,
907
+ piece: promoting.type,
908
+ promotion: piece.type
1028
909
  });
910
+ }
911
+ }));
912
+ });
913
+ ChessboardComponent.displayName = CHESSBOARD_NAME;
914
+ var Chessboard = /* @__PURE__ */ memo3(ChessboardComponent);
915
+ var PromotionSelector = ({ grid, piece, onSelect }) => {
916
+ const positions = [
917
+ "Q",
918
+ "N",
919
+ "R",
920
+ "B"
921
+ ].map((pieceType, i) => {
922
+ const location = [
923
+ piece.location[0] + (piece.location[0] === 0 ? i : -i),
924
+ piece.location[1]
925
+ ];
926
+ return {
927
+ piece: {
928
+ id: `promotion-${pieceType}`,
929
+ type: (piece.side === "black" ? "B" : "W") + pieceType,
930
+ side: piece.side,
931
+ location
932
+ },
933
+ bounds: grid[locationToString(location)]
1029
934
  };
1030
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, positions.map(({ piece: piece2, bounds }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
1031
- key: piece2.id,
1032
- piece: piece2,
1033
- bounds,
1034
- Component: ChessPieces[piece2.type],
1035
- classNames: mx4("border-2 border-neutral-700 rounded-full", boardStyles.promotion),
1036
- onClick: () => handleSelect(piece2)
1037
- })));
1038
- } finally {
1039
- _effect.f();
1040
- }
935
+ });
936
+ const handleSelect = (selected) => {
937
+ onSelect({
938
+ ...piece,
939
+ type: selected.type
940
+ });
941
+ };
942
+ return /* @__PURE__ */ React16.createElement(React16.Fragment, null, positions.map(({ piece: piece2, bounds }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
943
+ key: piece2.id,
944
+ classNames: mx4("border-2 border-neutral-700 rounded-full", boardStyles.promotion),
945
+ piece: piece2,
946
+ bounds,
947
+ Component: ChessPieces[piece2.type],
948
+ onClick: () => handleSelect(piece2)
949
+ })));
950
+ };
951
+ var getSquareLocation = (container, location) => {
952
+ return container.querySelector(`[data-location="${locationToString(location)}"]`);
1041
953
  };
1042
954
  export {
1043
955
  ChessModel,
@@ -1046,6 +958,8 @@ export {
1046
958
  Gameboard,
1047
959
  boardStyles,
1048
960
  createChess,
961
+ createPieceMap,
962
+ getRawPgn,
1049
963
  getRelativeBounds,
1050
964
  getSquareColor,
1051
965
  isEqualLocation,
@@ -1053,7 +967,6 @@ export {
1053
967
  isPiece,
1054
968
  locationToPos,
1055
969
  locationToString,
1056
- mapPieces,
1057
970
  posToLocation,
1058
971
  stringToLocation,
1059
972
  useGameboardContext