@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.4 → 6.2.2-dev.40

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 (100) hide show
  1. package/dist/browser/assets/{entry-Cvoo4_c9.js → entry-Db_lIhQq.js} +3 -2
  2. package/dist/browser/assets/{projection-entry-DVec8YRh.js → projection-entry-DqgHaUSy.js} +4 -4
  3. package/dist/browser/{connect-CV-z3DqA.js → connect-BUnNjGUW.js} +874 -200
  4. package/dist/browser/connect-BUnNjGUW.js.map +1 -0
  5. package/dist/browser/{dist-CXoKspdx.js → dist-B4FWbuEM.js} +10 -2
  6. package/dist/browser/{dist-CXoKspdx.js.map → dist-B4FWbuEM.js.map} +1 -1
  7. package/dist/{node/dist-BeZaEP6S.mjs → browser/dist-BAJ5nRDl.js} +21 -2
  8. package/dist/browser/{dist-D8H48e8N.js.map → dist-BAJ5nRDl.js.map} +1 -1
  9. package/dist/browser/{dist-BEs8jMgM.js → dist-BatmWBzA.js} +1782 -1640
  10. package/dist/browser/dist-BatmWBzA.js.map +1 -0
  11. package/dist/browser/{document-drive-sTKoi6L4.js → document-drive-D3Z9vXTQ.js} +864 -118
  12. package/dist/browser/document-drive-D3Z9vXTQ.js.map +1 -0
  13. package/dist/browser/document-models/index.js +1 -1
  14. package/dist/browser/{documents-D4ek7Ubv.js → documents-J_l59mSV.js} +5 -604
  15. package/dist/browser/documents-J_l59mSV.js.map +1 -0
  16. package/dist/browser/editor-BLeFoOh6.js +25 -0
  17. package/dist/browser/editor-BLeFoOh6.js.map +1 -0
  18. package/dist/browser/{editor-Cw38euRs.js → editor-Bn6uXvxG.js} +10 -142
  19. package/dist/browser/editor-Bn6uXvxG.js.map +1 -0
  20. package/dist/browser/editors/document-model-editor/module.js +1 -1
  21. package/dist/browser/editors/generic-drive-explorer/index.js +5 -5
  22. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  23. package/dist/{node/folder-view-DjKO1mAh.mjs → browser/folder-view-DNzFnfW2.js} +53 -45
  24. package/dist/browser/folder-view-DNzFnfW2.js.map +1 -0
  25. package/dist/browser/{graphql-editor-B-dNI5hD.js → graphql-editor-DWo8N_z4.js} +8 -7
  26. package/dist/browser/{graphql-editor-B-dNI5hD.js.map → graphql-editor-DWo8N_z4.js.map} +1 -1
  27. package/dist/browser/{hooks-CORHBNHb.js → hooks-KKcNp2X0.js} +2 -2
  28. package/dist/browser/{hooks-CORHBNHb.js.map → hooks-KKcNp2X0.js.map} +1 -1
  29. package/dist/browser/index.js +2 -2
  30. package/dist/browser/index.js.map +1 -1
  31. package/dist/browser/{json-editor-v_MnzQVs.js → json-editor-CEugjpFj.js} +4 -4
  32. package/dist/browser/{json-editor-v_MnzQVs.js.map → json-editor-CEugjpFj.js.map} +1 -1
  33. package/dist/browser/{lib-C-f3izXz.js → lib-CiaHsAaR.js} +12 -2
  34. package/dist/browser/lib-CiaHsAaR.js.map +1 -0
  35. package/dist/browser/{linting-Dn6pXRkK.js → linting-_AQWr8aE.js} +5 -4
  36. package/dist/browser/{linting-Dn6pXRkK.js.map → linting-_AQWr8aE.js.map} +1 -1
  37. package/dist/browser/printer-CEYr4JOg.js +604 -0
  38. package/dist/browser/printer-CEYr4JOg.js.map +1 -0
  39. package/dist/browser/{schema-context-DY-GEGnY.js → schema-context-ZyeclQwy.js} +2 -2
  40. package/dist/browser/{schema-context-DY-GEGnY.js.map → schema-context-ZyeclQwy.js.map} +1 -1
  41. package/dist/browser/{state-schemas-65Tp0ZuG.js → state-schemas-VrticHe4.js} +7 -7
  42. package/dist/browser/{state-schemas-65Tp0ZuG.js.map → state-schemas-VrticHe4.js.map} +1 -1
  43. package/dist/node/{connect-Bbi5wHyR.mjs → connect-wMkkAckX.mjs} +874 -200
  44. package/dist/node/connect-wMkkAckX.mjs.map +1 -0
  45. package/dist/node/{dist-8nCvrie2.mjs → dist-CUHBOv3P.mjs} +1593 -1446
  46. package/dist/node/dist-CUHBOv3P.mjs.map +1 -0
  47. package/dist/{browser/dist-D8H48e8N.js → node/dist-CzYOpeXN.mjs} +21 -2
  48. package/dist/node/{dist-BeZaEP6S.mjs.map → dist-CzYOpeXN.mjs.map} +1 -1
  49. package/dist/node/{dist-fA4EItr0.mjs → dist-DT7jI9ol.mjs} +10 -2
  50. package/dist/node/{dist-fA4EItr0.mjs.map → dist-DT7jI9ol.mjs.map} +1 -1
  51. package/dist/node/{document-drive-DjL9iikf.mjs → document-drive-CI0J7nMj.mjs} +864 -118
  52. package/dist/node/document-drive-CI0J7nMj.mjs.map +1 -0
  53. package/dist/node/document-models/index.mjs +1 -1
  54. package/dist/node/{documents-BFBPmyw1.mjs → documents-DCf53bzO.mjs} +3 -3
  55. package/dist/node/{documents-BFBPmyw1.mjs.map → documents-DCf53bzO.mjs.map} +1 -1
  56. package/dist/node/{editor-DkT0krRE.mjs → editor-Cr-mNQca.mjs} +10 -142
  57. package/dist/node/editor-Cr-mNQca.mjs.map +1 -0
  58. package/dist/node/editor-aIeTo2EE.mjs +25 -0
  59. package/dist/node/editor-aIeTo2EE.mjs.map +1 -0
  60. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  61. package/dist/node/editors/generic-drive-explorer/index.mjs +5 -5
  62. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  63. package/dist/{browser/folder-view-BQWrt8wh.js → node/folder-view-_x1OBYZN.mjs} +53 -45
  64. package/dist/node/folder-view-_x1OBYZN.mjs.map +1 -0
  65. package/dist/node/{graphql-DskHmkMe.mjs → graphql-BfAoPeWM.mjs} +2 -2
  66. package/dist/node/{graphql-DskHmkMe.mjs.map → graphql-BfAoPeWM.mjs.map} +1 -1
  67. package/dist/node/{graphql-editor-x-d_DoqN.mjs → graphql-editor-Dd2_z5QJ.mjs} +7 -7
  68. package/dist/node/{graphql-editor-x-d_DoqN.mjs.map → graphql-editor-Dd2_z5QJ.mjs.map} +1 -1
  69. package/dist/node/{hooks-DJrjfVaS.mjs → hooks-D0DcS3MV.mjs} +2 -2
  70. package/dist/node/{hooks-DJrjfVaS.mjs.map → hooks-D0DcS3MV.mjs.map} +1 -1
  71. package/dist/node/index.mjs +2 -2
  72. package/dist/node/index.mjs.map +1 -1
  73. package/dist/node/{json-editor-D8QbP3jl.mjs → json-editor-Dphg6ZeL.mjs} +4 -4
  74. package/dist/node/{json-editor-D8QbP3jl.mjs.map → json-editor-Dphg6ZeL.mjs.map} +1 -1
  75. package/dist/node/{linting-Dx50GuLN.mjs → linting-BjvRPjCY.mjs} +5 -5
  76. package/dist/node/{linting-Dx50GuLN.mjs.map → linting-BjvRPjCY.mjs.map} +1 -1
  77. package/dist/node/{main-D82dkD7g.mjs → main-Db0ei9wX.mjs} +14 -4
  78. package/dist/node/main-Db0ei9wX.mjs.map +1 -0
  79. package/dist/node/{schema-context-CX5ml_9t.mjs → schema-context-DL8jhi_d.mjs} +3 -3
  80. package/dist/node/{schema-context-CX5ml_9t.mjs.map → schema-context-DL8jhi_d.mjs.map} +1 -1
  81. package/dist/node/{state-schemas-BwvZVEhR.mjs → state-schemas-BSLgTw2O.mjs} +8 -8
  82. package/dist/node/{state-schemas-BwvZVEhR.mjs.map → state-schemas-BSLgTw2O.mjs.map} +1 -1
  83. package/package.json +6 -6
  84. package/dist/browser/connect-CV-z3DqA.js.map +0 -1
  85. package/dist/browser/dist-BEs8jMgM.js.map +0 -1
  86. package/dist/browser/document-drive-sTKoi6L4.js.map +0 -1
  87. package/dist/browser/documents-D4ek7Ubv.js.map +0 -1
  88. package/dist/browser/editor-Cw38euRs.js.map +0 -1
  89. package/dist/browser/editor-DY3JsQJ3.js +0 -29
  90. package/dist/browser/editor-DY3JsQJ3.js.map +0 -1
  91. package/dist/browser/folder-view-BQWrt8wh.js.map +0 -1
  92. package/dist/browser/lib-C-f3izXz.js.map +0 -1
  93. package/dist/node/connect-Bbi5wHyR.mjs.map +0 -1
  94. package/dist/node/dist-8nCvrie2.mjs.map +0 -1
  95. package/dist/node/document-drive-DjL9iikf.mjs.map +0 -1
  96. package/dist/node/editor-BH2gCDjt.mjs +0 -29
  97. package/dist/node/editor-BH2gCDjt.mjs.map +0 -1
  98. package/dist/node/editor-DkT0krRE.mjs.map +0 -1
  99. package/dist/node/folder-view-DjKO1mAh.mjs.map +0 -1
  100. package/dist/node/main-D82dkD7g.mjs.map +0 -1
