@eightshift/ui-components 5.2.1 → 5.3.1

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 (98) hide show
  1. package/dist/{Button-RTwMSBs-.js → Button-npzfSoYo.js} +3 -3
  2. package/dist/{Dialog-Xf6AsnV-.js → Dialog-CQ8H6Noi.js} +77 -50
  3. package/dist/{FocusScope-BnwM-e8R.js → FocusScope-DJApHXhY.js} +1 -1
  4. package/dist/Form-Cq3fu75_.js +5 -0
  5. package/dist/{Group-C4cXobNT.js → Input-ChJaTNa5.js} +39 -39
  6. package/dist/{List-CwJTORxj.js → List-BiAnh5G5.js} +5 -5
  7. package/dist/{ListBox-BeC97FZ4.js → ListBox-D0Stb4wr.js} +13 -23
  8. package/dist/{OverlayArrow-EZ0v_ljk.js → OverlayArrow-DivvkAVb.js} +46 -25
  9. package/dist/{Separator-Fl7qSeN-.js → SearchField-jVsbJe1O.js} +151 -475
  10. package/dist/{Select-DEQf8ZWI.js → Select-ciHB1pub.js} +12 -11
  11. package/dist/{Select-ef7c0426.esm-D6WOCaYm.js → Select-ef7c0426.esm-CmTkSxDx.js} +3 -3
  12. package/dist/{Collection-D_KhdLDC.js → SelectionManager-CabSdgMq.js} +1801 -1777
  13. package/dist/Separator-BPvqJny4.js +344 -0
  14. package/dist/{Slider-BQFSEhvk.js → Slider-ChP04COa.js} +4 -4
  15. package/dist/{VisuallyHidden-D9s7FTtC.js → VisuallyHidden-X6SggVVO.js} +1 -1
  16. package/dist/assets/style-admin.css +315 -79
  17. package/dist/assets/style-editor.css +315 -79
  18. package/dist/assets/style.css +315 -79
  19. package/dist/assets/wp-font-enhancements.css +1 -1
  20. package/dist/assets/wp-ui-enhancements.css +5 -14
  21. package/dist/components/animated-visibility/animated-visibility.js +16 -16
  22. package/dist/components/button/button.js +28 -23
  23. package/dist/components/checkbox/checkbox.js +11 -10
  24. package/dist/components/color-pickers/color-picker.js +5 -4
  25. package/dist/components/color-pickers/color-swatch.js +1 -1
  26. package/dist/components/color-pickers/gradient-editor.js +7 -7
  27. package/dist/components/color-pickers/solid-color-picker.js +8 -8
  28. package/dist/components/component-toggle/component-toggle.js +1 -1
  29. package/dist/components/draggable/draggable-handle.js +1 -1
  30. package/dist/components/draggable/draggable.js +34 -17
  31. package/dist/components/draggable-list/draggable-list-item.js +1 -1
  32. package/dist/components/draggable-list/draggable-list.js +6 -4
  33. package/dist/components/expandable/expandable.js +5 -5
  34. package/dist/components/index.js +2 -1
  35. package/dist/components/input-field/input-field.js +139 -3
  36. package/dist/components/item-collection/item-collection.js +1 -1
  37. package/dist/components/link-input/link-input.js +16 -15
  38. package/dist/components/matrix-align/matrix-align.js +1 -1
  39. package/dist/components/menu/menu.js +94 -24
  40. package/dist/components/modal/modal.js +4 -4
  41. package/dist/components/notice/notice.js +6 -5
  42. package/dist/components/number-picker/number-picker.js +5 -5
  43. package/dist/components/option-select/option-select.js +1 -1
  44. package/dist/components/placeholders/file-placeholder.js +1 -1
  45. package/dist/components/popover/popover.js +28 -21
  46. package/dist/components/radio/radio.js +7 -6
  47. package/dist/components/repeater/repeater-item.js +1 -1
  48. package/dist/components/repeater/repeater.js +2 -2
  49. package/dist/components/responsive/mini-responsive.js +1 -1
  50. package/dist/components/responsive/responsive-legacy.js +1 -1
  51. package/dist/components/responsive/responsive.js +21 -20
  52. package/dist/components/responsive-preview/responsive-preview.js +1 -1
  53. package/dist/components/rich-label/rich-label.js +28 -15
  54. package/dist/components/select/async-multi-select.js +3 -3
  55. package/dist/components/select/async-single-select.js +2 -2
  56. package/dist/components/select/custom-select-default-components.js +1 -1
  57. package/dist/components/select/multi-select-components.js +1 -1
  58. package/dist/components/select/multi-select.js +3 -3
  59. package/dist/components/select/react-select-component-wrappers.js +1 -1
  60. package/dist/components/select/single-select.js +2 -2
  61. package/dist/components/select/styles.js +1 -1
  62. package/dist/components/select/v2/async-multi-select.js +9 -9
  63. package/dist/components/select/v2/async-select.js +9 -9
  64. package/dist/components/select/v2/multi-select.js +8 -8
  65. package/dist/components/select/v2/shared.js +1 -1
  66. package/dist/components/select/v2/single-select.js +8 -8
  67. package/dist/components/slider/column-config-slider.js +2 -2
  68. package/dist/components/slider/slider.js +1 -1
  69. package/dist/components/slider/utils.js +1 -1
  70. package/dist/components/tabs/tabs.js +13 -9
  71. package/dist/components/toggle/switch.js +5 -5
  72. package/dist/components/toggle-button/toggle-button.js +7 -7
  73. package/dist/components/tooltip/tooltip.js +35 -35
  74. package/dist/context-DCAZLyDS.js +7 -0
  75. package/dist/{default-i18n-DY6EfUSA.js → default-i18n-CN_q3KUs.js} +15 -56
  76. package/dist/icons/icons.js +3347 -30273
  77. package/dist/{index-641ee5b8.esm-Bu-mgopl.js → index-641ee5b8.esm-DVp0njHa.js} +10 -8
  78. package/dist/{index-CBHA_HDD.js → index-D8-Zjpbd.js} +18 -18
  79. package/dist/index.js +2 -1
  80. package/dist/{multi-select-components-rCCyCaKO.js → multi-select-components-CT_W0Cy9.js} +1 -1
  81. package/dist/{react-select-async.esm-XYrsKYb2.js → react-select-async.esm-Zl1LPaPb.js} +3 -3
  82. package/dist/{react-select.esm-CCSPY6XR.js → react-select.esm-Bu36HujU.js} +3 -3
  83. package/dist/{textSelection-D5tWX1rJ.js → textSelection-k0u64dDA.js} +1 -1
  84. package/dist/{useAsyncList-ZqaIH2gh.js → useAsyncList-D52mQcrH.js} +30 -0
  85. package/dist/{useButton-BtJSiQi3.js → useButton-Bn4ZT295.js} +4 -3
  86. package/dist/{useDragAndDrop-CddFteYC.js → useDragAndDrop-DVLrIdEn.js} +18 -10
  87. package/dist/{useFilter-Cl2ggwwq.js → useFilter-C4wo8Iii.js} +1 -1
  88. package/dist/{useFocusRing-D5BfOWag.js → useFocusRing-CUxgjvAY.js} +1 -1
  89. package/dist/{Form-BeMxJA29.js → useFormValidation-CUtZcedF.js} +5 -7
  90. package/dist/{useHover-44IApaa2.js → useHover-LmGemtHE.js} +24 -24
  91. package/dist/{useListState-BSkHuB7-.js → useListState-Xsk-aOvN.js} +8 -5
  92. package/dist/{useNumberField-JhWPy1JY.js → useNumberField-BCjjZWaz.js} +100 -99
  93. package/dist/{usePress-BnrkvZ7e.js → usePress-CBQIDzpQ.js} +12 -12
  94. package/dist/{useSingleSelectListState-CzJFsSHr.js → useSingleSelectListState-DattSD7d.js} +2 -2
  95. package/dist/{useToggle-OaIBlwRu.js → useToggle-C8CedY6Z.js} +2 -2
  96. package/dist/{useToggleState-BF8hvidm.js → useToggleState-CiAradXs.js} +1 -1
  97. package/package.json +26 -26
  98. package/dist/TextField-x_eEa_qR.js +0 -143
@@ -1,12 +1,12 @@
1
- import { a as $f39a9eba43920ace$export$8dc98ba7eadeaa56 } from "./Hidden-rE6uR-lr.js";
2
- import { r as reactDomExports } from "./index-CBHA_HDD.js";
3
- import { B as $c87311424ea30a05$export$9ac100e40613ea10, f as $03deb23ff14920c4$export$4eaf04e54aa8eed6, c as $431fbd86ca7dc216$export$b204af158042fbac, z as $7215afc6de606d6b$export$de79e2c695e052f3, J as $f645667febf57a63$export$f9762fab77588ecb, h as $d4ee10de306f2510$export$cd4e5573fbe2b576, K as $c87311424ea30a05$export$e1865c3bedcd822b, s as $3ad3f6e1647bc98d$export$80f3e147d781571c, v as $507fabe10e71c6fb$export$630ff653c5ada6a9, a as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "./useHover-44IApaa2.js";
4
- import React__default, { useRef, useState, useMemo, cloneElement, forwardRef, useContext, createContext, useCallback, useEffect, isValidElement } from "react";
5
- import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, b as $3ef42575df84b30b$export$9d1611c77c2fe928, n as $b5e257d569688ac6$export$535bd6ca7f90a273, d as $bdb11010cef70236$export$f680877a34711e37, e as $8ae05eaa5c114e9c$export$7f54fc3180508a52, p as $ff5963eb1fccf552$export$e08e3b67e392101e } from "./utils-cvK1vxO7.js";
6
- import { $ as $f6c31cce2adf654f$export$45712eceda6fad21, b as $ea8dcbcb9ea1b556$export$9a302a45f65d0572, c as $ea8dcbcb9ea1b556$export$95185d699e05d4d7 } from "./usePress-BnrkvZ7e.js";
1
+ import React__default, { useRef, useState, useEffect, useMemo, cloneElement, forwardRef, useContext, createContext, useCallback, isValidElement } from "react";
2
+ import { B as $c87311424ea30a05$export$9ac100e40613ea10, e as $03deb23ff14920c4$export$4eaf04e54aa8eed6, c as $431fbd86ca7dc216$export$b204af158042fbac, z as $7215afc6de606d6b$export$de79e2c695e052f3, g as $d4ee10de306f2510$export$cd4e5573fbe2b576, J as $c87311424ea30a05$export$e1865c3bedcd822b, r as $3ad3f6e1647bc98d$export$80f3e147d781571c, u as $507fabe10e71c6fb$export$630ff653c5ada6a9, K as $f645667febf57a63$export$f9762fab77588ecb, a as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "./useHover-LmGemtHE.js";
3
+ import { k as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, b as $3ef42575df84b30b$export$9d1611c77c2fe928, d as $bdb11010cef70236$export$f680877a34711e37, e as $8ae05eaa5c114e9c$export$7f54fc3180508a52, p as $ff5963eb1fccf552$export$e08e3b67e392101e, n as $b5e257d569688ac6$export$535bd6ca7f90a273 } from "./utils-cvK1vxO7.js";
4
+ import { $ as $f6c31cce2adf654f$export$45712eceda6fad21, b as $ea8dcbcb9ea1b556$export$9a302a45f65d0572, c as $ea8dcbcb9ea1b556$export$95185d699e05d4d7 } from "./usePress-CBQIDzpQ.js";
7
5
  import { $ as $e9faafb641e167db$export$90fc3a17d93f704c } from "./useEvent-BifIGnVS.js";
8
- import { a as $9bf71ea28793e738$export$2d6ec8fc375ceafa } from "./FocusScope-BnwM-e8R.js";
6
+ import { a as $9bf71ea28793e738$export$2d6ec8fc375ceafa } from "./FocusScope-DJApHXhY.js";
7
+ import { r as reactDomExports } from "./index-D8-Zjpbd.js";
9
8
  import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-DMOmz986.js";
9
+ import { a as $f39a9eba43920ace$export$8dc98ba7eadeaa56 } from "./Hidden-rE6uR-lr.js";
10
10
  function $ca9b37712f007381$export$72ef708ab07251f1(effect, dependencies) {
11
11
  const isInitialMount = useRef(true);
12
12
  const lastDeps = useRef(null);
@@ -142,1794 +142,1874 @@ function $21f1aa98acb08317$export$16792effe837dba3(e) {
142
142
  if ($c87311424ea30a05$export$9ac100e40613ea10()) return e.metaKey;
143
143
  return e.ctrlKey;
144
144
  }
145
- class $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
146
- get childNodes() {
147
- throw new Error("childNodes is not supported");
148
- }
149
- clone() {
150
- let node = new $23b9f4fcf0fe224b$export$d68d59712b04d9d1(this.type, this.key);
151
- node.value = this.value;
152
- node.level = this.level;
153
- node.hasChildNodes = this.hasChildNodes;
154
- node.rendered = this.rendered;
155
- node.textValue = this.textValue;
156
- node["aria-label"] = this["aria-label"];
157
- node.index = this.index;
158
- node.parentKey = this.parentKey;
159
- node.prevKey = this.prevKey;
160
- node.nextKey = this.nextKey;
161
- node.firstChildKey = this.firstChildKey;
162
- node.lastChildKey = this.lastChildKey;
163
- node.props = this.props;
164
- node.render = this.render;
165
- node.colSpan = this.colSpan;
166
- node.colIndex = this.colIndex;
167
- return node;
168
- }
169
- constructor(type, key) {
170
- this.value = null;
171
- this.level = 0;
172
- this.hasChildNodes = false;
173
- this.rendered = null;
174
- this.textValue = "";
175
- this["aria-label"] = void 0;
176
- this.index = 0;
177
- this.parentKey = null;
178
- this.prevKey = null;
179
- this.nextKey = null;
180
- this.firstChildKey = null;
181
- this.lastChildKey = null;
182
- this.props = {};
183
- this.colSpan = null;
184
- this.colIndex = null;
185
- this.type = type;
186
- this.key = key;
187
- }
188
- }
189
- class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
190
- get size() {
191
- return this.itemCount;
192
- }
193
- getKeys() {
194
- return this.keyMap.keys();
195
- }
196
- *[Symbol.iterator]() {
197
- let node = this.firstKey != null ? this.keyMap.get(this.firstKey) : void 0;
198
- while (node) {
199
- yield node;
200
- node = node.nextKey != null ? this.keyMap.get(node.nextKey) : void 0;
201
- }
202
- }
203
- getChildren(key) {
204
- let keyMap = this.keyMap;
205
- return {
206
- *[Symbol.iterator]() {
207
- let parent = keyMap.get(key);
208
- let node = (parent === null || parent === void 0 ? void 0 : parent.firstChildKey) != null ? keyMap.get(parent.firstChildKey) : null;
209
- while (node) {
210
- yield node;
211
- node = node.nextKey != null ? keyMap.get(node.nextKey) : void 0;
145
+ const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
146
+ function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
147
+ let { isDisabled, onLongPressStart, onLongPressEnd, onLongPress, threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD, accessibilityDescription } = props;
148
+ const timeRef = useRef(void 0);
149
+ let { addGlobalListener, removeGlobalListener } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
150
+ let { pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
151
+ isDisabled,
152
+ onPressStart(e) {
153
+ e.continuePropagation();
154
+ if (e.pointerType === "mouse" || e.pointerType === "touch") {
155
+ if (onLongPressStart) onLongPressStart({
156
+ ...e,
157
+ type: "longpressstart"
158
+ });
159
+ timeRef.current = setTimeout(() => {
160
+ e.target.dispatchEvent(new PointerEvent("pointercancel", {
161
+ bubbles: true
162
+ }));
163
+ if ($431fbd86ca7dc216$export$b204af158042fbac(e.target).activeElement !== e.target) $7215afc6de606d6b$export$de79e2c695e052f3(e.target);
164
+ if (onLongPress) onLongPress({
165
+ ...e,
166
+ type: "longpress"
167
+ });
168
+ timeRef.current = void 0;
169
+ }, threshold);
170
+ if (e.pointerType === "touch") {
171
+ let onContextMenu = (e2) => {
172
+ e2.preventDefault();
173
+ };
174
+ addGlobalListener(e.target, "contextmenu", onContextMenu, {
175
+ once: true
176
+ });
177
+ addGlobalListener(window, "pointerup", () => {
178
+ setTimeout(() => {
179
+ removeGlobalListener(e.target, "contextmenu", onContextMenu);
180
+ }, 30);
181
+ }, {
182
+ once: true
183
+ });
212
184
  }
213
185
  }
214
- };
215
- }
216
- getKeyBefore(key) {
217
- let node = this.keyMap.get(key);
218
- if (!node) return null;
219
- if (node.prevKey != null) {
220
- node = this.keyMap.get(node.prevKey);
221
- while (node && node.type !== "item" && node.lastChildKey != null) node = this.keyMap.get(node.lastChildKey);
222
- var _node_key;
223
- return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
186
+ },
187
+ onPressEnd(e) {
188
+ if (timeRef.current) clearTimeout(timeRef.current);
189
+ if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
190
+ ...e,
191
+ type: "longpressend"
192
+ });
224
193
  }
225
- return node.parentKey;
194
+ });
195
+ let descriptionProps = $ef06256079686ba0$export$f8aeda7b10753fa1(onLongPress && !isDisabled ? accessibilityDescription : void 0);
196
+ return {
197
+ longPressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, descriptionProps)
198
+ };
199
+ }
200
+ function $55f9b1ae81f22853$export$76e4e37e5339496d(to) {
201
+ let from = $55f9b1ae81f22853$export$759df0d867455a91($431fbd86ca7dc216$export$b204af158042fbac(to));
202
+ if (from !== to) {
203
+ if (from) $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to);
204
+ if (to) $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from);
226
205
  }
227
- getKeyAfter(key) {
228
- let node = this.keyMap.get(key);
229
- if (!node) return null;
230
- if (node.type !== "item" && node.firstChildKey != null) return node.firstChildKey;
231
- while (node) {
232
- if (node.nextKey != null) return node.nextKey;
233
- if (node.parentKey != null) node = this.keyMap.get(node.parentKey);
234
- else return null;
206
+ }
207
+ function $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to) {
208
+ from.dispatchEvent(new FocusEvent("blur", {
209
+ relatedTarget: to
210
+ }));
211
+ from.dispatchEvent(new FocusEvent("focusout", {
212
+ bubbles: true,
213
+ relatedTarget: to
214
+ }));
215
+ }
216
+ function $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from) {
217
+ to.dispatchEvent(new FocusEvent("focus", {
218
+ relatedTarget: from
219
+ }));
220
+ to.dispatchEvent(new FocusEvent("focusin", {
221
+ bubbles: true,
222
+ relatedTarget: from
223
+ }));
224
+ }
225
+ function $55f9b1ae81f22853$export$759df0d867455a91(document2) {
226
+ let activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(document2);
227
+ let activeDescendant = activeElement === null || activeElement === void 0 ? void 0 : activeElement.getAttribute("aria-activedescendant");
228
+ if (activeDescendant) return document2.getElementById(activeDescendant) || activeElement;
229
+ return activeElement;
230
+ }
231
+ function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
232
+ return $c87311424ea30a05$export$e1865c3bedcd822b() ? e.altKey : e.ctrlKey;
233
+ }
234
+ function $feb5ffebff200149$export$c3d8340acf92597f(collectionRef, key) {
235
+ var _collectionRef_current, _collectionRef_current1;
236
+ let selector = `[data-key="${CSS.escape(String(key))}"]`;
237
+ let collection = (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dataset.collection;
238
+ if (collection) selector = `[data-collection="${CSS.escape(collection)}"]${selector}`;
239
+ return (_collectionRef_current1 = collectionRef.current) === null || _collectionRef_current1 === void 0 ? void 0 : _collectionRef_current1.querySelector(selector);
240
+ }
241
+ const $feb5ffebff200149$var$collectionMap = /* @__PURE__ */ new WeakMap();
242
+ function $feb5ffebff200149$export$881eb0d9f3605d9d(collection) {
243
+ let id = $bdb11010cef70236$export$f680877a34711e37();
244
+ $feb5ffebff200149$var$collectionMap.set(collection, id);
245
+ return id;
246
+ }
247
+ function $feb5ffebff200149$export$6aeb1680a0ae8741(collection) {
248
+ return $feb5ffebff200149$var$collectionMap.get(collection);
249
+ }
250
+ const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1e3;
251
+ function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
252
+ let { keyboardDelegate, selectionManager, onTypeSelect } = options;
253
+ let state = useRef({
254
+ search: "",
255
+ timeout: void 0
256
+ }).current;
257
+ let onKeyDown = (e) => {
258
+ let character = $fb3050f43d946246$var$getStringForKey(e.key);
259
+ if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target) || state.search.length === 0 && character === " ") return;
260
+ if (character === " " && state.search.trim().length > 0) {
261
+ e.preventDefault();
262
+ if (!("continuePropagation" in e)) e.stopPropagation();
235
263
  }
