@dxos/react-ui-gameboard 0.8.4-main.ead640a → 0.8.4-main.f466a3d56e

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 (54) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +2 -0
  3. package/dist/lib/browser/index.mjs +500 -695
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/node-esm/index.mjs +500 -695
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/types/src/components/Chessboard/Chessboard.d.ts +2 -2
  10. package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -1
  11. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts +2 -1
  12. package/dist/types/src/components/Chessboard/Chessboard.stories.d.ts.map +1 -1
  13. package/dist/types/src/components/Chessboard/chess.d.ts +5 -4
  14. package/dist/types/src/components/Chessboard/chess.d.ts.map +1 -1
  15. package/dist/types/src/components/Gameboard/Gameboard.d.ts +10 -7
  16. package/dist/types/src/components/Gameboard/Gameboard.d.ts.map +1 -1
  17. package/dist/types/src/components/Gameboard/Piece.d.ts.map +1 -1
  18. package/dist/types/src/components/Gameboard/Square.d.ts.map +1 -1
  19. package/dist/types/src/components/Gameboard/types.d.ts +2 -3
  20. package/dist/types/src/components/Gameboard/types.d.ts.map +1 -1
  21. package/dist/types/src/components/Gameboard/util.d.ts.map +1 -1
  22. package/dist/types/src/gen/pieces/chess/alpha/bB.d.ts.map +1 -1
  23. package/dist/types/src/gen/pieces/chess/alpha/bK.d.ts.map +1 -1
  24. package/dist/types/src/gen/pieces/chess/alpha/bN.d.ts.map +1 -1
  25. package/dist/types/src/gen/pieces/chess/alpha/bP.d.ts.map +1 -1
  26. package/dist/types/src/gen/pieces/chess/alpha/bQ.d.ts.map +1 -1
  27. package/dist/types/src/gen/pieces/chess/alpha/bR.d.ts.map +1 -1
  28. package/dist/types/src/gen/pieces/chess/alpha/wB.d.ts.map +1 -1
  29. package/dist/types/src/gen/pieces/chess/alpha/wK.d.ts.map +1 -1
  30. package/dist/types/src/gen/pieces/chess/alpha/wN.d.ts.map +1 -1
  31. package/dist/types/src/gen/pieces/chess/alpha/wP.d.ts.map +1 -1
  32. package/dist/types/src/gen/pieces/chess/alpha/wQ.d.ts.map +1 -1
  33. package/dist/types/src/gen/pieces/chess/alpha/wR.d.ts.map +1 -1
  34. package/dist/types/src/gen/pieces/chess/cburnett/bB.d.ts.map +1 -1
  35. package/dist/types/src/gen/pieces/chess/cburnett/bK.d.ts.map +1 -1
  36. package/dist/types/src/gen/pieces/chess/cburnett/bN.d.ts.map +1 -1
  37. package/dist/types/src/gen/pieces/chess/cburnett/bP.d.ts.map +1 -1
  38. package/dist/types/src/gen/pieces/chess/cburnett/bQ.d.ts.map +1 -1
  39. package/dist/types/src/gen/pieces/chess/cburnett/bR.d.ts.map +1 -1
  40. package/dist/types/src/gen/pieces/chess/cburnett/wB.d.ts.map +1 -1
  41. package/dist/types/src/gen/pieces/chess/cburnett/wK.d.ts.map +1 -1
  42. package/dist/types/src/gen/pieces/chess/cburnett/wN.d.ts.map +1 -1
  43. package/dist/types/src/gen/pieces/chess/cburnett/wP.d.ts.map +1 -1
  44. package/dist/types/src/gen/pieces/chess/cburnett/wQ.d.ts.map +1 -1
  45. package/dist/types/src/gen/pieces/chess/cburnett/wR.d.ts.map +1 -1
  46. package/dist/types/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +27 -27
  48. package/src/components/Chessboard/Chessboard.stories.tsx +9 -5
  49. package/src/components/Chessboard/Chessboard.tsx +19 -12
  50. package/src/components/Chessboard/chess.ts +13 -10
  51. package/src/components/Gameboard/Gameboard.tsx +8 -10
  52. package/src/components/Gameboard/Piece.tsx +5 -3
  53. package/src/components/Gameboard/Square.tsx +5 -3
  54. package/src/components/Gameboard/types.ts +2 -3
@@ -24,15 +24,13 @@ var getRelativeBounds = (container, element) => {
24
24
  };
25
25
 
26
26
  // src/components/Gameboard/Gameboard.tsx
27
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
28
27
  import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
29
28
  import { createContext } from "@radix-ui/react-context";
30
29
  import React3, { forwardRef, useCallback, useEffect as useEffect3, useState as useState3 } from "react";
31
30
  import { log as log3 } from "@dxos/log";
32
- import { mx as mx3 } from "@dxos/react-ui-theme";
31
+ import { mx as mx3 } from "@dxos/ui-theme";
33
32
 
34
33
  // src/components/Gameboard/Piece.tsx
35
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
36
34
  import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
37
35
  import { centerUnderPointer } from "@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer";
38
36
  import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
@@ -41,213 +39,173 @@ import { createPortal } from "react-dom";
41
39
  import { invariant } from "@dxos/invariant";
42
40
  import { log } from "@dxos/log";
43
41
  import { useDynamicRef } from "@dxos/react-ui";