@@ -1,9 +1,10 @@
1
- import { E as __commonJSMin, j as __toESM, t as capitalCase } from "./dist-fA4EItr0.mjs";
2
- import { B as setName, C as createZip, J as validateModules, X as generateId, Y as validateStateSchemaName, _ as baseLoadFromInputVersioned, a as handleTargetNameCollisions, b as createPresignedHeader, c as moveNode, d as logger, g as baseLoadFromInput, i as generateNodesCopy, j as replayDocumentVersioned, l as updateNode, n as copyNode, o as isFileNode, q as validateInitialState, s as isFolderNode, t as addFolder$1, v as baseSaveToFileHandle, y as buildSignedAction } from "./document-drive-DjL9iikf.mjs";
3
- import { a as DriveCollectionId, i as SyncStatus, o as ModuleNotFoundError, t as require_main } from "./main-D82dkD7g.mjs";
4
- import { Children, cloneElement, forwardRef, isValidElement, use, useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
1
+ import { D as __commonJSMin, M as __toESM, t as capitalCase } from "./dist-DT7jI9ol.mjs";
2
+ import { $ as generateId, P as replayDocumentVersioned, Q as validateStateSchemaName, S as createPresignedHeader, T as createZip, U as setName, X as validateInitialState, Z as validateModules, a as handleTargetNameCollisions, b as baseSaveToFileHandle, f as logger, g as assertAuthPreservedOnDuplicate, i as generateNodesCopy, l as moveNode, n as copyNode, o as isFileNode, s as isFolderNode, t as addFolder, u as updateNode, v as baseLoadFromInput, x as buildSignedAction, y as baseLoadFromInputVersioned } from "./document-drive-CI0J7nMj.mjs";
3
+ import { a as DriveCollectionId, i as SyncStatus, o as ModuleNotFoundError, t as require_main } from "./main-Db0ei9wX.mjs";
4
+ import { t as require_graphql } from "./graphql-BfAoPeWM.mjs";
5
+ import { createContext, use, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
5
6
  import "react/jsx-runtime";
6
- //#region ../reactor-browser/dist/make-ph-event-functions-BHoLPif5.js
7
+ //#region ../reactor-browser/dist/make-ph-event-functions-DBq3iWYn.js
7
8
  const isServer$1 = typeof window === "undefined";
8
9
  function makePHEventFunctions(key) {
9
10
  const setEventName = `ph:set${capitalCase(key)}`;
@@ -51,7 +52,7 @@ function makePHEventFunctions(key) {
51
52
  };
52
53
  }
53
54
  //#endregion
54
- //#region ../reactor-browser/dist/document-by-id-dLYFX-xz.js
55
+ //#region ../reactor-browser/dist/document-by-id-BPj6Gd7n.js
55
56
  async function queueActions(document, actionOrActions) {
56
57
  if (!document) throw new Error("No document provided");
57
58
  if (!actionOrActions) throw new Error("No actions provided");
@@ -97,12 +98,12 @@ async function uploadOperations(documentId, allOperations, pushOperations, optio
97
98
  logger.verbose(`uploadDocumentOperations:for:waitForUpdate(${documentId}): END`);
98
99
  }
99
100
  async function signAction(action, document) {
100
- const reactor = window.ph?.reactorClient;
101
- if (!reactor) return action;
102
- const reducer = (await reactor.getDocumentModelModule(document.header.documentType)).reducer;
103
101
  const renown = window.ph?.renown;
104
102
  if (!renown?.user) return action;
105
103
  if (!action.context?.signer) return action;
104
+ const reactorClient = window.ph?.reactorClientModule?.client;
105
+ if (!reactorClient) return action;
106
+ const reducer = (await reactorClient.getDocumentModelModule(document.header.documentType)).reducer;
106
107
  const actionSigner = action.context.signer;
107
108
  return await buildSignedAction(action, reducer, document, actionSigner, renown.crypto.sign);
108
109
  }
@@ -180,6 +181,21 @@ async function dispatchActions(actionOrActions, documentOrDocumentId, onErrors,
180
181
  if (onSuccess && result) onSuccess(result);
181
182
  return result;
182
183
  }
184
+ /**
185
+ * The reactor's `DocumentChangeType` members, typed as the enum so they can be
186
+ * assigned to `DocumentChangeEvent.type`. The assertion is unavoidable - a
187
+ * TypeScript string enum is nominal, so no string literal is assignable to it
188
+ * without one - and the two checks above are what make it safe.
189
+ */
190
+ const DOCUMENT_CHANGE_TYPE = {
191
+ Created: "created",
192
+ Deleted: "deleted",
193
+ Updated: "updated",
194
+ ParentAdded: "parent_added",
195
+ ParentRemoved: "parent_removed",
196
+ ChildAdded: "child_added",
197
+ ChildRemoved: "child_removed"
198
+ };
183
199
  const documentEventFunctions = makePHEventFunctions("documentCache");
184
200
  /** Returns all documents in the reactor. */
185
201
  const useDocumentCache = documentEventFunctions.useValue;
@@ -225,9 +241,27 @@ function useDocumentById(id) {
225
241
  const [, dispatch] = useDispatch(document);
226
242
  return [document, dispatch];
227
243
  }
244
+ Error;
245
+ require_graphql();
246
+ JSON;
228
247
  //#endregion
229
- //#region ../reactor-browser/dist/client-_Gh2Uf0E.js
248
+ //#region ../reactor-browser/dist/client-s_ISz_Zs.js
230
249
  var import_main = require_main();
250
+ let DocumentChangeType = /* @__PURE__ */ function(DocumentChangeType) {
251
+ DocumentChangeType["ChildAdded"] = "CHILD_ADDED";
252
+ DocumentChangeType["ChildRemoved"] = "CHILD_REMOVED";
253
+ DocumentChangeType["Created"] = "CREATED";
254
+ DocumentChangeType["Deleted"] = "DELETED";
255
+ DocumentChangeType["ParentAdded"] = "PARENT_ADDED";
256
+ DocumentChangeType["ParentRemoved"] = "PARENT_REMOVED";
257
+ DocumentChangeType["Updated"] = "UPDATED";
258
+ return DocumentChangeType;
259
+ }({});
260
+ let PropagationMode = /* @__PURE__ */ function(PropagationMode) {
261
+ PropagationMode["Cascade"] = "CASCADE";
262
+ PropagationMode["Orphan"] = "ORPHAN";
263
+ return PropagationMode;
264
+ }({});
231
265
  const PhDocumentFieldsFragmentDoc = import_main.gql`
232
266
  fragment PHDocumentFields on PHDocument {
233
267
  id
@@ -288,6 +322,7 @@ const GetDocumentWithOperationsDocument = import_main.gql`
288
322
  hash
289
323
  skip
290
324
  error
325
+ deniedReason
291
326
  id
292
327
  action {
293
328
  id
@@ -400,6 +435,7 @@ const GetDocumentOperationsDocument = import_main.gql`
400
435
  hash
401
436
  skip
402
437
  error
438
+ deniedReason
403
439
  id
404
440
  action {
405
441
  id
@@ -650,6 +686,7 @@ import_main.gql`
650
686
  hash
651
687
  skip
652
688
  error
689
+ deniedReason
653
690
  id
654
691
  action {
655
692
  id
@@ -692,6 +729,7 @@ import_main.gql`
692
729
  deadLetters {
693
730
  documentId
694
731
  error
732
+ errorType
695
733
  }
696
734
  hasMore
697
735
  }
@@ -738,8 +776,17 @@ function extractQueryParts(doc, fallbackBody) {
738
776
  extractSelectionSet(GetDocumentOperationsDocument, "documentOperations", "{ items { index } }");
739
777
  extractQueryParts(GetDocumentDocument, "document(identifier: $identifier) { document { id name documentType state revisionsList { scope revision } createdAtUtcIso lastModifiedAtUtcIso } childIds }");
740
778
  //#endregion
741
- //#region ../reactor-browser/dist/renown-D-1c_Bvx.js
779
+ //#region ../reactor-browser/dist/renown-BZabzj4l.js
742
780
  const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
781
+ const RenownInitialUserContext = createContext({ state: "unknown" });
782
+ /** First-render auth as a three-state value; use this to skip a spinner when anonymous. */
783
+ function useRenownInitialAuth() {
784
+ return useContext(RenownInitialUserContext);
785
+ }
786
+ function useRenownInitialUser() {
787
+ const initial = useRenownInitialAuth();
788
+ return initial.state === "authenticated" ? initial.user : void 0;
789
+ }
743
790
  const renownEventFunctions = makePHEventFunctions("renown");
744
791
  renownEventFunctions.addEventHandler;
745
792
  /** Returns the renown instance */
@@ -748,41 +795,17 @@ renownEventFunctions.setValue;
748
795
  /** Returns the current user from the renown instance, subscribing to user events */
749
796
  function useUser() {
750
797
  const renown = useRenown();
751
- const [user, setUser] = useState(renown?.user);
798
+ const initialUser = useRenownInitialUser();
799
+ const instance = renown ? renown : void 0;
800
+ const [user, setUser] = useState(instance ? instance.user : initialUser);
752
801
  useEffect(() => {
753
- setUser(renown?.user);
754
- if (!renown) return;
755
- return renown.on("user", setUser);
756
- }, [renown]);
757
- return user;
758
- }
759
- function mergeProps(parentProps, childProps) {
760
- const merged = { ...parentProps };
761
- for (const key of Object.keys(childProps)) {
762
- const parentValue = parentProps[key];
763
- const childValue = childProps[key];
764
- if (key === "style") merged[key] = {
765
- ...parentValue,
766
- ...childValue
767
- };
768
- else if (key === "className") merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
769
- else if (typeof parentValue === "function" && typeof childValue === "function") merged[key] = (...args) => {
770
- childValue(...args);
771
- parentValue(...args);
772
- };
773
- else if (childValue !== void 0) merged[key] = childValue;
774
- }
775
- return merged;
776
- }
777
- const Slot = forwardRef(({ children, ...props }, ref) => {
778
- const child = Children.only(children);
779
- if (!isValidElement(child)) return null;
780
- const childElement = child;
781
- const mergedProps = mergeProps(props, childElement.props);
782
- if (ref) mergedProps.ref = ref;
783
- return cloneElement(childElement, mergedProps);
784
- });
785
- Slot.displayName = "Slot";
802
+ if (instance) {
803
+ setUser(instance.user);
804
+ return instance.on("user", setUser);
805
+ }
806
+ }, [instance]);
807
+ return instance ? user : initialUser ?? user;
808
+ }
786
809
  //#endregion
787
810
  //#region ../../node_modules/.pnpm/remeda@2.33.7/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
788
811
  function e$8(e, t, n) {
@@ -907,6 +930,32 @@ function e(e) {
907
930
  let t = !1, n;
908
931
  return () => (t ||= (n = e(), !0), n);
909
932
  }
933
+ var CloseCode = /* @__PURE__ */ ((CloseCode2) => {
934
+ CloseCode2[CloseCode2["InternalServerError"] = 4500] = "InternalServerError";
935
+ CloseCode2[CloseCode2["InternalClientError"] = 4005] = "InternalClientError";
936
+ CloseCode2[CloseCode2["BadRequest"] = 4400] = "BadRequest";
937
+ CloseCode2[CloseCode2["BadResponse"] = 4004] = "BadResponse";
938
+ CloseCode2[CloseCode2["Unauthorized"] = 4401] = "Unauthorized";
939
+ CloseCode2[CloseCode2["Forbidden"] = 4403] = "Forbidden";
940
+ CloseCode2[CloseCode2["SubprotocolNotAcceptable"] = 4406] = "SubprotocolNotAcceptable";
941
+ CloseCode2[CloseCode2["ConnectionInitialisationTimeout"] = 4408] = "ConnectionInitialisationTimeout";
942
+ CloseCode2[CloseCode2["ConnectionAcknowledgementTimeout"] = 4504] = "ConnectionAcknowledgementTimeout";
943
+ CloseCode2[CloseCode2["SubscriberAlreadyExists"] = 4409] = "SubscriberAlreadyExists";
944
+ CloseCode2[CloseCode2["TooManyInitialisationRequests"] = 4429] = "TooManyInitialisationRequests";
945
+ return CloseCode2;
946
+ })(CloseCode || {});
947
+ var MessageType = /* @__PURE__ */ ((MessageType2) => {
948
+ MessageType2["ConnectionInit"] = "connection_init";
949
+ MessageType2["ConnectionAck"] = "connection_ack";
950
+ MessageType2["Ping"] = "ping";
951
+ MessageType2["Pong"] = "pong";
952
+ MessageType2["Subscribe"] = "subscribe";
953
+ MessageType2["Next"] = "next";
954
+ MessageType2["Error"] = "error";
955
+ MessageType2["Complete"] = "complete";
956
+ return MessageType2;
957
+ })(MessageType || {});
958
+ Error;
910
959
  //#endregion
911
960
  //#region ../../node_modules/.pnpm/slug@11.0.1/node_modules/slug/slug.js
912
961
  let base64;
@@ -1694,1075 +1743,449 @@ slug.setLocale = function(locale) {
1694
1743
  defaultLocale = locales[locale] || {};
1695
1744
  };
1696
1745
  //#endregion
1697
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
1698
- const normalizeDescriptors = (error) => {
1699
- CORE_ERROR_PROPS.forEach((propName) => {
1700
- normalizeDescriptor(error, propName);
1701
- });
1702
- };
1703
- const CORE_ERROR_PROPS = [
1704
- "name",
1705
- "message",
1706
- "stack",
1707
- "cause",
1708
- "errors"
1709
- ];
1710
- const normalizeDescriptor = (error, propName) => {
1711
- const descriptor = getDescriptor(error, propName);
1712
- if (descriptor === void 0) return;
1713
- if (isReadonlyGetter(descriptor)) {
1714
- setErrorProperty(error, propName, error[propName]);
1715
- return;
1746
+ //#region ../reactor-browser/dist/document-operations-DvhxGXqI.js
1747
+ var DocumentModelNotFoundError = class extends Error {
1748
+ documentType;
1749
+ name = "DocumentModelNotFoundError";
1750
+ constructor(documentType) {
1751
+ super(`Document model module for type ${documentType} not found`);
1752
+ this.documentType = documentType;
1753
+ }
1754
+ static isError(error) {
1755
+ return Error.isError(error) && error.name === "DocumentModelNotFoundError";
1716
1756
  }
1717
- if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
1718
- };
1719
- const getDescriptor = (value, propName) => {
1720
- const descriptor = Object.getOwnPropertyDescriptor(value, propName);
1721
- if (descriptor !== void 0) return descriptor;
1722
- const prototype = Object.getPrototypeOf(value);
1723
- return prototype === null ? void 0 : getDescriptor(prototype, propName);
1724
- };
1725
- const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
1726
- const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
1727
- const setErrorProperty = (error, propName, value) => {
1728
- setErrorDescriptor(error, propName, { value });
1729
- };
1730
- const setErrorDescriptor = (error, propName, descriptor) => {
1731
- Object.defineProperty(error, propName, {
1732
- ...descriptor,
1733
- ..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
1734
- enumerable: false,
1735
- configurable: true
1736
- });
1737
- };
1738
- //#endregion
1739
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
1740
- const normalizeAggregate = (error, recurse) => {
1741
- if (Array.isArray(error.errors)) setErrorProperty(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
1742
- else if (isAggregateError(error)) setErrorProperty(error, "errors", []);
1743
- else if (error.errors !== void 0) deleteAggregateErrors(error);
1744
- };
1745
- const isDefined = (error) => error !== void 0;
1746
- const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
1747
- const deleteAggregateErrors = (error) => {
1748
- delete error.errors;
1749
- if (error.errors !== void 0) setErrorProperty(error, "errors", []);
1750
- };
1751
- //#endregion
1752
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
1753
- const normalizeCause = (error, recurse) => {
1754
- if (!("cause" in error)) return;
1755
- const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
1756
- if (cause === void 0) delete error.cause;
1757
- else setErrorProperty(error, "cause", cause);
1758
1757
  };
1759
- //#endregion
1760
- //#region ../../node_modules/.pnpm/is-error-instance@3.0.1/node_modules/is-error-instance/build/src/main.js
1761
- const isErrorInstance = (value) => isInstanceOfError(value) || hasErrorTag(value);
1762
- const isInstanceOfError = (value) => {
1763
- try {
1764
- return value instanceof Error;
1765
- } catch {
1766
- return false;
1758
+ var DocumentTypeMismatchError = class extends Error {
1759
+ constructor(documentId, expectedType, actualType) {
1760
+ super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
1767
1761
  }
1768
1762
  };
1769
- const hasErrorTag = (value) => {
1770
- try {
1771
- return ERROR_TAGS.has(Object.prototype.toString.call(value));
1772
- } catch {
1773
- return false;
1763
+ var NoSelectedDocumentError = class extends Error {
1764
+ constructor() {
1765
+ super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
1774
1766
  }
1775
1767
  };
1776
- const ERROR_TAGS = new Set([
1777
- "[object Error]",
1778
- "[object DOMException]",
1779
- "[object DOMError]",
1780
- "[object Exception]"
1781
- ]);
1782
- //#endregion
1783
- //#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
1784
- function isPlainObject(value) {
1785
- if (typeof value !== "object" || value === null) return false;
1786
- const prototype = Object.getPrototypeOf(value);
1787
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
1768
+ function getUserPermissions() {
1769
+ const user = window.ph?.renown?.user;
1770
+ const allowList = window.ph?.allowList;
1771
+ if (!allowList) return {
1772
+ isAllowedToCreateDocuments: true,
1773
+ isAllowedToEditDocuments: true
1774
+ };
1775
+ return {
1776
+ isAllowedToCreateDocuments: allowList.includes(user?.address ?? ""),
1777
+ isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
1778
+ };
1788
1779
  }
1789
- //#endregion
1790
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
1791
- const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
1792
- const isNonConfigurableProp = (error, propName) => {
1793
- const descriptor = Object.getOwnPropertyDescriptor(error, propName);
1794
- return descriptor !== void 0 && !descriptor.configurable;
1795
- };
1796
- const isThrowingProp = (error, propName) => {
1780
+ const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
1781
+ async function downloadFile(document, fileName) {
1797
1782
  try {
1798
- error[propName];
1799
- return false;
1800
- } catch {
1801
- return true;
1783
+ const data = await createZip(document);
1784
+ const blob = new Blob([new Uint8Array(data)], { type: "application/zip" });
1785
+ const link = window.document.createElement("a");
1786
+ link.style.display = "none";
1787
+ link.href = URL.createObjectURL(blob);
1788
+ link.download = fileName;
1789
+ window.document.body.appendChild(link);
1790
+ link.click();
1791
+ window.document.body.removeChild(link);
1792
+ } catch (e) {
1793
+ logger.error(e instanceof Error ? e.message : String(e));
1802
1794
  }
1803
- };
1804
- //#endregion
1805
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
1806
- const setStack = (error) => {
1807
- setErrorProperty(error, "stack", getStack(error.message, error.name));
1808
- };
1809
- const getStack = (message = "", name = "Error") => {
1810
- const { stack } = new (getErrorClass(name))(message);
1811
- return typeof stack === "string" && stack !== "" ? stack : `${name}: ${message}`;
1812
- };
1813
- const getErrorClass = (name) => {
1814
- const descriptor = {
1815
- value: name,
1816
- enumerable: false,
1817
- writable: true,
1818
- configurable: true
1819
- };
1820
- const StackError = Object.defineProperty(class extends Error {}, "name", descriptor);
1821
- Object.defineProperty(StackError.prototype, "name", descriptor);
1822
- return StackError;
1823
- };
1824
- //#endregion
1825
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
1826
- const copyObject = (object) => {
1827
- const objectCopy = {};
1828
- for (const propName of getPropsToCopy(object)) try {
1829
- const value = object[propName];
1830
- const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
1831
- Object.defineProperty(objectCopy, propName, {
1832
- value,
1833
- enumerable,
1834
- configurable,
1835
- writable
1795
+ }
1796
+ async function getDocumentExtension(document) {
1797
+ const documentType = document.header.documentType;
1798
+ let rawExtension;
1799
+ if (documentType === "powerhouse/document-model") rawExtension = document.state.global?.extension;
1800
+ else {
1801
+ const reactorClient = window.ph?.reactorClientModule?.client;
1802
+ if (reactorClient) {
1803
+ const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
1804
+ rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
1805
+ }
1806
+ }
1807
+ return (rawExtension ?? "").replace(/^\.+|\.+$/g, "");
1808
+ }
1809
+ /**
1810
+ * Fetches all operations for a document using cursor-based pagination.
1811
+ * The reactor client handles multi-scope cursors transparently via
1812
+ * composite cursors, so all scopes are fetched in a single paginated stream.
1813
+ */
1814
+ async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
1815
+ const scopes = Object.keys(document.state);
1816
+ const operations = {};
1817
+ for (const scope of scopes) operations[scope] = [];
1818
+ let cursor = "";
1819
+ do {
1820
+ const page = await reactorClient.getOperations(document.header.id, { scopes }, void 0, {
1821
+ cursor,
1822
+ limit: pageSize
1836
1823
  });
1837
- } catch {}
1838
- return objectCopy;
1839
- };
1840
- const getPropsToCopy = (object) => {
1841
- const propNames = getOwnKeys(object);
1842
- for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
1843
- return propNames;
1844
- };
1845
- const getOwnKeys = (object) => {
1824
+ for (const op of page.results) {
1825
+ const scope = op.action.scope ?? "global";
1826
+ if (operations[scope]) operations[scope].push(op);
1827
+ }
1828
+ cursor = page.nextCursor ?? "";
1829
+ } while (cursor);
1830
+ return operations;
1831
+ }
1832
+ function extractInitialState(documentScopeOps) {
1833
+ const upgradeOp = documentScopeOps.find((op) => op.action.type === "UPGRADE_DOCUMENT");
1834
+ if (!upgradeOp) throw new Error("No UPGRADE_DOCUMENT operation found — document is invalid");
1835
+ const input = upgradeOp.action.input;
1836
+ const initialState = input.initialState ?? input.state;
1837
+ if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
1838
+ return initialState;
1839
+ }
1840
+ function filterDomainOperations(operations) {
1841
+ return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
1842
+ }
1843
+ async function exportFile(document, suggestedName) {
1844
+ const reactorClient = window.ph?.reactorClient;
1845
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1846
+ const operations = await fetchDocumentOperations(reactorClient, document);
1847
+ const initialState = extractInitialState(operations["document"] ?? []);
1848
+ const documentWithOps = {
1849
+ ...document,
1850
+ operations,
1851
+ initialState
1852
+ };
1853
+ const extension = await getDocumentExtension(documentWithOps);
1854
+ const baseName = suggestedName || documentWithOps.header.name || "Untitled";
1855
+ const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
1856
+ if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
1846
1857
  try {
1847
- return Reflect.ownKeys(object);
1848
- } catch {
1849
- return [];
1858
+ const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
1859
+ await baseSaveToFileHandle(documentWithOps, fileHandle);
1860
+ return fileHandle;
1861
+ } catch (e) {
1862
+ if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
1850
1863
  }
1851
- };
1852
- const isInheritedProp = (object, propName) => {
1853
- try {
1854
- return propName in object && !Object.hasOwn(object, propName);
1855
- } catch {
1856
- return false;
1857
- }
1858
- };
1859
- //#endregion
1860
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
1861
- const objectifyError = (object) => {
1862
- const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
1863
- const messageA = getMessage(message, objectA);
1864
- const error = newError(name, messageA);
1865
- if (message === messageA) assignObjectProps(error, objectA);
1866
- Object.entries({
1867
- name,
1868
- stack,
1869
- cause,
1870
- errors
1871
- }).forEach(([propName, propValue]) => {
1872
- setNewErrorProperty(error, propName, propValue);
1864
+ }
1865
+ /**
1866
+ * Loads a document file and replays it with version-aware reducers from the registry.
1867
+ * Falls back to single-version legacy replay when no upgrade manifest is registered for
1868
+ * the document type.
1869
+ */
1870
+ async function loadFile(path) {
1871
+ const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
1872
+ const reactorClient = window.ph?.reactorClientModule?.client;
1873
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1874
+ const documentType = baseDocument.header.documentType;
1875
+ const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
1876
+ const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
1877
+ if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
1878
+ const reducers = {};
1879
+ for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
1880
+ const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
1881
+ let upgradeManifest;
1882
+ if (registry) try {
1883
+ upgradeManifest = registry.getUpgradeManifest(documentType);
1884
+ } catch {}
1885
+ return baseLoadFromInputVersioned(path, {
1886
+ reducers,
1887
+ upgradeManifest
1873
1888
  });
1874
- if (stack === void 0) setStack(error);
1875
- return error;
1876
- };
1877
- const getMessage = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
1878
- const safeJsonStringify = (object) => {
1879
- try {
1880
- return JSON.stringify(object);
1881
- } catch {
1882
- return safeStringify(object);
1883
- }
1884
- };
1885
- const safeStringify = (object) => {
1889
+ }
1890
+ async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
1891
+ const { isAllowedToCreateDocuments } = getUserPermissions();
1892
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
1893
+ const reactorClient = window.ph?.reactorClientModule?.client;
1894
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1895
+ const documentModelModule = await reactorClient.getDocumentModelModule(documentType);
1896
+ const newDocument = document ?? documentModelModule.utils.createDocument();
1897
+ newDocument.header.name = name;
1898
+ if (preferredEditor) newDocument.header.meta = {
1899
+ ...newDocument.header.meta,
1900
+ preferredEditor
1901
+ };
1902
+ let newDoc;
1886
1903
  try {
1887
- return String(object);
1888
- } catch {
1889
- return "Invalid error";
1904
+ newDoc = await reactorClient.drives.addFile(driveId, newDocument, parentFolder);
1905
+ } catch (e) {
1906
+ logger.error("Error adding document: @error", e);
1907
+ throw new Error("There was an error adding document", { cause: e });
1890
1908
  }
1891
- };
1892
- const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
1893
- const MESSAGE_MAX_SIZE = 1e3;
1894
- const newError = (name, message) => {
1895
- if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
1896
- if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
1897
- return new Error(message);
1898
- };
1899
- const NATIVE_ERRORS = {
1900
- Error,
1901
- ReferenceError,
1902
- TypeError,
1903
- SyntaxError,
1904
- RangeError,
1905
- URIError,
1906
- EvalError
1907
- };
1908
- const assignObjectProps = (error, object) => {
1909
- for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
1910
- };
1911
- const setNewErrorProperty = (error, propName, propValue) => {
1912
- if (propValue !== void 0) setErrorProperty(error, propName, propValue);
1913
- };
1914
- //#endregion
1915
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
1916
- const stringifyError = (value) => {
1909
+ return {
1910
+ id: newDoc.header.id,
1911
+ name: newDoc.header.name,
1912
+ documentType,
1913
+ parentFolder: parentFolder ?? null,
1914
+ kind: "file"
1915
+ };
1916
+ }
1917
+ async function addFile(file, driveId, name, parentFolder) {
1918
+ logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
1919
+ const { isAllowedToCreateDocuments } = getUserPermissions();
1920
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
1921
+ const document = await loadFile(file);
1922
+ let duplicateId = false;
1923
+ const reactorClient = window.ph?.reactorClient;
1924
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1917
1925
  try {
1918
- const error = new Error(String(value));
1919
- setStack(error);
1920
- return error;
1921
- } catch (error_) {
1922
- return error_;
1926
+ await reactorClient.get(document.header.id);
1927
+ duplicateId = true;
1928
+ } catch {}
1929
+ const documentId = duplicateId ? generateId() : document.header.id;
1930
+ const header = createPresignedHeader(documentId, document.header.documentType);
1931
+ header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
1932
+ header.meta = document.header.meta;
1933
+ header.name = name || document.header.name;
1934
+ const initialDocument = {
1935
+ ...document,
1936
+ header,
1937
+ state: document.initialState,
1938
+ operations: Object.keys(document.operations).reduce((acc, key) => {
1939
+ acc[key] = [];
1940
+ return acc;
1941
+ }, {})
1942
+ };
1943
+ await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
1944
+ await uploadOperations(documentId, filterDomainOperations(document.operations), queueOperations);
1945
+ }
1946
+ async function addFolder$1(driveId, name, parentFolder) {
1947
+ const { isAllowedToCreateDocuments } = getUserPermissions();
1948
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
1949
+ const reactorClient = window.ph?.reactorClient;
1950
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1951
+ await reactorClient.get(driveId);
1952
+ const folderId = generateId();
1953
+ const node = (await reactorClient.execute(driveId, "main", [addFolder({
1954
+ id: folderId,
1955
+ name,
1956
+ parentFolder
1957
+ })])).state.global.nodes.find((node) => node.id === folderId);
1958
+ if (!node || !isFolderNode(node)) throw new Error("There was an error adding folder");
1959
+ return node;
1960
+ }
1961
+ async function renameNode(driveId, nodeId, name) {
1962
+ const { isAllowedToCreateDocuments } = getUserPermissions();
1963
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
1964
+ const reactorClient = window.ph?.reactorClient;
1965
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1966
+ if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
1967
+ const node = (await reactorClient.execute(driveId, "main", [updateNode({
1968
+ id: nodeId,
1969
+ name
1970
+ })])).state.global.nodes.find((n) => n.id === nodeId);
1971
+ if (!node) throw new Error("There was an error renaming node in the drive");
1972
+ return node;
1973
+ }
1974
+ async function renameDriveNode(driveId, nodeId, name) {
1975
+ const { isAllowedToCreateDocuments } = getUserPermissions();
1976
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
1977
+ const reactorClient = window.ph?.reactorClient;
1978
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1979
+ if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
1980
+ await reactorClient.execute(driveId, "main", [updateNode({
1981
+ id: nodeId,
1982
+ name
1983
+ })]);
1984
+ return (await reactorClient.get(driveId)).state.global.nodes.find((n) => n.id === nodeId);
1985
+ }
1986
+ async function moveNodeById(args) {
1987
+ const { driveId, srcId, targetId } = args;
1988
+ if (!driveId || !srcId) return;
1989
+ const { isAllowedToCreateDocuments } = getUserPermissions();
1990
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
1991
+ const reactorClient = window.ph?.reactorClient;
1992
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
1993
+ const targetParentFolder = t$3(targetId, [e$3(e$4), e$6(void 0)], [t(driveId), e$6(void 0)], e$6(targetId));
1994
+ if (t(targetParentFolder, srcId)) return;
1995
+ return await reactorClient.execute(driveId, "main", [moveNode({
1996
+ srcFolder: srcId,
1997
+ targetParentFolder
1998
+ })]);
1999
+ }
2000
+ async function moveNode$1(driveId, src, target) {
2001
+ const { isAllowedToCreateDocuments } = getUserPermissions();
2002
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
2003
+ const reactorClient = window.ph?.reactorClient;
2004
+ if (!reactorClient) throw new Error("ReactorClient not initialized");
2005
+ return await reactorClient.execute(driveId, "main", [moveNode({
2006
+ srcFolder: src.id,
2007
+ targetParentFolder: target?.id
2008
+ })]);
2009
+ }
2010
+ /**
2011
+ * Duplicates a document under a new id using version-aware replay.
2012
+ * Falls back gracefully when no upgrade manifest is registered for the document type.
2013
+ */
2014
+ async function _duplicateDocument(reactor, document, newId = generateId()) {
2015
+ const documentType = document.header.documentType;
2016
+ const { results: allModules } = await reactor.getDocumentModelModules();
2017
+ const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
2018
+ const reducers = {};
2019
+ for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
2020
+ if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
2021
+ const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
2022
+ let upgradeManifest;
2023
+ if (registry) try {
2024
+ upgradeManifest = registry.getUpgradeManifest(documentType);
2025
+ } catch {}
2026
+ const config = {
2027
+ reducers,
2028
+ upgradeManifest
2029
+ };
2030
+ const header = createPresignedHeader(newId, documentType);
2031
+ const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
2032
+ assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
2033
+ return duplicated;
2034
+ }
2035
+ async function copyNode$1(driveId, src, target) {
2036
+ const reactor = window.ph?.reactorClientModule?.client;
2037
+ if (!reactor) return;
2038
+ const { isAllowedToCreateDocuments } = getUserPermissions();
2039
+ if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
2040
+ const drive = await reactor.get(driveId);
2041
+ const copyNodesInput = generateNodesCopy({
2042
+ srcId: src.id,
2043
+ targetParentFolder: target?.id,
2044
+ targetName: src.name
2045
+ }, () => generateId(), drive.state.global.nodes);
2046
+ const resolvedNamesMap = /* @__PURE__ */ new Map();
2047
+ for (const copyNodeInput of copyNodesInput) {
2048
+ const node = drive.state.global.nodes.find((n) => n.id === copyNodeInput.srcId);
2049
+ if (node) {
2050
+ const resolvedName = handleTargetNameCollisions({
2051
+ nodes: drive.state.global.nodes,
2052
+ srcName: copyNodeInput.targetName || node.name,
2053
+ srcKind: isFileNode(node) ? "file" : "folder",
2054
+ targetParentFolder: copyNodeInput.targetParentFolder || null
2055
+ });
2056
+ resolvedNamesMap.set(copyNodeInput.targetId, resolvedName);
2057
+ }
1923
2058
  }
1924
- };
1925
- //#endregion
1926
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
1927
- const { toString: objectToString } = Object.prototype;
1928
- const createError = (value) => {
1929
- if (isErrorPlainObj(value)) return objectifyError(value);
1930
- if (!isErrorInstance(value)) return stringifyError(value);
1931
- if (isInvalidError(value)) return objectifyError(value);
1932
- return value;
1933
- };
1934
- const isErrorPlainObj = (value) => {
1935
- try {
1936
- return isPlainObject(value);
1937
- } catch {
1938
- return false;
1939
- }
1940
- };
1941
- const isInvalidError = (value) => isProxy(value) || isNonModifiableError(value) || hasInvalidConstructor(value);
1942
- const isProxy = (value) => {
1943
- try {
1944
- return objectToString.call(value) === "[object Object]";
1945
- } catch {
1946
- return true;
2059
+ const fileNodesToCopy = copyNodesInput.filter((copyNodeInput) => {
2060
+ const node = drive.state.global.nodes.find((node) => node.id === copyNodeInput.srcId);
2061
+ return node !== void 0 && isFileNode(node);
2062
+ });
2063
+ for (const fileNodeToCopy of fileNodesToCopy) try {
2064
+ const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
2065
+ const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
2066
+ if (resolvedName) duplicatedDocument.header.name = resolvedName;
2067
+ await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
2068
+ } catch (e) {
2069
+ logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
1947
2070
  }
2071
+ return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
2072
+ }
2073
+ const modalEventFunctions = makePHEventFunctions("modal");
2074
+ modalEventFunctions.useValue;
2075
+ /** Sets the current modal */
2076
+ const setPHModal = modalEventFunctions.setValue;
2077
+ modalEventFunctions.addEventHandler;
2078
+ /** Shows a modal */
2079
+ function showPHModal(modal) {
2080
+ setPHModal(modal);
2081
+ }
2082
+ /** Shows the delete node modal */
2083
+ function showDeleteNodeModal(nodeOrId) {
2084
+ setPHModal({
2085
+ type: "deleteItem",
2086
+ id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
2087
+ });
2088
+ }
2089
+ /**
2090
+ * The operation selection of `GetDocumentOperations`, lifted into a fragment so
2091
+ * the write path can reuse `remoteOperationToLocal` on the items it selects.
2092
+ */
2093
+ const ReactorOperationFieldsFragmentDoc = import_main.gql`
2094
+ fragment ReactorOperationFields on ReactorOperation {
2095
+ index
2096
+ timestampUtcMs
2097
+ hash
2098
+ skip
2099
+ error
2100
+ deniedReason
2101
+ id
2102
+ action {
2103
+ id
2104
+ type
2105
+ timestampUtcMs
2106
+ input
2107
+ scope
2108
+ context {
2109
+ signer {
2110
+ user {
2111
+ address
2112
+ networkId
2113
+ chainId
2114
+ }
2115
+ app {
2116
+ name
2117
+ key
2118
+ }
2119
+ signatures
2120
+ }
2121
+ }
2122
+ }
2123
+ }
2124
+ `;
2125
+ import_main.gql`
2126
+ mutation MutateDocumentWithOperations(
2127
+ $documentIdentifier: String!
2128
+ $actions: [JSONObject!]!
2129
+ $view: ViewFilterInput
2130
+ $sinceRevision: Int
2131
+ $scopes: [String!]
2132
+ $branch: String
2133
+ ) {
2134
+ mutateDocument(
2135
+ documentIdentifier: $documentIdentifier
2136
+ actions: $actions
2137
+ view: $view
2138
+ ) {
2139
+ ...PHDocumentFields
2140
+ operations(
2141
+ filter: {
2142
+ sinceRevision: $sinceRevision
2143
+ scopes: $scopes
2144
+ branch: $branch
2145
+ }
2146
+ ) {
2147
+ items {
2148
+ ...ReactorOperationFields
2149
+ }
2150
+ }
2151
+ }
2152
+ }
2153
+ ${PhDocumentFieldsFragmentDoc}
2154
+ ${ReactorOperationFieldsFragmentDoc}
2155
+ `;
2156
+ DocumentChangeType.Created, DOCUMENT_CHANGE_TYPE.Created, DocumentChangeType.Deleted, DOCUMENT_CHANGE_TYPE.Deleted, DocumentChangeType.Updated, DOCUMENT_CHANGE_TYPE.Updated, DocumentChangeType.ParentAdded, DOCUMENT_CHANGE_TYPE.ParentAdded, DocumentChangeType.ParentRemoved, DOCUMENT_CHANGE_TYPE.ParentRemoved, DocumentChangeType.ChildAdded, DOCUMENT_CHANGE_TYPE.ChildAdded, DocumentChangeType.ChildRemoved, DOCUMENT_CHANGE_TYPE.ChildRemoved;
2157
+ PropagationMode.Cascade, PropagationMode.Orphan;
2158
+ const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
2159
+ /** Sets whether external controls are enabled for a given editor. */
2160
+ const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
2161
+ /** Gets whether external controls are enabled for a given editor. */
2162
+ const useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
2163
+ isExternalControlsEnabledEventFunctions.addEventHandler;
2164
+ const isDragAndDropEnabledEventFunctions = makePHEventFunctions("isDragAndDropEnabled");
2165
+ /** Sets whether drag and drop is enabled for a given app. */
2166
+ const setIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.setValue;
2167
+ /** Gets whether drag and drop is enabled for a given app. */
2168
+ const useIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.useValue;
2169
+ isDragAndDropEnabledEventFunctions.addEventHandler;
2170
+ const allowedDocumentTypesEventFunctions = makePHEventFunctions("allowedDocumentTypes");
2171
+ /** Sets the allowed document types for a given app. */
2172
+ const setAllowedDocumentTypes = allowedDocumentTypesEventFunctions.setValue;
2173
+ /** Defines the document types a drive supports.
2174
+ *
2175
+ * Defaults to all of the document types registered in the reactor.
2176
+ */
2177
+ function useAllowedDocumentTypes() {
2178
+ return allowedDocumentTypesEventFunctions.useValue();
2179
+ }
2180
+ allowedDocumentTypesEventFunctions.addEventHandler;
2181
+ const phAppConfigSetters = {
2182
+ allowedDocumentTypes: setAllowedDocumentTypes,
2183
+ isDragAndDropEnabled: setIsDragAndDropEnabled
1948
2184
  };
1949
- const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
1950
- //#endregion
1951
- //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
1952
- const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
1953
- const recurseException = (error, parents, shallow) => {
1954
- if (parents.includes(error)) return;
1955
- const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
1956
- const errorA = createError(error);
1957
- normalizeProps(errorA, recurse);
1958
- return errorA;
1959
- };
1960
- const identity = (error) => error;
1961
- const normalizeProps = (error, recurse) => {
1962
- normalizeName(error);
1963
- normalizeMessage(error);
1964
- normalizeStack(error);
1965
- normalizeCause(error, recurse);
1966
- normalizeAggregate(error, recurse);
1967
- normalizeDescriptors(error);
1968
- };
1969
- const normalizeName = (error) => {
1970
- if (isDefinedString(error.name)) return;
1971
- const prototypeName = Object.getPrototypeOf(error).name;
1972
- setErrorProperty(error, "name", isDefinedString(prototypeName) ? prototypeName : error.constructor.name);
1973
- };
1974
- const normalizeMessage = (error) => {
1975
- if (!isDefinedString(error.message)) setErrorProperty(error, "message", "");
1976
- };
1977
- const normalizeStack = (error) => {
1978
- if (!isDefinedString(error.stack)) setStack(error);
1979
- };
1980
- const isDefinedString = (value) => typeof value === "string" && value !== "";
1981
- //#endregion
1982
- //#region ../reactor-browser/dist/index.js
1983
- var import_lz_string = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1984
- var LZString = (function() {
1985
- var f = String.fromCharCode;
1986
- var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
1987
- var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
1988
- var baseReverseDic = {};
1989
- function getBaseValue(alphabet, character) {
1990
- if (!baseReverseDic[alphabet]) {
1991
- baseReverseDic[alphabet] = {};
1992
- for (var i = 0; i < alphabet.length; i++) baseReverseDic[alphabet][alphabet.charAt(i)] = i;
1993
- }
1994
- return baseReverseDic[alphabet][character];
1995
- }
1996
- var LZString = {
1997
- compressToBase64: function(input) {
1998
- if (input == null) return "";
1999
- var res = LZString._compress(input, 6, function(a) {
2000
- return keyStrBase64.charAt(a);
2001
- });
2002
- switch (res.length % 4) {
2003
- default:
2004
- case 0: return res;
2005
- case 1: return res + "===";
2006
- case 2: return res + "==";
2007
- case 3: return res + "=";
2008
- }
2009
- },
2010
- decompressFromBase64: function(input) {
2011
- if (input == null) return "";
2012
- if (input == "") return null;
2013
- return LZString._decompress(input.length, 32, function(index) {
2014
- return getBaseValue(keyStrBase64, input.charAt(index));
2015
- });
2016
- },
2017
- compressToUTF16: function(input) {
2018
- if (input == null) return "";
2019
- return LZString._compress(input, 15, function(a) {
2020
- return f(a + 32);
2021
- }) + " ";
2022
- },
2023
- decompressFromUTF16: function(compressed) {
2024
- if (compressed == null) return "";
2025
- if (compressed == "") return null;
2026
- return LZString._decompress(compressed.length, 16384, function(index) {
2027
- return compressed.charCodeAt(index) - 32;
2028
- });
2029
- },
2030
- compressToUint8Array: function(uncompressed) {
2031
- var compressed = LZString.compress(uncompressed);
2032
- var buf = new Uint8Array(compressed.length * 2);
2033
- for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
2034
- var current_value = compressed.charCodeAt(i);
2035
- buf[i * 2] = current_value >>> 8;
2036
- buf[i * 2 + 1] = current_value % 256;
2037
- }
2038
- return buf;
2039
- },
2040
- decompressFromUint8Array: function(compressed) {
2041
- if (compressed === null || compressed === void 0) return LZString.decompress(compressed);
2042
- else {
2043
- var buf = new Array(compressed.length / 2);
2044
- for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
2045
- var result = [];
2046
- buf.forEach(function(c) {
2047
- result.push(f(c));
2048
- });
2049
- return LZString.decompress(result.join(""));
2050
- }
2051
- },
2052
- compressToEncodedURIComponent: function(input) {
2053
- if (input == null) return "";
2054
- return LZString._compress(input, 6, function(a) {
2055
- return keyStrUriSafe.charAt(a);
2056
- });
2057
- },
2058
- decompressFromEncodedURIComponent: function(input) {
2059
- if (input == null) return "";
2060
- if (input == "") return null;
2061
- input = input.replace(/ /g, "+");
2062
- return LZString._decompress(input.length, 32, function(index) {
2063
- return getBaseValue(keyStrUriSafe, input.charAt(index));
2064
- });
2065
- },
2066
- compress: function(uncompressed) {
2067
- return LZString._compress(uncompressed, 16, function(a) {
2068
- return f(a);
2069
- });
2070
- },
2071
- _compress: function(uncompressed, bitsPerChar, getCharFromInt) {
2072
- if (uncompressed == null) return "";
2073
- var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
2074
- for (ii = 0; ii < uncompressed.length; ii += 1) {
2075
- context_c = uncompressed.charAt(ii);
2076
- if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
2077
- context_dictionary[context_c] = context_dictSize++;
2078
- context_dictionaryToCreate[context_c] = true;
2079
- }
2080
- context_wc = context_w + context_c;
2081
- if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) context_w = context_wc;
2082
- else {
2083
- if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
2084
- if (context_w.charCodeAt(0) < 256) {
2085
- for (i = 0; i < context_numBits; i++) {
2086
- context_data_val = context_data_val << 1;
2087
- if (context_data_position == bitsPerChar - 1) {
2088
- context_data_position = 0;
2089
- context_data.push(getCharFromInt(context_data_val));
2090
- context_data_val = 0;
2091
- } else context_data_position++;
2092
- }
2093
- value = context_w.charCodeAt(0);
2094
- for (i = 0; i < 8; i++) {
2095
- context_data_val = context_data_val << 1 | value & 1;
2096
- if (context_data_position == bitsPerChar - 1) {
2097
- context_data_position = 0;
2098
- context_data.push(getCharFromInt(context_data_val));
2099
- context_data_val = 0;
2100
- } else context_data_position++;
2101
- value = value >> 1;
2102
- }
2103
- } else {
2104
- value = 1;
2105
- for (i = 0; i < context_numBits; i++) {
2106
- context_data_val = context_data_val << 1 | value;
2107
- if (context_data_position == bitsPerChar - 1) {
2108
- context_data_position = 0;
2109
- context_data.push(getCharFromInt(context_data_val));
2110
- context_data_val = 0;
2111
- } else context_data_position++;
2112
- value = 0;
2113
- }
2114
- value = context_w.charCodeAt(0);
2115
- for (i = 0; i < 16; i++) {
2116
- context_data_val = context_data_val << 1 | value & 1;
2117
- if (context_data_position == bitsPerChar - 1) {
2118
- context_data_position = 0;
2119
- context_data.push(getCharFromInt(context_data_val));
2120
- context_data_val = 0;
2121
- } else context_data_position++;
2122
- value = value >> 1;
2123
- }
2124
- }
2125
- context_enlargeIn--;
2126
- if (context_enlargeIn == 0) {
2127
- context_enlargeIn = Math.pow(2, context_numBits);
2128
- context_numBits++;
2129
- }
2130
- delete context_dictionaryToCreate[context_w];
2131
- } else {
2132
- value = context_dictionary[context_w];
2133
- for (i = 0; i < context_numBits; i++) {
2134
- context_data_val = context_data_val << 1 | value & 1;
2135
- if (context_data_position == bitsPerChar - 1) {
2136
- context_data_position = 0;
2137
- context_data.push(getCharFromInt(context_data_val));
2138
- context_data_val = 0;
2139
- } else context_data_position++;
2140
- value = value >> 1;
2141
- }
2142
- }
2143
- context_enlargeIn--;
2144
- if (context_enlargeIn == 0) {
2145
- context_enlargeIn = Math.pow(2, context_numBits);
2146
- context_numBits++;
2147
- }
2148
- context_dictionary[context_wc] = context_dictSize++;
2149
- context_w = String(context_c);
2150
- }
2151
- }
2152
- if (context_w !== "") {
2153
- if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
2154
- if (context_w.charCodeAt(0) < 256) {
2155
- for (i = 0; i < context_numBits; i++) {
2156
- context_data_val = context_data_val << 1;
2157
- if (context_data_position == bitsPerChar - 1) {
2158
- context_data_position = 0;
2159
- context_data.push(getCharFromInt(context_data_val));
2160
- context_data_val = 0;
2161
- } else context_data_position++;
2162
- }
2163
- value = context_w.charCodeAt(0);
2164
- for (i = 0; i < 8; i++) {
2165
- context_data_val = context_data_val << 1 | value & 1;
2166
- if (context_data_position == bitsPerChar - 1) {
2167
- context_data_position = 0;
2168
- context_data.push(getCharFromInt(context_data_val));
2169
- context_data_val = 0;
2170
- } else context_data_position++;
2171
- value = value >> 1;
2172
- }
2173
- } else {
2174
- value = 1;
2175
- for (i = 0; i < context_numBits; i++) {
2176
- context_data_val = context_data_val << 1 | value;
2177
- if (context_data_position == bitsPerChar - 1) {
2178
- context_data_position = 0;
2179
- context_data.push(getCharFromInt(context_data_val));
2180
- context_data_val = 0;
2181
- } else context_data_position++;
2182
- value = 0;
2183
- }
2184
- value = context_w.charCodeAt(0);
2185
- for (i = 0; i < 16; i++) {
2186
- context_data_val = context_data_val << 1 | value & 1;
2187
- if (context_data_position == bitsPerChar - 1) {
2188
- context_data_position = 0;
2189
- context_data.push(getCharFromInt(context_data_val));
2190
- context_data_val = 0;
2191
- } else context_data_position++;
2192
- value = value >> 1;
2193
- }
2194
- }
2195
- context_enlargeIn--;
2196
- if (context_enlargeIn == 0) {
2197
- context_enlargeIn = Math.pow(2, context_numBits);
2198
- context_numBits++;
2199
- }
2200
- delete context_dictionaryToCreate[context_w];
2201
- } else {
2202
- value = context_dictionary[context_w];
2203
- for (i = 0; i < context_numBits; i++) {
2204
- context_data_val = context_data_val << 1 | value & 1;
2205
- if (context_data_position == bitsPerChar - 1) {
2206
- context_data_position = 0;
2207
- context_data.push(getCharFromInt(context_data_val));
2208
- context_data_val = 0;
2209
- } else context_data_position++;
2210
- value = value >> 1;
2211
- }
2212
- }
2213
- context_enlargeIn--;
2214
- if (context_enlargeIn == 0) {
2215
- context_enlargeIn = Math.pow(2, context_numBits);
2216
- context_numBits++;
2217
- }
2218
- }
2219
- value = 2;
2220
- for (i = 0; i < context_numBits; i++) {
2221
- context_data_val = context_data_val << 1 | value & 1;
2222
- if (context_data_position == bitsPerChar - 1) {
2223
- context_data_position = 0;
2224
- context_data.push(getCharFromInt(context_data_val));
2225
- context_data_val = 0;
2226
- } else context_data_position++;
2227
- value = value >> 1;
2228
- }
2229
- while (true) {
2230
- context_data_val = context_data_val << 1;
2231
- if (context_data_position == bitsPerChar - 1) {
2232
- context_data.push(getCharFromInt(context_data_val));
2233
- break;
2234
- } else context_data_position++;
2235
- }
2236
- return context_data.join("");
2237
- },
2238
- decompress: function(compressed) {
2239
- if (compressed == null) return "";
2240
- if (compressed == "") return null;
2241
- return LZString._decompress(compressed.length, 32768, function(index) {
2242
- return compressed.charCodeAt(index);
2243
- });
2244
- },
2245
- _decompress: function(length, resetValue, getNextValue) {
2246
- var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = {
2247
- val: getNextValue(0),
2248
- position: resetValue,
2249
- index: 1
2250
- };
2251
- for (i = 0; i < 3; i += 1) dictionary[i] = i;
2252
- bits = 0;
2253
- maxpower = Math.pow(2, 2);
2254
- power = 1;
2255
- while (power != maxpower) {
2256
- resb = data.val & data.position;
2257
- data.position >>= 1;
2258
- if (data.position == 0) {
2259
- data.position = resetValue;
2260
- data.val = getNextValue(data.index++);
2261
- }
2262
- bits |= (resb > 0 ? 1 : 0) * power;
2263
- power <<= 1;
2264
- }
2265
- switch (bits) {
2266
- case 0:
2267
- bits = 0;
2268
- maxpower = Math.pow(2, 8);
2269
- power = 1;
2270
- while (power != maxpower) {
2271
- resb = data.val & data.position;
2272
- data.position >>= 1;
2273
- if (data.position == 0) {
2274
- data.position = resetValue;
2275
- data.val = getNextValue(data.index++);
2276
- }
2277
- bits |= (resb > 0 ? 1 : 0) * power;
2278
- power <<= 1;
2279
- }
2280
- c = f(bits);
2281
- break;
2282
- case 1:
2283
- bits = 0;
2284
- maxpower = Math.pow(2, 16);
2285
- power = 1;
2286
- while (power != maxpower) {
2287
- resb = data.val & data.position;
2288
- data.position >>= 1;
2289
- if (data.position == 0) {
2290
- data.position = resetValue;
2291
- data.val = getNextValue(data.index++);
2292
- }
2293
- bits |= (resb > 0 ? 1 : 0) * power;
2294
- power <<= 1;
2295
- }
2296
- c = f(bits);
2297
- break;
2298
- case 2: return "";
2299
- }
2300
- dictionary[3] = c;
2301
- w = c;
2302
- result.push(c);
2303
- while (true) {
2304
- if (data.index > length) return "";
2305
- bits = 0;
2306
- maxpower = Math.pow(2, numBits);
2307
- power = 1;
2308
- while (power != maxpower) {
2309
- resb = data.val & data.position;
2310
- data.position >>= 1;
2311
- if (data.position == 0) {
2312
- data.position = resetValue;
2313
- data.val = getNextValue(data.index++);
2314
- }
2315
- bits |= (resb > 0 ? 1 : 0) * power;
2316
- power <<= 1;
2317
- }
2318
- switch (c = bits) {
2319
- case 0:
2320
- bits = 0;
2321
- maxpower = Math.pow(2, 8);
2322
- power = 1;
2323
- while (power != maxpower) {
2324
- resb = data.val & data.position;
2325
- data.position >>= 1;
2326
- if (data.position == 0) {
2327
- data.position = resetValue;
2328
- data.val = getNextValue(data.index++);
2329
- }
2330
- bits |= (resb > 0 ? 1 : 0) * power;
2331
- power <<= 1;
2332
- }
2333
- dictionary[dictSize++] = f(bits);
2334
- c = dictSize - 1;
2335
- enlargeIn--;
2336
- break;
2337
- case 1:
2338
- bits = 0;
2339
- maxpower = Math.pow(2, 16);
2340
- power = 1;
2341
- while (power != maxpower) {
2342
- resb = data.val & data.position;
2343
- data.position >>= 1;
2344
- if (data.position == 0) {
2345
- data.position = resetValue;
2346
- data.val = getNextValue(data.index++);
2347
- }
2348
- bits |= (resb > 0 ? 1 : 0) * power;
2349
- power <<= 1;
2350
- }
2351
- dictionary[dictSize++] = f(bits);
2352
- c = dictSize - 1;
2353
- enlargeIn--;
2354
- break;
2355
- case 2: return result.join("");
2356
- }
2357
- if (enlargeIn == 0) {
2358
- enlargeIn = Math.pow(2, numBits);
2359
- numBits++;
2360
- }
2361
- if (dictionary[c]) entry = dictionary[c];
2362
- else if (c === dictSize) entry = w + w.charAt(0);
2363
- else return null;
2364
- result.push(entry);
2365
- dictionary[dictSize++] = w + entry.charAt(0);
2366
- enlargeIn--;
2367
- w = entry;
2368
- if (enlargeIn == 0) {
2369
- enlargeIn = Math.pow(2, numBits);
2370
- numBits++;
2371
- }
2372
- }
2373
- }
2374
- };
2375
- return LZString;
2376
- })();
2377
- if (typeof define === "function" && define.amd) define(function() {
2378
- return LZString;
2379
- });
2380
- else if (typeof module !== "undefined" && module != null) module.exports = LZString;
2381
- else if (typeof angular !== "undefined" && angular != null) angular.module("LZString", []).factory("LZString", function() {
2382
- return LZString;
2383
- });
2384
- })))(), 1);
2385
- var DocumentModelNotFoundError = class extends Error {
2386
- documentType;
2387
- name = "DocumentModelNotFoundError";
2388
- constructor(documentType) {
2389
- super(`Document model module for type ${documentType} not found`);
2390
- this.documentType = documentType;
2391
- }
2392
- static isError(error) {
2393
- return Error.isError(error) && error.name === "DocumentModelNotFoundError";
2394
- }
2395
- };
2396
- var DocumentTypeMismatchError = class extends Error {
2397
- constructor(documentId, expectedType, actualType) {
2398
- super(`Document ${documentId} is not of type ${expectedType}. Actual type: ${actualType}`);
2399
- }
2400
- };
2401
- var NoSelectedDocumentError = class extends Error {
2402
- constructor() {
2403
- super("There is no selected document. Did you mean to call 'useSelectedDocumentSafe' instead?");
2404
- }
2405
- };
2406
- function getUserPermissions() {
2407
- const user = window.ph?.renown?.user;
2408
- const allowList = window.ph?.allowList;
2409
- if (!allowList) return {
2410
- isAllowedToCreateDocuments: true,
2411
- isAllowedToEditDocuments: true
2412
- };
2413
- return {
2414
- isAllowedToCreateDocuments: allowList.includes(user?.address ?? ""),
2415
- isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
2416
- };
2417
- }
2418
- const BASE_STATE_KEYS = new Set(["auth"]);
2419
- const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
2420
- async function downloadFile(document, fileName) {
2421
- try {
2422
- const data = await createZip(document);
2423
- const blob = new Blob([new Uint8Array(data)], { type: "application/zip" });
2424
- const link = window.document.createElement("a");
2425
- link.style.display = "none";
2426
- link.href = URL.createObjectURL(blob);
2427
- link.download = fileName;
2428
- window.document.body.appendChild(link);
2429
- link.click();
2430
- window.document.body.removeChild(link);
2431
- } catch (e) {
2432
- logger.error(e instanceof Error ? e.message : String(e));
2433
- }
2434
- }
2435
- async function getDocumentExtension(document) {
2436
- const documentType = document.header.documentType;
2437
- let rawExtension;
2438
- if (documentType === "powerhouse/document-model") rawExtension = document.state.global?.extension;
2439
- else {
2440
- const reactorClient = window.ph?.reactorClient;
2441
- if (reactorClient) {
2442
- const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
2443
- rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
2444
- }
2445
- }
2446
- return (rawExtension ?? "").replace(/^\.+|\.+$/g, "");
2447
- }
2448
- /**
2449
- * Fetches all operations for a document using cursor-based pagination.
2450
- * The reactor client handles multi-scope cursors transparently via
2451
- * composite cursors, so all scopes are fetched in a single paginated stream.
2452
- */
2453
- async function fetchDocumentOperations(reactorClient, document, pageSize = 100) {
2454
- const scopes = Object.keys(document.state).filter((k) => !BASE_STATE_KEYS.has(k));
2455
- const operations = {};
2456
- for (const scope of scopes) operations[scope] = [];
2457
- let cursor = "";
2458
- do {
2459
- const page = await reactorClient.getOperations(document.header.id, { scopes }, void 0, {
2460
- cursor,
2461
- limit: pageSize
2462
- });
2463
- for (const op of page.results) {
2464
- const scope = op.action.scope ?? "global";
2465
- if (operations[scope]) operations[scope].push(op);
2466
- }
2467
- cursor = page.nextCursor ?? "";
2468
- } while (cursor);
2469
- return operations;
2470
- }
2471
- function extractInitialState(documentScopeOps) {
2472
- const upgradeOp = documentScopeOps.find((op) => op.action.type === "UPGRADE_DOCUMENT");
2473
- if (!upgradeOp) throw new Error("No UPGRADE_DOCUMENT operation found — document is invalid");
2474
- const input = upgradeOp.action.input;
2475
- const initialState = input.initialState ?? input.state;
2476
- if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
2477
- return initialState;
2478
- }
2479
- function filterDomainOperations(operations) {
2480
- return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
2481
- }
2482
- async function exportFile(document, suggestedName) {
2483
- const reactorClient = window.ph?.reactorClient;
2484
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2485
- const operations = await fetchDocumentOperations(reactorClient, document);
2486
- const initialState = extractInitialState(operations["document"] ?? []);
2487
- const documentWithOps = {
2488
- ...document,
2489
- operations,
2490
- initialState
2491
- };
2492
- const extension = await getDocumentExtension(documentWithOps);
2493
- const baseName = suggestedName || documentWithOps.header.name || "Untitled";
2494
- const name = extension ? `${baseName}.${extension}.phd` : `${baseName}.phd`;
2495
- if (!window.showSaveFilePicker) return await downloadFile(documentWithOps, name);
2496
- try {
2497
- const fileHandle = await window.showSaveFilePicker({ suggestedName: name });
2498
- await baseSaveToFileHandle(documentWithOps, fileHandle);
2499
- return fileHandle;
2500
- } catch (e) {
2501
- if (!(e instanceof DOMException && e.name === "AbortError")) throw e;
2502
- }
2503
- }
2504
- /**
2505
- * Loads a document file and replays it with version-aware reducers from the registry.
2506
- * Falls back to single-version legacy replay when no upgrade manifest is registered for
2507
- * the document type.
2508
- */
2509
- async function loadFile(path) {
2510
- const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
2511
- const reactorClient = window.ph?.reactorClient;
2512
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2513
- const documentType = baseDocument.header.documentType;
2514
- const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
2515
- const modulesForType = documentModelModules.filter((module) => module.documentModel.global.id === documentType);
2516
- if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
2517
- const reducers = {};
2518
- for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
2519
- const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
2520
- let upgradeManifest;
2521
- if (registry) try {
2522
- upgradeManifest = registry.getUpgradeManifest(documentType);
2523
- } catch {}
2524
- return baseLoadFromInputVersioned(path, {
2525
- reducers,
2526
- upgradeManifest
2527
- });
2528
- }
2529
- async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor) {
2530
- const { isAllowedToCreateDocuments } = getUserPermissions();
2531
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
2532
- const reactorClient = window.ph?.reactorClient;
2533
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2534
- const documentModelModule = await reactorClient.getDocumentModelModule(documentType);
2535
- const newDocument = document ?? documentModelModule.utils.createDocument();
2536
- newDocument.header.name = name;
2537
- if (preferredEditor) newDocument.header.meta = {
2538
- ...newDocument.header.meta,
2539
- preferredEditor
2540
- };
2541
- let newDoc;
2542
- try {
2543
- newDoc = await reactorClient.drives.addFile(driveId, newDocument, parentFolder);
2544
- } catch (e) {
2545
- logger.error("Error adding document: @error", e);
2546
- throw new Error("There was an error adding document", { cause: e });
2547
- }
2548
- return {
2549
- id: newDoc.header.id,
2550
- name: newDoc.header.name,
2551
- documentType,
2552
- parentFolder: parentFolder ?? null,
2553
- kind: "file"
2554
- };
2555
- }
2556
- async function addFile(file, driveId, name, parentFolder) {
2557
- logger.verbose(`addFile(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
2558
- const { isAllowedToCreateDocuments } = getUserPermissions();
2559
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create files");
2560
- const document = await loadFile(file);
2561
- let duplicateId = false;
2562
- const reactorClient = window.ph?.reactorClient;
2563
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2564
- try {
2565
- await reactorClient.get(document.header.id);
2566
- duplicateId = true;
2567
- } catch {}
2568
- const documentId = duplicateId ? generateId() : document.header.id;
2569
- const header = createPresignedHeader(documentId, document.header.documentType);
2570
- header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
2571
- header.meta = document.header.meta;
2572
- header.name = name || document.header.name;
2573
- const initialDocument = {
2574
- ...document,
2575
- header,
2576
- state: document.initialState,
2577
- operations: Object.keys(document.operations).reduce((acc, key) => {
2578
- acc[key] = [];
2579
- return acc;
2580
- }, {})
2581
- };
2582
- await addDocument(driveId, name || document.header.name, document.header.documentType, parentFolder, initialDocument, documentId, document.header.meta?.preferredEditor);
2583
- await uploadOperations(documentId, filterDomainOperations(document.operations), queueOperations);
2584
- }
2585
- async function addFolder(driveId, name, parentFolder) {
2586
- const { isAllowedToCreateDocuments } = getUserPermissions();
2587
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
2588
- const reactorClient = window.ph?.reactorClient;
2589
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2590
- await reactorClient.get(driveId);
2591
- const folderId = generateId();
2592
- const node = (await reactorClient.execute(driveId, "main", [addFolder$1({
2593
- id: folderId,
2594
- name,
2595
- parentFolder
2596
- })])).state.global.nodes.find((node) => node.id === folderId);
2597
- if (!node || !isFolderNode(node)) throw new Error("There was an error adding folder");
2598
- return node;
2599
- }
2600
- async function renameNode(driveId, nodeId, name) {
2601
- const { isAllowedToCreateDocuments } = getUserPermissions();
2602
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
2603
- const reactorClient = window.ph?.reactorClient;
2604
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2605
- if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
2606
- const node = (await reactorClient.execute(driveId, "main", [updateNode({
2607
- id: nodeId,
2608
- name
2609
- })])).state.global.nodes.find((n) => n.id === nodeId);
2610
- if (!node) throw new Error("There was an error renaming node in the drive");
2611
- return node;
2612
- }
2613
- async function renameDriveNode(driveId, nodeId, name) {
2614
- const { isAllowedToCreateDocuments } = getUserPermissions();
2615
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
2616
- const reactorClient = window.ph?.reactorClient;
2617
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2618
- if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
2619
- await reactorClient.execute(driveId, "main", [updateNode({
2620
- id: nodeId,
2621
- name
2622
- })]);
2623
- return (await reactorClient.get(driveId)).state.global.nodes.find((n) => n.id === nodeId);
2624
- }
2625
- async function moveNodeById(args) {
2626
- const { driveId, srcId, targetId } = args;
2627
- if (!driveId || !srcId) return;
2628
- const { isAllowedToCreateDocuments } = getUserPermissions();
2629
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
2630
- const reactorClient = window.ph?.reactorClient;
2631
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2632
- const targetParentFolder = t$3(targetId, [e$3(e$4), e$6(void 0)], [t(driveId), e$6(void 0)], e$6(targetId));
2633
- if (t(targetParentFolder, srcId)) return;
2634
- return await reactorClient.execute(driveId, "main", [moveNode({
2635
- srcFolder: srcId,
2636
- targetParentFolder
2637
- })]);
2638
- }
2639
- async function moveNode$1(driveId, src, target) {
2640
- const { isAllowedToCreateDocuments } = getUserPermissions();
2641
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
2642
- const reactorClient = window.ph?.reactorClient;
2643
- if (!reactorClient) throw new Error("ReactorClient not initialized");
2644
- return await reactorClient.execute(driveId, "main", [moveNode({
2645
- srcFolder: src.id,
2646
- targetParentFolder: target?.id
2647
- })]);
2648
- }
2649
- /**
2650
- * Duplicates a document under a new id using version-aware replay.
2651
- * Falls back gracefully when no upgrade manifest is registered for the document type.
2652
- */
2653
- async function _duplicateDocument(reactor, document, newId = generateId()) {
2654
- const documentType = document.header.documentType;
2655
- const { results: allModules } = await reactor.getDocumentModelModules();
2656
- const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
2657
- const reducers = {};
2658
- for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
2659
- if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
2660
- const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
2661
- let upgradeManifest;
2662
- if (registry) try {
2663
- upgradeManifest = registry.getUpgradeManifest(documentType);
2664
- } catch {}
2665
- const config = {
2666
- reducers,
2667
- upgradeManifest
2668
- };
2669
- const header = createPresignedHeader(newId, documentType);
2670
- return replayDocumentVersioned(document.initialState, document.operations, config, header);
2671
- }
2672
- async function copyNode$1(driveId, src, target) {
2673
- const reactor = window.ph?.reactorClient;
2674
- if (!reactor) return;
2675
- const { isAllowedToCreateDocuments } = getUserPermissions();
2676
- if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
2677
- const drive = await reactor.get(driveId);
2678
- const copyNodesInput = generateNodesCopy({
2679
- srcId: src.id,
2680
- targetParentFolder: target?.id,
2681
- targetName: src.name
2682
- }, () => generateId(), drive.state.global.nodes);
2683
- const resolvedNamesMap = /* @__PURE__ */ new Map();
2684
- for (const copyNodeInput of copyNodesInput) {
2685
- const node = drive.state.global.nodes.find((n) => n.id === copyNodeInput.srcId);
2686
- if (node) {
2687
- const resolvedName = handleTargetNameCollisions({
2688
- nodes: drive.state.global.nodes,
2689
- srcName: copyNodeInput.targetName || node.name,
2690
- srcKind: isFileNode(node) ? "file" : "folder",
2691
- targetParentFolder: copyNodeInput.targetParentFolder || null
2692
- });
2693
- resolvedNamesMap.set(copyNodeInput.targetId, resolvedName);
2694
- }
2695
- }
2696
- const fileNodesToCopy = copyNodesInput.filter((copyNodeInput) => {
2697
- const node = drive.state.global.nodes.find((node) => node.id === copyNodeInput.srcId);
2698
- return node !== void 0 && isFileNode(node);
2699
- });
2700
- for (const fileNodeToCopy of fileNodesToCopy) try {
2701
- const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
2702
- const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
2703
- if (resolvedName) duplicatedDocument.header.name = resolvedName;
2704
- await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
2705
- } catch (e) {
2706
- logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
2707
- }
2708
- return await queueActions(drive, copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput)));
2709
- }
2710
- const modalEventFunctions = makePHEventFunctions("modal");
2711
- modalEventFunctions.useValue;
2712
- /** Sets the current modal */
2713
- const setPHModal = modalEventFunctions.setValue;
2714
- modalEventFunctions.addEventHandler;
2715
- /** Shows a modal */
2716
- function showPHModal(modal) {
2717
- setPHModal(modal);
2718
- }
2719
- /** Shows the create document modal */
2720
- function showCreateDocumentModal(documentType) {
2721
- setPHModal({
2722
- type: "createDocument",
2723
- documentType
2724
- });
2725
- }
2726
- /** Shows the delete node modal */
2727
- function showDeleteNodeModal(nodeOrId) {
2728
- setPHModal({
2729
- type: "deleteItem",
2730
- id: typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id
2731
- });
2732
- }
2733
- /** Document types that represent a "drive": a container of nodes. */
2734
- const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
2735
- const isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
2736
- /** Sets whether external controls are enabled for a given editor. */
2737
- const setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
2738
- /** Gets whether external controls are enabled for a given editor. */
2739
- const useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
2740
- isExternalControlsEnabledEventFunctions.addEventHandler;
2741
- const isDragAndDropEnabledEventFunctions = makePHEventFunctions("isDragAndDropEnabled");
2742
- /** Sets whether drag and drop is enabled for a given app. */
2743
- const setIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.setValue;
2744
- /** Gets whether drag and drop is enabled for a given app. */
2745
- const useIsDragAndDropEnabled = isDragAndDropEnabledEventFunctions.useValue;
2746
- isDragAndDropEnabledEventFunctions.addEventHandler;
2747
- const allowedDocumentTypesEventFunctions = makePHEventFunctions("allowedDocumentTypes");
2748
- /** Sets the allowed document types for a given app. */
2749
- const setAllowedDocumentTypes = allowedDocumentTypesEventFunctions.setValue;
2750
- /** Defines the document types a drive supports.
2751
- *
2752
- * Defaults to all of the document types registered in the reactor.
2753
- */
2754
- function useAllowedDocumentTypes() {
2755
- return allowedDocumentTypesEventFunctions.useValue();
2756
- }
2757
- allowedDocumentTypesEventFunctions.addEventHandler;
2758
- const phAppConfigSetters = {
2759
- allowedDocumentTypes: setAllowedDocumentTypes,
2760
- isDragAndDropEnabled: setIsDragAndDropEnabled
2761
- };
2762
- const phDocumentEditorConfigSetters = { isExternalControlsEnabled: setIsExternalControlsEnabled };
2763
- const phAppConfigHooks = {
2764
- allowedDocumentTypes: useAllowedDocumentTypes,
2765
- isDragAndDropEnabled: useIsDragAndDropEnabled
2185
+ const phDocumentEditorConfigSetters = { isExternalControlsEnabled: setIsExternalControlsEnabled };
2186
+ const phAppConfigHooks = {
2187
+ allowedDocumentTypes: useAllowedDocumentTypes,
2188
+ isDragAndDropEnabled: useIsDragAndDropEnabled
2766
2189
  };
2767
2190
  const phDocumentEditorConfigHooks = { isExternalControlsEnabled: useIsExternalControlsEnabled };
2768
2191
  const { useValue: useRouterBasename, setValue: setRouterBasename, addEventHandler: addRouterBasenameEventHandler } = makePHEventFunctions("routerBasename");
@@ -2797,6 +2220,8 @@ const { useValue: useIsDriveAnalyticsEnabled, setValue: setIsDriveAnalyticsEnabl
2797
2220
  const { useValue: useRenownUrl, setValue: setRenownUrl, addEventHandler: addRenownUrlEventHandler } = makePHEventFunctions("renownUrl");
2798
2221
  const { useValue: useRenownNetworkId, setValue: setRenownNetworkId, addEventHandler: addRenownNetworkIdEventHandler } = makePHEventFunctions("renownNetworkId");
2799
2222
  const { useValue: useRenownChainId, setValue: setRenownChainId, addEventHandler: addRenownChainIdEventHandler } = makePHEventFunctions("renownChainId");
2223
+ const { useValue: useSwitchboardUrl, setValue: setSwitchboardUrl, addEventHandler: addSwitchboardUrlEventHandler } = makePHEventFunctions("switchboardUrl");
2224
+ const { useValue: useRenownAdapters, setValue: setRenownAdapters, addEventHandler: addRenownAdaptersEventHandler } = makePHEventFunctions("renownAdapters");
2800
2225
  const { useValue: useSentryRelease, setValue: setSentryRelease, addEventHandler: addSentryReleaseEventHandler } = makePHEventFunctions("sentryRelease");
2801
2226
  const { useValue: useSentryDsn, setValue: setSentryDsn, addEventHandler: addSentryDsnEventHandler } = makePHEventFunctions("sentryDsn");
2802
2227
  const { useValue: useSentryEnv, setValue: setSentryEnv, addEventHandler: addSentryEnvEventHandler } = makePHEventFunctions("sentryEnv");
@@ -2894,6 +2319,8 @@ const nonUserConfigSetters = {
2894
2319
  renownUrl: setRenownUrl,
2895
2320
  renownNetworkId: setRenownNetworkId,
2896
2321
  renownChainId: setRenownChainId,
2322
+ switchboardUrl: setSwitchboardUrl,
2323
+ renownAdapters: setRenownAdapters,
2897
2324
  sentryRelease: setSentryRelease,
2898
2325
  sentryDsn: setSentryDsn,
2899
2326
  sentryEnv: setSentryEnv,
@@ -2942,6 +2369,8 @@ const nonUserConfigHooks = {
2942
2369
  renownUrl: useRenownUrl,
2943
2370
  renownNetworkId: useRenownNetworkId,
2944
2371
  renownChainId: useRenownChainId,
2372
+ switchboardUrl: useSwitchboardUrl,
2373
+ renownAdapters: useRenownAdapters,
2945
2374
  sentryRelease: useSentryRelease,
2946
2375
  sentryDsn: useSentryDsn,
2947
2376
  sentryEnv: useSentryEnv,
@@ -2963,374 +2392,1089 @@ const nonUserConfigHooks = {
2963
2392
  ...phDocumentEditorConfigHooks,
2964
2393
  ...nonUserConfigHooks
2965
2394
  });
2966
- const attachmentServiceEventFunctions = makePHEventFunctions("attachmentService");
2967
- attachmentServiceEventFunctions.useValue;
2968
- attachmentServiceEventFunctions.setValue;
2969
- attachmentServiceEventFunctions.addEventHandler;
2970
- const featuresEventFunctions = makePHEventFunctions("features");
2971
- featuresEventFunctions.useValue;
2972
- featuresEventFunctions.setValue;
2973
- featuresEventFunctions.addEventHandler;
2974
- function resolveUrlPathname(path) {
2975
- return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
2395
+ const attachmentServiceEventFunctions = makePHEventFunctions("attachmentService");
2396
+ attachmentServiceEventFunctions.useValue;
2397
+ attachmentServiceEventFunctions.setValue;
2398
+ attachmentServiceEventFunctions.addEventHandler;
2399
+ const featuresEventFunctions = makePHEventFunctions("features");
2400
+ featuresEventFunctions.useValue;
2401
+ featuresEventFunctions.setValue;
2402
+ featuresEventFunctions.addEventHandler;
2403
+ function resolveUrlPathname(path) {
2404
+ return new URL(path.replace(/^\/+/, ""), window.location.origin + (window.ph?.basePath ?? "/")).pathname;
2405
+ }
2406
+ /** Returns the current path without the base path */
2407
+ function getPathWithoutBase(path) {
2408
+ const basePath = window.ph?.basePath ?? "/";
2409
+ return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
2410
+ }
2411
+ /** Makes a URL component for a node. */
2412
+ function makeNodeSlug(node) {
2413
+ if (!node) return "";
2414
+ const nodeName = node.name;
2415
+ if (!nodeName) return slug(node.id);
2416
+ return slug(`${nodeName}-${node.id}`);
2417
+ }
2418
+ /** Extracts the node slug from a path.
2419
+ *
2420
+ * The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.
2421
+ */
2422
+ function extractNodeSlugFromPath(path) {
2423
+ const currentPath = getPathWithoutBase(path);
2424
+ return /^\/d\/[^/]+\/([^/]+)$/.exec(currentPath)?.[1];
2425
+ }
2426
+ /** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */
2427
+ function findUuid(input) {
2428
+ if (!input) return void 0;
2429
+ return /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(input)?.[0];
2430
+ }
2431
+ function extractNodeIdFromSlug(nodeSlug) {
2432
+ return findUuid(nodeSlug);
2433
+ }
2434
+ /** Extracts the drive slug from a path.
2435
+ * Used for extracting drive ids from drive slugs in the URL.
2436
+ * Expects the path to be in the format `/d/<drive-slug>`.
2437
+ */
2438
+ function extractDriveSlugFromPath(path) {
2439
+ const currentPath = getPathWithoutBase(path);
2440
+ return /^\/d\/([^/]+)/.exec(currentPath)?.[1] ?? "";
2441
+ }
2442
+ /**
2443
+ * Creates a URL string with the given pathname while preserving existing query parameters.
2444
+ */
2445
+ function createUrlWithPreservedParams(pathname) {
2446
+ const search = window.location.search;
2447
+ return search ? `${pathname}${search}` : pathname;
2448
+ }
2449
+ const drivesEventFunctions = makePHEventFunctions("drives");
2450
+ /** Returns all of the drives in the reactor */
2451
+ const useDrives = drivesEventFunctions.useValue;
2452
+ /** Sets the drives in the reactor */
2453
+ const setDrives = drivesEventFunctions.setValue;
2454
+ drivesEventFunctions.addEventHandler;
2455
+ const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
2456
+ const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
2457
+ const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
2458
+ selectedNodeIdEventFunctions.addEventHandler;
2459
+ /** Sets the selected node (file or folder). */
2460
+ function setSelectedNode(nodeOrNodeSlug) {
2461
+ const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
2462
+ setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
2463
+ const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
2464
+ if (!driveSlugFromPath) return;
2465
+ if (!nodeSlug) {
2466
+ const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
2467
+ if (pathname === window.location.pathname) return;
2468
+ window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
2469
+ return;
2470
+ }
2471
+ const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
2472
+ if (pathname === window.location.pathname) return;
2473
+ window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
2474
+ }
2475
+ const selectedDriveIdEventFunctions = makePHEventFunctions("selectedDriveId");
2476
+ /** Returns the selected drive id */
2477
+ const useSelectedDriveId = selectedDriveIdEventFunctions.useValue;
2478
+ /** Sets the selected drive id */
2479
+ const setSelectedDriveId = selectedDriveIdEventFunctions.setValue;
2480
+ selectedDriveIdEventFunctions.addEventHandler;
2481
+ /** Returns the selected drive, or undefined if no drive is selected */
2482
+ function useSelectedDriveSafe() {
2483
+ const selectedDriveId = useSelectedDriveId();
2484
+ const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
2485
+ const [drive, dispatch] = useDispatch(selectedDrive);
2486
+ if (!selectedDrive) return [void 0, void 0];
2487
+ return [drive, dispatch];
2488
+ }
2489
+ function setSelectedDrive(driveOrDriveSlug) {
2490
+ const driveSlug = typeof driveOrDriveSlug === "string" ? driveOrDriveSlug : driveOrDriveSlug?.header.slug;
2491
+ const drives = window.ph?.drives;
2492
+ const driveId = (typeof driveOrDriveSlug === "object" && driveOrDriveSlug !== null ? driveOrDriveSlug : drives?.find((d) => d.header.slug === driveSlug))?.header.id;
2493
+ if (!driveId && driveSlug && extractDriveSlugFromPath(window.location.pathname) === driveSlug) {
2494
+ if (window.ph?.selectedDriveId) setSelectedDriveId(void 0);
2495
+ deferDriveSelection(driveSlug);
2496
+ return;
2497
+ }
2498
+ cancelPendingDriveSelection();
2499
+ setSelectedDriveId(driveId);
2500
+ if (!driveId) {
2501
+ const pathname = resolveUrlPathname("/");
2502
+ if (pathname === window.location.pathname) return;
2503
+ window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
2504
+ return;
2505
+ }
2506
+ const pathname = resolveUrlPathname(`/d/${driveSlug}`);
2507
+ if (pathname === window.location.pathname) return;
2508
+ window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
2509
+ }
2510
+ const DEFERRED_DRIVE_TICK_MS = 2e3;
2511
+ const DEFERRED_DRIVE_MAX_WAIT_MS = 15e3;
2512
+ function isInitialSyncInFlight() {
2513
+ const remotes = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager?.list();
2514
+ if (!remotes?.length) return false;
2515
+ return remotes.some((remote) => {
2516
+ try {
2517
+ const snapshot = remote.channel.getConnectionState();
2518
+ return snapshot.receivingPages || !snapshot.lastSuccessUtcMs && snapshot.state !== "error";
2519
+ } catch {
2520
+ return false;
2521
+ }
2522
+ });
2523
+ }
2524
+ let pendingHandler;
2525
+ let pendingTimeout;
2526
+ function cancelPendingDriveSelection() {
2527
+ if (pendingHandler) {
2528
+ window.removeEventListener("ph:drivesUpdated", pendingHandler);
2529
+ pendingHandler = void 0;
2530
+ }
2531
+ if (pendingTimeout) {
2532
+ clearTimeout(pendingTimeout);
2533
+ pendingTimeout = void 0;
2534
+ }
2535
+ }
2536
+ function deferDriveSelection(driveSlug) {
2537
+ cancelPendingDriveSelection();
2538
+ const nodeSlug = extractNodeSlugFromPath(window.location.pathname);
2539
+ const handler = () => {
2540
+ if (!window.ph?.drives?.find((d) => d.header.slug === driveSlug)) return;
2541
+ cancelPendingDriveSelection();
2542
+ setSelectedDrive(driveSlug);
2543
+ setSelectedNode(nodeSlug);
2544
+ };
2545
+ pendingHandler = handler;
2546
+ window.addEventListener("ph:drivesUpdated", handler);
2547
+ const deadline = Date.now() + DEFERRED_DRIVE_MAX_WAIT_MS;
2548
+ const scheduleTick = () => {
2549
+ pendingTimeout = setTimeout(() => {
2550
+ if (Date.now() < deadline && isInitialSyncInFlight()) {
2551
+ scheduleTick();
2552
+ return;
2553
+ }
2554
+ cancelPendingDriveSelection();
2555
+ const pathname = resolveUrlPathname("/");
2556
+ if (pathname === window.location.pathname) return;
2557
+ window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
2558
+ }, DEFERRED_DRIVE_TICK_MS);
2559
+ };
2560
+ scheduleTick();
2561
+ }
2562
+ function useDropTarget() {
2563
+ const [isDropTarget, setIsDropTarget] = useState(false);
2564
+ const isDragAndDropEnabled = useIsDragAndDropEnabled();
2565
+ const targetSetter = n$1(() => setIsDropTarget(true), {
2566
+ triggerAt: "start",
2567
+ minQuietPeriodMs: 100
2568
+ });
2569
+ const targetUnsetter = n$1(() => setIsDropTarget(false), {
2570
+ triggerAt: "start",
2571
+ minQuietPeriodMs: 100
2572
+ });
2573
+ function setTarget() {
2574
+ if (!isDragAndDropEnabled) return;
2575
+ targetUnsetter.cancel();
2576
+ targetSetter.call();
2577
+ }
2578
+ function unsetTarget() {
2579
+ if (!isDragAndDropEnabled) return;
2580
+ targetSetter.cancel();
2581
+ targetUnsetter.call();
2582
+ }
2583
+ return {
2584
+ isDropTarget,
2585
+ setTarget,
2586
+ unsetTarget
2587
+ };
2588
+ }
2589
+ const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
2590
+ const useDraggingNode = draggingNodeEventFunctions.useValue;
2591
+ const setDraggingNode = draggingNodeEventFunctions.setValue;
2592
+ draggingNodeEventFunctions.addEventHandler;
2593
+ const draggingNodeSetter = n$1((node) => setDraggingNode(node), {
2594
+ reducer: (_, newNode) => newNode,
2595
+ triggerAt: "start",
2596
+ minQuietPeriodMs: 100
2597
+ });
2598
+ const draggingNodeUnsetter = n$1(() => setDraggingNode(void 0), {
2599
+ triggerAt: "start",
2600
+ minQuietPeriodMs: 100
2601
+ });
2602
+ function setDragging(node) {
2603
+ draggingNodeUnsetter.cancel();
2604
+ draggingNodeSetter.call(node);
2976
2605
  }
2977
- /** Returns the current path without the base path */
2978
- function getPathWithoutBase(path) {
2979
- const basePath = window.ph?.basePath ?? "/";
2980
- return path.replace(basePath, basePath.endsWith("/") ? "/" : "");
2606
+ function unsetDragging() {
2607
+ draggingNodeSetter.cancel();
2608
+ draggingNodeUnsetter.call();
2981
2609
  }
2982
- /** Makes a URL component for a node. */
2983
- function makeNodeSlug(node) {
2984
- if (!node) return "";
2985
- const nodeName = node.name;
2986
- if (!nodeName) return slug(node.id);
2987
- return slug(`${nodeName}-${node.id}`);
2610
+ const isNodeDrag = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$1)(driveId), e$6(false)], [({ driveId, srcId }) => t(driveId, srcId), e$6(false)], e$6(true));
2611
+ function useDragNode(args) {
2612
+ const { srcId, parentId } = args;
2613
+ const driveId = useSelectedDriveId();
2614
+ const draggingNodeId = useDraggingNode()?.srcId;
2615
+ const params = {
2616
+ driveId,
2617
+ srcId,
2618
+ parentId
2619
+ };
2620
+ const draggable = isNodeDrag(params);
2621
+ const isDragging = t$4({
2622
+ srcId,
2623
+ draggingNodeId
2624
+ }, [
2625
+ () => draggable,
2626
+ ({ srcId }) => e$2(srcId),
2627
+ ({ draggingNodeId }) => e$2(draggingNodeId),
2628
+ ({ srcId, draggingNodeId }) => t(srcId, draggingNodeId)
2629
+ ]);
2630
+ const onDragStart = () => {
2631
+ if (!draggable) return;
2632
+ setDragging(params);
2633
+ };
2634
+ const onDragEnd = () => {
2635
+ if (!draggable) return;
2636
+ unsetDragging();
2637
+ };
2638
+ return {
2639
+ isDragging,
2640
+ draggable,
2641
+ onDragStart,
2642
+ onDragEnd
2643
+ };
2988
2644
  }
2989
- /** Extracts the node slug from a path.
2990
- *
2991
- * The path is expected to be in the format `/d/<drive-slug>/<node-slug>`.
2992
- */
2993
- function extractNodeSlugFromPath(path) {
2994
- const currentPath = getPathWithoutBase(path);
2995
- return /^\/d\/[^/]+\/([^/]+)$/.exec(currentPath)?.[1];
2645
+ const isNodeDrop = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$4)(driveId), e$6(false)], [({ srcId, targetId }) => t(srcId, targetId), e$6(false)], [({ driveId, parentId, targetId }) => e$3(e$1)(parentId) && t(targetId, driveId), e$6(false)], [({ targetId, parentId }) => t(targetId, parentId), e$6(false)], e$6(true));
2646
+ function useDropNode(targetId) {
2647
+ const driveId = useSelectedDriveId();
2648
+ const { srcId, parentId } = useDraggingNode() ?? {};
2649
+ const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
2650
+ const params = {
2651
+ driveId,
2652
+ parentId,
2653
+ targetId,
2654
+ srcId
2655
+ };
2656
+ function handleNodeDrop(event, cb) {
2657
+ if (!isNodeDrop(params)) return;
2658
+ event.preventDefault();
2659
+ event.stopPropagation();
2660
+ cb?.();
2661
+ }
2662
+ const onDragEnter = (event) => handleNodeDrop(event);
2663
+ const onDragOver = (event) => handleNodeDrop(event, e(setTarget));
2664
+ const onDragLeave = (event) => handleNodeDrop(event, e(unsetTarget));
2665
+ const onDrop = (event) => handleNodeDrop(event, e(() => {
2666
+ unsetDragging();
2667
+ unsetTarget();
2668
+ moveNodeById(params).catch(console.error);
2669
+ }));
2670
+ return {
2671
+ isDropTarget,
2672
+ onDragEnter,
2673
+ onDragOver,
2674
+ onDragLeave,
2675
+ onDrop
2676
+ };
2996
2677
  }
2997
- /** Finds a UUID in a string, used for extracting node ids from node slugs in the URL. */
2998
- function findUuid(input) {
2999
- if (!input) return void 0;
3000
- return /\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(input)?.[0];
2678
+ const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
2679
+ graphQLReactorClientEventFunctions.useValue;
2680
+ graphQLReactorClientEventFunctions.setValue;
2681
+ graphQLReactorClientEventFunctions.addEventHandler;
2682
+ const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
2683
+ packageDiscoveryFunctions.useValue;
2684
+ packageDiscoveryFunctions.setValue;
2685
+ packageDiscoveryFunctions.addEventHandler;
2686
+ const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
2687
+ const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
2688
+ /** Returns the reactor client module (in-process or worker-backed) */
2689
+ const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
2690
+ reactorClientModuleEventFunctions.setValue;
2691
+ reactorClientModuleEventFunctions.addEventHandler;
2692
+ reactorClientEventFunctions.useValue;
2693
+ reactorClientEventFunctions.setValue;
2694
+ reactorClientEventFunctions.addEventHandler;
2695
+ const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
2696
+ const useSyncList = () => {
2697
+ return useSync()?.list() ?? [];
2698
+ };
2699
+ const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
2700
+ revisionHistoryEventFunctions.useValue;
2701
+ /** Sets revision history visibility */
2702
+ const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
2703
+ revisionHistoryEventFunctions.addEventHandler;
2704
+ /** Shows the revision history */
2705
+ function showRevisionHistory() {
2706
+ setRevisionHistoryVisible(true);
3001
2707
  }
3002
- function extractNodeIdFromSlug(nodeSlug) {
3003
- return findUuid(nodeSlug);
2708
+ /** Sorts nodes by name. */
2709
+ function sortNodesByName(nodes) {
2710
+ return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
2711
+ }
2712
+ /** Returns whether a node is a file. */
2713
+ function isFileNodeKind(node) {
2714
+ if (!node) return false;
2715
+ return node.kind.toUpperCase() === "FILE";
2716
+ }
2717
+ /** Returns whether a node is a folder. */
2718
+ function isFolderNodeKind(node) {
2719
+ if (!node) return false;
2720
+ return node.kind.toUpperCase() === "FOLDER";
2721
+ }
2722
+ /** Returns the nodes in the selected drive. */
2723
+ function useNodesInSelectedDrive() {
2724
+ const [selectedDrive] = useSelectedDriveSafe();
2725
+ return selectedDrive?.state.global.nodes;
2726
+ }
2727
+ /** Returns the folder nodes in the selected drive. */
2728
+ function useFolderNodesInSelectedDrive() {
2729
+ return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
2730
+ }
2731
+ /** Returns the selected node. */
2732
+ function useSelectedNode() {
2733
+ const selectedNodeId = useSelectedNodeId();
2734
+ return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
3004
2735
  }
3005
- /** Extracts the drive slug from a path.
3006
- * Used for extracting drive ids from drive slugs in the URL.
3007
- * Expects the path to be in the format `/d/<drive-slug>`.
3008
- */
3009
- function extractDriveSlugFromPath(path) {
3010
- const currentPath = getPathWithoutBase(path);
3011
- return /^\/d\/([^/]+)/.exec(currentPath)?.[1] ?? "";
2736
+ const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
2737
+ selectedTimelineItemEventFunctions.useValue;
2738
+ selectedTimelineItemEventFunctions.setValue;
2739
+ selectedTimelineItemEventFunctions.addEventHandler;
2740
+ const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
2741
+ selectedTimelineRevisionEventFunctions.useValue;
2742
+ selectedTimelineRevisionEventFunctions.setValue;
2743
+ selectedTimelineRevisionEventFunctions.addEventHandler;
2744
+ const toastEventFunctions = makePHEventFunctions("toast");
2745
+ /** Returns the toast function */
2746
+ const usePHToast = toastEventFunctions.useValue;
2747
+ toastEventFunctions.setValue;
2748
+ toastEventFunctions.addEventHandler;
2749
+ const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
2750
+ const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
2751
+ /** Returns all of the Vetra packages loaded by the Connect instance */
2752
+ const useVetraPackages = () => {
2753
+ const packageManager = useVetraPackageManager();
2754
+ return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
2755
+ };
2756
+ vetraPackageManagerFunctions.addEventHandler;
2757
+ function useDocumentModelModules() {
2758
+ return useVetraPackages().flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && m.version === module.version) === index);
3012
2759
  }
3013
2760
  /**
3014
- * Creates a URL string with the given pathname while preserving existing query parameters.
2761
+ * Resolves a document model module by document type, mirroring the registry's
2762
+ * semantics (`IDocumentModelRegistry.getModule`): with `version` omitted the
2763
+ * LATEST version of the type wins (`version ?? 1` as each module's default),
2764
+ * with `version` given only an exact match is returned. The reactor resolves
2765
+ * modules the same way when a document is created, so metadata read through
2766
+ * this hook and the version a creation actually uses cannot disagree.
3015
2767
  */
3016
- function createUrlWithPreservedParams(pathname) {
3017
- const search = window.location.search;
3018
- return search ? `${pathname}${search}` : pathname;
2768
+ function useDocumentModelModuleById(id, version) {
2769
+ const documentModelModules = useDocumentModelModules();
2770
+ if (!id || !documentModelModules) return void 0;
2771
+ let latestModule;
2772
+ let latestVersion = -1;
2773
+ for (const module of documentModelModules) {
2774
+ if (module.documentModel.global.id !== id) continue;
2775
+ const moduleVersion = module.version ?? 1;
2776
+ if (version !== void 0) {
2777
+ if (moduleVersion === version) return module;
2778
+ continue;
2779
+ }
2780
+ if (moduleVersion > latestVersion) {
2781
+ latestVersion = moduleVersion;
2782
+ latestModule = module;
2783
+ }
2784
+ }
2785
+ return latestModule;
3019
2786
  }
3020
- const drivesEventFunctions = makePHEventFunctions("drives");
3021
- /** Returns all of the drives in the reactor */
3022
- const useDrives = drivesEventFunctions.useValue;
3023
- /** Sets the drives in the reactor */
3024
- const setDrives = drivesEventFunctions.setValue;
3025
- drivesEventFunctions.addEventHandler;
3026
- const selectedNodeIdEventFunctions = makePHEventFunctions("selectedNodeId");
3027
- const useSelectedNodeId = selectedNodeIdEventFunctions.useValue;
3028
- const setSelectedNodeId = selectedNodeIdEventFunctions.setValue;
3029
- selectedNodeIdEventFunctions.addEventHandler;
3030
- /** Sets the selected node (file or folder). */
3031
- function setSelectedNode(nodeOrNodeSlug) {
3032
- const nodeSlug = typeof nodeOrNodeSlug === "string" ? nodeOrNodeSlug : makeNodeSlug(nodeOrNodeSlug);
3033
- setSelectedNodeId(extractNodeIdFromSlug(nodeSlug));
3034
- const driveSlugFromPath = extractDriveSlugFromPath(window.location.pathname);
3035
- if (!driveSlugFromPath) return;
3036
- if (!nodeSlug) {
3037
- const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}`);
3038
- if (pathname === window.location.pathname) return;
3039
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
2787
+ //#endregion
2788
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/descriptors.js
2789
+ const normalizeDescriptors = (error) => {
2790
+ CORE_ERROR_PROPS.forEach((propName) => {
2791
+ normalizeDescriptor(error, propName);
2792
+ });
2793
+ };
2794
+ const CORE_ERROR_PROPS = [
2795
+ "name",
2796
+ "message",
2797
+ "stack",
2798
+ "cause",
2799
+ "errors"
2800
+ ];
2801
+ const normalizeDescriptor = (error, propName) => {
2802
+ const descriptor = getDescriptor(error, propName);
2803
+ if (descriptor === void 0) return;
2804
+ if (isReadonlyGetter(descriptor)) {
2805
+ setErrorProperty(error, propName, error[propName]);
3040
2806
  return;
3041
2807
  }
3042
- const pathname = resolveUrlPathname(`/d/${driveSlugFromPath}/${nodeSlug}`);
3043
- if (pathname === window.location.pathname) return;
3044
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
3045
- }
3046
- const selectedDriveIdEventFunctions = makePHEventFunctions("selectedDriveId");
3047
- /** Returns the selected drive id */
3048
- const useSelectedDriveId = selectedDriveIdEventFunctions.useValue;
3049
- /** Sets the selected drive id */
3050
- const setSelectedDriveId = selectedDriveIdEventFunctions.setValue;
3051
- selectedDriveIdEventFunctions.addEventHandler;
3052
- /** Returns the selected drive, or undefined if no drive is selected */
3053
- function useSelectedDriveSafe() {
3054
- const selectedDriveId = useSelectedDriveId();
3055
- const selectedDrive = useDrives()?.find((drive) => drive.header.id === selectedDriveId);
3056
- const [drive, dispatch] = useDispatch(selectedDrive);
3057
- if (!selectedDrive) return [void 0, void 0];
3058
- return [drive, dispatch];
2808
+ if (isInvalidDescriptor(descriptor)) setErrorDescriptor(error, propName, descriptor);
2809
+ };
2810
+ const getDescriptor = (value, propName) => {
2811
+ const descriptor = Object.getOwnPropertyDescriptor(value, propName);
2812
+ if (descriptor !== void 0) return descriptor;
2813
+ const prototype = Object.getPrototypeOf(value);
2814
+ return prototype === null ? void 0 : getDescriptor(prototype, propName);
2815
+ };
2816
+ const isReadonlyGetter = ({ get, set }) => get !== void 0 && set === void 0;
2817
+ const isInvalidDescriptor = ({ enumerable, writable }) => enumerable || !writable;
2818
+ const setErrorProperty = (error, propName, value) => {
2819
+ setErrorDescriptor(error, propName, { value });
2820
+ };
2821
+ const setErrorDescriptor = (error, propName, descriptor) => {
2822
+ Object.defineProperty(error, propName, {
2823
+ ...descriptor,
2824
+ ..."get" in descriptor || "set" in descriptor ? {} : { writable: true },
2825
+ enumerable: false,
2826
+ configurable: true
2827
+ });
2828
+ };
2829
+ //#endregion
2830
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/aggregate.js
2831
+ const normalizeAggregate = (error, recurse) => {
2832
+ if (Array.isArray(error.errors)) setErrorProperty(error, "errors", error.errors.filter(isDefined).map(recurse).filter(Boolean));
2833
+ else if (isAggregateError(error)) setErrorProperty(error, "errors", []);
2834
+ else if (error.errors !== void 0) deleteAggregateErrors(error);
2835
+ };
2836
+ const isDefined = (error) => error !== void 0;
2837
+ const isAggregateError = (error) => "AggregateError" in globalThis && (error.name === "AggregateError" || error instanceof AggregateError);
2838
+ const deleteAggregateErrors = (error) => {
2839
+ delete error.errors;
2840
+ if (error.errors !== void 0) setErrorProperty(error, "errors", []);
2841
+ };
2842
+ //#endregion
2843
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/cause.js
2844
+ const normalizeCause = (error, recurse) => {
2845
+ if (!("cause" in error)) return;
2846
+ const cause = error.cause === void 0 ? error.cause : recurse(error.cause);
2847
+ if (cause === void 0) delete error.cause;
2848
+ else setErrorProperty(error, "cause", cause);
2849
+ };
2850
+ //#endregion
2851
+ //#region ../../node_modules/.pnpm/is-error-instance@3.0.1/node_modules/is-error-instance/build/src/main.js
2852
+ const isErrorInstance = (value) => isInstanceOfError(value) || hasErrorTag(value);
2853
+ const isInstanceOfError = (value) => {
2854
+ try {
2855
+ return value instanceof Error;
2856
+ } catch {
2857
+ return false;
2858
+ }
2859
+ };
2860
+ const hasErrorTag = (value) => {
2861
+ try {
2862
+ return ERROR_TAGS.has(Object.prototype.toString.call(value));
2863
+ } catch {
2864
+ return false;
2865
+ }
2866
+ };
2867
+ const ERROR_TAGS = new Set([
2868
+ "[object Error]",
2869
+ "[object DOMException]",
2870
+ "[object DOMError]",
2871
+ "[object Exception]"
2872
+ ]);
2873
+ //#endregion
2874
+ //#region ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
2875
+ function isPlainObject(value) {
2876
+ if (typeof value !== "object" || value === null) return false;
2877
+ const prototype = Object.getPrototypeOf(value);
2878
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
3059
2879
  }
3060
- function setSelectedDrive(driveOrDriveSlug) {
3061
- const driveSlug = typeof driveOrDriveSlug === "string" ? driveOrDriveSlug : driveOrDriveSlug?.header.slug;
3062
- const drives = window.ph?.drives;
3063
- const driveId = (typeof driveOrDriveSlug === "object" && driveOrDriveSlug !== null ? driveOrDriveSlug : drives?.find((d) => d.header.slug === driveSlug))?.header.id;
3064
- if (!driveId && driveSlug && extractDriveSlugFromPath(window.location.pathname) === driveSlug) {
3065
- if (window.ph?.selectedDriveId) setSelectedDriveId(void 0);
3066
- deferDriveSelection(driveSlug);
3067
- return;
2880
+ //#endregion
2881
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/modifiable.js
2882
+ const isNonModifiableError = (error) => !Object.isExtensible(error) || CORE_ERROR_PROPS.some((propName) => isNonConfigurableProp(error, propName) || isThrowingProp(error, propName));
2883
+ const isNonConfigurableProp = (error, propName) => {
2884
+ const descriptor = Object.getOwnPropertyDescriptor(error, propName);
2885
+ return descriptor !== void 0 && !descriptor.configurable;
2886
+ };
2887
+ const isThrowingProp = (error, propName) => {
2888
+ try {
2889
+ error[propName];
2890
+ return false;
2891
+ } catch {
2892
+ return true;
2893
+ }
2894
+ };
2895
+ //#endregion
2896
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/stack.js
2897
+ const setStack = (error) => {
2898
+ setErrorProperty(error, "stack", getStack(error.message, error.name));
2899
+ };
2900
+ const getStack = (message = "", name = "Error") => {
2901
+ const { stack } = new (getErrorClass(name))(message);
2902
+ return typeof stack === "string" && stack !== "" ? stack : `${name}: ${message}`;
2903
+ };
2904
+ const getErrorClass = (name) => {
2905
+ const descriptor = {
2906
+ value: name,
2907
+ enumerable: false,
2908
+ writable: true,
2909
+ configurable: true
2910
+ };
2911
+ const StackError = Object.defineProperty(class extends Error {}, "name", descriptor);
2912
+ Object.defineProperty(StackError.prototype, "name", descriptor);
2913
+ return StackError;
2914
+ };
2915
+ //#endregion
2916
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/copy.js
2917
+ const copyObject = (object) => {
2918
+ const objectCopy = {};
2919
+ for (const propName of getPropsToCopy(object)) try {
2920
+ const value = object[propName];
2921
+ const { enumerable, configurable, writable = true } = getDescriptor(object, propName);
2922
+ Object.defineProperty(objectCopy, propName, {
2923
+ value,
2924
+ enumerable,
2925
+ configurable,
2926
+ writable
2927
+ });
2928
+ } catch {}
2929
+ return objectCopy;
2930
+ };
2931
+ const getPropsToCopy = (object) => {
2932
+ const propNames = getOwnKeys(object);
2933
+ for (const propName of CORE_ERROR_PROPS) if (isInheritedProp(object, propName)) propNames.push(propName);
2934
+ return propNames;
2935
+ };
2936
+ const getOwnKeys = (object) => {
2937
+ try {
2938
+ return Reflect.ownKeys(object);
2939
+ } catch {
2940
+ return [];
2941
+ }
2942
+ };
2943
+ const isInheritedProp = (object, propName) => {
2944
+ try {
2945
+ return propName in object && !Object.hasOwn(object, propName);
2946
+ } catch {
2947
+ return false;
2948
+ }
2949
+ };
2950
+ //#endregion
2951
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/object.js
2952
+ const objectifyError = (object) => {
2953
+ const { name, message, stack, cause, errors, ...objectA } = copyObject(object);
2954
+ const messageA = getMessage(message, objectA);
2955
+ const error = newError(name, messageA);
2956
+ if (message === messageA) assignObjectProps(error, objectA);
2957
+ Object.entries({
2958
+ name,
2959
+ stack,
2960
+ cause,
2961
+ errors
2962
+ }).forEach(([propName, propValue]) => {
2963
+ setNewErrorProperty(error, propName, propValue);
2964
+ });
2965
+ if (stack === void 0) setStack(error);
2966
+ return error;
2967
+ };
2968
+ const getMessage = (message, object) => typeof message === "string" && message !== "" ? message : truncateMessage(safeJsonStringify(object));
2969
+ const safeJsonStringify = (object) => {
2970
+ try {
2971
+ return JSON.stringify(object);
2972
+ } catch {
2973
+ return safeStringify(object);
3068
2974
  }
3069
- cancelPendingDriveSelection();
3070
- setSelectedDriveId(driveId);
3071
- if (!driveId) {
3072
- const pathname = resolveUrlPathname("/");
3073
- if (pathname === window.location.pathname) return;
3074
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
3075
- return;
2975
+ };
2976
+ const safeStringify = (object) => {
2977
+ try {
2978
+ return String(object);
2979
+ } catch {
2980
+ return "Invalid error";
3076
2981
  }
3077
- const pathname = resolveUrlPathname(`/d/${driveSlug}`);
3078
- if (pathname === window.location.pathname) return;
3079
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
3080
- }
3081
- const DEFERRED_DRIVE_TICK_MS = 2e3;
3082
- const DEFERRED_DRIVE_MAX_WAIT_MS = 15e3;
3083
- function isInitialSyncInFlight() {
3084
- const remotes = window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager?.list();
3085
- if (!remotes?.length) return false;
3086
- return remotes.some((remote) => {
3087
- try {
3088
- const snapshot = remote.channel.getConnectionState();
3089
- return snapshot.receivingPages || !snapshot.lastSuccessUtcMs && snapshot.state !== "error";
3090
- } catch {
3091
- return false;
3092
- }
3093
- });
3094
- }
3095
- let pendingHandler;
3096
- let pendingTimeout;
3097
- function cancelPendingDriveSelection() {
3098
- if (pendingHandler) {
3099
- window.removeEventListener("ph:drivesUpdated", pendingHandler);
3100
- pendingHandler = void 0;
2982
+ };
2983
+ const truncateMessage = (message) => message.length < MESSAGE_MAX_SIZE ? message : `${message.slice(0, MESSAGE_MAX_SIZE)}...`;
2984
+ const MESSAGE_MAX_SIZE = 1e3;
2985
+ const newError = (name, message) => {
2986
+ if (name === "AggregateError" && "AggregateError" in globalThis) return new AggregateError([], message);
2987
+ if (name in NATIVE_ERRORS) return new NATIVE_ERRORS[name](message);
2988
+ return new Error(message);
2989
+ };
2990
+ const NATIVE_ERRORS = {
2991
+ Error,
2992
+ ReferenceError,
2993
+ TypeError,
2994
+ SyntaxError,
2995
+ RangeError,
2996
+ URIError,
2997
+ EvalError
2998
+ };
2999
+ const assignObjectProps = (error, object) => {
3000
+ for (const propName in object) if (!(propName in error)) error[propName] = object[propName];
3001
+ };
3002
+ const setNewErrorProperty = (error, propName, propValue) => {
3003
+ if (propValue !== void 0) setErrorProperty(error, propName, propValue);
3004
+ };
3005
+ //#endregion
3006
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/string.js
3007
+ const stringifyError = (value) => {
3008
+ try {
3009
+ const error = new Error(String(value));
3010
+ setStack(error);
3011
+ return error;
3012
+ } catch (error_) {
3013
+ return error_;
3101
3014
  }
3102
- if (pendingTimeout) {
3103
- clearTimeout(pendingTimeout);
3104
- pendingTimeout = void 0;
3015
+ };
3016
+ //#endregion
3017
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/create/main.js
3018
+ const { toString: objectToString } = Object.prototype;
3019
+ const createError = (value) => {
3020
+ if (isErrorPlainObj(value)) return objectifyError(value);
3021
+ if (!isErrorInstance(value)) return stringifyError(value);
3022
+ if (isInvalidError(value)) return objectifyError(value);
3023
+ return value;
3024
+ };
3025
+ const isErrorPlainObj = (value) => {
3026
+ try {
3027
+ return isPlainObject(value);
3028
+ } catch {
3029
+ return false;
3105
3030
  }
3106
- }
3107
- function deferDriveSelection(driveSlug) {
3108
- cancelPendingDriveSelection();
3109
- const nodeSlug = extractNodeSlugFromPath(window.location.pathname);
3110
- const handler = () => {
3111
- if (!window.ph?.drives?.find((d) => d.header.slug === driveSlug)) return;
3112
- cancelPendingDriveSelection();
3113
- setSelectedDrive(driveSlug);
3114
- setSelectedNode(nodeSlug);
3115
- };
3116
- pendingHandler = handler;
3117
- window.addEventListener("ph:drivesUpdated", handler);
3118
- const deadline = Date.now() + DEFERRED_DRIVE_MAX_WAIT_MS;
3119
- const scheduleTick = () => {
3120
- pendingTimeout = setTimeout(() => {
3121
- if (Date.now() < deadline && isInitialSyncInFlight()) {
3122
- scheduleTick();
3123
- return;
3031
+ };
3032
+ const isInvalidError = (value) => isProxy(value) || isNonModifiableError(value) || hasInvalidConstructor(value);
3033
+ const isProxy = (value) => {
3034
+ try {
3035
+ return objectToString.call(value) === "[object Object]";
3036
+ } catch {
3037
+ return true;
3038
+ }
3039
+ };
3040
+ const hasInvalidConstructor = (error) => typeof error.constructor !== "function" || typeof error.constructor.name !== "string" || error.constructor.name === "" || error.constructor.prototype !== Object.getPrototypeOf(error);
3041
+ //#endregion
3042
+ //#region ../../node_modules/.pnpm/normalize-exception@4.0.1/node_modules/normalize-exception/build/src/main.js
3043
+ const normalizeException = (error, { shallow = false } = {}) => recurseException(error, [], shallow);
3044
+ const recurseException = (error, parents, shallow) => {
3045
+ if (parents.includes(error)) return;
3046
+ const recurse = shallow ? identity : (innerError) => recurseException(innerError, [...parents, error], shallow);
3047
+ const errorA = createError(error);
3048
+ normalizeProps(errorA, recurse);
3049
+ return errorA;
3050
+ };
3051
+ const identity = (error) => error;
3052
+ const normalizeProps = (error, recurse) => {
3053
+ normalizeName(error);
3054
+ normalizeMessage(error);
3055
+ normalizeStack(error);
3056
+ normalizeCause(error, recurse);
3057
+ normalizeAggregate(error, recurse);
3058
+ normalizeDescriptors(error);
3059
+ };
3060
+ const normalizeName = (error) => {
3061
+ if (isDefinedString(error.name)) return;
3062
+ const prototypeName = Object.getPrototypeOf(error).name;
3063
+ setErrorProperty(error, "name", isDefinedString(prototypeName) ? prototypeName : error.constructor.name);
3064
+ };
3065
+ const normalizeMessage = (error) => {
3066
+ if (!isDefinedString(error.message)) setErrorProperty(error, "message", "");
3067
+ };
3068
+ const normalizeStack = (error) => {
3069
+ if (!isDefinedString(error.stack)) setStack(error);
3070
+ };
3071
+ const isDefinedString = (value) => typeof value === "string" && value !== "";
3072
+ //#endregion
3073
+ //#region ../reactor-browser/dist/index.js
3074
+ var import_lz_string = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
3075
+ var LZString = (function() {
3076
+ var f = String.fromCharCode;
3077
+ var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
3078
+ var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
3079
+ var baseReverseDic = {};
3080
+ function getBaseValue(alphabet, character) {
3081
+ if (!baseReverseDic[alphabet]) {
3082
+ baseReverseDic[alphabet] = {};
3083
+ for (var i = 0; i < alphabet.length; i++) baseReverseDic[alphabet][alphabet.charAt(i)] = i;
3084
+ }
3085
+ return baseReverseDic[alphabet][character];
3086
+ }
3087
+ var LZString = {
3088
+ compressToBase64: function(input) {
3089
+ if (input == null) return "";
3090
+ var res = LZString._compress(input, 6, function(a) {
3091
+ return keyStrBase64.charAt(a);
3092
+ });
3093
+ switch (res.length % 4) {
3094
+ default:
3095
+ case 0: return res;
3096
+ case 1: return res + "===";
3097
+ case 2: return res + "==";
3098
+ case 3: return res + "=";
3099
+ }
3100
+ },
3101
+ decompressFromBase64: function(input) {
3102
+ if (input == null) return "";
3103
+ if (input == "") return null;
3104
+ return LZString._decompress(input.length, 32, function(index) {
3105
+ return getBaseValue(keyStrBase64, input.charAt(index));
3106
+ });
3107
+ },
3108
+ compressToUTF16: function(input) {
3109
+ if (input == null) return "";
3110
+ return LZString._compress(input, 15, function(a) {
3111
+ return f(a + 32);
3112
+ }) + " ";
3113
+ },
3114
+ decompressFromUTF16: function(compressed) {
3115
+ if (compressed == null) return "";
3116
+ if (compressed == "") return null;
3117
+ return LZString._decompress(compressed.length, 16384, function(index) {
3118
+ return compressed.charCodeAt(index) - 32;
3119
+ });
3120
+ },
3121
+ compressToUint8Array: function(uncompressed) {
3122
+ var compressed = LZString.compress(uncompressed);
3123
+ var buf = new Uint8Array(compressed.length * 2);
3124
+ for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
3125
+ var current_value = compressed.charCodeAt(i);
3126
+ buf[i * 2] = current_value >>> 8;
3127
+ buf[i * 2 + 1] = current_value % 256;
3128
+ }
3129
+ return buf;
3130
+ },
3131
+ decompressFromUint8Array: function(compressed) {
3132
+ if (compressed === null || compressed === void 0) return LZString.decompress(compressed);
3133
+ else {
3134
+ var buf = new Array(compressed.length / 2);
3135
+ for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
3136
+ var result = [];
3137
+ buf.forEach(function(c) {
3138
+ result.push(f(c));
3139
+ });
3140
+ return LZString.decompress(result.join(""));
3141
+ }
3142
+ },
3143
+ compressToEncodedURIComponent: function(input) {
3144
+ if (input == null) return "";
3145
+ return LZString._compress(input, 6, function(a) {
3146
+ return keyStrUriSafe.charAt(a);
3147
+ });
3148
+ },
3149
+ decompressFromEncodedURIComponent: function(input) {
3150
+ if (input == null) return "";
3151
+ if (input == "") return null;
3152
+ input = input.replace(/ /g, "+");
3153
+ return LZString._decompress(input.length, 32, function(index) {
3154
+ return getBaseValue(keyStrUriSafe, input.charAt(index));
3155
+ });
3156
+ },
3157
+ compress: function(uncompressed) {
3158
+ return LZString._compress(uncompressed, 16, function(a) {
3159
+ return f(a);
3160
+ });
3161
+ },
3162
+ _compress: function(uncompressed, bitsPerChar, getCharFromInt) {
3163
+ if (uncompressed == null) return "";
3164
+ var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
3165
+ for (ii = 0; ii < uncompressed.length; ii += 1) {
3166
+ context_c = uncompressed.charAt(ii);
3167
+ if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
3168
+ context_dictionary[context_c] = context_dictSize++;
3169
+ context_dictionaryToCreate[context_c] = true;
3170
+ }
3171
+ context_wc = context_w + context_c;
3172
+ if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) context_w = context_wc;
3173
+ else {
3174
+ if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
3175
+ if (context_w.charCodeAt(0) < 256) {
3176
+ for (i = 0; i < context_numBits; i++) {
3177
+ context_data_val = context_data_val << 1;
3178
+ if (context_data_position == bitsPerChar - 1) {
3179
+ context_data_position = 0;
3180
+ context_data.push(getCharFromInt(context_data_val));
3181
+ context_data_val = 0;
3182
+ } else context_data_position++;
3183
+ }
3184
+ value = context_w.charCodeAt(0);
3185
+ for (i = 0; i < 8; i++) {
3186
+ context_data_val = context_data_val << 1 | value & 1;
3187
+ if (context_data_position == bitsPerChar - 1) {
3188
+ context_data_position = 0;
3189
+ context_data.push(getCharFromInt(context_data_val));
3190
+ context_data_val = 0;
3191
+ } else context_data_position++;
3192
+ value = value >> 1;
3193
+ }
3194
+ } else {
3195
+ value = 1;
3196
+ for (i = 0; i < context_numBits; i++) {
3197
+ context_data_val = context_data_val << 1 | value;
3198
+ if (context_data_position == bitsPerChar - 1) {
3199
+ context_data_position = 0;
3200
+ context_data.push(getCharFromInt(context_data_val));
3201
+ context_data_val = 0;
3202
+ } else context_data_position++;
3203
+ value = 0;
3204
+ }
3205
+ value = context_w.charCodeAt(0);
3206
+ for (i = 0; i < 16; i++) {
3207
+ context_data_val = context_data_val << 1 | value & 1;
3208
+ if (context_data_position == bitsPerChar - 1) {
3209
+ context_data_position = 0;
3210
+ context_data.push(getCharFromInt(context_data_val));
3211
+ context_data_val = 0;
3212
+ } else context_data_position++;
3213
+ value = value >> 1;
3214
+ }
3215
+ }
3216
+ context_enlargeIn--;
3217
+ if (context_enlargeIn == 0) {
3218
+ context_enlargeIn = Math.pow(2, context_numBits);
3219
+ context_numBits++;
3220
+ }
3221
+ delete context_dictionaryToCreate[context_w];
3222
+ } else {
3223
+ value = context_dictionary[context_w];
3224
+ for (i = 0; i < context_numBits; i++) {
3225
+ context_data_val = context_data_val << 1 | value & 1;
3226
+ if (context_data_position == bitsPerChar - 1) {
3227
+ context_data_position = 0;
3228
+ context_data.push(getCharFromInt(context_data_val));
3229
+ context_data_val = 0;
3230
+ } else context_data_position++;
3231
+ value = value >> 1;
3232
+ }
3233
+ }
3234
+ context_enlargeIn--;
3235
+ if (context_enlargeIn == 0) {
3236
+ context_enlargeIn = Math.pow(2, context_numBits);
3237
+ context_numBits++;
3238
+ }
3239
+ context_dictionary[context_wc] = context_dictSize++;
3240
+ context_w = String(context_c);
3241
+ }
3242
+ }
3243
+ if (context_w !== "") {
3244
+ if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
3245
+ if (context_w.charCodeAt(0) < 256) {
3246
+ for (i = 0; i < context_numBits; i++) {
3247
+ context_data_val = context_data_val << 1;
3248
+ if (context_data_position == bitsPerChar - 1) {
3249
+ context_data_position = 0;
3250
+ context_data.push(getCharFromInt(context_data_val));
3251
+ context_data_val = 0;
3252
+ } else context_data_position++;
3253
+ }
3254
+ value = context_w.charCodeAt(0);
3255
+ for (i = 0; i < 8; i++) {
3256
+ context_data_val = context_data_val << 1 | value & 1;
3257
+ if (context_data_position == bitsPerChar - 1) {
3258
+ context_data_position = 0;
3259
+ context_data.push(getCharFromInt(context_data_val));
3260
+ context_data_val = 0;
3261
+ } else context_data_position++;
3262
+ value = value >> 1;
3263
+ }
3264
+ } else {
3265
+ value = 1;
3266
+ for (i = 0; i < context_numBits; i++) {
3267
+ context_data_val = context_data_val << 1 | value;
3268
+ if (context_data_position == bitsPerChar - 1) {
3269
+ context_data_position = 0;
3270
+ context_data.push(getCharFromInt(context_data_val));
3271
+ context_data_val = 0;
3272
+ } else context_data_position++;
3273
+ value = 0;
3274
+ }
3275
+ value = context_w.charCodeAt(0);
3276
+ for (i = 0; i < 16; i++) {
3277
+ context_data_val = context_data_val << 1 | value & 1;
3278
+ if (context_data_position == bitsPerChar - 1) {
3279
+ context_data_position = 0;
3280
+ context_data.push(getCharFromInt(context_data_val));
3281
+ context_data_val = 0;
3282
+ } else context_data_position++;
3283
+ value = value >> 1;
3284
+ }
3285
+ }
3286
+ context_enlargeIn--;
3287
+ if (context_enlargeIn == 0) {
3288
+ context_enlargeIn = Math.pow(2, context_numBits);
3289
+ context_numBits++;
3290
+ }
3291
+ delete context_dictionaryToCreate[context_w];
3292
+ } else {
3293
+ value = context_dictionary[context_w];
3294
+ for (i = 0; i < context_numBits; i++) {
3295
+ context_data_val = context_data_val << 1 | value & 1;
3296
+ if (context_data_position == bitsPerChar - 1) {
3297
+ context_data_position = 0;
3298
+ context_data.push(getCharFromInt(context_data_val));
3299
+ context_data_val = 0;
3300
+ } else context_data_position++;
3301
+ value = value >> 1;
3302
+ }
3303
+ }
3304
+ context_enlargeIn--;
3305
+ if (context_enlargeIn == 0) {
3306
+ context_enlargeIn = Math.pow(2, context_numBits);
3307
+ context_numBits++;
3308
+ }
3309
+ }
3310
+ value = 2;
3311
+ for (i = 0; i < context_numBits; i++) {
3312
+ context_data_val = context_data_val << 1 | value & 1;
3313
+ if (context_data_position == bitsPerChar - 1) {
3314
+ context_data_position = 0;
3315
+ context_data.push(getCharFromInt(context_data_val));
3316
+ context_data_val = 0;
3317
+ } else context_data_position++;
3318
+ value = value >> 1;
3319
+ }
3320
+ while (true) {
3321
+ context_data_val = context_data_val << 1;
3322
+ if (context_data_position == bitsPerChar - 1) {
3323
+ context_data.push(getCharFromInt(context_data_val));
3324
+ break;
3325
+ } else context_data_position++;
3326
+ }
3327
+ return context_data.join("");
3328
+ },
3329
+ decompress: function(compressed) {
3330
+ if (compressed == null) return "";
3331
+ if (compressed == "") return null;
3332
+ return LZString._decompress(compressed.length, 32768, function(index) {
3333
+ return compressed.charCodeAt(index);
3334
+ });
3335
+ },
3336
+ _decompress: function(length, resetValue, getNextValue) {
3337
+ var dictionary = [], enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = {
3338
+ val: getNextValue(0),
3339
+ position: resetValue,
3340
+ index: 1
3341
+ };
3342
+ for (i = 0; i < 3; i += 1) dictionary[i] = i;
3343
+ bits = 0;
3344
+ maxpower = Math.pow(2, 2);
3345
+ power = 1;
3346
+ while (power != maxpower) {
3347
+ resb = data.val & data.position;
3348
+ data.position >>= 1;
3349
+ if (data.position == 0) {
3350
+ data.position = resetValue;
3351
+ data.val = getNextValue(data.index++);
3352
+ }
3353
+ bits |= (resb > 0 ? 1 : 0) * power;
3354
+ power <<= 1;
3355
+ }
3356
+ switch (bits) {
3357
+ case 0:
3358
+ bits = 0;
3359
+ maxpower = Math.pow(2, 8);
3360
+ power = 1;
3361
+ while (power != maxpower) {
3362
+ resb = data.val & data.position;
3363
+ data.position >>= 1;
3364
+ if (data.position == 0) {
3365
+ data.position = resetValue;
3366
+ data.val = getNextValue(data.index++);
3367
+ }
3368
+ bits |= (resb > 0 ? 1 : 0) * power;
3369
+ power <<= 1;
3370
+ }
3371
+ c = f(bits);
3372
+ break;
3373
+ case 1:
3374
+ bits = 0;
3375
+ maxpower = Math.pow(2, 16);
3376
+ power = 1;
3377
+ while (power != maxpower) {
3378
+ resb = data.val & data.position;
3379
+ data.position >>= 1;
3380
+ if (data.position == 0) {
3381
+ data.position = resetValue;
3382
+ data.val = getNextValue(data.index++);
3383
+ }
3384
+ bits |= (resb > 0 ? 1 : 0) * power;
3385
+ power <<= 1;
3386
+ }
3387
+ c = f(bits);
3388
+ break;
3389
+ case 2: return "";
3390
+ }
3391
+ dictionary[3] = c;
3392
+ w = c;
3393
+ result.push(c);
3394
+ while (true) {
3395
+ if (data.index > length) return "";
3396
+ bits = 0;
3397
+ maxpower = Math.pow(2, numBits);
3398
+ power = 1;
3399
+ while (power != maxpower) {
3400
+ resb = data.val & data.position;
3401
+ data.position >>= 1;
3402
+ if (data.position == 0) {
3403
+ data.position = resetValue;
3404
+ data.val = getNextValue(data.index++);
3405
+ }
3406
+ bits |= (resb > 0 ? 1 : 0) * power;
3407
+ power <<= 1;
3408
+ }
3409
+ switch (c = bits) {
3410
+ case 0:
3411
+ bits = 0;
3412
+ maxpower = Math.pow(2, 8);
3413
+ power = 1;
3414
+ while (power != maxpower) {
3415
+ resb = data.val & data.position;
3416
+ data.position >>= 1;
3417
+ if (data.position == 0) {
3418
+ data.position = resetValue;
3419
+ data.val = getNextValue(data.index++);
3420
+ }
3421
+ bits |= (resb > 0 ? 1 : 0) * power;
3422
+ power <<= 1;
3423
+ }
3424
+ dictionary[dictSize++] = f(bits);
3425
+ c = dictSize - 1;
3426
+ enlargeIn--;
3427
+ break;
3428
+ case 1:
3429
+ bits = 0;
3430
+ maxpower = Math.pow(2, 16);
3431
+ power = 1;
3432
+ while (power != maxpower) {
3433
+ resb = data.val & data.position;
3434
+ data.position >>= 1;
3435
+ if (data.position == 0) {
3436
+ data.position = resetValue;
3437
+ data.val = getNextValue(data.index++);
3438
+ }
3439
+ bits |= (resb > 0 ? 1 : 0) * power;
3440
+ power <<= 1;
3441
+ }
3442
+ dictionary[dictSize++] = f(bits);
3443
+ c = dictSize - 1;
3444
+ enlargeIn--;
3445
+ break;
3446
+ case 2: return result.join("");
3447
+ }
3448
+ if (enlargeIn == 0) {
3449
+ enlargeIn = Math.pow(2, numBits);
3450
+ numBits++;
3451
+ }
3452
+ if (dictionary[c]) entry = dictionary[c];
3453
+ else if (c === dictSize) entry = w + w.charAt(0);
3454
+ else return null;
3455
+ result.push(entry);
3456
+ dictionary[dictSize++] = w + entry.charAt(0);
3457
+ enlargeIn--;
3458
+ w = entry;
3459
+ if (enlargeIn == 0) {
3460
+ enlargeIn = Math.pow(2, numBits);
3461
+ numBits++;
3462
+ }
3463
+ }
3124
3464
  }
3125
- cancelPendingDriveSelection();
3126
- const pathname = resolveUrlPathname("/");
3127
- if (pathname === window.location.pathname) return;
3128
- window.history.pushState(null, "", createUrlWithPreservedParams(pathname));
3129
- }, DEFERRED_DRIVE_TICK_MS);
3130
- };
3131
- scheduleTick();
3132
- }
3133
- function useDropTarget() {
3134
- const [isDropTarget, setIsDropTarget] = useState(false);
3135
- const isDragAndDropEnabled = useIsDragAndDropEnabled();
3136
- const targetSetter = n$1(() => setIsDropTarget(true), {
3137
- triggerAt: "start",
3138
- minQuietPeriodMs: 100
3465
+ };
3466
+ return LZString;
3467
+ })();
3468
+ if (typeof define === "function" && define.amd) define(function() {
3469
+ return LZString;
3139
3470
  });
3140
- const targetUnsetter = n$1(() => setIsDropTarget(false), {
3141
- triggerAt: "start",
3142
- minQuietPeriodMs: 100
3471
+ else if (typeof module !== "undefined" && module != null) module.exports = LZString;
3472
+ else if (typeof angular !== "undefined" && angular != null) angular.module("LZString", []).factory("LZString", function() {
3473
+ return LZString;
3143
3474
  });
3144
- function setTarget() {
3145
- if (!isDragAndDropEnabled) return;
3146
- targetUnsetter.cancel();
3147
- targetSetter.call();
3148
- }
3149
- function unsetTarget() {
3150
- if (!isDragAndDropEnabled) return;
3151
- targetSetter.cancel();
3152
- targetUnsetter.call();
3153
- }
3154
- return {
3155
- isDropTarget,
3156
- setTarget,
3157
- unsetTarget
3158
- };
3159
- }
3160
- const draggingNodeEventFunctions = makePHEventFunctions("draggingNode");
3161
- const useDraggingNode = draggingNodeEventFunctions.useValue;
3162
- const setDraggingNode = draggingNodeEventFunctions.setValue;
3163
- draggingNodeEventFunctions.addEventHandler;
3164
- const draggingNodeSetter = n$1((node) => setDraggingNode(node), {
3165
- reducer: (_, newNode) => newNode,
3166
- triggerAt: "start",
3167
- minQuietPeriodMs: 100
3168
- });
3169
- const draggingNodeUnsetter = n$1(() => setDraggingNode(void 0), {
3170
- triggerAt: "start",
3171
- minQuietPeriodMs: 100
3172
- });
3173
- function setDragging(node) {
3174
- draggingNodeUnsetter.cancel();
3175
- draggingNodeSetter.call(node);
3176
- }
3177
- function unsetDragging() {
3178
- draggingNodeSetter.cancel();
3179
- draggingNodeUnsetter.call();
3180
- }
3181
- const isNodeDrag = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$1)(driveId), e$6(false)], [({ driveId, srcId }) => t(driveId, srcId), e$6(false)], e$6(true));
3182
- function useDragNode(args) {
3183
- const { srcId, parentId } = args;
3184
- const driveId = useSelectedDriveId();
3185
- const draggingNodeId = useDraggingNode()?.srcId;
3186
- const params = {
3187
- driveId,
3188
- srcId,
3189
- parentId
3190
- };
3191
- const draggable = isNodeDrag(params);
3192
- const isDragging = t$4({
3193
- srcId,
3194
- draggingNodeId
3195
- }, [
3196
- () => draggable,
3197
- ({ srcId }) => e$2(srcId),
3198
- ({ draggingNodeId }) => e$2(draggingNodeId),
3199
- ({ srcId, draggingNodeId }) => t(srcId, draggingNodeId)
3200
- ]);
3201
- const onDragStart = () => {
3202
- if (!draggable) return;
3203
- setDragging(params);
3204
- };
3205
- const onDragEnd = () => {
3206
- if (!draggable) return;
3207
- unsetDragging();
3208
- };
3209
- return {
3210
- isDragging,
3211
- draggable,
3212
- onDragStart,
3213
- onDragEnd
3214
- };
3215
- }
3216
- const isNodeDrop = (params) => t$3(params, [({ srcId }) => e$3(e$1)(srcId), e$6(false)], [({ driveId }) => e$3(e$4)(driveId), e$6(false)], [({ srcId, targetId }) => t(srcId, targetId), e$6(false)], [({ driveId, parentId, targetId }) => e$3(e$1)(parentId) && t(targetId, driveId), e$6(false)], [({ targetId, parentId }) => t(targetId, parentId), e$6(false)], e$6(true));
3217
- function useDropNode(targetId) {
3218
- const driveId = useSelectedDriveId();
3219
- const { srcId, parentId } = useDraggingNode() ?? {};
3220
- const { isDropTarget, setTarget, unsetTarget } = useDropTarget();
3221
- const params = {
3222
- driveId,
3223
- parentId,
3224
- targetId,
3225
- srcId
3226
- };
3227
- function handleNodeDrop(event, cb) {
3228
- if (!isNodeDrop(params)) return;
3229
- event.preventDefault();
3230
- event.stopPropagation();
3231
- cb?.();
3232
- }
3233
- const onDragEnter = (event) => handleNodeDrop(event);
3234
- const onDragOver = (event) => handleNodeDrop(event, e(setTarget));
3235
- const onDragLeave = (event) => handleNodeDrop(event, e(unsetTarget));
3236
- const onDrop = (event) => handleNodeDrop(event, e(() => {
3237
- unsetDragging();
3238
- unsetTarget();
3239
- moveNodeById(params).catch(console.error);
3240
- }));
3241
- return {
3242
- isDropTarget,
3243
- onDragEnter,
3244
- onDragOver,
3245
- onDragLeave,
3246
- onDrop
3247
- };
3248
- }
3249
- const graphQLReactorClientEventFunctions = makePHEventFunctions("reactorGraphQLClient");
3250
- graphQLReactorClientEventFunctions.useValue;
3251
- graphQLReactorClientEventFunctions.setValue;
3252
- graphQLReactorClientEventFunctions.addEventHandler;
3253
- const packageDiscoveryFunctions = makePHEventFunctions("packageDiscoveryService");
3254
- packageDiscoveryFunctions.useValue;
3255
- packageDiscoveryFunctions.setValue;
3256
- packageDiscoveryFunctions.addEventHandler;
3257
- const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
3258
- const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
3259
- /** Returns the reactor client module (in-process or worker-backed) */
3260
- const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
3261
- reactorClientModuleEventFunctions.setValue;
3262
- reactorClientModuleEventFunctions.addEventHandler;
3263
- reactorClientEventFunctions.useValue;
3264
- reactorClientEventFunctions.setValue;
3265
- reactorClientEventFunctions.addEventHandler;
3266
- const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
3267
- const useSyncList = () => {
3268
- return useSync()?.list() ?? [];
3269
- };
3270
- const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
3271
- revisionHistoryEventFunctions.useValue;
3272
- /** Sets revision history visibility */
3273
- const setRevisionHistoryVisible = revisionHistoryEventFunctions.setValue;
3274
- revisionHistoryEventFunctions.addEventHandler;
3275
- /** Shows the revision history */
3276
- function showRevisionHistory() {
3277
- setRevisionHistoryVisible(true);
3278
- }
3279
- /** Sorts nodes by name. */
3280
- function sortNodesByName(nodes) {
3281
- return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
3282
- }
3283
- /** Returns whether a node is a file. */
3284
- function isFileNodeKind(node) {
3285
- if (!node) return false;
3286
- return node.kind.toUpperCase() === "FILE";
3287
- }
3288
- /** Returns whether a node is a folder. */
3289
- function isFolderNodeKind(node) {
3290
- if (!node) return false;
3291
- return node.kind.toUpperCase() === "FOLDER";
3292
- }
3293
- /** Returns the nodes in the selected drive. */
3294
- function useNodesInSelectedDrive() {
3295
- const [selectedDrive] = useSelectedDriveSafe();
3296
- return selectedDrive?.state.global.nodes;
3297
- }
3298
- /** Returns the folder nodes in the selected drive. */
3299
- function useFolderNodesInSelectedDrive() {
3300
- return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
3301
- }
3302
- /** Returns the selected node. */
3303
- function useSelectedNode() {
3304
- const selectedNodeId = useSelectedNodeId();
3305
- return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
3306
- }
3307
- const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
3308
- selectedTimelineItemEventFunctions.useValue;
3309
- selectedTimelineItemEventFunctions.setValue;
3310
- selectedTimelineItemEventFunctions.addEventHandler;
3311
- const selectedTimelineRevisionEventFunctions = makePHEventFunctions("selectedTimelineRevision");
3312
- selectedTimelineRevisionEventFunctions.useValue;
3313
- selectedTimelineRevisionEventFunctions.setValue;
3314
- selectedTimelineRevisionEventFunctions.addEventHandler;
3315
- const toastEventFunctions = makePHEventFunctions("toast");
3316
- /** Returns the toast function */
3317
- const usePHToast = toastEventFunctions.useValue;
3318
- toastEventFunctions.setValue;
3319
- toastEventFunctions.addEventHandler;
3320
- const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
3321
- const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
3322
- /** Returns all of the Vetra packages loaded by the Connect instance */
3323
- const useVetraPackages = () => {
3324
- const packageManager = useVetraPackageManager();
3325
- return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
3326
- };
3327
- vetraPackageManagerFunctions.addEventHandler;
3328
- function useDocumentModelModules() {
3329
- return useVetraPackages().flatMap((pkg) => pkg.documentModels).filter((module, index, modules) => modules.findIndex((m) => m.documentModel.global.id === module.documentModel.global.id && m.version === module.version) === index);
3330
- }
3331
- function useDocumentModelModuleById(id) {
3332
- return useDocumentModelModules()?.find((module) => module.documentModel.global.id === id);
3333
- }
3475
+ })))(), 1);
3476
+ /** Document types that represent a "drive": a container of nodes. */
3477
+ const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
3334
3478
  function useAllowedDocumentModelModules() {
3335
3479
  const documentModelModules = useDocumentModelModules();
3336
3480
  const allowedDocumentTypes = useAllowedDocumentTypes();
@@ -3515,7 +3659,7 @@ function useNodeActions() {
3515
3659
  }
3516
3660
  async function onAddFolder(name, parent) {
3517
3661
  if (!selectedDriveId) return;
3518
- return addFolder(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
3662
+ return addFolder$1(selectedDriveId, name, resolveNode(selectedDriveId, parent)?.id);
3519
3663
  }
3520
3664
  async function onRenameNode(newName, node) {
3521
3665
  if (!selectedDriveId) return;
@@ -3602,6 +3746,9 @@ function useSelectedNodePath() {
3602
3746
  function useNodeParentFolderById(id) {
3603
3747
  return useFolderById(useNodeById(id)?.parentFolder);
3604
3748
  }
3749
+ function useParentFolderForSelectedNode() {
3750
+ return useNodeParentFolderById(useSelectedNode()?.id);
3751
+ }
3605
3752
  /** Returns the selected document id */
3606
3753
  function useSelectedDocumentId() {
3607
3754
  const selectedNode = useSelectedNode();
@@ -3830,6 +3977,6 @@ function createDebouncedRefreshReactorDataClient(debounceDelayMs = DEFAULT_DEBOU
3830
3977
  createDebouncedRefreshReactorData();
3831
3978
  createDebouncedRefreshReactorDataClient();
3832
3979
  //#endregion
3833
- export { useSetPHDocumentEditorConfig as A, usePHToast as C, useSelectedDriveSafe as D, useSelectedDriveId as E, t$2 as F, t$5 as I, useDocumentById as L, useUserPermissions as M, e$1 as N, useSelectedNodePath as O, e$4 as P, useNodesInSelectedDriveOrFolder as S, useSelectedDocumentSafe as T, useEditorModulesForDocumentType as _, preloadEditorModule as a, useNodeById as b, showCreateDocumentModal as c, useAllowedDocumentModelModules as d, useDisabledEditors as f, useEditorModules as g, useDropNode as h, isFolderNodeKind as i, useTheme as j, useSetPHAppConfig as k, showDeleteNodeModal as l, useDragNode as m, getSyncStatusSync as n, setSelectedDrive as o, useDownloadDocument as p, isFileNodeKind as r, setSelectedNode as s, addFolder as t, showRevisionHistory as u, useGetSwitchboardLink as v, useSelectedDocumentOfType as w, useNodeParentFolderById as x, useNodeActions as y };
3980
+ export { useDragNode as A, isFileNodeKind as C, showDeleteNodeModal as D, setSelectedNode as E, e$1 as F, e$4 as I, t$2 as L, usePHToast as M, useSelectedDriveId as N, showRevisionHistory as O, useSelectedDriveSafe as P, t$5 as R, addFolder$1 as S, setSelectedDrive as T, useSetPHAppConfig as _, useEditorModules as a, useUserPermissions as b, useNodeActions as c, useNodesInSelectedDriveOrFolder as d, useParentFolderForSelectedNode as f, useSelectedNodePath as g, useSelectedFolder as h, useDownloadDocument as i, useDropNode as j, useDisabledEditors as k, useNodeById as l, useSelectedDocumentSafe as m, preloadEditorModule as n, useEditorModulesForDocumentType as o, useSelectedDocumentOfType as p, useAllowedDocumentModelModules as r, useGetSwitchboardLink as s, getSyncStatusSync as t, useNodeParentFolderById as u, useSetPHDocumentEditorConfig as v, isFolderNodeKind as w, addDocument as x, useTheme as y, useDocumentById as z };
3834
3981
 
3835
- //# sourceMappingURL=dist-8nCvrie2.mjs.map
3982
+ //# sourceMappingURL=dist-CUHBOv3P.mjs.map