@nice2dev/ui-erp 1.2.2 → 1.3.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.
Files changed (3) hide show
  1. package/dist/index.cjs +1590 -274
  2. package/dist/index.mjs +1535 -219
  3. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1,11 +1,155 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import ve, { useContext, createContext, useState, useMemo, useCallback, forwardRef, useRef, useEffect } from "react";
2
+ import $e$1, { useContext, createContext, useRef, useState, useEffect, useLayoutEffect, useMemo, useCallback, forwardRef } from "react";
3
3
  const a = (e, t) => t, c = /* @__PURE__ */ createContext(a), i = /* @__PURE__ */ createContext("en");
4
4
  function v() {
5
5
  const e = useContext(c), t = useContext(i);
6
6
  return { t: e, lang: t };
7
7
  }
8
- const tr = {
8
+ const gt = /* @__PURE__ */ new Set([
9
+ "",
10
+ "text",
11
+ "search",
12
+ "email",
13
+ "url",
14
+ "tel",
15
+ "password"
16
+ ]), Pe = /* @__PURE__ */ new Set([
17
+ "number",
18
+ "range",
19
+ "date",
20
+ "time",
21
+ "datetime-local",
22
+ "month",
23
+ "week"
24
+ ]), Ut = /* @__PURE__ */ new Set([
25
+ "checkbox",
26
+ "radio",
27
+ "button",
28
+ "submit",
29
+ "reset",
30
+ "file",
31
+ "image",
32
+ "color"
33
+ ]), Gt = /* @__PURE__ */ new Set([
34
+ "button",
35
+ "link",
36
+ "checkbox",
37
+ "radio",
38
+ "switch",
39
+ "tab",
40
+ "menuitem",
41
+ "menuitemcheckbox",
42
+ "menuitemradio",
43
+ "option",
44
+ "treeitem"
45
+ ]), bt = (n) => n instanceof HTMLInputElement && gt.has(n.type), De = (n) => n instanceof HTMLTextAreaElement, yt = (n) => n instanceof HTMLElement && n.isContentEditable;
46
+ function qt(n, e) {
47
+ const { intent: t, direction: a2 } = e;
48
+ return bt(n) ? t === "navigate" ? a2 === "left" || a2 === "right" : t === "first" || t === "last" || t === "activate" || t === "toggleHints" : De(n) || yt(n) ? t !== "back" && t !== "view" && t !== "menu" && t !== "secondary" : n instanceof HTMLSelectElement ? t !== "back" && t !== "view" && t !== "menu" : n instanceof HTMLInputElement ? Pe.has(n.type) ? t === "navigate" || t === "first" || t === "last" || t === "pagePrev" || t === "pageNext" : n.type === "radio" && t === "navigate" : false;
49
+ }
50
+ function wt(n) {
51
+ if (n instanceof HTMLButtonElement || n.tagName === "SUMMARY")
52
+ return true;
53
+ if (n instanceof HTMLAnchorElement)
54
+ return n.hasAttribute("href");
55
+ if (n instanceof HTMLInputElement)
56
+ return Ut.has(n.type);
57
+ const e = n.getAttribute("role");
58
+ return e !== null && Gt.has(e);
59
+ }
60
+ function $t(n) {
61
+ if (typeof n.click == "function") {
62
+ n.click();
63
+ return;
64
+ }
65
+ const e = n.ownerDocument.defaultView;
66
+ n.dispatchEvent(
67
+ new ((e == null ? void 0 : e.MouseEvent) ?? MouseEvent)("click", {
68
+ bubbles: true,
69
+ cancelable: true,
70
+ composed: true
71
+ })
72
+ );
73
+ }
74
+ function Et(n) {
75
+ if (n.defaultPrevented || n.repeat || n.target !== n.currentTarget || n.key !== "Enter" && n.key !== " " && n.key !== "Spacebar")
76
+ return;
77
+ const e = n.currentTarget;
78
+ if (!e || typeof e.dispatchEvent != "function")
79
+ return;
80
+ n.preventDefault();
81
+ const t = e.ownerDocument.defaultView;
82
+ e.dispatchEvent(
83
+ new ((t == null ? void 0 : t.MouseEvent) ?? MouseEvent)("click", {
84
+ bubbles: true,
85
+ cancelable: true,
86
+ composed: true,
87
+ ctrlKey: !!n.ctrlKey,
88
+ shiftKey: !!n.shiftKey,
89
+ altKey: !!n.altKey,
90
+ metaKey: !!n.metaKey
91
+ })
92
+ );
93
+ }
94
+ function me(n) {
95
+ const e = n.getAttribute("data-nice-engage");
96
+ if (e === "value" || e === "text" || e === "popup" || e === "canvas")
97
+ return e;
98
+ if (e === "none")
99
+ return null;
100
+ const t = n.getAttribute("role");
101
+ return t === "combobox" ? "popup" : t === "slider" || t === "spinbutton" || n instanceof HTMLSelectElement ? "value" : n instanceof HTMLInputElement ? gt.has(n.type) ? n.readOnly ? null : "text" : Pe.has(n.type) && !n.readOnly ? "value" : null : De(n) ? n.readOnly ? null : "text" : yt(n) ? "text" : null;
102
+ }
103
+ function kt(n, e) {
104
+ return e === "popup" ? n.getAttribute("aria-expanded") === "true" : n.hasAttribute("data-nice-engaged");
105
+ }
106
+ function ce(n) {
107
+ return n instanceof HTMLSelectElement || n instanceof HTMLInputElement && Pe.has(n.type);
108
+ }
109
+ function Me(n) {
110
+ n.dispatchEvent(new Event("input", { bubbles: true })), n.dispatchEvent(new Event("change", { bubbles: true }));
111
+ }
112
+ function Ie(n, e) {
113
+ var r;
114
+ const t = Object.getPrototypeOf(n), a2 = (r = Object.getOwnPropertyDescriptor(t, "value")) == null ? void 0 : r.set;
115
+ a2 ? a2.call(n, e) : n.value = e;
116
+ }
117
+ const be = (n) => n instanceof HTMLInputElement && n.type === "number";
118
+ function Wt(n, e) {
119
+ n.value !== e && (Ie(n, e), Me(n));
120
+ }
121
+ function le(n, e, t = "step") {
122
+ const a2 = e === "up" || e === "right";
123
+ if (n instanceof HTMLSelectElement) {
124
+ const s = n.selectedIndex, o = n.options.length - 1;
125
+ if (t === "edge")
126
+ n.selectedIndex = a2 ? o : 0;
127
+ else {
128
+ const i2 = t === "big" ? 10 : 1;
129
+ n.selectedIndex = Math.max(0, Math.min(o, s + (a2 ? i2 : -i2)));
130
+ }
131
+ return n.selectedIndex !== s ? (Me(n), true) : false;
132
+ }
133
+ const r = n.value;
134
+ try {
135
+ if (t === "edge" && (n.min !== "" || n.max !== ""))
136
+ Ie(n, a2 ? n.max || n.value : n.min || n.value);
137
+ else {
138
+ const s = t === "big" ? 10 : 1;
139
+ a2 ? n.stepUp(s) : n.stepDown(s);
140
+ }
141
+ } catch {
142
+ return false;
143
+ }
144
+ return n.value !== r ? (Me(n), true) : false;
145
+ }
146
+ function Xt(n, e) {
147
+ if (!(bt(n) || De(n)) || n.selectionStart === null || e !== "left" && e !== "right")
148
+ return false;
149
+ const t = n.selectionStart + (e === "right" ? 1 : -1), a2 = Math.max(0, Math.min(n.value.length, t));
150
+ return n.setSelectionRange(a2, a2), true;
151
+ }
152
+ const xt = {
9
153
  // Navigation
10
154
  "chevron-down": "M6 9l6 6 6-6",
11
155
  "chevron-up": "M18 15l-6-6-6 6",
@@ -223,77 +367,1206 @@ const tr = {
223
367
  midpoint: "M3 12h6 M15 12h6 M3 9v6 M21 9v6 M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6z",
224
368
  "angle-bisector": "M4 20h17 M4 20L16 5 M4 20l14.4-6.9 M10 20a6 6 0 0 0-2.25-4.68",
225
369
  group: "M3 7V3h4 M17 3h4v4 M21 17v4h-4 M7 21H3v-4 M7 7h5v5H7z M12 12h5v5h-5z",
226
- ungroup: "M3 3h8v8H3z M13 13h8v8h-8z"
227
- }, la = {
370
+ ungroup: "M3 3h8v8H3z M13 13h8v8h-8z",
371
+ // 1.3.0: button and key glyphs of the input prompts (ADR-005 § 8, decision 0.8). Outline here;
372
+ // the filled, coloured Ntd* of @nice2dev/icons carry the same names in its resolver.
373
+ "pad-xbox-a": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.25 16l2.75-8 2.75 8 M10.2 13.25h3.6",
374
+ "pad-xbox-b": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.75 8v8 M9.75 8h2.5a2 2 0 0 1 0 4h-2.5 M9.75 12h3a2 2 0 0 1 0 4h-3",
375
+ "pad-xbox-x": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l5 8 M14.5 8l-5 8",
376
+ "pad-xbox-y": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l2.5 4 2.5-4 M12 12v4",
377
+ "pad-nintendo-a": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.25 16l2.75-8 2.75 8 M10.2 13.25h3.6",
378
+ "pad-nintendo-b": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.75 8v8 M9.75 8h2.5a2 2 0 0 1 0 4h-2.5 M9.75 12h3a2 2 0 0 1 0 4h-3",
379
+ "pad-nintendo-x": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l5 8 M14.5 8l-5 8",
380
+ "pad-nintendo-y": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9.5 8l2.5 4 2.5-4 M12 12v4",
381
+ "pad-playstation-cross": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M9 9l6 6 M15 9l-6 6",
382
+ "pad-playstation-circle": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8.25a3.75 3.75 0 1 0 0 7.5a3.75 3.75 0 1 0 0 -7.5z",
383
+ "pad-playstation-square": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M8.5 8.5h7v7h-7z",
384
+ "pad-playstation-triangle": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8l4.5 7.5h-9z",
385
+ "pad-generic-north": "M12 3a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M12 6h.01 M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
386
+ "pad-generic-east": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 9a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M18 12h.01 M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
387
+ "pad-generic-west": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 9a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M6 12h.01 M12 16.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z",
388
+ "pad-generic-south": "M12 4.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M18 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M6 10.25a1.75 1.75 0 1 0 0 3.5a1.75 1.75 0 1 0 0 -3.5z M12 15a3 3 0 1 0 0 6a3 3 0 1 0 0 -6z M12 18h.01",
389
+ "pad-lb": "M6 9h12a3 3 0 0 1 0 6H6a3 3 0 0 1 0-6z M7.5 12h.01",
390
+ "pad-rb": "M6 9h12a3 3 0 0 1 0 6H6a3 3 0 0 1 0-6z M16.5 12h.01",
391
+ "pad-lt": "M9 3h6a3 3 0 0 1 3 3v7a6 6 0 0 1-12 0V6a3 3 0 0 1 3-3z M9.5 7h.01",
392
+ "pad-rt": "M9 3h6a3 3 0 0 1 3 3v7a6 6 0 0 1-12 0V6a3 3 0 0 1 3-3z M14.5 7h.01",
393
+ "pad-start": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M8.5 8.75h7 M8.5 12h7 M8.5 15.25h7",
394
+ "pad-select": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M7.75 7.75h5.5v5.5h-5.5z M10.75 16.25h5.5v-5.5",
395
+ "pad-home": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M7.95 12L12 8.6l4.05 3.4v4H7.95z",
396
+ "pad-dpad": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z",
397
+ "pad-dpad-up": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M12 5.6l1.15 1.5h-2.3z",
398
+ "pad-dpad-down": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M12 18.4l1.15-1.5h-2.3z",
399
+ "pad-dpad-left": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M5.6 12l1.5-1.15v2.3z",
400
+ "pad-dpad-right": "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z M18.4 12l-1.5-1.15v2.3z",
401
+ "pad-stick-left": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M4.5 12h1",
402
+ "pad-stick-right": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M18.5 12h1",
403
+ "pad-stick-left-press": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M12 12h.01 M4.5 12h1",
404
+ "pad-stick-right-press": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 7.5a4.5 4.5 0 1 0 0 9a4.5 4.5 0 1 0 0 -9z M12 12h.01 M18.5 12h1",
405
+ "remote-ok": "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0 -18z M12 8.5a3.5 3.5 0 1 0 0 7a3.5 3.5 0 1 0 0 -7z",
406
+ "remote-back": "M9 14l-4-4 4-4 M5 10h9a5 5 0 0 1 0 10h-2",
407
+ "remote-menu": "M4 6h16v12H4z M8 10h8 M8 14h8",
408
+ "key-command": "M9 9V6.5A2.5 2.5 0 1 0 6.5 9H9z M9 9h6 M9 9v6 M15 9V6.5A2.5 2.5 0 1 1 17.5 9H15z M15 9v6 M15 15H9 M15 15v2.5a2.5 2.5 0 1 0 2.5-2.5H15z M9 15H6.5A2.5 2.5 0 1 0 9 17.5V15z",
409
+ "key-option": "M4 6h5l6 12h5 M14 6h6",
410
+ "key-shift": "M12 4l-8 8h4v8h8v-8h4z",
411
+ "key-control": "M7 14l5-5 5 5",
412
+ "key-enter": "M20 5v7a3 3 0 0 1-3 3H5 M9 11l-4 4 4 4",
413
+ "key-tab": "M4 12h14 M14 8l4 4-4 4 M20 6v12",
414
+ // on-screen keyboard (1.3.0 H1)
415
+ "key-backspace": "M21 5H9l-6 7 6 7h12a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1z M17 9l-6 6 M11 9l6 6",
416
+ "key-space": "M4 10v4h16v-4",
417
+ "key-caps": "M12 4l-7 7h4v5h6v-5h4z M8 20h8"
418
+ }, Jt = {
228
419
  xs: 12,
229
420
  sm: 16,
230
421
  md: 20,
231
422
  lg: 24,
232
423
  xl: 32
233
- }, gt = /* @__PURE__ */ createContext({});
234
- function da({
235
- path: e,
236
- size: t,
237
- className: r,
424
+ }, Oe = /* @__PURE__ */ createContext({});
425
+ function Zt({
426
+ path: n,
427
+ size: e,
428
+ className: t,
238
429
  style: a2,
239
- color: n,
240
- title: o,
241
- onClick: i2
430
+ color: r,
431
+ title: s,
432
+ onClick: o
242
433
  }) {
243
434
  return /* @__PURE__ */ jsxs(
244
435
  "svg",
245
436
  {
246
437
  xmlns: "http://www.w3.org/2000/svg",
247
- width: t,
248
- height: t,
438
+ width: e,
439
+ height: e,
249
440
  viewBox: "0 0 24 24",
250
441
  fill: "none",
251
- stroke: n || "currentColor",
442
+ stroke: r || "currentColor",
252
443
  strokeWidth: 2,
253
444
  strokeLinecap: "round",
254
445
  strokeLinejoin: "round",
255
- className: `nice-icon ${r || ""}`,
446
+ className: `nice-icon ${t || ""}`,
256
447
  style: a2,
257
- role: o ? "img" : "presentation",
258
- "aria-label": o,
259
- "aria-hidden": !o,
260
- onClick: i2,
448
+ role: o ? "button" : s ? "img" : "presentation",
449
+ tabIndex: o ? 0 : void 0,
450
+ onKeyDown: o ? Et : void 0,
451
+ "aria-label": s,
452
+ "aria-hidden": o ? void 0 : !s,
453
+ onClick: o,
261
454
  children: [
262
- o && /* @__PURE__ */ jsx("title", { children: o }),
263
- /* @__PURE__ */ jsx("path", { d: e })
455
+ s && /* @__PURE__ */ jsx("title", { children: s }),
456
+ /* @__PURE__ */ jsx("path", { d: n })
264
457
  ]
265
458
  }
266
459
  );
267
460
  }
268
- const ae = ({
269
- name: e,
270
- size: t = "md",
271
- className: r,
461
+ const te = ({
462
+ name: n,
463
+ size: e = "md",
464
+ className: t,
272
465
  style: a2,
273
- color: n,
274
- title: o,
275
- onClick: i2
466
+ color: r,
467
+ title: s,
468
+ onClick: o
276
469
  }) => {
277
- const { resolver: s } = useContext(gt), c2 = typeof t == "number" ? t : la[t];
278
- if (s) {
279
- const d = s(e, c2);
280
- if (d)
281
- return /* @__PURE__ */ jsx("span", { className: `nice-icon-wrap ${r || ""}`, style: a2, onClick: i2, children: d });
282
- }
283
- const l = tr[e];
284
- return l ? /* @__PURE__ */ jsx(
285
- da,
470
+ const { resolver: i2 } = useContext(Oe), c2 = typeof e == "number" ? e : Jt[e];
471
+ if (i2) {
472
+ const u = i2(n, c2);
473
+ if (u)
474
+ return /* @__PURE__ */ jsx(
475
+ "span",
476
+ {
477
+ role: o ? "button" : void 0,
478
+ tabIndex: o ? 0 : void 0,
479
+ onKeyDown: o ? Et : void 0,
480
+ className: `nice-icon-wrap ${t || ""}`,
481
+ style: a2,
482
+ onClick: o,
483
+ children: u
484
+ }
485
+ );
486
+ }
487
+ const d = xt[n];
488
+ return d ? /* @__PURE__ */ jsx(
489
+ Zt,
286
490
  {
287
- path: l,
491
+ path: d,
288
492
  size: c2,
289
- className: r,
493
+ className: t,
290
494
  style: a2,
291
- color: n,
292
- title: o,
293
- onClick: i2
495
+ color: r,
496
+ title: s,
497
+ onClick: o
294
498
  }
295
499
  ) : null;
296
500
  };
501
+ const zt = [
502
+ "a[href]",
503
+ "area[href]",
504
+ "button",
505
+ 'input:not([type="hidden"])',
506
+ "select",
507
+ "textarea",
508
+ "summary",
509
+ "iframe",
510
+ "audio[controls]",
511
+ "video[controls]",
512
+ '[contenteditable]:not([contenteditable="false"])',
513
+ "[tabindex]",
514
+ "[data-nice-focusable]"
515
+ ].join(",");
516
+ function J(n) {
517
+ const e = n.getBoundingClientRect();
518
+ return {
519
+ left: e.left,
520
+ top: e.top,
521
+ right: e.right,
522
+ bottom: e.bottom,
523
+ width: e.width,
524
+ height: e.height
525
+ };
526
+ }
527
+ const _e = (n) => n instanceof HTMLButtonElement || n instanceof HTMLInputElement || n instanceof HTMLSelectElement || n instanceof HTMLTextAreaElement;
528
+ function Qt(n) {
529
+ if (_e(n) && n.disabled || n.getAttribute("aria-disabled") === "true" && !n.hasAttribute("data-nice-focusable"))
530
+ return true;
531
+ const e = n.closest("fieldset[disabled]");
532
+ if (e && _e(n)) {
533
+ const t = e.querySelector(":scope > legend");
534
+ return !(t && t.contains(n));
535
+ }
536
+ return false;
537
+ }
538
+ function en(n) {
539
+ var a2;
540
+ if (n.closest("[hidden]"))
541
+ return false;
542
+ const e = n.getBoundingClientRect();
543
+ if (e.width === 0 && e.height === 0) {
544
+ const r = n.ownerDocument.documentElement.getBoundingClientRect();
545
+ if (r.width !== 0 || r.height !== 0)
546
+ return false;
547
+ }
548
+ const t = (a2 = n.ownerDocument.defaultView) == null ? void 0 : a2.getComputedStyle(n);
549
+ return !t || t.display !== "none" && t.visibility !== "hidden" && t.visibility !== "collapse";
550
+ }
551
+ function tn(n) {
552
+ if (!(n instanceof HTMLInputElement) || n.type !== "radio" || !n.name || n.checked)
553
+ return true;
554
+ const t = [...(n.form ?? n.ownerDocument).querySelectorAll('input[type="radio"]')].filter(
555
+ (a2) => a2.name === n.name
556
+ );
557
+ return !t.some((a2) => a2.checked) && t[0] === n;
558
+ }
559
+ function ne(n) {
560
+ if (!(n instanceof HTMLElement) || !n.matches(zt))
561
+ return false;
562
+ if (!n.hasAttribute("data-nice-focusable")) {
563
+ const e = n.getAttribute("tabindex");
564
+ if (e !== null && Number(e) < 0 || n instanceof HTMLAnchorElement && !n.hasAttribute("href") && e === null)
565
+ return false;
566
+ }
567
+ return n.closest('[inert],[aria-hidden="true"]') || Qt(n) ? false : en(n) && tn(n);
568
+ }
569
+ function U(n, e = []) {
570
+ const t = [];
571
+ for (const a2 of n.querySelectorAll(zt))
572
+ e.some((r) => r && r.contains(a2)) || ne(a2) && t.push(a2);
573
+ return t;
574
+ }
575
+ const Be = typeof window > "u" ? useEffect : useLayoutEffect;
576
+ function _(n, e, t) {
577
+ const a2 = useRef({ el: null, deps: [] }), r = useRef(e);
578
+ r.current = e, Be(() => {
579
+ const s = (n == null ? void 0 : n.current) ?? null, o = a2.current;
580
+ s === o.el && t.length === o.deps.length && t.every((c2, d) => Object.is(c2, o.deps[d])) || (typeof o.cleanup == "function" && o.cleanup(), o.el = s, o.deps = [...t], o.cleanup = s ? r.current(s) : void 0);
581
+ }), Be(
582
+ () => () => {
583
+ const s = a2.current;
584
+ typeof s.cleanup == "function" && s.cleanup(), a2.current = { el: null, deps: [] };
585
+ },
586
+ []
587
+ );
588
+ }
589
+ const Ue = {
590
+ "045e": "xbox",
591
+ "054c": "playstation",
592
+ "057e": "nintendo",
593
+ "28de": "steam"
594
+ };
595
+ function on(n) {
596
+ var a2, r, s;
597
+ const e = n.toLowerCase(), t = ((a2 = /vendor:\s*([0-9a-f]{4})/.exec(e)) == null ? void 0 : a2[1]) ?? ((s = (r = /^([0-9a-f]{1,4})-[0-9a-f]{1,4}-/.exec(e)) == null ? void 0 : r[1]) == null ? void 0 : s.padStart(4, "0"));
598
+ return t && Ue[t] ? Ue[t] : /xbox|xinput|x-box/.test(e) ? "xbox" : /dualsense|dualshock|playstation/.test(e) ? "playstation" : /nintendo|pro controller|joy-con|switch/.test(e) ? "nintendo" : /steam|valve/.test(e) ? "steam" : "generic";
599
+ }
600
+ function cn(n, e) {
601
+ return e !== "auto" ? e : n === "nintendo" ? "east" : "south";
602
+ }
603
+ const Ht = ["up", "down", "left", "right"], Ee = {
604
+ navigate: ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"],
605
+ activate: ["Enter", "Space"],
606
+ back: ["Escape"],
607
+ secondary: ["ContextMenu", "Shift+F10"],
608
+ tertiary: [],
609
+ menu: ["Ctrl+K"],
610
+ view: ["F6", "Shift+F6"],
611
+ sectionPrev: ["Ctrl+PageUp"],
612
+ sectionNext: ["Ctrl+PageDown"],
613
+ pagePrev: ["PageUp"],
614
+ pageNext: ["PageDown"],
615
+ first: ["Home"],
616
+ last: ["End"],
617
+ scroll: [],
618
+ toggleHints: ["Shift+?"]
619
+ }, $e = {
620
+ navigate: ["dpadUp", "dpadDown", "dpadLeft", "dpadRight"],
621
+ activate: ["south"],
622
+ back: ["east"],
623
+ secondary: ["west"],
624
+ tertiary: ["north"],
625
+ menu: ["start"],
626
+ view: ["select"],
627
+ sectionPrev: ["leftBumper"],
628
+ sectionNext: ["rightBumper"],
629
+ pagePrev: ["leftTrigger"],
630
+ pageNext: ["rightTrigger"],
631
+ first: [],
632
+ last: [],
633
+ scroll: [],
634
+ toggleHints: ["leftStick"]
635
+ }, Mn = {
636
+ " ": "Space",
637
+ Spacebar: "Space",
638
+ Esc: "Escape",
639
+ Apps: "ContextMenu",
640
+ Up: "ArrowUp",
641
+ Down: "ArrowDown",
642
+ Left: "ArrowLeft",
643
+ Right: "ArrowRight"
644
+ };
645
+ function Ve(n) {
646
+ return Mn[n] ?? n;
647
+ }
648
+ function Nt(n) {
649
+ const e = n.endsWith("++") ? [...n.slice(0, -2).split("+"), "+"] : n.split("+"), t = e.pop() ?? "", a2 = new Set(e.map((r) => r.toLowerCase()));
650
+ return {
651
+ key: Ve(t),
652
+ primary: a2.has("ctrl") || a2.has("cmd") || a2.has("meta") || a2.has("mod"),
653
+ alt: a2.has("alt") || a2.has("option"),
654
+ shift: a2.has("shift")
655
+ };
656
+ }
657
+ const gn = (n) => n.length === 1 && n.toLowerCase() === n.toUpperCase();
658
+ function Tt(n, e) {
659
+ const t = Ve(e.key);
660
+ return !(t.length === 1 ? t.toLowerCase() === n.key.toLowerCase() : t === n.key) || n.primary !== (e.ctrlKey || e.metaKey) || n.alt !== e.altKey ? false : gn(n.key) || n.shift === e.shiftKey;
661
+ }
662
+ function Ye(n) {
663
+ const e = {};
664
+ for (const t of Object.keys(Ee)) {
665
+ const a2 = n.keyboardBindings[t] ?? Ee[t];
666
+ e[t] = a2.map(Nt);
667
+ }
668
+ return e;
669
+ }
670
+ function bn(n, e) {
671
+ for (const t of Object.keys(e)) {
672
+ const a2 = e[t];
673
+ for (let r = 0; r < a2.length; r++)
674
+ if (Tt(a2[r], n))
675
+ return t === "navigate" ? { intent: t, direction: Ht[r] } : t === "view" ? { intent: t, direction: a2[r].shift ? "up" : "down" } : { intent: t };
676
+ }
677
+ return null;
678
+ }
679
+ const yn = /* @__PURE__ */ new Set(["GoBack", "BrowserBack", "XF86Back"]), wn = /* @__PURE__ */ new Set([461, 10009]);
680
+ function En(n) {
681
+ return yn.has(n.key) || wn.has(n.keyCode) ? { intent: "back" } : n.key === "ChannelUp" ? { intent: "sectionNext" } : n.key === "ChannelDown" ? { intent: "sectionPrev" } : null;
682
+ }
683
+ function ke(n, e) {
684
+ const t = cn(e, n.confirmButton), a2 = t === "south" ? "east" : "south", r = {};
685
+ for (const s of Object.keys($e)) {
686
+ const o = n.gamepadBindings[s];
687
+ o ? r[s] = [...o] : s === "activate" ? r[s] = [t] : s === "back" ? r[s] = [a2] : r[s] = [...$e[s]];
688
+ }
689
+ return r;
690
+ }
691
+ function kn(n) {
692
+ const e = /* @__PURE__ */ new Map();
693
+ for (const t of Object.keys(n))
694
+ n[t].forEach((a2, r) => {
695
+ e.has(a2) || e.set(a2, t === "navigate" ? { intent: t, direction: Ht[r] } : { intent: t });
696
+ });
697
+ return e;
698
+ }
699
+ const se = "data-nice-focus-scope", xe = `[${se}]`;
700
+ function Pt(n) {
701
+ const e = n.getAttribute(se), t = n.getAttribute("data-nice-scope-enter");
702
+ return {
703
+ nav: e === "vertical" || e === "horizontal" || e === "grid" || e === "none" ? e : "spatial",
704
+ wrap: n.hasAttribute("data-nice-scope-wrap"),
705
+ trap: n.hasAttribute("data-nice-scope-trap"),
706
+ enter: t === "selected" || t === "first" ? t : "last"
707
+ };
708
+ }
709
+ function We(n, e) {
710
+ var a2;
711
+ const t = (a2 = n.parentElement) == null ? void 0 : a2.closest(xe);
712
+ return t && e.contains(t) && t !== e ? t : e;
713
+ }
714
+ function zn(n) {
715
+ var t, a2;
716
+ const e = [];
717
+ for (let r = (t = n.parentElement) == null ? void 0 : t.closest(xe); r; r = (a2 = r.parentElement) == null ? void 0 : a2.closest(xe))
718
+ e.push(r);
719
+ return e;
720
+ }
721
+ function An(n) {
722
+ var t;
723
+ const e = (t = n.closest("[data-nice-arrows]")) == null ? void 0 : t.getAttribute("data-nice-arrows");
724
+ return e === "spatial" || e === "native" ? e : null;
725
+ }
726
+ const Xe = { horizontal: 30, vertical: 2 }, G = 1, Je = (n) => n === "left" || n === "right", Ze = (n, e, t, a2) => Math.max(0, Math.max(n, t) - Math.min(e, a2));
727
+ function Sn(n, e, t) {
728
+ switch (t) {
729
+ case "right":
730
+ return e.left >= n.right - G;
731
+ case "left":
732
+ return e.right <= n.left + G;
733
+ case "down":
734
+ return e.top >= n.bottom - G;
735
+ default:
736
+ return e.bottom <= n.top + G;
737
+ }
738
+ }
739
+ function Ln(n, e, t) {
740
+ const a2 = n.left + n.width / 2, r = n.top + n.height / 2, s = e.left + e.width / 2, o = e.top + e.height / 2;
741
+ switch (t) {
742
+ case "right":
743
+ return s > a2 + G;
744
+ case "left":
745
+ return s < a2 - G;
746
+ case "down":
747
+ return o > r + G;
748
+ default:
749
+ return o < r - G;
750
+ }
751
+ }
752
+ function Cn(n, e, t) {
753
+ let a2, r, s;
754
+ Je(t) ? (a2 = t === "right" ? e.left - n.right : n.left - e.right, r = Ze(n.top, n.bottom, e.top, e.bottom), s = Math.abs(e.top + e.height / 2 - (n.top + n.height / 2))) : (a2 = t === "down" ? e.top - n.bottom : n.top - e.bottom, r = Ze(n.left, n.right, e.left, e.right), s = Math.abs(e.left + e.width / 2 - (n.left + n.width / 2)));
755
+ const o = Je(t) ? Xe.horizontal : Xe.vertical;
756
+ return Math.max(0, a2) + r * o + s * 0.01;
757
+ }
758
+ function Dt(n, e, t, a2) {
759
+ const r = e.map(t);
760
+ for (const s of [Sn, Ln]) {
761
+ let o = -1, i2 = 1 / 0;
762
+ for (let c2 = 0; c2 < r.length; c2++) {
763
+ if (!s(n, r[c2], a2))
764
+ continue;
765
+ const d = Cn(n, r[c2], a2);
766
+ d < i2 && (i2 = d, o = c2);
767
+ }
768
+ if (o >= 0)
769
+ return e[o];
770
+ }
771
+ return null;
772
+ }
773
+ const de = (n) => n === "left" || n === "right", Hn = (n) => {
774
+ var e;
775
+ return ((e = n.ownerDocument.defaultView) == null ? void 0 : e.getComputedStyle(n).direction) === "rtl";
776
+ };
777
+ function Nn(n, e, t, a2) {
778
+ if (n.length === 0)
779
+ return null;
780
+ const r = (s) => !!(e.compareDocumentPosition(s) & Node.DOCUMENT_POSITION_FOLLOWING);
781
+ if (t)
782
+ return n.find(r) ?? (a2 ? n[0] : null);
783
+ for (let s = n.length - 1; s >= 0; s--)
784
+ if (!r(n[s]))
785
+ return n[s];
786
+ return a2 ? n[n.length - 1] : null;
787
+ }
788
+ const Tn = '[aria-selected="true"],[aria-checked="true"],[aria-current]:not([aria-current="false"]),:checked';
789
+ function Pn(n, e, t) {
790
+ let a2 = null;
791
+ for (let s = n.parentElement; s && !s.contains(e); s = s.parentElement)
792
+ s.hasAttribute(se) && (a2 = s);
793
+ if (!a2)
794
+ return n;
795
+ const r = Pt(a2).enter;
796
+ if (r === "last") {
797
+ const s = t.get(a2);
798
+ return s && s.isConnected && a2.contains(s) && ne(s) ? s : n;
799
+ }
800
+ return r === "selected" ? [...a2.querySelectorAll(Tn)].find(ne) ?? n : U(a2)[0] ?? n;
801
+ }
802
+ function Dn(n, e, t) {
803
+ const a2 = J(n);
804
+ let r = We(n, t.root), s = null;
805
+ for (; ; ) {
806
+ const o = Pt(r);
807
+ if (o.nav === "spatial" || o.nav === "grid" || o.nav === "vertical" && !de(e) || o.nav === "horizontal" && de(e)) {
808
+ const c2 = U(r, [n, s]);
809
+ let d;
810
+ if (o.nav === "vertical" || o.nav === "horizontal") {
811
+ let u = e === "down" || e === "right";
812
+ de(e) && Hn(r) && (u = !u), d = Nn(c2, n, u, o.wrap);
813
+ } else
814
+ d = Dt(a2, c2, J, e);
815
+ if (d)
816
+ return Pn(d, n, t.memory);
817
+ }
818
+ if (r === t.root || o.trap)
819
+ return null;
820
+ s = r, r = We(r, t.root);
821
+ }
822
+ }
823
+ function Qe(n, e) {
824
+ const t = e.left + e.width / 2, a2 = e.top + e.height / 2;
825
+ let r = null, s = 1 / 0;
826
+ for (const o of U(n)) {
827
+ const i2 = J(o), c2 = Math.hypot(i2.left + i2.width / 2 - t, i2.top + i2.height / 2 - a2);
828
+ c2 < s && (s = c2, r = o);
829
+ }
830
+ return r;
831
+ }
832
+ const It = [
833
+ "[data-nice-region]",
834
+ "header",
835
+ "nav",
836
+ "main",
837
+ "aside",
838
+ "footer",
839
+ '[role="banner"]',
840
+ '[role="navigation"]',
841
+ '[role="main"]',
842
+ '[role="complementary"]',
843
+ '[role="contentinfo"]',
844
+ '[role="search"]',
845
+ '[role="region"][aria-label]',
846
+ '[role="region"][aria-labelledby]'
847
+ ].join(",");
848
+ function In(n, e, t) {
849
+ const a2 = [...t.root.querySelectorAll(It)], r = a2.filter(
850
+ (u) => !a2.some((p) => p !== u && p.contains(u)) && U(u).length > 0
851
+ );
852
+ if (r.length === 0)
853
+ return null;
854
+ const s = r.findIndex((u) => u.contains(n)), o = e === "up" || e === "left" ? -1 : 1, i2 = s < 0 ? o > 0 ? -1 : 0 : s, c2 = r[(i2 + o + r.length) % r.length];
855
+ if (c2 === r[s])
856
+ return null;
857
+ const d = t.memory.get(c2);
858
+ return d && d.isConnected && c2.contains(d) && ne(d) ? d : U(c2)[0];
859
+ }
860
+ const he = [
861
+ "south",
862
+ "east",
863
+ "west",
864
+ "north",
865
+ "leftBumper",
866
+ "rightBumper",
867
+ "leftTrigger",
868
+ "rightTrigger",
869
+ "select",
870
+ "start",
871
+ "leftStick",
872
+ "rightStick",
873
+ "dpadUp",
874
+ "dpadDown",
875
+ "dpadLeft",
876
+ "dpadRight",
877
+ "home"
878
+ ], ze = "nice-intent", ae = "nice-engagechange", W = {
879
+ confirmButton: "auto",
880
+ gamepadBindings: {},
881
+ keyboardBindings: {},
882
+ stickThreshold: 0.5,
883
+ stickDeadzone: 0.2,
884
+ invertScroll: false,
885
+ repeatDelay: 400,
886
+ repeatInterval: 110,
887
+ repeatIntervalMin: 50,
888
+ hints: "auto",
889
+ hintDensity: "bar",
890
+ glyphFamily: "auto",
891
+ vibration: false,
892
+ arrowNavigation: "auto",
893
+ onScreenKeyboard: "auto"
894
+ }, On = /* @__PURE__ */ new Set([4, 5, 6, 7, 12, 13, 14, 15]), Rn = 0.85;
895
+ function Vn(n, e) {
896
+ return Math.abs(n) > Math.abs(e) ? n > 0 ? "right" : "left" : e > 0 ? "down" : "up";
897
+ }
898
+ class Fn {
899
+ constructor(e, t) {
900
+ this.states = /* @__PURE__ */ new Map(), this.connected = /* @__PURE__ */ new Set(), this.warned = /* @__PURE__ */ new Set(), this.started = false, this.frameId = 0, this.onConnected = (a2) => {
901
+ const r = a2.gamepad;
902
+ r && this.connected.add(r.index), this.schedule();
903
+ }, this.onDisconnected = (a2) => {
904
+ var s, o;
905
+ const r = a2.gamepad;
906
+ r && (this.connected.delete(r.index), this.states.delete(r.index) && ((o = (s = this.opts).onPadsChange) == null || o.call(s, this.pads))), this.connected.size === 0 && this.cancel();
907
+ }, this.onVisibility = () => {
908
+ this.win.document.hidden ? this.cancel() : this.schedule();
909
+ }, this.frame = (a2) => {
910
+ this.frameId = 0, this.poll(a2), this.schedule();
911
+ }, this.win = e, this.opts = t;
912
+ }
913
+ /** Whether an animation frame is scheduled (false without a pad or on a hidden page). */
914
+ get running() {
915
+ return this.frameId !== 0;
916
+ }
917
+ get pads() {
918
+ return [...this.states.values()].map((e) => e.info);
919
+ }
920
+ start() {
921
+ if (!this.started) {
922
+ this.started = true, this.win.addEventListener("gamepadconnected", this.onConnected), this.win.addEventListener("gamepaddisconnected", this.onDisconnected), this.win.document.addEventListener("visibilitychange", this.onVisibility);
923
+ for (const e of this.read())
924
+ this.connected.add(e.index);
925
+ this.schedule();
926
+ }
927
+ }
928
+ stop() {
929
+ this.started && (this.started = false, this.win.removeEventListener("gamepadconnected", this.onConnected), this.win.removeEventListener("gamepaddisconnected", this.onDisconnected), this.win.document.removeEventListener("visibilitychange", this.onVisibility), this.cancel(), this.connected.clear(), this.states.clear());
930
+ }
931
+ /** Read every pad once; public so tests can drive a frame. */
932
+ poll(e) {
933
+ var o, i2, c2, d, u, p;
934
+ const t = this.opts.timing(), a2 = /* @__PURE__ */ new Set(), r = this.read();
935
+ for (const l of r) {
936
+ a2.add(l.index);
937
+ let v2 = this.states.get(l.index);
938
+ (!v2 || v2.info.id !== l.id) && (v2 = {
939
+ info: {
940
+ index: l.index,
941
+ id: l.id,
942
+ family: on(l.id),
943
+ mapping: l.mapping
944
+ },
945
+ pressed: [],
946
+ stick: null,
947
+ holds: /* @__PURE__ */ new Map()
948
+ }, this.states.set(l.index, v2), this.warnMapping(l), (i2 = (o = this.opts).onPadsChange) == null || i2.call(o, this.pads)), this.readButtons(v2, l, e, t), this.readSticks(v2, l, e, t);
949
+ }
950
+ let s = false;
951
+ for (const l of [...this.states.keys()])
952
+ a2.has(l) || (this.states.delete(l), s = true);
953
+ s && ((d = (c2 = this.opts).onPadsChange) == null || d.call(c2, this.pads)), (p = (u = this.opts).onFrame) == null || p.call(u, r, e);
954
+ }
955
+ readButtons(e, t, a2, r) {
956
+ for (let s = 0; s < he.length; s++) {
957
+ const o = t.buttons[s], i2 = !!(o && (o.pressed || o.value > 0.5)), c2 = `b${s}`;
958
+ i2 !== !!e.pressed[s] ? (e.pressed[s] = i2, i2 && On.has(s) ? e.holds.set(c2, { since: a2, last: a2, count: 0 }) : e.holds.delete(c2), this.opts.onButton({
959
+ pad: e.info,
960
+ button: he[s],
961
+ pressed: i2,
962
+ repeat: false
963
+ })) : i2 && this.repeats(e, c2, a2, r) && this.opts.onButton({
964
+ pad: e.info,
965
+ button: he[s],
966
+ pressed: i2,
967
+ repeat: true
968
+ });
969
+ }
970
+ }
971
+ readSticks(e, t, a2, r) {
972
+ const s = t.axes[0] ?? 0, o = t.axes[1] ?? 0, i2 = Math.hypot(s, o);
973
+ if (i2 >= r.stickThreshold) {
974
+ const p = Vn(s, o);
975
+ p !== e.stick ? (e.stick = p, e.holds.set("stick", { since: a2, last: a2, count: 0 }), this.opts.onStick({ pad: e.info, direction: p, repeat: false })) : this.repeats(e, "stick", a2, r) && this.opts.onStick({ pad: e.info, direction: p, repeat: true });
976
+ } else e.stick && i2 < r.stickThreshold * 0.7 && (e.stick = null, e.holds.delete("stick"));
977
+ const c2 = t.axes[2] ?? 0, d = t.axes[3] ?? 0, u = Math.hypot(c2, d);
978
+ if (u > r.stickDeadzone) {
979
+ const p = (u - r.stickDeadzone) / (1 - r.stickDeadzone) / u;
980
+ this.opts.onScroll({ pad: e.info, x: c2 * p, y: d * p });
981
+ }
982
+ }
983
+ repeats(e, t, a2, r) {
984
+ const s = e.holds.get(t);
985
+ if (!s || a2 - s.since < r.repeatDelay)
986
+ return false;
987
+ const o = Math.max(
988
+ r.repeatIntervalMin,
989
+ r.repeatInterval * Rn ** s.count
990
+ );
991
+ return a2 - s.last < o ? false : (s.last = a2, s.count++, true);
992
+ }
993
+ read() {
994
+ var a2, r;
995
+ const e = ((r = (a2 = this.win.navigator).getGamepads) == null ? void 0 : r.call(a2)) ?? [], t = [];
996
+ for (const s of e)
997
+ s && s.connected !== false && t.push(s);
998
+ return t;
999
+ }
1000
+ warnMapping(e) {
1001
+ e.mapping === "standard" || this.warned.has(e.id) || (this.warned.add(e.id), process.env.NODE_ENV !== "production" && console.warn(
1002
+ `[nice2dev/input] "${e.id}" has no standard mapping; its buttons are read by standard positions and may be off.`
1003
+ ));
1004
+ }
1005
+ schedule() {
1006
+ this.frameId === 0 && this.started && this.connected.size > 0 && !this.win.document.hidden && typeof this.win.requestAnimationFrame == "function" && (this.frameId = this.win.requestAnimationFrame(this.frame));
1007
+ }
1008
+ cancel() {
1009
+ this.frameId !== 0 && (this.win.cancelAnimationFrame(this.frameId), this.frameId = 0);
1010
+ }
1011
+ }
1012
+ const _n = {
1013
+ up: "ArrowUp",
1014
+ down: "ArrowDown",
1015
+ left: "ArrowLeft",
1016
+ right: "ArrowRight"
1017
+ }, et = {
1018
+ ArrowUp: 38,
1019
+ ArrowDown: 40,
1020
+ ArrowLeft: 37,
1021
+ ArrowRight: 39,
1022
+ Enter: 13,
1023
+ Escape: 27,
1024
+ Home: 36,
1025
+ End: 35,
1026
+ PageUp: 33,
1027
+ PageDown: 34
1028
+ }, tt = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta", "AltGraph", "OS"]), Bn = /Web0S|webOS|Tizen|SMART-TV|SmartTV|HbbTV|NetCast|Android TV|AFT|BRAVIA|CrKey/i, nt = 18, at = (n) => n === "keyboard" || n === "gamepad" || n === "remote";
1029
+ class Kn {
1030
+ constructor(e) {
1031
+ this.started = false, this.listeners = /* @__PURE__ */ new Set(), this.frameListeners = /* @__PURE__ */ new Set(), this.padMaps = /* @__PURE__ */ new Map(), this.memory = /* @__PURE__ */ new WeakMap(), this.engagedValues = /* @__PURE__ */ new WeakMap(), this.overlays = [], this.hintsToggled = false, this.activePad = null, this.lastFocus = null, this.observer = null, this.live = null, this.snapshot = [], this.capture = null, this.translate = (t, a2) => a2, this.onKeyDown = (t) => {
1032
+ if (t.niceSource)
1033
+ return;
1034
+ const a2 = En(t), r = this.tv || a2 ? "remote" : "keyboard";
1035
+ if (tt.has(t.key) || this.setMethod(r), this.capture && !tt.has(t.key)) {
1036
+ t.preventDefault();
1037
+ const c2 = [
1038
+ t.ctrlKey || t.metaKey ? "Ctrl" : "",
1039
+ t.altKey ? "Alt" : "",
1040
+ t.shiftKey ? "Shift" : ""
1041
+ ], d = Ve(t.key);
1042
+ this.capture({
1043
+ keys: [...c2, d.length === 1 ? d.toUpperCase() : d].filter(Boolean).join("+")
1044
+ });
1045
+ return;
1046
+ }
1047
+ if (t.defaultPrevented || t.isComposing)
1048
+ return;
1049
+ const s = a2 ?? bn(t, this.keyTable);
1050
+ if (!s)
1051
+ return;
1052
+ const o = this.targetOf(t);
1053
+ if (qt(o, s))
1054
+ return;
1055
+ const i2 = {
1056
+ intent: s.intent,
1057
+ direction: s.direction,
1058
+ source: r,
1059
+ repeat: t.repeat,
1060
+ keyEvent: t
1061
+ };
1062
+ (this.dispatchIntent(i2, o) || this.keyDefault(i2, o)) && t.preventDefault();
1063
+ }, this.onPadButton = (t) => {
1064
+ if (this.activePad = t.pad, this.setMethod("gamepad", t.pad.family), !t.pressed)
1065
+ return;
1066
+ if (this.capture) {
1067
+ t.repeat || this.capture({ button: t.button });
1068
+ return;
1069
+ }
1070
+ const a2 = this.padMap(t.pad.family).get(t.button);
1071
+ a2 && this.deviceIntent({ ...a2, source: "gamepad", repeat: t.repeat, gamepad: t.pad });
1072
+ }, this.onPadStick = (t) => {
1073
+ this.activePad = t.pad, this.setMethod("gamepad", t.pad.family), !this.capture && this.deviceIntent({
1074
+ intent: "navigate",
1075
+ direction: t.direction,
1076
+ source: "gamepad",
1077
+ repeat: t.repeat,
1078
+ gamepad: t.pad
1079
+ });
1080
+ }, this.onPadScroll = (t) => {
1081
+ this.activePad = t.pad, this.setMethod("gamepad", t.pad.family);
1082
+ const a2 = this.state.preferences.invertScroll ? -1 : 1, r = t.x * a2, s = t.y * a2, o = this.focused(), i2 = {
1083
+ intent: "scroll",
1084
+ direction: Math.abs(r) > Math.abs(s) ? r > 0 ? "right" : "left" : s > 0 ? "down" : "up",
1085
+ amount: Math.min(1, Math.hypot(r, s)),
1086
+ source: "gamepad",
1087
+ repeat: true,
1088
+ gamepad: t.pad
1089
+ };
1090
+ this.dispatchIntent(i2, o) || rt(st(o, r, s), r * nt, s * nt);
1091
+ }, this.onPointerDown = (t) => {
1092
+ this.setMethod(t.pointerType === "touch" ? "touch" : "pointer");
1093
+ }, this.onFocusIn = (t) => {
1094
+ const a2 = t.target;
1095
+ if (a2 instanceof HTMLElement) {
1096
+ for (let r = a2.parentElement; r; r = r.parentElement)
1097
+ (r.hasAttribute(se) || r.matches(It) || r === this.doc.body) && this.memory.set(r, a2);
1098
+ this.lastFocus = { el: a2, rect: J(a2), scope: zn(a2)[0] ?? null };
1099
+ }
1100
+ }, this.onFocusOut = (t) => {
1101
+ const a2 = t.target;
1102
+ a2 instanceof HTMLElement && a2.hasAttribute("data-nice-engaged") && this.release(a2, this.state.method === "gamepad" ? "gamepad" : "keyboard", false);
1103
+ }, this.recover = () => {
1104
+ const t = this.lastFocus;
1105
+ if (!t || t.el.isConnected)
1106
+ return;
1107
+ this.lastFocus = null;
1108
+ const a2 = this.doc.activeElement;
1109
+ if (a2 && a2 !== this.doc.body)
1110
+ return;
1111
+ const r = this.navigationRoot(), s = t.scope && t.scope.isConnected && r.contains(t.scope) ? t.scope : r, o = Qe(s, t.rect) ?? (s !== r ? Qe(r, t.rect) : null);
1112
+ o && this.focusElement(o);
1113
+ }, this.win = e, this.doc = e.document, this.tv = Bn.test(e.navigator.userAgent), this.keyTable = Ye(W), this.state = {
1114
+ method: "pointer",
1115
+ family: null,
1116
+ pads: [],
1117
+ preferences: W,
1118
+ hintsVisible: W.hints === "always"
1119
+ }, this.poller = new Fn(e, {
1120
+ timing: () => this.state.preferences,
1121
+ onButton: this.onPadButton,
1122
+ onStick: this.onPadStick,
1123
+ onScroll: this.onPadScroll,
1124
+ onPadsChange: (t) => {
1125
+ t.length === 0 && (this.snapshot = []), this.update({ pads: t });
1126
+ },
1127
+ onFrame: (t, a2) => {
1128
+ this.snapshot = t, this.frameListeners.forEach((r) => r(t, a2));
1129
+ }
1130
+ });
1131
+ }
1132
+ /* ── Lifecycle ───────────────────────────────────────────────── */
1133
+ get isStarted() {
1134
+ return this.started;
1135
+ }
1136
+ /** Whether the page runs in a TV browser (webOS, Tizen, Android TV, …): remote and 10-foot. */
1137
+ get isTv() {
1138
+ return this.tv;
1139
+ }
1140
+ start() {
1141
+ this.started || (this.started = true, this.tv && !this.doc.documentElement.hasAttribute("data-nice-tv") && this.doc.documentElement.setAttribute("data-nice-tv", "auto"), this.win.addEventListener("keydown", this.onKeyDown), this.win.addEventListener("pointerdown", this.onPointerDown, { capture: true, passive: true }), this.doc.addEventListener("focusin", this.onFocusIn), this.doc.addEventListener("focusout", this.onFocusOut), this.poller.start());
1142
+ }
1143
+ stop() {
1144
+ this.started && (this.started = false, this.win.removeEventListener("keydown", this.onKeyDown), this.win.removeEventListener("pointerdown", this.onPointerDown, { capture: true }), this.doc.removeEventListener("focusin", this.onFocusIn), this.doc.removeEventListener("focusout", this.onFocusOut), this.poller.stop(), this.watchRecovery(false));
1145
+ }
1146
+ /** Whether the gamepad loop is scheduled (false without a pad). */
1147
+ get polling() {
1148
+ return this.poller.running;
1149
+ }
1150
+ /* ── State ───────────────────────────────────────────────────── */
1151
+ /** Same object until something changes (fit for `useSyncExternalStore`). */
1152
+ getState() {
1153
+ return this.state;
1154
+ }
1155
+ subscribe(e) {
1156
+ return this.listeners.add(e), () => this.listeners.delete(e);
1157
+ }
1158
+ setPreferences(e) {
1159
+ const t = { ...this.state.preferences, ...e };
1160
+ this.keyTable = Ye(t), this.padMaps.clear(), this.update({ preferences: t });
1161
+ }
1162
+ /** Words of announcements and labels; the React provider passes the app's translator. */
1163
+ setTranslator(e) {
1164
+ this.translate = e;
1165
+ }
1166
+ /** Pad family of the prompts: the preference, else the pad used last. */
1167
+ get glyphFamily() {
1168
+ const e = this.state.preferences.glyphFamily;
1169
+ return e !== "auto" ? e : this.state.family ?? "xbox";
1170
+ }
1171
+ /** The buttons bound to an intent on a pad of the family (for prompts). */
1172
+ gamepadBinding(e, t = this.glyphFamily) {
1173
+ return ke(this.state.preferences, t)[e];
1174
+ }
1175
+ /** The keys bound to an intent (for prompts), as written in the preferences. */
1176
+ keyboardBinding(e) {
1177
+ return this.keyTable[e];
1178
+ }
1179
+ toggleHints() {
1180
+ this.hintsToggled = !this.hintsToggled, this.update({});
1181
+ }
1182
+ /**
1183
+ * Hands the next pad button or key press to `onInput` instead of acting on it (a bindings
1184
+ * screen); returns what cancels the capture.
1185
+ */
1186
+ captureNextInput(e) {
1187
+ const t = (a2) => {
1188
+ this.capture = null, e(a2);
1189
+ };
1190
+ return this.capture = t, () => {
1191
+ this.capture === t && (this.capture = null);
1192
+ };
1193
+ }
1194
+ update(e) {
1195
+ const t = { ...this.state, ...e }, { hints: a2 } = t.preferences;
1196
+ let r = a2 === "always" ? true : a2 === "never" ? false : at(t.method);
1197
+ this.hintsToggled && (r = !r), t.hintsVisible = r, this.state = t, this.listeners.forEach((s) => s());
1198
+ }
1199
+ setMethod(e, t) {
1200
+ const a2 = this.doc.documentElement;
1201
+ t && a2.getAttribute("data-nice-gamepad") !== t && a2.setAttribute("data-nice-gamepad", t), !(e === this.state.method && (t === void 0 || t === this.state.family)) && (a2.setAttribute("data-nice-input", e), this.watchRecovery(at(e)), this.update(t ? { method: e, family: t } : { method: e }));
1202
+ }
1203
+ /* ── Gamepad frames (games, device testers) ──────────────────── */
1204
+ /** Raw pads every polled frame while a pad is connected. */
1205
+ subscribeGamepadFrames(e) {
1206
+ return this.frameListeners.add(e), () => this.frameListeners.delete(e);
1207
+ }
1208
+ /**
1209
+ * The pads as read in the last polled frame — empty without a pad. For code that runs its own
1210
+ * animation loop (games, particle effects) instead of a second `getGamepads()` reader.
1211
+ */
1212
+ get gamepadSnapshot() {
1213
+ return this.snapshot;
1214
+ }
1215
+ /** Feedback rumble on the pad used last, when the user allows vibration. */
1216
+ vibrate(e, t = 0.5) {
1217
+ this.state.preferences.vibration && this.activePad && this.rumble(this.activePad.index, e, t, t);
1218
+ }
1219
+ /** Rumble a given pad regardless of the preference (a game's own effect). */
1220
+ rumble(e, t, a2 = 0.5, r = 0.5) {
1221
+ var i2, c2, d;
1222
+ const s = (c2 = (i2 = this.win.navigator).getGamepads) == null ? void 0 : c2.call(i2)[e], o = s == null ? void 0 : s.vibrationActuator;
1223
+ (d = o == null ? void 0 : o.playEffect) == null || d.call(o, "dual-rumble", {
1224
+ startDelay: 0,
1225
+ duration: t,
1226
+ weakMagnitude: a2,
1227
+ strongMagnitude: r
1228
+ });
1229
+ }
1230
+ /* ── Overlays ────────────────────────────────────────────────── */
1231
+ /** Puts an overlay on the stack; returns what takes it off. */
1232
+ pushOverlay(e) {
1233
+ return this.overlays.push(e), () => {
1234
+ const t = this.overlays.lastIndexOf(e);
1235
+ t >= 0 && this.overlays.splice(t, 1);
1236
+ };
1237
+ }
1238
+ topOverlay() {
1239
+ return this.overlays[this.overlays.length - 1];
1240
+ }
1241
+ /** Closes the top overlay that can be closed; returns whether one was. */
1242
+ closeTopOverlay(e) {
1243
+ for (let t = this.overlays.length - 1; t >= 0; t--) {
1244
+ const a2 = this.overlays[t];
1245
+ if (a2.onClose)
1246
+ return a2.onClose(e), true;
1247
+ if (a2.modal)
1248
+ return false;
1249
+ }
1250
+ return false;
1251
+ }
1252
+ /* ── Intents ─────────────────────────────────────────────────── */
1253
+ /** Dispatches `nice-intent` on the target; returns whether a handler consumed it. */
1254
+ dispatchIntent(e, t = this.focused()) {
1255
+ const a2 = new CustomEvent(ze, {
1256
+ detail: e,
1257
+ bubbles: true,
1258
+ cancelable: true,
1259
+ composed: true
1260
+ });
1261
+ return t.dispatchEvent(a2), a2.defaultPrevented;
1262
+ }
1263
+ /** Moves focus in a direction through the scope tree; returns whether it moved. */
1264
+ moveFocus(e, t = this.focused()) {
1265
+ const a2 = this.navigationRoot();
1266
+ if (t === this.doc.body || !a2.contains(t))
1267
+ return this.focusInitial(a2);
1268
+ const r = Dn(t, e, { root: a2, memory: this.memory });
1269
+ return r ? (this.focusElement(r), true) : false;
1270
+ }
1271
+ /** The `view` intent: next (`down`) or previous (`up`) region. */
1272
+ focusRegion(e, t = this.focused()) {
1273
+ const a2 = In(t, e, {
1274
+ root: this.navigationRoot(),
1275
+ memory: this.memory
1276
+ });
1277
+ return a2 ? (this.focusElement(a2), true) : false;
1278
+ }
1279
+ /** Focuses the element and brings it into view (scroll-padding respected). */
1280
+ focusElement(e) {
1281
+ var t;
1282
+ e.focus({ preventScroll: true, focusVisible: true }), (t = e.scrollIntoView) == null || t.call(e, { block: "nearest", inline: "nearest" });
1283
+ }
1284
+ /** Engages a control (ADR-005 § 6); popup controls open instead. */
1285
+ engage(e, t, a2 = me(e)) {
1286
+ if (a2) {
1287
+ if (a2 === "popup") {
1288
+ this.emulateKey(e, "ArrowDown", t);
1289
+ return;
1290
+ }
1291
+ e.setAttribute("data-nice-engaged", ""), be(e) && this.engagedValues.set(e, e.value), this.fireEngage(e, { engaged: true, cancelled: false, source: t }), this.announce(this.translate("input.engaged", "Editing"));
1292
+ }
1293
+ }
1294
+ /**
1295
+ * Releases an engaged control; `cancelled` when left with `back`. A native number field gets
1296
+ * its value from before back; custom controls do that in `useEngage`'s `onRelease`.
1297
+ */
1298
+ release(e, t, a2) {
1299
+ if (!e.hasAttribute("data-nice-engaged"))
1300
+ return;
1301
+ e.removeAttribute("data-nice-engaged");
1302
+ const r = this.engagedValues.get(e);
1303
+ this.engagedValues.delete(e), a2 && r !== void 0 && be(e) && Wt(e, r), this.fireEngage(e, { engaged: false, cancelled: a2, source: t }), this.announce(this.translate("input.released", "Done editing"));
1304
+ }
1305
+ /** Defaults of trusted keys: the browser already clicks, types and scrolls. */
1306
+ keyDefault(e, t) {
1307
+ switch (e.intent) {
1308
+ case "navigate":
1309
+ return this.arrowPolicy(t, e.source) === "spatial" ? this.moveFocus(e.direction ?? "down", t) : false;
1310
+ case "view":
1311
+ return this.focusRegion(e.direction ?? "down", t);
1312
+ case "back":
1313
+ return this.closeTopOverlay(e.source);
1314
+ case "toggleHints":
1315
+ return this.toggleHints(), true;
1316
+ default:
1317
+ return false;
1318
+ }
1319
+ }
1320
+ arrowPolicy(e, t) {
1321
+ if (t !== "keyboard")
1322
+ return "spatial";
1323
+ const a2 = this.state.preferences.arrowNavigation;
1324
+ return a2 !== "auto" ? a2 : An(e) ?? "native";
1325
+ }
1326
+ /* ── Gamepad ─────────────────────────────────────────────────── */
1327
+ padMap(e) {
1328
+ let t = this.padMaps.get(e);
1329
+ return t || (t = kn(ke(this.state.preferences, e)), this.padMaps.set(e, t)), t;
1330
+ }
1331
+ /** A pad intent: the intent event, then engage rules, key emulation and the default action. */
1332
+ deviceIntent(e) {
1333
+ const t = this.focused();
1334
+ if (this.dispatchIntent(e, t))
1335
+ return;
1336
+ const a2 = t === this.doc.body ? null : me(t), r = a2 !== null && kt(t, a2), s = t, o = e.source;
1337
+ switch (e.intent) {
1338
+ case "navigate": {
1339
+ const i2 = e.direction ?? "down";
1340
+ a2 && !r ? this.moveFocus(i2, t) : r && ce(t) ? le(t, i2) : r && a2 === "text" ? Xt(t, i2) : this.emulateKey(t, _n[i2], o) || this.moveFocus(i2, t);
1341
+ return;
1342
+ }
1343
+ case "activate":
1344
+ a2 && !r ? this.engage(s, o, a2) : r && a2 === "popup" ? this.emulateKey(t, "Enter", o) : r && (a2 === "value" || a2 === "canvas") ? this.release(s, o, false) : r || (wt(t) ? $t(t) : this.emulateKey(t, "Enter", o));
1345
+ return;
1346
+ case "back":
1347
+ r && a2 === "popup" ? this.emulateKey(t, "Escape", o) : r ? this.release(s, o, true) : this.emulateKey(t, "Escape", o) || this.closeTopOverlay(o);
1348
+ return;
1349
+ case "sectionPrev":
1350
+ case "sectionNext":
1351
+ if (r && a2 === "value") {
1352
+ const i2 = e.intent === "sectionNext";
1353
+ ce(t) ? le(t, i2 ? "up" : "down", "big") : this.emulateKey(t, i2 ? "PageUp" : "PageDown", o);
1354
+ }
1355
+ return;
1356
+ case "pagePrev":
1357
+ case "pageNext": {
1358
+ const i2 = e.intent === "pageNext";
1359
+ if (r && a2 === "value")
1360
+ ce(t) ? le(t, i2 ? "up" : "down", "edge") : this.emulateKey(t, i2 ? "End" : "Home", o);
1361
+ else if (!this.emulateKey(t, i2 ? "PageDown" : "PageUp", o)) {
1362
+ const c2 = st(t, 0, i2 ? 1 : -1);
1363
+ rt(c2, 0, (i2 ? 1 : -1) * ((c2 == null ? void 0 : c2.clientHeight) ?? 0) * 0.9);
1364
+ }
1365
+ return;
1366
+ }
1367
+ case "first":
1368
+ case "last":
1369
+ this.emulateKey(t, e.intent === "first" ? "Home" : "End", o);
1370
+ return;
1371
+ case "secondary":
1372
+ this.contextMenu(t);
1373
+ return;
1374
+ case "menu":
1375
+ r && a2 === "text" && (this.release(s, o, false), this.emulateKey(t, "Enter", o));
1376
+ return;
1377
+ case "view":
1378
+ this.focusRegion(e.direction ?? "down", t);
1379
+ return;
1380
+ case "toggleHints":
1381
+ this.toggleHints();
1382
+ return;
1383
+ default:
1384
+ return;
1385
+ }
1386
+ }
1387
+ /** A synthetic key on the element; returns whether a handler consumed it. */
1388
+ emulateKey(e, t, a2) {
1389
+ const r = (o) => {
1390
+ const i2 = new KeyboardEvent(o, {
1391
+ key: t,
1392
+ code: t,
1393
+ bubbles: true,
1394
+ cancelable: true,
1395
+ composed: true
1396
+ });
1397
+ return Object.defineProperty(i2, "niceSource", { value: a2 }), Object.defineProperty(i2, "keyCode", { value: et[t] ?? 0 }), Object.defineProperty(i2, "which", { value: et[t] ?? 0 }), i2;
1398
+ }, s = r("keydown");
1399
+ return e.dispatchEvent(s), e.dispatchEvent(r("keyup")), s.defaultPrevented;
1400
+ }
1401
+ /** `secondary` on a pad: the context menu of the element, as a right click would open it. */
1402
+ contextMenu(e) {
1403
+ const t = e.getBoundingClientRect();
1404
+ e.dispatchEvent(
1405
+ new MouseEvent("contextmenu", {
1406
+ bubbles: true,
1407
+ cancelable: true,
1408
+ button: 2,
1409
+ clientX: t.left + t.width / 2,
1410
+ clientY: t.top + t.height / 2
1411
+ })
1412
+ );
1413
+ }
1414
+ watchRecovery(e) {
1415
+ e && !this.observer && typeof MutationObserver < "u" && this.doc.body ? (this.observer = new MutationObserver(this.recover), this.observer.observe(this.doc.body, { childList: true, subtree: true })) : !e && this.observer && (this.observer.disconnect(), this.observer = null);
1416
+ }
1417
+ /* ── Helpers ─────────────────────────────────────────────────── */
1418
+ focused() {
1419
+ const e = this.doc.activeElement;
1420
+ return e && e !== this.doc.documentElement ? e : this.doc.body;
1421
+ }
1422
+ targetOf(e) {
1423
+ var a2;
1424
+ const t = (a2 = e.composedPath) == null ? void 0 : a2.call(e)[0];
1425
+ return t instanceof Element ? t : e.target instanceof Element ? e.target : this.focused();
1426
+ }
1427
+ /** Moves stay inside the top modal overlay. */
1428
+ navigationRoot() {
1429
+ for (let e = this.overlays.length - 1; e >= 0; e--)
1430
+ if (this.overlays[e].modal && this.overlays[e].element.isConnected)
1431
+ return this.overlays[e].element;
1432
+ return this.doc.body;
1433
+ }
1434
+ /** Nothing focused yet: the remembered element, else the first one of the main region. */
1435
+ focusInitial(e) {
1436
+ const t = this.memory.get(e), a2 = e.querySelector('main,[role="main"]'), r = (t && t.isConnected && e.contains(t) && ne(t) ? t : null) ?? (a2 ? U(a2)[0] : void 0) ?? U(e)[0];
1437
+ return r ? (this.focusElement(r), true) : false;
1438
+ }
1439
+ fireEngage(e, t) {
1440
+ e.dispatchEvent(new CustomEvent(ae, { detail: t, bubbles: true }));
1441
+ }
1442
+ /** Polite announcement through the engine's own live region. */
1443
+ announce(e) {
1444
+ if (!this.live || !this.live.isConnected) {
1445
+ const t = this.doc.createElement("div");
1446
+ t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite"), t.setAttribute("data-nice-input-live", ""), t.style.cssText = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0", this.doc.body.appendChild(t), this.live = t;
1447
+ }
1448
+ this.live.textContent = e;
1449
+ }
1450
+ }
1451
+ function rt(n, e, t) {
1452
+ n && (typeof n.scrollBy == "function" ? n.scrollBy({ left: e, top: t }) : (n.scrollLeft += e, n.scrollTop += t));
1453
+ }
1454
+ function st(n, e, t) {
1455
+ const a2 = n.ownerDocument, r = a2.defaultView;
1456
+ for (let s = n; s && s !== a2.body; s = s.parentElement) {
1457
+ if (!(s instanceof HTMLElement) || !r)
1458
+ continue;
1459
+ const o = r.getComputedStyle(s), i2 = /(auto|scroll)/.test(o.overflowY) && s.scrollHeight > s.clientHeight, c2 = /(auto|scroll)/.test(o.overflowX) && s.scrollWidth > s.clientWidth;
1460
+ if (t !== 0 && i2 || e !== 0 && c2)
1461
+ return s;
1462
+ }
1463
+ return a2.scrollingElement ?? a2.documentElement;
1464
+ }
1465
+ const ot = /* @__PURE__ */ new WeakMap();
1466
+ function jn(n = window, e = true) {
1467
+ let t = ot.get(n);
1468
+ return t || (t = new Kn(n), ot.set(n, t)), e && t.start(), t;
1469
+ }
1470
+ function B() {
1471
+ const [n] = useState(
1472
+ () => typeof window > "u" ? null : jn(window, false)
1473
+ );
1474
+ return useEffect(() => {
1475
+ n == null || n.start();
1476
+ }, [n]), n;
1477
+ }
1478
+ const da = '[role="row"],tr', ha = '[role="gridcell"],[role="columnheader"],[role="rowheader"],td,th', fa = 'button:not([disabled]),a[href],input:not([disabled]):not([type="hidden"]),select:not([disabled]),textarea:not([disabled])', pa = 'textarea,select,input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"])';
1479
+ function Xa(n, e = {}) {
1480
+ const { rowSelector: t = da, cellSelector: a2 = ha, pageSize: r = 10, enabled: s = true } = e, o = useRef(e);
1481
+ o.current = e;
1482
+ const i2 = B();
1483
+ _(
1484
+ n,
1485
+ (c2) => {
1486
+ if (!s)
1487
+ return;
1488
+ const d = c2.ownerDocument, u = (g) => {
1489
+ var S;
1490
+ return !!g && g.matches(t) && ((S = g.parentElement) == null ? void 0 : S.closest('[role="grid"],[role="treegrid"]')) === c2;
1491
+ }, p = () => [...c2.querySelectorAll(t)].filter(u), l = (g) => [...g.children].filter((S) => S.matches(a2)), v2 = (g) => {
1492
+ const S = g.querySelectorAll(fa);
1493
+ return S.length === 1 ? S[0] : g;
1494
+ }, y = () => p().flatMap((g) => l(g).map(v2)), k = (g) => {
1495
+ const S = (g == null ? void 0 : g.closest(a2)) ?? null;
1496
+ return S && u(S.parentElement) ? S : null;
1497
+ }, E = () => {
1498
+ const g = y();
1499
+ if (g.length === 0)
1500
+ return;
1501
+ const S = d.activeElement, N = g.find((w) => w === S || w.contains(S)) ?? g.find((w) => w.getAttribute("tabindex") === "0") ?? g[0];
1502
+ for (const w of g) {
1503
+ const b = w === N ? "0" : "-1";
1504
+ w.getAttribute("tabindex") !== b && w.setAttribute("tabindex", b);
1505
+ }
1506
+ }, H = (g, S, N) => {
1507
+ var b, T;
1508
+ const w = v2(g);
1509
+ for (const f of y())
1510
+ f.setAttribute("tabindex", f === w ? "0" : "-1");
1511
+ i2 ? i2.focusElement(w) : w.focus(), (T = (b = o.current).onMove) == null || T.call(b, g, S, N);
1512
+ }, x = (g) => {
1513
+ var D;
1514
+ if (g.defaultPrevented || g.altKey || g.metaKey)
1515
+ return;
1516
+ const S = g.target, N = k(S);
1517
+ if (!N || v2(N) !== S || S !== N && S.matches(pa))
1518
+ return;
1519
+ const w = p(), b = w.indexOf(N.parentElement), T = l(w[b]).indexOf(N), f = (L, P) => {
1520
+ const I = w[L] ? l(w[L]) : [];
1521
+ if (I.length === 0)
1522
+ return null;
1523
+ const $ = Math.min(P, I.length - 1);
1524
+ return [I[$], L, $];
1525
+ };
1526
+ let h = null;
1527
+ const A = ((D = d.defaultView) == null ? void 0 : D.getComputedStyle(c2).direction) === "rtl", m = A && g.key === "ArrowLeft" ? "ArrowRight" : A && g.key === "ArrowRight" ? "ArrowLeft" : g.key;
1528
+ if (g.ctrlKey && (m === "Home" || m === "End"))
1529
+ h = m === "Home" ? f(0, 0) : f(w.length - 1, Number.MAX_SAFE_INTEGER);
1530
+ else {
1531
+ if (g.ctrlKey)
1532
+ return;
1533
+ if (m === "ArrowRight")
1534
+ h = T + 1 < l(w[b]).length ? f(b, T + 1) : null;
1535
+ else if (m === "ArrowLeft")
1536
+ h = T > 0 ? f(b, T - 1) : null;
1537
+ else if (m === "ArrowDown")
1538
+ h = b + 1 < w.length ? f(b + 1, T) : null;
1539
+ else if (m === "ArrowUp")
1540
+ h = b > 0 ? f(b - 1, T) : null;
1541
+ else if (m === "Home")
1542
+ h = f(b, 0);
1543
+ else if (m === "End")
1544
+ h = f(b, Number.MAX_SAFE_INTEGER);
1545
+ else if (m === "PageDown" || m === "PageUp") {
1546
+ const L = m === "PageDown" ? Math.min(w.length - 1, b + r) : Math.max(0, b - r);
1547
+ h = L !== b ? f(L, T) : null;
1548
+ } else if ((m === "Enter" || m === " ") && S === N && !N.matches("button,a[href]")) {
1549
+ g.preventDefault(), N.click();
1550
+ return;
1551
+ } else
1552
+ return;
1553
+ }
1554
+ h && h[0] !== N && (g.preventDefault(), H(...h));
1555
+ }, M = () => E();
1556
+ E(), c2.addEventListener("keydown", x), c2.addEventListener("focusin", M);
1557
+ const z = typeof MutationObserver > "u" ? null : new MutationObserver(() => E());
1558
+ return z == null || z.observe(c2, {
1559
+ childList: true,
1560
+ subtree: true,
1561
+ attributes: true,
1562
+ attributeFilter: ["disabled"]
1563
+ }), () => {
1564
+ c2.removeEventListener("keydown", x), c2.removeEventListener("focusin", M), z == null || z.disconnect();
1565
+ };
1566
+ },
1567
+ [s, t, a2, r, i2]
1568
+ );
1569
+ }
297
1570
  process.env.NODE_ENV !== "production" && "NiceRTLProvider";
298
1571
  process.env.NODE_ENV !== "production" && "NiceAccessControl";
299
1572
  process.env.NODE_ENV !== "production" && "NiceA11yProvider";
@@ -538,7 +1811,7 @@ const NiceCapacityPlanner = ({
538
1811
  unit
539
1812
  )) }) }),
540
1813
  /* @__PURE__ */ jsx("div", { className: "nice-resource-allocation__toolbar-right", children: config.showConflicts && conflicts.length > 0 && /* @__PURE__ */ jsxs("div", { className: "nice-resource-allocation__conflicts-badge", children: [
541
- /* @__PURE__ */ jsx("span", { className: "nice-resource-allocation__badge-icon", children: /* @__PURE__ */ jsx(ae, { name: "warning", size: 14 }) }),
1814
+ /* @__PURE__ */ jsx("span", { className: "nice-resource-allocation__badge-icon", children: /* @__PURE__ */ jsx(te, { name: "warning", size: 14 }) }),
542
1815
  (conflicts.length === 1 ? t("capacityPlanner.oneConflict", "1 Conflict") : t("capacityPlanner.conflicts", "{count} Conflicts")).replace("{count}", String(conflicts.length))
543
1816
  ] }) })
544
1817
  ] }),
