@johnmorrisdotca/sugoroku 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/element.js CHANGED
@@ -1,23 +1,7 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _SugorokuFrame_widthBefore, _SugorokuFrame_widthOwned, _SugorokuFrame_labelBefore, _SugorokuBoard_instances, _SugorokuBoard_mount, _SugorokuBoard_key, _SugorokuBoard_queued, _SugorokuBoard_options, _SugorokuBoard_side, _SugorokuBoard_look, _SugorokuBoard_refresh, _SugorokuPosition_instances, _SugorokuPosition_value, _SugorokuPosition_options, _SugorokuPosition_resize, _SugorokuPosition_render;
13
- import { drawSugoroku } from "./draw.js";
14
- import { startPosition } from "./board.js";
15
- import { positionFromId } from "./positionId.js";
16
- import { VARIANTS } from "./variants.js";
1
+ import { SUGOROKU_BOARD_NAMES, SUGOROKU_CHECKER_SET_NAMES, } from "./colours.js";
17
2
  import { STRENGTHS } from "./computer.js";
18
- import { SUGOROKU_BOARD_NAMES, SUGOROKU_CHECKER_SET_NAMES } from "./colours.js";
3
+ import { GAME_ATTRIBUTES, isOn, oneOf, SugorokuFrame } from "./elementFrame.js";
19
4
  import { mountSugoroku } from "./mount.js";
20
- import { SUGOROKU_STYLE } from "./style.js";
21
5
  import { isVariantKey } from "./variants.js";
22
6
  /**
23
7
  * THE `<sugoroku-board>` ELEMENT: a playable backgammon board in a tag, with no
@@ -47,75 +31,6 @@ import { isVariantKey } from "./variants.js";
47
31
  * `nextGame`, `newMatch`, `record`) and the properties `game` and `match`. Nothing in it can be selected, and its box stays
48
32
  * one steady shape whatever is on the board.
49
33
  */
50
- const ElementBase = typeof HTMLElement === "undefined" ? class {
51
- } : HTMLElement;
52
- const isOn = (value, fallback = false) => value === null ? fallback : !["false", "off", "0", "no"].includes(value.trim().toLowerCase());
53
- const oneOf = (value, allowed) => (allowed.includes(value) ? value : undefined);
54
- /** The attributes that name the game: changing one starts a new match. */
55
- const GAME_ATTRIBUTES = ["variant", "preset", "points", "cube", "crawford", "jacoby", "beaver", "gammons", "seed", "dice", "controls", "drag", "auto-end", "sound", "computer-delay"];
56
- class SugorokuFrame extends ElementBase {
57
- constructor() {
58
- super(...arguments);
59
- _SugorokuFrame_widthBefore.set(this, null);
60
- _SugorokuFrame_widthOwned.set(this, false);
61
- _SugorokuFrame_labelBefore.set(this, null);
62
- }
63
- frame() {
64
- this.style.display = "block";
65
- this.style.maxWidth = "100%";
66
- const width = Number(this.getAttribute("width")), size = this.getAttribute("size");
67
- const pixels = this.hasAttribute("width") && width > 0 && Number.isFinite(width) ? Math.min(width, 2000) : size === "small" ? 320 : size === "medium" ? 480 : size === "large" ? 640 : null;
68
- if (pixels !== null) {
69
- if (!__classPrivateFieldGet(this, _SugorokuFrame_widthOwned, "f"))
70
- __classPrivateFieldSet(this, _SugorokuFrame_widthBefore, this.style.width, "f");
71
- __classPrivateFieldSet(this, _SugorokuFrame_widthOwned, true, "f");
72
- this.style.width = `${pixels}px`;
73
- }
74
- else if (__classPrivateFieldGet(this, _SugorokuFrame_widthOwned, "f")) {
75
- this.style.width = __classPrivateFieldGet(this, _SugorokuFrame_widthBefore, "f") ?? "";
76
- __classPrivateFieldSet(this, _SugorokuFrame_widthOwned, false, "f");
77
- }
78
- const theme = this.getAttribute("theme");
79
- this.style.colorScheme = theme === "light" || theme === "dark" ? theme : "light dark";
80
- this.setAttribute("data-sugoroku-embed", "");
81
- const root = this.getRootNode(), target = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : this.ownerDocument.head;
82
- if (target.querySelector("style[data-sugoroku-embed-style]") === null) {
83
- const style = this.ownerDocument.createElement("style");
84
- style.setAttribute("data-sugoroku-embed-style", "");
85
- const palette = SUGOROKU_STYLE.match(/\.sugoroku\[data-theme="dark"\] \{([^}]+)\}/)?.[1] ?? "";
86
- style.textContent = `@media(prefers-color-scheme:dark){[data-sugoroku-embed] .sugoroku:not([data-theme="light"]){${palette}}}`;
87
- target.append(style);
88
- }
89
- if (this.hasAttribute("label")) {
90
- __classPrivateFieldSet(this, _SugorokuFrame_labelBefore, __classPrivateFieldGet(this, _SugorokuFrame_labelBefore, "f") ?? { role: this.getAttribute("role"), label: this.getAttribute("aria-label") }, "f");
91
- this.setAttribute("role", "group");
92
- this.setAttribute("aria-label", this.getAttribute("label"));
93
- }
94
- else if (__classPrivateFieldGet(this, _SugorokuFrame_labelBefore, "f") !== null) {
95
- for (const [name, value] of [["role", __classPrivateFieldGet(this, _SugorokuFrame_labelBefore, "f").role], ["aria-label", __classPrivateFieldGet(this, _SugorokuFrame_labelBefore, "f").label]]) {
96
- if (value === null)
97
- this.removeAttribute(name);
98
- else
99
- this.setAttribute(name, value);
100
- }
101
- __classPrivateFieldSet(this, _SugorokuFrame_labelBefore, null, "f");
102
- }
103
- }
104
- write(name, value) { if (value === null || value === undefined)
105
- this.removeAttribute(name);
106
- else
107
- this.setAttribute(name, String(value)); }
108
- /** Symbolic display size, reflected. */
109
- get size() { return this.getAttribute("size"); }
110
- set size(value) { this.write("size", value); }
111
- /** Pixel display width, reflected. */
112
- get width() { return this.getAttribute("width"); }
113
- set width(value) { this.write("width", value); }
114
- /** Spoken group label, reflected. */
115
- get label() { return this.getAttribute("label"); }
116
- set label(value) { this.write("label", value); }
117
- }
118
- _SugorokuFrame_widthBefore = new WeakMap(), _SugorokuFrame_widthOwned = new WeakMap(), _SugorokuFrame_labelBefore = new WeakMap();
119
34
  /** The real mounted options, checked alongside builder coverage.
120
35
  * @example
121
36
  * ```ts
@@ -123,7 +38,35 @@ _SugorokuFrame_widthBefore = new WeakMap(), _SugorokuFrame_widthOwned = new Weak
123
38
  * console.log(typeof SUGOROKU_EMBED_OPTION_KEYS); // object
124
39
  * ```
125
40
  */