236
- return null;
237
- }
238
- getFirstKey() {
239
- return this.firstKey;
240
- }
241
- getLastKey() {
242
- let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;
243
- while ((node === null || node === void 0 ? void 0 : node.lastChildKey) != null) node = this.keyMap.get(node.lastChildKey);
244
- var _node_key;
245
- return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
246
- }
247
- getItem(key) {
248
- var _this_keyMap_get;
249
- return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
250
- }
251
- at() {
252
- throw new Error("Not implemented");
253
- }
254
- clone() {
255
- let Constructor = this.constructor;
256
- let collection = new Constructor();
257
- collection.keyMap = new Map(this.keyMap);
258
- collection.firstKey = this.firstKey;
259
- collection.lastKey = this.lastKey;
260
- collection.itemCount = this.itemCount;
261
- return collection;
262
- }
263
- addNode(node) {
264
- if (this.frozen) throw new Error("Cannot add a node to a frozen collection");
265
- if (node.type === "item" && this.keyMap.get(node.key) == null) this.itemCount++;
266
- this.keyMap.set(node.key, node);
267
- }
268
- removeNode(key) {
269
- if (this.frozen) throw new Error("Cannot remove a node to a frozen collection");
270
- let node = this.keyMap.get(key);
271
- if (node != null && node.type === "item") this.itemCount--;
272
- this.keyMap.delete(key);
273
- }
274
- commit(firstKey, lastKey, isSSR = false) {
275
- if (this.frozen) throw new Error("Cannot commit a frozen collection");
276
- this.firstKey = firstKey;
277
- this.lastKey = lastKey;
278
- this.frozen = !isSSR;
279
- }
280
- // TODO: this is pretty specific to menu, will need to check if it is generic enough
281
- // Will need to handle varying levels I assume but will revisit after I get searchable menu working for base menu
282
- // TODO: an alternative is to simply walk the collection and add all item nodes that match the filter and any sections/separators we encounter
283
- // to an array, then walk that new array and fix all the next/Prev keys while adding them to the new collection
284
- UNSTABLE_filter(filterFn) {
285
- let newCollection = new $23b9f4fcf0fe224b$export$408d25a4e12db025();
286
- let lastNode = null;
287
- for (let node of this) {
288
- if (node.type === "section" && node.hasChildNodes) {
289
- let clonedSection = node.clone();
290
- let lastChildInSection = null;
291
- for (let child of this.getChildren(node.key)) if ($23b9f4fcf0fe224b$var$shouldKeepNode(child, filterFn, this, newCollection)) {
292
- let clonedChild = child.clone();
293
- if (lastChildInSection == null) clonedSection.firstChildKey = clonedChild.key;
294
- if (newCollection.firstKey == null) newCollection.firstKey = clonedSection.key;
295
- if (lastChildInSection && lastChildInSection.parentKey === clonedChild.parentKey) {
296
- lastChildInSection.nextKey = clonedChild.key;
297
- clonedChild.prevKey = lastChildInSection.key;
298
- } else clonedChild.prevKey = null;
299
- clonedChild.nextKey = null;
300
- newCollection.addNode(clonedChild);
301
- lastChildInSection = clonedChild;
302
- }
303
- if (lastChildInSection) {
304
- if (lastChildInSection.type !== "header") {
305
- clonedSection.lastChildKey = lastChildInSection.key;
306
- if (lastNode == null) clonedSection.prevKey = null;
307
- else if (lastNode.type === "section" || lastNode.type === "separator") {
308
- lastNode.nextKey = clonedSection.key;
309
- clonedSection.prevKey = lastNode.key;
310
- }
311
- clonedSection.nextKey = null;
312
- lastNode = clonedSection;
313
- newCollection.addNode(clonedSection);
314
- } else {
315
- if (newCollection.firstKey === clonedSection.key) newCollection.firstKey = null;
316
- newCollection.removeNode(lastChildInSection.key);
317
- }
318
- }
319
- } else if (node.type === "separator") {
320
- let clonedSeparator = node.clone();
321
- clonedSeparator.nextKey = null;
322
- if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === "section") {
323
- lastNode.nextKey = clonedSeparator.key;
324
- clonedSeparator.prevKey = lastNode.key;
325
- lastNode = clonedSeparator;
326
- newCollection.addNode(clonedSeparator);
327
- }
328
- } else {
329
- let clonedNode = node.clone();
330
- if ($23b9f4fcf0fe224b$var$shouldKeepNode(clonedNode, filterFn, this, newCollection)) {
331
- if (newCollection.firstKey == null) newCollection.firstKey = clonedNode.key;
332
- if (lastNode != null && lastNode.type !== "section" && lastNode.type !== "separator" && lastNode.parentKey === clonedNode.parentKey) {
333
- lastNode.nextKey = clonedNode.key;
334
- clonedNode.prevKey = lastNode.key;
335
- } else clonedNode.prevKey = null;
336
- clonedNode.nextKey = null;
337
- newCollection.addNode(clonedNode);
338
- lastNode = clonedNode;
339
- }
264
+ state.search += character;
265
+ if (keyboardDelegate.getKeyForSearch != null) {
266
+ let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);
267
+ if (key == null) key = keyboardDelegate.getKeyForSearch(state.search);
268
+ if (key != null) {
269
+ selectionManager.setFocusedKey(key);
270
+ if (onTypeSelect) onTypeSelect(key);
340
271
  }
341
272
  }
342
- if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === "separator" && lastNode.nextKey === null) {
343
- let lastSection;
344
- if (lastNode.prevKey != null) {
345
- lastSection = newCollection.getItem(lastNode.prevKey);
346
- lastSection.nextKey = null;
347
- }
348
- newCollection.removeNode(lastNode.key);
349
- lastNode = lastSection;
273
+ clearTimeout(state.timeout);
274
+ state.timeout = setTimeout(() => {
275
+ state.search = "";
276
+ }, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
277
+ };
278
+ return {
279
+ typeSelectProps: {
280
+ // Using a capturing listener to catch the keydown event before
281
+ // other hooks in order to handle the Spacebar event.
282
+ onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : void 0
350
283
  }
351
- newCollection.lastKey = (lastNode === null || lastNode === void 0 ? void 0 : lastNode.key) || null;
352
- return newCollection;
353
- }
354
- constructor() {
355
- this.keyMap = /* @__PURE__ */ new Map();
356
- this.firstKey = null;
357
- this.lastKey = null;
358
- this.frozen = false;
359
- this.itemCount = 0;
360
- }
284
+ };
361
285
  }