@@ -586,6 +1859,9 @@ const NiceCapacityPlanner = ({
586
1859
  /* @__PURE__ */ jsxs(
587
1860
  "div",
588
1861
  {
1862
+ role: onResourceClick ? "button" : void 0,
1863
+ tabIndex: onResourceClick ? 0 : void 0,
1864
+ onKeyDown: onResourceClick ? Et : void 0,
589
1865
  className: "nice-resource-allocation__resource-cell",
590
1866
  onClick: () => onResourceClick == null ? void 0 : onResourceClick(resource),
591
1867
  children: [
@@ -598,7 +1874,7 @@ const NiceCapacityPlanner = ({
598
1874
  toggleResource(resource.id);
599
1875
  },
600
1876
  children: /* @__PURE__ */ jsx(
601
- ae,
1877
+ te,
602
1878
  {
603
1879
  name: expandedResources.has(resource.id) ? "chevron-down" : "chevron-right",
604
1880
  size: 14
@@ -606,7 +1882,7 @@ const NiceCapacityPlanner = ({
606
1882
  )
607
1883
  }
608
1884
  ),
609
- /* @__PURE__ */ jsx("span", { className: "nice-resource-allocation__resource-icon", children: /* @__PURE__ */ jsx(ae, { name: getResourceTypeIcon(resource.type), size: 16 }) }),
1885
+ /* @__PURE__ */ jsx("span", { className: "nice-resource-allocation__resource-icon", children: /* @__PURE__ */ jsx(te, { name: getResourceTypeIcon(resource.type), size: 16 }) }),
610
1886
  /* @__PURE__ */ jsxs("div", { className: "nice-resource-allocation__resource-info", children: [
611
1887
  /* @__PURE__ */ jsx("span", { className: "nice-resource-allocation__resource-name", children: resource.name }),
612
1888
  resource.department && /* @__PURE__ */ jsx("span", { className: "nice-resource-allocation__resource-dept", children: resource.department })
@@ -626,6 +1902,10 @@ const NiceCapacityPlanner = ({
626
1902
  return /* @__PURE__ */ jsxs(
627
1903
  "div",
628
1904
  {
1905
+ role: readOnly ? void 0 : "button",
1906
+ tabIndex: readOnly ? void 0 : 0,
1907
+ "aria-label": readOnly ? void 0 : `${resource.name} ${formatDate(period)}`,
1908
+ onKeyDown: readOnly ? void 0 : Et,
629
1909
  className: `nice-resource-allocation__time-cell ${isHovered ? "nice-resource-allocation__time-cell--hovered" : ""}`,
630
1910
  style: { backgroundColor: getCellColor(resource.id, period) },
631
1911
  onClick: () => handleCellClick(resource.id, period),
@@ -636,6 +1916,7 @@ const NiceCapacityPlanner = ({
636
1916
  cellAllocations.slice(0, 2).map((alloc) => /* @__PURE__ */ jsx(
637
1917
  "div",
638
1918
  {
1919
+ role: "presentation",
639
1920
  className: `nice-resource-allocation__allocation-dot nice-resource-allocation__allocation-dot--${alloc.status}`,
640
1921
  onClick: (e) => {
641
1922
  e.stopPropagation();
@@ -674,6 +1955,9 @@ const NiceCapacityPlanner = ({
674
1955
  return /* @__PURE__ */ jsxs(
675
1956
  "div",
676
1957
  {
1958
+ role: "button",
1959
+ tabIndex: 0,
1960
+ onKeyDown: Et,
677
1961
  className: `nice-resource-allocation__allocation-bar nice-resource-allocation__allocation-bar--${allocation.status} ${selectedAllocation === allocation.id ? "nice-resource-allocation__allocation-bar--selected" : ""}`,
678
1962
  style: {
679
1963
  left: `${leftPercent}%`,
@@ -694,7 +1978,7 @@ const NiceCapacityPlanner = ({
694
1978
  e.stopPropagation();
695
1979
  onAllocationDelete == null ? void 0 : onAllocationDelete(allocation.id);
696
1980
  },
697
- children: /* @__PURE__ */ jsx(ae, { name: "close", size: 14 })
1981
+ children: /* @__PURE__ */ jsx(te, { name: "close", size: 14 })
698
1982
  }
699
1983
  )
700
1984
  ]
@@ -707,11 +1991,13 @@ const NiceCapacityPlanner = ({
707
1991
  showAllocationModal && /* @__PURE__ */ jsx(
708
1992
  "div",
709
1993
  {
1994
+ role: "presentation",
710
1995
  className: "nice-resource-allocation__modal-overlay",
711
1996
  onClick: () => setShowAllocationModal(false),
712
1997
  children: /* @__PURE__ */ jsxs(
713
1998
  "div",
714
1999
  {
2000
+ role: "presentation",
715
2001
  className: "nice-resource-allocation__allocation-modal",
716
2002
  onClick: (e) => e.stopPropagation(),
717
2003
  children: [
@@ -1027,7 +2313,7 @@ const NiceInventoryManager = ({
1027
2313
  onChange: (e) => setFilters((prev) => ({ ...prev, searchQuery: e.target.value }))
1028
2314
  }
1029
2315
  ),
1030
- /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__search-icon", children: /* @__PURE__ */ jsx(ae, { name: "search", size: 14 }) })
2316
+ /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__search-icon", children: /* @__PURE__ */ jsx(te, { name: "search", size: 14 }) })
1031
2317
  ] }),
1032
2318
  /* @__PURE__ */ jsxs(
1033
2319
  "select",
@@ -1062,7 +2348,7 @@ const NiceInventoryManager = ({
1062
2348
  className: `nice-inventory-manager__view-button ${view === v2 ? "nice-inventory-manager__view-button--active" : ""}`,
1063
2349
  onClick: () => setView(v2),
1064
2350
  children: /* @__PURE__ */ jsx(
1065
- ae,
2351
+ te,
1066
2352
  {
1067
2353
  name: v2 === "grid" ? "grid" : v2 === "list" ? "list" : "table",
1068
2354
  size: 14
@@ -1134,6 +2420,9 @@ const NiceInventoryManager = ({
1134
2420
  return /* @__PURE__ */ jsxs(
1135
2421
  "div",
1136
2422
  {
2423
+ role: onItemClick ? "button" : void 0,
2424
+ tabIndex: onItemClick ? 0 : void 0,
2425
+ onKeyDown: onItemClick ? Et : void 0,
1137
2426
  className: `nice-inventory-manager__item-card ${selectedItems.has(item.id) ? "nice-inventory-manager__item-card--selected" : ""}`,
1138
2427
  onClick: () => onItemClick == null ? void 0 : onItemClick(item),
1139
2428
  children: [
@@ -1147,7 +2436,7 @@ const NiceInventoryManager = ({
1147
2436
  onClick: (e) => e.stopPropagation()
1148
2437
  }
1149
2438
  ),
1150
- config.showImages && /* @__PURE__ */ jsx("div", { className: "nice-inventory-manager__item-image", children: ((_a2 = item.images) == null ? void 0 : _a2[0]) ? /* @__PURE__ */ jsx("img", { src: item.images[0], alt: item.name }) : /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__placeholder-image", children: /* @__PURE__ */ jsx(ae, { name: "box", size: 32 }) }) }),
2439
+ config.showImages && /* @__PURE__ */ jsx("div", { className: "nice-inventory-manager__item-image", children: ((_a2 = item.images) == null ? void 0 : _a2[0]) ? /* @__PURE__ */ jsx("img", { src: item.images[0], alt: item.name }) : /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__placeholder-image", children: /* @__PURE__ */ jsx(te, { name: "box", size: 32 }) }) }),
1151
2440
  /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__item-info", children: [
1152
2441
  /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__item-sku", children: item.sku }),
1153
2442
  /* @__PURE__ */ jsx("h4", { className: "nice-inventory-manager__item-name", children: item.name }),
@@ -1168,7 +2457,7 @@ const NiceInventoryManager = ({
1168
2457
  item.unit
1169
2458
  ] }),
1170
2459
  item.quantity <= item.reorderLevel && /* @__PURE__ */ jsxs("span", { className: "nice-inventory-manager__reorder-alert", children: [
1171
- /* @__PURE__ */ jsx(ae, { name: "warning", size: 12 }),
2460
+ /* @__PURE__ */ jsx(te, { name: "warning", size: 12 }),
1172
2461
  " ",
1173
2462
  t("inventoryManager.lowStock", "Low Stock")
1174
2463
  ] })
@@ -1193,7 +2482,7 @@ const NiceInventoryManager = ({
1193
2482
  t("inventoryManager.sku", "SKU"),
1194
2483
  " ",
1195
2484
  sortBy === "sku" && /* @__PURE__ */ jsx(
1196
- ae,
2485
+ te,
1197
2486
  {
1198
2487
  name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
1199
2488
  size: 12
@@ -1213,7 +2502,7 @@ const NiceInventoryManager = ({
1213
2502
  t("inventoryManager.name", "Name"),
1214
2503
  " ",
1215
2504
  sortBy === "name" && /* @__PURE__ */ jsx(
1216
- ae,
2505
+ te,
1217
2506
  {
1218
2507
  name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
1219
2508
  size: 12
@@ -1234,7 +2523,7 @@ const NiceInventoryManager = ({
1234
2523
  t("inventoryManager.qty", "Qty"),
1235
2524
  " ",
1236
2525
  sortBy === "quantity" && /* @__PURE__ */ jsx(
1237
- ae,
2526
+ te,
1238
2527
  {
1239
2528
  name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
1240
2529
  size: 12
@@ -1256,7 +2545,7 @@ const NiceInventoryManager = ({
1256
2545
  t("inventoryManager.value", "Value"),
1257
2546
  " ",
1258
2547
  sortBy === "value" && /* @__PURE__ */ jsx(
1259
- ae,
2548
+ te,
1260
2549
  {
1261
2550
  name: sortOrder === "asc" ? "arrow-up" : "arrow-down",
1262
2551
  size: 12
@@ -1319,7 +2608,7 @@ const NiceInventoryManager = ({
1319
2608
  setEditingItem(item);
1320
2609
  setShowItemModal(true);
1321
2610
  },
1322
- children: /* @__PURE__ */ jsx(ae, { name: "edit", size: 14 })
2611
+ children: /* @__PURE__ */ jsx(te, { name: "edit", size: 14 })
1323
2612
  }
1324
2613
  ),
1325
2614
  /* @__PURE__ */ jsx(
@@ -1331,7 +2620,7 @@ const NiceInventoryManager = ({
1331
2620
  setNewTransaction({ itemId: item.id });
1332
2621
  setShowTransactionModal(true);
1333
2622
  },
1334
- children: /* @__PURE__ */ jsx(ae, { name: "clipboard", size: 14 })
2623
+ children: /* @__PURE__ */ jsx(te, { name: "clipboard", size: 14 })
1335
2624
  }
1336
2625
  ),
1337
2626
  /* @__PURE__ */ jsx(
@@ -1342,7 +2631,7 @@ const NiceInventoryManager = ({
1342
2631
  e.stopPropagation();
1343
2632
  onItemDelete == null ? void 0 : onItemDelete(item.id);
1344
2633
  },
1345
- children: /* @__PURE__ */ jsx(ae, { name: "trash", size: 14 })
2634
+ children: /* @__PURE__ */ jsx(te, { name: "trash", size: 14 })
1346
2635
  }
1347
2636
  )
1348
2637
  ] })
@@ -1373,6 +2662,9 @@ const NiceInventoryManager = ({
1373
2662
  /* @__PURE__ */ jsx("div", { className: "nice-inventory-manager__column-items", children: statusItems.map((item) => /* @__PURE__ */ jsxs(
1374
2663
  "div",
1375
2664
  {
2665
+ role: onItemClick ? "button" : void 0,
2666
+ tabIndex: onItemClick ? 0 : void 0,
2667
+ onKeyDown: onItemClick ? Et : void 0,
1376
2668
  className: "nice-inventory-manager__kanban-card",
1377
2669
  onClick: () => onItemClick == null ? void 0 : onItemClick(item),
1378
2670
  children: [
@@ -1406,7 +2698,7 @@ const NiceInventoryManager = ({
1406
2698
  /* @__PURE__ */ jsx("div", { className: "nice-inventory-manager__transactions-list", children: recentTransactions.map((tx) => {
1407
2699
  const item = items.find((i2) => i2.id === tx.itemId);
1408
2700
  return /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__transaction-item", children: [
1409
- /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__tx-icon", children: /* @__PURE__ */ jsx(ae, { name: getTransactionIcon(tx.type), size: 16 }) }),
2701
+ /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__tx-icon", children: /* @__PURE__ */ jsx(te, { name: getTransactionIcon(tx.type), size: 16 }) }),
1410
2702
  /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__tx-info", children: [
1411
2703
  /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__tx-type", children: tx.type }),
1412
2704
  /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__tx-item", children: (item == null ? void 0 : item.name) || tx.itemId })
@@ -1430,7 +2722,7 @@ const NiceInventoryManager = ({
1430
2722
  }) })
1431
2723
  ] }),
1432
2724
  activeTab === "reorder" && /* @__PURE__ */ jsx("div", { className: "nice-inventory-manager__reorder-tab", children: reorderItems.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__empty-state", children: [
1433
- /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__empty-icon", children: /* @__PURE__ */ jsx(ae, { name: "success", size: 32 }) }),
2725
+ /* @__PURE__ */ jsx("span", { className: "nice-inventory-manager__empty-icon", children: /* @__PURE__ */ jsx(te, { name: "success", size: 32 }) }),
1434
2726
  /* @__PURE__ */ jsx("p", { children: t(
1435
2727
  "inventoryManager.allItemsAreSufficientlyStocked",
1436
2728
  "All items are sufficiently stocked"
@@ -1466,153 +2758,164 @@ const NiceInventoryManager = ({
1466
2758
  showItemModal && editingItem && /* @__PURE__ */ jsx(
1467
2759
  "div",
1468
2760
  {
2761
+ role: "presentation",
1469
2762
  className: "nice-inventory-manager__modal-overlay",
1470
2763
  onClick: () => setShowItemModal(false),
1471
- children: /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__item-modal", onClick: (e) => e.stopPropagation(), children: [
1472
- /* @__PURE__ */ jsx("h3", { children: editingItem.id ? t("inventoryManager.editItem", "Edit Item") : t("inventoryManager.addNewItem", "Add New Item") }),
1473
- /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__modal-form", children: [
1474
- /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__form-row", children: [
1475
- /* @__PURE__ */ jsxs("label", { children: [
1476
- "SKU",
1477
- /* @__PURE__ */ jsx(
1478
- "input",
1479
- {
1480
- type: "text",
1481
- value: editingItem.sku || "",
1482
- onChange: (e) => setEditingItem((prev) => ({ ...prev, sku: e.target.value }))
1483
- }
1484
- )
2764
+ children: /* @__PURE__ */ jsxs(
2765
+ "div",
2766
+ {
2767
+ role: "presentation",
2768
+ className: "nice-inventory-manager__item-modal",
2769
+ onClick: (e) => e.stopPropagation(),
2770
+ children: [
2771
+ /* @__PURE__ */ jsx("h3", { children: editingItem.id ? t("inventoryManager.editItem", "Edit Item") : t("inventoryManager.addNewItem", "Add New Item") }),
2772
+ /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__modal-form", children: [
2773
+ /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__form-row", children: [
2774
+ /* @__PURE__ */ jsxs("label", { children: [
2775
+ "SKU",
2776
+ /* @__PURE__ */ jsx(
2777
+ "input",
2778
+ {
2779
+ type: "text",
2780
+ value: editingItem.sku || "",
2781
+ onChange: (e) => setEditingItem((prev) => ({ ...prev, sku: e.target.value }))
2782
+ }
2783
+ )
2784
+ ] }),
2785
+ /* @__PURE__ */ jsxs("label", { children: [
2786
+ t("inventoryManager.name", "Name"),
2787
+ /* @__PURE__ */ jsx(
2788
+ "input",
2789
+ {
2790
+ type: "text",
2791
+ value: editingItem.name || "",
2792
+ onChange: (e) => setEditingItem((prev) => ({ ...prev, name: e.target.value }))
2793
+ }
2794
+ )
2795
+ ] })
2796
+ ] }),
2797
+ /* @__PURE__ */ jsxs("label", { children: [
2798
+ t("inventoryManager.description", "Description"),
2799
+ /* @__PURE__ */ jsx(
2800
+ "textarea",
2801
+ {
2802
+ value: editingItem.description || "",
2803
+ onChange: (e) => setEditingItem((prev) => ({ ...prev, description: e.target.value }))
2804
+ }
2805
+ )
2806
+ ] }),
2807
+ /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__form-row", children: [
2808
+ /* @__PURE__ */ jsxs("label", { children: [
2809
+ t("inventoryManager.category", "Category"),
2810
+ /* @__PURE__ */ jsx(
2811
+ "input",
2812
+ {
2813
+ type: "text",
2814
+ value: editingItem.category || "",
2815
+ onChange: (e) => setEditingItem((prev) => ({ ...prev, category: e.target.value })),
2816
+ list: "categories"
2817
+ }
2818
+ ),
2819
+ /* @__PURE__ */ jsx("datalist", { id: "categories", children: categories.map((c2) => /* @__PURE__ */ jsx("option", { value: c2 }, c2)) })
2820
+ ] }),
2821
+ /* @__PURE__ */ jsxs("label", { children: [
2822
+ t("inventoryManager.unit", "Unit"),
2823
+ /* @__PURE__ */ jsx(
2824
+ "input",
2825
+ {
2826
+ type: "text",
2827
+ value: editingItem.unit || "",
2828
+ onChange: (e) => setEditingItem((prev) => ({ ...prev, unit: e.target.value }))
2829
+ }
2830
+ )
2831
+ ] })
2832
+ ] }),
2833
+ /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__form-row", children: [
2834
+ /* @__PURE__ */ jsxs("label", { children: [
2835
+ t("inventoryManager.quantity", "Quantity"),
2836
+ /* @__PURE__ */ jsx(
2837
+ "input",
2838
+ {
2839
+ type: "number",
2840
+ value: editingItem.quantity || 0,
2841
+ onChange: (e) => setEditingItem((prev) => ({ ...prev, quantity: parseInt(e.target.value) }))
2842
+ }
2843
+ )
2844
+ ] }),
2845
+ /* @__PURE__ */ jsxs("label", { children: [
2846
+ t("inventoryManager.reorderLevel", "Reorder Level"),
2847
+ /* @__PURE__ */ jsx(
2848
+ "input",
2849
+ {
2850
+ type: "number",
2851
+ value: editingItem.reorderLevel || 0,
2852
+ onChange: (e) => setEditingItem((prev) => ({
2853
+ ...prev,
2854
+ reorderLevel: parseInt(e.target.value)
2855
+ }))
2856
+ }
2857
+ )
2858
+ ] }),
2859
+ /* @__PURE__ */ jsxs("label", { children: [
2860
+ t("inventoryManager.reorderQty", "Reorder Qty"),
2861
+ /* @__PURE__ */ jsx(
2862
+ "input",
2863
+ {
2864
+ type: "number",
2865
+ value: editingItem.reorderQuantity || 0,
2866
+ onChange: (e) => setEditingItem((prev) => ({
2867
+ ...prev,
2868
+ reorderQuantity: parseInt(e.target.value)
2869
+ }))
2870
+ }
2871
+ )
2872
+ ] })
2873
+ ] }),
2874
+ /* @__PURE__ */ jsxs("label", { children: [
2875
+ t("inventoryManager.unitCost", "Unit Cost"),
2876
+ /* @__PURE__ */ jsx(
2877
+ "input",
2878
+ {
2879
+ type: "number",
2880
+ step: "0.01",
2881
+ value: ((_b = editingItem.cost) == null ? void 0 : _b.amount) || 0,
2882
+ onChange: (e) => setEditingItem((prev) => ({
2883
+ ...prev,
2884
+ cost: {
2885
+ ...prev.cost,
2886
+ amount: parseFloat(e.target.value)
2887
+ }
2888
+ }))
2889
+ }
2890
+ )
2891
+ ] })
1485
2892
  ] }),
1486
- /* @__PURE__ */ jsxs("label", { children: [
1487
- t("inventoryManager.name", "Name"),
1488
- /* @__PURE__ */ jsx(
1489
- "input",
1490
- {
1491
- type: "text",
1492
- value: editingItem.name || "",
1493
- onChange: (e) => setEditingItem((prev) => ({ ...prev, name: e.target.value }))
1494
- }
1495
- )
1496
- ] })
1497
- ] }),
1498
- /* @__PURE__ */ jsxs("label", { children: [
1499
- t("inventoryManager.description", "Description"),
1500
- /* @__PURE__ */ jsx(
1501
- "textarea",
1502
- {
1503
- value: editingItem.description || "",
1504
- onChange: (e) => setEditingItem((prev) => ({ ...prev, description: e.target.value }))
1505
- }
1506
- )
1507
- ] }),
1508
- /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__form-row", children: [
1509
- /* @__PURE__ */ jsxs("label", { children: [
1510
- t("inventoryManager.category", "Category"),
2893
+ /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__modal-actions", children: [
1511
2894
  /* @__PURE__ */ jsx(
1512
- "input",
2895
+ "button",
1513
2896
  {
1514
- type: "text",
1515
- value: editingItem.category || "",
1516
- onChange: (e) => setEditingItem((prev) => ({ ...prev, category: e.target.value })),
1517
- list: "categories"
2897
+ className: "nice-inventory-manager__cancel-button",
2898
+ onClick: () => setShowItemModal(false),
2899
+ children: t("inventoryManager.cancel", "Cancel")
1518
2900
  }
1519
2901
  ),
1520
- /* @__PURE__ */ jsx("datalist", { id: "categories", children: categories.map((c2) => /* @__PURE__ */ jsx("option", { value: c2 }, c2)) })
1521
- ] }),
1522
- /* @__PURE__ */ jsxs("label", { children: [
1523
- t("inventoryManager.unit", "Unit"),
1524
- /* @__PURE__ */ jsx(
1525
- "input",
1526
- {
1527
- type: "text",
1528
- value: editingItem.unit || "",
1529
- onChange: (e) => setEditingItem((prev) => ({ ...prev, unit: e.target.value }))
1530
- }
1531
- )
2902
+ /* @__PURE__ */ jsx("button", { className: "nice-inventory-manager__save-button", onClick: handleItemSubmit, children: editingItem.id ? t("inventoryManager.saveChanges", "Save Changes") : t("inventoryManager.createItem", "Create Item") })
1532
2903
  ] })
1533
- ] }),
1534
- /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__form-row", children: [
1535
- /* @__PURE__ */ jsxs("label", { children: [
1536
- t("inventoryManager.quantity", "Quantity"),
1537
- /* @__PURE__ */ jsx(
1538
- "input",
1539
- {
1540
- type: "number",
1541
- value: editingItem.quantity || 0,
1542
- onChange: (e) => setEditingItem((prev) => ({ ...prev, quantity: parseInt(e.target.value) }))
1543
- }
1544
- )
1545
- ] }),
1546
- /* @__PURE__ */ jsxs("label", { children: [
1547
- t("inventoryManager.reorderLevel", "Reorder Level"),
1548
- /* @__PURE__ */ jsx(
1549
- "input",
1550
- {
1551
- type: "number",
1552
- value: editingItem.reorderLevel || 0,
1553
- onChange: (e) => setEditingItem((prev) => ({
1554
- ...prev,
1555
- reorderLevel: parseInt(e.target.value)
1556
- }))
1557
- }
1558
- )
1559
- ] }),
1560
- /* @__PURE__ */ jsxs("label", { children: [
1561
- t("inventoryManager.reorderQty", "Reorder Qty"),
1562
- /* @__PURE__ */ jsx(
1563
- "input",
1564
- {
1565
- type: "number",
1566
- value: editingItem.reorderQuantity || 0,
1567
- onChange: (e) => setEditingItem((prev) => ({
1568
- ...prev,
1569
- reorderQuantity: parseInt(e.target.value)
1570
- }))
1571
- }
1572
- )
1573
- ] })
1574
- ] }),
1575
- /* @__PURE__ */ jsxs("label", { children: [
1576
- t("inventoryManager.unitCost", "Unit Cost"),
1577
- /* @__PURE__ */ jsx(
1578
- "input",
1579
- {
1580
- type: "number",
1581
- step: "0.01",
1582
- value: ((_b = editingItem.cost) == null ? void 0 : _b.amount) || 0,
1583
- onChange: (e) => setEditingItem((prev) => ({
1584
- ...prev,
1585
- cost: {
1586
- ...prev.cost,
1587
- amount: parseFloat(e.target.value)
1588
- }
1589
- }))
1590
- }
1591
- )
1592
- ] })
1593
- ] }),
1594
- /* @__PURE__ */ jsxs("div", { className: "nice-inventory-manager__modal-actions", children: [
1595
- /* @__PURE__ */ jsx(
1596
- "button",
1597
- {
1598
- className: "nice-inventory-manager__cancel-button",
1599
- onClick: () => setShowItemModal(false),
1600
- children: t("inventoryManager.cancel", "Cancel")
1601
- }
1602
- ),
1603
- /* @__PURE__ */ jsx("button", { className: "nice-inventory-manager__save-button", onClick: handleItemSubmit, children: editingItem.id ? t("inventoryManager.saveChanges", "Save Changes") : t("inventoryManager.createItem", "Create Item") })
1604
- ] })
1605
- ] })
2904
+ ]
2905
+ }
2906
+ )
1606
2907
  }
1607
2908
  ),
1608
2909
  showTransactionModal && /* @__PURE__ */ jsx(
1609
2910
  "div",
1610
2911
  {
2912
+ role: "presentation",
1611
2913
  className: "nice-inventory-manager__modal-overlay",
1612
2914
  onClick: () => setShowTransactionModal(false),
1613
2915
  children: /* @__PURE__ */ jsxs(
1614
2916
  "div",
1615
2917
  {
2918
+ role: "presentation",
1616
2919
  className: "nice-inventory-manager__transaction-modal",
1617
2920
  onClick: (e) => e.stopPropagation(),
1618
2921
  children: [
@@ -1849,7 +3152,7 @@ const NiceInvoiceView = /* @__PURE__ */ forwardRef(
1849
3152
  onClick: () => onAction == null ? void 0 : onAction("download"),
1850
3153
  "aria-label": t("invoiceView.download", "Download"),
1851
3154
  title: t("invoiceView.download", "Download"),
1852
- children: /* @__PURE__ */ jsx(ae, { name: "arrow-down", size: 12 })
3155
+ children: /* @__PURE__ */ jsx(te, { name: "arrow-down", size: 12 })
1853
3156
  }
1854
3157
  ),
1855
3158
  /* @__PURE__ */ jsx(
@@ -1859,7 +3162,7 @@ const NiceInvoiceView = /* @__PURE__ */ forwardRef(
1859
3162
  onClick: () => onAction == null ? void 0 : onAction("print"),
1860
3163
  "aria-label": t("invoiceView.print", "Print"),
1861
3164
  title: t("invoiceView.print", "Print"),
1862
- children: /* @__PURE__ */ jsx(ae, { name: "printer", size: 14 })
3165
+ children: /* @__PURE__ */ jsx(te, { name: "printer", size: 14 })
1863
3166
  }
1864
3167
  ),
1865
3168
  /* @__PURE__ */ jsx(
@@ -1869,7 +3172,7 @@ const NiceInvoiceView = /* @__PURE__ */ forwardRef(
1869
3172
  onClick: () => onAction == null ? void 0 : onAction("send"),
1870
3173
  "aria-label": t("invoiceView.send", "Send"),
1871
3174
  title: t("invoiceView.send", "Send"),
1872
- children: /* @__PURE__ */ jsx(ae, { name: "mail", size: 14 })
3175
+ children: /* @__PURE__ */ jsx(te, { name: "mail", size: 14 })
1873
3176
  }
1874
3177
  )
1875
3178
  ] })
@@ -2028,6 +3331,8 @@ const NiceWarehouseView = /* @__PURE__ */ forwardRef(
2028
3331
  }
2029
3332
  return [...rows.entries()].map(([rowKey, arr]) => ({ rowKey, cells: arr }));
2030
3333
  }, [cells]);
3334
+ const gridRef = useRef(null);
3335
+ Xa(gridRef);
2031
3336
  return /* @__PURE__ */ jsxs("div", { ref, id, className: `nice-warehouse-view ${className ?? ""}`, style, children: [
2032
3337
  /* @__PURE__ */ jsxs("header", { className: "nice-warehouse-view__header", children: [
2033
3338
  /* @__PURE__ */ jsx("h3", { children: warehouseName }),
@@ -2050,31 +3355,42 @@ const NiceWarehouseView = /* @__PURE__ */ forwardRef(
2050
3355
  }
2051
3356
  )
2052
3357
  ] }),
2053
- /* @__PURE__ */ jsx("div", { className: "nice-warehouse-view__grid", role: "grid", "aria-label": warehouseName, children: grid.map(({ rowKey, cells: row }) => /* @__PURE__ */ jsx("div", { className: "nice-warehouse-view__row", role: "row", children: row.map((c2, idx) => {
2054
- const key = [c2.location.rack, c2.location.aisle, c2.location.shelf, c2.location.bin].filter(Boolean).join("-") || String(idx);
2055
- const aisleBreak = aisleEvery > 0 && idx > 0 && idx % aisleEvery === 0;
2056
- return /* @__PURE__ */ jsxs(ve.Fragment, { children: [
2057
- aisleBreak && /* @__PURE__ */ jsx("div", { className: "nice-warehouse-view__aisle", "aria-hidden": true }),
2058
- /* @__PURE__ */ jsx(
2059
- "button",
2060
- {
2061
- type: "button",
2062
- role: "gridcell",
2063
- className: "nice-warehouse-view__cell",
2064
- style: {
2065
- width: cellSize,
2066
- height: cellSize,
2067
- background: colorFor(c2.occupancy, colors)
2068
- },
2069
- title: t("warehouseView.items", "{key} — {occupancy}% ({items} items)").replace("{key}", String(key)).replace("{occupancy}", String((c2.occupancy * 100).toFixed(0))).replace("{items}", String(c2.items.length)),
2070
- onClick: () => onCellClick == null ? void 0 : onCellClick(c2),
2071
- onMouseEnter: () => setHovered(c2),
2072
- onMouseLeave: () => setHovered(null),
2073
- children: /* @__PURE__ */ jsx("span", { className: "nice-warehouse-view__bin", children: c2.location.bin ?? c2.location.shelf ?? "" })
2074
- }
2075
- )
2076
- ] }, key);
2077
- }) }, rowKey)) }),
3358
+ /* @__PURE__ */ jsx(
3359
+ "div",
3360
+ {
3361
+ ref: gridRef,
3362
+ className: "nice-warehouse-view__grid",
3363
+ role: "grid",
3364
+ "aria-label": warehouseName,
3365
+ children: grid.map(({ rowKey, cells: row }) => /* @__PURE__ */ jsx("div", { className: "nice-warehouse-view__row", role: "row", children: row.map((c2, idx) => {
3366
+ const key = [c2.location.rack, c2.location.aisle, c2.location.shelf, c2.location.bin].filter(Boolean).join("-") || String(idx);
3367
+ const aisleBreak = aisleEvery > 0 && idx > 0 && idx % aisleEvery === 0;
3368
+ return /* @__PURE__ */ jsxs($e$1.Fragment, { children: [
3369
+ aisleBreak && /* @__PURE__ */ jsx("div", { className: "nice-warehouse-view__aisle", "aria-hidden": true }),
3370
+ /* @__PURE__ */ jsx(
3371
+ "button",
3372
+ {
3373
+ type: "button",
3374
+ role: "gridcell",
3375
+ className: "nice-warehouse-view__cell",
3376
+ style: {
3377
+ width: cellSize,
3378
+ height: cellSize,
3379
+ background: colorFor(c2.occupancy, colors)
3380
+ },
3381
+ title: t("warehouseView.items", "{key} — {occupancy}% ({items} items)").replace("{key}", String(key)).replace("{occupancy}", String((c2.occupancy * 100).toFixed(0))).replace("{items}", String(c2.items.length)),
3382
+ onClick: () => onCellClick == null ? void 0 : onCellClick(c2),
3383
+ onMouseEnter: () => setHovered(c2),
3384
+ onMouseLeave: () => setHovered(null),
3385
+ onFocus: () => setHovered(c2),
3386
+ onBlur: () => setHovered(null),
3387
+ children: /* @__PURE__ */ jsx("span", { className: "nice-warehouse-view__bin", children: c2.location.bin ?? c2.location.shelf ?? "" })
3388
+ }
3389
+ )
3390
+ ] }, key);
3391
+ }) }, rowKey))
3392
+ }
3393
+ ),
2078
3394
  hovered && /* @__PURE__ */ jsxs("aside", { className: "nice-warehouse-view__details", "aria-live": "polite", children: [
2079
3395
  /* @__PURE__ */ jsxs("strong", { children: [
2080
3396
  hovered.location.rack,
@@ -2517,7 +3833,7 @@ const NiceVatTable = /* @__PURE__ */ forwardRef(
2517
3833
  };
2518
3834
  const removeRow = (idx) => {
2519
3835
  const code = internal[idx].code;
2520
- const next = internal.filter((_, i2) => i2 !== idx);
3836
+ const next = internal.filter((_2, i2) => i2 !== idx);
2521
3837
  update(next);
2522
3838
  onRemove == null ? void 0 : onRemove(code);
2523
3839
  };
@@ -2570,7 +3886,7 @@ const NiceVatTable = /* @__PURE__ */ forwardRef(
2570
3886
  onChange: (e) => onCellEdit(idx, "description", e.target.value)
2571
3887
  }
2572
3888
  ) : r.description ?? "" }),
2573
- editable && /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", { type: "button", onClick: () => removeRow(idx), "aria-label": L.remove, children: /* @__PURE__ */ jsx(ae, { name: "close", size: 14 }) }) })
3889
+ editable && /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", { type: "button", onClick: () => removeRow(idx), "aria-label": L.remove, children: /* @__PURE__ */ jsx(te, { name: "close", size: 14 }) }) })
2574
3890
  ] }, r.code)) })
2575
3891
  ] }),
2576
3892
  editable && /* @__PURE__ */ jsx("button", { type: "button", className: "nice-vat-table__add", onClick: addRow, children: L.add })