126
- export const SUGOROKU_EMBED_OPTION_KEYS = Object.keys({ board: true, checkers: true, colours: true, theme: true, home: true, view: true, numbers: true, orientation: true, variant: true, rules: true, preset: true, seed: true, dice: true, computer: true, computerDelay: true, controls: true, drag: true, autoEnd: true, language: true, names: true, sound: true, match: true, onRoll: true, onMove: true, onTurn: true, onCube: true, onEnd: true });
41
+ export const SUGOROKU_EMBED_OPTION_KEYS = Object.keys({
42
+ board: true,
43
+ checkers: true,
44
+ colours: true,
45
+ theme: true,
46
+ home: true,
47
+ view: true,
48
+ numbers: true,
49
+ orientation: true,
50
+ variant: true,
51
+ rules: true,
52
+ preset: true,
53
+ seed: true,
54
+ dice: true,
55
+ computer: true,
56
+ computerDelay: true,
57
+ controls: true,
58
+ drag: true,
59
+ autoEnd: true,
60
+ language: true,
61
+ names: true,
62
+ sound: true,
63
+ match: true,
64
+ onRoll: true,
65
+ onMove: true,
66
+ onTurn: true,
67
+ onCube: true,
68
+ onEnd: true,
69
+ });
127
70
  /** Native custom element with reflected setup and presentation.
128
71
  * @example
129
72
  * ```ts
@@ -132,225 +75,362 @@ export const SUGOROKU_EMBED_OPTION_KEYS = Object.keys({ board: true, checkers: t
132
75
  * ```
133
76
  */