362
- function $23b9f4fcf0fe224b$var$shouldKeepNode(node, filterFn, oldCollection, newCollection) {
363
- if (node.type === "subdialogtrigger" || node.type === "submenutrigger") {
364
- let triggerChild = [
365
- ...oldCollection.getChildren(node.key)
366
- ][0];
367
- if (triggerChild && filterFn(triggerChild.textValue)) {
368
- let clonedChild = triggerChild.clone();
369
- newCollection.addNode(clonedChild);
370
- return true;
371
- } else return false;
372
- } else if (node.type === "header") return true;
373
- else return filterFn(node.textValue);
286
+ function $fb3050f43d946246$var$getStringForKey(key) {
287
+ if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
288
+ return "";
374
289
  }
375
- class $681cc3c98f569e39$export$410b0c854570d131 {
376
- *[Symbol.iterator]() {
377
- let node = this.firstChild;
378
- while (node) {
379
- yield node;
380
- node = node.nextSibling;
290
+ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
291
+ let { selectionManager: manager, keyboardDelegate: delegate, ref, autoFocus = false, shouldFocusWrap = false, disallowEmptySelection = false, disallowSelectAll = false, escapeKeyBehavior = "clearSelection", selectOnFocus = manager.selectionBehavior === "replace", disallowTypeAhead = false, shouldUseVirtualFocus, allowsTabNavigation = false, isVirtualized, scrollRef = ref, linkBehavior = "action" } = options;
292
+ let { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
293
+ let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
294
+ let onKeyDown = (e) => {
295
+ var _ref_current;
296
+ if (e.altKey && e.key === "Tab") e.preventDefault();
297
+ if (!((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(e.target))) return;
298
+ const navigateToKey = (key, childFocus) => {
299
+ if (key != null) {
300
+ if (manager.isLink(key) && linkBehavior === "selection" && selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) {
301
+ reactDomExports.flushSync(() => {
302
+ manager.setFocusedKey(key, childFocus);
303
+ });
304
+ let item = $feb5ffebff200149$export$c3d8340acf92597f(ref, key);
305
+ let itemProps = manager.getItemProps(key);
306
+ if (item) router.open(item, e, itemProps.href, itemProps.routerOptions);
307
+ return;
308
+ }
309
+ manager.setFocusedKey(key, childFocus);
310
+ if (manager.isLink(key) && linkBehavior === "override") return;
311
+ if (e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(key);
312
+ else if (selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.replaceSelection(key);
313
+ }
314
+ };
315
+ switch (e.key) {
316
+ case "ArrowDown":
317
+ if (delegate.getKeyBelow) {
318
+ var _delegate_getKeyBelow, _delegate_getFirstKey, _delegate_getFirstKey1;
319
+ let nextKey = manager.focusedKey != null ? (_delegate_getKeyBelow = delegate.getKeyBelow) === null || _delegate_getKeyBelow === void 0 ? void 0 : _delegate_getKeyBelow.call(delegate, manager.focusedKey) : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate);
320
+ if (nextKey == null && shouldFocusWrap) nextKey = (_delegate_getFirstKey1 = delegate.getFirstKey) === null || _delegate_getFirstKey1 === void 0 ? void 0 : _delegate_getFirstKey1.call(delegate, manager.focusedKey);
321
+ if (nextKey != null) {
322
+ e.preventDefault();
323
+ navigateToKey(nextKey);
324
+ }
325
+ }
326
+ break;
327
+ case "ArrowUp":
328
+ if (delegate.getKeyAbove) {
329
+ var _delegate_getKeyAbove, _delegate_getLastKey, _delegate_getLastKey1;
330
+ let nextKey = manager.focusedKey != null ? (_delegate_getKeyAbove = delegate.getKeyAbove) === null || _delegate_getKeyAbove === void 0 ? void 0 : _delegate_getKeyAbove.call(delegate, manager.focusedKey) : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate);
331
+ if (nextKey == null && shouldFocusWrap) nextKey = (_delegate_getLastKey1 = delegate.getLastKey) === null || _delegate_getLastKey1 === void 0 ? void 0 : _delegate_getLastKey1.call(delegate, manager.focusedKey);
332
+ if (nextKey != null) {
333
+ e.preventDefault();
334
+ navigateToKey(nextKey);
335
+ }
336
+ }
337
+ break;
338
+ case "ArrowLeft":
339
+ if (delegate.getKeyLeftOf) {
340
+ var _delegate_getKeyLeftOf, _delegate_getFirstKey2, _delegate_getLastKey2;
341
+ let nextKey = manager.focusedKey != null ? (_delegate_getKeyLeftOf = delegate.getKeyLeftOf) === null || _delegate_getKeyLeftOf === void 0 ? void 0 : _delegate_getKeyLeftOf.call(delegate, manager.focusedKey) : null;
342
+ if (nextKey == null && shouldFocusWrap) nextKey = direction === "rtl" ? (_delegate_getFirstKey2 = delegate.getFirstKey) === null || _delegate_getFirstKey2 === void 0 ? void 0 : _delegate_getFirstKey2.call(delegate, manager.focusedKey) : (_delegate_getLastKey2 = delegate.getLastKey) === null || _delegate_getLastKey2 === void 0 ? void 0 : _delegate_getLastKey2.call(delegate, manager.focusedKey);
343
+ if (nextKey != null) {
344
+ e.preventDefault();
345
+ navigateToKey(nextKey, direction === "rtl" ? "first" : "last");
346
+ }
347
+ }
348
+ break;
349
+ case "ArrowRight":
350
+ if (delegate.getKeyRightOf) {
351
+ var _delegate_getKeyRightOf, _delegate_getLastKey3, _delegate_getFirstKey3;
352
+ let nextKey = manager.focusedKey != null ? (_delegate_getKeyRightOf = delegate.getKeyRightOf) === null || _delegate_getKeyRightOf === void 0 ? void 0 : _delegate_getKeyRightOf.call(delegate, manager.focusedKey) : null;
353
+ if (nextKey == null && shouldFocusWrap) nextKey = direction === "rtl" ? (_delegate_getLastKey3 = delegate.getLastKey) === null || _delegate_getLastKey3 === void 0 ? void 0 : _delegate_getLastKey3.call(delegate, manager.focusedKey) : (_delegate_getFirstKey3 = delegate.getFirstKey) === null || _delegate_getFirstKey3 === void 0 ? void 0 : _delegate_getFirstKey3.call(delegate, manager.focusedKey);
354
+ if (nextKey != null) {
355
+ e.preventDefault();
356
+ navigateToKey(nextKey, direction === "rtl" ? "last" : "first");
357
+ }
358
+ }
359
+ break;
360
+ case "Home":
361
+ if (delegate.getFirstKey) {
362
+ if (manager.focusedKey === null && e.shiftKey) return;
363
+ e.preventDefault();
364
+ let firstKey = delegate.getFirstKey(manager.focusedKey, $21f1aa98acb08317$export$16792effe837dba3(e));
365
+ manager.setFocusedKey(firstKey);
366
+ if (firstKey != null) {
367
+ if ($21f1aa98acb08317$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(firstKey);
368
+ else if (selectOnFocus) manager.replaceSelection(firstKey);
369
+ }
370
+ }
371
+ break;
372
+ case "End":
373
+ if (delegate.getLastKey) {
374
+ if (manager.focusedKey === null && e.shiftKey) return;
375
+ e.preventDefault();
376
+ let lastKey = delegate.getLastKey(manager.focusedKey, $21f1aa98acb08317$export$16792effe837dba3(e));
377
+ manager.setFocusedKey(lastKey);
378
+ if (lastKey != null) {
379
+ if ($21f1aa98acb08317$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(lastKey);
380
+ else if (selectOnFocus) manager.replaceSelection(lastKey);
381
+ }
382
+ }
383
+ break;
384
+ case "PageDown":
385
+ if (delegate.getKeyPageBelow && manager.focusedKey != null) {
386
+ let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
387
+ if (nextKey != null) {
388
+ e.preventDefault();
389
+ navigateToKey(nextKey);
390
+ }
391
+ }
392
+ break;
393
+ case "PageUp":
394
+ if (delegate.getKeyPageAbove && manager.focusedKey != null) {
395
+ let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
396
+ if (nextKey != null) {
397
+ e.preventDefault();
398
+ navigateToKey(nextKey);
399
+ }
400
+ }
401
+ break;
402
+ case "a":
403
+ if ($21f1aa98acb08317$export$16792effe837dba3(e) && manager.selectionMode === "multiple" && disallowSelectAll !== true) {
404
+ e.preventDefault();
405
+ manager.selectAll();
406
+ }
407
+ break;
408
+ case "Escape":
409
+ if (escapeKeyBehavior === "clearSelection" && !disallowEmptySelection && manager.selectedKeys.size !== 0) {
410
+ e.stopPropagation();
411
+ e.preventDefault();
412
+ manager.clearSelection();
413
+ }
414
+ break;
415
+ case "Tab":
416
+ if (!allowsTabNavigation) {
417
+ if (e.shiftKey) ref.current.focus();
418
+ else {
419
+ let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ref.current, {
420
+ tabbable: true
421
+ });
422
+ let next = void 0;
423
+ let last;
424
+ do {
425
+ last = walker.lastChild();
426
+ if (last) next = last;
427
+ } while (last);
428
+ if (next && !next.contains(document.activeElement)) $7215afc6de606d6b$export$de79e2c695e052f3(next);
429
+ }
430
+ break;
431
+ }
381
432
  }
382
- }
383
- get firstChild() {
384
- return this._firstChild;
385
- }
386
- set firstChild(firstChild) {
387
- this._firstChild = firstChild;
388
- this.ownerDocument.markDirty(this);
389
- }
390
- get lastChild() {
391
- return this._lastChild;
392
- }
393
- set lastChild(lastChild) {
394
- this._lastChild = lastChild;
395
- this.ownerDocument.markDirty(this);
396
- }
397
- get previousSibling() {
398
- return this._previousSibling;
399
- }
400
- set previousSibling(previousSibling) {
401
- this._previousSibling = previousSibling;
402
- this.ownerDocument.markDirty(this);
403
- }
404
- get nextSibling() {
405
- return this._nextSibling;
406
- }
407
- set nextSibling(nextSibling) {
408
- this._nextSibling = nextSibling;
409
- this.ownerDocument.markDirty(this);
410
- }
411
- get parentNode() {
412
- return this._parentNode;
413
- }
414
- set parentNode(parentNode) {
415
- this._parentNode = parentNode;
416
- this.ownerDocument.markDirty(this);
417
- }
418
- get isConnected() {
419
- var _this_parentNode;
420
- return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
421
- }
422
- invalidateChildIndices(child) {
423
- if (this._minInvalidChildIndex == null || !this._minInvalidChildIndex.isConnected || child.index < this._minInvalidChildIndex.index) {
424
- this._minInvalidChildIndex = child;
425
- this.ownerDocument.markDirty(this);
433
+ };
434
+ let scrollPos = useRef({
435
+ top: 0,
436
+ left: 0
437
+ });
438
+ $e9faafb641e167db$export$90fc3a17d93f704c(scrollRef, "scroll", isVirtualized ? void 0 : () => {
439
+ var _scrollRef_current, _scrollRef_current1;
440
+ var _scrollRef_current_scrollTop, _scrollRef_current_scrollLeft;
441
+ scrollPos.current = {
442
+ top: (_scrollRef_current_scrollTop = (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 ? void 0 : _scrollRef_current.scrollTop) !== null && _scrollRef_current_scrollTop !== void 0 ? _scrollRef_current_scrollTop : 0,
443
+ left: (_scrollRef_current_scrollLeft = (_scrollRef_current1 = scrollRef.current) === null || _scrollRef_current1 === void 0 ? void 0 : _scrollRef_current1.scrollLeft) !== null && _scrollRef_current_scrollLeft !== void 0 ? _scrollRef_current_scrollLeft : 0
444
+ };
445
+ });
446
+ let onFocus = (e) => {
447
+ if (manager.isFocused) {
448
+ if (!e.currentTarget.contains(e.target)) manager.setFocused(false);
449
+ return;
426
450
  }
427
- }
428
- updateChildIndices() {
429
- let node = this._minInvalidChildIndex;
430
- while (node) {
431
- node.index = node.previousSibling ? node.previousSibling.index + 1 : 0;
432
- node = node.nextSibling;
451
+ if (!e.currentTarget.contains(e.target)) return;
452
+ manager.setFocused(true);
453
+ if (manager.focusedKey == null) {
454
+ var _delegate_getLastKey, _delegate_getFirstKey;
455
+ let navigateToKey = (key) => {
456
+ if (key != null) {
457
+ manager.setFocusedKey(key);
458
+ if (selectOnFocus && !manager.isSelected(key)) manager.replaceSelection(key);
459
+ }
460
+ };
461
+ let relatedTarget = e.relatedTarget;
462
+ var _manager_lastSelectedKey, _manager_firstSelectedKey;
463
+ if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate));
464
+ else navigateToKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate));
465
+ } else if (!isVirtualized && scrollRef.current) {
466
+ scrollRef.current.scrollTop = scrollPos.current.top;
467
+ scrollRef.current.scrollLeft = scrollPos.current.left;
433
468
  }
434
- this._minInvalidChildIndex = null;
435
- }
436
- appendChild(child) {
437
- if (child.parentNode) child.parentNode.removeChild(child);
438
- if (this.firstChild == null) this.firstChild = child;
439
- if (this.lastChild) {
440
- this.lastChild.nextSibling = child;
441
- child.index = this.lastChild.index + 1;
442
- child.previousSibling = this.lastChild;
443
- } else {
444
- child.previousSibling = null;
445
- child.index = 0;
446
- }
447
- child.parentNode = this;
448
- child.nextSibling = null;
449
- this.lastChild = child;
450
- this.ownerDocument.markDirty(this);
451
- if (this.isConnected) this.ownerDocument.queueUpdate();
452
- }
453
- insertBefore(newNode, referenceNode) {
454
- if (referenceNode == null) return this.appendChild(newNode);
455
- if (newNode.parentNode) newNode.parentNode.removeChild(newNode);
456
- newNode.nextSibling = referenceNode;
457
- newNode.previousSibling = referenceNode.previousSibling;
458
- newNode.index = referenceNode.index - 1;
459
- if (this.firstChild === referenceNode) this.firstChild = newNode;
460
- else if (referenceNode.previousSibling) referenceNode.previousSibling.nextSibling = newNode;
461
- referenceNode.previousSibling = newNode;
462
- newNode.parentNode = referenceNode.parentNode;
463
- this.invalidateChildIndices(newNode);
464
- if (this.isConnected) this.ownerDocument.queueUpdate();
465
- }
466
- removeChild(child) {
467
- if (child.parentNode !== this || !this.ownerDocument.isMounted) return;
468
- if (this._minInvalidChildIndex === child) this._minInvalidChildIndex = null;
469
- if (child.nextSibling) {
470
- this.invalidateChildIndices(child.nextSibling);
471
- child.nextSibling.previousSibling = child.previousSibling;
472
- }
473
- if (child.previousSibling) child.previousSibling.nextSibling = child.nextSibling;
474
- if (this.firstChild === child) this.firstChild = child.nextSibling;
475
- if (this.lastChild === child) this.lastChild = child.previousSibling;
476
- child.parentNode = null;
477
- child.nextSibling = null;
478
- child.previousSibling = null;
479
- child.index = 0;
480
- this.ownerDocument.markDirty(child);
481
- if (this.isConnected) this.ownerDocument.queueUpdate();
482
- }
483
- addEventListener() {
484
- }
485
- removeEventListener() {
486
- }
487
- get previousVisibleSibling() {
488
- let node = this.previousSibling;
489
- while (node && node.isHidden) node = node.previousSibling;
490
- return node;
491
- }
492
- get nextVisibleSibling() {
493
- let node = this.nextSibling;
494
- while (node && node.isHidden) node = node.nextSibling;
495
- return node;
496
- }
497
- get firstVisibleChild() {
498
- let node = this.firstChild;
499
- while (node && node.isHidden) node = node.nextSibling;
500
- return node;
501
- }
502
- get lastVisibleChild() {
503
- let node = this.lastChild;
504
- while (node && node.isHidden) node = node.previousSibling;
505
- return node;
506
- }
507
- constructor(ownerDocument) {
508
- this._firstChild = null;
509
- this._lastChild = null;
510
- this._previousSibling = null;
511
- this._nextSibling = null;
512
- this._parentNode = null;
513
- this._minInvalidChildIndex = null;
514
- this.ownerDocument = ownerDocument;
515
- }
516
- }
517
- class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export$410b0c854570d131 {
518
- get index() {
519
- return this._index;
520
- }
521
- set index(index) {
522
- this._index = index;
523
- this.ownerDocument.markDirty(this);
524
- }
525
- get level() {
526
- if (this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) return this.parentNode.level + (this.node.type === "item" ? 1 : 0);
527
- return 0;
528
- }
529
- /**
530
- * Lazily gets a mutable instance of a Node. If the node has already
531
- * been cloned during this update cycle, it just returns the existing one.
532
- */
533
- getMutableNode() {
534
- if (!this.isMutated) {
535
- this.node = this.node.clone();
536
- this.isMutated = true;
537
- }
538
- this.ownerDocument.markDirty(this);
539
- return this.node;
540
- }
541
- updateNode() {
542
- var _this_previousVisibleSibling, _this_firstVisibleChild, _this_lastVisibleChild;
543
- let nextSibling = this.nextVisibleSibling;
544
- let node = this.getMutableNode();
545
- node.index = this.index;
546
- node.level = this.level;
547
- node.parentKey = this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd ? this.parentNode.node.key : null;
548
- var _this_previousVisibleSibling_node_key;
549
- node.prevKey = (_this_previousVisibleSibling_node_key = (_this_previousVisibleSibling = this.previousVisibleSibling) === null || _this_previousVisibleSibling === void 0 ? void 0 : _this_previousVisibleSibling.node.key) !== null && _this_previousVisibleSibling_node_key !== void 0 ? _this_previousVisibleSibling_node_key : null;
550
- var _nextSibling_node_key;
551
- node.nextKey = (_nextSibling_node_key = nextSibling === null || nextSibling === void 0 ? void 0 : nextSibling.node.key) !== null && _nextSibling_node_key !== void 0 ? _nextSibling_node_key : null;
552
- node.hasChildNodes = !!this.firstChild;
553
- var _this_firstVisibleChild_node_key;
554
- node.firstChildKey = (_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : _this_firstVisibleChild.node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null;
555
- var _this_lastVisibleChild_node_key;
556
- node.lastChildKey = (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : _this_lastVisibleChild.node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null;
557
- if ((node.colSpan != null || node.colIndex != null) && nextSibling) {
558
- var _node_colIndex, _node_colSpan;
559
- let nextColIndex = ((_node_colIndex = node.colIndex) !== null && _node_colIndex !== void 0 ? _node_colIndex : node.index) + ((_node_colSpan = node.colSpan) !== null && _node_colSpan !== void 0 ? _node_colSpan : 1);
560
- if (nextColIndex !== nextSibling.node.colIndex) {
561
- let siblingNode = nextSibling.getMutableNode();
562
- siblingNode.colIndex = nextColIndex;
469
+ if (manager.focusedKey != null && scrollRef.current) {
470
+ let element = $feb5ffebff200149$export$c3d8340acf92597f(ref, manager.focusedKey);
471
+ if (element instanceof HTMLElement) {
472
+ if (!element.contains(document.activeElement) && !shouldUseVirtualFocus) $7215afc6de606d6b$export$de79e2c695e052f3(element);
473
+ let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
474
+ if (modality === "keyboard") $2f04cbc44ee30ce0$export$c826860796309d1b(element, {
475
+ containingElement: ref.current
476
+ });
563
477
  }
564
478
  }
565
- }
566
- setProps(obj, ref, rendered, render) {
567
- let node = this.getMutableNode();
568
- let { value: value1, textValue, id, ...props } = obj;
569
- props.ref = ref;
570
- node.props = props;
571
- node.rendered = rendered;
572
- node.render = render;
573
- node.value = value1;
574
- node.textValue = textValue || (typeof props.children === "string" ? props.children : "") || obj["aria-label"] || "";
575
- if (id != null && id !== node.key) {
576
- if (this.hasSetProps) throw new Error("Cannot change the id of an item");
577
- node.key = id;
479
+ };
480
+ let onBlur = (e) => {
481
+ if (!e.currentTarget.contains(e.relatedTarget)) manager.setFocused(false);
482
+ };
483
+ let shouldVirtualFocusFirst = useRef(false);
484
+ $e9faafb641e167db$export$90fc3a17d93f704c(ref, $5671b20cf9b562b2$export$831c820ad60f9d12, !shouldUseVirtualFocus ? void 0 : (e) => {
485
+ let { detail } = e;
486
+ e.stopPropagation();
487
+ manager.setFocused(true);
488
+ if ((detail === null || detail === void 0 ? void 0 : detail.focusStrategy) === "first") shouldVirtualFocusFirst.current = true;
489
+ });
490
+ let updateActiveDescendant = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
491
+ var _delegate_getFirstKey;
492
+ var _delegate_getFirstKey1;
493
+ let keyToFocus = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null;
494
+ if (keyToFocus == null) {
495
+ let previousActiveElement = $d4ee10de306f2510$export$cd4e5573fbe2b576();
496
+ $55f9b1ae81f22853$export$76e4e37e5339496d(ref.current);
497
+ $55f9b1ae81f22853$export$2b35b76d2e30e129(previousActiveElement, null);
498
+ if (manager.collection.size > 0) shouldVirtualFocusFirst.current = false;
499
+ } else {
500
+ manager.setFocusedKey(keyToFocus);
501
+ shouldVirtualFocusFirst.current = false;
578
502
  }
579
- if (props.colSpan != null) node.colSpan = props.colSpan;
580
- this.hasSetProps = true;
581
- if (this.isConnected) this.ownerDocument.queueUpdate();
582
- }
583
- get style() {
584
- let element = this;
585
- return {
586
- get display() {
587
- return element.isHidden ? "none" : "";
588
- },
589
- set display(value) {
590
- let isHidden = value === "none";
591
- if (element.isHidden !== isHidden) {
592
- var _element_parentNode, _element_parentNode1;
593
- if (((_element_parentNode = element.parentNode) === null || _element_parentNode === void 0 ? void 0 : _element_parentNode.firstVisibleChild) === element || ((_element_parentNode1 = element.parentNode) === null || _element_parentNode1 === void 0 ? void 0 : _element_parentNode1.lastVisibleChild) === element) element.ownerDocument.markDirty(element.parentNode);
594
- let prev = element.previousVisibleSibling;
595
- let next = element.nextVisibleSibling;
596
- if (prev) element.ownerDocument.markDirty(prev);
597
- if (next) element.ownerDocument.markDirty(next);
598
- element.isHidden = isHidden;
599
- element.ownerDocument.markDirty(element);
503
+ });
504
+ $ca9b37712f007381$export$72ef708ab07251f1(() => {
505
+ if (shouldVirtualFocusFirst.current) updateActiveDescendant();
506
+ }, [
507
+ manager.collection,
508
+ updateActiveDescendant
509
+ ]);
510
+ let resetFocusFirstFlag = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
511
+ if (manager.collection.size > 0) shouldVirtualFocusFirst.current = false;
512
+ });
513
+ $ca9b37712f007381$export$72ef708ab07251f1(() => {
514
+ resetFocusFirstFlag();
515
+ }, [
516
+ manager.focusedKey,
517
+ resetFocusFirstFlag
518
+ ]);
519
+ $e9faafb641e167db$export$90fc3a17d93f704c(ref, $5671b20cf9b562b2$export$447a38995de2c711, !shouldUseVirtualFocus ? void 0 : (e) => {
520
+ var _e_detail;
521
+ e.stopPropagation();
522
+ manager.setFocused(false);
523
+ if ((_e_detail = e.detail) === null || _e_detail === void 0 ? void 0 : _e_detail.clearFocusKey) manager.setFocusedKey(null);
524
+ });
525
+ const autoFocusRef = useRef(autoFocus);
526
+ const didAutoFocusRef = useRef(false);
527
+ useEffect(() => {
528
+ if (autoFocusRef.current) {
529
+ var _delegate_getFirstKey, _delegate_getLastKey;
530
+ let focusedKey = null;
531
+ var _delegate_getFirstKey1;
532
+ if (autoFocus === "first") focusedKey = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null;
533
+ var _delegate_getLastKey1;
534
+ if (autoFocus === "last") focusedKey = (_delegate_getLastKey1 = (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate)) !== null && _delegate_getLastKey1 !== void 0 ? _delegate_getLastKey1 : null;
535
+ let selectedKeys = manager.selectedKeys;
536
+ if (selectedKeys.size) {
537
+ for (let key of selectedKeys) if (manager.canSelectItem(key)) {
538
+ focusedKey = key;
539
+ break;
600
540
  }
601
541
  }
542
+ manager.setFocused(true);
543
+ manager.setFocusedKey(focusedKey);
544
+ if (focusedKey == null && !shouldUseVirtualFocus && ref.current) $3ad3f6e1647bc98d$export$80f3e147d781571c(ref.current);
545
+ if (manager.collection.size > 0) {
546
+ autoFocusRef.current = false;
547
+ didAutoFocusRef.current = true;
548
+ }
549
+ }
550
+ });
551
+ let lastFocusedKey = useRef(manager.focusedKey);
552
+ let raf = useRef(null);
553
+ useEffect(() => {
554
+ if (manager.isFocused && manager.focusedKey != null && (manager.focusedKey !== lastFocusedKey.current || didAutoFocusRef.current) && scrollRef.current && ref.current) {
555
+ let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
556
+ let element = $feb5ffebff200149$export$c3d8340acf92597f(ref, manager.focusedKey);
557
+ if (!(element instanceof HTMLElement))
558
+ return;
559
+ if (modality === "keyboard" || didAutoFocusRef.current) {
560
+ if (raf.current) cancelAnimationFrame(raf.current);
561
+ raf.current = requestAnimationFrame(() => {
562
+ if (scrollRef.current) {
563
+ $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollRef.current, element);
564
+ if (modality !== "virtual") $2f04cbc44ee30ce0$export$c826860796309d1b(element, {
565
+ containingElement: ref.current
566
+ });
567
+ }
568
+ });
569
+ }
570
+ }
571
+ if (!shouldUseVirtualFocus && manager.isFocused && manager.focusedKey == null && lastFocusedKey.current != null && ref.current) $3ad3f6e1647bc98d$export$80f3e147d781571c(ref.current);
572
+ lastFocusedKey.current = manager.focusedKey;
573
+ didAutoFocusRef.current = false;
574
+ });
575
+ useEffect(() => {
576
+ return () => {
577
+ if (raf.current) cancelAnimationFrame(raf.current);
602
578
  };
603
- }
604
- hasAttribute() {
605
- }
606
- setAttribute() {
607
- }
608
- setAttributeNS() {
609
- }
610
- removeAttribute() {
611
- }
612
- constructor(type, ownerDocument) {
613
- super(ownerDocument), this.nodeType = 8, this.isMutated = true, this._index = 0, this.hasSetProps = false, this.isHidden = false;
614
- this.node = new $23b9f4fcf0fe224b$export$d68d59712b04d9d1(type, `react-aria-${++ownerDocument.nodeId}`);
615
- }
616
- }
617
- class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export$410b0c854570d131 {
618
- get isConnected() {
619
- return this.isMounted;
620
- }
621
- createElement(type) {
622
- return new $681cc3c98f569e39$export$dc064fe9e59310fd(type, this);
623
- }
624
- getMutableCollection() {
625
- if (!this.nextCollection) this.nextCollection = this.collection.clone();
626
- return this.nextCollection;
627
- }
628
- markDirty(node) {
629
- this.dirtyNodes.add(node);
630
- }
631
- addNode(element) {
632
- if (element.isHidden) return;
633
- let collection = this.getMutableCollection();
634
- if (!collection.getItem(element.node.key)) for (let child of element) this.addNode(child);
635
- collection.addNode(element.node);
636
- }
637
- removeNode(node) {
638
- for (let child of node) this.removeNode(child);
639
- let collection = this.getMutableCollection();
640
- collection.removeNode(node.node.key);
641
- }
642
- /** Finalizes the collection update, updating all nodes and freezing the collection. */
643
- getCollection() {
644
- if (this.inSubscription) return this.collection.clone();
645
- this.queuedRender = false;
646
- this.updateCollection();
647
- return this.collection;
648
- }
649
- updateCollection() {
650
- for (let element of this.dirtyNodes) if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd && (!element.isConnected || element.isHidden)) this.removeNode(element);
651
- else element.updateChildIndices();
652
- for (let element of this.dirtyNodes) if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) {
653
- if (element.isConnected && !element.isHidden) {
654
- element.updateNode();
655
- this.addNode(element);
656
- }
657
- element.isMutated = false;
579
+ }, []);
580
+ $e9faafb641e167db$export$90fc3a17d93f704c(ref, "react-aria-focus-scope-restore", (e) => {
581
+ e.preventDefault();
582
+ manager.setFocused(true);
583
+ });
584
+ let handlers = {
585
+ onKeyDown,
586
+ onFocus,
587
+ onBlur,
588
+ onMouseDown(e) {
589
+ if (scrollRef.current === e.target)
590
+ e.preventDefault();
658
591
  }
659
- this.dirtyNodes.clear();
660
- if (this.nextCollection) {
661
- var _this_firstVisibleChild, _this_lastVisibleChild;
662
- var _this_firstVisibleChild_node_key, _this_lastVisibleChild_node_key;
663
- this.nextCollection.commit((_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : _this_firstVisibleChild.node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null, (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : _this_lastVisibleChild.node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null, this.isSSR);
664
- if (!this.isSSR) {
665
- this.collection = this.nextCollection;
666
- this.nextCollection = null;
592
+ };
593
+ let { typeSelectProps } = $fb3050f43d946246$export$e32c88dfddc6e1d8({
594
+ keyboardDelegate: delegate,
595
+ selectionManager: manager
596
+ });
597
+ if (!disallowTypeAhead) handlers = $3ef42575df84b30b$export$9d1611c77c2fe928(typeSelectProps, handlers);
598
+ let tabIndex = void 0;
599
+ if (!shouldUseVirtualFocus) tabIndex = manager.focusedKey == null ? 0 : -1;
600
+ let collectionId = $feb5ffebff200149$export$881eb0d9f3605d9d(manager.collection);
601
+ return {
602
+ collectionProps: $3ef42575df84b30b$export$9d1611c77c2fe928(handlers, {
603
+ tabIndex,
604
+ "data-collection": collectionId
605
+ })
606
+ };
607
+ }
608
+ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
609
+ let { id, selectionManager: manager, key, ref, shouldSelectOnPressUp, shouldUseVirtualFocus, focus, isDisabled, onAction, allowsDifferentPressOrigin, linkBehavior = "action" } = options;
610
+ let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
611
+ id = $bdb11010cef70236$export$f680877a34711e37(id);
612
+ let onSelect = (e) => {
613
+ if (e.pointerType === "keyboard" && $feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.toggleSelection(key);
614
+ else {
615
+ if (manager.selectionMode === "none") return;
616
+ if (manager.isLink(key)) {
617
+ if (linkBehavior === "selection" && ref.current) {
618
+ let itemProps2 = manager.getItemProps(key);
619
+ router.open(ref.current, e, itemProps2.href, itemProps2.routerOptions);
620
+ manager.setSelectedKeys(manager.selectedKeys);
621
+ return;
622
+ } else if (linkBehavior === "override" || linkBehavior === "none") return;
667
623
  }
624
+ if (manager.selectionMode === "single") {
625
+ if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
626
+ else manager.replaceSelection(key);
627
+ } else if (e && e.shiftKey) manager.extendSelection(key);
628
+ else if (manager.selectionBehavior === "toggle" || e && ($21f1aa98acb08317$export$16792effe837dba3(e) || e.pointerType === "touch" || e.pointerType === "virtual"))
629
+ manager.toggleSelection(key);
630
+ else manager.replaceSelection(key);
668
631
  }
669
- }
670
- queueUpdate() {
671
- if (this.dirtyNodes.size === 0 || this.queuedRender) return;
672
- this.queuedRender = true;
673
- this.inSubscription = true;
674
- for (let fn of this.subscriptions) fn();
675
- this.inSubscription = false;
676
- }
677
- subscribe(fn) {
678
- this.subscriptions.add(fn);
679
- return () => this.subscriptions.delete(fn);
680
- }
681
- resetAfterSSR() {
682
- if (this.isSSR) {
683
- this.isSSR = false;
684
- this.firstChild = null;
685
- this.lastChild = null;
686
- this.nodeId = 0;
632
+ };
633
+ useEffect(() => {
634
+ let isFocused = key === manager.focusedKey;
635
+ if (isFocused && manager.isFocused) {
636
+ if (!shouldUseVirtualFocus) {
637
+ if (focus) focus();
638
+ else if (document.activeElement !== ref.current && ref.current) $3ad3f6e1647bc98d$export$80f3e147d781571c(ref.current);
639
+ } else $55f9b1ae81f22853$export$76e4e37e5339496d(ref.current);
687
640
  }
688
- }
689
- constructor(collection) {
690
- super(null), this.nodeType = 11, this.ownerDocument = this, this.dirtyNodes = /* @__PURE__ */ new Set(), this.isSSR = false, this.nodeId = 0, this.nodesByProps = /* @__PURE__ */ new WeakMap(), this.isMounted = true, this.nextCollection = null, this.subscriptions = /* @__PURE__ */ new Set(), this.queuedRender = false, this.inSubscription = false;
691
- this.collection = collection;
692
- this.nextCollection = collection;
693
- }
694
- }
695
- function $e948873055cbafe4$export$727c8fc270210f13(props) {
696
- let { children, items, idScope, addIdAndValue, dependencies = [] } = props;
697
- let cache = useMemo(() => /* @__PURE__ */ new WeakMap(), dependencies);
698
- return useMemo(() => {
699
- if (items && typeof children === "function") {
700
- let res = [];
701
- for (let item of items) {
702
- let rendered = cache.get(item);
703
- if (!rendered) {
704
- rendered = children(item);
705
- var _rendered_props_id, _ref;
706
- let key = (_ref = (_rendered_props_id = rendered.props.id) !== null && _rendered_props_id !== void 0 ? _rendered_props_id : item.key) !== null && _ref !== void 0 ? _ref : item.id;
707
- if (key == null) throw new Error("Could not determine key for item");
708
- if (idScope) key = idScope + ":" + key;
709
- rendered = cloneElement(rendered, addIdAndValue ? {
710
- key,
711
- id: key,
712
- value: item
713
- } : {
714
- key
715
- });
716
- cache.set(item, rendered);
717
- }
718
- res.push(rendered);
719
- }
720
- return res;
721
- } else if (typeof children !== "function") return children;
722
641
  }, [
723
- children,
724
- items,
725
- cache,
726
- idScope,
727
- addIdAndValue
642
+ ref,
643
+ key,
644
+ manager.focusedKey,
645
+ manager.childFocusStrategy,
646
+ manager.isFocused,
647
+ shouldUseVirtualFocus
728
648
  ]);
729
- }
730
- const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
731
- function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
732
- let { isDisabled, onLongPressStart, onLongPressEnd, onLongPress, threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD, accessibilityDescription } = props;
733
- const timeRef = useRef(void 0);
734
- let { addGlobalListener, removeGlobalListener } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
735
- let { pressProps } = $f6c31cce2adf654f$export$45712eceda6fad21({
736
- isDisabled,
737
- onPressStart(e) {
738
- e.continuePropagation();
739
- if (e.pointerType === "mouse" || e.pointerType === "touch") {
740
- if (onLongPressStart) onLongPressStart({
741
- ...e,
742
- type: "longpressstart"
743
- });
744
- timeRef.current = setTimeout(() => {
745
- e.target.dispatchEvent(new PointerEvent("pointercancel", {
746
- bubbles: true
747
- }));
748
- if ($431fbd86ca7dc216$export$b204af158042fbac(e.target).activeElement !== e.target) $7215afc6de606d6b$export$de79e2c695e052f3(e.target);
749
- if (onLongPress) onLongPress({
750
- ...e,
751
- type: "longpress"
752
- });
753
- timeRef.current = void 0;
754
- }, threshold);
755
- if (e.pointerType === "touch") {
756
- let onContextMenu = (e2) => {
757
- e2.preventDefault();
758
- };
759
- addGlobalListener(e.target, "contextmenu", onContextMenu, {
760
- once: true
761
- });
762
- addGlobalListener(window, "pointerup", () => {
763
- setTimeout(() => {
764
- removeGlobalListener(e.target, "contextmenu", onContextMenu);
765
- }, 30);
766
- }, {
767
- once: true
768
- });
769
- }
770
- }
771
- },
772
- onPressEnd(e) {
773
- if (timeRef.current) clearTimeout(timeRef.current);
774
- if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
775
- ...e,
776
- type: "longpressend"
777
- });
649
+ isDisabled = isDisabled || manager.isDisabled(key);
650
+ let itemProps = {};
651
+ if (!shouldUseVirtualFocus && !isDisabled) itemProps = {
652
+ tabIndex: key === manager.focusedKey ? 0 : -1,
653
+ onFocus(e) {
654
+ if (e.target === ref.current) manager.setFocusedKey(key);
778
655
  }
779
- });
780
- let descriptionProps = $ef06256079686ba0$export$f8aeda7b10753fa1(onLongPress && !isDisabled ? accessibilityDescription : void 0);
781
- return {
782
- longPressProps: $3ef42575df84b30b$export$9d1611c77c2fe928(pressProps, descriptionProps)
783
656
  };
784
- }
785
- var shim = { exports: {} };
786
- var useSyncExternalStoreShim_production = {};
787
- /**
788
- * @license React
789
- * use-sync-external-store-shim.production.js
790
- *
791
- * Copyright (c) Meta Platforms, Inc. and affiliates.
792
- *
793
- * This source code is licensed under the MIT license found in the
794
- * LICENSE file in the root directory of this source tree.
795
- */
796
- var hasRequiredUseSyncExternalStoreShim_production;
797
- function requireUseSyncExternalStoreShim_production() {
798
- if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
799
- hasRequiredUseSyncExternalStoreShim_production = 1;
800
- var React = React__default;
801
- function is(x, y) {
802
- return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
803
- }
804
- var objectIs = "function" === typeof Object.is ? Object.is : is, useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
805
- function useSyncExternalStore$2(subscribe, getSnapshot) {
806
- var value = getSnapshot(), _useState = useState2({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
807
- useLayoutEffect(
808
- function() {
809
- inst.value = value;
810
- inst.getSnapshot = getSnapshot;
811
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
812
- },
813
- [subscribe, value, getSnapshot]
814
- );
815
- useEffect2(
816
- function() {
817
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
818
- return subscribe(function() {
819
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
820
- });
821
- },
822
- [subscribe]
823
- );
824
- useDebugValue(value);
825
- return value;
826
- }
827
- function checkIfSnapshotChanged(inst) {
828
- var latestGetSnapshot = inst.getSnapshot;
829
- inst = inst.value;
830
- try {
831
- var nextValue = latestGetSnapshot();
832
- return !objectIs(inst, nextValue);
833
- } catch (error) {
834
- return true;
657
+ else if (isDisabled) itemProps.onMouseDown = (e) => {
658
+ e.preventDefault();
659
+ };
660
+ let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
661
+ let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
662
+ let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
663
+ let allowsActions = (onAction || hasLinkAction) && !isDisabled;
664
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
665
+ let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
666
+ let hasAction = hasPrimaryAction || hasSecondaryAction;
667
+ let modality = useRef(null);
668
+ let longPressEnabled = hasAction && allowsSelection;
669
+ let longPressEnabledOnPressStart = useRef(false);
670
+ let hadPrimaryActionOnPressStart = useRef(false);
671
+ let collectionItemProps = manager.getItemProps(key);
672
+ let performAction = (e) => {
673
+ if (onAction) onAction();
674
+ if (hasLinkAction && ref.current) router.open(ref.current, e, collectionItemProps.href, collectionItemProps.routerOptions);
675
+ };
676
+ let itemPressProps = {
677
+ ref
678
+ };
679
+ if (shouldSelectOnPressUp) {
680
+ itemPressProps.onPressStart = (e) => {
681
+ modality.current = e.pointerType;
682
+ longPressEnabledOnPressStart.current = longPressEnabled;
683
+ if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
684
+ };
685
+ if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e) => {
686
+ if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
687
+ if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
688
+ performAction(e);
689
+ } else if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
690
+ };
691
+ else {
692
+ itemPressProps.onPressUp = hasPrimaryAction ? void 0 : (e) => {
693
+ if (e.pointerType === "mouse" && allowsSelection) onSelect(e);
694
+ };
695
+ itemPressProps.onPress = hasPrimaryAction ? performAction : (e) => {
696
+ if (e.pointerType !== "keyboard" && e.pointerType !== "mouse" && allowsSelection) onSelect(e);
697
+ };
835
698
  }
699
+ } else {
700
+ itemPressProps.onPressStart = (e) => {
701
+ modality.current = e.pointerType;
702
+ longPressEnabledOnPressStart.current = longPressEnabled;
703
+ hadPrimaryActionOnPressStart.current = hasPrimaryAction;
704
+ if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey()))) onSelect(e);
705
+ };
706
+ itemPressProps.onPress = (e) => {
707
+ if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
708
+ if (hasAction) performAction(e);
709
+ else if (allowsSelection) onSelect(e);
710
+ }
711
+ };
836
712
  }
837
- function useSyncExternalStore$1(subscribe, getSnapshot) {
838
- return getSnapshot();
839
- }
840
- var shim2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
841
- useSyncExternalStoreShim_production.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim2;
842
- return useSyncExternalStoreShim_production;
843
- }
844
- var useSyncExternalStoreShim_development = {};
845
- /**
846
- * @license React
847
- * use-sync-external-store-shim.development.js
848
- *
849
- * Copyright (c) Meta Platforms, Inc. and affiliates.
850
- *
851
- * This source code is licensed under the MIT license found in the
852
- * LICENSE file in the root directory of this source tree.
853
- */
854
- var hasRequiredUseSyncExternalStoreShim_development;
855
- function requireUseSyncExternalStoreShim_development() {
856
- if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
857
- hasRequiredUseSyncExternalStoreShim_development = 1;
858
- "production" !== process.env.NODE_ENV && function() {
859
- function is(x, y) {
860
- return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
861
- }
862
- function useSyncExternalStore$2(subscribe, getSnapshot) {
863
- didWarnOld18Alpha || void 0 === React.startTransition || (didWarnOld18Alpha = true, console.error(
864
- "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
865
- ));
866
- var value = getSnapshot();
867
- if (!didWarnUncachedGetSnapshot) {
868
- var cachedValue = getSnapshot();
869
- objectIs(value, cachedValue) || (console.error(
870
- "The result of getSnapshot should be cached to avoid an infinite loop"
871
- ), didWarnUncachedGetSnapshot = true);
713
+ itemProps["data-collection"] = $feb5ffebff200149$export$6aeb1680a0ae8741(manager.collection);
714
+ itemProps["data-key"] = key;
715
+ itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
716
+ if (shouldUseVirtualFocus) itemPressProps = $3ef42575df84b30b$export$9d1611c77c2fe928(itemPressProps, {
717
+ onPressStart(e) {
718
+ if (e.pointerType !== "touch") {
719
+ manager.setFocused(true);
720
+ manager.setFocusedKey(key);
872
721
  }
873
- cachedValue = useState2({
874
- inst: { value, getSnapshot }
875
- });
876
- var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
877
- useLayoutEffect(
878
- function() {
879
- inst.value = value;
880
- inst.getSnapshot = getSnapshot;
881
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
882
- },
883
- [subscribe, value, getSnapshot]
884
- );
885
- useEffect2(
886
- function() {
887
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
888
- return subscribe(function() {
889
- checkIfSnapshotChanged(inst) && forceUpdate({ inst });
890
- });
891
- },
892
- [subscribe]
893
- );
894
- useDebugValue(value);
895
- return value;
896
- }
897
- function checkIfSnapshotChanged(inst) {
898
- var latestGetSnapshot = inst.getSnapshot;
899
- inst = inst.value;
900
- try {
901
- var nextValue = latestGetSnapshot();
902
- return !objectIs(inst, nextValue);
903
- } catch (error) {
904
- return true;
722
+ },
723
+ onPress(e) {
724
+ if (e.pointerType === "touch") {
725
+ manager.setFocused(true);
726
+ manager.setFocusedKey(key);
905
727
  }
906
728
  }
907
- function useSyncExternalStore$1(subscribe, getSnapshot) {
908
- return getSnapshot();
909
- }
910
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
911
- var React = React__default, objectIs = "function" === typeof Object.is ? Object.is : is, useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
912
- useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim2;
913
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
914
- }();
915
- return useSyncExternalStoreShim_development;
916
- }
917
- var hasRequiredShim;
918
- function requireShim() {
919
- if (hasRequiredShim) return shim.exports;
920
- hasRequiredShim = 1;
921
- if (process.env.NODE_ENV === "production") {
922
- shim.exports = requireUseSyncExternalStoreShim_production();
923
- } else {
924
- shim.exports = requireUseSyncExternalStoreShim_development();
729
+ });
730
+ if (collectionItemProps) {
731
+ for (let key2 of [
732
+ "onPressStart",
733
+ "onPressEnd",
734
+ "onPressChange",
735
+ "onPress",
736
+ "onPressUp",
737
+ "onClick"
738
+ ]) if (collectionItemProps[key2]) itemPressProps[key2] = $ff5963eb1fccf552$export$e08e3b67e392101e(itemPressProps[key2], collectionItemProps[key2]);
925
739
  }
926
- return shim.exports;
740
+ let { pressProps, isPressed } = $f6c31cce2adf654f$export$45712eceda6fad21(itemPressProps);
741
+ let onDoubleClick = hasSecondaryAction ? (e) => {
742
+ if (modality.current === "mouse") {
743
+ e.stopPropagation();
744
+ e.preventDefault();
745
+ performAction(e);
746
+ }
747
+ } : void 0;
748
+ let { longPressProps } = $8a26561d2877236e$export$c24ed0104d07eab9({
749
+ isDisabled: !longPressEnabled,
750
+ onLongPress(e) {
751
+ if (e.pointerType === "touch") {
752
+ onSelect(e);
753
+ manager.setSelectionBehavior("toggle");
754
+ }
755
+ }
756
+ });
757
+ let onDragStartCapture = (e) => {
758
+ if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
759
+ };
760
+ let onClick = linkBehavior !== "none" && manager.isLink(key) ? (e) => {
761
+ if (!$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening) e.preventDefault();
762
+ } : void 0;
763
+ return {
764
+ itemProps: $3ef42575df84b30b$export$9d1611c77c2fe928(
765
+ itemProps,
766
+ allowsSelection || hasPrimaryAction || shouldUseVirtualFocus && !isDisabled ? pressProps : {},
767
+ longPressEnabled ? longPressProps : {},
768
+ {
769
+ onDoubleClick,
770
+ onDragStartCapture,
771
+ onClick,
772
+ id
773
+ },
774
+ // Prevent DOM focus from moving on mouse down when using virtual focus
775
+ shouldUseVirtualFocus ? {
776
+ onMouseDown: (e) => e.preventDefault()
777
+ } : void 0
778
+ ),
779
+ isPressed,
780
+ isSelected: manager.isSelected(key),
781
+ isFocused: manager.isFocused && manager.focusedKey === key,
782
+ isDisabled,
783
+ allowsSelection,
784
+ hasAction
785
+ };
927
786
  }
928
- var shimExports = requireShim();
929
- const $e1995378a142960e$var$ShallowRenderContext = /* @__PURE__ */ createContext(false);
930
- const $e1995378a142960e$var$CollectionDocumentContext = /* @__PURE__ */ createContext(null);
931
- function $e1995378a142960e$export$bf788dd355e3a401(props) {
932
- let doc = useContext($e1995378a142960e$var$CollectionDocumentContext);
933
- if (doc)
934
- return props.content;
935
- let { collection, document: document2 } = $e1995378a142960e$var$useCollectionDocument(props.createCollection);
936
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement($f39a9eba43920ace$export$8dc98ba7eadeaa56, null, /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionDocumentContext.Provider, {
937
- value: document2
938
- }, props.content)), /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionInner, {
939
- render: props.children,
940
- collection
941
- }));
787
+ function $880e95eb8b93ba9a$var$isActionKey() {
788
+ let event = window.event;
789
+ return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
942
790
  }
943
- function $e1995378a142960e$var$CollectionInner({ collection, render }) {
944
- return render(collection);
945
- }
946
- function $e1995378a142960e$var$useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
947
- let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
948
- let isSSRRef = useRef(isSSR);
949
- isSSRRef.current = isSSR;
950
- let getSnapshotWrapper = useCallback(() => {
951
- return isSSRRef.current ? getServerSnapshot() : getSnapshot();
952
- }, [
953
- getSnapshot,
954
- getServerSnapshot
955
- ]);
956
- return shimExports.useSyncExternalStore(subscribe, getSnapshotWrapper);
957
- }
958
- const $e1995378a142960e$var$useSyncExternalStore = typeof React__default["useSyncExternalStore"] === "function" ? React__default["useSyncExternalStore"] : $e1995378a142960e$var$useSyncExternalStoreFallback;
959
- function $e1995378a142960e$var$useCollectionDocument(createCollection) {
960
- let [document2] = useState(() => new $681cc3c98f569e39$export$b34a105447964f9f((createCollection === null || createCollection === void 0 ? void 0 : createCollection()) || new $23b9f4fcf0fe224b$export$408d25a4e12db025()));
961
- let subscribe = useCallback((fn) => document2.subscribe(fn), [
962
- document2
963
- ]);
964
- let getSnapshot = useCallback(() => {
965
- let collection2 = document2.getCollection();
966
- if (document2.isSSR)
967
- document2.resetAfterSSR();
968
- return collection2;
969
- }, [
970
- document2
971
- ]);
972
- let getServerSnapshot = useCallback(() => {
973
- document2.isSSR = true;
974
- return document2.getCollection();
975
- }, [
976
- document2
977
- ]);
978
- let collection = $e1995378a142960e$var$useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
979
- $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
980
- document2.isMounted = true;
981
- return () => {
982
- document2.isMounted = false;
983
- };
984
- }, [
985
- document2
986
- ]);
987
- return {
988
- collection,
989
- document: document2
990
- };
791
+ function $880e95eb8b93ba9a$var$isSelectionKey() {
792
+ let event = window.event;
793
+ return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
991
794
  }
992
- const $e1995378a142960e$var$SSRContext = /* @__PURE__ */ createContext(null);
993
- function $e1995378a142960e$var$useSSRCollectionNode(Type, props, ref, rendered, children, render) {
994
- let itemRef = useCallback((element) => {
995
- element === null || element === void 0 ? void 0 : element.setProps(props, ref, rendered, render);
996
- }, [
997
- props,
998
- ref,
999
- rendered,
1000
- render
1001
- ]);
1002
- let parentNode = useContext($e1995378a142960e$var$SSRContext);
1003
- if (parentNode) {
1004
- let element = parentNode.ownerDocument.nodesByProps.get(props);
1005
- if (!element) {
1006
- element = parentNode.ownerDocument.createElement(Type);
1007
- element.setProps(props, ref, rendered, render);
1008
- parentNode.appendChild(element);
1009
- parentNode.ownerDocument.updateCollection();
1010
- parentNode.ownerDocument.nodesByProps.set(props, element);
795
+ class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
796
+ build(props, context) {
797
+ this.context = context;
798
+ return $eb2240fc39a57fa5$var$iterable(() => this.iterateCollection(props));
799
+ }
800
+ *iterateCollection(props) {
801
+ let { children, items } = props;
802
+ if (React__default.isValidElement(children) && children.type === React__default.Fragment) yield* this.iterateCollection({
803
+ children: children.props.children,
804
+ items
805
+ });
806
+ else if (typeof children === "function") {
807
+ if (!items) throw new Error("props.children was a function but props.items is missing");
808
+ let index = 0;
809
+ for (let item of items) {
810
+ yield* this.getFullNode({
811
+ value: item,
812
+ index
813
+ }, {
814
+ renderer: children
815
+ });
816
+ index++;
817
+ }
818
+ } else {
819
+ let items2 = [];
820
+ React__default.Children.forEach(children, (child) => {
821
+ if (child) items2.push(child);
822
+ });
823
+ let index = 0;
824
+ for (let item of items2) {
825
+ let nodes = this.getFullNode({
826
+ element: item,
827
+ index
828
+ }, {});
829
+ for (let node of nodes) {
830
+ index++;
831
+ yield node;
832
+ }
833
+ }
1011
834
  }
1012
- return children ? /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$SSRContext.Provider, {
1013
- value: element
1014
- }, children) : null;
1015
835
  }
1016
- return /* @__PURE__ */ React__default.createElement(Type, {
1017
- ref: itemRef
1018
- }, children);
1019
- }
1020
- function $e1995378a142960e$export$18af5c7a9e9b3664(type, render) {
1021
- let Component = ({ node }) => render(node.props, node.props.ref, node);
1022
- let Result = forwardRef((props, ref) => {
1023
- let focusableProps = useContext($f645667febf57a63$export$f9762fab77588ecb);
1024
- let isShallow = useContext($e1995378a142960e$var$ShallowRenderContext);
1025
- if (!isShallow) {
1026
- if (render.length >= 3) throw new Error(render.name + " cannot be rendered outside a collection.");
1027
- return render(props, ref);
836
+ getKey(item, partialNode, state, parentKey) {
837
+ if (item.key != null) return item.key;
838
+ if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
839
+ let v = partialNode.value;
840
+ if (v != null) {
841
+ var _v_key;
842
+ let key = (_v_key = v.key) !== null && _v_key !== void 0 ? _v_key : v.id;
843
+ if (key == null) throw new Error("No key found for item");
844
+ return key;
1028
845
  }
1029
- return $e1995378a142960e$var$useSSRCollectionNode(type, props, ref, "children" in props ? props.children : null, null, (node) => (
1030
- // Forward FocusableContext to real DOM tree so tooltips work.
1031
- /* @__PURE__ */ React__default.createElement($f645667febf57a63$export$f9762fab77588ecb.Provider, {
1032
- value: focusableProps
1033
- }, /* @__PURE__ */ React__default.createElement(Component, {
1034
- node
1035
- }))
1036
- ));
1037
- });
1038
- Result.displayName = render.name;
1039
- return Result;
1040
- }
1041
- function $e1995378a142960e$export$e953bb1cd0f19726(type, render, useChildren = $e1995378a142960e$var$useCollectionChildren) {
1042
- let Component = ({ node }) => render(node.props, node.props.ref, node);
1043
- let Result = forwardRef((props, ref) => {
1044
- let children = useChildren(props);
1045
- var _useSSRCollectionNode;
1046
- return (_useSSRCollectionNode = $e1995378a142960e$var$useSSRCollectionNode(type, props, ref, null, children, (node) => /* @__PURE__ */ React__default.createElement(Component, {
1047
- node
1048
- }))) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
1049
- });
1050
- Result.displayName = render.name;
1051
- return Result;
1052
- }
1053
- function $e1995378a142960e$var$useCollectionChildren(options) {
1054
- return $e948873055cbafe4$export$727c8fc270210f13({
1055
- ...options,
1056
- addIdAndValue: true
1057
- });
1058
- }
1059
- const $e1995378a142960e$var$CollectionContext = /* @__PURE__ */ createContext(null);
1060
- function $e1995378a142960e$export$fb8073518f34e6ec(props) {
1061
- let ctx = useContext($e1995378a142960e$var$CollectionContext);
1062
- let dependencies = ((ctx === null || ctx === void 0 ? void 0 : ctx.dependencies) || []).concat(props.dependencies);
1063
- let idScope = props.idScope || (ctx === null || ctx === void 0 ? void 0 : ctx.idScope);
1064
- let children = $e1995378a142960e$var$useCollectionChildren({
1065
- ...props,
1066
- idScope,
1067
- dependencies
1068
- });
1069
- let doc = useContext($e1995378a142960e$var$CollectionDocumentContext);
1070
- if (doc) children = /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionRoot, null, children);
1071
- ctx = useMemo(() => ({
1072
- dependencies,
1073
- idScope
1074
- }), [
1075
- idScope,
1076
- ...dependencies
1077
- ]);
1078
- return /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionContext.Provider, {
1079
- value: ctx
1080
- }, children);
1081
- }
1082
- function $e1995378a142960e$var$CollectionRoot({ children }) {
1083
- let doc = useContext($e1995378a142960e$var$CollectionDocumentContext);
1084
- let wrappedChildren = useMemo(() => /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionDocumentContext.Provider, {
1085
- value: null
1086
- }, /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$ShallowRenderContext.Provider, {
1087
- value: true
1088
- }, children)), [
1089
- children
1090
- ]);
1091
- return $b5e257d569688ac6$export$535bd6ca7f90a273() ? /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$SSRContext.Provider, {
1092
- value: doc
1093
- }, wrappedChildren) : /* @__PURE__ */ reactDomExports.createPortal(wrappedChildren, doc);
1094
- }
1095
- function $55f9b1ae81f22853$export$76e4e37e5339496d(to) {
1096
- let from = $55f9b1ae81f22853$export$759df0d867455a91($431fbd86ca7dc216$export$b204af158042fbac(to));
1097
- if (from !== to) {
1098
- if (from) $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to);
1099
- if (to) $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from);
846
+ return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
1100
847
  }
1101
- }
1102
- function $55f9b1ae81f22853$export$6c5dc7e81d2cc29a(from, to) {
1103
- from.dispatchEvent(new FocusEvent("blur", {
1104
- relatedTarget: to
1105
- }));
1106
- from.dispatchEvent(new FocusEvent("focusout", {
1107
- bubbles: true,
1108
- relatedTarget: to
1109
- }));
1110
- }
1111
- function $55f9b1ae81f22853$export$2b35b76d2e30e129(to, from) {
1112
- to.dispatchEvent(new FocusEvent("focus", {
1113
- relatedTarget: from
1114
- }));
1115
- to.dispatchEvent(new FocusEvent("focusin", {
1116
- bubbles: true,
1117
- relatedTarget: from
1118
- }));
1119
- }
1120
- function $55f9b1ae81f22853$export$759df0d867455a91(document2) {
1121
- let activeElement = $d4ee10de306f2510$export$cd4e5573fbe2b576(document2);
1122
- let activeDescendant = activeElement === null || activeElement === void 0 ? void 0 : activeElement.getAttribute("aria-activedescendant");
1123
- if (activeDescendant) return document2.getElementById(activeDescendant) || activeElement;
1124
- return activeElement;
1125
- }
1126
- function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
1127
- return $c87311424ea30a05$export$e1865c3bedcd822b() ? e.altKey : e.ctrlKey;
1128
- }
1129
- function $feb5ffebff200149$export$c3d8340acf92597f(collectionRef, key) {
1130
- var _collectionRef_current, _collectionRef_current1;
1131
- let selector = `[data-key="${CSS.escape(String(key))}"]`;
1132
- let collection = (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dataset.collection;
1133
- if (collection) selector = `[data-collection="${CSS.escape(collection)}"]${selector}`;
1134
- return (_collectionRef_current1 = collectionRef.current) === null || _collectionRef_current1 === void 0 ? void 0 : _collectionRef_current1.querySelector(selector);
1135
- }
1136
- const $feb5ffebff200149$var$collectionMap = /* @__PURE__ */ new WeakMap();
1137
- function $feb5ffebff200149$export$881eb0d9f3605d9d(collection) {
1138
- let id = $bdb11010cef70236$export$f680877a34711e37();
1139
- $feb5ffebff200149$var$collectionMap.set(collection, id);
1140
- return id;
1141
- }
1142
- function $feb5ffebff200149$export$6aeb1680a0ae8741(collection) {
1143
- return $feb5ffebff200149$var$collectionMap.get(collection);
1144
- }
1145
- const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1e3;
1146
- function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
1147
- let { keyboardDelegate, selectionManager, onTypeSelect } = options;
1148
- let state = useRef({
1149
- search: "",
1150
- timeout: void 0
1151
- }).current;
1152
- let onKeyDown = (e) => {
1153
- let character = $fb3050f43d946246$var$getStringForKey(e.key);
1154
- if (!character || e.ctrlKey || e.metaKey || !e.currentTarget.contains(e.target) || state.search.length === 0 && character === " ") return;
1155
- if (character === " " && state.search.trim().length > 0) {
1156
- e.preventDefault();
1157
- if (!("continuePropagation" in e)) e.stopPropagation();
848
+ getChildState(state, partialNode) {
849
+ return {
850
+ renderer: partialNode.renderer || state.renderer
851
+ };
852
+ }
853
+ *getFullNode(partialNode, state, parentKey, parentNode) {
854
+ if (React__default.isValidElement(partialNode.element) && partialNode.element.type === React__default.Fragment) {
855
+ let children = [];
856
+ React__default.Children.forEach(partialNode.element.props.children, (child) => {
857
+ children.push(child);
858
+ });
859
+ var _partialNode_index;
860
+ let index = (_partialNode_index = partialNode.index) !== null && _partialNode_index !== void 0 ? _partialNode_index : 0;
861
+ for (const child of children) yield* this.getFullNode({
862
+ element: child,
863
+ index: index++
864
+ }, state, parentKey, parentNode);
865
+ return;
1158
866
  }
1159
- state.search += character;
1160
- if (keyboardDelegate.getKeyForSearch != null) {
1161
- let key = keyboardDelegate.getKeyForSearch(state.search, selectionManager.focusedKey);
1162
- if (key == null) key = keyboardDelegate.getKeyForSearch(state.search);
1163
- if (key != null) {
1164
- selectionManager.setFocusedKey(key);
1165
- if (onTypeSelect) onTypeSelect(key);
867
+ let element = partialNode.element;
868
+ if (!element && partialNode.value && state && state.renderer) {
869
+ let cached = this.cache.get(partialNode.value);
870
+ if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {
871
+ cached.index = partialNode.index;
872
+ cached.parentKey = parentNode ? parentNode.key : null;
873
+ yield cached;
874
+ return;
1166
875
  }
876
+ element = state.renderer(partialNode.value);
1167
877
  }
1168
- clearTimeout(state.timeout);
1169
- state.timeout = setTimeout(() => {
1170
- state.search = "";
1171
- }, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
1172
- };
1173
- return {
1174
- typeSelectProps: {
1175
- // Using a capturing listener to catch the keydown event before
1176
- // other hooks in order to handle the Spacebar event.
1177
- onKeyDownCapture: keyboardDelegate.getKeyForSearch ? onKeyDown : void 0
1178
- }
1179
- };
1180
- }
1181
- function $fb3050f43d946246$var$getStringForKey(key) {
1182
- if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
1183
- return "";
1184
- }
1185
- function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
1186
- let { selectionManager: manager, keyboardDelegate: delegate, ref, autoFocus = false, shouldFocusWrap = false, disallowEmptySelection = false, disallowSelectAll = false, escapeKeyBehavior = "clearSelection", selectOnFocus = manager.selectionBehavior === "replace", disallowTypeAhead = false, shouldUseVirtualFocus, allowsTabNavigation = false, isVirtualized, scrollRef = ref, linkBehavior = "action" } = options;
1187
- let { direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
1188
- let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
1189
- let onKeyDown = (e) => {
1190
- var _ref_current;
1191
- if (e.altKey && e.key === "Tab") e.preventDefault();
1192
- if (!((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.contains(e.target))) return;
1193
- const navigateToKey = (key, childFocus) => {
1194
- if (key != null) {
1195
- if (manager.isLink(key) && linkBehavior === "selection" && selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) {
1196
- reactDomExports.flushSync(() => {
1197
- manager.setFocusedKey(key, childFocus);
1198
- });
1199
- let item = $feb5ffebff200149$export$c3d8340acf92597f(ref, key);
1200
- let itemProps = manager.getItemProps(key);
1201
- if (item) router.open(item, e, itemProps.href, itemProps.routerOptions);
1202
- return;
1203
- }
1204
- manager.setFocusedKey(key, childFocus);
1205
- if (manager.isLink(key) && linkBehavior === "override") return;
1206
- if (e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(key);
1207
- else if (selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.replaceSelection(key);
878
+ if (React__default.isValidElement(element)) {
879
+ let type = element.type;
880
+ if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
881
+ let name = element.type;
882
+ throw new Error(`Unknown element <${name}> in collection.`);
883
+ }
884
+ let childNodes = type.getCollectionNode(element.props, this.context);
885
+ var _partialNode_index1;
886
+ let index = (_partialNode_index1 = partialNode.index) !== null && _partialNode_index1 !== void 0 ? _partialNode_index1 : 0;
887
+ let result = childNodes.next();
888
+ while (!result.done && result.value) {
889
+ let childNode = result.value;
890
+ partialNode.index = index;
891
+ var _childNode_key;
892
+ let nodeKey = (_childNode_key = childNode.key) !== null && _childNode_key !== void 0 ? _childNode_key : null;
893
+ if (nodeKey == null) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
894
+ let nodes = this.getFullNode({
895
+ ...childNode,
896
+ key: nodeKey,
897
+ index,
898
+ wrapper: $eb2240fc39a57fa5$var$compose(partialNode.wrapper, childNode.wrapper)
899
+ }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
900
+ let children = [
901
+ ...nodes
902
+ ];
903
+ for (let node2 of children) {
904
+ var _childNode_value, _ref;
905
+ node2.value = (_ref = (_childNode_value = childNode.value) !== null && _childNode_value !== void 0 ? _childNode_value : partialNode.value) !== null && _ref !== void 0 ? _ref : null;
906
+ if (node2.value) this.cache.set(node2.value, node2);
907
+ var _parentNode_type;
908
+ if (partialNode.type && node2.type !== partialNode.type) throw new Error(`Unsupported type <${$eb2240fc39a57fa5$var$capitalize(node2.type)}> in <${$eb2240fc39a57fa5$var$capitalize((_parentNode_type = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) !== null && _parentNode_type !== void 0 ? _parentNode_type : "unknown parent type")}>. Only <${$eb2240fc39a57fa5$var$capitalize(partialNode.type)}> is supported.`);
909
+ index++;
910
+ yield node2;
911
+ }
912
+ result = childNodes.next(children);
1208
913
  }
1209
- };
1210
- switch (e.key) {
1211
- case "ArrowDown":
1212
- if (delegate.getKeyBelow) {
1213
- var _delegate_getKeyBelow, _delegate_getFirstKey, _delegate_getFirstKey1;
1214
- let nextKey = manager.focusedKey != null ? (_delegate_getKeyBelow = delegate.getKeyBelow) === null || _delegate_getKeyBelow === void 0 ? void 0 : _delegate_getKeyBelow.call(delegate, manager.focusedKey) : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate);
1215
- if (nextKey == null && shouldFocusWrap) nextKey = (_delegate_getFirstKey1 = delegate.getFirstKey) === null || _delegate_getFirstKey1 === void 0 ? void 0 : _delegate_getFirstKey1.call(delegate, manager.focusedKey);
1216
- if (nextKey != null) {
1217
- e.preventDefault();
1218
- navigateToKey(nextKey);
1219
- }
1220
- }
1221
- break;
1222
- case "ArrowUp":
1223
- if (delegate.getKeyAbove) {
1224
- var _delegate_getKeyAbove, _delegate_getLastKey, _delegate_getLastKey1;
1225
- let nextKey = manager.focusedKey != null ? (_delegate_getKeyAbove = delegate.getKeyAbove) === null || _delegate_getKeyAbove === void 0 ? void 0 : _delegate_getKeyAbove.call(delegate, manager.focusedKey) : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate);
1226
- if (nextKey == null && shouldFocusWrap) nextKey = (_delegate_getLastKey1 = delegate.getLastKey) === null || _delegate_getLastKey1 === void 0 ? void 0 : _delegate_getLastKey1.call(delegate, manager.focusedKey);
1227
- if (nextKey != null) {
1228
- e.preventDefault();
1229
- navigateToKey(nextKey);
1230
- }
1231
- }
1232
- break;
1233
- case "ArrowLeft":
1234
- if (delegate.getKeyLeftOf) {
1235
- var _delegate_getKeyLeftOf, _delegate_getFirstKey2, _delegate_getLastKey2;
1236
- let nextKey = manager.focusedKey != null ? (_delegate_getKeyLeftOf = delegate.getKeyLeftOf) === null || _delegate_getKeyLeftOf === void 0 ? void 0 : _delegate_getKeyLeftOf.call(delegate, manager.focusedKey) : null;
1237
- if (nextKey == null && shouldFocusWrap) nextKey = direction === "rtl" ? (_delegate_getFirstKey2 = delegate.getFirstKey) === null || _delegate_getFirstKey2 === void 0 ? void 0 : _delegate_getFirstKey2.call(delegate, manager.focusedKey) : (_delegate_getLastKey2 = delegate.getLastKey) === null || _delegate_getLastKey2 === void 0 ? void 0 : _delegate_getLastKey2.call(delegate, manager.focusedKey);
1238
- if (nextKey != null) {
1239
- e.preventDefault();
1240
- navigateToKey(nextKey, direction === "rtl" ? "first" : "last");
1241
- }
1242
- }
1243
- break;
1244
- case "ArrowRight":
1245
- if (delegate.getKeyRightOf) {
1246
- var _delegate_getKeyRightOf, _delegate_getLastKey3, _delegate_getFirstKey3;
1247
- let nextKey = manager.focusedKey != null ? (_delegate_getKeyRightOf = delegate.getKeyRightOf) === null || _delegate_getKeyRightOf === void 0 ? void 0 : _delegate_getKeyRightOf.call(delegate, manager.focusedKey) : null;
1248
- if (nextKey == null && shouldFocusWrap) nextKey = direction === "rtl" ? (_delegate_getLastKey3 = delegate.getLastKey) === null || _delegate_getLastKey3 === void 0 ? void 0 : _delegate_getLastKey3.call(delegate, manager.focusedKey) : (_delegate_getFirstKey3 = delegate.getFirstKey) === null || _delegate_getFirstKey3 === void 0 ? void 0 : _delegate_getFirstKey3.call(delegate, manager.focusedKey);
1249
- if (nextKey != null) {
1250
- e.preventDefault();
1251
- navigateToKey(nextKey, direction === "rtl" ? "last" : "first");
1252
- }
1253
- }
1254
- break;
1255
- case "Home":
1256
- if (delegate.getFirstKey) {
1257
- if (manager.focusedKey === null && e.shiftKey) return;
1258
- e.preventDefault();
1259
- let firstKey = delegate.getFirstKey(manager.focusedKey, $21f1aa98acb08317$export$16792effe837dba3(e));
1260
- manager.setFocusedKey(firstKey);
1261
- if (firstKey != null) {
1262
- if ($21f1aa98acb08317$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(firstKey);
1263
- else if (selectOnFocus) manager.replaceSelection(firstKey);
1264
- }
1265
- }
1266
- break;
1267
- case "End":
1268
- if (delegate.getLastKey) {
1269
- if (manager.focusedKey === null && e.shiftKey) return;
1270
- e.preventDefault();
1271
- let lastKey = delegate.getLastKey(manager.focusedKey, $21f1aa98acb08317$export$16792effe837dba3(e));
1272
- manager.setFocusedKey(lastKey);
1273
- if (lastKey != null) {
1274
- if ($21f1aa98acb08317$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(lastKey);
1275
- else if (selectOnFocus) manager.replaceSelection(lastKey);
1276
- }
1277
- }
1278
- break;
1279
- case "PageDown":
1280
- if (delegate.getKeyPageBelow && manager.focusedKey != null) {
1281
- let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
1282
- if (nextKey != null) {
1283
- e.preventDefault();
1284
- navigateToKey(nextKey);
1285
- }
1286
- }
1287
- break;
1288
- case "PageUp":
1289
- if (delegate.getKeyPageAbove && manager.focusedKey != null) {
1290
- let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
1291
- if (nextKey != null) {
1292
- e.preventDefault();
1293
- navigateToKey(nextKey);
1294
- }
1295
- }
1296
- break;
1297
- case "a":
1298
- if ($21f1aa98acb08317$export$16792effe837dba3(e) && manager.selectionMode === "multiple" && disallowSelectAll !== true) {
1299
- e.preventDefault();
1300
- manager.selectAll();
1301
- }
1302
- break;
1303
- case "Escape":
1304
- if (escapeKeyBehavior === "clearSelection" && !disallowEmptySelection && manager.selectedKeys.size !== 0) {
1305
- e.stopPropagation();
1306
- e.preventDefault();
1307
- manager.clearSelection();
1308
- }
1309
- break;
1310
- case "Tab":
1311
- if (!allowsTabNavigation) {
1312
- if (e.shiftKey) ref.current.focus();
1313
- else {
1314
- let walker = $9bf71ea28793e738$export$2d6ec8fc375ceafa(ref.current, {
1315
- tabbable: true
1316
- });
1317
- let next = void 0;
1318
- let last;
1319
- do {
1320
- last = walker.lastChild();
1321
- if (last) next = last;
1322
- } while (last);
1323
- if (next && !next.contains(document.activeElement)) $7215afc6de606d6b$export$de79e2c695e052f3(next);
1324
- }
1325
- break;
1326
- }
1327
- }
1328
- };
1329
- let scrollPos = useRef({
1330
- top: 0,
1331
- left: 0
1332
- });
1333
- $e9faafb641e167db$export$90fc3a17d93f704c(scrollRef, "scroll", isVirtualized ? void 0 : () => {
1334
- var _scrollRef_current, _scrollRef_current1;
1335
- var _scrollRef_current_scrollTop, _scrollRef_current_scrollLeft;
1336
- scrollPos.current = {
1337
- top: (_scrollRef_current_scrollTop = (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 ? void 0 : _scrollRef_current.scrollTop) !== null && _scrollRef_current_scrollTop !== void 0 ? _scrollRef_current_scrollTop : 0,
1338
- left: (_scrollRef_current_scrollLeft = (_scrollRef_current1 = scrollRef.current) === null || _scrollRef_current1 === void 0 ? void 0 : _scrollRef_current1.scrollLeft) !== null && _scrollRef_current_scrollLeft !== void 0 ? _scrollRef_current_scrollLeft : 0
1339
- };
1340
- });
1341
- let onFocus = (e) => {
1342
- if (manager.isFocused) {
1343
- if (!e.currentTarget.contains(e.target)) manager.setFocused(false);
1344
914
  return;
1345
915
  }
1346
- if (!e.currentTarget.contains(e.target)) return;
1347
- manager.setFocused(true);
1348
- if (manager.focusedKey == null) {
1349
- var _delegate_getLastKey, _delegate_getFirstKey;
1350
- let navigateToKey = (key) => {
1351
- if (key != null) {
1352
- manager.setFocusedKey(key);
1353
- if (selectOnFocus && !manager.isSelected(key)) manager.replaceSelection(key);
916
+ if (partialNode.key == null || partialNode.type == null) return;
917
+ let builder = this;
918
+ var _partialNode_value, _partialNode_textValue;
919
+ let node = {
920
+ type: partialNode.type,
921
+ props: partialNode.props,
922
+ key: partialNode.key,
923
+ parentKey: parentNode ? parentNode.key : null,
924
+ value: (_partialNode_value = partialNode.value) !== null && _partialNode_value !== void 0 ? _partialNode_value : null,
925
+ level: parentNode ? parentNode.level + 1 : 0,
926
+ index: partialNode.index,
927
+ rendered: partialNode.rendered,
928
+ textValue: (_partialNode_textValue = partialNode.textValue) !== null && _partialNode_textValue !== void 0 ? _partialNode_textValue : "",
929
+ "aria-label": partialNode["aria-label"],
930
+ wrapper: partialNode.wrapper,
931
+ shouldInvalidate: partialNode.shouldInvalidate,
932
+ hasChildNodes: partialNode.hasChildNodes || false,
933
+ childNodes: $eb2240fc39a57fa5$var$iterable(function* () {
934
+ if (!partialNode.hasChildNodes || !partialNode.childNodes) return;
935
+ let index = 0;
936
+ for (let child of partialNode.childNodes()) {
937
+ if (child.key != null)
938
+ child.key = `${node.key}${child.key}`;
939
+ let nodes = builder.getFullNode({
940
+ ...child,
941
+ index
942
+ }, builder.getChildState(state, child), node.key, node);
943
+ for (let node2 of nodes) {
944
+ index++;
945
+ yield node2;
946
+ }
1354
947
  }
1355
- };
1356
- let relatedTarget = e.relatedTarget;
1357
- var _manager_lastSelectedKey, _manager_firstSelectedKey;
1358
- if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate));
1359
- else navigateToKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate));
1360
- } else if (!isVirtualized && scrollRef.current) {
1361
- scrollRef.current.scrollTop = scrollPos.current.top;
1362
- scrollRef.current.scrollLeft = scrollPos.current.left;
1363
- }
1364
- if (manager.focusedKey != null && scrollRef.current) {
1365
- let element = $feb5ffebff200149$export$c3d8340acf92597f(ref, manager.focusedKey);
1366
- if (element instanceof HTMLElement) {
1367
- if (!element.contains(document.activeElement) && !shouldUseVirtualFocus) $7215afc6de606d6b$export$de79e2c695e052f3(element);
1368
- let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
1369
- if (modality === "keyboard") $2f04cbc44ee30ce0$export$c826860796309d1b(element, {
1370
- containingElement: ref.current
1371
- });
948
+ })
949
+ };
950
+ yield node;
951
+ }
952
+ constructor() {
953
+ this.cache = /* @__PURE__ */ new WeakMap();
954
+ }
955
+ }
956
+ function $eb2240fc39a57fa5$var$iterable(iterator) {
957
+ let cache = [];
958
+ let iterable = null;
959
+ return {
960
+ *[Symbol.iterator]() {
961
+ for (let item of cache) yield item;
962
+ if (!iterable) iterable = iterator();
963
+ for (let item of iterable) {
964
+ cache.push(item);
965
+ yield item;
1372
966
  }
1373
967
  }
1374
968
  };
1375
- let onBlur = (e) => {
1376
- if (!e.currentTarget.contains(e.relatedTarget)) manager.setFocused(false);
1377
- };
1378
- let shouldVirtualFocusFirst = useRef(false);
1379
- $e9faafb641e167db$export$90fc3a17d93f704c(ref, $5671b20cf9b562b2$export$831c820ad60f9d12, !shouldUseVirtualFocus ? void 0 : (e) => {
1380
- let { detail } = e;
1381
- e.stopPropagation();
1382
- manager.setFocused(true);
1383
- if ((detail === null || detail === void 0 ? void 0 : detail.focusStrategy) === "first") shouldVirtualFocusFirst.current = true;
1384
- });
1385
- let updateActiveDescendant = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
1386
- var _delegate_getFirstKey;
1387
- var _delegate_getFirstKey1;
1388
- let keyToFocus = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null;
1389
- if (keyToFocus == null) {
1390
- let previousActiveElement = $d4ee10de306f2510$export$cd4e5573fbe2b576();
1391
- $55f9b1ae81f22853$export$76e4e37e5339496d(ref.current);
1392
- $55f9b1ae81f22853$export$2b35b76d2e30e129(previousActiveElement, null);
1393
- if (manager.collection.size > 0) shouldVirtualFocusFirst.current = false;
1394
- } else {
1395
- manager.setFocusedKey(keyToFocus);
1396
- shouldVirtualFocusFirst.current = false;
1397
- }
1398
- });
1399
- $ca9b37712f007381$export$72ef708ab07251f1(() => {
1400
- if (shouldVirtualFocusFirst.current) updateActiveDescendant();
1401
- }, [
1402
- manager.collection,
1403
- updateActiveDescendant
1404
- ]);
1405
- let resetFocusFirstFlag = $8ae05eaa5c114e9c$export$7f54fc3180508a52(() => {
1406
- if (manager.collection.size > 0) shouldVirtualFocusFirst.current = false;
1407
- });
1408
- $ca9b37712f007381$export$72ef708ab07251f1(() => {
1409
- resetFocusFirstFlag();
969
+ }
970
+ function $eb2240fc39a57fa5$var$compose(outer, inner) {
971
+ if (outer && inner) return (element) => outer(inner(element));
972
+ if (outer) return outer;
973
+ if (inner) return inner;
974
+ }
975
+ function $eb2240fc39a57fa5$var$capitalize(str) {
976
+ return str[0].toUpperCase() + str.slice(1);
977
+ }
978
+ function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context) {
979
+ let builder = useMemo(() => new $eb2240fc39a57fa5$export$bf788dd355e3a401(), []);
980
+ let { children, items, collection } = props;
981
+ let result = useMemo(() => {
982
+ if (collection) return collection;
983
+ let nodes = builder.build({
984
+ children,
985
+ items
986
+ }, context);
987
+ return factory(nodes);
1410
988
  }, [
1411
- manager.focusedKey,
1412
- resetFocusFirstFlag
989
+ builder,
990
+ children,
991
+ items,
992
+ collection,
993
+ context,
994
+ factory
1413
995
  ]);
1414
- $e9faafb641e167db$export$90fc3a17d93f704c(ref, $5671b20cf9b562b2$export$447a38995de2c711, !shouldUseVirtualFocus ? void 0 : (e) => {
1415
- var _e_detail;
1416
- e.stopPropagation();
1417
- manager.setFocused(false);
1418
- if ((_e_detail = e.detail) === null || _e_detail === void 0 ? void 0 : _e_detail.clearFocusKey) manager.setFocusedKey(null);
1419
- });
1420
- const autoFocusRef = useRef(autoFocus);
1421
- const didAutoFocusRef = useRef(false);
1422
- useEffect(() => {
1423
- if (autoFocusRef.current) {
1424
- var _delegate_getFirstKey, _delegate_getLastKey;
1425
- let focusedKey = null;
1426
- var _delegate_getFirstKey1;
1427
- if (autoFocus === "first") focusedKey = (_delegate_getFirstKey1 = (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate)) !== null && _delegate_getFirstKey1 !== void 0 ? _delegate_getFirstKey1 : null;
1428
- var _delegate_getLastKey1;
1429
- if (autoFocus === "last") focusedKey = (_delegate_getLastKey1 = (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate)) !== null && _delegate_getLastKey1 !== void 0 ? _delegate_getLastKey1 : null;
1430
- let selectedKeys = manager.selectedKeys;
1431
- if (selectedKeys.size) {
1432
- for (let key of selectedKeys) if (manager.canSelectItem(key)) {
1433
- focusedKey = key;
1434
- break;
1435
- }
1436
- }
1437
- manager.setFocused(true);
1438
- manager.setFocusedKey(focusedKey);
1439
- if (focusedKey == null && !shouldUseVirtualFocus && ref.current) $3ad3f6e1647bc98d$export$80f3e147d781571c(ref.current);
1440
- if (manager.collection.size > 0) {
1441
- autoFocusRef.current = false;
1442
- didAutoFocusRef.current = true;
1443
- }
996
+ return result;
997
+ }
998
+ function $c5a24bc478652b5f$export$1005530eda016c13(node, collection) {
999
+ if (typeof collection.getChildren === "function") return collection.getChildren(node.key);
1000
+ return node.childNodes;
1001
+ }
1002
+ function $c5a24bc478652b5f$export$fbdeaa6a76694f71(iterable) {
1003
+ return $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable);
1004
+ }
1005
+ function $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable, index) {
1006
+ for (let item of iterable) {
1007
+ return item;
1008
+ }
1009
+ }
1010
+ function $c5a24bc478652b5f$export$8c434b3a7a4dad6(collection, a, b) {
1011
+ if (a.parentKey === b.parentKey) return a.index - b.index;
1012
+ let aAncestors = [
1013
+ ...$c5a24bc478652b5f$var$getAncestors(collection, a),
1014
+ a
1015
+ ];
1016
+ let bAncestors = [
1017
+ ...$c5a24bc478652b5f$var$getAncestors(collection, b),
1018
+ b
1019
+ ];
1020
+ let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a2, i) => a2 !== bAncestors[i]);
1021
+ if (firstNonMatchingAncestor !== -1) {
1022
+ a = aAncestors[firstNonMatchingAncestor];
1023
+ b = bAncestors[firstNonMatchingAncestor];
1024
+ return a.index - b.index;
1025
+ }
1026
+ if (aAncestors.findIndex((node) => node === b) >= 0) return 1;
1027
+ else if (bAncestors.findIndex((node) => node === a) >= 0) return -1;
1028
+ return -1;
1029
+ }
1030
+ function $c5a24bc478652b5f$var$getAncestors(collection, node) {
1031
+ let parents = [];
1032
+ let currNode = node;
1033
+ while ((currNode === null || currNode === void 0 ? void 0 : currNode.parentKey) != null) {
1034
+ currNode = collection.getItem(currNode.parentKey);
1035
+ if (currNode) parents.unshift(currNode);
1036
+ }
1037
+ return parents;
1038
+ }
1039
+ class $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
1040
+ get childNodes() {
1041
+ throw new Error("childNodes is not supported");
1042
+ }
1043
+ clone() {
1044
+ let node = new this.constructor(this.key);
1045
+ node.value = this.value;
1046
+ node.level = this.level;
1047
+ node.hasChildNodes = this.hasChildNodes;
1048
+ node.rendered = this.rendered;
1049
+ node.textValue = this.textValue;
1050
+ node["aria-label"] = this["aria-label"];
1051
+ node.index = this.index;
1052
+ node.parentKey = this.parentKey;
1053
+ node.prevKey = this.prevKey;
1054
+ node.nextKey = this.nextKey;
1055
+ node.firstChildKey = this.firstChildKey;
1056
+ node.lastChildKey = this.lastChildKey;
1057
+ node.props = this.props;
1058
+ node.render = this.render;
1059
+ node.colSpan = this.colSpan;
1060
+ node.colIndex = this.colIndex;
1061
+ return node;
1062
+ }
1063
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1064
+ filter(collection, newCollection, filterFn) {
1065
+ let clone = this.clone();
1066
+ newCollection.addDescendants(clone, collection);
1067
+ return clone;
1068
+ }
1069
+ constructor(key) {
1070
+ this.value = null;
1071
+ this.level = 0;
1072
+ this.hasChildNodes = false;
1073
+ this.rendered = null;
1074
+ this.textValue = "";
1075
+ this["aria-label"] = void 0;
1076
+ this.index = 0;
1077
+ this.parentKey = null;
1078
+ this.prevKey = null;
1079
+ this.nextKey = null;
1080
+ this.firstChildKey = null;
1081
+ this.lastChildKey = null;
1082
+ this.props = {};
1083
+ this.colSpan = null;
1084
+ this.colIndex = null;
1085
+ this.type = this.constructor.type;
1086
+ this.key = key;
1087
+ }
1088
+ }
1089
+ class $23b9f4fcf0fe224b$export$b1918e978f1ee46f extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
1090
+ filter(collection, newCollection, filterFn) {
1091
+ let [firstKey, lastKey] = $23b9f4fcf0fe224b$var$filterChildren(collection, newCollection, this.firstChildKey, filterFn);
1092
+ let newNode = this.clone();
1093
+ newNode.firstChildKey = firstKey;
1094
+ newNode.lastChildKey = lastKey;
1095
+ return newNode;
1096
+ }
1097
+ }
1098
+ class $23b9f4fcf0fe224b$export$5ae2504e948afce5 extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
1099
+ }
1100
+ $23b9f4fcf0fe224b$export$5ae2504e948afce5.type = "header";
1101
+ class $23b9f4fcf0fe224b$export$8258a0665a675899 extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
1102
+ }
1103
+ $23b9f4fcf0fe224b$export$8258a0665a675899.type = "loader";
1104
+ class $23b9f4fcf0fe224b$export$fd11f34e1d07f134 extends $23b9f4fcf0fe224b$export$b1918e978f1ee46f {
1105
+ filter(collection, newCollection, filterFn) {
1106
+ if (filterFn(this.textValue, this)) {
1107
+ let clone = this.clone();
1108
+ newCollection.addDescendants(clone, collection);
1109
+ return clone;
1444
1110
  }
1445
- });
1446
- let lastFocusedKey = useRef(manager.focusedKey);
1447
- let raf = useRef(null);
1448
- useEffect(() => {
1449
- if (manager.isFocused && manager.focusedKey != null && (manager.focusedKey !== lastFocusedKey.current || didAutoFocusRef.current) && scrollRef.current && ref.current) {
1450
- let modality = $507fabe10e71c6fb$export$630ff653c5ada6a9();
1451
- let element = $feb5ffebff200149$export$c3d8340acf92597f(ref, manager.focusedKey);
1452
- if (!(element instanceof HTMLElement))
1453
- return;
1454
- if (modality === "keyboard" || didAutoFocusRef.current) {
1455
- if (raf.current) cancelAnimationFrame(raf.current);
1456
- raf.current = requestAnimationFrame(() => {
1457
- if (scrollRef.current) {
1458
- $2f04cbc44ee30ce0$export$53a0910f038337bd(scrollRef.current, element);
1459
- if (modality !== "virtual") $2f04cbc44ee30ce0$export$c826860796309d1b(element, {
1460
- containingElement: ref.current
1461
- });
1462
- }
1463
- });
1111
+ return null;
1112
+ }
1113
+ }
1114
+ $23b9f4fcf0fe224b$export$fd11f34e1d07f134.type = "item";
1115
+ class $23b9f4fcf0fe224b$export$437f11dc9b403b78 extends $23b9f4fcf0fe224b$export$b1918e978f1ee46f {
1116
+ filter(collection, newCollection, filterFn) {
1117
+ let filteredSection = super.filter(collection, newCollection, filterFn);
1118
+ if (filteredSection) {
1119
+ if (filteredSection.lastChildKey !== null) {
1120
+ let lastChild = collection.getItem(filteredSection.lastChildKey);
1121
+ if (lastChild && lastChild.type !== "header") return filteredSection;
1464
1122
  }
1465
1123
  }
1466
- if (!shouldUseVirtualFocus && manager.isFocused && manager.focusedKey == null && lastFocusedKey.current != null && ref.current) $3ad3f6e1647bc98d$export$80f3e147d781571c(ref.current);
1467
- lastFocusedKey.current = manager.focusedKey;
1468
- didAutoFocusRef.current = false;
1469
- });
1470
- useEffect(() => {
1471
- return () => {
1472
- if (raf.current) cancelAnimationFrame(raf.current);
1124
+ return null;
1125
+ }
1126
+ }
1127
+ $23b9f4fcf0fe224b$export$437f11dc9b403b78.type = "section";
1128
+ class $23b9f4fcf0fe224b$export$408d25a4e12db025 {
1129
+ get size() {
1130
+ return this.itemCount;
1131
+ }
1132
+ getKeys() {
1133
+ return this.keyMap.keys();
1134
+ }
1135
+ *[Symbol.iterator]() {
1136
+ let node = this.firstKey != null ? this.keyMap.get(this.firstKey) : void 0;
1137
+ while (node) {
1138
+ yield node;
1139
+ node = node.nextKey != null ? this.keyMap.get(node.nextKey) : void 0;
1140
+ }
1141
+ }
1142
+ getChildren(key) {
1143
+ let keyMap = this.keyMap;
1144
+ return {
1145
+ *[Symbol.iterator]() {
1146
+ let parent = keyMap.get(key);
1147
+ let node = (parent === null || parent === void 0 ? void 0 : parent.firstChildKey) != null ? keyMap.get(parent.firstChildKey) : null;
1148
+ while (node) {
1149
+ yield node;
1150
+ node = node.nextKey != null ? keyMap.get(node.nextKey) : void 0;
1151
+ }
1152
+ }
1473
1153
  };
1474
- }, []);
1475
- $e9faafb641e167db$export$90fc3a17d93f704c(ref, "react-aria-focus-scope-restore", (e) => {
1476
- e.preventDefault();
1477
- manager.setFocused(true);
1478
- });
1479
- let handlers = {
1480
- onKeyDown,
1481
- onFocus,
1482
- onBlur,
1483
- onMouseDown(e) {
1484
- if (scrollRef.current === e.target)
1485
- e.preventDefault();
1154
+ }
1155
+ getKeyBefore(key) {
1156
+ let node = this.keyMap.get(key);
1157
+ if (!node) return null;
1158
+ if (node.prevKey != null) {
1159
+ node = this.keyMap.get(node.prevKey);
1160
+ while (node && node.type !== "item" && node.lastChildKey != null) node = this.keyMap.get(node.lastChildKey);
1161
+ var _node_key;
1162
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
1486
1163
  }
1487
- };
1488
- let { typeSelectProps } = $fb3050f43d946246$export$e32c88dfddc6e1d8({
1489
- keyboardDelegate: delegate,
1490
- selectionManager: manager
1491
- });
1492
- if (!disallowTypeAhead) handlers = $3ef42575df84b30b$export$9d1611c77c2fe928(typeSelectProps, handlers);
1493
- let tabIndex = void 0;
1494
- if (!shouldUseVirtualFocus) tabIndex = manager.focusedKey == null ? 0 : -1;
1495
- let collectionId = $feb5ffebff200149$export$881eb0d9f3605d9d(manager.collection);
1496
- return {
1497
- collectionProps: $3ef42575df84b30b$export$9d1611c77c2fe928(handlers, {
1498
- tabIndex,
1499
- "data-collection": collectionId
1500
- })
1501
- };
1164
+ return node.parentKey;
1165
+ }
1166
+ getKeyAfter(key) {
1167
+ let node = this.keyMap.get(key);
1168
+ if (!node) return null;
1169
+ if (node.type !== "item" && node.firstChildKey != null) return node.firstChildKey;
1170
+ while (node) {
1171
+ if (node.nextKey != null) return node.nextKey;
1172
+ if (node.parentKey != null) node = this.keyMap.get(node.parentKey);
1173
+ else return null;
1174
+ }
1175
+ return null;
1176
+ }
1177
+ getFirstKey() {
1178
+ return this.firstKey;
1179
+ }
1180
+ getLastKey() {
1181
+ let node = this.lastKey != null ? this.keyMap.get(this.lastKey) : null;
1182
+ while ((node === null || node === void 0 ? void 0 : node.lastChildKey) != null) node = this.keyMap.get(node.lastChildKey);
1183
+ var _node_key;
1184
+ return (_node_key = node === null || node === void 0 ? void 0 : node.key) !== null && _node_key !== void 0 ? _node_key : null;
1185
+ }
1186
+ getItem(key) {
1187
+ var _this_keyMap_get;
1188
+ return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
1189
+ }
1190
+ at() {
1191
+ throw new Error("Not implemented");
1192
+ }
1193
+ clone() {
1194
+ let Constructor = this.constructor;
1195
+ let collection = new Constructor();
1196
+ collection.keyMap = new Map(this.keyMap);
1197
+ collection.firstKey = this.firstKey;
1198
+ collection.lastKey = this.lastKey;
1199
+ collection.itemCount = this.itemCount;
1200
+ return collection;
1201
+ }
1202
+ addNode(node) {
1203
+ if (this.frozen) throw new Error("Cannot add a node to a frozen collection");
1204
+ if (node.type === "item" && this.keyMap.get(node.key) == null) this.itemCount++;
1205
+ this.keyMap.set(node.key, node);
1206
+ }
1207
+ // Deeply add a node and its children to the collection from another collection, primarily used when filtering a collection
1208
+ addDescendants(node, oldCollection) {
1209
+ this.addNode(node);
1210
+ let children = oldCollection.getChildren(node.key);
1211
+ for (let child of children) this.addDescendants(child, oldCollection);
1212
+ }
1213
+ removeNode(key) {
1214
+ if (this.frozen) throw new Error("Cannot remove a node to a frozen collection");
1215
+ let node = this.keyMap.get(key);
1216
+ if (node != null && node.type === "item") this.itemCount--;
1217
+ this.keyMap.delete(key);
1218
+ }
1219
+ commit(firstKey, lastKey, isSSR = false) {
1220
+ if (this.frozen) throw new Error("Cannot commit a frozen collection");
1221
+ this.firstKey = firstKey;
1222
+ this.lastKey = lastKey;
1223
+ this.frozen = !isSSR;
1224
+ }
1225
+ filter(filterFn) {
1226
+ let newCollection = new this.constructor();
1227
+ let [firstKey, lastKey] = $23b9f4fcf0fe224b$var$filterChildren(this, newCollection, this.firstKey, filterFn);
1228
+ newCollection === null || newCollection === void 0 ? void 0 : newCollection.commit(firstKey, lastKey);
1229
+ return newCollection;
1230
+ }
1231
+ constructor() {
1232
+ this.keyMap = /* @__PURE__ */ new Map();
1233
+ this.firstKey = null;
1234
+ this.lastKey = null;
1235
+ this.frozen = false;
1236
+ this.itemCount = 0;
1237
+ }
1502
1238
  }
1503
- function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
1504
- let { id, selectionManager: manager, key, ref, shouldSelectOnPressUp, shouldUseVirtualFocus, focus, isDisabled, onAction, allowsDifferentPressOrigin, linkBehavior = "action" } = options;
1505
- let router = $ea8dcbcb9ea1b556$export$9a302a45f65d0572();
1506
- id = $bdb11010cef70236$export$f680877a34711e37(id);
1507
- let onSelect = (e) => {
1508
- if (e.pointerType === "keyboard" && $feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.toggleSelection(key);
1509
- else {
1510
- if (manager.selectionMode === "none") return;
1511
- if (manager.isLink(key)) {
1512
- if (linkBehavior === "selection" && ref.current) {
1513
- let itemProps2 = manager.getItemProps(key);
1514
- router.open(ref.current, e, itemProps2.href, itemProps2.routerOptions);
1515
- manager.setSelectedKeys(manager.selectedKeys);
1516
- return;
1517
- } else if (linkBehavior === "override" || linkBehavior === "none") return;
1239
+ function $23b9f4fcf0fe224b$var$filterChildren(collection, newCollection, firstChildKey, filterFn) {
1240
+ if (firstChildKey == null) return [
1241
+ null,
1242
+ null
1243
+ ];
1244
+ let firstNode = null;
1245
+ let lastNode = null;
1246
+ let currentNode = collection.getItem(firstChildKey);
1247
+ while (currentNode != null) {
1248
+ let newNode = currentNode.filter(collection, newCollection, filterFn);
1249
+ if (newNode != null) {
1250
+ newNode.nextKey = null;
1251
+ if (lastNode) {
1252
+ newNode.prevKey = lastNode.key;
1253
+ lastNode.nextKey = newNode.key;
1518
1254
  }
1519
- if (manager.selectionMode === "single") {
1520
- if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
1521
- else manager.replaceSelection(key);
1522
- } else if (e && e.shiftKey) manager.extendSelection(key);
1523
- else if (manager.selectionBehavior === "toggle" || e && ($21f1aa98acb08317$export$16792effe837dba3(e) || e.pointerType === "touch" || e.pointerType === "virtual"))
1524
- manager.toggleSelection(key);
1525
- else manager.replaceSelection(key);
1255
+ if (firstNode == null) firstNode = newNode;
1256
+ newCollection.addNode(newNode);
1257
+ lastNode = newNode;
1258
+ }
1259
+ currentNode = currentNode.nextKey ? collection.getItem(currentNode.nextKey) : null;
1260
+ }
1261
+ if (lastNode && lastNode.type === "separator") {
1262
+ let prevKey = lastNode.prevKey;
1263
+ newCollection.removeNode(lastNode.key);
1264
+ if (prevKey) {
1265
+ lastNode = newCollection.getItem(prevKey);
1266
+ lastNode.nextKey = null;
1267
+ } else lastNode = null;
1268
+ }
1269
+ var _firstNode_key, _lastNode_key;
1270
+ return [
1271
+ (_firstNode_key = firstNode === null || firstNode === void 0 ? void 0 : firstNode.key) !== null && _firstNode_key !== void 0 ? _firstNode_key : null,
1272
+ (_lastNode_key = lastNode === null || lastNode === void 0 ? void 0 : lastNode.key) !== null && _lastNode_key !== void 0 ? _lastNode_key : null
1273
+ ];
1274
+ }
1275
+ class $681cc3c98f569e39$export$410b0c854570d131 {
1276
+ *[Symbol.iterator]() {
1277
+ let node = this.firstChild;
1278
+ while (node) {
1279
+ yield node;
1280
+ node = node.nextSibling;
1281
+ }
1282
+ }
1283
+ get firstChild() {
1284
+ return this._firstChild;
1285
+ }
1286
+ set firstChild(firstChild) {
1287
+ this._firstChild = firstChild;
1288
+ this.ownerDocument.markDirty(this);
1289
+ }
1290
+ get lastChild() {
1291
+ return this._lastChild;
1292
+ }
1293
+ set lastChild(lastChild) {
1294
+ this._lastChild = lastChild;
1295
+ this.ownerDocument.markDirty(this);
1296
+ }
1297
+ get previousSibling() {
1298
+ return this._previousSibling;
1299
+ }
1300
+ set previousSibling(previousSibling) {
1301
+ this._previousSibling = previousSibling;
1302
+ this.ownerDocument.markDirty(this);
1303
+ }
1304
+ get nextSibling() {
1305
+ return this._nextSibling;
1306
+ }
1307
+ set nextSibling(nextSibling) {
1308
+ this._nextSibling = nextSibling;
1309
+ this.ownerDocument.markDirty(this);
1310
+ }
1311
+ get parentNode() {
1312
+ return this._parentNode;
1313
+ }
1314
+ set parentNode(parentNode) {
1315
+ this._parentNode = parentNode;
1316
+ this.ownerDocument.markDirty(this);
1317
+ }
1318
+ get isConnected() {
1319
+ var _this_parentNode;
1320
+ return ((_this_parentNode = this.parentNode) === null || _this_parentNode === void 0 ? void 0 : _this_parentNode.isConnected) || false;
1321
+ }
1322
+ invalidateChildIndices(child) {
1323
+ if (this._minInvalidChildIndex == null || !this._minInvalidChildIndex.isConnected || child.index < this._minInvalidChildIndex.index) {
1324
+ this._minInvalidChildIndex = child;
1325
+ this.ownerDocument.markDirty(this);
1326
+ }
1327
+ }
1328
+ updateChildIndices() {
1329
+ let node = this._minInvalidChildIndex;
1330
+ while (node) {
1331
+ node.index = node.previousSibling ? node.previousSibling.index + 1 : 0;
1332
+ node = node.nextSibling;
1333
+ }
1334
+ this._minInvalidChildIndex = null;
1335
+ }
1336
+ appendChild(child) {
1337
+ if (child.parentNode) child.parentNode.removeChild(child);
1338
+ if (this.firstChild == null) this.firstChild = child;
1339
+ if (this.lastChild) {
1340
+ this.lastChild.nextSibling = child;
1341
+ child.index = this.lastChild.index + 1;
1342
+ child.previousSibling = this.lastChild;
1343
+ } else {
1344
+ child.previousSibling = null;
1345
+ child.index = 0;
1526
1346
  }
1527
- };
1528
- useEffect(() => {
1529
- let isFocused = key === manager.focusedKey;
1530
- if (isFocused && manager.isFocused) {
1531
- if (!shouldUseVirtualFocus) {
1532
- if (focus) focus();
1533
- else if (document.activeElement !== ref.current && ref.current) $3ad3f6e1647bc98d$export$80f3e147d781571c(ref.current);
1534
- } else $55f9b1ae81f22853$export$76e4e37e5339496d(ref.current);
1347
+ child.parentNode = this;
1348
+ child.nextSibling = null;
1349
+ this.lastChild = child;
1350
+ this.ownerDocument.markDirty(this);
1351
+ if (this.isConnected) this.ownerDocument.queueUpdate();
1352
+ }
1353
+ insertBefore(newNode, referenceNode) {
1354
+ if (referenceNode == null) return this.appendChild(newNode);
1355
+ if (newNode.parentNode) newNode.parentNode.removeChild(newNode);
1356
+ newNode.nextSibling = referenceNode;
1357
+ newNode.previousSibling = referenceNode.previousSibling;
1358
+ newNode.index = referenceNode.index - 1;
1359
+ if (this.firstChild === referenceNode) this.firstChild = newNode;
1360
+ else if (referenceNode.previousSibling) referenceNode.previousSibling.nextSibling = newNode;
1361
+ referenceNode.previousSibling = newNode;
1362
+ newNode.parentNode = referenceNode.parentNode;
1363
+ this.invalidateChildIndices(newNode);
1364
+ if (this.isConnected) this.ownerDocument.queueUpdate();
1365
+ }
1366
+ removeChild(child) {
1367
+ if (child.parentNode !== this || !this.ownerDocument.isMounted) return;
1368
+ if (this._minInvalidChildIndex === child) this._minInvalidChildIndex = null;
1369
+ if (child.nextSibling) {
1370
+ this.invalidateChildIndices(child.nextSibling);
1371
+ child.nextSibling.previousSibling = child.previousSibling;
1535
1372
  }
1536
- }, [
1537
- ref,
1538
- key,
1539
- manager.focusedKey,
1540
- manager.childFocusStrategy,
1541
- manager.isFocused,
1542
- shouldUseVirtualFocus
1543
- ]);
1544
- isDisabled = isDisabled || manager.isDisabled(key);
1545
- let itemProps = {};
1546
- if (!shouldUseVirtualFocus && !isDisabled) itemProps = {
1547
- tabIndex: key === manager.focusedKey ? 0 : -1,
1548
- onFocus(e) {
1549
- if (e.target === ref.current) manager.setFocusedKey(key);
1373
+ if (child.previousSibling) child.previousSibling.nextSibling = child.nextSibling;
1374
+ if (this.firstChild === child) this.firstChild = child.nextSibling;
1375
+ if (this.lastChild === child) this.lastChild = child.previousSibling;
1376
+ child.parentNode = null;
1377
+ child.nextSibling = null;
1378
+ child.previousSibling = null;
1379
+ child.index = 0;
1380
+ this.ownerDocument.markDirty(child);
1381
+ if (this.isConnected) this.ownerDocument.queueUpdate();
1382
+ }
1383
+ addEventListener() {
1384
+ }
1385
+ removeEventListener() {
1386
+ }
1387
+ get previousVisibleSibling() {
1388
+ let node = this.previousSibling;
1389
+ while (node && node.isHidden) node = node.previousSibling;
1390
+ return node;
1391
+ }
1392
+ get nextVisibleSibling() {
1393
+ let node = this.nextSibling;
1394
+ while (node && node.isHidden) node = node.nextSibling;
1395
+ return node;
1396
+ }
1397
+ get firstVisibleChild() {
1398
+ let node = this.firstChild;
1399
+ while (node && node.isHidden) node = node.nextSibling;
1400
+ return node;
1401
+ }
1402
+ get lastVisibleChild() {
1403
+ let node = this.lastChild;
1404
+ while (node && node.isHidden) node = node.previousSibling;
1405
+ return node;
1406
+ }
1407
+ constructor(ownerDocument) {
1408
+ this._firstChild = null;
1409
+ this._lastChild = null;
1410
+ this._previousSibling = null;
1411
+ this._nextSibling = null;
1412
+ this._parentNode = null;
1413
+ this._minInvalidChildIndex = null;
1414
+ this.ownerDocument = ownerDocument;
1415
+ }
1416
+ }
1417
+ class $681cc3c98f569e39$export$dc064fe9e59310fd extends $681cc3c98f569e39$export$410b0c854570d131 {
1418
+ get index() {
1419
+ return this._index;
1420
+ }
1421
+ set index(index) {
1422
+ this._index = index;
1423
+ this.ownerDocument.markDirty(this);
1424
+ }
1425
+ get level() {
1426
+ var _this_node;
1427
+ if (this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) return this.parentNode.level + (((_this_node = this.node) === null || _this_node === void 0 ? void 0 : _this_node.type) === "item" ? 1 : 0);
1428
+ return 0;
1429
+ }
1430
+ /**
1431
+ * Lazily gets a mutable instance of a Node. If the node has already
1432
+ * been cloned during this update cycle, it just returns the existing one.
1433
+ */
1434
+ getMutableNode() {
1435
+ if (this.node == null) return null;
1436
+ if (!this.isMutated) {
1437
+ this.node = this.node.clone();
1438
+ this.isMutated = true;
1550
1439
  }
1551
- };
1552
- else if (isDisabled) itemProps.onMouseDown = (e) => {
1553
- e.preventDefault();
1554
- };
1555
- let isLinkOverride = manager.isLink(key) && linkBehavior === "override";
1556
- let hasLinkAction = manager.isLink(key) && linkBehavior !== "selection" && linkBehavior !== "none";
1557
- let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
1558
- let allowsActions = (onAction || hasLinkAction) && !isDisabled;
1559
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : !allowsSelection || manager.isEmpty);
1560
- let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
1561
- let hasAction = hasPrimaryAction || hasSecondaryAction;
1562
- let modality = useRef(null);
1563
- let longPressEnabled = hasAction && allowsSelection;
1564
- let longPressEnabledOnPressStart = useRef(false);
1565
- let hadPrimaryActionOnPressStart = useRef(false);
1566
- let collectionItemProps = manager.getItemProps(key);
1567
- let performAction = (e) => {
1568
- if (onAction) onAction();
1569
- if (hasLinkAction && ref.current) router.open(ref.current, e, collectionItemProps.href, collectionItemProps.routerOptions);
1570
- };
1571
- let itemPressProps = {
1572
- ref
1573
- };
1574
- if (shouldSelectOnPressUp) {
1575
- itemPressProps.onPressStart = (e) => {
1576
- modality.current = e.pointerType;
1577
- longPressEnabledOnPressStart.current = longPressEnabled;
1578
- if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
1579
- };
1580
- if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e) => {
1581
- if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
1582
- if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
1583
- performAction(e);
1584
- } else if (e.pointerType !== "keyboard" && allowsSelection) onSelect(e);
1585
- };
1586
- else {
1587
- itemPressProps.onPressUp = hasPrimaryAction ? void 0 : (e) => {
1588
- if (e.pointerType === "mouse" && allowsSelection) onSelect(e);
1589
- };
1590
- itemPressProps.onPress = hasPrimaryAction ? performAction : (e) => {
1591
- if (e.pointerType !== "keyboard" && e.pointerType !== "mouse" && allowsSelection) onSelect(e);
1592
- };
1440
+ this.ownerDocument.markDirty(this);
1441
+ return this.node;
1442
+ }
1443
+ updateNode() {
1444
+ var _this_parentNode_node, _this_previousVisibleSibling_node, _this_previousVisibleSibling, _nextSibling_node, _this_firstVisibleChild_node, _this_firstVisibleChild, _this_lastVisibleChild_node, _this_lastVisibleChild;
1445
+ let nextSibling = this.nextVisibleSibling;
1446
+ let node = this.getMutableNode();
1447
+ if (node == null) return;
1448
+ node.index = this.index;
1449
+ node.level = this.level;
1450
+ var _this_parentNode_node_key;
1451
+ node.parentKey = this.parentNode instanceof $681cc3c98f569e39$export$dc064fe9e59310fd ? (_this_parentNode_node_key = (_this_parentNode_node = this.parentNode.node) === null || _this_parentNode_node === void 0 ? void 0 : _this_parentNode_node.key) !== null && _this_parentNode_node_key !== void 0 ? _this_parentNode_node_key : null : null;
1452
+ var _this_previousVisibleSibling_node_key;
1453
+ node.prevKey = (_this_previousVisibleSibling_node_key = (_this_previousVisibleSibling = this.previousVisibleSibling) === null || _this_previousVisibleSibling === void 0 ? void 0 : (_this_previousVisibleSibling_node = _this_previousVisibleSibling.node) === null || _this_previousVisibleSibling_node === void 0 ? void 0 : _this_previousVisibleSibling_node.key) !== null && _this_previousVisibleSibling_node_key !== void 0 ? _this_previousVisibleSibling_node_key : null;
1454
+ var _nextSibling_node_key;
1455
+ node.nextKey = (_nextSibling_node_key = nextSibling === null || nextSibling === void 0 ? void 0 : (_nextSibling_node = nextSibling.node) === null || _nextSibling_node === void 0 ? void 0 : _nextSibling_node.key) !== null && _nextSibling_node_key !== void 0 ? _nextSibling_node_key : null;
1456
+ node.hasChildNodes = !!this.firstChild;
1457
+ var _this_firstVisibleChild_node_key;
1458
+ node.firstChildKey = (_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : (_this_firstVisibleChild_node = _this_firstVisibleChild.node) === null || _this_firstVisibleChild_node === void 0 ? void 0 : _this_firstVisibleChild_node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null;
1459
+ var _this_lastVisibleChild_node_key;
1460
+ node.lastChildKey = (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : (_this_lastVisibleChild_node = _this_lastVisibleChild.node) === null || _this_lastVisibleChild_node === void 0 ? void 0 : _this_lastVisibleChild_node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null;
1461
+ if ((node.colSpan != null || node.colIndex != null) && nextSibling) {
1462
+ var _node_colIndex, _node_colSpan;
1463
+ let nextColIndex = ((_node_colIndex = node.colIndex) !== null && _node_colIndex !== void 0 ? _node_colIndex : node.index) + ((_node_colSpan = node.colSpan) !== null && _node_colSpan !== void 0 ? _node_colSpan : 1);
1464
+ if (nextSibling.node != null && nextColIndex !== nextSibling.node.colIndex) {
1465
+ let siblingNode = nextSibling.getMutableNode();
1466
+ siblingNode.colIndex = nextColIndex;
1467
+ }
1593
1468
  }
1594
- } else {
1595
- itemPressProps.onPressStart = (e) => {
1596
- modality.current = e.pointerType;
1597
- longPressEnabledOnPressStart.current = longPressEnabled;
1598
- hadPrimaryActionOnPressStart.current = hasPrimaryAction;
1599
- if (allowsSelection && (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!allowsActions || $880e95eb8b93ba9a$var$isSelectionKey()))) onSelect(e);
1600
- };
1601
- itemPressProps.onPress = (e) => {
1602
- if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
1603
- if (hasAction) performAction(e);
1604
- else if (allowsSelection) onSelect(e);
1469
+ }
1470
+ setProps(obj, ref, CollectionNodeClass, rendered, render) {
1471
+ let node;
1472
+ let { value: value1, textValue, id, ...props } = obj;
1473
+ if (this.node == null) {
1474
+ node = new CollectionNodeClass(id !== null && id !== void 0 ? id : `react-aria-${++this.ownerDocument.nodeId}`);
1475
+ this.node = node;
1476
+ } else node = this.getMutableNode();
1477
+ props.ref = ref;
1478
+ node.props = props;
1479
+ node.rendered = rendered;
1480
+ node.render = render;
1481
+ node.value = value1;
1482
+ node.textValue = textValue || (typeof props.children === "string" ? props.children : "") || obj["aria-label"] || "";
1483
+ if (id != null && id !== node.key) throw new Error("Cannot change the id of an item");
1484
+ if (props.colSpan != null) node.colSpan = props.colSpan;
1485
+ if (this.isConnected) this.ownerDocument.queueUpdate();
1486
+ }
1487
+ get style() {
1488
+ let element = this;
1489
+ return {
1490
+ get display() {
1491
+ return element.isHidden ? "none" : "";
1492
+ },
1493
+ set display(value) {
1494
+ let isHidden = value === "none";
1495
+ if (element.isHidden !== isHidden) {
1496
+ var _element_parentNode, _element_parentNode1;
1497
+ if (((_element_parentNode = element.parentNode) === null || _element_parentNode === void 0 ? void 0 : _element_parentNode.firstVisibleChild) === element || ((_element_parentNode1 = element.parentNode) === null || _element_parentNode1 === void 0 ? void 0 : _element_parentNode1.lastVisibleChild) === element) element.ownerDocument.markDirty(element.parentNode);
1498
+ let prev = element.previousVisibleSibling;
1499
+ let next = element.nextVisibleSibling;
1500
+ if (prev) element.ownerDocument.markDirty(prev);
1501
+ if (next) element.ownerDocument.markDirty(next);
1502
+ element.isHidden = isHidden;
1503
+ element.ownerDocument.markDirty(element);
1504
+ }
1605
1505
  }
1606
1506
  };
1607
1507
  }
1608
- itemProps["data-collection"] = $feb5ffebff200149$export$6aeb1680a0ae8741(manager.collection);
1609
- itemProps["data-key"] = key;
1610
- itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
1611
- if (shouldUseVirtualFocus) itemPressProps = $3ef42575df84b30b$export$9d1611c77c2fe928(itemPressProps, {
1612
- onPressStart(e) {
1613
- if (e.pointerType !== "touch") {
1614
- manager.setFocused(true);
1615
- manager.setFocusedKey(key);
1508
+ hasAttribute() {
1509
+ }
1510
+ setAttribute() {
1511
+ }
1512
+ setAttributeNS() {
1513
+ }
1514
+ removeAttribute() {
1515
+ }
1516
+ constructor(type, ownerDocument) {
1517
+ super(ownerDocument), this.nodeType = 8, this.isMutated = true, this._index = 0, this.isHidden = false;
1518
+ this.node = null;
1519
+ }
1520
+ }
1521
+ class $681cc3c98f569e39$export$b34a105447964f9f extends $681cc3c98f569e39$export$410b0c854570d131 {
1522
+ get isConnected() {
1523
+ return this.isMounted;
1524
+ }
1525
+ createElement(type) {
1526
+ return new $681cc3c98f569e39$export$dc064fe9e59310fd(type, this);
1527
+ }
1528
+ getMutableCollection() {
1529
+ if (!this.nextCollection) this.nextCollection = this.collection.clone();
1530
+ return this.nextCollection;
1531
+ }
1532
+ markDirty(node) {
1533
+ this.dirtyNodes.add(node);
1534
+ }
1535
+ addNode(element) {
1536
+ if (element.isHidden || element.node == null) return;
1537
+ let collection = this.getMutableCollection();
1538
+ if (!collection.getItem(element.node.key)) for (let child of element) this.addNode(child);
1539
+ collection.addNode(element.node);
1540
+ }
1541
+ removeNode(node) {
1542
+ if (node.node == null) return;
1543
+ for (let child of node) this.removeNode(child);
1544
+ let collection = this.getMutableCollection();
1545
+ collection.removeNode(node.node.key);
1546
+ }
1547
+ /** Finalizes the collection update, updating all nodes and freezing the collection. */
1548
+ getCollection() {
1549
+ if (this.inSubscription) return this.collection.clone();
1550
+ this.queuedRender = false;
1551
+ this.updateCollection();
1552
+ return this.collection;
1553
+ }
1554
+ updateCollection() {
1555
+ for (let element of this.dirtyNodes) if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd && (!element.isConnected || element.isHidden)) this.removeNode(element);
1556
+ else element.updateChildIndices();
1557
+ for (let element of this.dirtyNodes) if (element instanceof $681cc3c98f569e39$export$dc064fe9e59310fd) {
1558
+ if (element.isConnected && !element.isHidden) {
1559
+ element.updateNode();
1560
+ this.addNode(element);
1616
1561
  }
1617
- },
1618
- onPress(e) {
1619
- if (e.pointerType === "touch") {
1620
- manager.setFocused(true);
1621
- manager.setFocusedKey(key);
1562
+ element.isMutated = false;
1563
+ }
1564
+ this.dirtyNodes.clear();
1565
+ if (this.nextCollection) {
1566
+ var _this_firstVisibleChild_node, _this_firstVisibleChild, _this_lastVisibleChild_node, _this_lastVisibleChild;
1567
+ var _this_firstVisibleChild_node_key, _this_lastVisibleChild_node_key;
1568
+ this.nextCollection.commit((_this_firstVisibleChild_node_key = (_this_firstVisibleChild = this.firstVisibleChild) === null || _this_firstVisibleChild === void 0 ? void 0 : (_this_firstVisibleChild_node = _this_firstVisibleChild.node) === null || _this_firstVisibleChild_node === void 0 ? void 0 : _this_firstVisibleChild_node.key) !== null && _this_firstVisibleChild_node_key !== void 0 ? _this_firstVisibleChild_node_key : null, (_this_lastVisibleChild_node_key = (_this_lastVisibleChild = this.lastVisibleChild) === null || _this_lastVisibleChild === void 0 ? void 0 : (_this_lastVisibleChild_node = _this_lastVisibleChild.node) === null || _this_lastVisibleChild_node === void 0 ? void 0 : _this_lastVisibleChild_node.key) !== null && _this_lastVisibleChild_node_key !== void 0 ? _this_lastVisibleChild_node_key : null, this.isSSR);
1569
+ if (!this.isSSR) {
1570
+ this.collection = this.nextCollection;
1571
+ this.nextCollection = null;
1622
1572
  }
1623
1573
  }
1624
- });
1625
- if (collectionItemProps) {
1626
- for (let key2 of [
1627
- "onPressStart",
1628
- "onPressEnd",
1629
- "onPressChange",
1630
- "onPress",
1631
- "onPressUp",
1632
- "onClick"
1633
- ]) if (collectionItemProps[key2]) itemPressProps[key2] = $ff5963eb1fccf552$export$e08e3b67e392101e(itemPressProps[key2], collectionItemProps[key2]);
1634
1574
  }
1635
- let { pressProps, isPressed } = $f6c31cce2adf654f$export$45712eceda6fad21(itemPressProps);
1636
- let onDoubleClick = hasSecondaryAction ? (e) => {
1637
- if (modality.current === "mouse") {
1638
- e.stopPropagation();
1639
- e.preventDefault();
1640
- performAction(e);
1641
- }
1642
- } : void 0;
1643
- let { longPressProps } = $8a26561d2877236e$export$c24ed0104d07eab9({
1644
- isDisabled: !longPressEnabled,
1645
- onLongPress(e) {
1646
- if (e.pointerType === "touch") {
1647
- onSelect(e);
1648
- manager.setSelectionBehavior("toggle");
1649
- }
1575
+ queueUpdate() {
1576
+ if (this.dirtyNodes.size === 0 || this.queuedRender) return;
1577
+ this.queuedRender = true;
1578
+ this.inSubscription = true;
1579
+ for (let fn of this.subscriptions) fn();
1580
+ this.inSubscription = false;
1581
+ }
1582
+ subscribe(fn) {
1583
+ this.subscriptions.add(fn);
1584
+ return () => this.subscriptions.delete(fn);
1585
+ }
1586
+ resetAfterSSR() {
1587
+ if (this.isSSR) {
1588
+ this.isSSR = false;
1589
+ this.firstChild = null;
1590
+ this.lastChild = null;
1591
+ this.nodeId = 0;
1650
1592
  }
1651
- });
1652
- let onDragStartCapture = (e) => {
1653
- if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
1654
- };
1655
- let onClick = linkBehavior !== "none" && manager.isLink(key) ? (e) => {
1656
- if (!$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening) e.preventDefault();
1657
- } : void 0;
1658
- return {
1659
- itemProps: $3ef42575df84b30b$export$9d1611c77c2fe928(
1660
- itemProps,
1661
- allowsSelection || hasPrimaryAction || shouldUseVirtualFocus && !isDisabled ? pressProps : {},
1662
- longPressEnabled ? longPressProps : {},
1663
- {
1664
- onDoubleClick,
1665
- onDragStartCapture,
1666
- onClick,
1667
- id
1668
- },
1669
- // Prevent DOM focus from moving on mouse down when using virtual focus
1670
- shouldUseVirtualFocus ? {
1671
- onMouseDown: (e) => e.preventDefault()
1672
- } : void 0
1673
- ),
1674
- isPressed,
1675
- isSelected: manager.isSelected(key),
1676
- isFocused: manager.isFocused && manager.focusedKey === key,
1677
- isDisabled,
1678
- allowsSelection,
1679
- hasAction
1680
- };
1681
- }
1682
- function $880e95eb8b93ba9a$var$isActionKey() {
1683
- let event = window.event;
1684
- return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
1685
- }
1686
- function $880e95eb8b93ba9a$var$isSelectionKey() {
1687
- let event = window.event;
1688
- return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
1689
- }
1690
- class $eb2240fc39a57fa5$export$bf788dd355e3a401 {
1691
- build(props, context) {
1692
- this.context = context;
1693
- return $eb2240fc39a57fa5$var$iterable(() => this.iterateCollection(props));
1694
1593
  }
1695
- *iterateCollection(props) {
1696
- let { children, items } = props;
1697
- if (React__default.isValidElement(children) && children.type === React__default.Fragment) yield* this.iterateCollection({
1698
- children: children.props.children,
1699
- items
1700
- });
1701
- else if (typeof children === "function") {
1702
- if (!items) throw new Error("props.children was a function but props.items is missing");
1703
- let index = 0;
1594
+ constructor(collection) {
1595
+ super(null), this.nodeType = 11, this.ownerDocument = this, this.dirtyNodes = /* @__PURE__ */ new Set(), this.isSSR = false, this.nodeId = 0, this.nodesByProps = /* @__PURE__ */ new WeakMap(), this.isMounted = true, this.nextCollection = null, this.subscriptions = /* @__PURE__ */ new Set(), this.queuedRender = false, this.inSubscription = false;
1596
+ this.collection = collection;
1597
+ this.nextCollection = collection;
1598
+ }
1599
+ }
1600
+ function $e948873055cbafe4$export$727c8fc270210f13(props) {
1601
+ let { children, items, idScope, addIdAndValue, dependencies = [] } = props;
1602
+ let cache = useMemo(() => /* @__PURE__ */ new WeakMap(), dependencies);
1603
+ return useMemo(() => {
1604
+ if (items && typeof children === "function") {
1605
+ let res = [];
1704
1606
  for (let item of items) {
1705
- yield* this.getFullNode({
1706
- value: item,
1707
- index
1708
- }, {
1709
- renderer: children
1710
- });
1711
- index++;
1712
- }
1713
- } else {
1714
- let items2 = [];
1715
- React__default.Children.forEach(children, (child) => {
1716
- if (child) items2.push(child);
1717
- });
1718
- let index = 0;
1719
- for (let item of items2) {
1720
- let nodes = this.getFullNode({
1721
- element: item,
1722
- index
1723
- }, {});
1724
- for (let node of nodes) {
1725
- index++;
1726
- yield node;
1607
+ let rendered = cache.get(item);
1608
+ if (!rendered) {
1609
+ rendered = children(item);
1610
+ var _rendered_props_id, _ref;
1611
+ let key = (_ref = (_rendered_props_id = rendered.props.id) !== null && _rendered_props_id !== void 0 ? _rendered_props_id : item.key) !== null && _ref !== void 0 ? _ref : item.id;
1612
+ if (key == null) throw new Error("Could not determine key for item");
1613
+ if (idScope) key = idScope + ":" + key;
1614
+ rendered = cloneElement(rendered, addIdAndValue ? {
1615
+ key,
1616
+ id: key,
1617
+ value: item
1618
+ } : {
1619
+ key
1620
+ });
1621
+ cache.set(item, rendered);
1727
1622
  }
1623
+ res.push(rendered);
1728
1624
  }
1729
- }
1625
+ return res;
1626
+ } else if (typeof children !== "function") return children;
1627
+ }, [
1628
+ children,
1629
+ items,
1630
+ cache,
1631
+ idScope,
1632
+ addIdAndValue
1633
+ ]);
1634
+ }
1635
+ var shim = { exports: {} };
1636
+ var useSyncExternalStoreShim_production = {};
1637
+ /**
1638
+ * @license React
1639
+ * use-sync-external-store-shim.production.js
1640
+ *
1641
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1642
+ *
1643
+ * This source code is licensed under the MIT license found in the
1644
+ * LICENSE file in the root directory of this source tree.
1645
+ */
1646
+ var hasRequiredUseSyncExternalStoreShim_production;
1647
+ function requireUseSyncExternalStoreShim_production() {
1648
+ if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
1649
+ hasRequiredUseSyncExternalStoreShim_production = 1;
1650
+ var React = React__default;
1651
+ function is(x, y) {
1652
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
1730
1653
  }
1731
- getKey(item, partialNode, state, parentKey) {
1732
- if (item.key != null) return item.key;
1733
- if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
1734
- let v = partialNode.value;
1735
- if (v != null) {
1736
- var _v_key;
1737
- let key = (_v_key = v.key) !== null && _v_key !== void 0 ? _v_key : v.id;
1738
- if (key == null) throw new Error("No key found for item");
1739
- return key;
1654
+ var objectIs = "function" === typeof Object.is ? Object.is : is, useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
1655
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
1656
+ var value = getSnapshot(), _useState = useState2({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
1657
+ useLayoutEffect(
1658
+ function() {
1659
+ inst.value = value;
1660
+ inst.getSnapshot = getSnapshot;
1661
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1662
+ },
1663
+ [subscribe, value, getSnapshot]
1664
+ );
1665
+ useEffect2(
1666
+ function() {
1667
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1668
+ return subscribe(function() {
1669
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1670
+ });
1671
+ },
1672
+ [subscribe]
1673
+ );
1674
+ useDebugValue(value);
1675
+ return value;
1676
+ }
1677
+ function checkIfSnapshotChanged(inst) {
1678
+ var latestGetSnapshot = inst.getSnapshot;
1679
+ inst = inst.value;
1680
+ try {
1681
+ var nextValue = latestGetSnapshot();
1682
+ return !objectIs(inst, nextValue);
1683
+ } catch (error) {
1684
+ return true;
1740
1685
  }
1741
- return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
1742
1686
  }
1743
- getChildState(state, partialNode) {
1744
- return {
1745
- renderer: partialNode.renderer || state.renderer
1746
- };
1687
+ function useSyncExternalStore$1(subscribe, getSnapshot) {
1688
+ return getSnapshot();
1747
1689
  }
1748
- *getFullNode(partialNode, state, parentKey, parentNode) {
1749
- if (React__default.isValidElement(partialNode.element) && partialNode.element.type === React__default.Fragment) {
1750
- let children = [];
1751
- React__default.Children.forEach(partialNode.element.props.children, (child) => {
1752
- children.push(child);
1753
- });
1754
- var _partialNode_index;
1755
- let index = (_partialNode_index = partialNode.index) !== null && _partialNode_index !== void 0 ? _partialNode_index : 0;
1756
- for (const child of children) yield* this.getFullNode({
1757
- element: child,
1758
- index: index++
1759
- }, state, parentKey, parentNode);
1760
- return;
1690
+ var shim2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
1691
+ useSyncExternalStoreShim_production.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim2;
1692
+ return useSyncExternalStoreShim_production;
1693
+ }
1694
+ var useSyncExternalStoreShim_development = {};
1695
+ /**
1696
+ * @license React
1697
+ * use-sync-external-store-shim.development.js
1698
+ *
1699
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
1700
+ *
1701
+ * This source code is licensed under the MIT license found in the
1702
+ * LICENSE file in the root directory of this source tree.
1703
+ */
1704
+ var hasRequiredUseSyncExternalStoreShim_development;
1705
+ function requireUseSyncExternalStoreShim_development() {
1706
+ if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
1707
+ hasRequiredUseSyncExternalStoreShim_development = 1;
1708
+ "production" !== process.env.NODE_ENV && (function() {
1709
+ function is(x, y) {
1710
+ return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
1761
1711
  }
1762
- let element = partialNode.element;
1763
- if (!element && partialNode.value && state && state.renderer) {
1764
- let cached = this.cache.get(partialNode.value);
1765
- if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {
1766
- cached.index = partialNode.index;
1767
- cached.parentKey = parentNode ? parentNode.key : null;
1768
- yield cached;
1769
- return;
1712
+ function useSyncExternalStore$2(subscribe, getSnapshot) {
1713
+ didWarnOld18Alpha || void 0 === React.startTransition || (didWarnOld18Alpha = true, console.error(
1714
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
1715
+ ));
1716
+ var value = getSnapshot();
1717
+ if (!didWarnUncachedGetSnapshot) {
1718
+ var cachedValue = getSnapshot();
1719
+ objectIs(value, cachedValue) || (console.error(
1720
+ "The result of getSnapshot should be cached to avoid an infinite loop"
1721
+ ), didWarnUncachedGetSnapshot = true);
1770
1722
  }
1771
- element = state.renderer(partialNode.value);
1723
+ cachedValue = useState2({
1724
+ inst: { value, getSnapshot }
1725
+ });
1726
+ var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
1727
+ useLayoutEffect(
1728
+ function() {
1729
+ inst.value = value;
1730
+ inst.getSnapshot = getSnapshot;
1731
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1732
+ },
1733
+ [subscribe, value, getSnapshot]
1734
+ );
1735
+ useEffect2(
1736
+ function() {
1737
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1738
+ return subscribe(function() {
1739
+ checkIfSnapshotChanged(inst) && forceUpdate({ inst });
1740
+ });
1741
+ },
1742
+ [subscribe]
1743
+ );
1744
+ useDebugValue(value);
1745
+ return value;
1772
1746
  }
1773
- if (React__default.isValidElement(element)) {
1774
- let type = element.type;
1775
- if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
1776
- let name = element.type;
1777
- throw new Error(`Unknown element <${name}> in collection.`);
1778
- }
1779
- let childNodes = type.getCollectionNode(element.props, this.context);
1780
- var _partialNode_index1;
1781
- let index = (_partialNode_index1 = partialNode.index) !== null && _partialNode_index1 !== void 0 ? _partialNode_index1 : 0;
1782
- let result = childNodes.next();
1783
- while (!result.done && result.value) {
1784
- let childNode = result.value;
1785
- partialNode.index = index;
1786
- var _childNode_key;
1787
- let nodeKey = (_childNode_key = childNode.key) !== null && _childNode_key !== void 0 ? _childNode_key : null;
1788
- if (nodeKey == null) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
1789
- let nodes = this.getFullNode({
1790
- ...childNode,
1791
- key: nodeKey,
1792
- index,
1793
- wrapper: $eb2240fc39a57fa5$var$compose(partialNode.wrapper, childNode.wrapper)
1794
- }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
1795
- let children = [
1796
- ...nodes
1797
- ];
1798
- for (let node2 of children) {
1799
- var _childNode_value, _ref;
1800
- node2.value = (_ref = (_childNode_value = childNode.value) !== null && _childNode_value !== void 0 ? _childNode_value : partialNode.value) !== null && _ref !== void 0 ? _ref : null;
1801
- if (node2.value) this.cache.set(node2.value, node2);
1802
- var _parentNode_type;
1803
- if (partialNode.type && node2.type !== partialNode.type) throw new Error(`Unsupported type <${$eb2240fc39a57fa5$var$capitalize(node2.type)}> in <${$eb2240fc39a57fa5$var$capitalize((_parentNode_type = parentNode === null || parentNode === void 0 ? void 0 : parentNode.type) !== null && _parentNode_type !== void 0 ? _parentNode_type : "unknown parent type")}>. Only <${$eb2240fc39a57fa5$var$capitalize(partialNode.type)}> is supported.`);
1804
- index++;
1805
- yield node2;
1806
- }
1807
- result = childNodes.next(children);
1747
+ function checkIfSnapshotChanged(inst) {
1748
+ var latestGetSnapshot = inst.getSnapshot;
1749
+ inst = inst.value;
1750
+ try {
1751
+ var nextValue = latestGetSnapshot();
1752
+ return !objectIs(inst, nextValue);
1753
+ } catch (error) {
1754
+ return true;
1808
1755
  }
1809
- return;
1810
1756
  }
1811
- if (partialNode.key == null || partialNode.type == null) return;
1812
- let builder = this;
1813
- var _partialNode_value, _partialNode_textValue;
1814
- let node = {
1815
- type: partialNode.type,
1816
- props: partialNode.props,
1817
- key: partialNode.key,
1818
- parentKey: parentNode ? parentNode.key : null,
1819
- value: (_partialNode_value = partialNode.value) !== null && _partialNode_value !== void 0 ? _partialNode_value : null,
1820
- level: parentNode ? parentNode.level + 1 : 0,
1821
- index: partialNode.index,
1822
- rendered: partialNode.rendered,
1823
- textValue: (_partialNode_textValue = partialNode.textValue) !== null && _partialNode_textValue !== void 0 ? _partialNode_textValue : "",
1824
- "aria-label": partialNode["aria-label"],
1825
- wrapper: partialNode.wrapper,
1826
- shouldInvalidate: partialNode.shouldInvalidate,
1827
- hasChildNodes: partialNode.hasChildNodes || false,
1828
- childNodes: $eb2240fc39a57fa5$var$iterable(function* () {
1829
- if (!partialNode.hasChildNodes || !partialNode.childNodes) return;
1830
- let index = 0;
1831
- for (let child of partialNode.childNodes()) {
1832
- if (child.key != null)
1833
- child.key = `${node.key}${child.key}`;
1834
- let nodes = builder.getFullNode({
1835
- ...child,
1836
- index
1837
- }, builder.getChildState(state, child), node.key, node);
1838
- for (let node2 of nodes) {
1839
- index++;
1840
- yield node2;
1841
- }
1842
- }
1843
- })
1844
- };
1845
- yield node;
1757
+ function useSyncExternalStore$1(subscribe, getSnapshot) {
1758
+ return getSnapshot();
1759
+ }
1760
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1761
+ var React = React__default, objectIs = "function" === typeof Object.is ? Object.is : is, useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
1762
+ useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim2;
1763
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1764
+ })();
1765
+ return useSyncExternalStoreShim_development;
1766
+ }
1767
+ var hasRequiredShim;
1768
+ function requireShim() {
1769
+ if (hasRequiredShim) return shim.exports;
1770
+ hasRequiredShim = 1;
1771
+ if (process.env.NODE_ENV === "production") {
1772
+ shim.exports = requireUseSyncExternalStoreShim_production();
1773
+ } else {
1774
+ shim.exports = requireUseSyncExternalStoreShim_development();
1846
1775
  }
1847
- constructor() {
1848
- this.cache = /* @__PURE__ */ new WeakMap();
1776
+ return shim.exports;
1777
+ }
1778
+ var shimExports = requireShim();
1779
+ const $e1995378a142960e$var$ShallowRenderContext = /* @__PURE__ */ createContext(false);
1780
+ const $e1995378a142960e$var$CollectionDocumentContext = /* @__PURE__ */ createContext(null);
1781
+ function $e1995378a142960e$export$bf788dd355e3a401(props) {
1782
+ let doc = useContext($e1995378a142960e$var$CollectionDocumentContext);
1783
+ if (doc)
1784
+ return props.content;
1785
+ let { collection, document: document2 } = $e1995378a142960e$var$useCollectionDocument(props.createCollection);
1786
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement($f39a9eba43920ace$export$8dc98ba7eadeaa56, null, /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionDocumentContext.Provider, {
1787
+ value: document2
1788
+ }, props.content)), /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionInner, {
1789
+ render: props.children,
1790
+ collection
1791
+ }));
1792
+ }
1793
+ function $e1995378a142960e$var$CollectionInner({ collection, render }) {
1794
+ return render(collection);
1795
+ }
1796
+ function $e1995378a142960e$var$useSyncExternalStoreFallback(subscribe, getSnapshot, getServerSnapshot) {
1797
+ let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
1798
+ let isSSRRef = useRef(isSSR);
1799
+ isSSRRef.current = isSSR;
1800
+ let getSnapshotWrapper = useCallback(() => {
1801
+ return isSSRRef.current ? getServerSnapshot() : getSnapshot();
1802
+ }, [
1803
+ getSnapshot,
1804
+ getServerSnapshot
1805
+ ]);
1806
+ return shimExports.useSyncExternalStore(subscribe, getSnapshotWrapper);
1807
+ }
1808
+ const $e1995378a142960e$var$useSyncExternalStore = typeof React__default["useSyncExternalStore"] === "function" ? React__default["useSyncExternalStore"] : $e1995378a142960e$var$useSyncExternalStoreFallback;
1809
+ function $e1995378a142960e$var$useCollectionDocument(createCollection) {
1810
+ let [document2] = useState(() => new $681cc3c98f569e39$export$b34a105447964f9f((createCollection === null || createCollection === void 0 ? void 0 : createCollection()) || new $23b9f4fcf0fe224b$export$408d25a4e12db025()));
1811
+ let subscribe = useCallback((fn) => document2.subscribe(fn), [
1812
+ document2
1813
+ ]);
1814
+ let getSnapshot = useCallback(() => {
1815
+ let collection2 = document2.getCollection();
1816
+ if (document2.isSSR)
1817
+ document2.resetAfterSSR();
1818
+ return collection2;
1819
+ }, [
1820
+ document2
1821
+ ]);
1822
+ let getServerSnapshot = useCallback(() => {
1823
+ document2.isSSR = true;
1824
+ return document2.getCollection();
1825
+ }, [
1826
+ document2
1827
+ ]);
1828
+ let collection = $e1995378a142960e$var$useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
1829
+ $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c(() => {
1830
+ document2.isMounted = true;
1831
+ return () => {
1832
+ document2.isMounted = false;
1833
+ };
1834
+ }, [
1835
+ document2
1836
+ ]);
1837
+ return {
1838
+ collection,
1839
+ document: document2
1840
+ };
1841
+ }
1842
+ const $e1995378a142960e$var$SSRContext = /* @__PURE__ */ createContext(null);
1843
+ function $e1995378a142960e$var$createCollectionNodeClass(type) {
1844
+ var _class;
1845
+ let NodeClass = (_class = class extends $23b9f4fcf0fe224b$export$d68d59712b04d9d1 {
1846
+ }, _class.type = type, _class);
1847
+ return NodeClass;
1848
+ }
1849
+ function $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, rendered, children, render) {
1850
+ if (typeof CollectionNodeClass === "string") CollectionNodeClass = $e1995378a142960e$var$createCollectionNodeClass(CollectionNodeClass);
1851
+ let itemRef = useCallback((element) => {
1852
+ element === null || element === void 0 ? void 0 : element.setProps(props, ref, CollectionNodeClass, rendered, render);
1853
+ }, [
1854
+ props,
1855
+ ref,
1856
+ rendered,
1857
+ render,
1858
+ CollectionNodeClass
1859
+ ]);
1860
+ let parentNode = useContext($e1995378a142960e$var$SSRContext);
1861
+ if (parentNode) {
1862
+ let element = parentNode.ownerDocument.nodesByProps.get(props);
1863
+ if (!element) {
1864
+ element = parentNode.ownerDocument.createElement(CollectionNodeClass.type);
1865
+ element.setProps(props, ref, CollectionNodeClass, rendered, render);
1866
+ parentNode.appendChild(element);
1867
+ parentNode.ownerDocument.updateCollection();
1868
+ parentNode.ownerDocument.nodesByProps.set(props, element);
1869
+ }
1870
+ return children ? /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$SSRContext.Provider, {
1871
+ value: element
1872
+ }, children) : null;
1849
1873
  }
1874
+ return /* @__PURE__ */ React__default.createElement(CollectionNodeClass.type, {
1875
+ ref: itemRef
1876
+ }, children);
1850
1877
  }
1851
- function $eb2240fc39a57fa5$var$iterable(iterator) {
1852
- let cache = [];
1853
- let iterable = null;
1854
- return {
1855
- *[Symbol.iterator]() {
1856
- for (let item of cache) yield item;
1857
- if (!iterable) iterable = iterator();
1858
- for (let item of iterable) {
1859
- cache.push(item);
1860
- yield item;
1861
- }
1878
+ function $e1995378a142960e$export$18af5c7a9e9b3664(CollectionNodeClass, render) {
1879
+ let Component = ({ node }) => render(node.props, node.props.ref, node);
1880
+ let Result = forwardRef((props, ref) => {
1881
+ let focusableProps = useContext($f645667febf57a63$export$f9762fab77588ecb);
1882
+ let isShallow = useContext($e1995378a142960e$var$ShallowRenderContext);
1883
+ if (!isShallow) {
1884
+ if (render.length >= 3) throw new Error(render.name + " cannot be rendered outside a collection.");
1885
+ return render(props, ref);
1862
1886
  }
1863
- };
1887
+ return $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, "children" in props ? props.children : null, null, (node) => (
1888
+ // Forward FocusableContext to real DOM tree so tooltips work.
1889
+ /* @__PURE__ */ React__default.createElement($f645667febf57a63$export$f9762fab77588ecb.Provider, {
1890
+ value: focusableProps
1891
+ }, /* @__PURE__ */ React__default.createElement(Component, {
1892
+ node
1893
+ }))
1894
+ ));
1895
+ });
1896
+ Result.displayName = render.name;
1897
+ return Result;
1864
1898
  }
1865
- function $eb2240fc39a57fa5$var$compose(outer, inner) {
1866
- if (outer && inner) return (element) => outer(inner(element));
1867
- if (outer) return outer;
1868
- if (inner) return inner;
1899
+ function $e1995378a142960e$export$e953bb1cd0f19726(CollectionNodeClass, render, useChildren = $e1995378a142960e$var$useCollectionChildren) {
1900
+ let Component = ({ node }) => render(node.props, node.props.ref, node);
1901
+ let Result = forwardRef((props, ref) => {
1902
+ let children = useChildren(props);
1903
+ var _useSSRCollectionNode;
1904
+ return (_useSSRCollectionNode = $e1995378a142960e$var$useSSRCollectionNode(CollectionNodeClass, props, ref, null, children, (node) => /* @__PURE__ */ React__default.createElement(Component, {
1905
+ node
1906
+ }))) !== null && _useSSRCollectionNode !== void 0 ? _useSSRCollectionNode : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
1907
+ });
1908
+ Result.displayName = render.name;
1909
+ return Result;
1869
1910
  }
1870
- function $eb2240fc39a57fa5$var$capitalize(str) {
1871
- return str[0].toUpperCase() + str.slice(1);
1911
+ function $e1995378a142960e$var$useCollectionChildren(options) {
1912
+ return $e948873055cbafe4$export$727c8fc270210f13({
1913
+ ...options,
1914
+ addIdAndValue: true
1915
+ });
1872
1916
  }
1873
- function $7613b1592d41b092$export$6cd28814d92fa9c9(props, factory, context) {
1874
- let builder = useMemo(() => new $eb2240fc39a57fa5$export$bf788dd355e3a401(), []);
1875
- let { children, items, collection } = props;
1876
- let result = useMemo(() => {
1877
- if (collection) return collection;
1878
- let nodes = builder.build({
1879
- children,
1880
- items
1881
- }, context);
1882
- return factory(nodes);
1883
- }, [
1884
- builder,
1885
- children,
1886
- items,
1887
- collection,
1888
- context,
1889
- factory
1917
+ const $e1995378a142960e$var$CollectionContext = /* @__PURE__ */ createContext(null);
1918
+ function $e1995378a142960e$export$fb8073518f34e6ec(props) {
1919
+ let ctx = useContext($e1995378a142960e$var$CollectionContext);
1920
+ let dependencies = ((ctx === null || ctx === void 0 ? void 0 : ctx.dependencies) || []).concat(props.dependencies);
1921
+ let idScope = props.idScope || (ctx === null || ctx === void 0 ? void 0 : ctx.idScope);
1922
+ let children = $e1995378a142960e$var$useCollectionChildren({
1923
+ ...props,
1924
+ idScope,
1925
+ dependencies
1926
+ });
1927
+ let doc = useContext($e1995378a142960e$var$CollectionDocumentContext);
1928
+ if (doc) children = /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionRoot, null, children);
1929
+ ctx = useMemo(() => ({
1930
+ dependencies,
1931
+ idScope
1932
+ }), [
1933
+ idScope,
1934
+ ...dependencies
1890
1935
  ]);
1891
- return result;
1892
- }
1893
- function $c5a24bc478652b5f$export$1005530eda016c13(node, collection) {
1894
- if (typeof collection.getChildren === "function") return collection.getChildren(node.key);
1895
- return node.childNodes;
1936
+ return /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionContext.Provider, {
1937
+ value: ctx
1938
+ }, children);
1896
1939
  }
1897
- function $c5a24bc478652b5f$export$fbdeaa6a76694f71(iterable) {
1898
- return $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable);
1940
+ function $e1995378a142960e$var$CollectionRoot({ children }) {
1941
+ let doc = useContext($e1995378a142960e$var$CollectionDocumentContext);
1942
+ let wrappedChildren = useMemo(() => /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$CollectionDocumentContext.Provider, {
1943
+ value: null
1944
+ }, /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$ShallowRenderContext.Provider, {
1945
+ value: true
1946
+ }, children)), [
1947
+ children
1948
+ ]);
1949
+ return $b5e257d569688ac6$export$535bd6ca7f90a273() ? /* @__PURE__ */ React__default.createElement($e1995378a142960e$var$SSRContext.Provider, {
1950
+ value: doc
1951
+ }, wrappedChildren) : /* @__PURE__ */ reactDomExports.createPortal(wrappedChildren, doc);
1899
1952
  }
1900
- function $c5a24bc478652b5f$export$5f3398f8733f90e2(iterable, index) {
1901
- for (let item of iterable) {
1902
- return item;
1953
+ const $7135fc7d473fd974$export$d40e14dec8b060a8 = /* @__PURE__ */ createContext(null);
1954
+ const $7135fc7d473fd974$export$a164736487e3f0ae = {
1955
+ CollectionRoot({ collection, renderDropIndicator }) {
1956
+ return $7135fc7d473fd974$var$useCollectionRender(collection, null, renderDropIndicator);
1957
+ },
1958
+ CollectionBranch({ collection, parent, renderDropIndicator }) {
1959
+ return $7135fc7d473fd974$var$useCollectionRender(collection, parent, renderDropIndicator);
1903
1960
  }
1961
+ };
1962
+ function $7135fc7d473fd974$var$useCollectionRender(collection, parent, renderDropIndicator) {
1963
+ return $e948873055cbafe4$export$727c8fc270210f13({
1964
+ items: parent ? collection.getChildren(parent.key) : collection,
1965
+ dependencies: [
1966
+ renderDropIndicator
1967
+ ],
1968
+ children(node) {
1969
+ let rendered = node.render(node);
1970
+ if (!renderDropIndicator || node.type !== "item") return rendered;
1971
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderDropIndicator({
1972
+ type: "item",
1973
+ key: node.key,
1974
+ dropPosition: "before"
1975
+ }), rendered, $7135fc7d473fd974$export$2dbbd341daed716d(collection, node, renderDropIndicator));
1976
+ }
1977
+ });
1904
1978
  }
1905
- function $c5a24bc478652b5f$export$8c434b3a7a4dad6(collection, a, b) {
1906
- if (a.parentKey === b.parentKey) return a.index - b.index;
1907
- let aAncestors = [
1908
- ...$c5a24bc478652b5f$var$getAncestors(collection, a),
1909
- a
1910
- ];
1911
- let bAncestors = [
1912
- ...$c5a24bc478652b5f$var$getAncestors(collection, b),
1913
- b
1914
- ];
1915
- let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a2, i) => a2 !== bAncestors[i]);
1916
- if (firstNonMatchingAncestor !== -1) {
1917
- a = aAncestors[firstNonMatchingAncestor];
1918
- b = bAncestors[firstNonMatchingAncestor];
1919
- return a.index - b.index;
1979
+ function $7135fc7d473fd974$export$2dbbd341daed716d(collection, node, renderDropIndicator) {
1980
+ let key = node.key;
1981
+ let keyAfter = collection.getKeyAfter(key);
1982
+ let nextItemInFlattenedCollection = keyAfter != null ? collection.getItem(keyAfter) : null;
1983
+ while (nextItemInFlattenedCollection != null && nextItemInFlattenedCollection.type !== "item") {
1984
+ keyAfter = collection.getKeyAfter(nextItemInFlattenedCollection.key);
1985
+ nextItemInFlattenedCollection = keyAfter != null ? collection.getItem(keyAfter) : null;
1920
1986
  }
1921
- if (aAncestors.findIndex((node) => node === b) >= 0) return 1;
1922
- else if (bAncestors.findIndex((node) => node === a) >= 0) return -1;
1923
- return -1;
1924
- }
1925
- function $c5a24bc478652b5f$var$getAncestors(collection, node) {
1926
- let parents = [];
1927
- let currNode = node;
1928
- while ((currNode === null || currNode === void 0 ? void 0 : currNode.parentKey) != null) {
1929
- currNode = collection.getItem(currNode.parentKey);
1930
- if (currNode) parents.unshift(currNode);
1987
+ let nextItemInSameLevel = node.nextKey != null ? collection.getItem(node.nextKey) : null;
1988
+ while (nextItemInSameLevel != null && nextItemInSameLevel.type !== "item") nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
1989
+ let afterIndicators = [];
1990
+ if (nextItemInSameLevel == null) {
1991
+ let current = node;
1992
+ while (current && (!nextItemInFlattenedCollection || current.parentKey !== nextItemInFlattenedCollection.parentKey && nextItemInFlattenedCollection.level < current.level)) {
1993
+ let indicator = renderDropIndicator({
1994
+ type: "item",
1995
+ key: current.key,
1996
+ dropPosition: "after"
1997
+ });
1998
+ if (/* @__PURE__ */ isValidElement(indicator)) afterIndicators.push(/* @__PURE__ */ cloneElement(indicator, {
1999
+ key: `${current.key}-after`
2000
+ }));
2001
+ current = current.parentKey != null ? collection.getItem(current.parentKey) : null;
2002
+ }
1931
2003
  }
1932
- return parents;
2004
+ return afterIndicators;
2005
+ }
2006
+ const $7135fc7d473fd974$export$4feb769f8ddf26c5 = /* @__PURE__ */ createContext($7135fc7d473fd974$export$a164736487e3f0ae);
2007
+ function $7135fc7d473fd974$export$90e00781bc59d8f9(focusedKey) {
2008
+ return useMemo(() => focusedKey != null ? /* @__PURE__ */ new Set([
2009
+ focusedKey
2010
+ ]) : null, [
2011
+ focusedKey
2012
+ ]);
1933
2013
  }
1934
2014
  class $e40ea825a81a3709$export$52baac22726c72bf extends Set {
1935
2015
  constructor(keys, anchorKey, currentKey) {
@@ -2329,92 +2409,36 @@ class $d496c0a20b6e58ec$export$6c8a5aaad13c9852 {
2329
2409
  this.layoutDelegate = (options === null || options === void 0 ? void 0 : options.layoutDelegate) || null;
2330
2410
  }
2331
2411
  }
2332
- const $7135fc7d473fd974$export$d40e14dec8b060a8 = /* @__PURE__ */ createContext(null);
2333
- const $7135fc7d473fd974$export$a164736487e3f0ae = {
2334
- CollectionRoot({ collection, renderDropIndicator }) {
2335
- return $7135fc7d473fd974$var$useCollectionRender(collection, null, renderDropIndicator);
2336
- },
2337
- CollectionBranch({ collection, parent, renderDropIndicator }) {
2338
- return $7135fc7d473fd974$var$useCollectionRender(collection, parent, renderDropIndicator);
2339
- }
2340
- };
2341
- function $7135fc7d473fd974$var$useCollectionRender(collection, parent, renderDropIndicator) {
2342
- return $e948873055cbafe4$export$727c8fc270210f13({
2343
- items: parent ? collection.getChildren(parent.key) : collection,
2344
- dependencies: [
2345
- renderDropIndicator
2346
- ],
2347
- children(node) {
2348
- let rendered = node.render(node);
2349
- if (!renderDropIndicator || node.type !== "item") return rendered;
2350
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderDropIndicator({
2351
- type: "item",
2352
- key: node.key,
2353
- dropPosition: "before"
2354
- }), rendered, $7135fc7d473fd974$export$2dbbd341daed716d(collection, node, renderDropIndicator));
2355
- }
2356
- });
2357
- }
2358
- function $7135fc7d473fd974$export$2dbbd341daed716d(collection, node, renderDropIndicator) {
2359
- let key = node.key;
2360
- let keyAfter = collection.getKeyAfter(key);
2361
- let nextItemInFlattenedCollection = keyAfter != null ? collection.getItem(keyAfter) : null;
2362
- while (nextItemInFlattenedCollection != null && nextItemInFlattenedCollection.type !== "item") {
2363
- keyAfter = collection.getKeyAfter(nextItemInFlattenedCollection.key);
2364
- nextItemInFlattenedCollection = keyAfter != null ? collection.getItem(keyAfter) : null;
2365
- }
2366
- let nextItemInSameLevel = node.nextKey != null ? collection.getItem(node.nextKey) : null;
2367
- while (nextItemInSameLevel != null && nextItemInSameLevel.type !== "item") nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
2368
- let afterIndicators = [];
2369
- if (nextItemInSameLevel == null) {
2370
- let current = node;
2371
- while (current && (!nextItemInFlattenedCollection || current.parentKey !== nextItemInFlattenedCollection.parentKey && nextItemInFlattenedCollection.level < current.level)) {
2372
- let indicator = renderDropIndicator({
2373
- type: "item",
2374
- key: current.key,
2375
- dropPosition: "after"
2376
- });
2377
- if (/* @__PURE__ */ isValidElement(indicator)) afterIndicators.push(/* @__PURE__ */ cloneElement(indicator, {
2378
- key: `${current.key}-after`
2379
- }));
2380
- current = current.parentKey != null ? collection.getItem(current.parentKey) : null;
2381
- }
2382
- }
2383
- return afterIndicators;
2384
- }
2385
- const $7135fc7d473fd974$export$4feb769f8ddf26c5 = /* @__PURE__ */ createContext($7135fc7d473fd974$export$a164736487e3f0ae);
2386
- function $7135fc7d473fd974$export$90e00781bc59d8f9(focusedKey) {
2387
- return useMemo(() => focusedKey != null ? /* @__PURE__ */ new Set([
2388
- focusedKey
2389
- ]) : null, [
2390
- focusedKey
2391
- ]);
2392
- }
2393
2412
  export {
2394
2413
  $7af3f5b51489e0b5$export$253fe78d46329472 as $,
2414
+ $55f9b1ae81f22853$export$759df0d867455a91 as A,
2415
+ $8a26561d2877236e$export$c24ed0104d07eab9 as B,
2416
+ $e1995378a142960e$export$e953bb1cd0f19726 as C,
2417
+ $23b9f4fcf0fe224b$export$437f11dc9b403b78 as D,
2395
2418
  $7613b1592d41b092$export$6cd28814d92fa9c9 as a,
2396
2419
  $d496c0a20b6e58ec$export$6c8a5aaad13c9852 as b,
2397
2420
  $880e95eb8b93ba9a$export$ecf600387e221c37 as c,
2398
2421
  $e1995378a142960e$export$18af5c7a9e9b3664 as d,
2399
2422
  $e1995378a142960e$export$bf788dd355e3a401 as e,
2400
2423
  $e1995378a142960e$export$fb8073518f34e6ec as f,
2401
- $7135fc7d473fd974$export$4feb769f8ddf26c5 as g,
2402
- $7135fc7d473fd974$export$d40e14dec8b060a8 as h,
2403
- $ae20dd8cbca75726$export$d6daf82dcd84e87c as i,
2404
- $7135fc7d473fd974$export$a164736487e3f0ae as j,
2405
- $7135fc7d473fd974$export$90e00781bc59d8f9 as k,
2406
- $fb3050f43d946246$export$e32c88dfddc6e1d8 as l,
2407
- $c5a24bc478652b5f$export$1005530eda016c13 as m,
2408
- $55f9b1ae81f22853$export$2b35b76d2e30e129 as n,
2409
- $ef06256079686ba0$export$f8aeda7b10753fa1 as o,
2410
- $cc38e7bd3fc7b213$export$2bb74740c4e19def as p,
2411
- $feb5ffebff200149$export$c3d8340acf92597f as q,
2412
- $5671b20cf9b562b2$export$831c820ad60f9d12 as r,
2413
- $55f9b1ae81f22853$export$76e4e37e5339496d as s,
2414
- $5671b20cf9b562b2$export$447a38995de2c711 as t,
2415
- $55f9b1ae81f22853$export$6c5dc7e81d2cc29a as u,
2416
- $21f1aa98acb08317$export$16792effe837dba3 as v,
2417
- $55f9b1ae81f22853$export$759df0d867455a91 as w,
2418
- $8a26561d2877236e$export$c24ed0104d07eab9 as x,
2419
- $e1995378a142960e$export$e953bb1cd0f19726 as y
2424
+ $23b9f4fcf0fe224b$export$fd11f34e1d07f134 as g,
2425
+ $7135fc7d473fd974$export$4feb769f8ddf26c5 as h,
2426
+ $7135fc7d473fd974$export$d40e14dec8b060a8 as i,
2427
+ $23b9f4fcf0fe224b$export$8258a0665a675899 as j,
2428
+ $ae20dd8cbca75726$export$d6daf82dcd84e87c as k,
2429
+ $7135fc7d473fd974$export$a164736487e3f0ae as l,
2430
+ $23b9f4fcf0fe224b$export$d68d59712b04d9d1 as m,
2431
+ $7135fc7d473fd974$export$90e00781bc59d8f9 as n,
2432
+ $cc38e7bd3fc7b213$export$2bb74740c4e19def as o,
2433
+ $feb5ffebff200149$export$c3d8340acf92597f as p,
2434
+ $c5a24bc478652b5f$export$1005530eda016c13 as q,
2435
+ $23b9f4fcf0fe224b$export$5ae2504e948afce5 as r,
2436
+ $fb3050f43d946246$export$e32c88dfddc6e1d8 as s,
2437
+ $55f9b1ae81f22853$export$2b35b76d2e30e129 as t,
2438
+ $ef06256079686ba0$export$f8aeda7b10753fa1 as u,
2439
+ $5671b20cf9b562b2$export$831c820ad60f9d12 as v,
2440
+ $55f9b1ae81f22853$export$76e4e37e5339496d as w,
2441
+ $5671b20cf9b562b2$export$447a38995de2c711 as x,
2442
+ $55f9b1ae81f22853$export$6c5dc7e81d2cc29a as y,
2443
+ $21f1aa98acb08317$export$16792effe837dba3 as z
2420
2444
  };