44
- import { mx } from "@dxos/react-ui-theme";
42
+ import { mx } from "@dxos/ui-theme";
45
43
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Piece.tsx";
44
+ var PIECE_NAME = "Piece";
46
45
  var Piece = /* @__PURE__ */ memo(({ classNames, Component, piece, bounds, label, onClick }) => {
47
- var _effect = _useSignals();
48
- try {
49
- const { model, dragging: isDragging, promoting } = useGameboardContext(Piece.displayName);
50
- const promotingRef = useDynamicRef(promoting);
51
- const [dragging, setDragging] = useState(false);
52
- const [preview, setPreview] = useState();
53
- const [current, setCurrent] = useState({});
54
- const ref = useRef(null);
55
- useEffect(() => {
56
- if (!model) {
57
- return;
58
- }
59
- const el = ref.current;
60
- invariant(el, void 0, {
61
- F: __dxlog_file,
62
- L: 45,
63
- S: void 0,
64
- A: [
65
- "el",
66
- ""
67
- ]
68
- });
69
- return draggable({
70
- element: el,
71
- getInitialData: () => ({
72
- piece
73
- }),
74
- onGenerateDragPreview: ({ nativeSetDragImage, source }) => {
75
- log("onGenerateDragPreview", {
76
- source: source.data
77
- }, {
78
- F: __dxlog_file,
79
- L: 51,
80
- S: void 0,
81
- C: (f, a) => f(...a)
82
- });
83
- setCustomNativeDragPreview({
84
- getOffset: centerUnderPointer,
85
- render: ({ container }) => {
86
- setPreview(container);
87
- const { width, height } = el.getBoundingClientRect();
88
- container.style.width = width + "px";
89
- container.style.height = height + "px";
90
- return () => {
91
- setPreview(void 0);
92
- };
93
- },
94
- nativeSetDragImage
95
- });
96
- },
97
- canDrag: () => !promotingRef.current && !model.readonly && model.turn === piece.side,
98
- onDragStart: () => setDragging(true),
99
- onDrop: ({ location: { current: current2 } }) => {
100
- try {
101
- const location = current2.dropTargets[0]?.data.location;
102
- if (isLocation(location)) {
103
- setCurrent((current3) => ({
104
- ...current3,
105
- location
106
- }));
107
- }
108
- } catch {
46
+ const { model, dragging: isDragging, promoting } = useGameboardContext(PIECE_NAME);
47
+ const promotingRef = useDynamicRef(promoting);
48
+ const [dragging, setDragging] = useState(false);
49
+ const [preview, setPreview] = useState();
50
+ const [current, setCurrent] = useState({});
51
+ const ref = useRef(null);
52
+ useEffect(() => {
53
+ if (!model) {
54
+ return;
55
+ }
56
+ const el = ref.current;
57
+ invariant(el, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 29, S: void 0, A: ["el", ""] });
58
+ return draggable({
59
+ element: el,
60
+ getInitialData: () => ({
61
+ piece
62
+ }),
63
+ onGenerateDragPreview: ({ nativeSetDragImage, source }) => {
64
+ log("onGenerateDragPreview", {
65
+ source: source.data
66
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 36, S: void 0 });
67
+ setCustomNativeDragPreview({
68
+ getOffset: centerUnderPointer,
69
+ render: ({ container }) => {
70
+ setPreview(container);
71
+ const { width, height } = el.getBoundingClientRect();
72
+ container.style.width = width + "px";
73
+ container.style.height = height + "px";
74
+ return () => {
75
+ setPreview(void 0);
76
+ };
77
+ },
78
+ nativeSetDragImage
79
+ });
80
+ },
81
+ canDrag: () => !promotingRef.current && !model.readonly && model.turn === piece.side,
82
+ onDragStart: () => setDragging(true),
83
+ onDrop: ({ location: { current: current2 } }) => {
84
+ try {
85
+ const location = current2.dropTargets[0]?.data.location;
86
+ if (isLocation(location)) {
87
+ setCurrent((current3) => ({
88
+ ...current3,
89
+ location
90
+ }));
109
91
  }
110
- setDragging(false);
111
- }
112
- });
113
- }, [
114
- model,
115
- piece
116
- ]);
117
- useEffect(() => {
118
- requestAnimationFrame(() => {
119
- if (!ref.current || !bounds) {
120
- return;
121
- }
122
- if (!current.location || !isEqualLocation(current.location, piece.location)) {
123
- ref.current.style.transition = "top 250ms ease-out, left 250ms ease-out";
124
- ref.current.style.top = bounds.top + "px";
125
- ref.current.style.left = bounds.left + "px";
126
- setCurrent({
127
- location: piece.location,
128
- bounds
129
- });
130
- } else if (current.bounds !== bounds) {
131
- ref.current.style.transition = "none";
132
- ref.current.style.top = bounds.top + "px";
133
- ref.current.style.left = bounds.left + "px";
134
- setCurrent({
135
- location: piece.location,
136
- bounds
137
- });
92
+ } catch {
138
93
  }
139
- });
140
- }, [
141
- current,
142
- piece.location,
143
- bounds
144
- ]);
145
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
146
- ref,
147
- style: {
148
- width: bounds?.width,
149
- height: bounds?.height
150
- },
151
- className: mx("absolute", classNames, dragging && "opacity-20", isDragging && "pointer-events-none"),
152
- onClick
153
- }, /* @__PURE__ */ React.createElement(Component, {
154
- className: "grow"
155
- }), label && /* @__PURE__ */ React.createElement("div", {
156
- className: "absolute inset-1 text-xs text-black"
157
- }, label)), preview && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement("div", {
158
- className: mx(classNames)
159
- }, /* @__PURE__ */ React.createElement(Component, {
160
- className: "grow"
161
- })), preview));
162
- } finally {
163
- _effect.f();
164
- }
94
+ setDragging(false);
95
+ }
96
+ });
97
+ }, [
98
+ model,
99
+ piece
100
+ ]);
101
+ useEffect(() => {
102
+ requestAnimationFrame(() => {
103
+ if (!ref.current || !bounds) {
104
+ return;
105
+ }
106
+ if (!current.location || !isEqualLocation(current.location, piece.location)) {
107
+ ref.current.style.transition = "top 250ms ease-out, left 250ms ease-out";
108
+ ref.current.style.top = bounds.top + "px";
109
+ ref.current.style.left = bounds.left + "px";
110
+ setCurrent({
111
+ location: piece.location,
112
+ bounds
113
+ });
114
+ } else if (current.bounds !== bounds) {
115
+ ref.current.style.transition = "none";
116
+ ref.current.style.top = bounds.top + "px";
117
+ ref.current.style.left = bounds.left + "px";
118
+ setCurrent({
119
+ location: piece.location,
120
+ bounds
121
+ });
122
+ }
123
+ });
124
+ }, [
125
+ current,
126
+ piece.location,
127
+ bounds
128
+ ]);
129
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
130
+ ref,
131
+ style: {
132
+ width: bounds?.width,
133
+ height: bounds?.height
134
+ },
135
+ className: mx("absolute", classNames, dragging && "opacity-20", isDragging && "pointer-events-none"),
136
+ onClick
137
+ }, /* @__PURE__ */ React.createElement(Component, {
138
+ className: "grow"
139
+ }), label && /* @__PURE__ */ React.createElement("div", {
140
+ className: "absolute inset-1 text-xs text-black"
141
+ }, label)), preview && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement("div", {
142
+ className: mx(classNames)
143
+ }, /* @__PURE__ */ React.createElement(Component, {
144
+ className: "grow"
145
+ })), preview));
165
146
  });
166
- Piece.displayName = "Piece";
147
+ Piece.displayName = PIECE_NAME;
167
148
 
168
149
  // src/components/Gameboard/Square.tsx
169
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
170
150
  import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
