@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.23 → 6.2.3-dev.25

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 (88) hide show
  1. package/dist/browser/assets/{entry-4ObkElbc.js → entry-GDzXcBs1.js} +10 -6
  2. package/dist/browser/assets/{projection-entry-4FDMlGcp.js → projection-entry-BJpyPvov.js} +7 -13
  3. package/dist/browser/{documents-C-lAnv6o.js → documents-CRzouuNR.js} +45 -35
  4. package/dist/browser/{documents-C-lAnv6o.js.map → documents-CRzouuNR.js.map} +1 -1
  5. package/dist/browser/{editor-DNV-46lY.js → editor-CYdXmSpt.js} +2 -3
  6. package/dist/browser/{editor-DNV-46lY.js.map → editor-CYdXmSpt.js.map} +1 -1
  7. package/dist/browser/{editor-CQ4wUFK5.js → editor-Dk_HEgr2.js} +943 -66
  8. package/dist/browser/editor-Dk_HEgr2.js.map +1 -0
  9. package/dist/browser/editors/document-model-editor/module.js +1 -1
  10. package/dist/browser/editors/document-model-editor/module.js.map +1 -1
  11. package/dist/browser/editors/generic-drive-explorer/index.js +68 -57
  12. package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
  13. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  14. package/dist/browser/editors/generic-drive-explorer/module.js.map +1 -1
  15. package/dist/browser/{src-CVV6HzQZ-D-OQvEkh.js → folder-view-DjGlA0kT.js} +901 -1643
  16. package/dist/browser/folder-view-DjGlA0kT.js.map +1 -0
  17. package/dist/browser/{graphql-editor-DoXZvdNr.js → graphql-editor-C9Nc_cOY.js} +97 -85
  18. package/dist/browser/graphql-editor-C9Nc_cOY.js.map +1 -0
  19. package/dist/{node/hooks-Di3FASx-.mjs → browser/hooks-eQxBX7g4.js} +824 -444
  20. package/dist/browser/{hooks-Bh1JCohS.js.map → hooks-eQxBX7g4.js.map} +1 -1
  21. package/dist/browser/index.js +16 -14
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/browser/{json-editor-DBhkG5TF.js → json-editor-DfRD-pfk.js} +7 -7
  24. package/dist/browser/{json-editor-DBhkG5TF.js.map → json-editor-DfRD-pfk.js.map} +1 -1
  25. package/dist/browser/{parser-BBzK7bLd.js → parser-DtbeHA3H.js} +7 -6
  26. package/dist/browser/{parser-BBzK7bLd.js.map → parser-DtbeHA3H.js.map} +1 -1
  27. package/dist/browser/{chunk-BVTlhY3a.js → rolldown-runtime-DC62tzP2.js} +12 -3
  28. package/dist/browser/src-CrUksCLW-Co0PBoNN.js +5255 -0
  29. package/dist/browser/src-CrUksCLW-Co0PBoNN.js.map +1 -0
  30. package/dist/browser/{state-schemas-B47wHvDV.js → state-schemas-BSc_36Vd.js} +12 -10
  31. package/dist/browser/{state-schemas-B47wHvDV.js.map → state-schemas-BSc_36Vd.js.map} +1 -1
  32. package/dist/browser/{tslib.es6-CeIASJ2O.js → tslib.es6-Cno80yFJ.js} +1 -1
  33. package/dist/browser/{tslib.es6-CeIASJ2O.js.map → tslib.es6-Cno80yFJ.js.map} +1 -1
  34. package/dist/node/{documents-XAQfHX5Q.mjs → documents-D70S9PZL.mjs} +2 -2
  35. package/dist/node/documents-D70S9PZL.mjs.map +1 -0
  36. package/dist/node/{editor-Cp2TC5MJ.mjs → editor-BZZ0eN3p.mjs} +2 -3
  37. package/dist/node/{editor-Cp2TC5MJ.mjs.map → editor-BZZ0eN3p.mjs.map} +1 -1
  38. package/dist/node/{editor-BiiLqEe9.mjs → editor-CeSEXEgf.mjs} +866 -68
  39. package/dist/node/editor-CeSEXEgf.mjs.map +1 -0
  40. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  41. package/dist/node/editors/document-model-editor/module.mjs.map +1 -1
  42. package/dist/node/editors/generic-drive-explorer/index.mjs +19 -13
  43. package/dist/node/editors/generic-drive-explorer/index.mjs.map +1 -1
  44. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  45. package/dist/node/editors/generic-drive-explorer/module.mjs.map +1 -1
  46. package/dist/node/{src-CVV6HzQZ-CvqjXbXk.mjs → folder-view-B2Jo-wsr.mjs} +891 -2311
  47. package/dist/node/{src-CVV6HzQZ-CvqjXbXk.mjs.map → folder-view-B2Jo-wsr.mjs.map} +1 -1
  48. package/dist/node/{graphql-BvV3tC1U.mjs → graphql-Dp4j7rmx.mjs} +50 -49
  49. package/dist/node/{graphql-BvV3tC1U.mjs.map → graphql-Dp4j7rmx.mjs.map} +1 -1
  50. package/dist/node/{graphql-editor-BhF6KN6y.mjs → graphql-editor-CBJXEY_C.mjs} +76 -61
  51. package/dist/node/graphql-editor-CBJXEY_C.mjs.map +1 -0
  52. package/dist/{browser/hooks-Bh1JCohS.js → node/hooks-C2b46djt.mjs} +824 -444
  53. package/dist/node/{hooks-Di3FASx-.mjs.map → hooks-C2b46djt.mjs.map} +1 -1
  54. package/dist/node/index.mjs +16 -15
  55. package/dist/node/index.mjs.map +1 -1
  56. package/dist/node/{json-editor-Cqc0zuz0.mjs → json-editor-DaqHARBD.mjs} +7 -7
  57. package/dist/node/{json-editor-Cqc0zuz0.mjs.map → json-editor-DaqHARBD.mjs.map} +1 -1
  58. package/dist/node/{schema-context-mHmP3Cl6.mjs → schema-context-CojjnSE6.mjs} +6 -5
  59. package/dist/node/schema-context-CojjnSE6.mjs.map +1 -0
  60. package/dist/node/src-CrUksCLW-BHpiSprT.mjs +5936 -0
  61. package/dist/node/src-CrUksCLW-BHpiSprT.mjs.map +1 -0
  62. package/dist/node/{state-schemas-DXG02fMh.mjs → state-schemas-CWuLjYFF.mjs} +13 -10
  63. package/dist/node/{state-schemas-DXG02fMh.mjs.map → state-schemas-CWuLjYFF.mjs.map} +1 -1
  64. package/dist/node/{tslib.es6-DdiHgz9e.mjs → tslib.es6-VORZjfk3.mjs} +45 -7
  65. package/dist/node/{tslib.es6-DdiHgz9e.mjs.map → tslib.es6-VORZjfk3.mjs.map} +1 -1
  66. package/package.json +11 -10
  67. package/dist/browser/button-sZQCXeCo.js +0 -803
  68. package/dist/browser/button-sZQCXeCo.js.map +0 -1
  69. package/dist/browser/dist-D3_ER0Dn.js +0 -2314
  70. package/dist/browser/dist-D3_ER0Dn.js.map +0 -1
  71. package/dist/browser/editor-CQ4wUFK5.js.map +0 -1
  72. package/dist/browser/folder-view-CzItU0hn.js +0 -957
  73. package/dist/browser/folder-view-CzItU0hn.js.map +0 -1
  74. package/dist/browser/graphql-editor-DoXZvdNr.js.map +0 -1
  75. package/dist/browser/schema-context-p2bhyog_.js +0 -69
  76. package/dist/browser/schema-context-p2bhyog_.js.map +0 -1
  77. package/dist/browser/src-CVV6HzQZ-D-OQvEkh.js.map +0 -1
  78. package/dist/node/button-5bnYEAVq.mjs +0 -785
  79. package/dist/node/button-5bnYEAVq.mjs.map +0 -1
  80. package/dist/node/chunk-17FXJ3dL.mjs +0 -31
  81. package/dist/node/dist-Bf_PIbO7.mjs +0 -2314
  82. package/dist/node/dist-Bf_PIbO7.mjs.map +0 -1
  83. package/dist/node/documents-XAQfHX5Q.mjs.map +0 -1
  84. package/dist/node/editor-BiiLqEe9.mjs.map +0 -1
  85. package/dist/node/folder-view-m_rH84Nz.mjs +0 -962
  86. package/dist/node/folder-view-m_rH84Nz.mjs.map +0 -1
  87. package/dist/node/graphql-editor-BhF6KN6y.mjs.map +0 -1
  88. package/dist/node/schema-context-mHmP3Cl6.mjs.map +0 -1
@@ -1,10 +1,11 @@
1
- import { n as __rest, r as __spreadArray, t as __assign } from "./tslib.es6-CeIASJ2O.js";
2
- import { a as dispatchDiscreteCustomEvent, c as useLayoutEffect2, d as composeRefs, f as useComposedRefs, h as twMerge, i as Primitive$1, l as createContext2, m as twJoin, n as useId$1, o as createSlot$1, p as composeEventHandlers, r as useCallbackRef$1, s as useControllableState, t as Presence, u as createContextScope } from "./dist-D3_ER0Dn.js";
1
+ import { h as twMerge, n as PowerhouseButton, r as useWindowSize } from "./src-CrUksCLW-Co0PBoNN.js";
3
2
  import * as React$1 from "react";
4
- import { Suspense, forwardRef, useEffect, useState } from "react";
3
+ import React, { Suspense, useRef, useState } from "react";
5
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import ReactDOM from "react-dom";
7
- //#region ../design-system/dist/Removed-CO_5C1ce.js
5
+ import { flushSync } from "react-dom";
6
+ import { CreateDocumentWithTypeModal, FileItem, FolderItem } from "@powerhousedao/design-system/connect";
7
+ import { addDocument, isFileNodeKind, isFolderNodeKind, preloadEditorModule, setSelectedNode, useAllowedDocumentModelModules, useDisabledEditors, useEditorModules, useNodesInSelectedDriveOrFolder, useParentFolderForSelectedNode, useSelectedDriveSafe, useSelectedFolder, useStudioMode, useUserPermissions } from "@powerhousedao/reactor-browser";
8
+ //#region ../design-system/dist/Removed-OP4eTrAN.js
8
9
  function Created(props) {
9
10
  return /* @__PURE__ */ jsxs("svg", {
10
11
  ...props,
@@ -168,7 +169,7 @@ function Removed(props) {
168
169
  });
169
170
  }
170
171
  //#endregion
171
- //#region ../design-system/dist/Tabler-FjvVqX5a.js
172
+ //#region ../design-system/dist/Tabler-rjLxlzUV.js
172
173
  function CrossCircle(props) {
173
174
  return /* @__PURE__ */ jsxs("svg", {
174
175
  ...props,
@@ -225,7 +226,7 @@ function Tabler(props) {
225
226
  });
226
227
  }
227
228
  //#endregion
228
- //#region ../design-system/dist/icon-C4QOpsdI.js
229
+ //#region ../design-system/dist/icon-01W_S_9A.js
229
230
  function AnalyticsProcessorModule(props) {
230
231
  return /* @__PURE__ */ jsxs("svg", {
231
232
  ...props,
@@ -3448,1704 +3449,961 @@ function Icon({ name, size = 24, color, style, ...props }) {
3448
3449
  });
3449
3450
  }
3450
3451
  //#endregion
3451
- //#region ../../node_modules/.pnpm/@radix-ui+react-use-escape-keydown@1.1.1_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs
3452
- function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
3453
- const onEscapeKeyDown = useCallbackRef$1(onEscapeKeyDownProp);
3454
- React$1.useEffect(() => {
3455
- const handleKeyDown = (event) => {
3456
- if (event.key === "Escape") onEscapeKeyDown(event);
3457
- };
3458
- ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
3459
- return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
3460
- }, [onEscapeKeyDown, ownerDocument]);
3452
+ //#region editors/generic-drive-explorer/utils/select-creatable-modules.ts
3453
+ /**
3454
+ * The modules a user may pick from when creating a new document. Outside
3455
+ * studio mode only the latest version of each document type is offered: new
3456
+ * documents should never start on an outdated schema. Builders testing
3457
+ * migrations run in studio mode and still get every version.
3458
+ */
3459
+ function selectCreatableModules(modules, studioMode) {
3460
+ if (studioMode) return [...modules];
3461
+ const latestByType = /* @__PURE__ */ new Map();
3462
+ for (const module of modules) {
3463
+ const id = module.documentModel.global.id;
3464
+ const current = latestByType.get(id);
3465
+ if (!current || (module.version ?? 1) > (current.version ?? 1)) latestByType.set(id, module);
3466
+ }
3467
+ return [...latestByType.values()];
3461
3468
  }
3462
3469
  //#endregion
3463
- //#region ../../node_modules/.pnpm/@radix-ui+react-dismissable-layer@1.1.11_@types+react-dom@19.2.3_@types+react@19.2.14___9e4771d0900293d89694eff7a0933149/node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
3464
- var DISMISSABLE_LAYER_NAME = "DismissableLayer";
3465
- var CONTEXT_UPDATE = "dismissableLayer.update";
3466
- var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
3467
- var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
3468
- var originalBodyPointerEvents;
3469
- var DismissableLayerContext = React$1.createContext({
3470
- layers: /* @__PURE__ */ new Set(),
3471
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
3472
- branches: /* @__PURE__ */ new Set()
3473
- });
3474
- var DismissableLayer = React$1.forwardRef((props, forwardedRef) => {
3475
- const { disableOutsidePointerEvents = false, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, ...layerProps } = props;
3476
- const context = React$1.useContext(DismissableLayerContext);
3477
- const [node, setNode] = React$1.useState(null);
3478
- const ownerDocument = node?.ownerDocument ?? globalThis?.document;
3479
- const [, force] = React$1.useState({});
3480
- const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
3481
- const layers = Array.from(context.layers);
3482
- const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
3483
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
3484
- const index = node ? layers.indexOf(node) : -1;
3485
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
3486
- const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
3487
- const pointerDownOutside = usePointerDownOutside((event) => {
3488
- const target = event.target;
3489
- const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
3490
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
3491
- onPointerDownOutside?.(event);
3492
- onInteractOutside?.(event);
3493
- if (!event.defaultPrevented) onDismiss?.();
3494
- }, ownerDocument);
3495
- const focusOutside = useFocusOutside((event) => {
3496
- const target = event.target;
3497
- if ([...context.branches].some((branch) => branch.contains(target))) return;
3498
- onFocusOutside?.(event);
3499
- onInteractOutside?.(event);
3500
- if (!event.defaultPrevented) onDismiss?.();
3501
- }, ownerDocument);
3502
- useEscapeKeydown((event) => {
3503
- if (!(index === context.layers.size - 1)) return;
3504
- onEscapeKeyDown?.(event);
3505
- if (!event.defaultPrevented && onDismiss) {
3506
- event.preventDefault();
3507
- onDismiss();
3508
- }
3509
- }, ownerDocument);
3510
- React$1.useEffect(() => {
3511
- if (!node) return;
3512
- if (disableOutsidePointerEvents) {
3513
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
3514
- originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
3515
- ownerDocument.body.style.pointerEvents = "none";
3516
- }
3517
- context.layersWithOutsidePointerEventsDisabled.add(node);
3518
- }
3519
- context.layers.add(node);
3520
- dispatchUpdate();
3521
- return () => {
3522
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
3523
- };
3524
- }, [
3525
- node,
3526
- ownerDocument,
3527
- disableOutsidePointerEvents,
3528
- context
3529
- ]);
3530
- React$1.useEffect(() => {
3531
- return () => {
3532
- if (!node) return;
3533
- context.layers.delete(node);
3534
- context.layersWithOutsidePointerEventsDisabled.delete(node);
3535
- dispatchUpdate();
3536
- };
3537
- }, [node, context]);
3538
- React$1.useEffect(() => {
3539
- const handleUpdate = () => force({});
3540
- document.addEventListener(CONTEXT_UPDATE, handleUpdate);
3541
- return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
3542
- }, []);
3543
- return /* @__PURE__ */ jsx(Primitive$1.div, {
3544
- ...layerProps,
3545
- ref: composedRefs,
3546
- style: {
3547
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
3548
- ...props.style
3549
- },
3550
- onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
3551
- onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
3552
- onPointerDownCapture: composeEventHandlers(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture)
3553
- });
3554
- });
3555
- DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
3556
- var BRANCH_NAME = "DismissableLayerBranch";
3557
- var DismissableLayerBranch = React$1.forwardRef((props, forwardedRef) => {
3558
- const context = React$1.useContext(DismissableLayerContext);
3559
- const ref = React$1.useRef(null);
3560
- const composedRefs = useComposedRefs(forwardedRef, ref);
3561
- React$1.useEffect(() => {
3562
- const node = ref.current;
3563
- if (node) {
3564
- context.branches.add(node);
3565
- return () => {
3566
- context.branches.delete(node);
3567
- };
3568
- }
3569
- }, [context.branches]);
3570
- return /* @__PURE__ */ jsx(Primitive$1.div, {
3571
- ...props,
3572
- ref: composedRefs
3573
- });
3574
- });
3575
- DismissableLayerBranch.displayName = BRANCH_NAME;
3576
- function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
3577
- const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
3578
- const isPointerInsideReactTreeRef = React$1.useRef(false);
3579
- const handleClickRef = React$1.useRef(() => {});
3580
- React$1.useEffect(() => {
3581
- const handlePointerDown = (event) => {
3582
- if (event.target && !isPointerInsideReactTreeRef.current) {
3583
- let handleAndDispatchPointerDownOutsideEvent2 = function() {
3584
- handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, { discrete: true });
3585
- };
3586
- const eventDetail = { originalEvent: event };
3587
- if (event.pointerType === "touch") {
3588
- ownerDocument.removeEventListener("click", handleClickRef.current);
3589
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
3590
- ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
3591
- } else handleAndDispatchPointerDownOutsideEvent2();
3592
- } else ownerDocument.removeEventListener("click", handleClickRef.current);
3593
- isPointerInsideReactTreeRef.current = false;
3594
- };
3595
- const timerId = window.setTimeout(() => {
3596
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
3597
- }, 0);
3598
- return () => {
3599
- window.clearTimeout(timerId);
3600
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
3601
- ownerDocument.removeEventListener("click", handleClickRef.current);
3602
- };
3603
- }, [ownerDocument, handlePointerDownOutside]);
3604
- return { onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true };
3605
- }
3606
- function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
3607
- const handleFocusOutside = useCallbackRef$1(onFocusOutside);
3608
- const isFocusInsideReactTreeRef = React$1.useRef(false);
3609
- React$1.useEffect(() => {
3610
- const handleFocus = (event) => {
3611
- if (event.target && !isFocusInsideReactTreeRef.current) handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, { originalEvent: event }, { discrete: false });
3612
- };
3613
- ownerDocument.addEventListener("focusin", handleFocus);
3614
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
3615
- }, [ownerDocument, handleFocusOutside]);
3470
+ //#region editors/generic-drive-explorer/components/create-document.tsx
3471
+ function toDocumentTypeOption(doc, studioMode) {
3472
+ const spec = doc.documentModel.global;
3616
3473
  return {
3617
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
3618
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
3474
+ documentType: spec.id,
3475
+ name: spec.name,
3476
+ version: studioMode ? doc.version : void 0,
3477
+ description: spec.description
3619
3478
  };
3620
3479
  }