134
77
  export class SugorokuBoard extends SugorokuFrame {
135
- constructor() {
136
- super(...arguments);
137
- _SugorokuBoard_instances.add(this);
138
- _SugorokuBoard_mount.set(this, null);
139
- _SugorokuBoard_key.set(this, "");
140
- _SugorokuBoard_queued.set(this, false);
141
- _SugorokuBoard_options.set(this, {});
142
- }
78
+ static observedAttributes = [
79
+ ...GAME_ATTRIBUTES,
80
+ "white",
81
+ "black",
82
+ "board",
83
+ "checkers",
84
+ "theme",
85
+ "home",
86
+ "view",
87
+ "numbers",
88
+ "orientation",
89
+ "lang",
90
+ "size",
91
+ "width",
92
+ "label",
93
+ ];
94
+ #mount = null;
95
+ #key = "";
96
+ #queued = false;
97
+ #options = {};
143
98
  /** Host mount options; callback and look changes preserve the current game. */
144
- get options() { return __classPrivateFieldGet(this, _SugorokuBoard_options, "f"); }
145
- set options(value) { __classPrivateFieldSet(this, _SugorokuBoard_options, value ?? {}, "f"); if (this.isConnected)
146
- __classPrivateFieldGet(this, _SugorokuBoard_instances, "m", _SugorokuBoard_refresh).call(this); }
99
+ get options() {
100
+ return this.#options;
101
+ }
102
+ set options(value) {
103
+ this.#options = value ?? {};
104
+ if (this.isConnected)
105
+ this.#refresh();
106
+ }
147
107
  connectedCallback() {
148
- __classPrivateFieldGet(this, _SugorokuBoard_instances, "m", _SugorokuBoard_refresh).call(this);
108
+ this.#refresh();
149
109
  }
150
110
  disconnectedCallback() {
151
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.destroy();
152
- __classPrivateFieldSet(this, _SugorokuBoard_mount, null, "f");
153
- __classPrivateFieldSet(this, _SugorokuBoard_key, "", "f");
111
+ this.#mount?.destroy();
112
+ this.#mount = null;
113
+ this.#key = "";
154
114
  }
155
115
  attributeChangedCallback() {
156
- if (!this.isConnected || __classPrivateFieldGet(this, _SugorokuBoard_queued, "f"))
116
+ if (!this.isConnected || this.#queued)
157
117
  return;
158
- __classPrivateFieldSet(this, _SugorokuBoard_queued, true, "f");
118
+ this.#queued = true;
159
119
  queueMicrotask(() => {
160
- __classPrivateFieldSet(this, _SugorokuBoard_queued, false, "f");
120
+ this.#queued = false;
161
121
  if (this.isConnected)
162
- __classPrivateFieldGet(this, _SugorokuBoard_instances, "m", _SugorokuBoard_refresh).call(this);
122
+ this.#refresh();
163
123
  });
164
124
  }
165
125
  /** The mounted board's handle (`mountSugoroku`), or null while it is not on a page. */
166
126
  get mount() {
167
- return __classPrivateFieldGet(this, _SugorokuBoard_mount, "f");
127
+ return this.#mount;
168
128
  }
169
129
  get game() {
170
- return __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.game() ?? null;
130
+ return this.#mount?.game() ?? null;
171
131
  }
172
132
  get match() {
173
- return __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.match() ?? null;
133
+ return this.#mount?.match() ?? null;
174
134
  }
175
135
  record() {
176
- return __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.record() ?? "";
136
+ return this.#mount?.record() ?? "";
177
137
  }
178
138
  roll(dice) {
179
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.roll(dice);
139
+ this.#mount?.roll(dice);
180
140
  }
181
141
  move(from, to) {
182
- return __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.move(from, to) ?? false;
142
+ return this.#mount?.move(from, to) ?? false;
183
143
  }
184
144
  undo() {
185
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.undo();
145
+ this.#mount?.undo();
186
146
  }
187
147
  done() {
188
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.done();
148
+ this.#mount?.done();
189
149
  }
190
150
  double() {
191
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.double();
151
+ this.#mount?.double();
192
152
  }
193
153
  take() {
194
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.take();
154
+ this.#mount?.take();
195
155
  }
196
156
  drop() {
197
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.drop();
157
+ this.#mount?.drop();
198
158
  }
199
159
  /** Calling beaver() keeps the native action; assignment reflects the rule attribute. */
200
- get beaver() { return () => __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.beaver(); }
201
- set beaver(value) { if (typeof value !== "function")
202
- this.write("beaver", value); }
160
+ get beaver() {
161
+ return () => this.#mount?.beaver();
162
+ }
163
+ set beaver(value) {
164
+ if (typeof value !== "function")
165
+ this.write("beaver", value);
166
+ }
203
167
  resign() {
204
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.resign();
168
+ this.#mount?.resign();
205
169
  }
206
170
  nextGame() {
207
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.nextGame();
171
+ this.#mount?.nextGame();
208
172
  }
209
173
  newMatch() {
210
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.newMatch();
174
+ this.#mount?.newMatch();
211
175
  }
212
176
  /** The `variant` attribute, reflected. */
213
- get variant() { return this.getAttribute("variant"); }
214
- set variant(value) { this.write("variant", value); }
177
+ get variant() {
178
+ return this.getAttribute("variant");
179
+ }
180
+ set variant(value) {
181
+ this.write("variant", value);
182
+ }
215
183
  /** The `preset` attribute, reflected. */
216
- get preset() { return this.getAttribute("preset"); }
217
- set preset(value) { this.write("preset", value); }
184
+ get preset() {
185
+ return this.getAttribute("preset");
186
+ }
187
+ set preset(value) {
188
+ this.write("preset", value);
189
+ }
218
190
  /** The `points` attribute, reflected. */
219
- get points() { return this.getAttribute("points"); }
220
- set points(value) { this.write("points", value); }
191
+ get points() {
192
+ return this.getAttribute("points");
193
+ }
194
+ set points(value) {
195
+ this.write("points", value);
196
+ }
221
197
  /** The `cube` attribute, reflected. */
222
- get cube() { return this.getAttribute("cube"); }
223
- set cube(value) { this.write("cube", value); }
198
+ get cube() {
199
+ return this.getAttribute("cube");
200
+ }
201
+ set cube(value) {
202
+ this.write("cube", value);
203
+ }
224
204
  /** The `crawford` attribute, reflected. */
225
- get crawford() { return this.getAttribute("crawford"); }
226
- set crawford(value) { this.write("crawford", value); }
205
+ get crawford() {
206
+ return this.getAttribute("crawford");
207
+ }
208
+ set crawford(value) {
209
+ this.write("crawford", value);
210
+ }
227
211
  /** The `jacoby` attribute, reflected. */
228
- get jacoby() { return this.getAttribute("jacoby"); }
229
- set jacoby(value) { this.write("jacoby", value); }
212
+ get jacoby() {
213
+ return this.getAttribute("jacoby");
214
+ }
215
+ set jacoby(value) {
216
+ this.write("jacoby", value);
217
+ }
230
218
  /** The `gammons` attribute, reflected. */
231
- get gammons() { return this.getAttribute("gammons"); }
232
- set gammons(value) { this.write("gammons", value); }
219
+ get gammons() {
220
+ return this.getAttribute("gammons");
221
+ }
222
+ set gammons(value) {
223
+ this.write("gammons", value);
224
+ }
233
225
  /** The `seed` attribute, reflected. */
234
- get seed() { return this.getAttribute("seed"); }
235
- set seed(value) { this.write("seed", value); }
226
+ get seed() {
227
+ return this.getAttribute("seed");
228
+ }
229
+ set seed(value) {
230
+ this.write("seed", value);
231
+ }
236
232
  /** The `dice` attribute, reflected. */
237
- get dice() { return this.getAttribute("dice"); }
238
- set dice(value) { this.write("dice", value); }
233
+ get dice() {
234
+ return this.getAttribute("dice");
235
+ }
236
+ set dice(value) {
237
+ this.write("dice", value);
238
+ }
239
239
  /** The `controls` attribute, reflected. */
240
- get controls() { return this.getAttribute("controls"); }
241
- set controls(value) { this.write("controls", value); }
240
+ get controls() {
241
+ return this.getAttribute("controls");
242
+ }
243
+ set controls(value) {
244
+ this.write("controls", value);
245
+ }
242
246
  /** The `drag` attribute, reflected. */
243
- get drag() { return this.getAttribute("drag"); }
244
- set drag(value) { this.write("drag", value); }
247
+ get drag() {
248
+ return this.getAttribute("drag");
249
+ }
250
+ set drag(value) {
251
+ this.write("drag", value);
252
+ }
245
253
  /** The `auto-end` attribute, reflected. */
246
- get autoEnd() { return this.getAttribute("auto-end"); }
247
- set autoEnd(value) { this.write("auto-end", value); }
254
+ get autoEnd() {
255
+ return this.getAttribute("auto-end");
256
+ }
257
+ set autoEnd(value) {
258
+ this.write("auto-end", value);
259
+ }
248
260
  /** The `sound` attribute, reflected. */
249
- get sound() { return this.getAttribute("sound"); }
250
- set sound(value) { this.write("sound", value); }
261
+ get sound() {
262
+ return this.getAttribute("sound");
263
+ }
264
+ set sound(value) {
265
+ this.write("sound", value);
266
+ }
251
267
  /** The `computer-delay` attribute, reflected. */
252
- get computerDelay() { return this.getAttribute("computer-delay"); }
253
- set computerDelay(value) { this.write("computer-delay", value); }
268
+ get computerDelay() {
269
+ return this.getAttribute("computer-delay");
270
+ }
271
+ set computerDelay(value) {
272
+ this.write("computer-delay", value);
273
+ }
254
274
  /** The `white` attribute, reflected. */
255
- get white() { return this.getAttribute("white"); }
256
- set white(value) { this.write("white", value); }
275
+ get white() {
276
+ return this.getAttribute("white");
277
+ }
278
+ set white(value) {
279
+ this.write("white", value);
280
+ }
257
281
  /** The `black` attribute, reflected. */
258
- get black() { return this.getAttribute("black"); }
259
- set black(value) { this.write("black", value); }
282
+ get black() {
283
+ return this.getAttribute("black");
284
+ }
285
+ set black(value) {
286
+ this.write("black", value);
287
+ }
260
288
  /** The `board` attribute, reflected. */
261
- get board() { return this.getAttribute("board"); }
262
- set board(value) { this.write("board", value); }
289
+ get board() {
290
+ return this.getAttribute("board");
291
+ }
292
+ set board(value) {
293
+ this.write("board", value);
294
+ }
263
295
  /** The `checkers` attribute, reflected. */
264
- get checkers() { return this.getAttribute("checkers"); }
265
- set checkers(value) { this.write("checkers", value); }
296
+ get checkers() {
297
+ return this.getAttribute("checkers");
298
+ }
299
+ set checkers(value) {
300
+ this.write("checkers", value);
301
+ }
266
302
  /** The `theme` attribute, reflected. */
267
- get theme() { return this.getAttribute("theme"); }
268
- set theme(value) { this.write("theme", value); }
303
+ get theme() {
304
+ return this.getAttribute("theme");
305
+ }
306
+ set theme(value) {
307
+ this.write("theme", value);
308
+ }
269
309
  /** The `home` attribute, reflected. */
270
- get home() { return this.getAttribute("home"); }
271
- set home(value) { this.write("home", value); }
310
+ get home() {
311
+ return this.getAttribute("home");
312
+ }
313
+ set home(value) {
314
+ this.write("home", value);
315
+ }
272
316
  /** The `view` attribute, reflected. */
273
- get view() { return this.getAttribute("view"); }
274
- set view(value) { this.write("view", value); }
317
+ get view() {
318
+ return this.getAttribute("view");
319
+ }
320
+ set view(value) {
321
+ this.write("view", value);
322
+ }
275
323
  /** The `numbers` attribute, reflected. */
276
- get numbers() { return this.getAttribute("numbers"); }
277
- set numbers(value) { this.write("numbers", value); }
324
+ get numbers() {
325
+ return this.getAttribute("numbers");
326
+ }
327
+ set numbers(value) {
328
+ this.write("numbers", value);
329
+ }
278
330
  /** The `orientation` attribute, reflected. */
279
- get orientation() { return this.getAttribute("orientation"); }
280
- set orientation(value) { this.write("orientation", value); }
281
- }
282
- _SugorokuBoard_mount = new WeakMap(), _SugorokuBoard_key = new WeakMap(), _SugorokuBoard_queued = new WeakMap(), _SugorokuBoard_options = new WeakMap(), _SugorokuBoard_instances = new WeakSet(), _SugorokuBoard_side = function _SugorokuBoard_side(name) {
283
- const value = this.getAttribute(name);
284
- return value === null ? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").computer?.[name] ?? null : oneOf(value, STRENGTHS) ?? null;
285
- }, _SugorokuBoard_look = function _SugorokuBoard_look() {
286
- const view = this.getAttribute("view");
287
- const language = oneOf(this.getAttribute("lang"), ["en", "ja"]) ?? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").language;
288
- return {
289
- board: oneOf(this.getAttribute("board"), SUGOROKU_BOARD_NAMES) ?? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").board,
290
- checkers: oneOf(this.getAttribute("checkers"), SUGOROKU_CHECKER_SET_NAMES) ?? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").checkers,
291
- theme: oneOf(this.getAttribute("theme"), ["auto", "light", "dark"]) ?? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").theme,
292
- home: oneOf(this.getAttribute("home"), ["left", "right"]) ?? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").home,
293
- view: view === "white" || view === "black" || view === "auto" ? view : __classPrivateFieldGet(this, _SugorokuBoard_options, "f").view,
294
- numbers: isOn(this.getAttribute("numbers"), __classPrivateFieldGet(this, _SugorokuBoard_options, "f").numbers ?? false),
295
- orientation: oneOf(this.getAttribute("orientation"), ["auto", "landscape", "portrait"]) ?? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").orientation,
296
- computer: { white: __classPrivateFieldGet(this, _SugorokuBoard_instances, "m", _SugorokuBoard_side).call(this, "white"), black: __classPrivateFieldGet(this, _SugorokuBoard_instances, "m", _SugorokuBoard_side).call(this, "black") },
297
- language, colours: __classPrivateFieldGet(this, _SugorokuBoard_options, "f").colours,
298
- };
299
- }, _SugorokuBoard_refresh = function _SugorokuBoard_refresh() {
300
- this.frame();
301
- const key = JSON.stringify([GAME_ATTRIBUTES.map((name) => this.getAttribute(name)), ...["variant", "rules", "preset", "seed", "dice", "controls", "drag", "autoEnd", "computerDelay", "match"].map(name => __classPrivateFieldGet(this, _SugorokuBoard_options, "f")[name])]);
302
- if (key === __classPrivateFieldGet(this, _SugorokuBoard_key, "f") && __classPrivateFieldGet(this, _SugorokuBoard_mount, "f") !== null) {
303
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f").set({ ...__classPrivateFieldGet(this, _SugorokuBoard_instances, "m", _SugorokuBoard_look).call(this), names: __classPrivateFieldGet(this, _SugorokuBoard_options, "f").names, sound: this.hasAttribute("sound") ? isOn(this.getAttribute("sound")) : __classPrivateFieldGet(this, _SugorokuBoard_options, "f").sound });
304
- return;
305
- }
306
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.destroy();
307
- __classPrivateFieldSet(this, _SugorokuBoard_mount, null, "f");
308
- __classPrivateFieldSet(this, _SugorokuBoard_key, "", "f");
309
- try {
310
- const variant = this.getAttribute("variant");
311
- const rules = { ...__classPrivateFieldGet(this, _SugorokuBoard_options, "f").rules };
312
- const points = this.getAttribute("points");
313
- if (points !== null && /^\d+$/.test(points))
314
- rules.points = Number(points);
315
- for (const name of ["cube", "crawford", "jacoby", "beaver", "gammons"]) {
316
- const value = this.getAttribute(name);
317
- if (value !== null)
318
- rules[name] = isOn(value);
319
- }
320
- const seed = this.getAttribute("seed");
321
- const delay = this.getAttribute("computer-delay");
322
- const sound = this.getAttribute("sound");
323
- __classPrivateFieldSet(this, _SugorokuBoard_mount, mountSugoroku(this, {
324
- ...__classPrivateFieldGet(this, _SugorokuBoard_options, "f"),
325
- variant: isVariantKey(variant) ? variant : __classPrivateFieldGet(this, _SugorokuBoard_options, "f").variant,
326
- rules,
327
- preset: this.getAttribute("preset") ?? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").preset,
328
- seed: seed === null ? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").seed : /^\d+$/.test(seed) ? Number(seed) : seed,
329
- dice: this.getAttribute("dice") === "host" ? "host" : this.getAttribute("dice") === "button" ? "button" : __classPrivateFieldGet(this, _SugorokuBoard_options, "f").dice ?? "button",
330
- controls: isOn(this.getAttribute("controls"), __classPrivateFieldGet(this, _SugorokuBoard_options, "f").controls ?? true),
331
- drag: isOn(this.getAttribute("drag"), __classPrivateFieldGet(this, _SugorokuBoard_options, "f").drag ?? true),
332
- autoEnd: isOn(this.getAttribute("auto-end"), __classPrivateFieldGet(this, _SugorokuBoard_options, "f").autoEnd ?? false),
333
- sound: sound === null ? __classPrivateFieldGet(this, _SugorokuBoard_options, "f").sound : isOn(sound === "" ? "on" : sound),
334
- computerDelay: delay !== null && /^\d+$/.test(delay) ? Number(delay) : __classPrivateFieldGet(this, _SugorokuBoard_options, "f").computerDelay,
335
- ...__classPrivateFieldGet(this, _SugorokuBoard_instances, "m", _SugorokuBoard_look).call(this),
336
- onRoll: detail => __classPrivateFieldGet(this, _SugorokuBoard_options, "f").onRoll?.(detail), onMove: detail => __classPrivateFieldGet(this, _SugorokuBoard_options, "f").onMove?.(detail), onTurn: detail => __classPrivateFieldGet(this, _SugorokuBoard_options, "f").onTurn?.(detail), onCube: detail => __classPrivateFieldGet(this, _SugorokuBoard_options, "f").onCube?.(detail), onEnd: detail => __classPrivateFieldGet(this, _SugorokuBoard_options, "f").onEnd?.(detail),
337
- }), "f");
338
- __classPrivateFieldSet(this, _SugorokuBoard_key, key, "f");
331
+ get orientation() {
332
+ return this.getAttribute("orientation");
333
+ }
334
+ set orientation(value) {
335
+ this.write("orientation", value);
336
+ }
337
+ #side(name) {
338
+ const value = this.getAttribute(name);
339
+ return value === null ? (this.#options.computer?.[name] ?? null) : (oneOf(value, STRENGTHS) ?? null);
340
+ }
341
+ #look() {
342
+ const view = this.getAttribute("view");
343
+ const language = oneOf(this.getAttribute("lang"), ["en", "ja", "fr"]) ?? this.#options.language;
344
+ return {
345
+ board: oneOf(this.getAttribute("board"), SUGOROKU_BOARD_NAMES) ?? this.#options.board,
346
+ checkers: oneOf(this.getAttribute("checkers"), SUGOROKU_CHECKER_SET_NAMES) ??
347
+ this.#options.checkers,
348
+ theme: oneOf(this.getAttribute("theme"), ["auto", "light", "dark"]) ?? this.#options.theme,
349
+ home: oneOf(this.getAttribute("home"), ["left", "right"]) ?? this.#options.home,
350
+ view: view === "white" || view === "black" || view === "auto" ? view : this.#options.view,
351
+ numbers: isOn(this.getAttribute("numbers"), this.#options.numbers ?? false),
352
+ orientation: oneOf(this.getAttribute("orientation"), ["auto", "landscape", "portrait"]) ??
353
+ this.#options.orientation,
354
+ computer: { white: this.#side("white"), black: this.#side("black") },
355
+ language,
356
+ colours: this.#options.colours,
357
+ };
358
+ }
359
+ #refresh() {
339
360
  this.frame();
340
- this.dispatchEvent(new CustomEvent("sugoroku-load", { bubbles: true, composed: true, detail: JSON.parse(JSON.stringify({ game: this.game, match: this.match })) }));
341
- }
342
- catch (error) {
343
- __classPrivateFieldGet(this, _SugorokuBoard_mount, "f")?.destroy();
344
- __classPrivateFieldSet(this, _SugorokuBoard_mount, null, "f");
345
- __classPrivateFieldSet(this, _SugorokuBoard_key, "", "f");
346
- const message = error instanceof Error ? error.message : String(error), status = this.ownerDocument.createElement("p");
347
- status.setAttribute("role", "status");
348
- status.textContent = message;
349
- this.replaceChildren(status);
350
- this.dispatchEvent(new CustomEvent("sugoroku-error", { bubbles: true, composed: true, detail: { message } }));
351
- }
352
- };
353
- SugorokuBoard.observedAttributes = [...GAME_ATTRIBUTES, "white", "black", "board", "checkers", "theme", "home", "view", "numbers", "orientation", "lang", "size", "width", "label"];
361
+ const key = JSON.stringify([
362
+ GAME_ATTRIBUTES.map((name) => this.getAttribute(name)),
363
+ ...["variant", "rules", "preset", "seed", "dice", "controls", "drag", "autoEnd", "computerDelay", "match"].map((name) => this.#options[name]),
364
+ ]);
365
+ if (key === this.#key && this.#mount !== null) {
366
+ this.#mount.set({
367
+ ...this.#look(),
368
+ names: this.#options.names,
369
+ sound: this.hasAttribute("sound") ? isOn(this.getAttribute("sound")) : this.#options.sound,
370
+ });
371
+ return;
372
+ }
373
+ this.#mount?.destroy();
374
+ this.#mount = null;
375
+ this.#key = "";
376
+ try {
377
+ const variant = this.getAttribute("variant");
378
+ const rules = { ...this.#options.rules };
379
+ const points = this.getAttribute("points");
380
+ if (points !== null && /^\d+$/.test(points))
381
+ rules.points = Number(points);
382
+ for (const name of ["cube", "crawford", "jacoby", "beaver", "gammons"]) {
383
+ const value = this.getAttribute(name);
384
+ if (value !== null)
385
+ rules[name] = isOn(value);
386
+ }
387
+ const seed = this.getAttribute("seed");
388
+ const delay = this.getAttribute("computer-delay");
389
+ const sound = this.getAttribute("sound");
390
+ this.#mount = mountSugoroku(this, {
391
+ ...this.#options,
392
+ variant: isVariantKey(variant) ? variant : this.#options.variant,
393
+ rules,
394
+ preset: this.getAttribute("preset") ?? this.#options.preset,
395
+ seed: seed === null ? this.#options.seed : /^\d+$/.test(seed) ? Number(seed) : seed,
396
+ dice: this.getAttribute("dice") === "host"
397
+ ? "host"
398
+ : this.getAttribute("dice") === "button"
399
+ ? "button"
400
+ : (this.#options.dice ?? "button"),
401
+ controls: isOn(this.getAttribute("controls"), this.#options.controls ?? true),
402
+ drag: isOn(this.getAttribute("drag"), this.#options.drag ?? true),
403
+ autoEnd: isOn(this.getAttribute("auto-end"), this.#options.autoEnd ?? false),
404
+ sound: sound === null ? this.#options.sound : isOn(sound === "" ? "on" : sound),
405
+ computerDelay: delay !== null && /^\d+$/.test(delay) ? Number(delay) : this.#options.computerDelay,
406
+ ...this.#look(),
407
+ onRoll: (detail) => this.#options.onRoll?.(detail),
408
+ onMove: (detail) => this.#options.onMove?.(detail),
409
+ onTurn: (detail) => this.#options.onTurn?.(detail),
410
+ onCube: (detail) => this.#options.onCube?.(detail),
411
+ onEnd: (detail) => this.#options.onEnd?.(detail),
412
+ });
413
+ this.#key = key;
414
+ this.frame();
415
+ this.dispatchEvent(new CustomEvent("sugoroku-load", {
416
+ bubbles: true,
417
+ composed: true,
418
+ detail: JSON.parse(JSON.stringify({ game: this.game, match: this.match })),
419
+ }));
420
+ }
421
+ catch (error) {
422
+ this.#mount?.destroy();
423
+ this.#mount = null;
424
+ this.#key = "";
425
+ const message = error instanceof Error ? error.message : String(error);
426
+ const status = this.ownerDocument.createElement("p");
427
+ status.setAttribute("role", "status");
428
+ status.textContent = message;
429
+ this.replaceChildren(status);
430
+ this.dispatchEvent(new CustomEvent("sugoroku-error", { bubbles: true, composed: true, detail: { message } }));
431
+ }
432
+ }
433
+ }
354
434
  /** Defines the default playable board, or a subclass under a custom tag. Server-safe and idempotent.
355
435
  * @param tagName - The custom tag name; omitted to use the package default.
356
436
  * @param registry - The custom-element registry; omitted outside a browser.
@@ -362,167 +442,9 @@ SugorokuBoard.observedAttributes = [...GAME_ATTRIBUTES, "white", "black", "board
362
442
  * console.log(typeof defineBoard); // function
363
443
  * ```
364
444
  */
365
- export function defineBoard(tagName = "sugoroku-board", registry = typeof customElements === "undefined" ? undefined : customElements) { if (registry !== undefined && registry.get(tagName) === undefined)
366
- registry.define(tagName, tagName === "sugoroku-board" ? SugorokuBoard : class extends SugorokuBoard {
367
- }); }
368
- /**
369
- * Reads a GNU position ID or bounded JSON position; null means invalid counts or input.
370
- * @param text - Position ID, JSON position, or null for the variant's start.
371
- * @param variant - The native variant used for checker counts and layout.
372
- * @param turn - The on-roll side encoded by a GNU ID.
373
- * @returns A complete position, or null for malformed or inconsistent input.
374
- * @example
375
- * ```ts
376
- * import { readEmbedPosition } from "@johnmorrisdotca/sugoroku/element";
377
- * console.log(readEmbedPosition("4HPwATDgc/ABMA")?.points[0].length);
378
- * ```
379
- */
380
- export function readEmbedPosition(text, variant = "backgammon", turn = "white") {
381
- if (!isVariantKey(variant) || (turn !== "white" && turn !== "black"))
382
- return null;
383
- const spec = VARIANTS[variant];
384
- if (text === null)
385
- return startPosition(spec);
386
- if (text.length > 10000)
387
- return null;
388
- if (text.trim() === "")
389
- return startPosition(spec);
390
- if (/^[A-Za-z0-9+/]{14}$/.test(text.trim()))
391
- return positionFromId(text.trim(), turn, spec.checkers);
392
- try {
393
- const data = JSON.parse(text);
394
- const count = (value) => Number.isInteger(value) && Number(value) >= 0 && Number(value) <= spec.checkers;
395
- const pair = (value) => Array.isArray(value) && value.length === 2 && value.every(count);
396
- if (data === null || typeof data !== "object" || !Array.isArray(data.points) || data.points.length !== 2 || !data.points.every(row => Array.isArray(row) && row.length === 24 && row.every(count)) || !pair(data.bar) || !pair(data.off) || !pair(data.reserve))
397
- return null;
398
- for (const side of [0, 1])
399
- if (data.points[side].reduce((sum, n) => sum + n, 0) + data.bar[side] + data.off[side] + data.reserve[side] !== spec.checkers)
400
- return null;
401
- return { points: [[...data.points[0]], [...data.points[1]]], bar: [data.bar[0], data.bar[1]], off: [data.off[0], data.off[1]], reserve: [data.reserve[0], data.reserve[1]] };
402
- }
403
- catch {
404
- return null;
405
- }
406
- }
407
- /** Native draw keys, checked by the shared builder.
408
- * @example
409
- * ```ts
410
- * import { SUGOROKU_DRAW_OPTION_KEYS } from "@johnmorrisdotca/sugoroku/element";
411
- * console.log(typeof SUGOROKU_DRAW_OPTION_KEYS); // object
412
- * ```
413
- */
414
- export const SUGOROKU_DRAW_OPTION_KEYS = Object.keys({ variant: true, view: true, home: true, orientation: true, numbers: true, board: true, checkers: true, colours: true, theme: true, dice: true, cube: true, highlight: true, label: true, style: true });
415
- /** All host position options, checked by the builder.
416
- * @example
417
- * ```ts
418
- * import { SUGOROKU_POSITION_OPTION_KEYS } from "@johnmorrisdotca/sugoroku/element";
419
- * console.log(typeof SUGOROKU_POSITION_OPTION_KEYS); // object
420
- * ```
421
- */
422
- export const SUGOROKU_POSITION_OPTION_KEYS = Object.keys({ position: true, onChange: true, variant: true, view: true, home: true, orientation: true, numbers: true, board: true, checkers: true, colours: true, theme: true, dice: true, cube: true, highlight: true, label: true, style: true });
423
- /** A read-only backgammon position, drawn by the native SVG writer.
424
- * @example
425
- * ```ts
426
- * import { SugorokuPosition } from "@johnmorrisdotca/sugoroku/element";
427
- * console.log(SugorokuPosition.observedAttributes.includes("lang")); // true
428
- * ```
429
- */
430
- export class SugorokuPosition extends SugorokuFrame {
431
- constructor() {
432
- super(...arguments);
433
- _SugorokuPosition_instances.add(this);
434
- _SugorokuPosition_value.set(this, null);
435
- _SugorokuPosition_options.set(this, {});
436
- _SugorokuPosition_resize.set(this, null);
437
- }
438
- /** Structured current position, or null after an input error. */
439
- get value() { return __classPrivateFieldGet(this, _SugorokuPosition_value, "f"); }
440
- /** Native drawing options and trusted host position data. */
441
- get options() { return __classPrivateFieldGet(this, _SugorokuPosition_options, "f"); }
442
- set options(value) { __classPrivateFieldSet(this, _SugorokuPosition_options, value ?? {}, "f"); if (this.isConnected)
443
- __classPrivateFieldGet(this, _SugorokuPosition_instances, "m", _SugorokuPosition_render).call(this); }
444
- connectedCallback() { __classPrivateFieldGet(this, _SugorokuPosition_instances, "m", _SugorokuPosition_render).call(this); const Resize = this.ownerDocument.defaultView?.ResizeObserver; if (Resize !== undefined) {
445
- __classPrivateFieldSet(this, _SugorokuPosition_resize, new Resize(() => { if (this.isConnected)
446
- __classPrivateFieldGet(this, _SugorokuPosition_instances, "m", _SugorokuPosition_render).call(this); }), "f");
447
- __classPrivateFieldGet(this, _SugorokuPosition_resize, "f").observe(this);
448
- } }
449
- disconnectedCallback() { __classPrivateFieldGet(this, _SugorokuPosition_resize, "f")?.disconnect(); __classPrivateFieldSet(this, _SugorokuPosition_resize, null, "f"); }
450
- attributeChangedCallback() { if (this.isConnected)
451
- __classPrivateFieldGet(this, _SugorokuPosition_instances, "m", _SugorokuPosition_render).call(this); }
452
- /** Position ID or JSON, reflected. Assign an object to serialize it. */
453
- get position() { return this.getAttribute("position"); }
454
- set position(value) { this.write("position", value !== null && typeof value === "object" ? JSON.stringify(value) : value); }
455
- /** The `variant` attribute, reflected. */
456
- get variant() { return this.getAttribute("variant"); }
457
- set variant(value) { this.write("variant", value); }
458
- /** The `turn` attribute, reflected. */
459
- get turn() { return this.getAttribute("turn"); }
460
- set turn(value) { this.write("turn", value); }
461
- /** The `board` attribute, reflected. */
462
- get board() { return this.getAttribute("board"); }
463
- set board(value) { this.write("board", value); }
464
- /** The `checkers` attribute, reflected. */
465
- get checkers() { return this.getAttribute("checkers"); }
466
- set checkers(value) { this.write("checkers", value); }
467
- /** The `theme` attribute, reflected. */
468
- get theme() { return this.getAttribute("theme"); }
469
- set theme(value) { this.write("theme", value); }
470
- /** The `home` attribute, reflected. */
471
- get home() { return this.getAttribute("home"); }
472
- set home(value) { this.write("home", value); }
473
- /** The `view` attribute, reflected. */
474
- get view() { return this.getAttribute("view"); }
475
- set view(value) { this.write("view", value); }
476
- /** The `numbers` attribute, reflected. */
477
- get numbers() { return this.getAttribute("numbers"); }
478
- set numbers(value) { this.write("numbers", value); }
479
- /** The `orientation` attribute, reflected. */
480
- get orientation() { return this.getAttribute("orientation"); }
481
- set orientation(value) { this.write("orientation", value); }
445
+ export function defineBoard(tagName = "sugoroku-board", registry = typeof customElements === "undefined" ? undefined : customElements) {
446
+ if (registry !== undefined && registry.get(tagName) === undefined)
447
+ registry.define(tagName, tagName === "sugoroku-board" ? SugorokuBoard : class extends SugorokuBoard {
448
+ });
482
449
  }
483
- _SugorokuPosition_value = new WeakMap(), _SugorokuPosition_options = new WeakMap(), _SugorokuPosition_resize = new WeakMap(), _SugorokuPosition_instances = new WeakSet(), _SugorokuPosition_render = function _SugorokuPosition_render() {
484
- this.frame();
485
- try {
486
- const variant = this.getAttribute("variant") ?? (typeof __classPrivateFieldGet(this, _SugorokuPosition_options, "f").variant === "string" ? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").variant : "backgammon");
487
- if (!isVariantKey(variant))
488
- throw new RangeError("Choose a known backgammon variant.");
489
- const turn = this.getAttribute("turn") ?? "white";
490
- if (turn !== "white" && turn !== "black")
491
- throw new RangeError("Choose white or black on roll.");
492
- const position = this.hasAttribute("position") ? readEmbedPosition(this.getAttribute("position"), variant, turn) : __classPrivateFieldGet(this, _SugorokuPosition_options, "f").position ?? startPosition(VARIANTS[variant]);
493
- if (position === null)
494
- throw new RangeError("Use a valid GNU position ID or complete JSON position.");
495
- __classPrivateFieldSet(this, _SugorokuPosition_value, position, "f");
496
- const orientation = this.getAttribute("orientation") ?? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").orientation;
497
- const draw = { ...__classPrivateFieldGet(this, _SugorokuPosition_options, "f"), variant: this.hasAttribute("variant") ? variant : __classPrivateFieldGet(this, _SugorokuPosition_options, "f").variant ?? variant, theme: oneOf(this.getAttribute("theme"), ["auto", "light", "dark"]) ?? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").theme, board: oneOf(this.getAttribute("board"), SUGOROKU_BOARD_NAMES) ?? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").board, checkers: oneOf(this.getAttribute("checkers"), SUGOROKU_CHECKER_SET_NAMES) ?? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").checkers, home: oneOf(this.getAttribute("home"), ["left", "right"]) ?? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").home, view: oneOf(this.getAttribute("view"), ["white", "black"]) ?? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").view, numbers: isOn(this.getAttribute("numbers"), __classPrivateFieldGet(this, _SugorokuPosition_options, "f").numbers ?? false), orientation: orientation === "portrait" || orientation !== "landscape" && (this.clientWidth || 600) < 560 ? "portrait" : "landscape", label: this.getAttribute("label") ?? __classPrivateFieldGet(this, _SugorokuPosition_options, "f").label ?? ((this.getAttribute("lang") ?? this.ownerDocument.documentElement.lang) === "ja" ? "双六の局面" : undefined), style: __classPrivateFieldGet(this, _SugorokuPosition_options, "f").style ?? true };
498
- const svg = new DOMParser().parseFromString(drawSugoroku(position, draw), "image/svg+xml").documentElement;
499
- this.replaceChildren(this.ownerDocument.importNode(svg, true));
500
- __classPrivateFieldGet(this, _SugorokuPosition_options, "f").onChange?.(position);
501
- const detail = JSON.parse(JSON.stringify({ variant, position }));
502
- this.dispatchEvent(new CustomEvent("sugoroku-change", { bubbles: true, composed: true, detail }));
503
- this.dispatchEvent(new CustomEvent("sugoroku-load", { bubbles: true, composed: true, detail }));
504
- }
505
- catch (error) {
506
- __classPrivateFieldSet(this, _SugorokuPosition_value, null, "f");
507
- const message = error instanceof Error ? error.message : String(error), status = this.ownerDocument.createElement("p");
508
- status.setAttribute("role", "status");
509
- status.textContent = message;
510
- this.replaceChildren(status);
511
- this.dispatchEvent(new CustomEvent("sugoroku-error", { bubbles: true, composed: true, detail: { message } }));
512
- }
513
- };
514
- SugorokuPosition.observedAttributes = ["position", "variant", "turn", "board", "checkers", "theme", "home", "view", "numbers", "orientation", "lang", "size", "width", "label"];
515
- /** Defines a static position, or a subclass under a host's tag. Safe on a server.
516
- * @param tagName - The custom tag name; omitted to use the package default.
517
- * @param registry - The custom-element registry; omitted outside a browser.
518
- * @returns Nothing; existing definitions and server imports remain safe.
519
- * @example
520
- * ```ts
521
- * import { definePosition } from "@johnmorrisdotca/sugoroku/element";
522
- * definePosition();
523
- * console.log(typeof definePosition); // function
524
- * ```
525
- */
526
- export function definePosition(tagName = "sugoroku-position", registry = typeof customElements === "undefined" ? undefined : customElements) { if (registry !== undefined && registry.get(tagName) === undefined)
527
- registry.define(tagName, tagName === "sugoroku-position" ? SugorokuPosition : class extends SugorokuPosition {
528
- }); }
450
+ export { definePosition, readEmbedPosition, SUGOROKU_DRAW_OPTION_KEYS, SUGOROKU_POSITION_OPTION_KEYS, SugorokuPosition, } from "./positionElement.js";