171
151
  import React2, { memo as memo2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
172
152
  import { invariant as invariant2 } from "@dxos/invariant";
173
153
  import { log as log2 } from "@dxos/log";
174
- import { mx as mx2 } from "@dxos/react-ui-theme";
154
+ import { mx as mx2 } from "@dxos/ui-theme";
175
155
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Square.tsx";
156
+ var SQUARE_NAME = "Square";
176
157
  var Square = /* @__PURE__ */ memo2(({ location, bounds, label, classNames }) => {
177
- var _effect = _useSignals2();
178
- try {
179
- const ref = useRef2(null);
180
- const [state, setState] = useState2("idle");
181
- const { model } = useGameboardContext(Square.displayName);
182
- useEffect2(() => {
183
- const el = ref.current;
184
- invariant2(el, void 0, {
185
- F: __dxlog_file2,
186
- L: 32,
187
- S: void 0,
188
- A: [
189
- "el",
190
- ""
191
- ]
192
- });
193
- return dropTargetForElements({
194
- element: el,
195
- getData: () => ({
196
- location
197
- }),
198
- canDrop: ({ source }) => {
199
- log2("canDrop", {
200
- source: source.data
201
- }, {
202
- F: __dxlog_file2,
203
- L: 38,
204
- S: void 0,
205
- C: (f, a) => f(...a)
206
- });
207
- return true;
208
- },
209
- onDragEnter: ({ source }) => {
210
- log2("onDragEnter", {
211
- source: source.data
212
- }, {
213
- F: __dxlog_file2,
214
- L: 42,
215
- S: void 0,
216
- C: (f, a) => f(...a)
217
- });
218
- const piece = source.data.piece;
219
- if (!isPiece(piece)) {
220
- return;
221
- }
222
- if (model?.isValidMove({
223
- from: piece.location,
224
- to: location,
225
- piece: piece.type
226
- })) {
227
- setState("validMove");
228
- } else {
229
- setState("invalidMove");
230
- }
231
- },
232
- onDragLeave: () => setState("idle"),
233
- onDrop: () => setState("idle")
234
- });
235
- }, [
236
- model,
237
- location
238
- ]);
239
- return /* @__PURE__ */ React2.createElement("div", {
240
- ref,
241
- style: bounds,
242
- className: mx2("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
243
- }, label && /* @__PURE__ */ React2.createElement("div", {
244
- className: mx2("absolute bottom-1 left-1 text-xs text-neutral-500")
245
- }, label));
246
- } finally {
247
- _effect.f();
248
- }
158
+ const ref = useRef2(null);
159
+ const [state, setState] = useState2("idle");
160
+ const { model } = useGameboardContext(SQUARE_NAME);
161
+ useEffect2(() => {
162
+ const el = ref.current;
163
+ invariant2(el, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 18, S: void 0, A: ["el", ""] });
164
+ return dropTargetForElements({
165
+ element: el,
166
+ getData: () => ({
167
+ location
168
+ }),
169
+ canDrop: ({ source }) => {
170
+ log2("canDrop", {
171
+ source: source.data
172
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 25, S: void 0 });
173
+ return true;
174
+ },
175
+ onDragEnter: ({ source }) => {
176
+ log2("onDragEnter", {
177
+ source: source.data
178
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 31, S: void 0 });
179
+ const piece = source.data.piece;
180
+ if (!isPiece(piece)) {
181
+ return;
182
+ }
183
+ if (model?.isValidMove({
184
+ from: piece.location,
185
+ to: location,
186
+ piece: piece.type
187
+ })) {
188
+ setState("validMove");
189
+ } else {
190
+ setState("invalidMove");
191
+ }
192
+ },
193
+ onDragLeave: () => setState("idle"),
194
+ onDrop: () => setState("idle")
195
+ });
196
+ }, [
197
+ model,
198
+ location
199
+ ]);
200
+ return /* @__PURE__ */ React2.createElement("div", {
201
+ ref,
202
+ style: bounds,
203
+ className: mx2("absolute flex justify-center items-center border-2 box-border select-none", classNames, state === "validMove" ? "border-neutral-800" : "border-transparent")
204
+ }, label && /* @__PURE__ */ React2.createElement("div", {
205
+ className: mx2("absolute bottom-1 left-1 text-xs text-neutral-500")
206
+ }, label));
249
207
  });
250
- Square.displayName = "Square";
208
+ Square.displayName = SQUARE_NAME;
251
209
 
252
210
  // src/components/Gameboard/Gameboard.tsx
253
211
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Gameboard/Gameboard.tsx";
@@ -255,103 +213,77 @@ var [GameboardContextProvider, useRadixGameboardContext] = createContext("Gamebo
255
213
  var useGameboardContext = (consumerName) => {
256
214
  return useRadixGameboardContext(consumerName);
257
215
  };
258
- var GameboardRoot = ({ children, model, moveNumber, onDrop }) => {
259
- var _effect = _useSignals3();
260
- try {
261
- const [dragging, setDragging] = useState3(false);
262
- const [promoting, setPromoting] = useState3();
263
- const handlePromotion = useCallback((move) => {
264
- log3("onPromotion", {
265
- move
266
- }, {
267
- F: __dxlog_file3,
268
- L: 48,
269
- S: void 0,
270
- C: (f, a) => f(...a)
271
- });
272
- setPromoting(void 0);
273
- onDrop?.(move);
274
- }, []);
275
- useEffect3(() => {
276
- if (!model) {
277
- return;
278
- }
279
- return monitorForElements({
280
- onDragStart: ({ source }) => {
281
- log3("onDragStart", {
282
- source
283
- }, {
284
- F: __dxlog_file3,
285
- L: 61,
286
- S: void 0,
287
- C: (f, a) => f(...a)
288
- });
289
- setDragging(true);
290
- },
291
- onDrop: ({ source, location }) => {
292
- log3("onDrop", {
293
- source,
294
- location
295
- }, {
296
- F: __dxlog_file3,
297
- L: 65,
298
- S: void 0,
299
- C: (f, a) => f(...a)
300
- });
301
- const target = location.current.dropTargets[0];
302
- if (!target) {
303
- return;
304
- }
305
- const targetLocation = target.data.location;
306
- const piece = source.data.piece;
307
- if (!isLocation(targetLocation) || !isPiece(piece)) {
308
- return;
309
- }
310
- const move = {
311
- from: piece.location,
312
- to: targetLocation,
313
- piece: piece.type
314
- };
315
- if (model.isValidMove(move)) {
316
- if (model.canPromote?.(move)) {
317
- setPromoting({
318
- ...piece,
319
- location: targetLocation
320
- });
321
- } else {
322
- onDrop?.(move);
323
- }
216
+ var GameboardRoot = ({ children, model, onDrop }) => {
217
+ const [dragging, setDragging] = useState3(false);
218
+ const [promoting, setPromoting] = useState3();
219
+ const handlePromotion = useCallback((move) => {
220
+ log3("onPromotion", {
221
+ move
222
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 22, S: void 0 });
223
+ setPromoting(void 0);
224
+ onDrop?.(move);
225
+ }, []);
226
+ useEffect3(() => {
227
+ if (!model) {
228
+ return;
229
+ }
230
+ return monitorForElements({
231
+ onDragStart: ({ source }) => {
232
+ log3("onDragStart", {
233
+ source
234
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 35, S: void 0 });
235
+ setDragging(true);
236
+ },
237
+ onDrop: ({ source, location }) => {
238
+ log3("onDrop", {
239
+ source,
240
+ location
241
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 41, S: void 0 });
242
+ const target = location.current.dropTargets[0];
243
+ if (!target) {
244
+ return;
245
+ }
246
+ const targetLocation = target.data.location;
247
+ const piece = source.data.piece;
248
+ if (!isLocation(targetLocation) || !isPiece(piece)) {
249
+ return;
250
+ }
251
+ const move = {
252
+ from: piece.location,
253
+ to: targetLocation,
254
+ piece: piece.type
255
+ };
256
+ if (model.isValidMove(move)) {
257
+ if (model.canPromote?.(move)) {
258
+ setPromoting({
259
+ ...piece,
260
+ location: targetLocation
261
+ });
262
+ } else {
263
+ onDrop?.(move);
324
264
  }
325
- setDragging(false);
326
265
  }
327
- });
328
- }, [
329
- model
330
- ]);
331
- return /* @__PURE__ */ React3.createElement(GameboardContextProvider, {
332
- model,
333
- dragging,
334
- promoting,
335
- onPromotion: handlePromotion
336
- }, children);
337
- } finally {
338
- _effect.f();
339
- }
266
+ setDragging(false);
267
+ }
268
+ });
269
+ }, [
270
+ model
271
+ ]);
272
+ return /* @__PURE__ */ React3.createElement(GameboardContextProvider, {
273
+ model,
274
+ dragging,
275
+ promoting,
276
+ onPromotion: handlePromotion
277
+ }, children);
340
278
  };
341
279
  GameboardRoot.displayName = "Gameboard.Root";
342
280
  var GameboardContent = /* @__PURE__ */ forwardRef(({ children, classNames, grow, contain }, forwardedRef) => {
343
- var _effect = _useSignals3();
344
- try {
345
- return /* @__PURE__ */ React3.createElement("div", {
346
- role: "none",
347
- className: mx3(grow && "grid is-full bs-full size-container place-content-center", classNames),
348
- ref: forwardedRef
349
- }, contain ? /* @__PURE__ */ React3.createElement("div", {
350
- className: "is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]"
351
- }, children) : children);
352
- } finally {
353
- _effect.f();
354
- }
281
+ return /* @__PURE__ */ React3.createElement("div", {
282
+ className: mx3(grow && "dx-size-container dx-expander grid place-content-center", classNames),
283
+ ref: forwardedRef
284
+ }, contain ? /* @__PURE__ */ React3.createElement("div", {
285
+ className: "w-[min(100cqw,100cqh)] h-[min(100cqw,100cqh)]"
286
+ }, children) : children);
355
287
  });
356
288
  GameboardContent.displayName = "Gameboard.Content";
357
289
  var Gameboard = {
@@ -362,7 +294,7 @@ var Gameboard = {
362
294
  };
363
295
 
364
296
  // src/components/Chessboard/chess.ts
365
- import { signal } from "@preact/signals-core";
297
+ import { Atom } from "@effect-atom/atom-react";
366
298
  import { Chess as ChessJS } from "chess.js";
367
299
  import { invariant as invariant3 } from "@dxos/invariant";
368
300
  import { log as log4 } from "@dxos/log";
@@ -385,292 +317,183 @@ __export(alpha_exports, {
385
317
  });
386
318
 
387
319
  // src/gen/pieces/chess/alpha/bB.tsx
388
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
389
320
  import * as React4 from "react";
390
- var SvgBB = (props) => {
391
- var _effect = _useSignals4();
392
- try {
393
- return /* @__PURE__ */ React4.createElement("svg", {
394
- xmlns: "http://www.w3.org/2000/svg",
395
- viewBox: "0 0 2048 2048",
396
- ...props
397
- }, /* @__PURE__ */ React4.createElement("path", {
398
- fill: "#f9f9f9",
399
- d: "M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z"
400
- }), /* @__PURE__ */ React4.createElement("path", {
401
- fill: "#101010",
402
- 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"
403
- }));
404
- } finally {
405
- _effect.f();
406
- }
407
- };
321
+ var SvgBB = (props) => /* @__PURE__ */ React4.createElement("svg", {
322
+ xmlns: "http://www.w3.org/2000/svg",
323
+ viewBox: "0 0 2048 2048",
324
+ ...props
325
+ }, /* @__PURE__ */ React4.createElement("path", {
326
+ fill: "#f9f9f9",
327
+ d: "M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z"
328
+ }), /* @__PURE__ */ React4.createElement("path", {
329
+ fill: "#101010",
330
+ 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"
331
+ }));
408
332
  var bB_default = SvgBB;
409
333
 
410
334
  // src/gen/pieces/chess/alpha/bK.tsx
411
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
412
335
  import * as React5 from "react";
413
- var SvgBK = (props) => {
414
- var _effect = _useSignals5();
415
- try {
416
- return /* @__PURE__ */ React5.createElement("svg", {
417
- xmlns: "http://www.w3.org/2000/svg",
418
- viewBox: "0 0 2048 2048",
419
- ...props
420
- }, /* @__PURE__ */ React5.createElement("path", {
421
- fill: "#f9f9f9",
422
- 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"
423
- }), /* @__PURE__ */ React5.createElement("path", {
424
- fill: "#101010",
425
- 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"
426
- }));
427
- } finally {
428
- _effect.f();
429
- }
430
- };
336
+ var SvgBK = (props) => /* @__PURE__ */ React5.createElement("svg", {
337
+ xmlns: "http://www.w3.org/2000/svg",
338
+ viewBox: "0 0 2048 2048",
339
+ ...props
340
+ }, /* @__PURE__ */ React5.createElement("path", {
341
+ fill: "#f9f9f9",
342
+ 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"
343
+ }), /* @__PURE__ */ React5.createElement("path", {
344
+ fill: "#101010",
345
+ 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"
346
+ }));
431
347
  var bK_default = SvgBK;
432
348
 
433
349
  // src/gen/pieces/chess/alpha/bN.tsx
434
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
435
350
  import * as React6 from "react";
436
- var SvgBN = (props) => {
437
- var _effect = _useSignals6();
438
- try {
439
- return /* @__PURE__ */ React6.createElement("svg", {
440
- xmlns: "http://www.w3.org/2000/svg",
441
- viewBox: "0 0 2048 2048",
442
- ...props
443
- }, /* @__PURE__ */ React6.createElement("path", {
444
- fill: "#f9f9f9",
445
- 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"
446
- }), /* @__PURE__ */ React6.createElement("path", {
447
- fill: "#101010",
448
- 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"
449
- }));
450
- } finally {
451
- _effect.f();
452
- }
453
- };
351
+ var SvgBN = (props) => /* @__PURE__ */ React6.createElement("svg", {
352
+ xmlns: "http://www.w3.org/2000/svg",
353
+ viewBox: "0 0 2048 2048",
354
+ ...props
355
+ }, /* @__PURE__ */ React6.createElement("path", {
356
+ fill: "#f9f9f9",
357
+ 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"
358
+ }), /* @__PURE__ */ React6.createElement("path", {
359
+ fill: "#101010",
360
+ 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"
361
+ }));
454
362
  var bN_default = SvgBN;
455
363
 
456
364
  // src/gen/pieces/chess/alpha/bP.tsx
457
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
458
365
  import * as React7 from "react";
459
- var SvgBP = (props) => {
460
- var _effect = _useSignals7();
461
- try {
462
- return /* @__PURE__ */ React7.createElement("svg", {
463
- xmlns: "http://www.w3.org/2000/svg",
464
- viewBox: "0 0 2048 2048",
465
- ...props
466
- }, /* @__PURE__ */ React7.createElement("path", {
467
- fill: "#101010",
468
- 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"
469
- }));
470
- } finally {
471
- _effect.f();
472
- }
473
- };
366
+ var SvgBP = (props) => /* @__PURE__ */ React7.createElement("svg", {
367
+ xmlns: "http://www.w3.org/2000/svg",
368
+ viewBox: "0 0 2048 2048",
369
+ ...props
370
+ }, /* @__PURE__ */ React7.createElement("path", {
371
+ fill: "#101010",
372
+ 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"
373
+ }));
474
374
  var bP_default = SvgBP;
475
375
 
476
376
  // src/gen/pieces/chess/alpha/bQ.tsx
477
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
478
377
  import * as React8 from "react";
479
- var SvgBQ = (props) => {
480
- var _effect = _useSignals8();
481
- try {
482
- return /* @__PURE__ */ React8.createElement("svg", {
483
- xmlns: "http://www.w3.org/2000/svg",
484
- viewBox: "0 0 2048 2048",
485
- ...props
486
- }, /* @__PURE__ */ React8.createElement("path", {
487
- fill: "#f9f9f9",
488
- d: "m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z"
489
- }), /* @__PURE__ */ React8.createElement("path", {
490
- fill: "#101010",
491
- 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"
492
- }));
493
- } finally {
494
- _effect.f();
495
- }
496
- };
378
+ var SvgBQ = (props) => /* @__PURE__ */ React8.createElement("svg", {
379
+ xmlns: "http://www.w3.org/2000/svg",
380
+ viewBox: "0 0 2048 2048",
381
+ ...props
382
+ }, /* @__PURE__ */ React8.createElement("path", {
383
+ fill: "#f9f9f9",
384
+ d: "m520 1801.8 41.5-448.7 474-128.9 458 133.5 34.4 446.4z"
385
+ }), /* @__PURE__ */ React8.createElement("path", {
386
+ fill: "#101010",
387
+ 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"
388
+ }));
497
389
  var bQ_default = SvgBQ;
498
390
 
499
391
  // src/gen/pieces/chess/alpha/bR.tsx
500
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
501
392
  import * as React9 from "react";
502
- var SvgBR = (props) => {
503
- var _effect = _useSignals9();
504
- try {
505
- return /* @__PURE__ */ React9.createElement("svg", {
506
- xmlns: "http://www.w3.org/2000/svg",
507
- viewBox: "0 0 2048 2048",
508
- ...props
509
- }, /* @__PURE__ */ React9.createElement("path", {
510
- fill: "#f9f9f9",
511
- d: "m674 732-76 807 851 14-75-833z"
512
- }), /* @__PURE__ */ React9.createElement("path", {
513
- fill: "#101010",
514
- 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"
515
- }));
516
- } finally {
517
- _effect.f();
518
- }
519
- };
393
+ var SvgBR = (props) => /* @__PURE__ */ React9.createElement("svg", {
394
+ xmlns: "http://www.w3.org/2000/svg",
395
+ viewBox: "0 0 2048 2048",
396
+ ...props
397
+ }, /* @__PURE__ */ React9.createElement("path", {
398
+ fill: "#f9f9f9",
399
+ d: "m674 732-76 807 851 14-75-833z"
400
+ }), /* @__PURE__ */ React9.createElement("path", {
401
+ fill: "#101010",
402
+ 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"
403
+ }));
520
404
  var bR_default = SvgBR;
521
405
 
522
406
  // src/gen/pieces/chess/alpha/wB.tsx
523
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
524
407
  import * as React10 from "react";
525
- var SvgWB = (props) => {
526
- var _effect = _useSignals10();
527
- try {
528
- return /* @__PURE__ */ React10.createElement("svg", {
529
- xmlns: "http://www.w3.org/2000/svg",
530
- viewBox: "0 0 2048 2048",
531
- ...props
532
- }, /* @__PURE__ */ React10.createElement("path", {
533
- fill: "#f9f9f9",
534
- 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"
535
- }), /* @__PURE__ */ React10.createElement("path", {
536
- fill: "#101010",
537
- 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"
538
- }));
539
- } finally {
540
- _effect.f();
541
- }
542
- };
408
+ var SvgWB = (props) => /* @__PURE__ */ React10.createElement("svg", {
409
+ xmlns: "http://www.w3.org/2000/svg",
410
+ viewBox: "0 0 2048 2048",
411
+ ...props
412
+ }, /* @__PURE__ */ React10.createElement("path", {
413
+ fill: "#f9f9f9",
414
+ 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"
415
+ }), /* @__PURE__ */ React10.createElement("path", {
416
+ fill: "#101010",
417
+ 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"
418
+ }));
543
419
  var wB_default = SvgWB;
544
420
 
545
421
  // src/gen/pieces/chess/alpha/wK.tsx
546
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
547
422
  import * as React11 from "react";
548
- var SvgWK = (props) => {
549
- var _effect = _useSignals11();
550
- try {
551
- return /* @__PURE__ */ React11.createElement("svg", {
552
- xmlns: "http://www.w3.org/2000/svg",
553
- viewBox: "0 0 2048 2048",
554
- ...props
555
- }, /* @__PURE__ */ React11.createElement("path", {
556
- fill: "#f9f9f9",
557
- 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"
558
- }), /* @__PURE__ */ React11.createElement("path", {
559
- fill: "#101010",
560
- 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"
561
- }));
562
- } finally {
563
- _effect.f();
564
- }
565
- };
423
+ var SvgWK = (props) => /* @__PURE__ */ React11.createElement("svg", {
424
+ xmlns: "http://www.w3.org/2000/svg",
425
+ viewBox: "0 0 2048 2048",
426
+ ...props
427
+ }, /* @__PURE__ */ React11.createElement("path", {
428
+ fill: "#f9f9f9",
429
+ 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"
430
+ }), /* @__PURE__ */ React11.createElement("path", {
431
+ fill: "#101010",
432
+ 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"
433
+ }));
566
434
  var wK_default = SvgWK;
567
435
 
568
436
  // src/gen/pieces/chess/alpha/wN.tsx
569
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
570
437
  import * as React12 from "react";
571
- var SvgWN = (props) => {
572
- var _effect = _useSignals12();
573
- try {
574
- return /* @__PURE__ */ React12.createElement("svg", {
575
- xmlns: "http://www.w3.org/2000/svg",
576
- viewBox: "0 0 2048 2048",
577
- ...props
578
- }, /* @__PURE__ */ React12.createElement("path", {
579
- fill: "#f9f9f9",
580
- 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"
581
- }), /* @__PURE__ */ React12.createElement("path", {
582
- fill: "#101010",
583
- 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"
584
- }));
585
- } finally {
586
- _effect.f();
587
- }
588
- };
438
+ var SvgWN = (props) => /* @__PURE__ */ React12.createElement("svg", {
439
+ xmlns: "http://www.w3.org/2000/svg",
440
+ viewBox: "0 0 2048 2048",
441
+ ...props
442
+ }, /* @__PURE__ */ React12.createElement("path", {
443
+ fill: "#f9f9f9",
444
+ 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"
445
+ }), /* @__PURE__ */ React12.createElement("path", {
446
+ fill: "#101010",
447
+ 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"
448
+ }));
589
449
  var wN_default = SvgWN;
590
450
 
591
451
  // src/gen/pieces/chess/alpha/wP.tsx
592
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
593
452
  import * as React13 from "react";
594
- var SvgWP = (props) => {
595
- var _effect = _useSignals13();
596
- try {
597
- return /* @__PURE__ */ React13.createElement("svg", {
598
- xmlns: "http://www.w3.org/2000/svg",
599
- viewBox: "0 0 2048 2048",
600
- ...props
601
- }, /* @__PURE__ */ React13.createElement("path", {
602
- fill: "#f9f9f9",
603
- 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"
604
- }), /* @__PURE__ */ React13.createElement("path", {
605
- fill: "#101010",
606
- 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"
607
- }));
608
- } finally {
609
- _effect.f();
610
- }
611
- };
453
+ var SvgWP = (props) => /* @__PURE__ */ React13.createElement("svg", {
454
+ xmlns: "http://www.w3.org/2000/svg",
455
+ viewBox: "0 0 2048 2048",
456
+ ...props
457
+ }, /* @__PURE__ */ React13.createElement("path", {
458
+ fill: "#f9f9f9",
459
+ 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"
460
+ }), /* @__PURE__ */ React13.createElement("path", {
461
+ fill: "#101010",
462
+ 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"
463
+ }));
612
464
  var wP_default = SvgWP;
613
465
 
614
466
  // src/gen/pieces/chess/alpha/wQ.tsx
615
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
616
467
  import * as React14 from "react";
617
- var SvgWQ = (props) => {
618
- var _effect = _useSignals14();
619
- try {
620
- return /* @__PURE__ */ React14.createElement("svg", {
621
- xmlns: "http://www.w3.org/2000/svg",
622
- viewBox: "0 0 2048 2048",
623
- ...props
624
- }, /* @__PURE__ */ React14.createElement("path", {
625
- fill: "#f9f9f9",
626
- 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"
627
- }), /* @__PURE__ */ React14.createElement("path", {
628
- fill: "#101010",
629
- 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"
630
- }));
631
- } finally {
632
- _effect.f();
633
- }
634
- };
468
+ var SvgWQ = (props) => /* @__PURE__ */ React14.createElement("svg", {
469
+ xmlns: "http://www.w3.org/2000/svg",
470
+ viewBox: "0 0 2048 2048",
471
+ ...props
472
+ }, /* @__PURE__ */ React14.createElement("path", {
473
+ fill: "#f9f9f9",
474
+ 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"
475
+ }), /* @__PURE__ */ React14.createElement("path", {
476
+ fill: "#101010",
477
+ 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"
478
+ }));
635
479
  var wQ_default = SvgWQ;
636
480
 
637
481
  // src/gen/pieces/chess/alpha/wR.tsx
638
- import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
639
482
  import * as React15 from "react";
640
- var SvgWR = (props) => {
641
- var _effect = _useSignals15();
642
- try {
643
- return /* @__PURE__ */ React15.createElement("svg", {
644
- xmlns: "http://www.w3.org/2000/svg",
645
- viewBox: "0 0 2048 2048",
646
- ...props
647
- }, /* @__PURE__ */ React15.createElement("path", {
648
- fill: "#f9f9f9",
649
- 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"
650
- }), /* @__PURE__ */ React15.createElement("path", {
651
- fill: "#101010",
652
- 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"
653
- }));
654
- } finally {
655
- _effect.f();
656
- }
657
- };
483
+ var SvgWR = (props) => /* @__PURE__ */ React15.createElement("svg", {
484
+ xmlns: "http://www.w3.org/2000/svg",
485
+ viewBox: "0 0 2048 2048",
486
+ ...props
487
+ }, /* @__PURE__ */ React15.createElement("path", {
488
+ fill: "#f9f9f9",
489
+ 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"
490
+ }), /* @__PURE__ */ React15.createElement("path", {
491
+ fill: "#101010",
492
+ 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"
493
+ }));
658
494
  var wR_default = SvgWR;
659
495
 
660
496
  // src/components/Chessboard/chess.ts
661
- function _define_property(obj, key, value) {
662
- if (key in obj) {
663
- Object.defineProperty(obj, key, {
664
- value,
665
- enumerable: true,
666
- configurable: true,
667
- writable: true
668
- });
669
- } else {
670
- obj[key] = value;
671
- }
672
- return obj;
673
- }
674
497
  var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-gameboard/src/components/Chessboard/chess.ts";
675
498
  var ChessPieces = alpha_exports;
676
499
  var posToLocation = (pos) => {
@@ -719,19 +542,22 @@ var createChess = (pgn) => {
719
542
  try {
720
543
  chess.loadPgn(pgn);
721
544
  } catch {
722
- log4.warn(pgn, void 0, {
723
- F: __dxlog_file4,
724
- L: 76,
725
- S: void 0,
726
- C: (f, a) => f(...a)
727
- });
545
+ log4.warn(pgn, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 57, S: void 0 });
728
546
  }
729
547
  }
730
548
  return chess;
731
549
  };
732
550
  var ChessModel = class {
551
+ _registry;
552
+ _chess = new ChessJS();
553
+ _pieces = Atom.make({});
554
+ _moveIndex = Atom.make(0);
555
+ constructor(_registry, pgn) {
556
+ this._registry = _registry;
557
+ this.update(pgn);
558
+ }
733
559
  get readonly() {
734
- return this._moveIndex.value !== this._chess.history().length;
560
+ return this._registry.get(this._moveIndex) !== this._chess.history().length;
735
561
  }
736
562
  get turn() {
737
563
  return this._chess.turn() === "w" ? "white" : "black";
@@ -783,7 +609,7 @@ var ChessModel = class {
783
609
  }
784
610
  const current = this._chess.history();
785
611
  if (!isValidNextMove(previous, current)) {
786
- this._pieces.value = {};
612
+ this._registry.set(this._pieces, {});
787
613
  }
788
614
  this._updateBoard(this._chess);
789
615
  }
@@ -817,14 +643,8 @@ var ChessModel = class {
817
643
  * Update pieces preserving identity.
818
644
  */
819
645
  _updateBoard(chess) {
820
- this._pieces.value = createPieceMap(chess);
821
- this._moveIndex.value = chess.history().length;
822
- }
823
- constructor(pgn) {
824
- _define_property(this, "_chess", new ChessJS());
825
- _define_property(this, "_pieces", signal({}));
826
- _define_property(this, "_moveIndex", signal(0));
827
- this.update(pgn);
646
+ this._registry.set(this._pieces, createPieceMap(chess));
647
+ this._registry.set(this._moveIndex, chess.history().length);
828
648
  }
829
649
  };
830
650
  var tryMove = (chess, move) => {
@@ -867,15 +687,7 @@ var createPieceMap = (chess) => {
867
687
  pieces = _diffPieces(pieces, _createPieceMap(temp));
868
688
  const test = /* @__PURE__ */ new Set();
869
689
  Object.values(pieces).forEach((piece) => {
870
- invariant3(!test.has(piece.id), "Duplicate: " + piece.id, {
871
- F: __dxlog_file4,
872
- L: 252,
873
- S: void 0,
874
- A: [
875
- "!test.has(piece.id)",
876
- "'Duplicate: ' + piece.id"
877
- ]
878
- });
690
+ invariant3(!test.has(piece.id), "Duplicate: " + piece.id, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 213, S: void 0, A: ["!test.has(piece.id)", "'Duplicate: ' + piece.id"] });
879
691
  test.add(piece.id);
880
692
  });
881
693
  }
@@ -927,160 +739,153 @@ var _diffPieces = (before, after) => {
927
739
  var createDate = (date = /* @__PURE__ */ new Date()) => date.toISOString().slice(0, 10).replace(/-/g, ".");
928
740
 
929
741
  // src/components/Chessboard/Chessboard.tsx
930
- import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
742
+ import { Atom as Atom2, useAtomValue } from "@effect-atom/atom-react";
931
743
  import React16, { forwardRef as forwardRef2, memo as memo3, useEffect as useEffect4, useMemo, useRef as useRef3, useState as useState4 } from "react";
932
744
  import { useResizeDetector } from "react-resize-detector";
933
745
  import { useForwardedRef } from "@dxos/react-ui";
934
- import { mx as mx4 } from "@dxos/react-ui-theme";
746
+ import { mx as mx4 } from "@dxos/ui-theme";
935
747
  import { isNonNullable } from "@dxos/util";
748
+ var EMPTY_PIECES_ATOM = Atom2.make({});
749
+ var CHESSBOARD_NAME = "Chessboard";
936
750
  var ChessboardComponent = /* @__PURE__ */ forwardRef2(({ classNames, orientation, showLabels, debug, rows = 8, cols = 8 }, forwardedRef) => {
937
- var _effect = _useSignals16();
938
- try {
939
- const targetRef = useForwardedRef(forwardedRef);
940
- const { width, height } = useResizeDetector({
941
- targetRef,
942
- refreshRate: 200
943
- });
944
- const { model, promoting, onPromotion } = useGameboardContext(Chessboard.displayName);
945
- const squares = useMemo(() => {
946
- return Array.from({
947
- length: rows
948
- }, (_, i) => orientation === "black" ? i : rows - 1 - i).flatMap((row) => Array.from({
949
- length: cols
950
- }).map((_, col) => [
951
- row,
952
- col
953
- ]));
954
- }, [
955
- orientation,
956
- rows,
957
- cols
958
- ]);
959
- const layout = useMemo(() => {
960
- return squares.map((location) => {
961
- return /* @__PURE__ */ React16.createElement("div", {
962
- key: locationToString(location),
963
- ["data-location"]: locationToString(location)
964
- });
751
+ const targetRef = useForwardedRef(forwardedRef);
752
+ const { width, height } = useResizeDetector({
753
+ targetRef,
754
+ refreshRate: 200
755
+ });
756
+ const { model, promoting, onPromotion } = useGameboardContext(CHESSBOARD_NAME);
757
+ const pieces = useAtomValue(model?.pieces ?? EMPTY_PIECES_ATOM);
758
+ const squares = useMemo(() => {
759
+ return Array.from({
760
+ length: rows
761
+ }, (_, i) => orientation === "black" ? i : rows - 1 - i).flatMap((row) => Array.from({
762
+ length: cols
763
+ }).map((_, col) => [
764
+ row,
765
+ col
766
+ ]));
767
+ }, [
768
+ orientation,
769
+ rows,
770
+ cols
771
+ ]);
772
+ const layout = useMemo(() => {
773
+ return squares.map((location) => {
774
+ return /* @__PURE__ */ React16.createElement("div", {
775
+ key: locationToString(location),
776
+ "data-location": locationToString(location)
965
777
  });
966
- }, [
967
- squares
968
- ]);
969
- const [grid, setGrid] = useState4({});
970
- const gridRef = useRef3(null);
971
- useEffect4(() => {
972
- setGrid(squares.reduce((acc, location) => {
973
- const square = getSquareLocation(gridRef.current, location);
974
- const bounds = getRelativeBounds(gridRef.current, square);
975
- return {
976
- ...acc,
977
- [locationToString(location)]: bounds
978
- };
979
- }, {}));
980
- }, [
981
- squares,
982
- width,
983
- height
984
- ]);
985
- const positions = useMemo(() => {
986
- if (!gridRef.current) {
987
- return [];
988
- }
989
- return Object.values(model?.pieces.value ?? {}).map((piece) => {
990
- if (piece.id === promoting?.id) {
991
- return null;
992
- }
993
- const bounds = grid[locationToString(piece.location)];
994
- return {
995
- piece,
996
- bounds
997
- };
998
- }).filter(isNonNullable);
999
- }, [
1000
- grid,
1001
- model?.pieces.value,
1002
- promoting
1003
- ]);
1004
- return /* @__PURE__ */ React16.createElement("div", {
1005
- ref: targetRef,
1006
- tabIndex: 0,
1007
- className: mx4("relative outline-none", classNames)
1008
- }, /* @__PURE__ */ React16.createElement("div", {
1009
- ref: gridRef,
1010
- className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
1011
- }, layout), /* @__PURE__ */ React16.createElement("div", null, squares.map((location) => /* @__PURE__ */ React16.createElement(Gameboard.Square, {
1012
- key: locationToString(location),
1013
- location,
1014
- label: showLabels ? locationToPos(location) : void 0,
1015
- bounds: grid[locationToString(location)],
1016
- classNames: getSquareColor(location)
1017
- }))), /* @__PURE__ */ React16.createElement("div", {
1018
- className: mx4(promoting && "opacity-50")
1019
- }, positions.map(({ bounds, piece }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
1020
- key: piece.id,
1021
- piece,
1022
- bounds,
1023
- label: debug ? piece.id : void 0,
1024
- orientation,
1025
- Component: ChessPieces[piece.type]
1026
- }))), promoting && /* @__PURE__ */ React16.createElement(PromotionSelector, {
1027
- grid,
1028
- piece: promoting,
1029
- onSelect: (piece) => {
1030
- onPromotion({
1031
- from: Object.values(model.pieces.value).find((p) => p.id === promoting.id).location,
1032
- to: piece.location,
1033
- piece: promoting.type,
1034
- promotion: piece.type
1035
- });
778
+ });
779
+ }, [
780
+ squares
781
+ ]);
782
+ const [grid, setGrid] = useState4({});
783
+ const gridRef = useRef3(null);
784
+ useEffect4(() => {
785
+ setGrid(squares.reduce((acc, location) => {
786
+ const square = getSquareLocation(gridRef.current, location);
787
+ const bounds = getRelativeBounds(gridRef.current, square);
788
+ return {
789
+ ...acc,
790
+ [locationToString(location)]: bounds
791
+ };
792
+ }, {}));
793
+ }, [
794
+ squares,
795
+ width,
796
+ height
797
+ ]);
798
+ const positions = useMemo(() => {
799
+ if (!gridRef.current) {
800
+ return [];
801
+ }
802
+ return Object.values(pieces).map((piece) => {
803
+ if (piece.id === promoting?.id) {
804
+ return null;
1036
805
  }
1037
- }));
1038
- } finally {
1039
- _effect.f();
1040
- }
1041
- });
1042
- ChessboardComponent.displayName = "Chessboard";
1043
- var Chessboard = /* @__PURE__ */ memo3(ChessboardComponent);
1044
- var PromotionSelector = ({ grid, piece, onSelect }) => {
1045
- var _effect = _useSignals16();
1046
- try {
1047
- const positions = [
1048
- "Q",
1049
- "N",
1050
- "R",
1051
- "B"
1052
- ].map((pieceType, i) => {
1053
- const location = [
1054
- piece.location[0] + (piece.location[0] === 0 ? i : -i),
1055
- piece.location[1]
1056
- ];
806
+ const bounds = grid[locationToString(piece.location)];
1057
807
  return {
1058
- piece: {
1059
- id: `promotion-${pieceType}`,
1060
- type: (piece.side === "black" ? "B" : "W") + pieceType,
1061
- side: piece.side,
1062
- location
1063
- },
1064
- bounds: grid[locationToString(location)]
808
+ piece,
809
+ bounds
1065
810
  };
1066
- });
1067
- const handleSelect = (selected) => {
1068
- onSelect({
1069
- ...piece,
1070
- type: selected.type
811
+ }).filter(isNonNullable);
812
+ }, [
813
+ grid,
814
+ pieces,
815
+ promoting
816
+ ]);
817
+ return /* @__PURE__ */ React16.createElement("div", {
818
+ ref: targetRef,
819
+ tabIndex: 0,
820
+ className: mx4("dx-expander relative outline-hidden", classNames)
821
+ }, /* @__PURE__ */ React16.createElement("div", {
822
+ ref: gridRef,
823
+ className: "grid grid-rows-8 grid-cols-8 aspect-square select-none"
824
+ }, layout), /* @__PURE__ */ React16.createElement("div", null, squares.map((location) => /* @__PURE__ */ React16.createElement(Gameboard.Square, {
825
+ key: locationToString(location),
826
+ location,
827
+ label: showLabels ? locationToPos(location) : void 0,
828
+ bounds: grid[locationToString(location)],
829
+ classNames: getSquareColor(location)
830
+ }))), /* @__PURE__ */ React16.createElement("div", {
831
+ className: mx4(promoting && "opacity-50")
832
+ }, positions.map(({ bounds, piece }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
833
+ key: piece.id,
834
+ piece,
835
+ bounds,
836
+ label: debug ? piece.id : void 0,
837
+ orientation,
838
+ Component: ChessPieces[piece.type]
839
+ }))), promoting && /* @__PURE__ */ React16.createElement(PromotionSelector, {
840
+ grid,
841
+ piece: promoting,
842
+ onSelect: (piece) => {
843
+ onPromotion({
844
+ from: Object.values(pieces).find((p) => p.id === promoting.id).location,
845
+ to: piece.location,
846
+ piece: promoting.type,
847
+ promotion: piece.type
1071
848
  });
849
+ }
850
+ }));
851
+ });
852
+ ChessboardComponent.displayName = CHESSBOARD_NAME;
853
+ var Chessboard = /* @__PURE__ */ memo3(ChessboardComponent);
854
+ var PromotionSelector = ({ grid, piece, onSelect }) => {
855
+ const positions = [
856
+ "Q",
857
+ "N",
858
+ "R",
859
+ "B"
860
+ ].map((pieceType, i) => {
861
+ const location = [
862
+ piece.location[0] + (piece.location[0] === 0 ? i : -i),
863
+ piece.location[1]
864
+ ];
865
+ return {
866
+ piece: {
867
+ id: `promotion-${pieceType}`,
868
+ type: (piece.side === "black" ? "B" : "W") + pieceType,
869
+ side: piece.side,
870
+ location
871
+ },
872
+ bounds: grid[locationToString(location)]
1072
873
  };
1073
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, positions.map(({ piece: piece2, bounds }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
1074
- key: piece2.id,
1075
- classNames: mx4("border-2 border-neutral-700 rounded-full", boardStyles.promotion),
1076
- piece: piece2,
1077
- bounds,
1078
- Component: ChessPieces[piece2.type],
1079
- onClick: () => handleSelect(piece2)
1080
- })));
1081
- } finally {
1082
- _effect.f();
1083
- }
874
+ });
875
+ const handleSelect = (selected) => {
876
+ onSelect({
877
+ ...piece,
878
+ type: selected.type
879
+ });
880
+ };
881
+ return /* @__PURE__ */ React16.createElement(React16.Fragment, null, positions.map(({ piece: piece2, bounds }) => /* @__PURE__ */ React16.createElement(Gameboard.Piece, {
882
+ key: piece2.id,
883
+ classNames: mx4("border-2 border-neutral-700 rounded-full", boardStyles.promotion),
884
+ piece: piece2,
885
+ bounds,
886
+ Component: ChessPieces[piece2.type],
887
+ onClick: () => handleSelect(piece2)
888
+ })));
1084
889
  };
1085
890
  var getSquareLocation = (container, location) => {
1086
891
  return container.querySelector(`[data-location="${locationToString(location)}"]`);