3621
- function dispatchUpdate() {
3622
- const event = new CustomEvent(CONTEXT_UPDATE);
3623
- document.dispatchEvent(event);
3624
- }
3625
- function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
3626
- const target = detail.originalEvent.target;
3627
- const event = new CustomEvent(name, {
3628
- bubbles: false,
3629
- cancelable: true,
3630
- detail
3631
- });
3632
- if (handler) target.addEventListener(name, handler, { once: true });
3633
- if (discrete) dispatchDiscreteCustomEvent(target, event);
3634
- else target.dispatchEvent(event);
3635
- }
3636
- //#endregion
3637
- //#region ../../node_modules/.pnpm/@radix-ui+react-focus-guards@1.1.3_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-focus-guards/dist/index.mjs
3638
- var count = 0;
3639
- function useFocusGuards() {
3640
- React$1.useEffect(() => {
3641
- const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
3642
- document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
3643
- document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
3644
- count++;
3645
- return () => {
3646
- if (count === 1) document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
3647
- count--;
3648
- };
3649
- }, []);
3650
- }
3651
- function createFocusGuard() {
3652
- const element = document.createElement("span");
3653
- element.setAttribute("data-radix-focus-guard", "");
3654
- element.tabIndex = 0;
3655
- element.style.outline = "none";
3656
- element.style.opacity = "0";
3657
- element.style.position = "fixed";
3658
- element.style.pointerEvents = "none";
3659
- return element;
3480
+ function CreateDocument() {
3481
+ const [showModal, setShowModal] = useState(false);
3482
+ const { isAllowedToCreateDocuments } = useUserPermissions();
3483
+ const allowedDocumentModelModules = useAllowedDocumentModelModules();
3484
+ const editorModules = useEditorModules();
3485
+ const disabledEditors = useDisabledEditors() ?? [];
3486
+ const [selectedDrive] = useSelectedDriveSafe();
3487
+ const selectedFolder = useSelectedFolder();
3488
+ const parentFolder = useParentFolderForSelectedNode();
3489
+ const DRIVE_CONTAINER_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
3490
+ const studioMode = useStudioMode() ?? false;
3491
+ const visibleDocumentModelModules = selectCreatableModules(allowedDocumentModelModules ?? [], studioMode).filter((module) => {
3492
+ const id = module.documentModel.global.id;
3493
+ return !DRIVE_CONTAINER_TYPES.includes(id) && !disabledEditors.includes(id);
3494
+ });
3495
+ const preloadEditorsForType = (documentType) => editorModules?.filter((editorModule) => editorModule.documentTypes.includes(documentType)).forEach((editorModule) => {
3496
+ preloadEditorModule(editorModule);
3497
+ });
3498
+ const handleCreate = async ({ name, documentType, version }) => {
3499
+ setShowModal(false);
3500
+ if (!selectedDrive) return;
3501
+ try {
3502
+ const node = await addDocument(selectedDrive.header.id, name, documentType, selectedFolder?.id ?? parentFolder?.id, void 0, void 0, void 0, version);
3503
+ setSelectedNode(node);
3504
+ } catch (error) {
3505
+ console.error("Failed to create document:", error);
3506
+ }
3507
+ };
3508
+ if (!isAllowedToCreateDocuments) return null;
3509
+ if (!visibleDocumentModelModules.length) return null;
3510
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(PowerhouseButton, {
3511
+ className: "py-2",
3512
+ color: "blue",
3513
+ icon: /* @__PURE__ */ jsx(Icon, {
3514
+ name: "Plus",
3515
+ size: 14
3516
+ }),
3517
+ onClick: () => setShowModal(true),
3518
+ size: "small",
3519
+ children: "Create New Document"
3520
+ }), /* @__PURE__ */ jsx(CreateDocumentWithTypeModal, {
3521
+ documentTypes: visibleDocumentModelModules.map((module) => toDocumentTypeOption(module, studioMode)),
3522
+ onCreate: (input) => void handleCreate(input),
3523
+ onOpenChange: setShowModal,
3524
+ onTypeSelected: preloadEditorsForType,
3525
+ open: showModal
3526
+ })] });
3660
3527
  }
3661
3528
  //#endregion
3662
- //#region ../../node_modules/.pnpm/@radix-ui+react-focus-scope@1.1.7_@types+react-dom@19.2.3_@types+react@19.2.14__@types+_c6061abe6ab403e0e04cce9bd67455fb/node_modules/@radix-ui/react-focus-scope/dist/index.mjs
3663
- var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
3664
- var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
3665
- var EVENT_OPTIONS = {
3666
- bubbles: false,
3667
- cancelable: true
3668
- };
3669
- var FOCUS_SCOPE_NAME = "FocusScope";
3670
- var FocusScope = React$1.forwardRef((props, forwardedRef) => {
3671
- const { loop = false, trapped = false, onMountAutoFocus: onMountAutoFocusProp, onUnmountAutoFocus: onUnmountAutoFocusProp, ...scopeProps } = props;
3672
- const [container, setContainer] = React$1.useState(null);
3673
- const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
3674
- const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
3675
- const lastFocusedElementRef = React$1.useRef(null);
3676
- const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
3677
- const focusScope = React$1.useRef({
3678
- paused: false,
3679
- pause() {
3680
- this.paused = true;
3681
- },
3682
- resume() {
3683
- this.paused = false;
3684
- }
3685
- }).current;
3686
- React$1.useEffect(() => {
3687
- if (trapped) {
3688
- let handleFocusIn2 = function(event) {
3689
- if (focusScope.paused || !container) return;
3690
- const target = event.target;
3691
- if (container.contains(target)) lastFocusedElementRef.current = target;
3692
- else focus(lastFocusedElementRef.current, { select: true });
3693
- }, handleFocusOut2 = function(event) {
3694
- if (focusScope.paused || !container) return;
3695
- const relatedTarget = event.relatedTarget;
3696
- if (relatedTarget === null) return;
3697
- if (!container.contains(relatedTarget)) focus(lastFocusedElementRef.current, { select: true });
3698
- }, handleMutations2 = function(mutations) {
3699
- if (document.activeElement !== document.body) return;
3700
- for (const mutation of mutations) if (mutation.removedNodes.length > 0) focus(container);
3701
- };
3702
- document.addEventListener("focusin", handleFocusIn2);
3703
- document.addEventListener("focusout", handleFocusOut2);
3704
- const mutationObserver = new MutationObserver(handleMutations2);
3705
- if (container) mutationObserver.observe(container, {
3706
- childList: true,
3707
- subtree: true
3708
- });
3709
- return () => {
3710
- document.removeEventListener("focusin", handleFocusIn2);
3711
- document.removeEventListener("focusout", handleFocusOut2);
3712
- mutationObserver.disconnect();
3713
- };
3714
- }
3715
- }, [
3716
- trapped,
3717
- container,
3718
- focusScope.paused
3719
- ]);
3720
- React$1.useEffect(() => {
3721
- if (container) {
3722
- focusScopesStack.add(focusScope);
3723
- const previouslyFocusedElement = document.activeElement;
3724
- if (!container.contains(previouslyFocusedElement)) {
3725
- const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
3726
- container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
3727
- container.dispatchEvent(mountEvent);
3728
- if (!mountEvent.defaultPrevented) {
3729
- focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
3730
- if (document.activeElement === previouslyFocusedElement) focus(container);
3731
- }
3732
- }
3733
- return () => {
3734
- container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
3735
- setTimeout(() => {
3736
- const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
3737
- container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
3738
- container.dispatchEvent(unmountEvent);
3739
- if (!unmountEvent.defaultPrevented) focus(previouslyFocusedElement ?? document.body, { select: true });
3740
- container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
3741
- focusScopesStack.remove(focusScope);
3742
- }, 0);
3529
+ //#region ../../node_modules/.pnpm/@tanstack+virtual-core@3.13.19/node_modules/@tanstack/virtual-core/dist/esm/utils.js
3530
+ function memo$1(getDeps, fn, opts) {
3531
+ let deps = opts.initialDeps ?? [];
3532
+ let result;
3533
+ let isInitial = true;
3534
+ function memoizedFunction() {
3535
+ var _a, _b, _c;
3536
+ let depTime;
3537
+ if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
3538
+ const newDeps = getDeps();
3539
+ if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep))) return result;
3540
+ deps = newDeps;
3541
+ let resultTime;
3542
+ if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
3543
+ result = fn(...newDeps);
3544
+ if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) {
3545
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
3546
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
3547
+ const resultFpsPercentage = resultEndTime / 16;
3548
+ const pad = (str, num) => {
3549
+ str = String(str);
3550
+ while (str.length < num) str = " " + str;
3551
+ return str;
3743
3552
  };
3553
+ console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
3554
+ font-size: .6rem;
3555
+ font-weight: bold;
3556
+ color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
3744
3557
  }
3745
- }, [
3746
- container,
3747
- onMountAutoFocus,
3748
- onUnmountAutoFocus,
3749
- focusScope
3750
- ]);
3751
- const handleKeyDown = React$1.useCallback((event) => {
3752
- if (!loop && !trapped) return;
3753
- if (focusScope.paused) return;
3754
- const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
3755
- const focusedElement = document.activeElement;
3756
- if (isTabKey && focusedElement) {
3757
- const container2 = event.currentTarget;
3758
- const [first, last] = getTabbableEdges(container2);
3759
- if (!(first && last)) {
3760
- if (focusedElement === container2) event.preventDefault();
3761
- } else if (!event.shiftKey && focusedElement === last) {
3762
- event.preventDefault();
3763
- if (loop) focus(first, { select: true });
3764
- } else if (event.shiftKey && focusedElement === first) {
3765
- event.preventDefault();
3766
- if (loop) focus(last, { select: true });
3767
- }
3768
- }
3769
- }, [
3770
- loop,
3771
- trapped,
3772
- focusScope.paused
3773
- ]);
3774
- return /* @__PURE__ */ jsx(Primitive$1.div, {
3775
- tabIndex: -1,
3776
- ...scopeProps,
3777
- ref: composedRefs,
3778
- onKeyDown: handleKeyDown
3779
- });
3780
- });
3781
- FocusScope.displayName = FOCUS_SCOPE_NAME;
3782
- function focusFirst(candidates, { select = false } = {}) {
3783
- const previouslyFocusedElement = document.activeElement;
3784
- for (const candidate of candidates) {
3785
- focus(candidate, { select });
3786
- if (document.activeElement !== previouslyFocusedElement) return;
3558
+ if ((opts == null ? void 0 : opts.onChange) && !(isInitial && opts.skipInitialOnChange)) opts.onChange(result);
3559
+ isInitial = false;
3560
+ return result;
3787
3561
  }
3788
- }
3789
- function getTabbableEdges(container) {
3790
- const candidates = getTabbableCandidates(container);
3791
- return [findVisible(candidates, container), findVisible(candidates.reverse(), container)];
3792
- }
3793
- function getTabbableCandidates(container) {
3794
- const nodes = [];
3795
- const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, { acceptNode: (node) => {
3796
- const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
3797
- if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
3798
- return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
3799
- } });
3800
- while (walker.nextNode()) nodes.push(walker.currentNode);
3801
- return nodes;
3802
- }
3803
- function findVisible(elements, container) {
3804
- for (const element of elements) if (!isHidden(element, { upTo: container })) return element;
3805
- }
3806
- function isHidden(node, { upTo }) {
3807
- if (getComputedStyle(node).visibility === "hidden") return true;
3808
- while (node) {
3809
- if (upTo !== void 0 && node === upTo) return false;
3810
- if (getComputedStyle(node).display === "none") return true;
3811
- node = node.parentElement;
3812
- }
3813
- return false;
3814
- }
3815
- function isSelectableInput(element) {
3816
- return element instanceof HTMLInputElement && "select" in element;
3817
- }
3818
- function focus(element, { select = false } = {}) {
3819
- if (element && element.focus) {
3820
- const previouslyFocusedElement = document.activeElement;
3821
- element.focus({ preventScroll: true });
3822
- if (element !== previouslyFocusedElement && isSelectableInput(element) && select) element.select();
3823
- }
3824
- }
3825
- var focusScopesStack = createFocusScopesStack();
3826
- function createFocusScopesStack() {
3827
- let stack = [];
3828
- return {
3829
- add(focusScope) {
3830
- const activeFocusScope = stack[0];
3831
- if (focusScope !== activeFocusScope) activeFocusScope?.pause();
3832
- stack = arrayRemove(stack, focusScope);
3833
- stack.unshift(focusScope);
3834
- },
3835
- remove(focusScope) {
3836
- stack = arrayRemove(stack, focusScope);
3837
- stack[0]?.resume();
3838
- }
3562
+ memoizedFunction.updateDeps = (newDeps) => {
3563
+ deps = newDeps;
3564
+ };
3565
+ return memoizedFunction;
3566
+ }
3567
+ function notUndefined(value, msg) {
3568
+ if (value === void 0) throw new Error(`Unexpected undefined${msg ? `: ${msg}` : ""}`);
3569
+ else return value;
3570
+ }
3571
+ const approxEqual = (a, b) => Math.abs(a - b) < 1.01;
3572
+ const debounce = (targetWindow, fn, ms) => {
3573
+ let timeoutId;
3574
+ return function(...args) {
3575
+ targetWindow.clearTimeout(timeoutId);
3576
+ timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms);
3839
3577
  };
3840
- }
3841
- function arrayRemove(array, item) {
3842
- const updatedArray = [...array];
3843
- const index = updatedArray.indexOf(item);
3844
- if (index !== -1) updatedArray.splice(index, 1);
3845
- return updatedArray;
3846
- }
3847
- function removeLinks(items) {
3848
- return items.filter((item) => item.tagName !== "A");
3849
- }
3850
- //#endregion
3851
- //#region ../../node_modules/.pnpm/@radix-ui+react-portal@1.1.9_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react_266ca67294f168fbf2e025541d323e69/node_modules/@radix-ui/react-portal/dist/index.mjs
3852
- var PORTAL_NAME$1 = "Portal";
3853
- var Portal$1 = React$1.forwardRef((props, forwardedRef) => {
3854
- const { container: containerProp, ...portalProps } = props;
3855
- const [mounted, setMounted] = React$1.useState(false);
3856
- useLayoutEffect2(() => setMounted(true), []);
3857
- const container = containerProp || mounted && globalThis?.document?.body;
3858
- return container ? ReactDOM.createPortal(/* @__PURE__ */ jsx(Primitive$1.div, {
3859
- ...portalProps,
3860
- ref: forwardedRef
3861
- }), container) : null;
3862
- });
3863
- Portal$1.displayName = PORTAL_NAME$1;
3864
- //#endregion
3865
- //#region ../../node_modules/.pnpm/aria-hidden@1.2.6/node_modules/aria-hidden/dist/es2015/index.js
3866
- var getDefaultParent = function(originalTarget) {
3867
- if (typeof document === "undefined") return null;
3868
- return (Array.isArray(originalTarget) ? originalTarget[0] : originalTarget).ownerDocument.body;
3869
3578
  };
3870
- var counterMap = /* @__PURE__ */ new WeakMap();
3871
- var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
3872
- var markerMap = {};
3873
- var lockCount = 0;
3874
- var unwrapHost = function(node) {
3875
- return node && (node.host || unwrapHost(node.parentNode));
3579
+ //#endregion
3580
+ //#region ../../node_modules/.pnpm/@tanstack+virtual-core@3.13.19/node_modules/@tanstack/virtual-core/dist/esm/index.js
3581
+ const getRect = (element) => {
3582
+ const { offsetWidth, offsetHeight } = element;
3583
+ return {
3584
+ width: offsetWidth,
3585
+ height: offsetHeight
3586
+ };
3876
3587
  };
3877
- var correctTargets = function(parent, targets) {
3878
- return targets.map(function(target) {
3879
- if (parent.contains(target)) return target;
3880
- var correctedTarget = unwrapHost(target);
3881
- if (correctedTarget && parent.contains(correctedTarget)) return correctedTarget;
3882
- console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
3883
- return null;
3884
- }).filter(function(x) {
3885
- return Boolean(x);
3886
- });
3588
+ const defaultKeyExtractor = (index) => index;
3589
+ const defaultRangeExtractor = (range) => {
3590
+ const start = Math.max(range.startIndex - range.overscan, 0);
3591
+ const end = Math.min(range.endIndex + range.overscan, range.count - 1);
3592
+ const arr = [];
3593
+ for (let i = start; i <= end; i++) arr.push(i);
3594
+ return arr;
3887
3595
  };
3888
- /**
3889
- * Marks everything except given node(or nodes) as aria-hidden
3890
- * @param {Element | Element[]} originalTarget - elements to keep on the page
3891
- * @param [parentNode] - top element, defaults to document.body
3892
- * @param {String} [markerName] - a special attribute to mark every node
3893
- * @param {String} [controlAttribute] - html Attribute to control
3894
- * @return {Undo} undo command
3895
- */
3896
- var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
3897
- var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
3898
- if (!markerMap[markerName]) markerMap[markerName] = /* @__PURE__ */ new WeakMap();
3899
- var markerCounter = markerMap[markerName];
3900
- var hiddenNodes = [];
3901
- var elementsToKeep = /* @__PURE__ */ new Set();
3902
- var elementsToStop = new Set(targets);
3903
- var keep = function(el) {
3904
- if (!el || elementsToKeep.has(el)) return;
3905
- elementsToKeep.add(el);
3906
- keep(el.parentNode);
3907
- };
3908
- targets.forEach(keep);
3909
- var deep = function(parent) {
3910
- if (!parent || elementsToStop.has(parent)) return;
3911
- Array.prototype.forEach.call(parent.children, function(node) {
3912
- if (elementsToKeep.has(node)) deep(node);
3913
- else try {
3914
- var attr = node.getAttribute(controlAttribute);
3915
- var alreadyHidden = attr !== null && attr !== "false";
3916
- var counterValue = (counterMap.get(node) || 0) + 1;
3917
- var markerValue = (markerCounter.get(node) || 0) + 1;
3918
- counterMap.set(node, counterValue);
3919
- markerCounter.set(node, markerValue);
3920
- hiddenNodes.push(node);
3921
- if (counterValue === 1 && alreadyHidden) uncontrolledNodes.set(node, true);
3922
- if (markerValue === 1) node.setAttribute(markerName, "true");
3923
- if (!alreadyHidden) node.setAttribute(controlAttribute, "true");
3924
- } catch (e) {
3925
- console.error("aria-hidden: cannot operate on ", node, e);
3926
- }
3596
+ const observeElementRect = (instance, cb) => {
3597
+ const element = instance.scrollElement;
3598
+ if (!element) return;
3599
+ const targetWindow = instance.targetWindow;
3600
+ if (!targetWindow) return;
3601
+ const handler = (rect) => {
3602
+ const { width, height } = rect;
3603
+ cb({
3604
+ width: Math.round(width),
3605
+ height: Math.round(height)
3927
3606
  });
3928
3607
  };
3929
- deep(parentNode);
3930
- elementsToKeep.clear();
3931
- lockCount++;
3932
- return function() {
3933
- hiddenNodes.forEach(function(node) {
3934
- var counterValue = counterMap.get(node) - 1;
3935
- var markerValue = markerCounter.get(node) - 1;
3936
- counterMap.set(node, counterValue);
3937
- markerCounter.set(node, markerValue);
3938
- if (!counterValue) {
3939
- if (!uncontrolledNodes.has(node)) node.removeAttribute(controlAttribute);
3940
- uncontrolledNodes.delete(node);
3608
+ handler(getRect(element));
3609
+ if (!targetWindow.ResizeObserver) return () => {};
3610
+ const observer = new targetWindow.ResizeObserver((entries) => {
3611
+ const run = () => {
3612
+ const entry = entries[0];
3613
+ if (entry == null ? void 0 : entry.borderBoxSize) {
3614
+ const box = entry.borderBoxSize[0];
3615
+ if (box) {
3616
+ handler({
3617
+ width: box.inlineSize,
3618
+ height: box.blockSize
3619
+ });
3620
+ return;
3621
+ }
3941
3622
  }
3942
- if (!markerValue) node.removeAttribute(markerName);
3943
- });
3944
- lockCount--;
3945
- if (!lockCount) {
3946
- counterMap = /* @__PURE__ */ new WeakMap();
3947
- counterMap = /* @__PURE__ */ new WeakMap();
3948
- uncontrolledNodes = /* @__PURE__ */ new WeakMap();
3949
- markerMap = {};
3950
- }
3623
+ handler(getRect(element));
3624
+ };
3625
+ instance.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
3626
+ });
3627
+ observer.observe(element, { box: "border-box" });
3628
+ return () => {
3629
+ observer.unobserve(element);
3951
3630
  };
3952
3631
  };
3953
- /**
3954
- * Marks everything except given node(or nodes) as aria-hidden
3955
- * @param {Element | Element[]} originalTarget - elements to keep on the page
3956
- * @param [parentNode] - top element, defaults to document.body
3957
- * @param {String} [markerName] - a special attribute to mark every node
3958
- * @return {Undo} undo command
3959
- */
3960
- var hideOthers = function(originalTarget, parentNode, markerName) {
3961
- if (markerName === void 0) markerName = "data-aria-hidden";
3962
- var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
3963
- var activeParentNode = parentNode || getDefaultParent(originalTarget);
3964
- if (!activeParentNode) return function() {
3965
- return null;
3632
+ const addEventListenerOptions = { passive: true };
3633
+ const supportsScrollend = typeof window == "undefined" ? true : "onscrollend" in window;
3634
+ const observeElementOffset = (instance, cb) => {
3635
+ const element = instance.scrollElement;
3636
+ if (!element) return;
3637
+ const targetWindow = instance.targetWindow;
3638
+ if (!targetWindow) return;
3639
+ let offset = 0;
3640
+ const fallback = instance.options.useScrollendEvent && supportsScrollend ? () => void 0 : debounce(targetWindow, () => {
3641
+ cb(offset, false);
3642
+ }, instance.options.isScrollingResetDelay);
3643
+ const createHandler = (isScrolling) => () => {
3644
+ const { horizontal, isRtl } = instance.options;
3645
+ offset = horizontal ? element["scrollLeft"] * (isRtl && -1 || 1) : element["scrollTop"];
3646
+ fallback();
3647
+ cb(offset, isScrolling);
3648
+ };
3649
+ const handler = createHandler(true);
3650
+ const endHandler = createHandler(false);
3651
+ element.addEventListener("scroll", handler, addEventListenerOptions);
3652
+ const registerScrollendEvent = instance.options.useScrollendEvent && supportsScrollend;
3653
+ if (registerScrollendEvent) element.addEventListener("scrollend", endHandler, addEventListenerOptions);
3654
+ return () => {
3655
+ element.removeEventListener("scroll", handler);
3656
+ if (registerScrollendEvent) element.removeEventListener("scrollend", endHandler);
3966
3657
  };
3967
- targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
3968
- return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
3969
3658
  };
3970
- //#endregion
3971
- //#region ../../node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll-bar/dist/es2015/constants.js
3972
- var zeroRightClassName = "right-scroll-bar-position";
3973
- var fullWidthClassName = "width-before-scroll-bar";
3974
- var noScrollbarsClassName = "with-scroll-bars-hidden";
3975
- /**
3976
- * Name of a CSS variable containing the amount of "hidden" scrollbar
3977
- * ! might be undefined ! use will fallback!
3978
- */
3979
- var removedBarSizeVariable = "--removed-body-scroll-bar-size";
3980
- //#endregion
3981
- //#region ../../node_modules/.pnpm/use-callback-ref@1.3.3_@types+react@19.2.14_react@19.2.6/node_modules/use-callback-ref/dist/es2015/assignRef.js
3982
- /**
3983
- * Assigns a value for a given ref, no matter of the ref format
3984
- * @param {RefObject} ref - a callback function or ref object
3985
- * @param value - a new value
3986
- *
3987
- * @see https://github.com/theKashey/use-callback-ref#assignref
3988
- * @example
3989
- * const refObject = useRef();
3990
- * const refFn = (ref) => {....}
3991
- *
3992
- * assignRef(refObject, "refValue");
3993
- * assignRef(refFn, "refValue");
3994
- */
3995
- function assignRef(ref, value) {
3996
- if (typeof ref === "function") ref(value);
3997
- else if (ref) ref.current = value;
3998
- return ref;
3999
- }
4000
- //#endregion
4001
- //#region ../../node_modules/.pnpm/use-callback-ref@1.3.3_@types+react@19.2.14_react@19.2.6/node_modules/use-callback-ref/dist/es2015/useRef.js
4002
- /**
4003
- * creates a MutableRef with ref change callback
4004
- * @param initialValue - initial ref value
4005
- * @param {Function} callback - a callback to run when value changes
4006
- *
4007
- * @example
4008
- * const ref = useCallbackRef(0, (newValue, oldValue) => console.log(oldValue, '->', newValue);
4009
- * ref.current = 1;
4010
- * // prints 0 -> 1
4011
- *
4012
- * @see https://reactjs.org/docs/hooks-reference.html#useref
4013
- * @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
4014
- * @returns {MutableRefObject}
4015
- */
4016
- function useCallbackRef(initialValue, callback) {
4017
- var ref = useState(function() {
4018
- return {
4019
- value: initialValue,
4020
- callback,
4021
- facade: {
4022
- get current() {
4023
- return ref.value;
4024
- },
4025
- set current(value) {
4026
- var last = ref.value;
4027
- if (last !== value) {
4028
- ref.value = value;
4029
- ref.callback(value, last);
4030
- }
4031
- }
4032
- }
4033
- };
4034
- })[0];
4035
- ref.callback = callback;
4036
- return ref.facade;
4037
- }
4038
- //#endregion
4039
- //#region ../../node_modules/.pnpm/use-callback-ref@1.3.3_@types+react@19.2.14_react@19.2.6/node_modules/use-callback-ref/dist/es2015/useMergeRef.js
4040
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React$1.useLayoutEffect : React$1.useEffect;
4041
- var currentValues = /* @__PURE__ */ new WeakMap();
4042
- /**
4043
- * Merges two or more refs together providing a single interface to set their value
4044
- * @param {RefObject|Ref} refs
4045
- * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
4046
- *
4047
- * @see {@link mergeRefs} a version without buit-in memoization
4048
- * @see https://github.com/theKashey/use-callback-ref#usemergerefs
4049
- * @example
4050
- * const Component = React.forwardRef((props, ref) => {
4051
- * const ownRef = useRef();
4052
- * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
4053
- * return <div ref={domRef}>...</div>
4054
- * }
4055
- */
4056
- function useMergeRefs(refs, defaultValue) {
4057
- var callbackRef = useCallbackRef(defaultValue || null, function(newValue) {
4058
- return refs.forEach(function(ref) {
4059
- return assignRef(ref, newValue);
4060
- });
3659
+ const measureElement = (element, entry, instance) => {
3660
+ if (entry == null ? void 0 : entry.borderBoxSize) {
3661
+ const box = entry.borderBoxSize[0];
3662
+ if (box) return Math.round(box[instance.options.horizontal ? "inlineSize" : "blockSize"]);
3663
+ }
3664
+ return element[instance.options.horizontal ? "offsetWidth" : "offsetHeight"];
3665
+ };
3666
+ const elementScroll = (offset, { adjustments = 0, behavior }, instance) => {
3667
+ var _a, _b;
3668
+ const toOffset = offset + adjustments;
3669
+ (_b = (_a = instance.scrollElement) == null ? void 0 : _a.scrollTo) == null || _b.call(_a, {
3670
+ [instance.options.horizontal ? "left" : "top"]: toOffset,
3671
+ behavior
4061
3672
  });
4062
- useIsomorphicLayoutEffect(function() {
4063
- var oldValue = currentValues.get(callbackRef);
4064
- if (oldValue) {
4065
- var prevRefs_1 = new Set(oldValue);
4066
- var nextRefs_1 = new Set(refs);
4067
- var current_1 = callbackRef.current;
4068
- prevRefs_1.forEach(function(ref) {
4069
- if (!nextRefs_1.has(ref)) assignRef(ref, null);
4070
- });
4071
- nextRefs_1.forEach(function(ref) {
4072
- if (!prevRefs_1.has(ref)) assignRef(ref, current_1);
4073
- });
4074
- }
4075
- currentValues.set(callbackRef, refs);
4076
- }, [refs]);
4077
- return callbackRef;
4078
- }
4079
- //#endregion
4080
- //#region ../../node_modules/.pnpm/use-sidecar@1.1.3_@types+react@19.2.14_react@19.2.6/node_modules/use-sidecar/dist/es2015/medium.js
4081
- function ItoI(a) {
4082
- return a;
4083
- }
4084
- function innerCreateMedium(defaults, middleware) {
4085
- if (middleware === void 0) middleware = ItoI;
4086
- var buffer = [];
4087
- var assigned = false;
4088
- return {
4089
- read: function() {
4090
- if (assigned) throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
4091
- if (buffer.length) return buffer[buffer.length - 1];
4092
- return defaults;
4093
- },
4094
- useMedium: function(data) {
4095
- var item = middleware(data, assigned);
4096
- buffer.push(item);
4097
- return function() {
4098
- buffer = buffer.filter(function(x) {
4099
- return x !== item;
3673
+ };
3674
+ var Virtualizer = class {
3675
+ constructor(opts) {
3676
+ this.unsubs = [];
3677
+ this.scrollElement = null;
3678
+ this.targetWindow = null;
3679
+ this.isScrolling = false;
3680
+ this.currentScrollToIndex = null;
3681
+ this.measurementsCache = [];
3682
+ this.itemSizeCache = /* @__PURE__ */ new Map();
3683
+ this.laneAssignments = /* @__PURE__ */ new Map();
3684
+ this.pendingMeasuredCacheIndexes = [];
3685
+ this.prevLanes = void 0;
3686
+ this.lanesChangedFlag = false;
3687
+ this.lanesSettling = false;
3688
+ this.scrollRect = null;
3689
+ this.scrollOffset = null;
3690
+ this.scrollDirection = null;
3691
+ this.scrollAdjustments = 0;
3692
+ this.elementsCache = /* @__PURE__ */ new Map();
3693
+ this.observer = /* @__PURE__ */ (() => {
3694
+ let _ro = null;
3695
+ const get = () => {
3696
+ if (_ro) return _ro;
3697
+ if (!this.targetWindow || !this.targetWindow.ResizeObserver) return null;
3698
+ return _ro = new this.targetWindow.ResizeObserver((entries) => {
3699
+ entries.forEach((entry) => {
3700
+ const run = () => {
3701
+ this._measureElement(entry.target, entry);
3702
+ };
3703
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(run) : run();
3704
+ });
4100
3705
  });
4101
3706
  };
4102
- },
4103
- assignSyncMedium: function(cb) {
4104
- assigned = true;
4105
- while (buffer.length) {
4106
- var cbs = buffer;
4107
- buffer = [];
4108
- cbs.forEach(cb);
4109
- }
4110
- buffer = {
4111
- push: function(x) {
4112
- return cb(x);
3707
+ return {
3708
+ disconnect: () => {
3709
+ var _a;
3710
+ (_a = get()) == null || _a.disconnect();
3711
+ _ro = null;
4113
3712
  },
4114
- filter: function() {
4115
- return buffer;
3713
+ observe: (target) => {
3714
+ var _a;
3715
+ return (_a = get()) == null ? void 0 : _a.observe(target, { box: "border-box" });
3716
+ },
3717
+ unobserve: (target) => {
3718
+ var _a;
3719
+ return (_a = get()) == null ? void 0 : _a.unobserve(target);
4116
3720
  }
4117
3721
  };
4118
- },
4119
- assignMedium: function(cb) {
4120
- assigned = true;
4121
- var pendingQueue = [];
4122
- if (buffer.length) {
4123
- var cbs = buffer;
4124
- buffer = [];
4125
- cbs.forEach(cb);
4126
- pendingQueue = buffer;
4127
- }
4128
- var executeQueue = function() {
4129
- var cbs = pendingQueue;
4130
- pendingQueue = [];
4131
- cbs.forEach(cb);
3722
+ })();
3723
+ this.range = null;
3724
+ this.setOptions = (opts2) => {
3725
+ Object.entries(opts2).forEach(([key, value]) => {
3726
+ if (typeof value === "undefined") delete opts2[key];
3727
+ });
3728
+ this.options = {
3729
+ debug: false,
3730
+ initialOffset: 0,
3731
+ overscan: 1,
3732
+ paddingStart: 0,
3733
+ paddingEnd: 0,
3734
+ scrollPaddingStart: 0,
3735
+ scrollPaddingEnd: 0,
3736
+ horizontal: false,
3737
+ getItemKey: defaultKeyExtractor,
3738
+ rangeExtractor: defaultRangeExtractor,
3739
+ onChange: () => {},
3740
+ measureElement,
3741
+ initialRect: {
3742
+ width: 0,
3743
+ height: 0
3744
+ },
3745
+ scrollMargin: 0,
3746
+ gap: 0,
3747
+ indexAttribute: "data-index",
3748
+ initialMeasurementsCache: [],
3749
+ lanes: 1,
3750
+ isScrollingResetDelay: 150,
3751
+ enabled: true,
3752
+ isRtl: false,
3753
+ useScrollendEvent: false,
3754
+ useAnimationFrameWithResizeObserver: false,
3755
+ ...opts2
4132
3756
  };
4133
- var cycle = function() {
4134
- return Promise.resolve().then(executeQueue);
3757
+ };
3758
+ this.notify = (sync) => {
3759
+ var _a, _b;
3760
+ (_b = (_a = this.options).onChange) == null || _b.call(_a, this, sync);
3761
+ };
3762
+ this.maybeNotify = memo$1(() => {
3763
+ this.calculateRange();
3764
+ return [
3765
+ this.isScrolling,
3766
+ this.range ? this.range.startIndex : null,
3767
+ this.range ? this.range.endIndex : null
3768
+ ];
3769
+ }, (isScrolling) => {
3770
+ this.notify(isScrolling);
3771
+ }, {
3772
+ key: "maybeNotify",
3773
+ debug: () => this.options.debug,
3774
+ initialDeps: [
3775
+ this.isScrolling,
3776
+ this.range ? this.range.startIndex : null,
3777
+ this.range ? this.range.endIndex : null
3778
+ ]
3779
+ });
3780
+ this.cleanup = () => {
3781
+ this.unsubs.filter(Boolean).forEach((d) => d());
3782
+ this.unsubs = [];
3783
+ this.observer.disconnect();
3784
+ this.scrollElement = null;
3785
+ this.targetWindow = null;
3786
+ };
3787
+ this._didMount = () => {
3788
+ return () => {
3789
+ this.cleanup();
4135
3790
  };
4136
- cycle();
4137
- buffer = {
4138
- push: function(x) {
4139
- pendingQueue.push(x);
4140
- cycle();
4141
- },
4142
- filter: function(filter) {
4143
- pendingQueue = pendingQueue.filter(filter);
4144
- return buffer;
3791
+ };
3792
+ this._willUpdate = () => {
3793
+ var _a;
3794
+ const scrollElement = this.options.enabled ? this.options.getScrollElement() : null;
3795
+ if (this.scrollElement !== scrollElement) {
3796
+ this.cleanup();
3797
+ if (!scrollElement) {
3798
+ this.maybeNotify();
3799
+ return;
4145
3800
  }
3801
+ this.scrollElement = scrollElement;
3802
+ if (this.scrollElement && "ownerDocument" in this.scrollElement) this.targetWindow = this.scrollElement.ownerDocument.defaultView;
3803
+ else this.targetWindow = ((_a = this.scrollElement) == null ? void 0 : _a.window) ?? null;
3804
+ this.elementsCache.forEach((cached) => {
3805
+ this.observer.observe(cached);
3806
+ });
3807
+ this.unsubs.push(this.options.observeElementRect(this, (rect) => {
3808
+ this.scrollRect = rect;
3809
+ this.maybeNotify();
3810
+ }));
3811
+ this.unsubs.push(this.options.observeElementOffset(this, (offset, isScrolling) => {
3812
+ this.scrollAdjustments = 0;
3813
+ this.scrollDirection = isScrolling ? this.getScrollOffset() < offset ? "forward" : "backward" : null;
3814
+ this.scrollOffset = offset;
3815
+ this.isScrolling = isScrolling;
3816
+ this.maybeNotify();
3817
+ }));
3818
+ this._scrollToOffset(this.getScrollOffset(), {
3819
+ adjustments: void 0,
3820
+ behavior: void 0
3821
+ });
3822
+ }
3823
+ };
3824
+ this.getSize = () => {
3825
+ if (!this.options.enabled) {
3826
+ this.scrollRect = null;
3827
+ return 0;
3828
+ }
3829
+ this.scrollRect = this.scrollRect ?? this.options.initialRect;
3830
+ return this.scrollRect[this.options.horizontal ? "width" : "height"];
3831
+ };
3832
+ this.getScrollOffset = () => {
3833
+ if (!this.options.enabled) {
3834
+ this.scrollOffset = null;
3835
+ return 0;
3836
+ }
3837
+ this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset === "function" ? this.options.initialOffset() : this.options.initialOffset);
3838
+ return this.scrollOffset;
3839
+ };
3840
+ this.getFurthestMeasurement = (measurements, index) => {
3841
+ const furthestMeasurementsFound = /* @__PURE__ */ new Map();
3842
+ const furthestMeasurements = /* @__PURE__ */ new Map();
3843
+ for (let m = index - 1; m >= 0; m--) {
3844
+ const measurement = measurements[m];
3845
+ if (furthestMeasurementsFound.has(measurement.lane)) continue;
3846
+ const previousFurthestMeasurement = furthestMeasurements.get(measurement.lane);
3847
+ if (previousFurthestMeasurement == null || measurement.end > previousFurthestMeasurement.end) furthestMeasurements.set(measurement.lane, measurement);
3848
+ else if (measurement.end < previousFurthestMeasurement.end) furthestMeasurementsFound.set(measurement.lane, true);
3849
+ if (furthestMeasurementsFound.size === this.options.lanes) break;
3850
+ }
3851
+ return furthestMeasurements.size === this.options.lanes ? Array.from(furthestMeasurements.values()).sort((a, b) => {
3852
+ if (a.end === b.end) return a.index - b.index;
3853
+ return a.end - b.end;
3854
+ })[0] : void 0;
3855
+ };
3856
+ this.getMeasurementOptions = memo$1(() => [
3857
+ this.options.count,
3858
+ this.options.paddingStart,
3859
+ this.options.scrollMargin,
3860
+ this.options.getItemKey,
3861
+ this.options.enabled,
3862
+ this.options.lanes
3863
+ ], (count, paddingStart, scrollMargin, getItemKey, enabled, lanes) => {
3864
+ if (this.prevLanes !== void 0 && this.prevLanes !== lanes) this.lanesChangedFlag = true;
3865
+ this.prevLanes = lanes;
3866
+ this.pendingMeasuredCacheIndexes = [];
3867
+ return {
3868
+ count,
3869
+ paddingStart,
3870
+ scrollMargin,
3871
+ getItemKey,
3872
+ enabled,
3873
+ lanes
4146
3874
  };
4147
- }
4148
- };
4149
- }
4150
- function createSidecarMedium(options) {
4151
- if (options === void 0) options = {};
4152
- var medium = innerCreateMedium(null);
4153
- medium.options = __assign({
4154
- async: true,
4155
- ssr: false
4156
- }, options);
4157
- return medium;
4158
- }
4159
- //#endregion
4160
- //#region ../../node_modules/.pnpm/use-sidecar@1.1.3_@types+react@19.2.14_react@19.2.6/node_modules/use-sidecar/dist/es2015/exports.js
4161
- var SideCar = function(_a) {
4162
- var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
4163
- if (!sideCar) throw new Error("Sidecar: please provide `sideCar` property to import the right car");
4164
- var Target = sideCar.read();
4165
- if (!Target) throw new Error("Sidecar medium not found");
4166
- return React$1.createElement(Target, __assign({}, rest));
4167
- };
4168
- SideCar.isSideCarExport = true;
4169
- function exportSidecar(medium, exported) {
4170
- medium.useMedium(exported);
4171
- return SideCar;
4172
- }
4173
- //#endregion
4174
- //#region ../../node_modules/.pnpm/react-remove-scroll@2.7.2_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll/dist/es2015/medium.js
4175
- var effectCar = createSidecarMedium();
4176
- //#endregion
4177
- //#region ../../node_modules/.pnpm/react-remove-scroll@2.7.2_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll/dist/es2015/UI.js
4178
- var nothing = function() {};
4179
- /**
4180
- * Removes scrollbar from the page and contain the scroll within the Lock
4181
- */
4182
- var RemoveScroll = React$1.forwardRef(function(props, parentRef) {
4183
- var ref = React$1.useRef(null);
4184
- var _a = React$1.useState({
4185
- onScrollCapture: nothing,
4186
- onWheelCapture: nothing,
4187
- onTouchMoveCapture: nothing
4188
- }), callbacks = _a[0], setCallbacks = _a[1];
4189
- var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, [
4190
- "forwardProps",
4191
- "children",
4192
- "className",
4193
- "removeScrollBar",
4194
- "enabled",
4195
- "shards",
4196
- "sideCar",
4197
- "noRelative",
4198
- "noIsolation",
4199
- "inert",
4200
- "allowPinchZoom",
4201
- "as",
4202
- "gapMode"
4203
- ]);
4204
- var SideCar = sideCar;
4205
- var containerRef = useMergeRefs([ref, parentRef]);
4206
- var containerProps = __assign(__assign({}, rest), callbacks);
4207
- return React$1.createElement(React$1.Fragment, null, enabled && React$1.createElement(SideCar, {
4208
- sideCar: effectCar,
4209
- removeScrollBar,
4210
- shards,
4211
- noRelative,
4212
- noIsolation,
4213
- inert,
4214
- setCallbacks,
4215
- allowPinchZoom: !!allowPinchZoom,
4216
- lockRef: ref,
4217
- gapMode
4218
- }), forwardProps ? React$1.cloneElement(React$1.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React$1.createElement(Container, __assign({}, containerProps, {
4219
- className,
4220
- ref: containerRef
4221
- }), children));
4222
- });
4223
- RemoveScroll.defaultProps = {
4224
- enabled: true,
4225
- removeScrollBar: true,
4226
- inert: false
4227
- };
4228
- RemoveScroll.classNames = {
4229
- fullWidth: fullWidthClassName,
4230
- zeroRight: zeroRightClassName
4231
- };
4232
- //#endregion
4233
- //#region ../../node_modules/.pnpm/get-nonce@1.0.1/node_modules/get-nonce/dist/es2015/index.js
4234
- var currentNonce;
4235
- var getNonce = function() {
4236
- if (currentNonce) return currentNonce;
4237
- if (typeof __webpack_nonce__ !== "undefined") return __webpack_nonce__;
4238
- };
4239
- //#endregion
4240
- //#region ../../node_modules/.pnpm/react-style-singleton@2.2.3_@types+react@19.2.14_react@19.2.6/node_modules/react-style-singleton/dist/es2015/singleton.js
4241
- function makeStyleTag() {
4242
- if (!document) return null;
4243
- var tag = document.createElement("style");
4244
- tag.type = "text/css";
4245
- var nonce = getNonce();
4246
- if (nonce) tag.setAttribute("nonce", nonce);
4247
- return tag;
4248
- }
4249
- function injectStyles(tag, css) {
4250
- if (tag.styleSheet) tag.styleSheet.cssText = css;
4251
- else tag.appendChild(document.createTextNode(css));
4252
- }
4253
- function insertStyleTag(tag) {
4254
- (document.head || document.getElementsByTagName("head")[0]).appendChild(tag);
4255
- }
4256
- var stylesheetSingleton = function() {
4257
- var counter = 0;
4258
- var stylesheet = null;
4259
- return {
4260
- add: function(style) {
4261
- if (counter == 0) {
4262
- if (stylesheet = makeStyleTag()) {
4263
- injectStyles(stylesheet, style);
4264
- insertStyleTag(stylesheet);
3875
+ }, { key: false });
3876
+ this.getMeasurements = memo$1(() => [this.getMeasurementOptions(), this.itemSizeCache], ({ count, paddingStart, scrollMargin, getItemKey, enabled, lanes }, itemSizeCache) => {
3877
+ if (!enabled) {
3878
+ this.measurementsCache = [];
3879
+ this.itemSizeCache.clear();
3880
+ this.laneAssignments.clear();
3881
+ return [];
3882
+ }
3883
+ if (this.laneAssignments.size > count) {
3884
+ for (const index of this.laneAssignments.keys()) if (index >= count) this.laneAssignments.delete(index);
3885
+ }
3886
+ if (this.lanesChangedFlag) {
3887
+ this.lanesChangedFlag = false;
3888
+ this.lanesSettling = true;
3889
+ this.measurementsCache = [];
3890
+ this.itemSizeCache.clear();
3891
+ this.laneAssignments.clear();
3892
+ this.pendingMeasuredCacheIndexes = [];
3893
+ }
3894
+ if (this.measurementsCache.length === 0 && !this.lanesSettling) {
3895
+ this.measurementsCache = this.options.initialMeasurementsCache;
3896
+ this.measurementsCache.forEach((item) => {
3897
+ this.itemSizeCache.set(item.key, item.size);
3898
+ });
3899
+ }
3900
+ const min = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
3901
+ this.pendingMeasuredCacheIndexes = [];
3902
+ if (this.lanesSettling && this.measurementsCache.length === count) this.lanesSettling = false;
3903
+ const measurements = this.measurementsCache.slice(0, min);
3904
+ const laneLastIndex = new Array(lanes).fill(void 0);
3905
+ for (let m = 0; m < min; m++) {
3906
+ const item = measurements[m];
3907
+ if (item) laneLastIndex[item.lane] = m;
3908
+ }
3909
+ for (let i = min; i < count; i++) {
3910
+ const key = getItemKey(i);
3911
+ const cachedLane = this.laneAssignments.get(i);
3912
+ let lane;
3913
+ let start;
3914
+ if (cachedLane !== void 0 && this.options.lanes > 1) {
3915
+ lane = cachedLane;
3916
+ const prevIndex = laneLastIndex[lane];
3917
+ const prevInLane = prevIndex !== void 0 ? measurements[prevIndex] : void 0;
3918
+ start = prevInLane ? prevInLane.end + this.options.gap : paddingStart + scrollMargin;
3919
+ } else {
3920
+ const furthestMeasurement = this.options.lanes === 1 ? measurements[i - 1] : this.getFurthestMeasurement(measurements, i);
3921
+ start = furthestMeasurement ? furthestMeasurement.end + this.options.gap : paddingStart + scrollMargin;
3922
+ lane = furthestMeasurement ? furthestMeasurement.lane : i % this.options.lanes;
3923
+ if (this.options.lanes > 1) this.laneAssignments.set(i, lane);
4265
3924
  }
3925
+ const measuredSize = itemSizeCache.get(key);
3926
+ const size = typeof measuredSize === "number" ? measuredSize : this.options.estimateSize(i);
3927
+ const end = start + size;
3928
+ measurements[i] = {
3929
+ index: i,
3930
+ start,
3931
+ size,
3932
+ end,
3933
+ key,
3934
+ lane
3935
+ };
3936
+ laneLastIndex[lane] = i;
4266
3937
  }
4267
- counter++;
4268
- },
4269
- remove: function() {
4270
- counter--;
4271
- if (!counter && stylesheet) {
4272
- stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
4273
- stylesheet = null;
3938
+ this.measurementsCache = measurements;
3939
+ return measurements;
3940
+ }, {
3941
+ key: "getMeasurements",
3942
+ debug: () => this.options.debug
3943
+ });
3944
+ this.calculateRange = memo$1(() => [
3945
+ this.getMeasurements(),
3946
+ this.getSize(),
3947
+ this.getScrollOffset(),
3948
+ this.options.lanes
3949
+ ], (measurements, outerSize, scrollOffset, lanes) => {
3950
+ return this.range = measurements.length > 0 && outerSize > 0 ? calculateRange({
3951
+ measurements,
3952
+ outerSize,
3953
+ scrollOffset,
3954
+ lanes
3955
+ }) : null;
3956
+ }, {
3957
+ key: "calculateRange",
3958
+ debug: () => this.options.debug
3959
+ });
3960
+ this.getVirtualIndexes = memo$1(() => {
3961
+ let startIndex = null;
3962
+ let endIndex = null;
3963
+ const range = this.calculateRange();
3964
+ if (range) {
3965
+ startIndex = range.startIndex;
3966
+ endIndex = range.endIndex;
4274
3967
  }
4275
- }
4276
- };
4277
- };
4278
- //#endregion
4279
- //#region ../../node_modules/.pnpm/react-style-singleton@2.2.3_@types+react@19.2.14_react@19.2.6/node_modules/react-style-singleton/dist/es2015/hook.js
4280
- /**
4281
- * creates a hook to control style singleton
4282
- * @see {@link styleSingleton} for a safer component version
4283
- * @example
4284
- * ```tsx
4285
- * const useStyle = styleHookSingleton();
4286
- * ///
4287
- * useStyle('body { overflow: hidden}');
4288
- */
4289
- var styleHookSingleton = function() {
4290
- var sheet = stylesheetSingleton();
4291
- return function(styles, isDynamic) {
4292
- React$1.useEffect(function() {
4293
- sheet.add(styles);
4294
- return function() {
4295
- sheet.remove();
4296
- };
4297
- }, [styles && isDynamic]);
4298
- };
4299
- };
4300
- //#endregion
4301
- //#region ../../node_modules/.pnpm/react-style-singleton@2.2.3_@types+react@19.2.14_react@19.2.6/node_modules/react-style-singleton/dist/es2015/component.js
4302
- /**
4303
- * create a Component to add styles on demand
4304
- * - styles are added when first instance is mounted
4305
- * - styles are removed when the last instance is unmounted
4306
- * - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
4307
- */
4308
- var styleSingleton = function() {
4309
- var useStyle = styleHookSingleton();
4310
- var Sheet = function(_a) {
4311
- var styles = _a.styles, dynamic = _a.dynamic;
4312
- useStyle(styles, dynamic);
4313
- return null;
4314
- };
4315
- return Sheet;
4316
- };
4317
- //#endregion
4318
- //#region ../../node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll-bar/dist/es2015/utils.js
4319
- var zeroGap = {
4320
- left: 0,
4321
- top: 0,
4322
- right: 0,
4323
- gap: 0
4324
- };
4325
- var parse = function(x) {
4326
- return parseInt(x || "", 10) || 0;
4327
- };
4328
- var getOffset = function(gapMode) {
4329
- var cs = window.getComputedStyle(document.body);
4330
- var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
4331
- var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
4332
- var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
4333
- return [
4334
- parse(left),
4335
- parse(top),
4336
- parse(right)
4337
- ];
4338
- };
4339
- var getGapWidth = function(gapMode) {
4340
- if (gapMode === void 0) gapMode = "margin";
4341
- if (typeof window === "undefined") return zeroGap;
4342
- var offsets = getOffset(gapMode);
4343
- var documentWidth = document.documentElement.clientWidth;
4344
- var windowWidth = window.innerWidth;
4345
- return {
4346
- left: offsets[0],
4347
- top: offsets[1],
4348
- right: offsets[2],
4349
- gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
4350
- };
4351
- };
4352
- //#endregion
4353
- //#region ../../node_modules/.pnpm/react-remove-scroll-bar@2.3.8_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll-bar/dist/es2015/component.js
4354
- var Style = styleSingleton();
4355
- var lockAttribute = "data-scroll-locked";
4356
- var getStyles = function(_a, allowRelative, gapMode, important) {
4357
- var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
4358
- if (gapMode === void 0) gapMode = "margin";
4359
- return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
4360
- allowRelative && "position: relative ".concat(important, ";"),
4361
- gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
4362
- gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
4363
- ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
4364
- };
4365
- var getCurrentUseCounter = function() {
4366
- var counter = parseInt(document.body.getAttribute("data-scroll-locked") || "0", 10);
4367
- return isFinite(counter) ? counter : 0;
4368
- };
4369
- var useLockAttribute = function() {
4370
- React$1.useEffect(function() {
4371
- document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
4372
- return function() {
4373
- var newCounter = getCurrentUseCounter() - 1;
4374
- if (newCounter <= 0) document.body.removeAttribute(lockAttribute);
4375
- else document.body.setAttribute(lockAttribute, newCounter.toString());
3968
+ this.maybeNotify.updateDeps([
3969
+ this.isScrolling,
3970
+ startIndex,
3971
+ endIndex
3972
+ ]);
3973
+ return [
3974
+ this.options.rangeExtractor,
3975
+ this.options.overscan,
3976
+ this.options.count,
3977
+ startIndex,
3978
+ endIndex
3979
+ ];
3980
+ }, (rangeExtractor, overscan, count, startIndex, endIndex) => {
3981
+ return startIndex === null || endIndex === null ? [] : rangeExtractor({
3982
+ startIndex,
3983
+ endIndex,
3984
+ overscan,
3985
+ count
3986
+ });
3987
+ }, {
3988
+ key: "getVirtualIndexes",
3989
+ debug: () => this.options.debug
3990
+ });
3991
+ this.indexFromElement = (node) => {
3992
+ const attributeName = this.options.indexAttribute;
3993
+ const indexStr = node.getAttribute(attributeName);
3994
+ if (!indexStr) {
3995
+ console.warn(`Missing attribute name '${attributeName}={index}' on measured element.`);
3996
+ return -1;
3997
+ }
3998
+ return parseInt(indexStr, 10);
4376
3999
  };
4377
- }, []);
4378
- };
4379
- /**
4380
- * Removes page scrollbar and blocks page scroll when mounted
4381
- */
4382
- var RemoveScrollBar = function(_a) {
4383
- var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
4384
- useLockAttribute();
4385
- var gap = React$1.useMemo(function() {
4386
- return getGapWidth(gapMode);
4387
- }, [gapMode]);
4388
- return React$1.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
4389
- };
4390
- //#endregion
4391
- //#region ../../node_modules/.pnpm/react-remove-scroll@2.7.2_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
4392
- var passiveSupported = false;
4393
- if (typeof window !== "undefined") try {
4394
- var options = Object.defineProperty({}, "passive", { get: function() {
4395
- passiveSupported = true;
4396
- return true;
4397
- } });
4398
- window.addEventListener("test", options, options);
4399
- window.removeEventListener("test", options, options);
4400
- } catch (err) {
4401
- passiveSupported = false;
4402
- }
4403
- var nonPassive = passiveSupported ? { passive: false } : false;
4404
- //#endregion
4405
- //#region ../../node_modules/.pnpm/react-remove-scroll@2.7.2_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll/dist/es2015/handleScroll.js
4406
- var alwaysContainsScroll = function(node) {
4407
- return node.tagName === "TEXTAREA";
4408
- };
4409
- var elementCanBeScrolled = function(node, overflow) {
4410
- if (!(node instanceof Element)) return false;
4411
- var styles = window.getComputedStyle(node);
4412
- return styles[overflow] !== "hidden" && !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible");
4413
- };
4414
- var elementCouldBeVScrolled = function(node) {
4415
- return elementCanBeScrolled(node, "overflowY");
4416
- };
4417
- var elementCouldBeHScrolled = function(node) {
4418
- return elementCanBeScrolled(node, "overflowX");
4419
- };
4420
- var locationCouldBeScrolled = function(axis, node) {
4421
- var ownerDocument = node.ownerDocument;
4422
- var current = node;
4423
- do {
4424
- if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) current = current.host;
4425
- if (elementCouldBeScrolled(axis, current)) {
4426
- var _a = getScrollVariables(axis, current);
4427
- if (_a[1] > _a[2]) return true;
4428
- }
4429
- current = current.parentNode;
4430
- } while (current && current !== ownerDocument.body);
4431
- return false;
4432
- };
4433
- var getVScrollVariables = function(_a) {
4434
- return [
4435
- _a.scrollTop,
4436
- _a.scrollHeight,
4437
- _a.clientHeight
4438
- ];
4439
- };
4440
- var getHScrollVariables = function(_a) {
4441
- return [
4442
- _a.scrollLeft,
4443
- _a.scrollWidth,
4444
- _a.clientWidth
4445
- ];
4446
- };
4447
- var elementCouldBeScrolled = function(axis, node) {
4448
- return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
4449
- };
4450
- var getScrollVariables = function(axis, node) {
4451
- return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
4452
- };
4453
- var getDirectionFactor = function(axis, direction) {
4454
- /**
4455
- * If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
4456
- * and then increasingly negative as you scroll towards the end of the content.
4457
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
4458
- */
4459
- return axis === "h" && direction === "rtl" ? -1 : 1;
4460
- };
4461
- var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
4462
- var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
4463
- var delta = directionFactor * sourceDelta;
4464
- var target = event.target;
4465
- var targetInLock = endTarget.contains(target);
4466
- var shouldCancelScroll = false;
4467
- var isDeltaPositive = delta > 0;
4468
- var availableScroll = 0;
4469
- var availableScrollTop = 0;
4470
- do {
4471
- if (!target) break;
4472
- var _a = getScrollVariables(axis, target), position = _a[0];
4473
- var elementScroll = _a[1] - _a[2] - directionFactor * position;
4474
- if (position || elementScroll) {
4475
- if (elementCouldBeScrolled(axis, target)) {
4476
- availableScroll += elementScroll;
4477
- availableScrollTop += position;
4000
+ this._measureElement = (node, entry) => {
4001
+ const index = this.indexFromElement(node);
4002
+ const item = this.measurementsCache[index];
4003
+ if (!item) return;
4004
+ const key = item.key;
4005
+ const prevNode = this.elementsCache.get(key);
4006
+ if (prevNode !== node) {
4007
+ if (prevNode) this.observer.unobserve(prevNode);
4008
+ this.observer.observe(node);
4009
+ this.elementsCache.set(key, node);
4478
4010
  }
4479
- }
4480
- var parent_1 = target.parentNode;
4481
- target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
4482
- } while (!targetInLock && target !== document.body || targetInLock && (endTarget.contains(target) || endTarget === target));
4483
- if (isDeltaPositive && (noOverscroll && Math.abs(availableScroll) < 1 || !noOverscroll && delta > availableScroll)) shouldCancelScroll = true;
4484
- else if (!isDeltaPositive && (noOverscroll && Math.abs(availableScrollTop) < 1 || !noOverscroll && -delta > availableScrollTop)) shouldCancelScroll = true;
4485
- return shouldCancelScroll;
4486
- };
4487
- //#endregion
4488
- //#region ../../node_modules/.pnpm/react-remove-scroll@2.7.2_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll/dist/es2015/SideEffect.js
4489
- var getTouchXY = function(event) {
4490
- return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
4491
- };
4492
- var getDeltaXY = function(event) {
4493
- return [event.deltaX, event.deltaY];
4494
- };
4495
- var extractRef = function(ref) {
4496
- return ref && "current" in ref ? ref.current : ref;
4497
- };
4498
- var deltaCompare = function(x, y) {
4499
- return x[0] === y[0] && x[1] === y[1];
4500
- };
4501
- var generateStyle = function(id) {
4502
- return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
4503
- };
4504
- var idCounter = 0;
4505
- var lockStack = [];
4506
- function RemoveScrollSideCar(props) {
4507
- var shouldPreventQueue = React$1.useRef([]);
4508
- var touchStartRef = React$1.useRef([0, 0]);
4509
- var activeAxis = React$1.useRef();
4510
- var id = React$1.useState(idCounter++)[0];
4511
- var Style = React$1.useState(styleSingleton)[0];
4512
- var lastProps = React$1.useRef(props);
4513
- React$1.useEffect(function() {
4514
- lastProps.current = props;
4515
- }, [props]);
4516
- React$1.useEffect(function() {
4517
- if (props.inert) {
4518
- document.body.classList.add("block-interactivity-".concat(id));
4519
- var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
4520
- allow_1.forEach(function(el) {
4521
- return el.classList.add("allow-interactivity-".concat(id));
4522
- });
4523
- return function() {
4524
- document.body.classList.remove("block-interactivity-".concat(id));
4525
- allow_1.forEach(function(el) {
4526
- return el.classList.remove("allow-interactivity-".concat(id));
4011
+ if (node.isConnected) this.resizeItem(index, this.options.measureElement(node, entry, this));
4012
+ };
4013
+ this.resizeItem = (index, size) => {
4014
+ const item = this.measurementsCache[index];
4015
+ if (!item) return;
4016
+ const delta = size - (this.itemSizeCache.get(item.key) ?? item.size);
4017
+ if (delta !== 0) {
4018
+ if (this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this) : item.start < this.getScrollOffset() + this.scrollAdjustments) {
4019
+ if (this.options.debug) console.info("correction", delta);
4020
+ this._scrollToOffset(this.getScrollOffset(), {
4021
+ adjustments: this.scrollAdjustments += delta,
4022
+ behavior: void 0
4023
+ });
4024
+ }
4025
+ this.pendingMeasuredCacheIndexes.push(item.index);
4026
+ this.itemSizeCache = new Map(this.itemSizeCache.set(item.key, size));
4027
+ this.notify(false);
4028
+ }
4029
+ };
4030
+ this.measureElement = (node) => {
4031
+ if (!node) {
4032
+ this.elementsCache.forEach((cached, key) => {
4033
+ if (!cached.isConnected) {
4034
+ this.observer.unobserve(cached);
4035
+ this.elementsCache.delete(key);
4036
+ }
4527
4037
  });
4528
- };
4529
- }
4530
- }, [
4531
- props.inert,
4532
- props.lockRef.current,
4533
- props.shards
4534
- ]);
4535
- var shouldCancelEvent = React$1.useCallback(function(event, parent) {
4536
- if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) return !lastProps.current.allowPinchZoom;
4537
- var touch = getTouchXY(event);
4538
- var touchStart = touchStartRef.current;
4539
- var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
4540
- var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
4541
- var currentAxis;
4542
- var target = event.target;
4543
- var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
4544
- if ("touches" in event && moveDirection === "h" && target.type === "range") return false;
4545
- var selection = window.getSelection();
4546
- var anchorNode = selection && selection.anchorNode;
4547
- if (anchorNode ? anchorNode === target || anchorNode.contains(target) : false) return false;
4548
- var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
4549
- if (!canBeScrolledInMainDirection) return true;
4550
- if (canBeScrolledInMainDirection) currentAxis = moveDirection;
4551
- else {
4552
- currentAxis = moveDirection === "v" ? "h" : "v";
4553
- canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
4554
- }
4555
- if (!canBeScrolledInMainDirection) return false;
4556
- if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) activeAxis.current = currentAxis;
4557
- if (!currentAxis) return true;
4558
- var cancelingAxis = activeAxis.current || currentAxis;
4559
- return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
4560
- }, []);
4561
- var shouldPrevent = React$1.useCallback(function(_event) {
4562
- var event = _event;
4563
- if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) return;
4564
- var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
4565
- var sourceEvent = shouldPreventQueue.current.filter(function(e) {
4566
- return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
4567
- })[0];
4568
- if (sourceEvent && sourceEvent.should) {
4569
- if (event.cancelable) event.preventDefault();
4570
- return;
4571
- }
4572
- if (!sourceEvent) {
4573
- var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
4574
- return node.contains(event.target);
4575
- });
4576
- if (shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation) {
4577
- if (event.cancelable) event.preventDefault();
4038
+ return;
4578
4039
  }
4579
- }
4580
- }, []);
4581
- var shouldCancel = React$1.useCallback(function(name, delta, target, should) {
4582
- var event = {
4583
- name,
4584
- delta,
4585
- target,
4586
- should,
4587
- shadowParent: getOutermostShadowParent(target)
4040
+ this._measureElement(node, void 0);
4588
4041
  };
4589
- shouldPreventQueue.current.push(event);
4590
- setTimeout(function() {
4591
- shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
4592
- return e !== event;
4593
- });
4594
- }, 1);
4595
- }, []);
4596
- var scrollTouchStart = React$1.useCallback(function(event) {
4597
- touchStartRef.current = getTouchXY(event);
4598
- activeAxis.current = void 0;
4599
- }, []);
4600
- var scrollWheel = React$1.useCallback(function(event) {
4601
- shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
4602
- }, []);
4603
- var scrollTouchMove = React$1.useCallback(function(event) {
4604
- shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
4605
- }, []);
4606
- React$1.useEffect(function() {
4607
- lockStack.push(Style);
4608
- props.setCallbacks({
4609
- onScrollCapture: scrollWheel,
4610
- onWheelCapture: scrollWheel,
4611
- onTouchMoveCapture: scrollTouchMove
4042
+ this.getVirtualItems = memo$1(() => [this.getVirtualIndexes(), this.getMeasurements()], (indexes, measurements) => {
4043
+ const virtualItems = [];
4044
+ for (let k = 0, len = indexes.length; k < len; k++) {
4045
+ const measurement = measurements[indexes[k]];
4046
+ virtualItems.push(measurement);
4047
+ }
4048
+ return virtualItems;
4049
+ }, {
4050
+ key: "getVirtualItems",
4051
+ debug: () => this.options.debug
4612
4052
  });
4613
- document.addEventListener("wheel", shouldPrevent, nonPassive);
4614
- document.addEventListener("touchmove", shouldPrevent, nonPassive);
4615
- document.addEventListener("touchstart", scrollTouchStart, nonPassive);
4616
- return function() {
4617
- lockStack = lockStack.filter(function(inst) {
4618
- return inst !== Style;
4619
- });
4620
- document.removeEventListener("wheel", shouldPrevent, nonPassive);
4621
- document.removeEventListener("touchmove", shouldPrevent, nonPassive);
4622
- document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
4053
+ this.getVirtualItemForOffset = (offset) => {
4054
+ const measurements = this.getMeasurements();
4055
+ if (measurements.length === 0) return;
4056
+ return notUndefined(measurements[findNearestBinarySearch(0, measurements.length - 1, (index) => notUndefined(measurements[index]).start, offset)]);
4623
4057
  };
4624
- }, []);
4625
- var removeScrollBar = props.removeScrollBar, inert = props.inert;
4626
- return React$1.createElement(React$1.Fragment, null, inert ? React$1.createElement(Style, { styles: generateStyle(id) }) : null, removeScrollBar ? React$1.createElement(RemoveScrollBar, {
4627
- noRelative: props.noRelative,
4628
- gapMode: props.gapMode
4629
- }) : null);
4630
- }
4631
- function getOutermostShadowParent(node) {
4632
- var shadowParent = null;
4633
- while (node !== null) {
4634
- if (node instanceof ShadowRoot) {
4635
- shadowParent = node.host;
4636
- node = node.host;
4637
- }
4638
- node = node.parentNode;
4639
- }
4640
- return shadowParent;
4641
- }
4642
- //#endregion
4643
- //#region ../../node_modules/.pnpm/react-remove-scroll@2.7.2_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll/dist/es2015/sidecar.js
4644
- var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar);
4645
- //#endregion
4646
- //#region ../../node_modules/.pnpm/react-remove-scroll@2.7.2_@types+react@19.2.14_react@19.2.6/node_modules/react-remove-scroll/dist/es2015/Combination.js
4647
- var ReactRemoveScroll = React$1.forwardRef(function(props, ref) {
4648
- return React$1.createElement(RemoveScroll, __assign({}, props, {
4649
- ref,
4650
- sideCar: sidecar_default
4651
- }));
4652
- });
4653
- ReactRemoveScroll.classNames = RemoveScroll.classNames;
4654
- //#endregion
4655
- //#region ../../node_modules/.pnpm/@radix-ui+react-dialog@1.1.15_@types+react-dom@19.2.3_@types+react@19.2.14__@types+reac_340425d8afbecb0b8c61fd2281bc18a1/node_modules/@radix-ui/react-dialog/dist/index.mjs
4656
- var DIALOG_NAME = "Dialog";
4657
- var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
4658
- var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
4659
- var Dialog = (props) => {
4660
- const { __scopeDialog, children, open: openProp, defaultOpen, onOpenChange, modal = true } = props;
4661
- const triggerRef = React$1.useRef(null);
4662
- const contentRef = React$1.useRef(null);
4663
- const [open, setOpen] = useControllableState({
4664
- prop: openProp,
4665
- defaultProp: defaultOpen ?? false,
4666
- onChange: onOpenChange,
4667
- caller: DIALOG_NAME
4668
- });
4669
- return /* @__PURE__ */ jsx(DialogProvider, {
4670
- scope: __scopeDialog,
4671
- triggerRef,
4672
- contentRef,
4673
- contentId: useId$1(),
4674
- titleId: useId$1(),
4675
- descriptionId: useId$1(),
4676
- open,
4677
- onOpenChange: setOpen,
4678
- onOpenToggle: React$1.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
4679
- modal,
4680
- children
4681
- });
4682
- };
4683
- Dialog.displayName = DIALOG_NAME;
4684
- var TRIGGER_NAME = "DialogTrigger";
4685
- var DialogTrigger = React$1.forwardRef((props, forwardedRef) => {
4686
- const { __scopeDialog, ...triggerProps } = props;
4687
- const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
4688
- const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
4689
- return /* @__PURE__ */ jsx(Primitive$1.button, {
4690
- type: "button",
4691
- "aria-haspopup": "dialog",
4692
- "aria-expanded": context.open,
4693
- "aria-controls": context.contentId,
4694
- "data-state": getState(context.open),
4695
- ...triggerProps,
4696
- ref: composedTriggerRef,
4697
- onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
4698
- });
4699
- });
4700
- DialogTrigger.displayName = TRIGGER_NAME;
4701
- var PORTAL_NAME = "DialogPortal";
4702
- var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, { forceMount: void 0 });
4703
- var DialogPortal = (props) => {
4704
- const { __scopeDialog, forceMount, children, container } = props;
4705
- const context = useDialogContext(PORTAL_NAME, __scopeDialog);
4706
- return /* @__PURE__ */ jsx(PortalProvider, {
4707
- scope: __scopeDialog,
4708
- forceMount,
4709
- children: React$1.Children.map(children, (child) => /* @__PURE__ */ jsx(Presence, {
4710
- present: forceMount || context.open,
4711
- children: /* @__PURE__ */ jsx(Portal$1, {
4712
- asChild: true,
4713
- container,
4714
- children: child
4715
- })
4716
- }))
4717
- });
4718
- };
4719
- DialogPortal.displayName = PORTAL_NAME;
4720
- var OVERLAY_NAME = "DialogOverlay";
4721
- var DialogOverlay = React$1.forwardRef((props, forwardedRef) => {
4722
- const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
4723
- const { forceMount = portalContext.forceMount, ...overlayProps } = props;
4724
- const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
4725
- return context.modal ? /* @__PURE__ */ jsx(Presence, {
4726
- present: forceMount || context.open,
4727
- children: /* @__PURE__ */ jsx(DialogOverlayImpl, {
4728
- ...overlayProps,
4729
- ref: forwardedRef
4730
- })
4731
- }) : null;
4732
- });
4733
- DialogOverlay.displayName = OVERLAY_NAME;
4734
- var Slot$1 = createSlot$1("DialogOverlay.RemoveScroll");
4735
- var DialogOverlayImpl = React$1.forwardRef((props, forwardedRef) => {
4736
- const { __scopeDialog, ...overlayProps } = props;
4737
- const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
4738
- return /* @__PURE__ */ jsx(ReactRemoveScroll, {
4739
- as: Slot$1,
4740
- allowPinchZoom: true,
4741
- shards: [context.contentRef],
4742
- children: /* @__PURE__ */ jsx(Primitive$1.div, {
4743
- "data-state": getState(context.open),
4744
- ...overlayProps,
4745
- ref: forwardedRef,
4746
- style: {
4747
- pointerEvents: "auto",
4748
- ...overlayProps.style
4058
+ this.getMaxScrollOffset = () => {
4059
+ if (!this.scrollElement) return 0;
4060
+ if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
4061
+ else {
4062
+ const doc = this.scrollElement.document.documentElement;
4063
+ return this.options.horizontal ? doc.scrollWidth - this.scrollElement.innerWidth : doc.scrollHeight - this.scrollElement.innerHeight;
4749
4064
  }
4750
- })
4751
- });
4752
- });
4753
- var CONTENT_NAME = "DialogContent";
4754
- var DialogContent = React$1.forwardRef((props, forwardedRef) => {
4755
- const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
4756
- const { forceMount = portalContext.forceMount, ...contentProps } = props;
4757
- const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
4758
- return /* @__PURE__ */ jsx(Presence, {
4759
- present: forceMount || context.open,
4760
- children: context.modal ? /* @__PURE__ */ jsx(DialogContentModal, {
4761
- ...contentProps,
4762
- ref: forwardedRef
4763
- }) : /* @__PURE__ */ jsx(DialogContentNonModal, {
4764
- ...contentProps,
4765
- ref: forwardedRef
4766
- })
4767
- });
4768
- });
4769
- DialogContent.displayName = CONTENT_NAME;
4770
- var DialogContentModal = React$1.forwardRef((props, forwardedRef) => {
4771
- const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
4772
- const contentRef = React$1.useRef(null);
4773
- const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
4774
- React$1.useEffect(() => {
4775
- const content = contentRef.current;
4776
- if (content) return hideOthers(content);
4777
- }, []);
4778
- return /* @__PURE__ */ jsx(DialogContentImpl, {
4779
- ...props,
4780
- ref: composedRefs,
4781
- trapFocus: context.open,
4782
- disableOutsidePointerEvents: true,
4783
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
4784
- event.preventDefault();
4785
- context.triggerRef.current?.focus();
4786
- }),
4787
- onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
4788
- const originalEvent = event.detail.originalEvent;
4789
- const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
4790
- if (originalEvent.button === 2 || ctrlLeftClick) event.preventDefault();
4791
- }),
4792
- onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => event.preventDefault())
4793
- });
4794
- });
4795
- var DialogContentNonModal = React$1.forwardRef((props, forwardedRef) => {
4796
- const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
4797
- const hasInteractedOutsideRef = React$1.useRef(false);
4798
- const hasPointerDownOutsideRef = React$1.useRef(false);
4799
- return /* @__PURE__ */ jsx(DialogContentImpl, {
4800
- ...props,
4801
- ref: forwardedRef,
4802
- trapFocus: false,
4803
- disableOutsidePointerEvents: false,
4804
- onCloseAutoFocus: (event) => {
4805
- props.onCloseAutoFocus?.(event);
4806
- if (!event.defaultPrevented) {
4807
- if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
4808
- event.preventDefault();
4065
+ };
4066
+ this.getOffsetForAlignment = (toOffset, align, itemSize = 0) => {
4067
+ if (!this.scrollElement) return 0;
4068
+ const size = this.getSize();
4069
+ const scrollOffset = this.getScrollOffset();
4070
+ if (align === "auto") align = toOffset >= scrollOffset + size ? "end" : "start";
4071
+ if (align === "center") toOffset += (itemSize - size) / 2;
4072
+ else if (align === "end") toOffset -= size;
4073
+ const maxOffset = this.getMaxScrollOffset();
4074
+ return Math.max(Math.min(maxOffset, toOffset), 0);
4075
+ };
4076
+ this.getOffsetForIndex = (index, align = "auto") => {
4077
+ index = Math.max(0, Math.min(index, this.options.count - 1));
4078
+ const item = this.measurementsCache[index];
4079
+ if (!item) return;
4080
+ const size = this.getSize();
4081
+ const scrollOffset = this.getScrollOffset();
4082
+ if (align === "auto") {
4083
+ if (item.end >= scrollOffset + size - this.options.scrollPaddingEnd) align = "end";
4084
+ else if (item.start <= scrollOffset + this.options.scrollPaddingStart) align = "start";
4085
+ else return [scrollOffset, align];
4809
4086
  }
4810
- hasInteractedOutsideRef.current = false;
4811
- hasPointerDownOutsideRef.current = false;
4812
- },
4813
- onInteractOutside: (event) => {
4814
- props.onInteractOutside?.(event);
4815
- if (!event.defaultPrevented) {
4816
- hasInteractedOutsideRef.current = true;
4817
- if (event.detail.originalEvent.type === "pointerdown") hasPointerDownOutsideRef.current = true;
4087
+ if (align === "end" && index === this.options.count - 1) return [this.getMaxScrollOffset(), align];
4088
+ const toOffset = align === "end" ? item.end + this.options.scrollPaddingEnd : item.start - this.options.scrollPaddingStart;
4089
+ return [this.getOffsetForAlignment(toOffset, align, item.size), align];
4090
+ };
4091
+ this.isDynamicMode = () => this.elementsCache.size > 0;
4092
+ this.scrollToOffset = (toOffset, { align = "start", behavior } = {}) => {
4093
+ if (behavior === "smooth" && this.isDynamicMode()) console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");
4094
+ this._scrollToOffset(this.getOffsetForAlignment(toOffset, align), {
4095
+ adjustments: void 0,
4096
+ behavior
4097
+ });
4098
+ };
4099
+ this.scrollToIndex = (index, { align: initialAlign = "auto", behavior } = {}) => {
4100
+ if (behavior === "smooth" && this.isDynamicMode()) console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");
4101
+ index = Math.max(0, Math.min(index, this.options.count - 1));
4102
+ this.currentScrollToIndex = index;
4103
+ let attempts = 0;
4104
+ const maxAttempts = 10;
4105
+ const tryScroll = (currentAlign) => {
4106
+ if (!this.targetWindow) return;
4107
+ const offsetInfo = this.getOffsetForIndex(index, currentAlign);
4108
+ if (!offsetInfo) {
4109
+ console.warn("Failed to get offset for index:", index);
4110
+ return;
4111
+ }
4112
+ const [offset, align] = offsetInfo;
4113
+ this._scrollToOffset(offset, {
4114
+ adjustments: void 0,
4115
+ behavior
4116
+ });
4117
+ this.targetWindow.requestAnimationFrame(() => {
4118
+ if (!this.targetWindow) return;
4119
+ const verify = () => {
4120
+ if (this.currentScrollToIndex !== index) return;
4121
+ const currentOffset = this.getScrollOffset();
4122
+ const afterInfo = this.getOffsetForIndex(index, align);
4123
+ if (!afterInfo) {
4124
+ console.warn("Failed to get offset for index:", index);
4125
+ return;
4126
+ }
4127
+ if (!approxEqual(afterInfo[0], currentOffset)) scheduleRetry(align);
4128
+ };
4129
+ if (this.isDynamicMode()) this.targetWindow.requestAnimationFrame(verify);
4130
+ else verify();
4131
+ });
4132
+ };
4133
+ const scheduleRetry = (align) => {
4134
+ if (!this.targetWindow) return;
4135
+ if (this.currentScrollToIndex !== index) return;
4136
+ attempts++;
4137
+ if (attempts < maxAttempts) {
4138
+ if (this.options.debug) console.info("Schedule retry", attempts, maxAttempts);
4139
+ this.targetWindow.requestAnimationFrame(() => tryScroll(align));
4140
+ } else console.warn(`Failed to scroll to index ${index} after ${maxAttempts} attempts.`);
4141
+ };
4142
+ tryScroll(initialAlign);
4143
+ };
4144
+ this.scrollBy = (delta, { behavior } = {}) => {
4145
+ if (behavior === "smooth" && this.isDynamicMode()) console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");
4146
+ this._scrollToOffset(this.getScrollOffset() + delta, {
4147
+ adjustments: void 0,
4148
+ behavior
4149
+ });
4150
+ };
4151
+ this.getTotalSize = () => {
4152
+ var _a;
4153
+ const measurements = this.getMeasurements();
4154
+ let end;
4155
+ if (measurements.length === 0) end = this.options.paddingStart;
4156
+ else if (this.options.lanes === 1) end = ((_a = measurements[measurements.length - 1]) == null ? void 0 : _a.end) ?? 0;
4157
+ else {
4158
+ const endByLane = Array(this.options.lanes).fill(null);
4159
+ let endIndex = measurements.length - 1;
4160
+ while (endIndex >= 0 && endByLane.some((val) => val === null)) {
4161
+ const item = measurements[endIndex];
4162
+ if (endByLane[item.lane] === null) endByLane[item.lane] = item.end;
4163
+ endIndex--;
4164
+ }
4165
+ end = Math.max(...endByLane.filter((val) => val !== null));
4818
4166
  }
4819
- const target = event.target;
4820
- if (context.triggerRef.current?.contains(target)) event.preventDefault();
4821
- if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) event.preventDefault();
4822
- }
4823
- });
4824
- });
4825
- var DialogContentImpl = React$1.forwardRef((props, forwardedRef) => {
4826
- const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
4827
- const context = useDialogContext(CONTENT_NAME, __scopeDialog);
4828
- const contentRef = React$1.useRef(null);
4829
- const composedRefs = useComposedRefs(forwardedRef, contentRef);
4830
- useFocusGuards();
4831
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FocusScope, {
4832
- asChild: true,
4833
- loop: true,
4834
- trapped: trapFocus,
4835
- onMountAutoFocus: onOpenAutoFocus,
4836
- onUnmountAutoFocus: onCloseAutoFocus,
4837
- children: /* @__PURE__ */ jsx(DismissableLayer, {
4838
- role: "dialog",
4839
- id: context.contentId,
4840
- "aria-describedby": context.descriptionId,
4841
- "aria-labelledby": context.titleId,
4842
- "data-state": getState(context.open),
4843
- ...contentProps,
4844
- ref: composedRefs,
4845
- onDismiss: () => context.onOpenChange(false)
4846
- })
4847
- }), /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(TitleWarning, { titleId: context.titleId }), /* @__PURE__ */ jsx(DescriptionWarning, {
4848
- contentRef,
4849
- descriptionId: context.descriptionId
4850
- })] })] });
4851
- });
4852
- var TITLE_NAME = "DialogTitle";
4853
- var DialogTitle = React$1.forwardRef((props, forwardedRef) => {
4854
- const { __scopeDialog, ...titleProps } = props;
4855
- const context = useDialogContext(TITLE_NAME, __scopeDialog);
4856
- return /* @__PURE__ */ jsx(Primitive$1.h2, {
4857
- id: context.titleId,
4858
- ...titleProps,
4859
- ref: forwardedRef
4860
- });
4861
- });
4862
- DialogTitle.displayName = TITLE_NAME;
4863
- var DESCRIPTION_NAME = "DialogDescription";
4864
- var DialogDescription = React$1.forwardRef((props, forwardedRef) => {
4865
- const { __scopeDialog, ...descriptionProps } = props;
4866
- const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
4867
- return /* @__PURE__ */ jsx(Primitive$1.p, {
4868
- id: context.descriptionId,
4869
- ...descriptionProps,
4870
- ref: forwardedRef
4871
- });
4872
- });
4873
- DialogDescription.displayName = DESCRIPTION_NAME;
4874
- var CLOSE_NAME = "DialogClose";
4875
- var DialogClose = React$1.forwardRef((props, forwardedRef) => {
4876
- const { __scopeDialog, ...closeProps } = props;
4877
- const context = useDialogContext(CLOSE_NAME, __scopeDialog);
4878
- return /* @__PURE__ */ jsx(Primitive$1.button, {
4879
- type: "button",
4880
- ...closeProps,
4881
- ref: forwardedRef,
4882
- onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
4883
- });
4884
- });
4885
- DialogClose.displayName = CLOSE_NAME;
4886
- function getState(open) {
4887
- return open ? "open" : "closed";
4888
- }
4889
- var TITLE_WARNING_NAME = "DialogTitleWarning";
4890
- var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
4891
- contentName: CONTENT_NAME,
4892
- titleName: TITLE_NAME,
4893
- docsSlug: "dialog"
4894
- });
4895
- var TitleWarning = ({ titleId }) => {
4896
- const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
4897
- const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
4898
-
4899
- If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
4900
-
4901
- For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
4902
- React$1.useEffect(() => {
4903
- if (titleId) {
4904
- if (!document.getElementById(titleId)) console.error(MESSAGE);
4905
- }
4906
- }, [MESSAGE, titleId]);
4907
- return null;
4167
+ return Math.max(end - this.options.scrollMargin + this.options.paddingEnd, 0);
4168
+ };
4169
+ this._scrollToOffset = (offset, { adjustments, behavior }) => {
4170
+ this.options.scrollToFn(offset, {
4171
+ behavior,
4172
+ adjustments
4173
+ }, this);
4174
+ };
4175
+ this.measure = () => {
4176
+ this.itemSizeCache = /* @__PURE__ */ new Map();
4177
+ this.laneAssignments = /* @__PURE__ */ new Map();
4178
+ this.notify(false);
4179
+ };
4180
+ this.setOptions(opts);
4181
+ }
4908
4182
  };
4909
- var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
4910
- var DescriptionWarning = ({ contentRef, descriptionId }) => {
4911
- const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${useWarningContext(DESCRIPTION_WARNING_NAME).contentName}}.`;
4912
- React$1.useEffect(() => {
4913
- const describedById = contentRef.current?.getAttribute("aria-describedby");
4914
- if (descriptionId && describedById) {
4915
- if (!document.getElementById(descriptionId)) console.warn(MESSAGE);
4916
- }
4917
- }, [
4918
- MESSAGE,
4919
- contentRef,
4920
- descriptionId
4921
- ]);
4922
- return null;
4183
+ const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
4184
+ while (low <= high) {
4185
+ const middle = (low + high) / 2 | 0;
4186
+ const currentValue = getCurrentValue(middle);
4187
+ if (currentValue < value) low = middle + 1;
4188
+ else if (currentValue > value) high = middle - 1;
4189
+ else return middle;
4190
+ }
4191
+ if (low > 0) return low - 1;
4192
+ else return 0;
4923
4193
  };
4924
- var Root$1 = Dialog;
4925
- var Portal = DialogPortal;
4926
- var Overlay = DialogOverlay;
4927
- var Content = DialogContent;
4928
- var Title = DialogTitle;
4929
- var Description = DialogDescription;
4930
- //#endregion
4931
- //#region ../../node_modules/.pnpm/@radix-ui+react-slot@1.2.4_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-slot/dist/index.mjs
4932
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
4933
- var use = React$1[" use ".trim().toString()];
4934
- function isPromiseLike(value) {
4935
- return typeof value === "object" && value !== null && "then" in value;
4936
- }
4937
- function isLazyComponent(element) {
4938
- return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
4939
- }
4940
- /* @__NO_SIDE_EFFECTS__ */
4941
- function createSlot(ownerName) {
4942
- const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
4943
- const Slot2 = React$1.forwardRef((props, forwardedRef) => {
4944
- let { children, ...slotProps } = props;
4945
- if (isLazyComponent(children) && typeof use === "function") children = use(children._payload);
4946
- const childrenArray = React$1.Children.toArray(children);
4947
- const slottable = childrenArray.find(isSlottable);
4948
- if (slottable) {
4949
- const newElement = slottable.props.children;
4950
- const newChildren = childrenArray.map((child) => {
4951
- if (child === slottable) {
4952
- if (React$1.Children.count(newElement) > 1) return React$1.Children.only(null);
4953
- return React$1.isValidElement(newElement) ? newElement.props.children : null;
4954
- } else return child;
4955
- });
4956
- return /* @__PURE__ */ jsx(SlotClone, {
4957
- ...slotProps,
4958
- ref: forwardedRef,
4959
- children: React$1.isValidElement(newElement) ? React$1.cloneElement(newElement, void 0, newChildren) : null
4960
- });
4194
+ function calculateRange({ measurements, outerSize, scrollOffset, lanes }) {
4195
+ const lastIndex = measurements.length - 1;
4196
+ const getOffset = (index) => measurements[index].start;
4197
+ if (measurements.length <= lanes) return {
4198
+ startIndex: 0,
4199
+ endIndex: lastIndex
4200
+ };
4201
+ let startIndex = findNearestBinarySearch(0, lastIndex, getOffset, scrollOffset);
4202
+ let endIndex = startIndex;
4203
+ if (lanes === 1) while (endIndex < lastIndex && measurements[endIndex].end < scrollOffset + outerSize) endIndex++;
4204
+ else if (lanes > 1) {
4205
+ const endPerLane = Array(lanes).fill(0);
4206
+ while (endIndex < lastIndex && endPerLane.some((pos) => pos < scrollOffset + outerSize)) {
4207
+ const item = measurements[endIndex];
4208
+ endPerLane[item.lane] = item.end;
4209
+ endIndex++;
4961
4210
  }
4962
- return /* @__PURE__ */ jsx(SlotClone, {
4963
- ...slotProps,
4964
- ref: forwardedRef,
4965
- children
4966
- });
4967
- });
4968
- Slot2.displayName = `${ownerName}.Slot`;
4969
- return Slot2;
4970
- }
4971
- var Slot = /* @__PURE__ */ createSlot("Slot");
4972
- /* @__NO_SIDE_EFFECTS__ */
4973
- function createSlotClone(ownerName) {
4974
- const SlotClone = React$1.forwardRef((props, forwardedRef) => {
4975
- let { children, ...slotProps } = props;
4976
- if (isLazyComponent(children) && typeof use === "function") children = use(children._payload);
4977
- if (React$1.isValidElement(children)) {
4978
- const childrenRef = getElementRef(children);
4979
- const props2 = mergeProps(slotProps, children.props);
4980
- if (children.type !== React$1.Fragment) props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
4981
- return React$1.cloneElement(children, props2);
4211
+ const startPerLane = Array(lanes).fill(scrollOffset + outerSize);
4212
+ while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
4213
+ const item = measurements[startIndex];
4214
+ startPerLane[item.lane] = item.start;
4215
+ startIndex--;
4982
4216
  }
4983
- return React$1.Children.count(children) > 1 ? React$1.Children.only(null) : null;
4984
- });
4985
- SlotClone.displayName = `${ownerName}.SlotClone`;
4986
- return SlotClone;
4987
- }
4988
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
4989
- function isSlottable(child) {
4990
- return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
4991
- }
4992
- function mergeProps(slotProps, childProps) {
4993
- const overrideProps = { ...childProps };
4994
- for (const propName in childProps) {
4995
- const slotPropValue = slotProps[propName];
4996
- const childPropValue = childProps[propName];
4997
- if (/^on[A-Z]/.test(propName)) {
4998
- if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
4999
- const result = childPropValue(...args);
5000
- slotPropValue(...args);
5001
- return result;
5002
- };
5003
- else if (slotPropValue) overrideProps[propName] = slotPropValue;
5004
- } else if (propName === "style") overrideProps[propName] = {
5005
- ...slotPropValue,
5006
- ...childPropValue
5007
- };
5008
- else if (propName === "className") overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
4217
+ startIndex = Math.max(0, startIndex - startIndex % lanes);
4218
+ endIndex = Math.min(lastIndex, endIndex + (lanes - 1 - endIndex % lanes));
5009
4219
  }
5010
4220
  return {
5011
- ...slotProps,
5012
- ...overrideProps
4221
+ startIndex,
4222
+ endIndex
4223
+ };
4224
+ }
4225
+ //#endregion
4226
+ //#region ../../node_modules/.pnpm/@tanstack+react-virtual@3.13.19_react-dom@19.2.6_react@19.2.6__react@19.2.6/node_modules/@tanstack/react-virtual/dist/esm/index.js
4227
+ const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React$1.useLayoutEffect : React$1.useEffect;
4228
+ function useVirtualizerBase({ useFlushSync = true, ...options }) {
4229
+ const rerender = React$1.useReducer(() => ({}), {})[1];
4230
+ const resolvedOptions = {
4231
+ ...options,
4232
+ onChange: (instance2, sync) => {
4233
+ var _a;
4234
+ if (useFlushSync && sync) flushSync(rerender);
4235
+ else rerender();
4236
+ (_a = options.onChange) == null || _a.call(options, instance2, sync);
4237
+ }
5013
4238
  };
4239
+ const [instance] = React$1.useState(() => new Virtualizer(resolvedOptions));
4240
+ instance.setOptions(resolvedOptions);
4241
+ useIsomorphicLayoutEffect(() => {
4242
+ return instance._didMount();
4243
+ }, []);
4244
+ useIsomorphicLayoutEffect(() => {
4245
+ return instance._willUpdate();
4246
+ });
4247
+ return instance;
5014
4248
  }
5015
- function getElementRef(element) {
5016
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
5017
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
5018
- if (mayWarn) return element.ref;
5019
- getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
5020
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
5021
- if (mayWarn) return element.props.ref;
5022
- return element.props.ref || element.ref;
4249
+ function useVirtualizer(options) {
4250
+ return useVirtualizerBase({
4251
+ observeElementRect,
4252
+ observeElementOffset,
4253
+ scrollToFn: elementScroll,
4254
+ ...options
4255
+ });
5023
4256
  }
5024
4257
  //#endregion
5025
- //#region ../../node_modules/.pnpm/@radix-ui+react-primitive@2.1.4_@types+react-dom@19.2.3_@types+react@19.2.14__@types+re_c8c8fd2647f03197dbf56370d7498033/node_modules/@radix-ui/react-primitive/dist/index.mjs
5026
- var Primitive = [
5027
- "a",
5028
- "button",
5029
- "div",
5030
- "form",
5031
- "h2",
5032
- "h3",
5033
- "img",
5034
- "input",
5035
- "label",
5036
- "li",
5037
- "nav",
5038
- "ol",
5039
- "p",
5040
- "select",
5041
- "span",
5042
- "svg",
5043
- "ul"
5044
- ].reduce((primitive, node) => {
5045
- const Slot = /* @__PURE__ */ createSlot(`Primitive.${node}`);
5046
- const Node = React$1.forwardRef((props, forwardedRef) => {
5047
- const { asChild, ...primitiveProps } = props;
5048
- const Comp = asChild ? Slot : node;
5049
- if (typeof window !== "undefined") window[Symbol.for("radix-ui")] = true;
5050
- return /* @__PURE__ */ jsx(Comp, {
5051
- ...primitiveProps,
5052
- ref: forwardedRef
5053
- });
4258
+ //#region editors/generic-drive-explorer/components/file-content-view.tsx
4259
+ const GAP = 8;
4260
+ const ITEM_WIDTH = 256;
4261
+ const ITEM_HEIGHT = 48;
4262
+ const USED_SPACE = 420;
4263
+ function FileContentView() {
4264
+ const parentRef = useRef(null);
4265
+ const availableWidth = useWindowSize().innerWidth - USED_SPACE;
4266
+ const fileNodes = useNodesInSelectedDriveOrFolder().filter((n) => isFileNodeKind(n));
4267
+ const columnCount = Math.floor(availableWidth / 264) || 1;
4268
+ const rowVirtualizer = useVirtualizer({
4269
+ count: Math.ceil(fileNodes.length / columnCount),
4270
+ getScrollElement: () => parentRef.current,
4271
+ estimateSize: (index) => {
4272
+ if (index > 0) return 56;
4273
+ return ITEM_HEIGHT;
4274
+ },
4275
+ overscan: 5
4276
+ });
4277
+ const columnVirtualizer = useVirtualizer({
4278
+ horizontal: true,
4279
+ count: columnCount,
4280
+ getScrollElement: () => parentRef.current,
4281
+ estimateSize: (index) => {
4282
+ if (index > 0) return 264;
4283
+ return ITEM_WIDTH;
4284
+ },
4285
+ overscan: 5
5054
4286
  });
5055
- Node.displayName = `Primitive.${node}`;
5056
- return {
5057
- ...primitive,
5058
- [node]: Node
4287
+ const getItemIndex = (rowIndex, columnIndex) => rowIndex * columnCount + columnIndex;
4288
+ const getItem = (rowIndex, columnIndex) => {
4289
+ const index = getItemIndex(rowIndex, columnIndex);
4290
+ return fileNodes[index] || null;
5059
4291
  };
5060
- }, {});
5061
- //#endregion
5062
- //#region ../../node_modules/.pnpm/@radix-ui+react-visually-hidden@1.2.4_@types+react-dom@19.2.3_@types+react@19.2.14__@ty_c96f9879086bb31d068780de3c4b72ff/node_modules/@radix-ui/react-visually-hidden/dist/index.mjs
5063
- var VISUALLY_HIDDEN_STYLES = Object.freeze({
5064
- position: "absolute",
5065
- border: 0,
5066
- width: 1,
5067
- height: 1,
5068
- padding: 0,
5069
- margin: -1,
5070
- overflow: "hidden",
5071
- clip: "rect(0, 0, 0, 0)",
5072
- whiteSpace: "nowrap",
5073
- wordWrap: "normal"
5074
- });
5075
- var NAME = "VisuallyHidden";
5076
- var VisuallyHidden = React$1.forwardRef((props, forwardedRef) => {
5077
- return /* @__PURE__ */ jsx(Primitive.span, {
5078
- ...props,
5079
- ref: forwardedRef,
4292
+ if (fileNodes.length === 0) return /* @__PURE__ */ jsx("div", {
4293
+ className: "mb-8 text-sm text-muted-foreground",
4294
+ children: "No documents or files 📄"
4295
+ });
4296
+ const renderItem = (rowIndex, columnIndex) => {
4297
+ const fileNode = getItem(rowIndex, columnIndex);
4298
+ if (!fileNode) return null;
4299
+ return /* @__PURE__ */ jsx("div", {
4300
+ style: { marginLeft: columnIndex === 0 ? 0 : GAP },
4301
+ children: /* @__PURE__ */ jsx(FileItem, { fileNode }, fileNode.id)
4302
+ });
4303
+ };
4304
+ return /* @__PURE__ */ jsx("div", {
4305
+ ref: parentRef,
5080
4306
  style: {
5081
- ...VISUALLY_HIDDEN_STYLES,
5082
- ...props.style
5083
- }
4307
+ width: `100%`,
4308
+ overflow: "auto"
4309
+ },
4310
+ children: /* @__PURE__ */ jsx("div", {
4311
+ style: {
4312
+ height: `${rowVirtualizer.getTotalSize()}px`,
4313
+ width: `${columnVirtualizer.getTotalSize()}px`,
4314
+ position: "relative"
4315
+ },
4316
+ children: rowVirtualizer.getVirtualItems().map((virtualRow) => /* @__PURE__ */ jsx(React.Fragment, { children: columnVirtualizer.getVirtualItems().map((virtualColumn) => /* @__PURE__ */ jsx("div", {
4317
+ style: {
4318
+ position: "absolute",
4319
+ top: 0,
4320
+ left: 0,
4321
+ marginTop: virtualRow.index === 0 ? 0 : GAP,
4322
+ width: `${virtualColumn.size}px`,
4323
+ height: `${ITEM_HEIGHT}px`,
4324
+ overflow: "hidden",
4325
+ transform: `translateX(${virtualColumn.start}px) translateY(${virtualRow.start}px)`
4326
+ },
4327
+ children: renderItem(virtualRow.index, virtualColumn.index)
4328
+ }, virtualColumn.key)) }, virtualRow.key))
4329
+ })
5084
4330
  });
5085
- });
5086
- VisuallyHidden.displayName = NAME;
5087
- var Root = VisuallyHidden;
4331
+ }
5088
4332
  //#endregion
5089
- //#region ../design-system/dist/src-CVV6HzQZ.js
5090
- const PowerhouseButton = /* @__PURE__ */ forwardRef(function PowerhouseButton(props, ref) {
5091
- const { color = "dark", size = "medium", className = "", children, icon, iconPosition = "left", ...delegatedProps } = props;
5092
- return /* @__PURE__ */ jsxs("button", {
5093
- className: twMerge("flex items-center justify-center gap-2 border border-none transition outline-none disabled:disabled-effect", twJoin({
5094
- light: "bg-secondary text-foreground hover:hover-effect active:active-effect disabled:disabled-effect",
5095
- dark: "bg-primary text-primary-foreground hover:hover-effect active:active-effect disabled:disabled-effect",
5096
- red: "bg-destructive text-destructive-foreground hover:hover-effect active:active-effect disabled:disabled-effect disabled:opacity-100",
5097
- blue: "bg-info text-info-foreground hover:hover-effect active:active-effect disabled:disabled-effect disabled:opacity-100"
5098
- }[color], {
5099
- small: "px-2 py-1.5 text-xs rounded-md font-medium",
5100
- medium: "px-6 py-3 text-base rounded-xl font-semibold tracking-wide"
5101
- }[size]), className),
5102
- ref,
5103
- ...delegatedProps,
5104
- children: [
5105
- iconPosition === "left" && icon,
5106
- children,
5107
- iconPosition === "right" && icon
5108
- ]
5109
- });
5110
- });
5111
- function Modal(props) {
5112
- const { title, open, onOpenChange, contentProps, overlayProps, children, ...delegated } = props;
5113
- return /* @__PURE__ */ jsx(Root$1, {
5114
- defaultOpen: open,
5115
- onOpenChange,
5116
- open,
5117
- children: /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(Overlay, {
5118
- ...overlayProps,
5119
- className: twMerge("fixed inset-0 grid place-items-center overflow-y-auto bg-background/50 data-[state=closed]:animate-fade-out data-[state=open]:animate-fade-in", overlayProps?.className),
5120
- children: /* @__PURE__ */ jsxs(Content, {
5121
- ...delegated,
5122
- ...contentProps,
5123
- className: twMerge("overflow-hidden rounded-3xl bg-background shadow-modal data-[state=closed]:animate-zoom-out data-[state=open]:animate-zoom-in dark:shadow-modal-dark", contentProps?.className),
5124
- children: [/* @__PURE__ */ jsxs(Root, { children: [/* @__PURE__ */ jsx(Title, { children: title || "Modal" }), /* @__PURE__ */ jsx(Description, { children: title || "Modal" })] }), children]
5125
- })
5126
- }) })
4333
+ //#region editors/generic-drive-explorer/components/layout.tsx
4334
+ function DriveLayout({ children, className, ...props }) {
4335
+ return /* @__PURE__ */ jsx(DriveLayout.Container, {
4336
+ className,
4337
+ ...props,
4338
+ children
5127
4339
  });
5128
4340
  }
5129
- const useWindowSize = () => {
5130
- const [windowSize, setWindowSize] = useState({
5131
- innerWidth: window.innerWidth,
5132
- innerHeight: window.innerHeight
4341
+ DriveLayout.Container = function DriveLayoutContainer({ children, className, containerProps, ...props }) {
4342
+ return /* @__PURE__ */ jsx("div", {
4343
+ className: twMerge("flex grow flex-col overflow-auto", className),
4344
+ ...containerProps,
4345
+ ...props,
4346
+ children
4347
+ });
4348
+ };
4349
+ DriveLayout.Header = function DriveLayoutHeader({ children, className, containerProps, ...props }) {
4350
+ return /* @__PURE__ */ jsx("div", {
4351
+ className: twMerge("flex-0", className),
4352
+ ...containerProps,
4353
+ ...props,
4354
+ children
4355
+ });
4356
+ };
4357
+ DriveLayout.Content = function DriveLayoutContent({ children, className, containerProps, ...props }) {
4358
+ return /* @__PURE__ */ jsx("div", {
4359
+ className: twMerge("mb-5 flex-1 px-4", className),
4360
+ ...containerProps,
4361
+ ...props,
4362
+ children
5133
4363
  });
5134
- useEffect(() => {
5135
- const windowSizeHandler = () => {
5136
- setWindowSize({
5137
- innerWidth: window.innerWidth,
5138
- innerHeight: window.innerHeight
5139
- });
5140
- };
5141
- window.addEventListener("resize", windowSizeHandler);
5142
- return () => {
5143
- window.removeEventListener("resize", windowSizeHandler);
5144
- };
5145
- }, []);
5146
- return windowSize;
5147
4364
  };
4365
+ DriveLayout.ContentSection = function DriveLayoutContentSection({ title, actions, children, className, containerProps, ...props }) {
4366
+ return /* @__PURE__ */ jsxs("div", {
4367
+ className: twMerge(className),
4368
+ ...containerProps,
4369
+ ...props,
4370
+ children: [(title || actions) && /* @__PURE__ */ jsxs("div", {
4371
+ className: "mb-4 flex items-center justify-between gap-3",
4372
+ children: [title && /* @__PURE__ */ jsx("div", {
4373
+ className: "text-base font-semibold text-foreground",
4374
+ children: title
4375
+ }), actions]
4376
+ }), /* @__PURE__ */ jsx("div", {
4377
+ className: "flex flex-wrap gap-2",
4378
+ children
4379
+ })]
4380
+ });
4381
+ };
4382
+ //#endregion
4383
+ //#region editors/generic-drive-explorer/components/folder-view.tsx
4384
+ function FolderView(props) {
4385
+ const { className } = props;
4386
+ const folderNodes = useNodesInSelectedDriveOrFolder().filter((n) => isFolderNodeKind(n));
4387
+ return /* @__PURE__ */ jsxs("div", {
4388
+ className: twMerge("rounded-md border-2 border-transparent p-2", className),
4389
+ children: [/* @__PURE__ */ jsx(DriveLayout.ContentSection, {
4390
+ title: "Folders",
4391
+ className: "mb-4",
4392
+ children: folderNodes.length > 0 ? folderNodes.map((folderNode) => /* @__PURE__ */ jsx(FolderItem, { folderNode }, folderNode.id)) : /* @__PURE__ */ jsx("div", {
4393
+ className: "mb-8 text-sm text-muted-foreground",
4394
+ children: "No documents or files 📄"
4395
+ })
4396
+ }), /* @__PURE__ */ jsx(DriveLayout.ContentSection, {
4397
+ title: "Documents and files",
4398
+ actions: /* @__PURE__ */ jsx(CreateDocument, {}),
4399
+ children: /* @__PURE__ */ jsx("div", {
4400
+ className: "w-full",
4401
+ children: /* @__PURE__ */ jsx(FileContentView, {})
4402
+ })
4403
+ })]
4404
+ });
4405
+ }
5148
4406
  //#endregion
5149
- export { Slot as a, Primitive as i, PowerhouseButton as n, Icon as o, useWindowSize as r, Modal as t };
4407
+ export { Icon as a, CreateDocument as i, DriveLayout as n, FileContentView as r, FolderView as t };
5150
4408
 
5151
- //# sourceMappingURL=src-CVV6HzQZ-D-OQvEkh.js.map
4409
+ //# sourceMappingURL=folder-view-DjGlA0kT.js.map