@powerhousedao/connect 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddDriveModal.DTQmLkRW.js → AddDriveModal.Co18Guku.js} +2 -2
- package/dist/assets/{AddDriveModal.DTQmLkRW.js.map → AddDriveModal.Co18Guku.js.map} +1 -1
- package/dist/assets/{CreateDocumentModal.CL5_6y3O.js → CreateDocumentModal.CaioRAB5.js} +2 -2
- package/dist/assets/{CreateDocumentModal.CL5_6y3O.js.map → CreateDocumentModal.CaioRAB5.js.map} +1 -1
- package/dist/assets/{DebugSettingsModal.CvUCX6AI.js → DebugSettingsModal.Dc-lh2p_.js} +2 -2
- package/dist/assets/{DebugSettingsModal.CvUCX6AI.js.map → DebugSettingsModal.Dc-lh2p_.js.map} +1 -1
- package/dist/assets/{SettingsModal.A29jTwO1.js → SettingsModal.PrY-Ocw1.js} +2 -2
- package/dist/assets/{SettingsModal.A29jTwO1.js.map → SettingsModal.PrY-Ocw1.js.map} +1 -1
- package/dist/assets/{app.BphhVPY9.js → app.p03Jbd-6.js} +4 -4
- package/dist/assets/{app.BphhVPY9.js.map → app.p03Jbd-6.js.map} +1 -1
- package/dist/assets/{atlas-import.BVl4fbI6.js → atlas-import.CZu-y-lV.js} +2 -2
- package/dist/assets/{atlas-import.BVl4fbI6.js.map → atlas-import.CZu-y-lV.js.map} +1 -1
- package/dist/assets/{connect.config.BAfiKr20.js → connect.config._T1v6EoS.js} +2 -2
- package/dist/assets/{connect.config.BAfiKr20.js.map → connect.config._T1v6EoS.js.map} +1 -1
- package/dist/assets/{content.CEwaGXuh.js → content.Bm5SXqTG.js} +2 -2
- package/dist/assets/{content.CEwaGXuh.js.map → content.Bm5SXqTG.js.map} +1 -1
- package/dist/assets/{cookie-banner.p38g8xUo.js → cookie-banner.DHaEPv4f.js} +2 -2
- package/dist/assets/{cookie-banner.p38g8xUo.js.map → cookie-banner.DHaEPv4f.js.map} +1 -1
- package/dist/assets/{home.C4S42bTu.js → home.BOhOCme9.js} +2 -2
- package/dist/assets/{home.C4S42bTu.js.map → home.BOhOCme9.js.map} +1 -1
- package/dist/assets/{index.CEKa8Fji.js → index.Bc5mN9Zd.js} +2 -2
- package/dist/assets/{index.CEKa8Fji.js.map → index.Bc5mN9Zd.js.map} +1 -1
- package/dist/assets/{index.0AiLbVU1.js → index.C9cXurZH.js} +2 -2
- package/dist/assets/{index.0AiLbVU1.js.map → index.C9cXurZH.js.map} +1 -1
- package/dist/assets/{index.CZ7j2DZj.js → index.CIKNjgvt.js} +3 -3
- package/dist/assets/{index.CZ7j2DZj.js.map → index.CIKNjgvt.js.map} +1 -1
- package/dist/assets/{index.-24VHt4X.js → index.D1LmSqIY.js} +2 -2
- package/dist/assets/{index.-24VHt4X.js.map → index.D1LmSqIY.js.map} +1 -1
- package/dist/assets/index.DFyMrewv.js.map +1 -1
- package/dist/assets/{index.BeT7gpI8.js → index.P5mz_7_c.js} +2 -2
- package/dist/assets/{index.BeT7gpI8.js.map → index.P5mz_7_c.js.map} +1 -1
- package/dist/assets/{index.CJ6lG_Wb.js → index.nPXtj_yn.js} +2 -2
- package/dist/assets/{index.CJ6lG_Wb.js.map → index.nPXtj_yn.js.map} +1 -1
- package/dist/assets/{main.-mZWVdr-.js → main.Cvp8g1Yn.js} +3 -3
- package/dist/assets/{main.-mZWVdr-.js.map → main.Cvp8g1Yn.js.map} +1 -1
- package/dist/assets/{modal.D7XhYnZR.js → modal.ChDGZoHG.js} +3 -3
- package/dist/assets/{modal.D7XhYnZR.js.map → modal.ChDGZoHG.js.map} +1 -1
- package/dist/assets/{modals.CtBRZQUb.js → modals.BUDWDdmy.js} +2 -2
- package/dist/assets/{modals.CtBRZQUb.js.map → modals.BUDWDdmy.js.map} +1 -1
- package/dist/assets/{registerServiceWorker.CYN4Klg3.js → registerServiceWorker.DoRTBtYI.js} +2 -2
- package/dist/assets/{registerServiceWorker.CYN4Klg3.js.map → registerServiceWorker.DoRTBtYI.js.map} +1 -1
- package/dist/assets/{root.Wi3khl8r.js → root.-e9qWpwj.js} +2 -2
- package/dist/assets/{root.Wi3khl8r.js.map → root.-e9qWpwj.js.map} +1 -1
- package/dist/assets/{useAcceptedCookies.DwxJsFr2.js → useAcceptedCookies.szoyvsjl.js} +2 -2
- package/dist/assets/{useAcceptedCookies.DwxJsFr2.js.map → useAcceptedCookies.szoyvsjl.js.map} +1 -1
- package/dist/assets/useConnectConfig.CYEP32RG.js +2 -0
- package/dist/assets/{useConnectConfig.JCoDhzuj.js.map → useConnectConfig.CYEP32RG.js.map} +1 -1
- package/dist/assets/{useDefaultDocumentModelEditor.B43PMqGl.js → useDefaultDocumentModelEditor.DNpBOumt.js} +2 -2
- package/dist/assets/{useDefaultDocumentModelEditor.B43PMqGl.js.map → useDefaultDocumentModelEditor.DNpBOumt.js.map} +1 -1
- package/dist/assets/{useDocumentDriveServer.OThcLdfg.js → useDocumentDriveServer.DyeegGAO.js} +2 -2
- package/dist/assets/{useDocumentDriveServer.OThcLdfg.js.map → useDocumentDriveServer.DyeegGAO.js.map} +1 -1
- package/dist/assets/{useFeatureFlags.Cj7jQ21q.js → useFeatureFlags.B1cQjxLV.js} +2 -2
- package/dist/assets/{useFeatureFlags.Cj7jQ21q.js.map → useFeatureFlags.B1cQjxLV.js.map} +1 -1
- package/dist/assets/{user.DFdIcEeb.js → user.D5A2C_6c.js} +4 -4
- package/dist/assets/{user.DFdIcEeb.js.map → user.D5A2C_6c.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/vite-envs.sh +1 -1
- package/package.json +9 -9
- package/dist/assets/useConnectConfig.JCoDhzuj.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":";2kDAEA,SAASA,GAAgBC,EAAK,CAC1B,MAAI,uBAAwBA,EACjBA,EAAI,mBAERA,EAAI,aACf,CACO,MAAMC,GAAiB,CAAC,CAAE,eAAAC,EAAgB,eAAAC,KACrCC,EAAM,MAA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IAGhC4b,KAAO,KAAE,mBAAO5b,EAAQ,cAAU,EAAM,CAAE,KAAM,UAAW,EAC3DoP,EAAS,GAAG,EAChB,EACD,CAACqM,EAAQzb,EAASuU,CAAc,CAAC,IAG/B,OAAI,UAAU,qCAAqC,GAAG,eAClD,WACGtI,EAACsE,GAAA,GAA6B/I,EAAiB,UAAY,EAC3DI,EACAqE,EAACuH,MAA0B5L,EAAkB,EAAI,EACjD,KACR,CAER","names":["getDocumentSpec","doc","CreateDocument","documentModels","createDocument","_jsxs","_jsx","spec","Button","sortUiNodesByName","a","b","GAP","ITEM_WIDTH","ITEM_HEIGHT","USED_SPACE","FileContentView","props","parentRef","useRef","t","useTranslation","windowSize","useWindowSize","fileNodes","fileProps","availableWidth","columnCount","rowCount","rowVirtualizer","useVirtualizer","index","columnVirtualizer","getItemIndex","rowIndex","columnIndex","getItem","renderItem","fileNode","FileItem","virtualRow","React","virtualColumn","DriveLayout","children","className","containerProps","cn","title","FolderView","node","isDropTarget","nodeProps","folderNodes","FOLDER","FILE","folderCallbacks","name","fileCallbacks","baseNodeCallbacks","file","parentNode","uiNode","targetNode","twMerge","folderNode","FolderItem","defaultFilterItems","Icon","SearchBar","value","setValue","useState","ConnectSearchBar","BaseEditor","document","dispatch","driveId","showSearchBar","isAllowedToCreateDocuments","showCreateDocumentModal","useDriveContext","driveNodes","selectedNode","selectedNodePath","getNodeById","setSelectedNode","useUiNodesContext","driveNode","useMemo","n","addDocument","addFile","addFolder","renameNode","deleteNode","moveNode","copyNode","duplicateNode","useDriveActionsWithUiNodes","onCreateDocument","useCallback","documentModel","isDropTargetFolder","dropPropsFolder","useDrop","dropProps","breadcrumbs","onBreadcrumbSelected","useBreadcrumbs","_Fragment","Breadcrumbs","Editor","DriveContextProvider","GenericDriveExplorer","useAnalyticsQueryWrapper","options","queryFn","queryOptions","store","useAnalyticsStoreAsync","engine","useAnalyticsEngineAsync","enabled","useQuery","DEBOUNCE_INTERVAL","useAnalyticsQuery","query","queryClient","useQueryClient","sources","result","useEffect","subscriptions","invalidateTimeout","debouncedInvalidate","e","path","unsub","getBarSize","addItemsDividers","items","item","currentDate","nextDate","currentHour","nextHour","currentDay","nextDay","metricsToItems","metrics","aDate","bDate","row","additions","deletions","acc","startDate","useTimelineItems","documentId","startTimestamp","start","DateTime","AnalyticsGranularity","AnalyticsPath","getRevisionFromDate","endDate","operations","operation","operationDate","themeAtom","atomWithStorageCallback","theme","_a","debounceOperations","callback","timeout","timer","op","oldOperation","resolve","reject","documentCacheAtom","atom","singletonFileNodeDocumentAtom","isSameDocument","prev","next","hashDocumentStateForScope","fileNodeDocumentAtom","get","set","newValue","currentValue","documentCache","documentToHash","selectedDocumentAtom","fileNodeDocument","useSetSelectedDocument","useSetAtom","useFileNodeDocument","selectedDriveNode","openFile","addOperations","onStrandUpdate","useDocumentDriveServer","fetchReadDocument","useReadModeContext","setFileNodeDocument","useAtom","isReadMode","kind","documentType","setSelectedDocument","fetchDocument","id","error","logger","strand","addOperationToSelectedDocument","addOperationToSelectedDrive","isSelectedDocument","selectedDocument","loadBaseEditors","documentModelEditor","__vitePreload","getEditorsFromModules","modules","module","val","baseEditorsAtom","atomWithLazy","editorsAtom","baseEditors","externalModules","externalPackagesAtom","unwrappedEditorsAtom","unwrap","loadableEditorsAtom","loadable","useUnwrappedEditors","useAtomValue","getEditor","editors","preferredEditorId","preferredEditor","useGetEditor","defaultDocumentModelEditor","useDefaultDocumentModelEditor","openBrowserUrl","url","openUrl","validateDocument","errors","specs","initialStateErrors","scopeKey","scope","validateInitialState","err","schemaStateErrors","isGlobalScope","validateStateSchemaName","modulesErrors","validateModules","EditorLoader","showLoading","setShowLoading","customEditorLoader","defaultProps","jsx","Fragment","DefaultEditorLoader","EditorError","message","FallbackEditorError","DocumentEditor","initialDocument","onClose","onChange","onExport","onAddOperation","onGetDocumentRevision","onOpenSwitchboardLink","selectedTimelineItem","setSelectedTimelineItem","revisionHistoryVisible","setRevisionHistoryVisible","user","useUser","connectDid","useConnectDid","sign","useConnectCrypto","getDocumentModelModule","useGetDocumentModelModule","editor","_dispatch","useDocumentDispatch","context","userPermissions","useUserPermissions","timelineItems","currentDocument","action","onErrorCallback","state","prevState","signOperation","addActionContext","showRevisionHistory","hideRevisionHistory","handleUndo","undo","handleRedo","redo","isLoadingDocument","isLoadingEditor","canUndo","canRedo","useUndoRedoShortcuts","navigate","useNavigate","showModal","useModal","editorError","setEditorError","handleEditorError","info","jsxs","EditorComponent","disableExternalControls","documentToolbarEnabled","showSwitchboardLink","timelineEnabled","handleSwitchboardLinkClick","DocumentToolbar","RevisionHistory","Suspense","ErrorBoundary","DocumentEditorContainer","selectedParentNode","isRemoteDrive","remoteUrl","useDocumentDriveById","getDocument","useGetDocument","handleAddOperationToSelectedDocument","onDocumentChangeHandler","exportDocument","validationErrors","closeModal","exportFile","documentModelModule","buildDocumentSubgraphUrl","useDocumentsState","args","reactor","documentIds","statesByDocumentId","setStatesByDocumentId","isInitialized","isSubscribed","initialize","ids","update","updatedDocument","newStatesByDocumentId","makeDriveDocumentStateHook","useDocumentState","DELETE_NODE_OPERATION_TYPE","useGetDriveDocuments","documents","setDocuments","getDocumentsIds","onOperationsAdded","fetchDocuments","_driveId","_documentIds","_deletedNodes","getDocumentsPromise","newDocumentsState","newState","nodeId","deletedNodes","deletedNodesIds","DriveEditorError","useSelectedDocumentDrive","documentDrive","DriveEditorContainer","driveDocumentModelModule","useReactor","handleAddOperationToSelectedDrive","editorProps","useEditorProps","useFilteredDocumentModels","useDriveDocumentState","driveContext","useSyncStatus","useDocumentEditor","driveEditor","useDriveEditor","DriveEditorComponent","connectConfig","documentDrives","drive","pullResponder","trigger","useUnwrappedReactor","useDocument","useDocumentEditorProps","useEditorDispatch","documentDispatch","getSyncStatusSync","onSyncStatus","useSyncExternalStore","onStoreChange","_drive","_sharingType","sharingType","_extends","r","reservedModifierKeywords","mappedKeys","mapKey","key","isHotkeyModifier","parseKeysHookInput","keys","splitKey","parseHotkey","hotkey","combinationKey","description","k","modifiers","singleCharKeys","pushToCurrentlyPressedKeys","removeFromCurrentlyPressedKeys","currentlyPressedKeys","isReadonlyArray","isHotkeyPressed","hotkeyArray","maybePreventDefault","preventDefault","isHotkeyEnabled","isKeyboardEventTriggeredByInput","ev","isHotkeyEnabledOnTag","event","enabledOnTags","target","composed","targetTagName","isCustomElement","tag","_targetTagName","element","isScopeActive","activeScopes","scopes","isHotkeyMatchingKeyboardEvent","ignoreModifiers","alt","meta","mod","shift","ctrl","pressedKeyUppercase","code","ctrlKey","metaKey","shiftKey","altKey","keyCode","pressedKey","BoundHotkeysProxyProvider","createContext","useBoundHotkeysProxy","useContext","deepEqual","x","y","isEqual","HotkeysContext","useHotkeysContext","useDeepEqualMemo","ref","stopPropagation","useSafeLayoutEffect","useLayoutEffect","useHotkeys","dependencies","_useState","setRef","hasTriggeredRef","_options","_keys","_deps","memoisedCB","cbRef","memoisedOptions","_useHotkeysContext","enabledScopes","proxy","listener","isKeyUp","_e$target","rootNode","_hotkey$keys","handleKeyDown","handleKeyUp","domNode","isMac","undoShortcut","redoShortcut","Content","useParams","status","useDocumentDrives","d","toast"],"ignoreList":[27],"sources":["../../../../packages/common/dist/editors/generic-drive-explorer/components/create-document.js","../../../../packages/common/dist/editors/utils/uiNodes.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/file-content-view.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/layout.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/folder-view.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/search-bar.js","../../../../packages/common/dist/editors/generic-drive-explorer/editor.js","../../../../packages/common/dist/editors/generic-drive-explorer/index.js","../../../../packages/reactor-browser/dist/src/analytics/hooks.js","../../../../packages/common/dist/hooks/useTimelineItems.js","../../../../packages/common/dist/utils/index.js","../../src/store/theme.ts","../../src/store/document-drive.ts","../../src/store/editor.ts","../../src/utils/openUrl.ts","../../src/utils/validate-document.ts","../../src/components/editor-loader.tsx","../../src/components/editors.tsx","../../src/components/document-editor-container.tsx","../../../../packages/reactor-browser/dist/src/hooks/document-state.js","../../src/hooks/useGetDriveDocuments.ts","../../src/components/drive-editor-container.tsx","../../src/hooks/useDocumentDriveById.ts","../../src/hooks/useDocumentEditor.ts","../../src/hooks/useEditorProps.tsx","../../src/hooks/useGetDocument.ts","../../src/hooks/useSyncStatus.ts","../../../../node_modules/.pnpm/react-hotkeys-hook@4.6.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js","../../src/hooks/useUndoRedoShortcuts.ts","../../src/pages/content.tsx"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Button } from \"@powerhousedao/design-system\";\nfunction getDocumentSpec(doc) {\n if (\"documentModelState\" in doc) {\n return doc.documentModelState;\n }\n return doc.documentModel;\n}\nexport const CreateDocument = ({ documentModels, createDocument, }) => {\n return (_jsxs(\"div\", { className: \"px-6\", children: [_jsx(\"h3\", { className: \"mb-3 mt-4 text-xl font-bold text-gray-600\", children: \"New document\" }), _jsx(\"div\", { className: \"flex w-full flex-wrap gap-4\", children: documentModels?.map((doc) => {\n const spec = getDocumentSpec(doc);\n return (_jsx(Button, { color: \"light\", title: spec.name, \"aria-description\": spec.description, onClick: () => createDocument(doc), children: _jsx(\"span\", { className: \"text-sm\", children: spec.name }) }, spec.id));\n }) })] }));\n};\n//# sourceMappingURL=create-document.js.map","import { DRIVE, FILE, LOCAL, } from \"@powerhousedao/reactor-browser/uiNodes/constants\";\nimport { isFolderNode, } from \"document-drive\";\nexport function sortUiNodesByName(a, b) {\n return a.name.localeCompare(b.name);\n}\nexport function makeNodeSlugFromNodeName(name) {\n return name.replaceAll(/\\s/g, \"-\");\n}\nexport function makeUiNode(node, drive, withChildren) {\n const { id, slug } = drive.header;\n const { name, icon, nodes } = drive.state.global;\n const { sharingType: _sharingType, availableOffline } = drive.state.local;\n const __sharingType = _sharingType?.toUpperCase();\n const sharingType = __sharingType === \"PRIVATE\" ? LOCAL : __sharingType;\n // TODO: handle sync status\n // const normalizedDriveSyncStatus =\n // syncStatus === 'INITIAL_SYNC'\n // ? 'SYNCING'\n // : syncStatus;\n if (node) {\n const uiNode = {\n ...node,\n slug: makeNodeSlugFromNodeName(node.name),\n driveId: id,\n parentFolder: node.parentFolder || id,\n kind: node.kind.toUpperCase(),\n syncStatus: undefined,\n sharingType,\n };\n if (uiNode.kind === FILE) {\n return uiNode;\n }\n else if (isFolderNode(node)) {\n return {\n ...uiNode,\n children: withChildren\n ? nodes\n .filter((n) => n.parentFolder === node.id)\n .map((n) => makeUiNode(n, drive, false))\n : [],\n };\n }\n }\n return {\n id,\n name,\n slug: slug || null,\n kind: DRIVE,\n nodeMap: {},\n sharingType,\n syncStatus: undefined,\n availableOffline,\n icon,\n parentFolder: null,\n driveId: id,\n children: nodes\n .filter((n) => n.parentFolder)\n .map((n) => makeUiNode(n, drive, false)),\n };\n}\nexport function makeUiDriveNode(drive) {\n const driveNode = makeUiNode(undefined, drive, true);\n driveNode.nodeMap = drive.state.global.nodes.reduce((acc, node) => {\n acc[node.id] = makeUiNode(node, drive, true);\n return acc;\n }, {});\n return driveNode;\n}\n//# sourceMappingURL=uiNodes.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { FileItem, useWindowSize, } from \"@powerhousedao/design-system\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport React, { useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nconst GAP = 8;\nconst ITEM_WIDTH = 256;\nconst ITEM_HEIGHT = 48;\nconst USED_SPACE = 420;\nexport function FileContentView(props) {\n const parentRef = useRef(null);\n const { t } = useTranslation();\n const windowSize = useWindowSize();\n const { fileNodes, ...fileProps } = props;\n const availableWidth = windowSize.innerWidth - USED_SPACE;\n const columnCount = Math.floor(availableWidth / (ITEM_WIDTH + GAP)) || 1;\n const rowCount = Math.ceil(fileNodes.length / columnCount);\n const rowVirtualizer = useVirtualizer({\n count: rowCount,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n if (index > 0) {\n return ITEM_HEIGHT + GAP;\n }\n return ITEM_HEIGHT;\n },\n overscan: 5,\n });\n const columnVirtualizer = useVirtualizer({\n horizontal: true,\n count: columnCount,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n if (index > 0) {\n return ITEM_WIDTH + GAP;\n }\n return ITEM_WIDTH;\n },\n overscan: 5,\n });\n const getItemIndex = (rowIndex, columnIndex) => rowIndex * columnCount + columnIndex;\n const getItem = (rowIndex, columnIndex) => {\n const index = getItemIndex(rowIndex, columnIndex);\n return fileNodes[index] || null;\n };\n if (fileNodes.length === 0) {\n return (_jsx(\"div\", { className: \"mb-8 text-sm text-gray-400\", children: t(\"folderView.sections.documents.empty\", {\n defaultValue: \"No documents or files 📄\",\n }) }));\n }\n const renderItem = (rowIndex, columnIndex) => {\n const fileNode = getItem(rowIndex, columnIndex);\n if (!fileNode) {\n return null;\n }\n return (_jsx(\"div\", { style: {\n marginLeft: columnIndex === 0 ? 0 : GAP,\n }, children: _jsx(FileItem, { uiNode: fileNode, ...fileProps }, fileNode.id) }));\n };\n return (_jsx(\"div\", { ref: parentRef, style: {\n height: `400px`,\n width: `100%`,\n overflow: \"auto\",\n }, children: _jsx(\"div\", { style: {\n height: `${rowVirtualizer.getTotalSize()}px`,\n width: `${columnVirtualizer.getTotalSize()}px`,\n position: \"relative\",\n }, children: rowVirtualizer.getVirtualItems().map((virtualRow) => (_jsx(React.Fragment, { children: columnVirtualizer.getVirtualItems().map((virtualColumn) => (_jsx(\"div\", { style: {\n position: \"absolute\",\n top: 0,\n left: 0,\n marginTop: virtualRow.index === 0 ? 0 : GAP,\n width: `${virtualColumn.size}px`,\n height: `${virtualRow.size}px`,\n transform: `translateX(${virtualColumn.start}px) translateY(${virtualRow.start}px)`,\n }, children: renderItem(virtualRow.index, virtualColumn.index) }, virtualColumn.key))) }, virtualRow.key))) }) }));\n}\nexport default FileContentView;\n//# sourceMappingURL=file-content-view.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { cn } from \"@powerhousedao/design-system\";\nexport function DriveLayout({ children, className, ...props }) {\n return (_jsx(DriveLayout.Container, { className: className, ...props, children: children }));\n}\nDriveLayout.Container = function DriveLayoutContainer({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"flex grow flex-col overflow-auto rounded-2xl bg-gray-50 p-2\", className), ...containerProps, ...props, children: children }));\n};\nDriveLayout.Header = function DriveLayoutHeader({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"flex-0\", className), ...containerProps, ...props, children: children }));\n};\nDriveLayout.Content = function DriveLayoutContent({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"mb-5 flex-1 px-4\", className), ...containerProps, ...props, children: children }));\n};\nDriveLayout.ContentSection = function DriveLayoutContentSection({ title, children, className, containerProps, ...props }) {\n return (_jsxs(\"div\", { className: cn(className), ...containerProps, ...props, children: [title && (_jsx(\"div\", { className: \"mb-4 text-base font-semibold text-gray-600\", children: title })), _jsx(\"div\", { className: \"flex flex-wrap gap-2\", children: children })] }));\n};\nDriveLayout.Footer = function DriveLayoutFooter({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"flex-0\", className), ...containerProps, ...props, children: children }));\n};\n//# sourceMappingURL=layout.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { FILE, FOLDER, FolderItem, } from \"@powerhousedao/design-system\";\nimport { useTranslation } from \"react-i18next\";\nimport { twMerge } from \"tailwind-merge\";\nimport { sortUiNodesByName } from \"../../utils/uiNodes.js\";\nimport FileContentView from \"./file-content-view.js\";\nimport { DriveLayout } from \"./layout.js\";\nexport function FolderView(props) {\n const { node, className, isDropTarget, containerProps, ...nodeProps } = props;\n const { t } = useTranslation();\n // Remove after ts reset is fixed\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const folderNodes = node.children\n .filter((node) => node.kind === FOLDER)\n .sort(sortUiNodesByName);\n // Remove after ts reset is fixed\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const fileNodes = node.children\n .filter((node) => node.kind === FILE)\n .sort(sortUiNodesByName);\n // Convert UiNode callbacks to BaseUiFolderNode callbacks\n const folderCallbacks = {\n onSelectNode: (node) => nodeProps.onSelectNode(node),\n onRenameNode: (name, node) => nodeProps.onRenameNode(name, node),\n onDuplicateNode: (node) => nodeProps.onDuplicateNode(node),\n onDeleteNode: (node) => nodeProps.onDeleteNode(node),\n };\n // Convert UiNode callbacks to BaseUiFileNode callbacks\n const fileCallbacks = {\n onSelectNode: (node) => nodeProps.onSelectNode(node),\n onRenameNode: (name, node) => nodeProps.onRenameNode(name, node),\n onDuplicateNode: (node) => nodeProps.onDuplicateNode(node),\n onDeleteNode: (node) => nodeProps.onDeleteNode(node),\n };\n // Convert UiNode callbacks to BaseUiNode callbacks\n const baseNodeCallbacks = {\n onAddFile: async (file, parentNode) => {\n await nodeProps.onAddFile(file, parentNode);\n },\n onCopyNode: async (uiNode, targetNode) => {\n await nodeProps.onCopyNode(uiNode, targetNode);\n },\n onMoveNode: async (uiNode, targetNode) => {\n await nodeProps.onMoveNode(uiNode, targetNode);\n },\n };\n return (_jsxs(\"div\", { className: twMerge(\"rounded-md border-2 border-transparent p-2\", isDropTarget && \"border-dashed border-blue-100\", className), ...containerProps, children: [_jsx(DriveLayout.ContentSection, { title: t(\"folderView.sections.folders.title\", {\n defaultValue: \"Folders\",\n }), className: \"mb-4\", children: folderNodes.length > 0 ? (folderNodes.map((folderNode) => (_jsx(FolderItem, { uiNode: folderNode, ...baseNodeCallbacks, ...folderCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }, folderNode.id)))) : (_jsx(\"div\", { className: \"mb-8 text-sm text-gray-400\", children: t(\"folderView.sections.folders.empty\", {\n defaultValue: \"No documents or files 📄\",\n }) })) }), _jsx(DriveLayout.ContentSection, { title: t(\"folderView.sections.documents.title\", {\n defaultValue: \"Documents and files\",\n }), children: _jsx(\"div\", { className: twMerge(\"w-full\", fileNodes.length > 0 ? \"min-h-[400px]\" : \"min-h-14\"), children: _jsx(FileContentView, { fileNodes: fileNodes, ...fileCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }) }) })] }));\n}\nexport default FolderView;\n//# sourceMappingURL=folder-view.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { ConnectSearchBar, Icon, } from \"@powerhousedao/design-system\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nconst defaultFilterItems = [\n {\n id: \"project\",\n label: \".project\",\n icon: _jsx(Icon, { name: \"Project\", color: \"#FF6A55\", size: 16 }),\n },\n {\n id: \"budget\",\n label: \".budget\",\n icon: _jsx(Icon, { name: \"BarChart\", color: \"#8E55EA\", size: 16 }),\n },\n {\n id: \"profile\",\n label: \".profile\",\n icon: _jsx(Icon, { name: \"Person\", color: \"#3E90F0\", size: 16 }),\n },\n {\n id: \"legal\",\n label: \".legal\",\n icon: _jsx(Icon, { name: \"Briefcase\", color: \"#4BAB71\", size: 16 }),\n },\n {\n id: \"atlas\",\n label: \".Atlas\",\n icon: _jsx(Icon, { name: \"Globe\", color: \"#FF8A00\", size: 16 }),\n },\n];\nexport const SearchBar = () => {\n const { t } = useTranslation();\n const [value, setValue] = useState(\"\"); // TODO\n return (_jsx(ConnectSearchBar, { className: \"max-w-searchbar-width m-4 shrink-0 bg-gray-100\", placeholder: t(\"searchbar.placeholder\"), filterLabel: t(\"searchbar.filterLabel\"), filterItems: defaultFilterItems, value: value, onChange: setValue }));\n};\n//# sourceMappingURL=search-bar.js.map","import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Breadcrumbs, useBreadcrumbs, useDrop, } from \"@powerhousedao/design-system\";\nimport { useDriveActionsWithUiNodes } from \"@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes\";\nimport { DriveContextProvider, useDriveContext, } from \"@powerhousedao/reactor-browser/hooks/useDriveContext\";\nimport { FILE, useUiNodesContext, } from \"@powerhousedao/reactor-browser/hooks/useUiNodesContext\";\nimport { useCallback, useMemo } from \"react\";\n/* import { useDocuments, useSelectedDocument } from \"../../state/documents.js\";\nimport { useDrives, useSelectedDrive } from \"../../state/drives.js\";\nimport { useSelectedFolder } from \"../../state/folders.js\";\nimport { useReactor } from \"../../state/reactor.js\"; */\nimport { CreateDocument } from \"./components/create-document.js\";\nimport FolderView from \"./components/folder-view.js\";\nimport { DriveLayout } from \"./components/layout.js\";\nimport { SearchBar } from \"./components/search-bar.js\";\nexport function BaseEditor(props) {\n /* const loadableReactor = useReactor();\n const loadableDrives = useDrives();\n const loadableDocuments = useDocuments();\n const loadableSelectedDrive = useSelectedDrive();\n const loadableSelectedFolder = useSelectedFolder();\n const loadableSelectedDocument = useSelectedDocument();\n console.log(\"in base editor\", {\n loadableReactor,\n loadableDrives,\n loadableDocuments,\n loadableSelectedDrive,\n loadableSelectedFolder,\n loadableSelectedDocument,\n }); */\n const { document, dispatch, className, children } = props;\n const { header: { id: driveId }, } = document;\n const { showSearchBar, isAllowedToCreateDocuments, documentModels, showCreateDocumentModal, } = useDriveContext();\n const { driveNodes, selectedNode, selectedNodePath, getNodeById, setSelectedNode, } = useUiNodesContext();\n const driveNode = useMemo(() => driveNodes.find((n) => n.id === driveId), [driveNodes, driveId]);\n const { addDocument, addFile, addFolder, renameNode, deleteNode, moveNode, copyNode, duplicateNode, } = useDriveActionsWithUiNodes(document, dispatch);\n const onCreateDocument = useCallback(async (documentModel) => {\n const { name } = await showCreateDocumentModal(documentModel);\n const document = documentModel.utils.createDocument();\n await addDocument(name, documentModel.documentModel.name, document, selectedNode?.id);\n }, [addDocument, showCreateDocumentModal, selectedNode?.id]);\n const { isDropTarget: isDropTargetFolder, dropProps: dropPropsFolder } = useDrop({\n uiNode: selectedNode,\n onAddFile: addFile,\n onCopyNode: copyNode,\n onMoveNode: moveNode,\n });\n const { isDropTarget, dropProps } = useDrop({\n uiNode: selectedNode?.kind === \"FOLDER\" ? selectedNode : null,\n onAddFile: addFile,\n onCopyNode: copyNode,\n onMoveNode: moveNode,\n });\n const { breadcrumbs, onBreadcrumbSelected } = useBreadcrumbs({\n selectedNodePath,\n getNodeById,\n setSelectedNode,\n });\n if (!driveNode) {\n return _jsx(\"div\", { children: \"Drive not found\" });\n }\n else if (selectedNode?.kind === FILE) {\n return _jsx(_Fragment, {});\n }\n return (_jsxs(DriveLayout, { className: className, children: [children, _jsxs(DriveLayout.Header, { children: [_jsx(Breadcrumbs, { breadcrumbs: breadcrumbs, createEnabled: isAllowedToCreateDocuments, onCreate: addFolder, onBreadcrumbSelected: onBreadcrumbSelected }), showSearchBar && _jsx(SearchBar, {})] }), _jsx(DriveLayout.Content, { ...dropProps, className: isDropTarget ? \"rounded-xl bg-blue-100\" : \"\", children: _jsx(FolderView, { node: selectedNode || driveNode, onSelectNode: setSelectedNode, onRenameNode: renameNode, onDuplicateNode: duplicateNode, onDeleteNode: deleteNode, onAddFile: addFile, onCopyNode: copyNode, onMoveNode: moveNode, isAllowedToCreateDocuments: isAllowedToCreateDocuments, isDropTarget: isDropTargetFolder, ...dropPropsFolder }) }), _jsx(DriveLayout.Footer, { children: isAllowedToCreateDocuments && (_jsx(CreateDocument, { documentModels: documentModels, createDocument: onCreateDocument })) })] }));\n}\nexport default function Editor(props) {\n return (_jsx(DriveContextProvider, { value: props.context, children: _jsx(BaseEditor, { ...props }) }));\n}\n//# sourceMappingURL=editor.js.map","import Editor from \"./editor.js\";\nexport const GenericDriveExplorer = {\n Component: Editor,\n documentTypes: [\"powerhouse/document-drive\"],\n config: {\n id: \"GenericDriveExplorer\",\n disableExternalControls: true,\n documentToolbarEnabled: true,\n showSwitchboardLink: true,\n },\n};\n//# sourceMappingURL=index.js.map","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { useMutation, useQuery, useQueryClient, } from \"@tanstack/react-query\";\nimport { useEffect } from \"react\";\nimport { getAnalyticsStore, useAnalyticsEngineAsync, useAnalyticsStoreAsync, useAnalyticsStoreOptions, } from \"./context.js\";\nfunction useAnalyticsQueryWrapper(options) {\n const { queryFn, ...queryOptions } = options;\n const { data: store } = useAnalyticsStoreAsync();\n const { data: engine } = useAnalyticsEngineAsync();\n const enabled = \"enabled\" in queryOptions ? queryOptions.enabled : !!store && !!engine;\n return useQuery({\n ...queryOptions,\n enabled,\n queryFn: async () => {\n if (!store || !engine) {\n throw new Error(\"No analytics store available. Use within an AnalyticsProvider.\");\n }\n return await queryFn({ store, engine });\n },\n });\n}\nfunction useAnalyticsMutationWrapper(options) {\n const { mutationFn, ...mutationOptions } = options;\n const storeOptions = useAnalyticsStoreOptions();\n return useMutation({\n ...mutationOptions,\n mutationFn: async (value) => {\n let store = null;\n try {\n store = await getAnalyticsStore(storeOptions);\n }\n catch (e) {\n console.error(e);\n }\n if (!store) {\n throw new Error(\"No analytics store available. Use within an AnalyticsProvider.\");\n }\n return await mutationFn(value, { store });\n },\n });\n}\nconst DEBOUNCE_INTERVAL = 200;\nexport function useAnalyticsQuery(query, options) {\n const { data: store } = useAnalyticsStoreAsync();\n const queryClient = useQueryClient();\n const sources = options?.sources ?? [];\n const result = useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"query\", query],\n queryFn: ({ engine }) => engine.execute(query),\n ...options,\n });\n useEffect(() => {\n if (!sources.length || !store) {\n return;\n }\n const subscriptions = new Array();\n // Debounce invalidateQueries so it's not called too frequently\n let invalidateTimeout = null;\n const debouncedInvalidate = () => {\n if (invalidateTimeout)\n clearTimeout(invalidateTimeout);\n invalidateTimeout = setTimeout(() => {\n queryClient\n .invalidateQueries({\n queryKey: [\"analytics\", \"query\", query],\n })\n .catch((e) => {\n console.error(e);\n });\n }, DEBOUNCE_INTERVAL);\n };\n sources.forEach((path) => {\n const unsub = store.subscribeToSource(path, debouncedInvalidate);\n subscriptions.push(unsub);\n });\n // Unsubscribes from store when component unmounts or dependencies change\n return () => {\n subscriptions.forEach((unsub) => unsub());\n };\n }, [query, store, sources]);\n return result;\n}\nexport function useAnalyticsSeries(query, options) {\n return useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"series\", query],\n queryFn: ({ store }) => store.getMatchingSeries(query),\n ...options,\n });\n}\nexport function useAddSeriesValue(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"addSeries\"],\n mutationFn: async (value, { store }) => {\n return await store.addSeriesValue(value);\n },\n ...options,\n });\n}\nexport function useClearSeriesBySource(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"clearSeries\"],\n mutationFn: async ({ source, cleanUpDimensions }, { store }) => {\n return store.clearSeriesBySource(source, cleanUpDimensions);\n },\n ...options,\n });\n}\nexport function useClearEmptyAnalyticsDimensions(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"clearEmptyDimensions\"],\n mutationFn: async (_, { store }) => {\n return store.clearEmptyAnalyticsDimensions();\n },\n ...options,\n });\n}\nexport function useAddSeriesValues(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"addSeriesValues\"],\n mutationFn: async (values, { store }) => {\n return store.addSeriesValues(values);\n },\n ...options,\n });\n}\nexport function useGetDimensions(options) {\n return useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"dimensions\"],\n queryFn: ({ store }) => store.getDimensions(),\n ...options,\n });\n}\nexport function useMatchingSeries(query, options) {\n const result = useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"matchingSeries\", query],\n queryFn: ({ store }) => store.getMatchingSeries(query),\n ...options,\n });\n return result;\n}\nexport function useQuerySources(query, options) {\n const { data: matchingSeries } = useMatchingSeries(query);\n return useQuery({\n queryKey: [\"analytics\", \"sources\", query],\n queryFn: () => {\n if (!matchingSeries?.length) {\n return [];\n }\n const uniqueSources = [\n ...new Set(matchingSeries.map((s) => s.source.toString())),\n ];\n return uniqueSources.map((source) => AnalyticsPath.fromString(source));\n },\n enabled: !!matchingSeries,\n ...options,\n });\n}\n//# sourceMappingURL=hooks.js.map","import { AnalyticsGranularity, AnalyticsPath, DateTime, useAnalyticsQuery, } from \"@powerhousedao/reactor-browser/analytics\";\nconst getBarSize = (value) => {\n if (value <= 0)\n return 0;\n if (value > 0 && value <= 50)\n return 1;\n if (value > 50 && value <= 100)\n return 2;\n if (value > 100 && value <= 250)\n return 3;\n return 4;\n};\nfunction addItemsDividers(items) {\n if (!items.length)\n return [];\n const result = [];\n items.forEach((item, index) => {\n result.push(item);\n // Check if there's a next item and if they're not in consecutive hours\n if (index < items.length - 1) {\n const currentDate = new Date(item.startDate);\n const nextDate = new Date(items[index + 1].startDate);\n const currentHour = currentDate.getHours();\n const nextHour = nextDate.getHours();\n // Get day parts (without time) for comparison\n const currentDay = currentDate.toDateString();\n const nextDay = nextDate.toDateString();\n // If different days or non-consecutive hours on the same day\n if (currentDay !== nextDay ||\n (currentDay === nextDay && Math.abs(nextHour - currentHour) > 1)) {\n result.push({\n id: `divider-${item.id}-${items[index + 1].id}`,\n type: \"divider\",\n revision: 0,\n });\n }\n }\n });\n return result;\n}\nfunction metricsToItems(metrics) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!metrics)\n return [];\n const items = metrics\n .sort((a, b) => {\n const aDate = new Date(a.start);\n const bDate = new Date(b.start);\n return aDate.getTime() - bDate.getTime();\n })\n .filter((result) => {\n return result.rows.every((row) => row.value > 0);\n })\n .map((result) => {\n const { additions, deletions } = result.rows.reduce((acc, row) => {\n if (row.dimensions.changes.path ===\n \"ph/diff/changes/add\") {\n acc.additions += row.value;\n }\n else if (row.dimensions.changes.path ===\n \"ph/diff/changes/remove\") {\n acc.deletions += row.value;\n }\n return acc;\n }, { additions: 0, deletions: 0 });\n const startDate = new Date(result.start);\n return {\n id: startDate.toISOString(),\n type: \"bar\",\n addSize: getBarSize(additions),\n delSize: getBarSize(deletions),\n additions,\n deletions,\n timestamp: startDate.toISOString(),\n startDate: startDate,\n endDate: new Date(result.end),\n revision: 0,\n };\n });\n return addItemsDividers(items);\n}\nexport const useTimelineItems = (documentId, startTimestamp, driveId) => {\n const start = startTimestamp\n ? DateTime.fromISO(startTimestamp)\n : DateTime.now().startOf(\"day\");\n return useAnalyticsQuery({\n start,\n end: DateTime.now().endOf(\"day\"),\n granularity: AnalyticsGranularity.Hourly,\n metrics: [\"Count\"],\n select: {\n changes: [AnalyticsPath.fromString(`ph/diff/changes`)],\n document: [AnalyticsPath.fromString(`ph/diff/document/${documentId}`)],\n },\n lod: {\n changes: 4,\n },\n }, {\n sources: [AnalyticsPath.fromString(`ph/diff/${driveId}/${documentId}`)],\n select: metricsToItems,\n });\n};\n//# sourceMappingURL=useTimelineItems.js.map","export const getRevisionFromDate = (startDate, endDate, operations = []) => {\n if (!startDate || !endDate)\n return 0;\n const operation = operations.find((operation) => {\n const operationDate = new Date(operation.timestamp);\n return operationDate >= startDate && operationDate <= endDate;\n });\n return operation ? operation.index : 0;\n};\n//# sourceMappingURL=index.js.map","import { useAtomValue } from 'jotai';\nimport { atomWithStorageCallback } from './utils.js';\n\nconst THEMES = ['light', 'dark'] as const;\n\nexport type Theme = (typeof THEMES)[number];\n\nexport const themeAtom = atomWithStorageCallback<Theme>(\n 'theme',\n 'light',\n theme => {\n if (typeof window !== 'undefined') {\n window.electronAPI?.setTheme(theme);\n }\n },\n);\n\nexport const useTheme = () => useAtomValue(themeAtom);\n\nexport function isTheme(theme: string): theme is Theme {\n return THEMES.includes(theme as Theme);\n}\n","import { useReadModeContext } from '#context';\nimport { documentToHash, useDocumentDriveServer } from '#hooks';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport { logger } from 'document-drive';\nimport {\n hashDocumentStateForScope,\n type Operation,\n type PHDocument,\n} from 'document-model';\nimport { atom, useAtom, useSetAtom } from 'jotai';\nimport { useCallback, useEffect, useMemo } from 'react';\n\nfunction debounceOperations(\n callback: (operations: Operation[]) => Promise<PHDocument | undefined>,\n timeout = 50,\n) {\n let timer: number;\n const operations: Operation[] = [];\n return (operation: Operation) => {\n if (timer) {\n clearTimeout(timer);\n }\n const index = operations.findIndex(\n op => op.scope === operation.scope && op.index === operation.index,\n );\n if (index > -1) {\n const oldOperation = operations[index];\n if (\n !(\n oldOperation.type === operation.type &&\n JSON.stringify(operation.input) ===\n JSON.stringify(oldOperation.input)\n )\n ) {\n console.warn(\n 'Two conflicting operations were dispatched:',\n oldOperation,\n operation,\n );\n }\n operations[index] = operation;\n } else {\n operations.push(operation);\n }\n return new Promise<PHDocument | undefined>((resolve, reject) => {\n timer = setTimeout(() => {\n callback(operations).then(resolve).catch(reject);\n }, timeout) as unknown as number;\n });\n };\n}\n\nexport type FileNodeDocument =\n | {\n driveId: string;\n documentId: string;\n documentType: string;\n name: string;\n document: PHDocument | undefined;\n status: 'LOADING' | 'ERROR';\n }\n | {\n driveId: string;\n documentId: string;\n documentType: string;\n name: string;\n document: PHDocument;\n status: 'LOADED';\n }\n | undefined;\n\nconst documentCacheAtom = atom(new Map<string, PHDocument>());\ndocumentCacheAtom.debugLabel = 'documentCacheAtomInConnect';\n\nconst singletonFileNodeDocumentAtom = atom<FileNodeDocument>(undefined);\nsingletonFileNodeDocumentAtom.debugLabel =\n 'singletonFileNodeDocumentAtomInConnect';\n\nexport function isSameDocument(\n prev: PHDocument | undefined,\n next: PHDocument | undefined,\n) {\n if (prev === next) {\n return true;\n }\n if (!prev || !next) {\n return false;\n }\n if (hashDocumentStateForScope(prev) === hashDocumentStateForScope(next)) {\n return true;\n } else {\n return false;\n }\n}\n\nconst fileNodeDocumentAtom = atom(\n get => get(singletonFileNodeDocumentAtom),\n (get, set, newValue: FileNodeDocument) => {\n const currentValue = get(singletonFileNodeDocumentAtom);\n\n // if document will be loaded then sets\n // the cached version while it loads\n const documentCache = get(documentCacheAtom);\n if (!newValue?.document && newValue?.status === 'LOADING') {\n newValue.document = documentCache.get(\n `${newValue.driveId}:${newValue.documentId}`,\n );\n }\n\n // only change if the provided file node is different\n if (\n currentValue?.driveId !== newValue?.driveId ||\n currentValue?.documentId !== newValue?.documentId ||\n currentValue?.documentType !== newValue?.documentType ||\n currentValue?.status !== newValue?.status ||\n !!currentValue?.document !== !!newValue?.document ||\n (currentValue?.document &&\n newValue?.document &&\n documentToHash(currentValue.document) !==\n documentToHash(newValue.document))\n ) {\n // if document has been fetched then updates the cache\n if (newValue?.status === 'LOADED') {\n documentCache.set(\n `${newValue.driveId}:${newValue.documentId}`,\n newValue.document,\n );\n }\n\n set(singletonFileNodeDocumentAtom, newValue);\n return true;\n }\n\n return false;\n },\n);\nfileNodeDocumentAtom.debugLabel = 'fileNodeDocumentAtomInConnect';\n\nconst selectedDocumentAtom = atom(\n null,\n (get, set, document: PHDocument | undefined) => {\n const fileNodeDocument = get(fileNodeDocumentAtom);\n if (!fileNodeDocument) {\n throw new Error('fileNodeDocument is undefined');\n } else if (!document) {\n set(fileNodeDocumentAtom, undefined);\n } else if (!isSameDocument(document, fileNodeDocument.document)) {\n set(fileNodeDocumentAtom, { ...fileNodeDocument, document });\n }\n },\n);\nselectedDocumentAtom.debugLabel = 'selectedDocumentAtomInConnect';\nconst useSetSelectedDocument = () => useSetAtom(selectedDocumentAtom);\n\nexport function useFileNodeDocument() {\n const { selectedNode, selectedDriveNode } = useUiNodesContext();\n\n const { openFile, addOperations, onStrandUpdate } =\n useDocumentDriveServer();\n const { fetchDocument: fetchReadDocument } = useReadModeContext();\n const [fileNodeDocument, setFileNodeDocument] =\n useAtom(fileNodeDocumentAtom);\n const isReadMode =\n selectedDriveNode?.sharingType !== 'LOCAL' &&\n selectedDriveNode?.syncStatus === undefined;\n const driveId = selectedNode?.driveId;\n const documentId = selectedNode?.id;\n const name = selectedNode?.name;\n const kind = selectedNode?.kind;\n const documentType =\n kind === 'FILE' ? selectedNode?.documentType : undefined;\n\n const setSelectedDocument = useSetSelectedDocument();\n const fetchDocument = useCallback(\n async (driveId: string, id: string, documentType: string) => {\n const document = await (isReadMode\n ? fetchReadDocument(driveId, id, documentType)\n : openFile(driveId, id));\n if (document instanceof Error) {\n throw document;\n }\n return document;\n },\n [fetchReadDocument, isReadMode, openFile],\n );\n\n useEffect(() => {\n // if selected node is undefine then clears fileNodeDocument\n if (!driveId || !documentId || !documentType) {\n if (fileNodeDocument) {\n setFileNodeDocument(undefined);\n }\n return;\n }\n\n // if selectedNode changes then fetches fileNodeDocument\n if (\n driveId !== fileNodeDocument?.driveId ||\n documentId !== fileNodeDocument.documentId ||\n documentType !== fileNodeDocument.documentType ||\n name !== fileNodeDocument.name\n ) {\n const changed = setFileNodeDocument({\n driveId,\n documentId,\n documentType,\n name: name || '',\n document: undefined,\n status: 'LOADING',\n });\n\n // if the selected file node changed then fetches the new document\n if (changed) {\n fetchDocument(driveId, documentId, documentType)\n .then(document =>\n setFileNodeDocument(\n document\n ? {\n driveId,\n documentId,\n documentType,\n document,\n name: name || '',\n status: 'LOADED',\n }\n : {\n driveId,\n documentId,\n documentType,\n document,\n name: name || '',\n status: 'ERROR',\n },\n ),\n )\n .catch(error => {\n logger.error(error);\n setFileNodeDocument({\n driveId,\n documentId,\n documentType,\n name: name || '',\n document: undefined,\n status: 'ERROR',\n });\n });\n }\n }\n }, [\n selectedNode,\n documentId,\n documentType,\n name,\n driveId,\n fetchDocument,\n fileNodeDocument,\n setFileNodeDocument,\n ]);\n\n useEffect(() => {\n if (\n !fileNodeDocument?.driveId ||\n !fileNodeDocument.documentId ||\n !fileNodeDocument.documentType\n ) {\n return;\n }\n\n // watches for strand updates to update the document\n const removeListener = onStrandUpdate(strand => {\n if (\n strand.driveId === fileNodeDocument.driveId &&\n strand.documentId === fileNodeDocument.documentId\n ) {\n fetchDocument(\n fileNodeDocument.driveId,\n fileNodeDocument.documentId,\n fileNodeDocument.documentType,\n )\n .then(setSelectedDocument)\n .catch(logger.error);\n }\n });\n\n return removeListener;\n }, [\n fileNodeDocument?.driveId,\n fileNodeDocument?.documentId,\n fileNodeDocument?.documentType,\n onStrandUpdate,\n fetchDocument,\n setSelectedDocument,\n ]);\n\n const addOperationToSelectedDocument = useMemo(() => {\n if (driveId && documentId && kind === 'FILE') {\n return debounceOperations(operations =>\n addOperations(driveId, documentId, operations),\n );\n }\n }, [addOperations, driveId, documentId, kind]);\n\n const addOperationToSelectedDrive = useCallback(\n (operation: Operation) => {\n if (!selectedDriveNode?.id) {\n throw new Error('No drive node selected');\n }\n return debounceOperations(operations =>\n addOperations(selectedDriveNode.id, undefined, operations),\n )(operation);\n },\n [addOperations, selectedDriveNode?.id],\n );\n\n const isSelectedDocument =\n kind === 'FILE' &&\n fileNodeDocument?.driveId === driveId &&\n fileNodeDocument?.documentId === documentId;\n const selectedDocument = isSelectedDocument\n ? fileNodeDocument?.document\n : undefined;\n\n return useMemo(\n () => ({\n fileNodeDocument,\n selectedDocument,\n setSelectedDocument,\n addOperationToSelectedDocument,\n addOperationToSelectedDrive,\n }),\n [\n fileNodeDocument,\n isSelectedDocument,\n selectedDocument,\n setSelectedDocument,\n addOperationToSelectedDocument,\n addOperationToSelectedDrive,\n ],\n );\n}\n","import { useDefaultDocumentModelEditor } from '#hooks';\nimport { type DocumentModelLib, type EditorModule } from 'document-model';\nimport { atom, useAtomValue } from 'jotai';\nimport { atomWithLazy, loadable, unwrap } from 'jotai/utils';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { externalPackagesAtom } from './external-packages.js';\n\nasync function loadBaseEditors() {\n const documentModelEditor = await import(\n '@powerhousedao/builder-tools/document-model-editor'\n );\n await import('@powerhousedao/builder-tools/style.css');\n const module = documentModelEditor.documentModelEditorModule;\n return [module] as EditorModule[];\n}\n\nfunction getEditorsFromModules(modules: DocumentModelLib[]) {\n return modules\n .map(module => module.editors)\n .reduce((acc, val) => acc.concat(val), []);\n}\n\nconst baseEditorsAtom = atomWithLazy(loadBaseEditors);\nbaseEditorsAtom.debugLabel = 'baseEditorsAtomInConnect';\nexport const editorsAtom = atom(async get => {\n const baseEditors = await get(baseEditorsAtom);\n const externalModules = await get(externalPackagesAtom);\n const externalEditors = getEditorsFromModules(externalModules);\n\n return externalEditors.concat(baseEditors);\n});\neditorsAtom.debugLabel = 'editorsAtomInConnect';\n\nconst unwrappedEditorsAtom = unwrap(editorsAtom);\nunwrappedEditorsAtom.debugLabel = 'unwrappedEditorsAtomInConnect';\nconst loadableEditorsAtom = loadable(editorsAtom);\nloadableEditorsAtom.debugLabel = 'loadableEditorsAtomInConnect';\n\n// suspends the UI while editors are loading\nexport const useEditors = () => {\n return useAtomValue(editorsAtom);\n};\n\n// will return undefined until editors are initialized. Does not block rendering.\nexport const useUnwrappedEditors = () => {\n return useAtomValue(unwrappedEditorsAtom);\n};\n\n// returns state, data and error, which will cause a rerender when the editors are loaded. Does not suspend the UI\nexport const useLoadableEditors = () => {\n return useAtomValue(loadableEditorsAtom);\n};\n\nexport const useEditorsAsync = () => {\n const editorsPromise = useRef(\n (() => {\n let resolveFn!: (value: EditorModule[]) => void;\n let rejectFn!: (reason?: any) => void;\n\n const promise = new Promise<EditorModule[]>((resolve, reject) => {\n resolveFn = resolve;\n rejectFn = reject;\n });\n\n return { promise, resolve: resolveFn, reject: rejectFn };\n })(),\n );\n\n const editors = useLoadableEditors();\n\n useEffect(() => {\n if (editors.state === 'hasError') {\n editorsPromise.current.reject(editors.error);\n } else if (editors.state === 'hasData') {\n editorsPromise.current.resolve(editors.data);\n }\n }, [editors]);\n return editorsPromise.current.promise;\n};\n\nconst getEditor = (\n documentType: string,\n editors: EditorModule[],\n preferredEditorId?: string,\n) => {\n const preferredEditor = editors.find(\n e =>\n e.config.id === preferredEditorId &&\n e.documentTypes.includes(documentType),\n );\n\n if (preferredEditor) return preferredEditor;\n\n const editor =\n editors.find(e => e.documentTypes.includes(documentType)) ||\n editors.find(e => e.documentTypes.includes('*'));\n\n return editor || null;\n};\n\nexport const useEditor = (documentType: string) => {\n const editors = useUnwrappedEditors();\n if (!editors) {\n return undefined;\n }\n return getEditor(documentType, editors);\n};\n\nexport const useGetEditor = () => {\n const editors = useUnwrappedEditors();\n const [defaultDocumentModelEditor] = useDefaultDocumentModelEditor();\n\n return (documentType: string) =>\n editors\n ? getEditor(documentType, editors, defaultDocumentModelEditor.value)\n : undefined;\n};\n\nexport const usePreloadEditor = () => {\n const editorsPromise = useEditorsAsync();\n return useCallback(\n async (documentType: string) => {\n const editors = await editorsPromise;\n const editor = getEditor(documentType, editors);\n if (editor && 'preload' in editor.Component) {\n console.log(\n `Preloading editor for document '${documentType}': ${editor.config.id}`,\n );\n await (\n editor.Component as { preload: () => Promise<void> }\n ).preload();\n }\n },\n [editorsPromise],\n );\n};\n","const openBrowserUrl = (url: string) => window.open(url, '_blank');\n\nexport const openUrl = window.electronAPI?.openURL ?? openBrowserUrl;\n","import {\n type DocumentModelDocument,\n type PHDocument,\n validateInitialState,\n validateModules,\n validateStateSchemaName,\n type ValidationError,\n} from 'document-model';\nexport const validateDocument = (document: PHDocument) => {\n const errors: ValidationError[] = [];\n\n if (document.header.documentType !== 'powerhouse/document-model') {\n return errors;\n }\n\n const doc = document as DocumentModelDocument;\n const specs = doc.state.global.specifications[0];\n\n // validate initial state errors\n const initialStateErrors = Object.keys(specs.state).reduce<\n ValidationError[]\n >((acc, scopeKey) => {\n const scope = scopeKey as keyof typeof specs.state;\n\n return [\n ...acc,\n ...validateInitialState(\n specs.state[scope].initialValue,\n scope !== 'global',\n ).map(err => ({\n ...err,\n message: `${err.message}. Scope: ${scope}`,\n details: { ...err.details, scope },\n })),\n ];\n }, []);\n\n // validate schema state errors\n const schemaStateErrors = Object.keys(specs.state).reduce<\n ValidationError[]\n >((acc, scopeKey) => {\n const scope = scopeKey as keyof typeof specs.state;\n const isGlobalScope = scope === 'global';\n\n return [\n ...acc,\n ...validateStateSchemaName(\n specs.state[scope].schema,\n doc.header.name || doc.state.global?.name || '',\n !isGlobalScope ? scope : '',\n !isGlobalScope,\n ).map(err => ({\n ...err,\n message: `${err.message}. Scope: ${scope}`,\n details: { ...err.details, scope },\n })),\n ];\n }, []);\n\n // modules validation\n const modulesErrors = validateModules(specs.modules);\n\n return [...initialStateErrors, ...schemaStateErrors, ...modulesErrors];\n};\n","import { DefaultEditorLoader } from '@powerhousedao/design-system';\nimport {\n type ComponentProps,\n type ReactNode,\n useEffect,\n useState,\n} from 'react';\n\ntype Props = ComponentProps<typeof DefaultEditorLoader> & {\n loadingTimeout?: number;\n customEditorLoader?: ReactNode;\n};\nexport function EditorLoader(props: Props) {\n const [showLoading, setShowLoading] = useState(false);\n\n // only shows the loader after some time has passed\n useEffect(() => {\n setTimeout(() => {\n setShowLoading(true);\n }, props.loadingTimeout ?? 200);\n }, [props]);\n\n if (!showLoading) return null;\n\n const { customEditorLoader, ...defaultProps } = props;\n\n if (customEditorLoader) return <>{customEditorLoader}</>;\n\n return <DefaultEditorLoader {...defaultProps} />;\n}\n","import {\n useConnectCrypto,\n useConnectDid,\n useUndoRedoShortcuts,\n useUserPermissions,\n} from '#hooks';\nimport {\n type FileNodeDocument,\n isSameDocument,\n themeAtom,\n useGetDocumentModelModule,\n useGetEditor,\n useUser,\n} from '#store';\nimport {\n addActionContext,\n type DocumentDispatchCallback,\n signOperation,\n useDocumentDispatch,\n} from '#utils';\nimport { getRevisionFromDate, useTimelineItems } from '@powerhousedao/common';\nimport {\n Button,\n DocumentToolbar,\n RevisionHistory,\n type TimelineItem,\n} from '@powerhousedao/design-system';\nimport { logger } from 'document-drive';\nimport {\n type Action,\n type ActionErrorCallback,\n type EditorContext,\n type Operation,\n type PHDocument,\n redo,\n undo,\n} from 'document-model';\nimport { useAtomValue } from 'jotai';\nimport {\n Suspense,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { ErrorBoundary, type FallbackProps } from 'react-error-boundary';\nimport { useNavigate } from 'react-router-dom';\nimport { EditorLoader } from './editor-loader.js';\nimport { useModal } from './modal/index.js';\n\nexport type EditorProps<TDocument extends PHDocument = PHDocument> = {\n fileNodeDocument: FileNodeDocument;\n document: TDocument | undefined;\n onClose: () => void;\n onExport: () => void;\n onAddOperation: (operation: Operation) => Promise<void>;\n onOpenSwitchboardLink?: () => Promise<void>;\n onChange?: (documentId: string, document: TDocument) => void;\n onGetDocumentRevision?: EditorContext['getDocumentRevision'];\n};\n\nfunction EditorError({ message }: { message: React.ReactNode }) {\n return (\n <div className=\"flex size-full items-center justify-center\">\n <h3 className=\"text-lg font-semibold\">{message}</h3>\n </div>\n );\n}\n\nfunction FallbackEditorError(props: FallbackProps) {\n const message =\n props.error instanceof Error\n ? props.error.message\n : (props.error as string);\n return <EditorError message={message} />;\n}\n\nexport const DocumentEditor: React.FC<EditorProps> = props => {\n const {\n fileNodeDocument,\n document: initialDocument,\n onClose,\n onChange,\n onExport,\n onAddOperation,\n onGetDocumentRevision,\n onOpenSwitchboardLink,\n } = props;\n const documentId = fileNodeDocument?.documentId;\n const [selectedTimelineItem, setSelectedTimelineItem] =\n useState<TimelineItem | null>(null);\n\n const [revisionHistoryVisible, setRevisionHistoryVisible] = useState(false);\n const theme = useAtomValue(themeAtom);\n const user = useUser() || undefined;\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n const getDocumentModelModule = useGetDocumentModelModule();\n const getEditor = useGetEditor();\n\n const documentType = fileNodeDocument?.documentType;\n const documentModel = useMemo(\n () => (documentType ? getDocumentModelModule(documentType) : undefined),\n [documentType, getDocumentModelModule],\n );\n\n const editor = useMemo(\n () => (documentType ? getEditor(documentType) : undefined),\n [documentType, getEditor],\n );\n\n const [document, _dispatch, error] = useDocumentDispatch(\n documentModel?.reducer,\n initialDocument,\n );\n const context: EditorContext = useMemo(\n () => ({ theme, user }),\n [theme, user],\n );\n const userPermissions = useUserPermissions();\n\n const timelineItems = useTimelineItems(\n documentId,\n initialDocument?.header.createdAtUtcIso,\n );\n\n const currentDocument = useRef({ ...fileNodeDocument, document });\n useEffect(() => {\n if (!fileNodeDocument?.documentId || !document) return;\n\n // if current document ref is undefined or outdated then updates the ref\n // and doesn't call the onChange callback\n if (\n !('documentId' in currentDocument.current) ||\n currentDocument.current.documentId !== documentId\n ) {\n currentDocument.current = { ...fileNodeDocument, document };\n return;\n }\n\n // if the document is different then calls the onChange callback\n if (!isSameDocument(currentDocument.current.document, document)) {\n currentDocument.current.document = document;\n window.documentEditorDebugTools?.setDocument(document);\n onChange?.(documentId, document);\n }\n }, [document, documentId, fileNodeDocument, onChange]);\n\n const dispatch = useCallback(\n (action: Action, onErrorCallback?: ActionErrorCallback) => {\n const callback: DocumentDispatchCallback<PHDocument> = (\n operation,\n state,\n ) => {\n if (!fileNodeDocument?.documentId) return;\n\n const { prevState } = state;\n\n signOperation(\n operation,\n sign,\n fileNodeDocument.documentId,\n prevState,\n documentModel?.reducer,\n user,\n )\n .then(op => {\n window.documentEditorDebugTools?.pushOperation(\n operation,\n );\n return onAddOperation(op);\n })\n .catch(logger.error);\n };\n\n _dispatch(\n addActionContext(action, connectDid, user),\n callback,\n onErrorCallback,\n );\n },\n [\n _dispatch,\n connectDid,\n documentModel?.reducer,\n onAddOperation,\n fileNodeDocument,\n sign,\n user,\n ],\n );\n\n const showRevisionHistory = useCallback(\n () => setRevisionHistoryVisible(true),\n [],\n );\n\n const hideRevisionHistory = useCallback(\n () => setRevisionHistoryVisible(false),\n [],\n );\n const handleUndo = useCallback(() => {\n dispatch(undo());\n }, [dispatch]);\n\n const handleRedo = useCallback(() => {\n dispatch(redo());\n }, [dispatch]);\n\n const isLoadingDocument =\n fileNodeDocument?.status === 'LOADING' || !document;\n const isLoadingEditor =\n editor === undefined ||\n (!!document &&\n editor &&\n !editor.documentTypes.includes(document.header.documentType) &&\n !editor.documentTypes.includes('*'));\n\n const canUndo =\n !!document &&\n (document.header.revision.global > 0 ||\n document.header.revision.local > 0);\n const canRedo = !!document?.clipboard.length;\n useUndoRedoShortcuts({\n undo: handleUndo,\n redo: handleRedo,\n canUndo,\n canRedo,\n });\n\n useEffect(() => {\n return () => {\n window.documentEditorDebugTools?.clear();\n };\n }, []);\n\n const navigate = useNavigate();\n const { showModal } = useModal();\n\n const [editorError, setEditorError] = useState<\n | {\n error: any;\n info: React.ErrorInfo;\n documentId?: string;\n // clear: () => void;\n }\n | undefined\n >(undefined);\n\n useEffect(() => {\n if (\n editorError &&\n editorError.documentId !== fileNodeDocument?.documentId\n ) {\n setEditorError(undefined);\n }\n }, [editorError, fileNodeDocument, document]);\n\n const handleEditorError = useCallback(\n (error: Error, info: React.ErrorInfo) => {\n setEditorError({\n error,\n documentId,\n info,\n });\n },\n [documentId],\n );\n\n if (fileNodeDocument?.status === 'ERROR') {\n return <EditorError message={'Error loading document'} />;\n }\n\n if (isLoadingDocument || isLoadingEditor) {\n const message = isLoadingDocument\n ? 'Loading document'\n : 'Loading editor';\n return <EditorLoader message={message} />;\n }\n\n if (!fileNodeDocument) {\n return null;\n }\n\n if (!documentModel) {\n return (\n <EditorError\n message={\n <div className=\"text-center leading-10\">\n <p>\n Unable to open the document because the document\n model \"{documentType}\" is not supported.\n </p>\n <p>\n Go to the{' '}\n <button\n type=\"button\"\n className=\"cursor-pointer underline\"\n onClick={() => {\n showModal('settingsModal', {\n onRefresh: () => navigate(0),\n });\n }}\n >\n package manager\n </button>{' '}\n to install this document model\n </p>\n </div>\n }\n />\n );\n }\n\n if (editor === null) {\n return (\n <EditorError\n message={\n <div className=\"text-center leading-10\">\n <p>\n Unable to open the document because no editor has\n been found\n </p>\n <p>\n Go to the{' '}\n <button\n type=\"button\"\n className=\"cursor-pointer underline\"\n onClick={() => {\n showModal('settingsModal', {\n onRefresh: () => navigate(0),\n });\n }}\n >\n package manager\n </button>{' '}\n an editor for the \"${documentType}\" document type\n </p>\n </div>\n }\n />\n );\n }\n\n const EditorComponent = editor.Component;\n const {\n disableExternalControls,\n documentToolbarEnabled,\n showSwitchboardLink,\n timelineEnabled,\n } = editor.config || {};\n\n const handleSwitchboardLinkClick =\n showSwitchboardLink !== false ? onOpenSwitchboardLink : undefined;\n return (\n <div className=\"relative h-full\" id=\"document-editor-context\">\n {documentToolbarEnabled &&\n disableExternalControls &&\n !revisionHistoryVisible && (\n <DocumentToolbar\n onClose={onClose}\n onExport={onExport}\n onShowRevisionHistory={showRevisionHistory}\n title={fileNodeDocument.name || document.header.name}\n onSwitchboardLinkClick={handleSwitchboardLinkClick}\n timelineButtonVisible={timelineEnabled}\n timelineItems={timelineItems.data}\n onTimelineItemClick={setSelectedTimelineItem}\n />\n )}\n {!disableExternalControls && (\n <div className=\"mb-4 flex justify-end gap-10\">\n <Button onClick={onExport}>Export</Button>\n <div className=\"flex gap-4\">\n <Button onClick={handleUndo} disabled={!canUndo}>\n Undo\n </Button>\n <Button onClick={handleRedo} disabled={!canRedo}>\n Redo\n </Button>\n </div>\n <div className=\"flex gap-4\">\n <Button onClick={onClose}>Close</Button>\n </div>\n </div>\n )}\n {revisionHistoryVisible ? (\n <RevisionHistory\n key={documentId}\n documentTitle={document.header.name}\n documentId={fileNodeDocument.documentId}\n globalOperations={document.operations.global}\n localOperations={document.operations.local}\n onClose={hideRevisionHistory}\n />\n ) : (\n <Suspense fallback={<EditorLoader />} name=\"EditorLoader\">\n <ErrorBoundary\n fallbackRender={FallbackEditorError}\n key={documentId}\n onError={handleEditorError}\n >\n {!editorError?.error && (\n <EditorComponent\n key={documentId}\n error={error}\n context={{\n ...context,\n getDocumentRevision: onGetDocumentRevision,\n readMode: !!selectedTimelineItem,\n selectedTimelineRevision:\n getRevisionFromDate(\n selectedTimelineItem?.startDate,\n selectedTimelineItem?.endDate,\n document.operations.global,\n ),\n }}\n document={document}\n documentNodeName={fileNodeDocument.name}\n dispatch={dispatch}\n onClose={onClose}\n onExport={onExport}\n canUndo={canUndo}\n canRedo={canRedo}\n undo={handleUndo}\n redo={handleRedo}\n onSwitchboardLinkClick={\n handleSwitchboardLinkClick\n }\n onShowRevisionHistory={showRevisionHistory}\n isAllowedToCreateDocuments={\n userPermissions?.isAllowedToCreateDocuments ??\n false\n }\n isAllowedToEditDocuments={\n userPermissions?.isAllowedToEditDocuments ??\n false\n }\n />\n )}\n </ErrorBoundary>\n </Suspense>\n )}\n </div>\n );\n};\n","import {\n useDocumentDriveById,\n useDocumentDriveServer,\n useGetDocument,\n} from '#hooks';\nimport { useFileNodeDocument, useGetDocumentModelModule } from '#store';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport { buildDocumentSubgraphUrl } from '@powerhousedao/reactor-browser/utils/switchboard';\nimport { type GetDocumentOptions } from 'document-drive';\nimport {\n type EditorContext,\n type Operation,\n type PHDocument,\n} from 'document-model';\nimport { useCallback, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useModal } from '../components/modal/index.js';\nimport { exportFile, openUrl } from '../utils/index.js';\nimport { validateDocument } from '../utils/validate-document.js';\nimport { DocumentEditor } from './editors.js';\n\nexport function DocumentEditorContainer() {\n const { t } = useTranslation();\n const { showModal } = useModal();\n const {\n selectedDocument,\n fileNodeDocument,\n setSelectedDocument,\n addOperationToSelectedDocument,\n } = useFileNodeDocument();\n const { renameNode } = useDocumentDriveServer();\n const {\n selectedNode,\n selectedDriveNode,\n selectedParentNode,\n setSelectedNode,\n } = useUiNodesContext();\n const { isRemoteDrive, remoteUrl } = useDocumentDriveById(\n selectedDriveNode?.id,\n );\n const getDocumentModelModule = useGetDocumentModelModule();\n\n const getDocument = useGetDocument();\n\n const handleAddOperationToSelectedDocument = useCallback(\n async (operation: Operation) => {\n if (!selectedDocument) {\n throw new Error('No document selected');\n }\n if (!addOperationToSelectedDocument) {\n throw new Error('No add operation function defined');\n }\n await addOperationToSelectedDocument(operation);\n },\n [addOperationToSelectedDocument, selectedDocument],\n );\n\n const onDocumentChangeHandler = useCallback(\n (documentId: string, document: PHDocument) => {\n if (documentId !== fileNodeDocument?.documentId) {\n return;\n }\n setSelectedDocument(document);\n\n if (\n !!selectedNode &&\n document.header.name !== '' &&\n selectedNode.name !== document.header.name\n ) {\n return renameNode(\n selectedNode.driveId,\n selectedNode.id,\n document.header.name,\n );\n }\n },\n [\n fileNodeDocument?.documentId,\n renameNode,\n selectedNode,\n setSelectedDocument,\n ],\n );\n\n const onClose = useCallback(() => {\n setSelectedNode(selectedParentNode);\n }, [selectedParentNode, setSelectedNode]);\n\n const exportDocument = useCallback(\n (document: PHDocument) => {\n const validationErrors = validateDocument(document);\n\n if (validationErrors.length) {\n showModal('confirmationModal', {\n title: t('modals.exportDocumentWithErrors.title'),\n body: (\n <div>\n <p>{t('modals.exportDocumentWithErrors.body')}</p>\n <ul className=\"mt-4 flex list-disc flex-col items-start px-4 text-xs\">\n {validationErrors.map((error, index) => (\n <li key={index}>{error.message}</li>\n ))}\n </ul>\n </div>\n ),\n cancelLabel: t('common.cancel'),\n continueLabel: t('common.export'),\n onCancel(closeModal) {\n closeModal();\n },\n onContinue(closeModal) {\n closeModal();\n return exportFile(document, getDocumentModelModule);\n },\n });\n } else {\n return exportFile(document, getDocumentModelModule);\n }\n },\n [getDocumentModelModule, showModal, t],\n );\n\n const onGetDocumentRevision: EditorContext['getDocumentRevision'] =\n useCallback(\n (options?: GetDocumentOptions) => {\n if (!selectedNode) {\n console.error('No selected node');\n return Promise.reject(new Error('No selected node'));\n }\n return getDocument(\n selectedNode.driveId,\n selectedNode.id,\n options,\n );\n },\n [getDocument, selectedNode],\n );\n\n const onExport = useCallback(() => {\n if (selectedDocument) {\n return exportDocument(selectedDocument);\n }\n }, [exportDocument, selectedDocument]);\n\n const onOpenSwitchboardLink = useMemo(() => {\n return isRemoteDrive\n ? async () => {\n if (!selectedDocument) {\n console.error('No selected document');\n return;\n }\n\n if (!remoteUrl) {\n console.error('No remote drive url found');\n return;\n }\n\n const documentModelModule = getDocumentModelModule(\n selectedDocument.header.documentType,\n );\n\n if (!documentModelModule) {\n console.error('No document model found');\n return;\n }\n\n const url = buildDocumentSubgraphUrl(\n remoteUrl,\n selectedDocument.header.id,\n documentModelModule.documentModel,\n );\n try {\n await openUrl(url);\n } catch (e) {\n console.error('Error opening switchboard link', e);\n }\n }\n : undefined;\n }, [isRemoteDrive, remoteUrl, selectedDocument, getDocumentModelModule]);\n\n if (!fileNodeDocument) return null;\n\n return (\n <div\n key={fileNodeDocument.documentId}\n className=\"flex-1 rounded-2xl bg-gray-50 p-4\"\n >\n <DocumentEditor\n fileNodeDocument={fileNodeDocument}\n document={selectedDocument}\n onChange={onDocumentChangeHandler}\n onClose={onClose}\n onExport={onExport}\n onGetDocumentRevision={onGetDocumentRevision}\n onAddOperation={handleAddOperationToSelectedDocument}\n onOpenSwitchboardLink={onOpenSwitchboardLink}\n />\n </div>\n );\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nexport function useDocumentsState(args) {\n const { reactor, driveId, documentIds, options } = args;\n const [statesByDocumentId, setStatesByDocumentId] = useState({});\n const isInitialized = useRef(false);\n const isSubscribed = useRef(false);\n useEffect(() => {\n async function initialize() {\n if (isInitialized.current)\n return;\n if (!reactor || !driveId)\n return;\n isInitialized.current = true;\n const ids = documentIds ?? (await reactor.getDocuments(driveId));\n const statesByDocumentId = {};\n for (const id of ids) {\n const document = await reactor.getDocument(driveId, id, options);\n statesByDocumentId[id] = {\n ...document.state,\n documentType: document.header.documentType,\n revision: document.header.revision,\n createdAtUtcIso: document.header.createdAtUtcIso,\n lastModifiedAtUtcIso: document.header.lastModifiedAtUtcIso,\n };\n }\n setStatesByDocumentId(statesByDocumentId);\n }\n void initialize();\n }, [reactor, driveId, options]);\n useEffect(() => {\n if (!reactor || !driveId)\n return;\n if (isSubscribed.current)\n return;\n isSubscribed.current = true;\n const unsubscribe = reactor.on(\"strandUpdate\", async (update) => {\n if (update.driveId !== driveId ||\n (documentIds && !documentIds.includes(update.documentId)))\n return;\n const updatedDocument = await reactor.getDocument(driveId, update.documentId, options);\n setStatesByDocumentId((prev) => {\n const newStatesByDocumentId = { ...prev };\n newStatesByDocumentId[update.documentId] = {\n ...updatedDocument.state,\n documentType: updatedDocument.header.documentType,\n revision: updatedDocument.header.revision,\n createdAtUtcIso: updatedDocument.header.createdAtUtcIso,\n lastModifiedAtUtcIso: updatedDocument.header.lastModifiedAtUtcIso,\n };\n return newStatesByDocumentId;\n });\n });\n return unsubscribe;\n }, [reactor, driveId, options]);\n return useMemo(() => statesByDocumentId, [statesByDocumentId]);\n}\nexport function makeDriveDocumentStatesHook(reactor) {\n const useDriveDocumentStates = useCallback((args) => {\n const { driveId, documentIds, options } = args;\n return useDocumentsState({\n reactor,\n driveId,\n documentIds,\n options,\n });\n }, [reactor]);\n return useDriveDocumentStates;\n}\nexport function makeDriveDocumentStateHook(reactor) {\n const useDriveDocumentState = useCallback((args) => {\n const { driveId, documentId } = args;\n return useDocumentState({\n reactor,\n driveId,\n documentId,\n });\n }, [reactor]);\n return useDriveDocumentState;\n}\nexport function useDocumentState(args) {\n const { reactor, driveId, documentId } = args;\n const state = useDocumentsState({\n reactor,\n driveId,\n documentIds: [documentId],\n });\n return useMemo(() => state[documentId], [state, documentId]);\n}\n//# sourceMappingURL=document-state.js.map","import { type GetDocumentOptions } from 'document-drive';\nimport { type PHDocument, type PHDocumentHeader } from 'document-model';\nimport { useEffect, useState } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer';\n\nconst DELETE_NODE_OPERATION_TYPE = 'DELETE_NODE';\n\ntype DeleteOperationInput = { id: string };\n\nexport type HookState = PHDocument['state'] &\n Pick<\n PHDocumentHeader,\n 'documentType' | 'revision' | 'createdAtUtcIso' | 'lastModifiedAtUtcIso'\n >;\n\nexport interface UseGetDriveDocumentsProps {\n driveId?: string;\n documentIds?: string[];\n options?: GetDocumentOptions;\n}\n\nexport function useGetDriveDocuments(props: UseGetDriveDocumentsProps) {\n const { driveId } = props;\n const [documents, setDocuments] = useState<Record<string, HookState>>({});\n\n const { getDocumentsIds, openFile, onOperationsAdded } =\n useDocumentDriveServer();\n\n const fetchDocuments = async (\n _driveId: string,\n _documentIds?: string[],\n _deletedNodes: string[] = [],\n ) => {\n let documentIds = _documentIds;\n\n if (!documentIds || documentIds.length === 0) {\n documentIds = await getDocumentsIds(_driveId);\n }\n\n if (!documentIds) {\n return;\n }\n\n const getDocumentsPromise = documentIds.map<\n Promise<[string, PHDocument]>\n >(async documentId => {\n const document = await openFile(_driveId, documentId);\n return [documentId, document];\n });\n\n const docs = await Promise.all(getDocumentsPromise);\n\n const newDocumentsState = docs.reduce<Record<string, HookState>>(\n (acc, [documentId, document]) => {\n acc[documentId] = {\n ...document.state,\n documentType: document.header.documentType,\n revision: document.header.revision,\n createdAtUtcIso: document.header.createdAtUtcIso,\n lastModifiedAtUtcIso: document.header.lastModifiedAtUtcIso,\n };\n return acc;\n },\n {},\n );\n\n setDocuments(prevState => ({\n ...prevState,\n ...newDocumentsState,\n }));\n\n if (_deletedNodes.length > 0) {\n setDocuments(prevState => {\n const newState = { ...prevState };\n _deletedNodes.forEach(nodeId => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete newState[nodeId];\n });\n return newState;\n });\n }\n };\n\n useEffect(() => {\n if (driveId) {\n fetchDocuments(driveId).catch(console.error);\n }\n }, [driveId]);\n\n useEffect(() => {\n const removeListener = onOperationsAdded(\n (driveId, documentId, operations) => {\n const deletedNodes: string[] = [];\n\n if (driveId === driveId && !documentId) {\n const deletedNodesIds = operations\n .filter(op => op.type === DELETE_NODE_OPERATION_TYPE)\n .map(op => (op.input as DeleteOperationInput).id);\n\n deletedNodes.push(...deletedNodesIds);\n }\n\n if (driveId === driveId) {\n const docId = documentId ? [documentId] : undefined;\n fetchDocuments(driveId, docId, deletedNodes).catch(\n console.error,\n );\n }\n },\n );\n\n return removeListener;\n }, [onOperationsAdded, driveId]);\n\n return [documents, fetchDocuments] as const;\n}\n","import connectConfig from '#connect-config';\nimport {\n useDocumentDriveById,\n useDocumentDriveServer,\n useDocumentEditor,\n useEditorProps,\n useGetDocument,\n useSyncStatus,\n} from '#hooks';\nimport {\n useDriveEditor,\n useFileNodeDocument,\n useFilteredDocumentModels,\n useGetDocumentModelModule,\n useGetEditor,\n useReactor,\n} from '#store';\nimport { useDocumentDispatch } from '#utils';\nimport { GenericDriveExplorer } from '@powerhousedao/common';\nimport { type DriveEditorContext } from '@powerhousedao/reactor-browser';\nimport { makeDriveDocumentStateHook } from '@powerhousedao/reactor-browser/hooks/document-state';\nimport { type IDriveContext } from '@powerhousedao/reactor-browser/hooks/useDriveContext';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport {\n driveDocumentModelModule,\n type GetDocumentOptions,\n} from 'document-drive';\nimport { type DocumentModelModule, type Operation } from 'document-model';\nimport { useCallback, useMemo } from 'react';\nimport { ErrorBoundary, type FallbackProps } from 'react-error-boundary';\nimport { useGetDriveDocuments } from '../hooks/useGetDriveDocuments.js';\nimport { useModal } from './modal/index.js';\n\nfunction DriveEditorError({ error }: FallbackProps) {\n return (\n <div className=\"mx-auto flex max-w-[80%] flex-1 flex-col items-center justify-center\">\n <h1 className=\"mb-2 text-xl font-semibold\">Error</h1>\n <i>{error instanceof Error ? error.message : error}</i>\n <pre>{JSON.stringify(error, null, 2)}</pre>\n </div>\n );\n}\n\nfunction useSelectedDocumentDrive() {\n const { selectedDriveNode } = useUiNodesContext();\n\n if (!selectedDriveNode) {\n throw new Error('No drive node selected');\n }\n\n const documentDrive = useDocumentDriveById(selectedDriveNode.id);\n\n if (!documentDrive.drive) {\n throw new Error(`Drive with id \"${selectedDriveNode.id}\" not found`);\n }\n\n return documentDrive.drive;\n}\n\nexport function DriveEditorContainer() {\n const {\n selectedDriveNode,\n setSelectedNode,\n selectedNode,\n selectedParentNode,\n } = useUiNodesContext();\n const { addOperationToSelectedDrive } = useFileNodeDocument();\n const documentDrive = useSelectedDocumentDrive();\n const [document, _dispatch, error] = useDocumentDispatch(\n driveDocumentModelModule.reducer,\n documentDrive,\n );\n const reactor = useReactor();\n\n const handleAddOperationToSelectedDrive = useCallback(\n async (operation: Operation) => {\n await addOperationToSelectedDrive(operation);\n },\n [addOperationToSelectedDrive],\n );\n\n const editorProps = useEditorProps(\n document,\n selectedDriveNode,\n _dispatch,\n handleAddOperationToSelectedDrive,\n );\n\n const { showModal } = useModal();\n const showCreateDocumentModal = useCallback(\n (documentModel: DocumentModelModule) => {\n if (!selectedDriveNode) {\n throw new Error('No drive node selected');\n }\n\n showModal('createDocument', {\n documentModel,\n selectedParentNode,\n setSelectedNode,\n });\n return Promise.resolve({ name: 'New Document' }); // TODO fix this\n },\n [selectedDriveNode, selectedParentNode, setSelectedNode, showModal],\n );\n\n const { addFile, addDocument } = useDocumentDriveServer();\n const documentModels = useFilteredDocumentModels();\n const useDriveDocumentState = makeDriveDocumentStateHook(reactor);\n const getDocument = useGetDocument();\n const getDocumentModelModule = useGetDocumentModelModule();\n const getEditor = useGetEditor();\n\n const onGetDocumentRevision: DriveEditorContext['getDocumentRevision'] =\n useCallback(\n (documentId: string, options?: GetDocumentOptions) => {\n if (!selectedNode) {\n console.error('No selected node');\n return Promise.reject(new Error('No selected node'));\n }\n return getDocument(selectedNode.driveId, documentId, options);\n },\n [getDocument, selectedNode],\n );\n\n const driveContext: IDriveContext = useMemo(\n () => ({\n showSearchBar: false,\n isAllowedToCreateDocuments: editorProps.isAllowedToCreateDocuments,\n documentModels: documentModels ?? [],\n selectedDriveNode,\n selectedNode,\n selectNode: setSelectedNode,\n addFile,\n showCreateDocumentModal,\n useSyncStatus,\n useDocumentEditorProps: useDocumentEditor,\n useDriveDocumentStates: useGetDriveDocuments,\n useDriveDocumentState,\n addDocument,\n reactor,\n }),\n [\n reactor,\n editorProps.isAllowedToCreateDocuments,\n documentModels,\n selectedNode,\n setSelectedNode,\n addFile,\n addDocument,\n showCreateDocumentModal,\n ],\n );\n\n const driveEditor = useDriveEditor(document?.header.meta?.preferredEditor);\n\n if (!document) {\n return null;\n }\n\n const DriveEditorComponent =\n driveEditor?.Component ?? GenericDriveExplorer.Component;\n\n return (\n <ErrorBoundary\n fallbackRender={DriveEditorError}\n key={selectedDriveNode?.id}\n >\n <DriveEditorComponent\n key={selectedDriveNode?.id}\n {...editorProps}\n context={{\n ...editorProps.context,\n ...driveContext,\n analyticsDatabaseName: connectConfig.analytics.databaseName,\n getDocumentRevision: onGetDocumentRevision,\n getDocumentModelModule,\n getEditor,\n }}\n onSwitchboardLinkClick={undefined} // TODO\n document={document}\n error={error}\n />\n </ErrorBoundary>\n );\n}\n","import { type DocumentDriveState } from 'document-drive';\nimport { useDocumentDriveServer } from './useDocumentDriveServer.js';\n\ntype ExtendedDocumentDriveState = DocumentDriveState & { remoteUrl?: string };\n\nexport function useDocumentDriveById(driveId: string | undefined) {\n const { documentDrives } = useDocumentDriveServer();\n if (!driveId)\n return {\n drive: null,\n remoteUrl: null,\n isRemoteDrive: false,\n };\n\n const drive = documentDrives.find(drive => drive.header.id === driveId);\n\n const pullResponder = drive?.state.local.triggers.find(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n trigger => trigger.type === 'PullResponder',\n );\n\n const { remoteUrl } = (drive?.state.global ||\n {}) as ExtendedDocumentDriveState;\n\n const isRemoteDrive = !!remoteUrl || !!pullResponder;\n\n return {\n drive,\n remoteUrl: remoteUrl || pullResponder?.data?.url,\n isRemoteDrive,\n };\n}\n","import { useUnwrappedReactor } from '#store';\nimport {\n useDocument,\n useDocumentEditorProps,\n type User,\n} from '@powerhousedao/reactor-browser';\nimport { type DocumentModelModule, type PHDocument } from 'document-model';\n\nimport { useConnectCrypto, useConnectDid } from '#hooks';\n\nexport interface DocumentEditorProps {\n driveId: string;\n documentId: string;\n documentType: string;\n documentModelModule: DocumentModelModule<PHDocument>;\n user?: User;\n}\n\nexport function useDocumentEditor(props: DocumentEditorProps) {\n const { driveId, documentId, documentType, documentModelModule, user } =\n props;\n\n const reactor = useUnwrappedReactor();\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n\n const doc = useDocument(reactor, { documentId, driveId, documentType });\n\n const documentEditorProps = useDocumentEditorProps(reactor, {\n nodeId: documentId,\n driveId: driveId,\n document: doc,\n documentModelModule,\n connectDid,\n sign,\n user,\n });\n\n return documentEditorProps;\n}\n","import { useModal } from '#components';\nimport {\n themeAtom,\n useFileNodeDocument,\n useGetDocumentModelModule,\n useUser,\n} from '#store';\nimport {\n addActionContext,\n type DocumentDispatch,\n type DocumentDispatchCallback,\n exportFile,\n signOperation,\n validateDocument,\n} from '#utils';\nimport {\n type UiDriveNode,\n type UiFileNode,\n} from '@powerhousedao/design-system';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser';\nimport { logger } from 'document-drive';\nimport {\n type Action,\n type ActionErrorCallback,\n type EditorContext,\n type Operation,\n type PHDocument,\n redo,\n undo,\n} from 'document-model';\nimport { useAtomValue } from 'jotai';\nimport { useCallback, useMemo, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useConnectCrypto, useConnectDid } from './useConnectCrypto.js';\nimport { useUserPermissions } from './useUserPermissions.js';\n\nexport interface EditorProps {\n context: EditorContext;\n canUndo: boolean;\n canRedo: boolean;\n undo: () => void;\n redo: () => void;\n onClose: () => void;\n onExport: () => void;\n onShowRevisionHistory: () => void;\n isAllowedToCreateDocuments: boolean;\n isAllowedToEditDocuments: boolean;\n}\n\nexport function useEditorDispatch(\n node: UiDriveNode | UiFileNode | null,\n documentDispatch: DocumentDispatch<PHDocument>,\n onAddOperation: (operation: Operation) => Promise<void>,\n) {\n const user = useUser() || undefined;\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n\n const documentType =\n node?.kind === 'DRIVE'\n ? 'powerhouse/document-drive'\n : node?.documentType;\n const getDocumentModelModule = useGetDocumentModelModule();\n const documentModelModule = useMemo(\n () => (documentType ? getDocumentModelModule(documentType) : undefined),\n [documentType, getDocumentModelModule],\n );\n\n const dispatch = useCallback(\n (action: Action, onErrorCallback?: ActionErrorCallback) => {\n const callback: DocumentDispatchCallback<PHDocument> = (\n operation,\n state,\n ) => {\n if (!node?.id) return;\n\n const { prevState } = state;\n\n signOperation(\n operation,\n sign,\n node.id,\n prevState,\n documentModelModule?.reducer,\n user,\n )\n .then(op => {\n window.documentEditorDebugTools?.pushOperation(\n operation,\n );\n return onAddOperation(op);\n })\n .catch(logger.error);\n };\n\n documentDispatch(\n addActionContext(action, connectDid, user),\n callback,\n onErrorCallback,\n );\n },\n [\n documentDispatch,\n connectDid,\n documentModelModule?.reducer,\n onAddOperation,\n node,\n sign,\n user,\n ],\n );\n\n return dispatch;\n}\n\nexport function useEditorProps(\n document: PHDocument | undefined,\n node: UiDriveNode | UiFileNode | null,\n documentDispatch: DocumentDispatch<PHDocument>,\n onAddOperation: (operation: Operation) => Promise<void>,\n) {\n const { t } = useTranslation();\n const { showModal } = useModal();\n const theme = useAtomValue(themeAtom);\n const user = useUser() || undefined;\n const userPermissions = useUserPermissions();\n\n const context = useMemo(() => ({ theme, user }), [theme, user]);\n const { selectedDocument } = useFileNodeDocument();\n const { selectedParentNode, setSelectedNode } = useUiNodesContext();\n const getDocumentModelModule = useGetDocumentModelModule();\n\n const canUndo =\n !!document &&\n (document.header.revision.global > 0 ||\n document.header.revision.local > 0);\n const canRedo = !!document?.clipboard.length;\n\n const dispatch = useEditorDispatch(node, documentDispatch, onAddOperation);\n\n const handleUndo = useCallback(() => {\n dispatch(undo());\n }, [dispatch]);\n\n const handleRedo = useCallback(() => {\n dispatch(redo());\n }, [dispatch]);\n\n const onClose = useCallback(() => {\n setSelectedNode(selectedParentNode);\n }, [selectedParentNode, setSelectedNode]);\n\n const exportDocument = useCallback(\n (document: PHDocument) => {\n const validationErrors = validateDocument(document);\n\n if (validationErrors.length) {\n showModal('confirmationModal', {\n title: t('modals.exportDocumentWithErrors.title'),\n body: (\n <div>\n <p>{t('modals.exportDocumentWithErrors.body')}</p>\n <ul className=\"mt-4 flex list-disc flex-col items-start px-4 text-xs\">\n {validationErrors.map((error, index) => (\n <li key={index}>{error.message}</li>\n ))}\n </ul>\n </div>\n ),\n cancelLabel: t('common.cancel'),\n continueLabel: t('common.export'),\n onCancel(closeModal) {\n closeModal();\n },\n onContinue(closeModal) {\n closeModal();\n return exportFile(document, getDocumentModelModule);\n },\n });\n } else {\n return exportFile(document, getDocumentModelModule);\n }\n },\n [getDocumentModelModule, showModal, t],\n );\n\n const onExport = useCallback(() => {\n if (selectedDocument) {\n return exportDocument(selectedDocument);\n }\n }, [exportDocument, selectedDocument]);\n\n const [revisionHistoryVisible, setRevisionHistoryVisible] = useState(false);\n const showRevisionHistory = useCallback(\n () => setRevisionHistoryVisible(true),\n [],\n );\n\n return {\n dispatch,\n revisionHistoryVisible,\n context,\n canUndo,\n canRedo,\n undo: handleUndo,\n redo: handleRedo,\n onClose,\n onExport,\n onShowRevisionHistory: showRevisionHistory,\n isAllowedToCreateDocuments:\n userPermissions?.isAllowedToCreateDocuments ?? false,\n isAllowedToEditDocuments:\n userPermissions?.isAllowedToEditDocuments ?? false,\n };\n}\n","import { type GetDocumentOptions } from 'document-drive';\nimport { type PHDocumentHeader, type PHDocument } from 'document-model';\nimport { useCallback } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer';\n\nexport type HookState = PHDocument['state'] &\n Pick<\n PHDocumentHeader,\n 'documentType' | 'revision' | 'createdAtUtcIso' | 'lastModifiedAtUtcIso'\n >;\n\nexport interface UseGetDriveDocumentsProps {\n driveId?: string;\n documentIds?: string[];\n options?: GetDocumentOptions;\n}\n\nexport function useGetDocument() {\n const { openFile } = useDocumentDriveServer();\n\n const getDocument = useCallback(\n async (\n driveId: string,\n documentId: string,\n options?: GetDocumentOptions,\n ) => {\n const document = await openFile(driveId, documentId, options);\n return document;\n },\n [openFile],\n );\n\n return getDocument;\n}\n","import { type SharingType } from '@powerhousedao/design-system';\nimport { type SyncStatus } from 'document-drive';\nimport { useSyncExternalStore } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer.js';\n\nexport function useSyncStatus(\n driveId: string,\n documentId?: string,\n): SyncStatus | undefined {\n const { getSyncStatusSync, onSyncStatus, documentDrives } =\n useDocumentDriveServer();\n\n const syncStatus = useSyncExternalStore(\n onStoreChange => {\n const unsub = onSyncStatus(onStoreChange);\n return unsub;\n },\n () => {\n const drive = documentDrives.find(\n _drive => _drive.header.id === driveId,\n );\n\n if (!drive) return;\n const isReadDrive = 'readContext' in drive;\n const _sharingType = !isReadDrive\n ? drive.state.local.sharingType?.toUpperCase()\n : 'PUBLIC';\n\n const sharingType =\n _sharingType === 'PRIVATE' ? 'LOCAL' : _sharingType;\n\n if (!documentId) {\n const status = getSyncStatusSync(\n driveId,\n sharingType as SharingType,\n );\n\n return status;\n }\n\n const document = drive.state.global.nodes.find(\n node => node.id === documentId,\n );\n\n if (!document) return;\n if (!('synchronizationUnits' in document)) return;\n\n const status = getSyncStatusSync(\n document.synchronizationUnits[0].syncId,\n sharingType as SharingType,\n );\n\n return status;\n },\n );\n\n return syncStatus;\n}\n","import { useContext, createContext, useState, useCallback, useRef, useLayoutEffect, useEffect } from 'react';\nimport { jsx } from 'react/jsx-runtime';\n\nfunction _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\n\nvar reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl'];\nvar mappedKeys = {\n esc: 'escape',\n \"return\": 'enter',\n '.': 'period',\n ',': 'comma',\n '-': 'slash',\n ' ': 'space',\n '`': 'backquote',\n '#': 'backslash',\n '+': 'bracketright',\n ShiftLeft: 'shift',\n ShiftRight: 'shift',\n AltLeft: 'alt',\n AltRight: 'alt',\n MetaLeft: 'meta',\n MetaRight: 'meta',\n OSLeft: 'meta',\n OSRight: 'meta',\n ControlLeft: 'ctrl',\n ControlRight: 'ctrl'\n};\nfunction mapKey(key) {\n return (key && mappedKeys[key] || key || '').trim().toLowerCase().replace(/key|digit|numpad|arrow/, '');\n}\nfunction isHotkeyModifier(key) {\n return reservedModifierKeywords.includes(key);\n}\nfunction parseKeysHookInput(keys, splitKey) {\n if (splitKey === void 0) {\n splitKey = ',';\n }\n return keys.split(splitKey);\n}\nfunction parseHotkey(hotkey, combinationKey, description) {\n if (combinationKey === void 0) {\n combinationKey = '+';\n }\n var keys = hotkey.toLocaleLowerCase().split(combinationKey).map(function (k) {\n return mapKey(k);\n });\n var modifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl') || keys.includes('control'),\n shift: keys.includes('shift'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod')\n };\n var singleCharKeys = keys.filter(function (k) {\n return !reservedModifierKeywords.includes(k);\n });\n return _extends({}, modifiers, {\n keys: singleCharKeys,\n description: description,\n hotkey: hotkey\n });\n}\n\n(function () {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', function (e) {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);\n });\n document.addEventListener('keyup', function (e) {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);\n });\n }\n if (typeof window !== 'undefined') {\n window.addEventListener('blur', function () {\n currentlyPressedKeys.clear();\n });\n }\n})();\nvar currentlyPressedKeys = /*#__PURE__*/new Set();\n// https://github.com/microsoft/TypeScript/issues/17002\nfunction isReadonlyArray(value) {\n return Array.isArray(value);\n}\nfunction isHotkeyPressed(key, splitKey) {\n if (splitKey === void 0) {\n splitKey = ',';\n }\n var hotkeyArray = isReadonlyArray(key) ? key : key.split(splitKey);\n return hotkeyArray.every(function (hotkey) {\n return currentlyPressedKeys.has(hotkey.trim().toLowerCase());\n });\n}\nfunction pushToCurrentlyPressedKeys(key) {\n var hotkeyArray = Array.isArray(key) ? key : [key];\n /*\r\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\r\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\r\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\r\n */\n if (currentlyPressedKeys.has('meta')) {\n currentlyPressedKeys.forEach(function (key) {\n return !isHotkeyModifier(key) && currentlyPressedKeys[\"delete\"](key.toLowerCase());\n });\n }\n hotkeyArray.forEach(function (hotkey) {\n return currentlyPressedKeys.add(hotkey.toLowerCase());\n });\n}\nfunction removeFromCurrentlyPressedKeys(key) {\n var hotkeyArray = Array.isArray(key) ? key : [key];\n /*\r\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\r\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\r\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\r\n */\n if (key === 'meta') {\n currentlyPressedKeys.clear();\n } else {\n hotkeyArray.forEach(function (hotkey) {\n return currentlyPressedKeys[\"delete\"](hotkey.toLowerCase());\n });\n }\n}\n\nfunction maybePreventDefault(e, hotkey, preventDefault) {\n if (typeof preventDefault === 'function' && preventDefault(e, hotkey) || preventDefault === true) {\n e.preventDefault();\n }\n}\nfunction isHotkeyEnabled(e, hotkey, enabled) {\n if (typeof enabled === 'function') {\n return enabled(e, hotkey);\n }\n return enabled === true || enabled === undefined;\n}\nfunction isKeyboardEventTriggeredByInput(ev) {\n return isHotkeyEnabledOnTag(ev, ['input', 'textarea', 'select']);\n}\nfunction isHotkeyEnabledOnTag(event, enabledOnTags) {\n if (enabledOnTags === void 0) {\n enabledOnTags = false;\n }\n var target = event.target,\n composed = event.composed;\n var targetTagName = null;\n if (isCustomElement(target) && composed) {\n targetTagName = event.composedPath()[0] && event.composedPath()[0].tagName;\n } else {\n targetTagName = target && target.tagName;\n }\n if (isReadonlyArray(enabledOnTags)) {\n return Boolean(targetTagName && enabledOnTags && enabledOnTags.some(function (tag) {\n var _targetTagName;\n return tag.toLowerCase() === ((_targetTagName = targetTagName) == null ? void 0 : _targetTagName.toLowerCase());\n }));\n }\n return Boolean(targetTagName && enabledOnTags && enabledOnTags);\n}\nfunction isCustomElement(element) {\n // We just do a basic check w/o any complex RegEx or validation against the list of legacy names containing a hyphen,\n // as none of them is likely to be an event target, and it won't hurt anyway if we miss.\n // see: https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname\n return !!element.tagName && !element.tagName.startsWith(\"-\") && element.tagName.includes(\"-\");\n}\nfunction isScopeActive(activeScopes, scopes) {\n if (activeScopes.length === 0 && scopes) {\n console.warn('A hotkey has the \"scopes\" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>');\n return true;\n }\n if (!scopes) {\n return true;\n }\n return activeScopes.some(function (scope) {\n return scopes.includes(scope);\n }) || activeScopes.includes('*');\n}\nvar isHotkeyMatchingKeyboardEvent = function isHotkeyMatchingKeyboardEvent(e, hotkey, ignoreModifiers) {\n if (ignoreModifiers === void 0) {\n ignoreModifiers = false;\n }\n var alt = hotkey.alt,\n meta = hotkey.meta,\n mod = hotkey.mod,\n shift = hotkey.shift,\n ctrl = hotkey.ctrl,\n keys = hotkey.keys;\n var pressedKeyUppercase = e.key,\n code = e.code,\n ctrlKey = e.ctrlKey,\n metaKey = e.metaKey,\n shiftKey = e.shiftKey,\n altKey = e.altKey;\n var keyCode = mapKey(code);\n var pressedKey = pressedKeyUppercase.toLowerCase();\n if (!(keys != null && keys.includes(keyCode)) && !(keys != null && keys.includes(pressedKey)) && !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(keyCode)) {\n return false;\n }\n if (!ignoreModifiers) {\n // We check the pressed keys for compatibility with the keyup event. In keyup events the modifier flags are not set.\n if (alt === !altKey && pressedKey !== 'alt') {\n return false;\n }\n if (shift === !shiftKey && pressedKey !== 'shift') {\n return false;\n }\n // Mod is a special key name that is checking for meta on macOS and ctrl on other platforms\n if (mod) {\n if (!metaKey && !ctrlKey) {\n return false;\n }\n } else {\n if (meta === !metaKey && pressedKey !== 'meta' && pressedKey !== 'os') {\n return false;\n }\n if (ctrl === !ctrlKey && pressedKey !== 'ctrl' && pressedKey !== 'control') {\n return false;\n }\n }\n }\n // All modifiers are correct, now check the key\n // If the key is set, we check for the key\n if (keys && keys.length === 1 && (keys.includes(pressedKey) || keys.includes(keyCode))) {\n return true;\n } else if (keys) {\n // Check if all keys are present in pressedDownKeys set\n return isHotkeyPressed(keys);\n } else if (!keys) {\n // If the key is not set, we only listen for modifiers, that check went alright, so we return true\n return true;\n }\n // There is nothing that matches.\n return false;\n};\n\nvar BoundHotkeysProxyProvider = /*#__PURE__*/createContext(undefined);\nvar useBoundHotkeysProxy = function useBoundHotkeysProxy() {\n return useContext(BoundHotkeysProxyProvider);\n};\nfunction BoundHotkeysProxyProviderProvider(_ref) {\n var addHotkey = _ref.addHotkey,\n removeHotkey = _ref.removeHotkey,\n children = _ref.children;\n return /*#__PURE__*/jsx(BoundHotkeysProxyProvider.Provider, {\n value: {\n addHotkey: addHotkey,\n removeHotkey: removeHotkey\n },\n children: children\n });\n}\n\nfunction deepEqual(x, y) {\n //@ts-ignore\n return x && y && typeof x === 'object' && typeof y === 'object' ? Object.keys(x).length === Object.keys(y).length &&\n //@ts-ignore\n Object.keys(x).reduce(function (isEqual, key) {\n return isEqual && deepEqual(x[key], y[key]);\n }, true) : x === y;\n}\n\nvar HotkeysContext = /*#__PURE__*/createContext({\n hotkeys: [],\n enabledScopes: [],\n toggleScope: function toggleScope() {},\n enableScope: function enableScope() {},\n disableScope: function disableScope() {}\n});\nvar useHotkeysContext = function useHotkeysContext() {\n return useContext(HotkeysContext);\n};\nvar HotkeysProvider = function HotkeysProvider(_ref) {\n var _ref$initiallyActiveS = _ref.initiallyActiveScopes,\n initiallyActiveScopes = _ref$initiallyActiveS === void 0 ? ['*'] : _ref$initiallyActiveS,\n children = _ref.children;\n var _useState = useState((initiallyActiveScopes == null ? void 0 : initiallyActiveScopes.length) > 0 ? initiallyActiveScopes : ['*']),\n internalActiveScopes = _useState[0],\n setInternalActiveScopes = _useState[1];\n var _useState2 = useState([]),\n boundHotkeys = _useState2[0],\n setBoundHotkeys = _useState2[1];\n var enableScope = useCallback(function (scope) {\n setInternalActiveScopes(function (prev) {\n if (prev.includes('*')) {\n return [scope];\n }\n return Array.from(new Set([].concat(prev, [scope])));\n });\n }, []);\n var disableScope = useCallback(function (scope) {\n setInternalActiveScopes(function (prev) {\n if (prev.filter(function (s) {\n return s !== scope;\n }).length === 0) {\n return ['*'];\n } else {\n return prev.filter(function (s) {\n return s !== scope;\n });\n }\n });\n }, []);\n var toggleScope = useCallback(function (scope) {\n setInternalActiveScopes(function (prev) {\n if (prev.includes(scope)) {\n if (prev.filter(function (s) {\n return s !== scope;\n }).length === 0) {\n return ['*'];\n } else {\n return prev.filter(function (s) {\n return s !== scope;\n });\n }\n } else {\n if (prev.includes('*')) {\n return [scope];\n }\n return Array.from(new Set([].concat(prev, [scope])));\n }\n });\n }, []);\n var addBoundHotkey = useCallback(function (hotkey) {\n setBoundHotkeys(function (prev) {\n return [].concat(prev, [hotkey]);\n });\n }, []);\n var removeBoundHotkey = useCallback(function (hotkey) {\n setBoundHotkeys(function (prev) {\n return prev.filter(function (h) {\n return !deepEqual(h, hotkey);\n });\n });\n }, []);\n return /*#__PURE__*/jsx(HotkeysContext.Provider, {\n value: {\n enabledScopes: internalActiveScopes,\n hotkeys: boundHotkeys,\n enableScope: enableScope,\n disableScope: disableScope,\n toggleScope: toggleScope\n },\n children: /*#__PURE__*/jsx(BoundHotkeysProxyProviderProvider, {\n addHotkey: addBoundHotkey,\n removeHotkey: removeBoundHotkey,\n children: children\n })\n });\n};\n\nfunction useDeepEqualMemo(value) {\n var ref = useRef(undefined);\n if (!deepEqual(ref.current, value)) {\n ref.current = value;\n }\n return ref.current;\n}\n\nvar stopPropagation = function stopPropagation(e) {\n e.stopPropagation();\n e.preventDefault();\n e.stopImmediatePropagation();\n};\nvar useSafeLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\nfunction useHotkeys(keys, callback, options, dependencies) {\n var _useState = useState(null),\n ref = _useState[0],\n setRef = _useState[1];\n var hasTriggeredRef = useRef(false);\n var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : undefined;\n var _keys = isReadonlyArray(keys) ? keys.join(_options == null ? void 0 : _options.splitKey) : keys;\n var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined;\n var memoisedCB = useCallback(callback, _deps != null ? _deps : []);\n var cbRef = useRef(memoisedCB);\n if (_deps) {\n cbRef.current = memoisedCB;\n } else {\n cbRef.current = callback;\n }\n var memoisedOptions = useDeepEqualMemo(_options);\n var _useHotkeysContext = useHotkeysContext(),\n enabledScopes = _useHotkeysContext.enabledScopes;\n var proxy = useBoundHotkeysProxy();\n useSafeLayoutEffect(function () {\n if ((memoisedOptions == null ? void 0 : memoisedOptions.enabled) === false || !isScopeActive(enabledScopes, memoisedOptions == null ? void 0 : memoisedOptions.scopes)) {\n return;\n }\n var listener = function listener(e, isKeyUp) {\n var _e$target;\n if (isKeyUp === void 0) {\n isKeyUp = false;\n }\n if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions == null ? void 0 : memoisedOptions.enableOnFormTags)) {\n return;\n }\n // TODO: SINCE THE EVENT IS NOW ATTACHED TO THE REF, THE ACTIVE ELEMENT CAN NEVER BE INSIDE THE REF. THE HOTKEY ONLY TRIGGERS IF THE\n // REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.\n if (ref !== null) {\n var rootNode = ref.getRootNode();\n if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement !== ref && !ref.contains(rootNode.activeElement)) {\n stopPropagation(e);\n return;\n }\n }\n if ((_e$target = e.target) != null && _e$target.isContentEditable && !(memoisedOptions != null && memoisedOptions.enableOnContentEditable)) {\n return;\n }\n parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {\n var _hotkey$keys;\n var hotkey = parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey);\n if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.ignoreModifiers) || (_hotkey$keys = hotkey.keys) != null && _hotkey$keys.includes('*')) {\n if (memoisedOptions != null && memoisedOptions.ignoreEventWhen != null && memoisedOptions.ignoreEventWhen(e)) {\n return;\n }\n if (isKeyUp && hasTriggeredRef.current) {\n return;\n }\n maybePreventDefault(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.preventDefault);\n if (!isHotkeyEnabled(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.enabled)) {\n stopPropagation(e);\n return;\n }\n // Execute the user callback for that hotkey\n cbRef.current(e, hotkey);\n if (!isKeyUp) {\n hasTriggeredRef.current = true;\n }\n }\n });\n };\n var handleKeyDown = function handleKeyDown(event) {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n pushToCurrentlyPressedKeys(mapKey(event.code));\n if ((memoisedOptions == null ? void 0 : memoisedOptions.keydown) === undefined && (memoisedOptions == null ? void 0 : memoisedOptions.keyup) !== true || memoisedOptions != null && memoisedOptions.keydown) {\n listener(event);\n }\n };\n var handleKeyUp = function handleKeyUp(event) {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n removeFromCurrentlyPressedKeys(mapKey(event.code));\n hasTriggeredRef.current = false;\n if (memoisedOptions != null && memoisedOptions.keyup) {\n listener(event, true);\n }\n };\n var domNode = ref || (_options == null ? void 0 : _options.document) || document;\n // @ts-ignore\n domNode.addEventListener('keyup', handleKeyUp, _options == null ? void 0 : _options.eventListenerOptions);\n // @ts-ignore\n domNode.addEventListener('keydown', handleKeyDown, _options == null ? void 0 : _options.eventListenerOptions);\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {\n return proxy.addHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));\n });\n }\n return function () {\n // @ts-ignore\n domNode.removeEventListener('keyup', handleKeyUp, _options == null ? void 0 : _options.eventListenerOptions);\n // @ts-ignore\n domNode.removeEventListener('keydown', handleKeyDown, _options == null ? void 0 : _options.eventListenerOptions);\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {\n return proxy.removeHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));\n });\n }\n };\n }, [ref, _keys, memoisedOptions, enabledScopes]);\n return setRef;\n}\n\nfunction useRecordHotkeys() {\n var _useState = useState(new Set()),\n keys = _useState[0],\n setKeys = _useState[1];\n var _useState2 = useState(false),\n isRecording = _useState2[0],\n setIsRecording = _useState2[1];\n var handler = useCallback(function (event) {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n setKeys(function (prev) {\n var newKeys = new Set(prev);\n newKeys.add(mapKey(event.code));\n return newKeys;\n });\n }, []);\n var stop = useCallback(function () {\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handler);\n setIsRecording(false);\n }\n }, [handler]);\n var start = useCallback(function () {\n setKeys(new Set());\n if (typeof document !== 'undefined') {\n stop();\n document.addEventListener('keydown', handler);\n setIsRecording(true);\n }\n }, [handler, stop]);\n var resetKeys = useCallback(function () {\n setKeys(new Set());\n }, []);\n return [keys, {\n start: start,\n stop: stop,\n resetKeys: resetKeys,\n isRecording: isRecording\n }];\n}\n\nexport { HotkeysProvider, isHotkeyPressed, useHotkeys, useHotkeysContext, useRecordHotkeys };\n//# sourceMappingURL=react-hotkeys-hook.esm.js.map\n","import { useHotkeys } from 'react-hotkeys-hook';\n\nexport interface UseUndoRedoShortcutsProps {\n undo: () => void;\n redo: () => void;\n canUndo: boolean;\n canRedo: boolean;\n}\n\nexport const useUndoRedoShortcuts = (props: UseUndoRedoShortcutsProps) => {\n const { undo, redo, canRedo, canUndo } = props;\n const { isMac } = window.electronAPI?.platformInfo || {};\n\n let undoShortcut = 'ctrl+z';\n let redoShortcut = 'ctrl+y';\n\n if (isMac) {\n undoShortcut = 'mod+z';\n redoShortcut = 'mod+shift+z';\n }\n\n // set handler for undo\n useHotkeys(\n undoShortcut,\n event => {\n event.preventDefault();\n if (canUndo) {\n undo();\n }\n },\n {},\n [canUndo, undo],\n );\n\n // set handler for redo\n useHotkeys(\n redoShortcut,\n event => {\n event.preventDefault();\n if (canRedo) {\n redo();\n }\n },\n {},\n [canRedo, redo],\n );\n};\n","import { useDocumentDrives, useDocumentDriveServer } from '#hooks';\nimport { useFileNodeDocument } from '#store';\n/* import {\n useReactor,\n useDocuments,\n useDrives,\n useSelectedDocument,\n useSelectedDrive,\n useSelectedFolder,\n} from '@powerhousedao/common'; */\nimport { FILE } from '@powerhousedao/design-system';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser';\nimport { useEffect } from 'react';\nimport { useNavigate, useParams } from 'react-router-dom';\nimport { DocumentEditorContainer } from '../components/document-editor-container.js';\nimport { DriveEditorContainer } from '../components/drive-editor-container.js';\nimport { toast } from '../services/toast.js';\n\nexport default function Content() {\n const navigate = useNavigate();\n const { driveId } = useParams();\n const [documentDrives, , , status] = useDocumentDrives();\n const { selectedDriveNode, selectedNode } = useUiNodesContext();\n const { addFile } = useDocumentDriveServer();\n const { fileNodeDocument } = useFileNodeDocument();\n /* const loadableReactor = useReactor();\n const loadableDrives = useDrives();\n const loadableDocuments = useDocuments();\n const loadableSelectedDrive = useSelectedDrive();\n const loadableSelectedFolder = useSelectedFolder();\n const loadableSelectedDocument = useSelectedDocument();\n\n console.log('in content', {\n loadableReactor,\n loadableDrives,\n loadableDocuments,\n loadableSelectedDrive,\n loadableSelectedFolder,\n loadableSelectedDocument,\n }); */\n\n useEffect(() => {\n return window.electronAPI?.handleFileOpen(async file => {\n if (!selectedDriveNode || selectedNode?.kind !== FILE) {\n return;\n }\n\n await addFile(\n file.content,\n selectedDriveNode.id,\n file.name,\n selectedNode.parentFolder,\n );\n });\n }, [selectedDriveNode, selectedNode, addFile]);\n\n // if drives are loaded and route driveId is not found\n // then redirects to homepage\n useEffect(() => {\n if (\n (status === 'LOADED' || status === 'ERROR') &&\n !documentDrives.find(\n d =>\n d.header.id === driveId ||\n d.header.slug === driveId ||\n d.state.global.name === driveId,\n )\n ) {\n toast(<p>Drive {driveId} not found</p>, { type: 'warning' });\n navigate('/');\n }\n }, [status, driveId, documentDrives]);\n\n return (\n <div className=\"flex h-full flex-col overflow-auto\" id=\"content-view\">\n {fileNodeDocument ? (\n <DocumentEditorContainer key={fileNodeDocument.documentId} />\n ) : selectedDriveNode ? (\n <DriveEditorContainer key={selectedDriveNode.id} />\n ) : null}\n </div>\n );\n}\n"],"file":"assets/content.CEwaGXuh.js"}
|
|
1
|
+
{"version":3,"mappings":";2kDAEA,SAASA,GAAgBC,EAAK,CAC1B,MAAI,uBAAwBA,EACjBA,EAAI,mBAERA,EAAI,aACf,CACO,MAAMC,GAAiB,CAAC,CAAE,eAAAC,EAAgB,eAAAC,KACrCC,EAAM,MAAO,CAAE,UAAW,OAAQ,SAAU,CAACC,EAAK,KAAM,CAAE,UAAW,4CAA6C,SAAU,eAAgB,EAAGA,EAAK,MAAO,CAAE,UAAW,8BAA+B,SAAUH,GAAA,YAAAA,EAAgB,IAAKF,GAAQ,CACtO,MAAMM,EAAOP,GAAgBC,CAAG,EAChC,OAAQK,EAAKE,EAAQ,CAAE,MAAO,QAAS,MAAOD,EAAK,KAAM,mBAAoBA,EAAK,YAAa,QAAS,IAAMH,EAAeH,CAAG,EAAG,SAAUK,EAAK,OAAQ,CAAE,UAAW,UAAW,SAAUC,EAAK,IAAI,CAAE,CAAC,EAAIA,EAAK,EAAE,CACvO,EAAkB,CAAE,CAAC,EAAG,ECVjB,SAASE,GAAkBC,EAAGC,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EAAA,CACJ,EAEJ,GACA,CAACI,EAASJ,CAAI,EAEtB,EC5BA,SAAwByM,IAAU,CAC9B,MAAMnM,EAAWC,GAAA,EACX,CAAE,QAAArP,CAAA,EAAYwb,GAAA,EACd,CAACjH,EAAA,EAAoBkH,CAAM,EAAIC,GAAA,EAC/B,CAAE,kBAAA9T,EAAmB,aAAAtH,CAAA,EAAiBI,EAAA,EACtC,CAAE,QAAAK,CAAA,EAAYiH,EAAA,EACd,CAAE,iBAAAR,CAAA,EAAqBG,GAAA,EAiB7B,OAAApE,EAAU,IAAM,OACZ,OAAOyC,EAAA,OAAO,cAAP,YAAAA,EAAoB,eAAe,MAAMjH,GAAQ,CAChD,CAAC6I,IAAqBtH,GAAA,YAAAA,EAAc,QAAS5B,IAIjD,MAAMqC,EACFhC,EAAK,QACL6I,EAAkB,GAClB7I,EAAK,KACLuB,EAAa,aACjB,EACH,EACF,CAACsH,EAAmBtH,EAAcS,CAAO,CAAC,EAI7CwC,EAAU,IAAM,EAEPkY,IAAW,UAAYA,IAAW,UACnC,CAAClH,EAAe,KACZoH,GACIA,EAAE,OAAO,KAAO3b,GAChB2b,EAAE,OAAO,OAAS3b,GAClB2b,EAAE,MAAM,OAAO,OAAS3b,CAAA,IAGhC4b,KAAO,KAAE,mBAAO5b,EAAQ,cAAU,EAAM,CAAE,KAAM,UAAW,EAC3DoP,EAAS,GAAG,EAChB,EACD,CAACqM,EAAQzb,EAASuU,CAAc,CAAC,IAG/B,OAAI,UAAU,qCAAqC,GAAG,eAClD,WACGtI,EAACsE,GAAA,GAA6B/I,EAAiB,UAAY,EAC3DI,EACAqE,EAACuH,MAA0B5L,EAAkB,EAAI,EACjD,KACR,CAER","names":["getDocumentSpec","doc","CreateDocument","documentModels","createDocument","_jsxs","_jsx","spec","Button","sortUiNodesByName","a","b","GAP","ITEM_WIDTH","ITEM_HEIGHT","USED_SPACE","FileContentView","props","parentRef","useRef","t","useTranslation","windowSize","useWindowSize","fileNodes","fileProps","availableWidth","columnCount","rowCount","rowVirtualizer","useVirtualizer","index","columnVirtualizer","getItemIndex","rowIndex","columnIndex","getItem","renderItem","fileNode","FileItem","virtualRow","React","virtualColumn","DriveLayout","children","className","containerProps","cn","title","FolderView","node","isDropTarget","nodeProps","folderNodes","FOLDER","FILE","folderCallbacks","name","fileCallbacks","baseNodeCallbacks","file","parentNode","uiNode","targetNode","twMerge","folderNode","FolderItem","defaultFilterItems","Icon","SearchBar","value","setValue","useState","ConnectSearchBar","BaseEditor","document","dispatch","driveId","showSearchBar","isAllowedToCreateDocuments","showCreateDocumentModal","useDriveContext","driveNodes","selectedNode","selectedNodePath","getNodeById","setSelectedNode","useUiNodesContext","driveNode","useMemo","n","addDocument","addFile","addFolder","renameNode","deleteNode","moveNode","copyNode","duplicateNode","useDriveActionsWithUiNodes","onCreateDocument","useCallback","documentModel","isDropTargetFolder","dropPropsFolder","useDrop","dropProps","breadcrumbs","onBreadcrumbSelected","useBreadcrumbs","_Fragment","Breadcrumbs","Editor","DriveContextProvider","GenericDriveExplorer","useAnalyticsQueryWrapper","options","queryFn","queryOptions","store","useAnalyticsStoreAsync","engine","useAnalyticsEngineAsync","enabled","useQuery","DEBOUNCE_INTERVAL","useAnalyticsQuery","query","queryClient","useQueryClient","sources","result","useEffect","subscriptions","invalidateTimeout","debouncedInvalidate","e","path","unsub","getBarSize","addItemsDividers","items","item","currentDate","nextDate","currentHour","nextHour","currentDay","nextDay","metricsToItems","metrics","aDate","bDate","row","additions","deletions","acc","startDate","useTimelineItems","documentId","startTimestamp","start","DateTime","AnalyticsGranularity","AnalyticsPath","getRevisionFromDate","endDate","operations","operation","operationDate","themeAtom","atomWithStorageCallback","theme","_a","debounceOperations","callback","timeout","timer","op","oldOperation","resolve","reject","documentCacheAtom","atom","singletonFileNodeDocumentAtom","isSameDocument","prev","next","hashDocumentStateForScope","fileNodeDocumentAtom","get","set","newValue","currentValue","documentCache","documentToHash","selectedDocumentAtom","fileNodeDocument","useSetSelectedDocument","useSetAtom","useFileNodeDocument","selectedDriveNode","openFile","addOperations","onStrandUpdate","useDocumentDriveServer","fetchReadDocument","useReadModeContext","setFileNodeDocument","useAtom","isReadMode","kind","documentType","setSelectedDocument","fetchDocument","id","error","logger","strand","addOperationToSelectedDocument","addOperationToSelectedDrive","isSelectedDocument","selectedDocument","loadBaseEditors","documentModelEditor","__vitePreload","getEditorsFromModules","modules","module","val","baseEditorsAtom","atomWithLazy","editorsAtom","baseEditors","externalModules","externalPackagesAtom","unwrappedEditorsAtom","unwrap","loadableEditorsAtom","loadable","useUnwrappedEditors","useAtomValue","getEditor","editors","preferredEditorId","preferredEditor","useGetEditor","defaultDocumentModelEditor","useDefaultDocumentModelEditor","openBrowserUrl","url","openUrl","validateDocument","errors","specs","initialStateErrors","scopeKey","scope","validateInitialState","err","schemaStateErrors","isGlobalScope","validateStateSchemaName","modulesErrors","validateModules","EditorLoader","showLoading","setShowLoading","customEditorLoader","defaultProps","jsx","Fragment","DefaultEditorLoader","EditorError","message","FallbackEditorError","DocumentEditor","initialDocument","onClose","onChange","onExport","onAddOperation","onGetDocumentRevision","onOpenSwitchboardLink","selectedTimelineItem","setSelectedTimelineItem","revisionHistoryVisible","setRevisionHistoryVisible","user","useUser","connectDid","useConnectDid","sign","useConnectCrypto","getDocumentModelModule","useGetDocumentModelModule","editor","_dispatch","useDocumentDispatch","context","userPermissions","useUserPermissions","timelineItems","currentDocument","action","onErrorCallback","state","prevState","signOperation","addActionContext","showRevisionHistory","hideRevisionHistory","handleUndo","undo","handleRedo","redo","isLoadingDocument","isLoadingEditor","canUndo","canRedo","useUndoRedoShortcuts","navigate","useNavigate","showModal","useModal","editorError","setEditorError","handleEditorError","info","jsxs","EditorComponent","disableExternalControls","documentToolbarEnabled","showSwitchboardLink","timelineEnabled","handleSwitchboardLinkClick","DocumentToolbar","RevisionHistory","Suspense","ErrorBoundary","DocumentEditorContainer","selectedParentNode","isRemoteDrive","remoteUrl","useDocumentDriveById","getDocument","useGetDocument","handleAddOperationToSelectedDocument","onDocumentChangeHandler","exportDocument","validationErrors","closeModal","exportFile","documentModelModule","buildDocumentSubgraphUrl","useDocumentsState","args","reactor","documentIds","statesByDocumentId","setStatesByDocumentId","isInitialized","isSubscribed","initialize","ids","update","updatedDocument","newStatesByDocumentId","makeDriveDocumentStateHook","useDocumentState","DELETE_NODE_OPERATION_TYPE","useGetDriveDocuments","documents","setDocuments","getDocumentsIds","onOperationsAdded","fetchDocuments","_driveId","_documentIds","_deletedNodes","getDocumentsPromise","newDocumentsState","newState","nodeId","deletedNodes","deletedNodesIds","DriveEditorError","useSelectedDocumentDrive","documentDrive","DriveEditorContainer","driveDocumentModelModule","useReactor","handleAddOperationToSelectedDrive","editorProps","useEditorProps","useFilteredDocumentModels","useDriveDocumentState","driveContext","useSyncStatus","useDocumentEditor","driveEditor","useDriveEditor","DriveEditorComponent","connectConfig","documentDrives","drive","pullResponder","trigger","useUnwrappedReactor","useDocument","useDocumentEditorProps","useEditorDispatch","documentDispatch","getSyncStatusSync","onSyncStatus","useSyncExternalStore","onStoreChange","_drive","_sharingType","sharingType","_extends","r","reservedModifierKeywords","mappedKeys","mapKey","key","isHotkeyModifier","parseKeysHookInput","keys","splitKey","parseHotkey","hotkey","combinationKey","description","k","modifiers","singleCharKeys","pushToCurrentlyPressedKeys","removeFromCurrentlyPressedKeys","currentlyPressedKeys","isReadonlyArray","isHotkeyPressed","hotkeyArray","maybePreventDefault","preventDefault","isHotkeyEnabled","isKeyboardEventTriggeredByInput","ev","isHotkeyEnabledOnTag","event","enabledOnTags","target","composed","targetTagName","isCustomElement","tag","_targetTagName","element","isScopeActive","activeScopes","scopes","isHotkeyMatchingKeyboardEvent","ignoreModifiers","alt","meta","mod","shift","ctrl","pressedKeyUppercase","code","ctrlKey","metaKey","shiftKey","altKey","keyCode","pressedKey","BoundHotkeysProxyProvider","createContext","useBoundHotkeysProxy","useContext","deepEqual","x","y","isEqual","HotkeysContext","useHotkeysContext","useDeepEqualMemo","ref","stopPropagation","useSafeLayoutEffect","useLayoutEffect","useHotkeys","dependencies","_useState","setRef","hasTriggeredRef","_options","_keys","_deps","memoisedCB","cbRef","memoisedOptions","_useHotkeysContext","enabledScopes","proxy","listener","isKeyUp","_e$target","rootNode","_hotkey$keys","handleKeyDown","handleKeyUp","domNode","isMac","undoShortcut","redoShortcut","Content","useParams","status","useDocumentDrives","d","toast"],"ignoreList":[27],"sources":["../../../../packages/common/dist/editors/generic-drive-explorer/components/create-document.js","../../../../packages/common/dist/editors/utils/uiNodes.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/file-content-view.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/layout.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/folder-view.js","../../../../packages/common/dist/editors/generic-drive-explorer/components/search-bar.js","../../../../packages/common/dist/editors/generic-drive-explorer/editor.js","../../../../packages/common/dist/editors/generic-drive-explorer/index.js","../../../../packages/reactor-browser/dist/src/analytics/hooks.js","../../../../packages/common/dist/hooks/useTimelineItems.js","../../../../packages/common/dist/utils/index.js","../../src/store/theme.ts","../../src/store/document-drive.ts","../../src/store/editor.ts","../../src/utils/openUrl.ts","../../src/utils/validate-document.ts","../../src/components/editor-loader.tsx","../../src/components/editors.tsx","../../src/components/document-editor-container.tsx","../../../../packages/reactor-browser/dist/src/hooks/document-state.js","../../src/hooks/useGetDriveDocuments.ts","../../src/components/drive-editor-container.tsx","../../src/hooks/useDocumentDriveById.ts","../../src/hooks/useDocumentEditor.ts","../../src/hooks/useEditorProps.tsx","../../src/hooks/useGetDocument.ts","../../src/hooks/useSyncStatus.ts","../../../../node_modules/.pnpm/react-hotkeys-hook@4.6.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js","../../src/hooks/useUndoRedoShortcuts.ts","../../src/pages/content.tsx"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Button } from \"@powerhousedao/design-system\";\nfunction getDocumentSpec(doc) {\n if (\"documentModelState\" in doc) {\n return doc.documentModelState;\n }\n return doc.documentModel;\n}\nexport const CreateDocument = ({ documentModels, createDocument, }) => {\n return (_jsxs(\"div\", { className: \"px-6\", children: [_jsx(\"h3\", { className: \"mb-3 mt-4 text-xl font-bold text-gray-600\", children: \"New document\" }), _jsx(\"div\", { className: \"flex w-full flex-wrap gap-4\", children: documentModels?.map((doc) => {\n const spec = getDocumentSpec(doc);\n return (_jsx(Button, { color: \"light\", title: spec.name, \"aria-description\": spec.description, onClick: () => createDocument(doc), children: _jsx(\"span\", { className: \"text-sm\", children: spec.name }) }, spec.id));\n }) })] }));\n};\n//# sourceMappingURL=create-document.js.map","import { DRIVE, FILE, LOCAL, } from \"@powerhousedao/reactor-browser/uiNodes/constants\";\nimport { isFolderNode, } from \"document-drive\";\nexport function sortUiNodesByName(a, b) {\n return a.name.localeCompare(b.name);\n}\nexport function makeNodeSlugFromNodeName(name) {\n return name.replaceAll(/\\s/g, \"-\");\n}\nexport function makeUiNode(node, drive, withChildren) {\n const { id, slug } = drive.header;\n const { name, icon, nodes } = drive.state.global;\n const { sharingType: _sharingType, availableOffline } = drive.state.local;\n const __sharingType = _sharingType?.toUpperCase();\n const sharingType = __sharingType === \"PRIVATE\" ? LOCAL : __sharingType;\n // TODO: handle sync status\n // const normalizedDriveSyncStatus =\n // syncStatus === 'INITIAL_SYNC'\n // ? 'SYNCING'\n // : syncStatus;\n if (node) {\n const uiNode = {\n ...node,\n slug: makeNodeSlugFromNodeName(node.name),\n driveId: id,\n parentFolder: node.parentFolder || id,\n kind: node.kind.toUpperCase(),\n syncStatus: undefined,\n sharingType,\n };\n if (uiNode.kind === FILE) {\n return uiNode;\n }\n else if (isFolderNode(node)) {\n return {\n ...uiNode,\n children: withChildren\n ? nodes\n .filter((n) => n.parentFolder === node.id)\n .map((n) => makeUiNode(n, drive, false))\n : [],\n };\n }\n }\n return {\n id,\n name,\n slug: slug || null,\n kind: DRIVE,\n nodeMap: {},\n sharingType,\n syncStatus: undefined,\n availableOffline,\n icon,\n parentFolder: null,\n driveId: id,\n children: nodes\n .filter((n) => n.parentFolder)\n .map((n) => makeUiNode(n, drive, false)),\n };\n}\nexport function makeUiDriveNode(drive) {\n const driveNode = makeUiNode(undefined, drive, true);\n driveNode.nodeMap = drive.state.global.nodes.reduce((acc, node) => {\n acc[node.id] = makeUiNode(node, drive, true);\n return acc;\n }, {});\n return driveNode;\n}\n//# sourceMappingURL=uiNodes.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { FileItem, useWindowSize, } from \"@powerhousedao/design-system\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport React, { useRef } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nconst GAP = 8;\nconst ITEM_WIDTH = 256;\nconst ITEM_HEIGHT = 48;\nconst USED_SPACE = 420;\nexport function FileContentView(props) {\n const parentRef = useRef(null);\n const { t } = useTranslation();\n const windowSize = useWindowSize();\n const { fileNodes, ...fileProps } = props;\n const availableWidth = windowSize.innerWidth - USED_SPACE;\n const columnCount = Math.floor(availableWidth / (ITEM_WIDTH + GAP)) || 1;\n const rowCount = Math.ceil(fileNodes.length / columnCount);\n const rowVirtualizer = useVirtualizer({\n count: rowCount,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n if (index > 0) {\n return ITEM_HEIGHT + GAP;\n }\n return ITEM_HEIGHT;\n },\n overscan: 5,\n });\n const columnVirtualizer = useVirtualizer({\n horizontal: true,\n count: columnCount,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n if (index > 0) {\n return ITEM_WIDTH + GAP;\n }\n return ITEM_WIDTH;\n },\n overscan: 5,\n });\n const getItemIndex = (rowIndex, columnIndex) => rowIndex * columnCount + columnIndex;\n const getItem = (rowIndex, columnIndex) => {\n const index = getItemIndex(rowIndex, columnIndex);\n return fileNodes[index] || null;\n };\n if (fileNodes.length === 0) {\n return (_jsx(\"div\", { className: \"mb-8 text-sm text-gray-400\", children: t(\"folderView.sections.documents.empty\", {\n defaultValue: \"No documents or files 📄\",\n }) }));\n }\n const renderItem = (rowIndex, columnIndex) => {\n const fileNode = getItem(rowIndex, columnIndex);\n if (!fileNode) {\n return null;\n }\n return (_jsx(\"div\", { style: {\n marginLeft: columnIndex === 0 ? 0 : GAP,\n }, children: _jsx(FileItem, { uiNode: fileNode, ...fileProps }, fileNode.id) }));\n };\n return (_jsx(\"div\", { ref: parentRef, style: {\n height: `400px`,\n width: `100%`,\n overflow: \"auto\",\n }, children: _jsx(\"div\", { style: {\n height: `${rowVirtualizer.getTotalSize()}px`,\n width: `${columnVirtualizer.getTotalSize()}px`,\n position: \"relative\",\n }, children: rowVirtualizer.getVirtualItems().map((virtualRow) => (_jsx(React.Fragment, { children: columnVirtualizer.getVirtualItems().map((virtualColumn) => (_jsx(\"div\", { style: {\n position: \"absolute\",\n top: 0,\n left: 0,\n marginTop: virtualRow.index === 0 ? 0 : GAP,\n width: `${virtualColumn.size}px`,\n height: `${virtualRow.size}px`,\n transform: `translateX(${virtualColumn.start}px) translateY(${virtualRow.start}px)`,\n }, children: renderItem(virtualRow.index, virtualColumn.index) }, virtualColumn.key))) }, virtualRow.key))) }) }));\n}\nexport default FileContentView;\n//# sourceMappingURL=file-content-view.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { cn } from \"@powerhousedao/design-system\";\nexport function DriveLayout({ children, className, ...props }) {\n return (_jsx(DriveLayout.Container, { className: className, ...props, children: children }));\n}\nDriveLayout.Container = function DriveLayoutContainer({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"flex grow flex-col overflow-auto rounded-2xl bg-gray-50 p-2\", className), ...containerProps, ...props, children: children }));\n};\nDriveLayout.Header = function DriveLayoutHeader({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"flex-0\", className), ...containerProps, ...props, children: children }));\n};\nDriveLayout.Content = function DriveLayoutContent({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"mb-5 flex-1 px-4\", className), ...containerProps, ...props, children: children }));\n};\nDriveLayout.ContentSection = function DriveLayoutContentSection({ title, children, className, containerProps, ...props }) {\n return (_jsxs(\"div\", { className: cn(className), ...containerProps, ...props, children: [title && (_jsx(\"div\", { className: \"mb-4 text-base font-semibold text-gray-600\", children: title })), _jsx(\"div\", { className: \"flex flex-wrap gap-2\", children: children })] }));\n};\nDriveLayout.Footer = function DriveLayoutFooter({ children, className, containerProps, ...props }) {\n return (_jsx(\"div\", { className: cn(\"flex-0\", className), ...containerProps, ...props, children: children }));\n};\n//# sourceMappingURL=layout.js.map","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { FILE, FOLDER, FolderItem, } from \"@powerhousedao/design-system\";\nimport { useTranslation } from \"react-i18next\";\nimport { twMerge } from \"tailwind-merge\";\nimport { sortUiNodesByName } from \"../../utils/uiNodes.js\";\nimport FileContentView from \"./file-content-view.js\";\nimport { DriveLayout } from \"./layout.js\";\nexport function FolderView(props) {\n const { node, className, isDropTarget, containerProps, ...nodeProps } = props;\n const { t } = useTranslation();\n // Remove after ts reset is fixed\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const folderNodes = node.children\n .filter((node) => node.kind === FOLDER)\n .sort(sortUiNodesByName);\n // Remove after ts reset is fixed\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const fileNodes = node.children\n .filter((node) => node.kind === FILE)\n .sort(sortUiNodesByName);\n // Convert UiNode callbacks to BaseUiFolderNode callbacks\n const folderCallbacks = {\n onSelectNode: (node) => nodeProps.onSelectNode(node),\n onRenameNode: (name, node) => nodeProps.onRenameNode(name, node),\n onDuplicateNode: (node) => nodeProps.onDuplicateNode(node),\n onDeleteNode: (node) => nodeProps.onDeleteNode(node),\n };\n // Convert UiNode callbacks to BaseUiFileNode callbacks\n const fileCallbacks = {\n onSelectNode: (node) => nodeProps.onSelectNode(node),\n onRenameNode: (name, node) => nodeProps.onRenameNode(name, node),\n onDuplicateNode: (node) => nodeProps.onDuplicateNode(node),\n onDeleteNode: (node) => nodeProps.onDeleteNode(node),\n };\n // Convert UiNode callbacks to BaseUiNode callbacks\n const baseNodeCallbacks = {\n onAddFile: async (file, parentNode) => {\n await nodeProps.onAddFile(file, parentNode);\n },\n onCopyNode: async (uiNode, targetNode) => {\n await nodeProps.onCopyNode(uiNode, targetNode);\n },\n onMoveNode: async (uiNode, targetNode) => {\n await nodeProps.onMoveNode(uiNode, targetNode);\n },\n };\n return (_jsxs(\"div\", { className: twMerge(\"rounded-md border-2 border-transparent p-2\", isDropTarget && \"border-dashed border-blue-100\", className), ...containerProps, children: [_jsx(DriveLayout.ContentSection, { title: t(\"folderView.sections.folders.title\", {\n defaultValue: \"Folders\",\n }), className: \"mb-4\", children: folderNodes.length > 0 ? (folderNodes.map((folderNode) => (_jsx(FolderItem, { uiNode: folderNode, ...baseNodeCallbacks, ...folderCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }, folderNode.id)))) : (_jsx(\"div\", { className: \"mb-8 text-sm text-gray-400\", children: t(\"folderView.sections.folders.empty\", {\n defaultValue: \"No documents or files 📄\",\n }) })) }), _jsx(DriveLayout.ContentSection, { title: t(\"folderView.sections.documents.title\", {\n defaultValue: \"Documents and files\",\n }), children: _jsx(\"div\", { className: twMerge(\"w-full\", fileNodes.length > 0 ? \"min-h-[400px]\" : \"min-h-14\"), children: _jsx(FileContentView, { fileNodes: fileNodes, ...fileCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }) }) })] }));\n}\nexport default FolderView;\n//# sourceMappingURL=folder-view.js.map","import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { ConnectSearchBar, Icon, } from \"@powerhousedao/design-system\";\nimport { useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nconst defaultFilterItems = [\n {\n id: \"project\",\n label: \".project\",\n icon: _jsx(Icon, { name: \"Project\", color: \"#FF6A55\", size: 16 }),\n },\n {\n id: \"budget\",\n label: \".budget\",\n icon: _jsx(Icon, { name: \"BarChart\", color: \"#8E55EA\", size: 16 }),\n },\n {\n id: \"profile\",\n label: \".profile\",\n icon: _jsx(Icon, { name: \"Person\", color: \"#3E90F0\", size: 16 }),\n },\n {\n id: \"legal\",\n label: \".legal\",\n icon: _jsx(Icon, { name: \"Briefcase\", color: \"#4BAB71\", size: 16 }),\n },\n {\n id: \"atlas\",\n label: \".Atlas\",\n icon: _jsx(Icon, { name: \"Globe\", color: \"#FF8A00\", size: 16 }),\n },\n];\nexport const SearchBar = () => {\n const { t } = useTranslation();\n const [value, setValue] = useState(\"\"); // TODO\n return (_jsx(ConnectSearchBar, { className: \"max-w-searchbar-width m-4 shrink-0 bg-gray-100\", placeholder: t(\"searchbar.placeholder\"), filterLabel: t(\"searchbar.filterLabel\"), filterItems: defaultFilterItems, value: value, onChange: setValue }));\n};\n//# sourceMappingURL=search-bar.js.map","import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Breadcrumbs, useBreadcrumbs, useDrop, } from \"@powerhousedao/design-system\";\nimport { useDriveActionsWithUiNodes } from \"@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes\";\nimport { DriveContextProvider, useDriveContext, } from \"@powerhousedao/reactor-browser/hooks/useDriveContext\";\nimport { FILE, useUiNodesContext, } from \"@powerhousedao/reactor-browser/hooks/useUiNodesContext\";\nimport { useCallback, useMemo } from \"react\";\n/* import { useDocuments, useSelectedDocument } from \"../../state/documents.js\";\nimport { useDrives, useSelectedDrive } from \"../../state/drives.js\";\nimport { useSelectedFolder } from \"../../state/folders.js\";\nimport { useReactor } from \"../../state/reactor.js\"; */\nimport { CreateDocument } from \"./components/create-document.js\";\nimport FolderView from \"./components/folder-view.js\";\nimport { DriveLayout } from \"./components/layout.js\";\nimport { SearchBar } from \"./components/search-bar.js\";\nexport function BaseEditor(props) {\n /* const loadableReactor = useReactor();\n const loadableDrives = useDrives();\n const loadableDocuments = useDocuments();\n const loadableSelectedDrive = useSelectedDrive();\n const loadableSelectedFolder = useSelectedFolder();\n const loadableSelectedDocument = useSelectedDocument();\n console.log(\"in base editor\", {\n loadableReactor,\n loadableDrives,\n loadableDocuments,\n loadableSelectedDrive,\n loadableSelectedFolder,\n loadableSelectedDocument,\n }); */\n const { document, dispatch, className, children } = props;\n const { header: { id: driveId }, } = document;\n const { showSearchBar, isAllowedToCreateDocuments, documentModels, showCreateDocumentModal, } = useDriveContext();\n const { driveNodes, selectedNode, selectedNodePath, getNodeById, setSelectedNode, } = useUiNodesContext();\n const driveNode = useMemo(() => driveNodes.find((n) => n.id === driveId), [driveNodes, driveId]);\n const { addDocument, addFile, addFolder, renameNode, deleteNode, moveNode, copyNode, duplicateNode, } = useDriveActionsWithUiNodes(document, dispatch);\n const onCreateDocument = useCallback(async (documentModel) => {\n const { name } = await showCreateDocumentModal(documentModel);\n const document = documentModel.utils.createDocument();\n await addDocument(name, documentModel.documentModel.name, document, selectedNode?.id);\n }, [addDocument, showCreateDocumentModal, selectedNode?.id]);\n const { isDropTarget: isDropTargetFolder, dropProps: dropPropsFolder } = useDrop({\n uiNode: selectedNode,\n onAddFile: addFile,\n onCopyNode: copyNode,\n onMoveNode: moveNode,\n });\n const { isDropTarget, dropProps } = useDrop({\n uiNode: selectedNode?.kind === \"FOLDER\" ? selectedNode : null,\n onAddFile: addFile,\n onCopyNode: copyNode,\n onMoveNode: moveNode,\n });\n const { breadcrumbs, onBreadcrumbSelected } = useBreadcrumbs({\n selectedNodePath,\n getNodeById,\n setSelectedNode,\n });\n if (!driveNode) {\n return _jsx(\"div\", { children: \"Drive not found\" });\n }\n else if (selectedNode?.kind === FILE) {\n return _jsx(_Fragment, {});\n }\n return (_jsxs(DriveLayout, { className: className, children: [children, _jsxs(DriveLayout.Header, { children: [_jsx(Breadcrumbs, { breadcrumbs: breadcrumbs, createEnabled: isAllowedToCreateDocuments, onCreate: addFolder, onBreadcrumbSelected: onBreadcrumbSelected }), showSearchBar && _jsx(SearchBar, {})] }), _jsx(DriveLayout.Content, { ...dropProps, className: isDropTarget ? \"rounded-xl bg-blue-100\" : \"\", children: _jsx(FolderView, { node: selectedNode || driveNode, onSelectNode: setSelectedNode, onRenameNode: renameNode, onDuplicateNode: duplicateNode, onDeleteNode: deleteNode, onAddFile: addFile, onCopyNode: copyNode, onMoveNode: moveNode, isAllowedToCreateDocuments: isAllowedToCreateDocuments, isDropTarget: isDropTargetFolder, ...dropPropsFolder }) }), _jsx(DriveLayout.Footer, { children: isAllowedToCreateDocuments && (_jsx(CreateDocument, { documentModels: documentModels, createDocument: onCreateDocument })) })] }));\n}\nexport default function Editor(props) {\n return (_jsx(DriveContextProvider, { value: props.context, children: _jsx(BaseEditor, { ...props }) }));\n}\n//# sourceMappingURL=editor.js.map","import Editor from \"./editor.js\";\nexport const GenericDriveExplorer = {\n Component: Editor,\n documentTypes: [\"powerhouse/document-drive\"],\n config: {\n id: \"GenericDriveExplorer\",\n disableExternalControls: true,\n documentToolbarEnabled: true,\n showSwitchboardLink: true,\n },\n};\n//# sourceMappingURL=index.js.map","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { useMutation, useQuery, useQueryClient, } from \"@tanstack/react-query\";\nimport { useEffect } from \"react\";\nimport { getAnalyticsStore, useAnalyticsEngineAsync, useAnalyticsStoreAsync, useAnalyticsStoreOptions, } from \"./context.js\";\nfunction useAnalyticsQueryWrapper(options) {\n const { queryFn, ...queryOptions } = options;\n const { data: store } = useAnalyticsStoreAsync();\n const { data: engine } = useAnalyticsEngineAsync();\n const enabled = \"enabled\" in queryOptions ? queryOptions.enabled : !!store && !!engine;\n return useQuery({\n ...queryOptions,\n enabled,\n queryFn: async () => {\n if (!store || !engine) {\n throw new Error(\"No analytics store available. Use within an AnalyticsProvider.\");\n }\n return await queryFn({ store, engine });\n },\n });\n}\nfunction useAnalyticsMutationWrapper(options) {\n const { mutationFn, ...mutationOptions } = options;\n const storeOptions = useAnalyticsStoreOptions();\n return useMutation({\n ...mutationOptions,\n mutationFn: async (value) => {\n let store = null;\n try {\n store = await getAnalyticsStore(storeOptions);\n }\n catch (e) {\n console.error(e);\n }\n if (!store) {\n throw new Error(\"No analytics store available. Use within an AnalyticsProvider.\");\n }\n return await mutationFn(value, { store });\n },\n });\n}\nconst DEBOUNCE_INTERVAL = 200;\nexport function useAnalyticsQuery(query, options) {\n const { data: store } = useAnalyticsStoreAsync();\n const queryClient = useQueryClient();\n const sources = options?.sources ?? [];\n const result = useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"query\", query],\n queryFn: ({ engine }) => engine.execute(query),\n ...options,\n });\n useEffect(() => {\n if (!sources.length || !store) {\n return;\n }\n const subscriptions = new Array();\n // Debounce invalidateQueries so it's not called too frequently\n let invalidateTimeout = null;\n const debouncedInvalidate = () => {\n if (invalidateTimeout)\n clearTimeout(invalidateTimeout);\n invalidateTimeout = setTimeout(() => {\n queryClient\n .invalidateQueries({\n queryKey: [\"analytics\", \"query\", query],\n })\n .catch((e) => {\n console.error(e);\n });\n }, DEBOUNCE_INTERVAL);\n };\n sources.forEach((path) => {\n const unsub = store.subscribeToSource(path, debouncedInvalidate);\n subscriptions.push(unsub);\n });\n // Unsubscribes from store when component unmounts or dependencies change\n return () => {\n subscriptions.forEach((unsub) => unsub());\n };\n }, [query, store, sources]);\n return result;\n}\nexport function useAnalyticsSeries(query, options) {\n return useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"series\", query],\n queryFn: ({ store }) => store.getMatchingSeries(query),\n ...options,\n });\n}\nexport function useAddSeriesValue(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"addSeries\"],\n mutationFn: async (value, { store }) => {\n return await store.addSeriesValue(value);\n },\n ...options,\n });\n}\nexport function useClearSeriesBySource(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"clearSeries\"],\n mutationFn: async ({ source, cleanUpDimensions }, { store }) => {\n return store.clearSeriesBySource(source, cleanUpDimensions);\n },\n ...options,\n });\n}\nexport function useClearEmptyAnalyticsDimensions(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"clearEmptyDimensions\"],\n mutationFn: async (_, { store }) => {\n return store.clearEmptyAnalyticsDimensions();\n },\n ...options,\n });\n}\nexport function useAddSeriesValues(options) {\n return useAnalyticsMutationWrapper({\n mutationKey: [\"analytics\", \"addSeriesValues\"],\n mutationFn: async (values, { store }) => {\n return store.addSeriesValues(values);\n },\n ...options,\n });\n}\nexport function useGetDimensions(options) {\n return useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"dimensions\"],\n queryFn: ({ store }) => store.getDimensions(),\n ...options,\n });\n}\nexport function useMatchingSeries(query, options) {\n const result = useAnalyticsQueryWrapper({\n queryKey: [\"analytics\", \"matchingSeries\", query],\n queryFn: ({ store }) => store.getMatchingSeries(query),\n ...options,\n });\n return result;\n}\nexport function useQuerySources(query, options) {\n const { data: matchingSeries } = useMatchingSeries(query);\n return useQuery({\n queryKey: [\"analytics\", \"sources\", query],\n queryFn: () => {\n if (!matchingSeries?.length) {\n return [];\n }\n const uniqueSources = [\n ...new Set(matchingSeries.map((s) => s.source.toString())),\n ];\n return uniqueSources.map((source) => AnalyticsPath.fromString(source));\n },\n enabled: !!matchingSeries,\n ...options,\n });\n}\n//# sourceMappingURL=hooks.js.map","import { AnalyticsGranularity, AnalyticsPath, DateTime, useAnalyticsQuery, } from \"@powerhousedao/reactor-browser/analytics\";\nconst getBarSize = (value) => {\n if (value <= 0)\n return 0;\n if (value > 0 && value <= 50)\n return 1;\n if (value > 50 && value <= 100)\n return 2;\n if (value > 100 && value <= 250)\n return 3;\n return 4;\n};\nfunction addItemsDividers(items) {\n if (!items.length)\n return [];\n const result = [];\n items.forEach((item, index) => {\n result.push(item);\n // Check if there's a next item and if they're not in consecutive hours\n if (index < items.length - 1) {\n const currentDate = new Date(item.startDate);\n const nextDate = new Date(items[index + 1].startDate);\n const currentHour = currentDate.getHours();\n const nextHour = nextDate.getHours();\n // Get day parts (without time) for comparison\n const currentDay = currentDate.toDateString();\n const nextDay = nextDate.toDateString();\n // If different days or non-consecutive hours on the same day\n if (currentDay !== nextDay ||\n (currentDay === nextDay && Math.abs(nextHour - currentHour) > 1)) {\n result.push({\n id: `divider-${item.id}-${items[index + 1].id}`,\n type: \"divider\",\n revision: 0,\n });\n }\n }\n });\n return result;\n}\nfunction metricsToItems(metrics) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!metrics)\n return [];\n const items = metrics\n .sort((a, b) => {\n const aDate = new Date(a.start);\n const bDate = new Date(b.start);\n return aDate.getTime() - bDate.getTime();\n })\n .filter((result) => {\n return result.rows.every((row) => row.value > 0);\n })\n .map((result) => {\n const { additions, deletions } = result.rows.reduce((acc, row) => {\n if (row.dimensions.changes.path ===\n \"ph/diff/changes/add\") {\n acc.additions += row.value;\n }\n else if (row.dimensions.changes.path ===\n \"ph/diff/changes/remove\") {\n acc.deletions += row.value;\n }\n return acc;\n }, { additions: 0, deletions: 0 });\n const startDate = new Date(result.start);\n return {\n id: startDate.toISOString(),\n type: \"bar\",\n addSize: getBarSize(additions),\n delSize: getBarSize(deletions),\n additions,\n deletions,\n timestamp: startDate.toISOString(),\n startDate: startDate,\n endDate: new Date(result.end),\n revision: 0,\n };\n });\n return addItemsDividers(items);\n}\nexport const useTimelineItems = (documentId, startTimestamp, driveId) => {\n const start = startTimestamp\n ? DateTime.fromISO(startTimestamp)\n : DateTime.now().startOf(\"day\");\n return useAnalyticsQuery({\n start,\n end: DateTime.now().endOf(\"day\"),\n granularity: AnalyticsGranularity.Hourly,\n metrics: [\"Count\"],\n select: {\n changes: [AnalyticsPath.fromString(`ph/diff/changes`)],\n document: [AnalyticsPath.fromString(`ph/diff/document/${documentId}`)],\n },\n lod: {\n changes: 4,\n },\n }, {\n sources: [AnalyticsPath.fromString(`ph/diff/${driveId}/${documentId}`)],\n select: metricsToItems,\n });\n};\n//# sourceMappingURL=useTimelineItems.js.map","export const getRevisionFromDate = (startDate, endDate, operations = []) => {\n if (!startDate || !endDate)\n return 0;\n const operation = operations.find((operation) => {\n const operationDate = new Date(operation.timestamp);\n return operationDate >= startDate && operationDate <= endDate;\n });\n return operation ? operation.index : 0;\n};\n//# sourceMappingURL=index.js.map","import { useAtomValue } from 'jotai';\nimport { atomWithStorageCallback } from './utils.js';\n\nconst THEMES = ['light', 'dark'] as const;\n\nexport type Theme = (typeof THEMES)[number];\n\nexport const themeAtom = atomWithStorageCallback<Theme>(\n 'theme',\n 'light',\n theme => {\n if (typeof window !== 'undefined') {\n window.electronAPI?.setTheme(theme);\n }\n },\n);\n\nexport const useTheme = () => useAtomValue(themeAtom);\n\nexport function isTheme(theme: string): theme is Theme {\n return THEMES.includes(theme as Theme);\n}\n","import { useReadModeContext } from '#context';\nimport { documentToHash, useDocumentDriveServer } from '#hooks';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport { logger } from 'document-drive';\nimport {\n hashDocumentStateForScope,\n type Operation,\n type PHDocument,\n} from 'document-model';\nimport { atom, useAtom, useSetAtom } from 'jotai';\nimport { useCallback, useEffect, useMemo } from 'react';\n\nfunction debounceOperations(\n callback: (operations: Operation[]) => Promise<PHDocument | undefined>,\n timeout = 50,\n) {\n let timer: number;\n const operations: Operation[] = [];\n return (operation: Operation) => {\n if (timer) {\n clearTimeout(timer);\n }\n const index = operations.findIndex(\n op => op.scope === operation.scope && op.index === operation.index,\n );\n if (index > -1) {\n const oldOperation = operations[index];\n if (\n !(\n oldOperation.type === operation.type &&\n JSON.stringify(operation.input) ===\n JSON.stringify(oldOperation.input)\n )\n ) {\n console.warn(\n 'Two conflicting operations were dispatched:',\n oldOperation,\n operation,\n );\n }\n operations[index] = operation;\n } else {\n operations.push(operation);\n }\n return new Promise<PHDocument | undefined>((resolve, reject) => {\n timer = setTimeout(() => {\n callback(operations).then(resolve).catch(reject);\n }, timeout) as unknown as number;\n });\n };\n}\n\nexport type FileNodeDocument =\n | {\n driveId: string;\n documentId: string;\n documentType: string;\n name: string;\n document: PHDocument | undefined;\n status: 'LOADING' | 'ERROR';\n }\n | {\n driveId: string;\n documentId: string;\n documentType: string;\n name: string;\n document: PHDocument;\n status: 'LOADED';\n }\n | undefined;\n\nconst documentCacheAtom = atom(new Map<string, PHDocument>());\ndocumentCacheAtom.debugLabel = 'documentCacheAtomInConnect';\n\nconst singletonFileNodeDocumentAtom = atom<FileNodeDocument>(undefined);\nsingletonFileNodeDocumentAtom.debugLabel =\n 'singletonFileNodeDocumentAtomInConnect';\n\nexport function isSameDocument(\n prev: PHDocument | undefined,\n next: PHDocument | undefined,\n) {\n if (prev === next) {\n return true;\n }\n if (!prev || !next) {\n return false;\n }\n if (hashDocumentStateForScope(prev) === hashDocumentStateForScope(next)) {\n return true;\n } else {\n return false;\n }\n}\n\nconst fileNodeDocumentAtom = atom(\n get => get(singletonFileNodeDocumentAtom),\n (get, set, newValue: FileNodeDocument) => {\n const currentValue = get(singletonFileNodeDocumentAtom);\n\n // if document will be loaded then sets\n // the cached version while it loads\n const documentCache = get(documentCacheAtom);\n if (!newValue?.document && newValue?.status === 'LOADING') {\n newValue.document = documentCache.get(\n `${newValue.driveId}:${newValue.documentId}`,\n );\n }\n\n // only change if the provided file node is different\n if (\n currentValue?.driveId !== newValue?.driveId ||\n currentValue?.documentId !== newValue?.documentId ||\n currentValue?.documentType !== newValue?.documentType ||\n currentValue?.status !== newValue?.status ||\n !!currentValue?.document !== !!newValue?.document ||\n (currentValue?.document &&\n newValue?.document &&\n documentToHash(currentValue.document) !==\n documentToHash(newValue.document))\n ) {\n // if document has been fetched then updates the cache\n if (newValue?.status === 'LOADED') {\n documentCache.set(\n `${newValue.driveId}:${newValue.documentId}`,\n newValue.document,\n );\n }\n\n set(singletonFileNodeDocumentAtom, newValue);\n return true;\n }\n\n return false;\n },\n);\nfileNodeDocumentAtom.debugLabel = 'fileNodeDocumentAtomInConnect';\n\nconst selectedDocumentAtom = atom(\n null,\n (get, set, document: PHDocument | undefined) => {\n const fileNodeDocument = get(fileNodeDocumentAtom);\n if (!fileNodeDocument) {\n throw new Error('fileNodeDocument is undefined');\n } else if (!document) {\n set(fileNodeDocumentAtom, undefined);\n } else if (!isSameDocument(document, fileNodeDocument.document)) {\n set(fileNodeDocumentAtom, { ...fileNodeDocument, document });\n }\n },\n);\nselectedDocumentAtom.debugLabel = 'selectedDocumentAtomInConnect';\nconst useSetSelectedDocument = () => useSetAtom(selectedDocumentAtom);\n\nexport function useFileNodeDocument() {\n const { selectedNode, selectedDriveNode } = useUiNodesContext();\n\n const { openFile, addOperations, onStrandUpdate } =\n useDocumentDriveServer();\n const { fetchDocument: fetchReadDocument } = useReadModeContext();\n const [fileNodeDocument, setFileNodeDocument] =\n useAtom(fileNodeDocumentAtom);\n const isReadMode =\n selectedDriveNode?.sharingType !== 'LOCAL' &&\n selectedDriveNode?.syncStatus === undefined;\n const driveId = selectedNode?.driveId;\n const documentId = selectedNode?.id;\n const name = selectedNode?.name;\n const kind = selectedNode?.kind;\n const documentType =\n kind === 'FILE' ? selectedNode?.documentType : undefined;\n\n const setSelectedDocument = useSetSelectedDocument();\n const fetchDocument = useCallback(\n async (driveId: string, id: string, documentType: string) => {\n const document = await (isReadMode\n ? fetchReadDocument(driveId, id, documentType)\n : openFile(driveId, id));\n if (document instanceof Error) {\n throw document;\n }\n return document;\n },\n [fetchReadDocument, isReadMode, openFile],\n );\n\n useEffect(() => {\n // if selected node is undefine then clears fileNodeDocument\n if (!driveId || !documentId || !documentType) {\n if (fileNodeDocument) {\n setFileNodeDocument(undefined);\n }\n return;\n }\n\n // if selectedNode changes then fetches fileNodeDocument\n if (\n driveId !== fileNodeDocument?.driveId ||\n documentId !== fileNodeDocument.documentId ||\n documentType !== fileNodeDocument.documentType ||\n name !== fileNodeDocument.name\n ) {\n const changed = setFileNodeDocument({\n driveId,\n documentId,\n documentType,\n name: name || '',\n document: undefined,\n status: 'LOADING',\n });\n\n // if the selected file node changed then fetches the new document\n if (changed) {\n fetchDocument(driveId, documentId, documentType)\n .then(document =>\n setFileNodeDocument(\n document\n ? {\n driveId,\n documentId,\n documentType,\n document,\n name: name || '',\n status: 'LOADED',\n }\n : {\n driveId,\n documentId,\n documentType,\n document,\n name: name || '',\n status: 'ERROR',\n },\n ),\n )\n .catch(error => {\n logger.error(error);\n setFileNodeDocument({\n driveId,\n documentId,\n documentType,\n name: name || '',\n document: undefined,\n status: 'ERROR',\n });\n });\n }\n }\n }, [\n selectedNode,\n documentId,\n documentType,\n name,\n driveId,\n fetchDocument,\n fileNodeDocument,\n setFileNodeDocument,\n ]);\n\n useEffect(() => {\n if (\n !fileNodeDocument?.driveId ||\n !fileNodeDocument.documentId ||\n !fileNodeDocument.documentType\n ) {\n return;\n }\n\n // watches for strand updates to update the document\n const removeListener = onStrandUpdate(strand => {\n if (\n strand.driveId === fileNodeDocument.driveId &&\n strand.documentId === fileNodeDocument.documentId\n ) {\n fetchDocument(\n fileNodeDocument.driveId,\n fileNodeDocument.documentId,\n fileNodeDocument.documentType,\n )\n .then(setSelectedDocument)\n .catch(logger.error);\n }\n });\n\n return removeListener;\n }, [\n fileNodeDocument?.driveId,\n fileNodeDocument?.documentId,\n fileNodeDocument?.documentType,\n onStrandUpdate,\n fetchDocument,\n setSelectedDocument,\n ]);\n\n const addOperationToSelectedDocument = useMemo(() => {\n if (driveId && documentId && kind === 'FILE') {\n return debounceOperations(operations =>\n addOperations(driveId, documentId, operations),\n );\n }\n }, [addOperations, driveId, documentId, kind]);\n\n const addOperationToSelectedDrive = useCallback(\n (operation: Operation) => {\n if (!selectedDriveNode?.id) {\n throw new Error('No drive node selected');\n }\n return debounceOperations(operations =>\n addOperations(selectedDriveNode.id, undefined, operations),\n )(operation);\n },\n [addOperations, selectedDriveNode?.id],\n );\n\n const isSelectedDocument =\n kind === 'FILE' &&\n fileNodeDocument?.driveId === driveId &&\n fileNodeDocument?.documentId === documentId;\n const selectedDocument = isSelectedDocument\n ? fileNodeDocument?.document\n : undefined;\n\n return useMemo(\n () => ({\n fileNodeDocument,\n selectedDocument,\n setSelectedDocument,\n addOperationToSelectedDocument,\n addOperationToSelectedDrive,\n }),\n [\n fileNodeDocument,\n isSelectedDocument,\n selectedDocument,\n setSelectedDocument,\n addOperationToSelectedDocument,\n addOperationToSelectedDrive,\n ],\n );\n}\n","import { useDefaultDocumentModelEditor } from '#hooks';\nimport { type DocumentModelLib, type EditorModule } from 'document-model';\nimport { atom, useAtomValue } from 'jotai';\nimport { atomWithLazy, loadable, unwrap } from 'jotai/utils';\nimport { useCallback, useEffect, useRef } from 'react';\nimport { externalPackagesAtom } from './external-packages.js';\n\nasync function loadBaseEditors() {\n const documentModelEditor = await import(\n '@powerhousedao/builder-tools/document-model-editor'\n );\n await import('@powerhousedao/builder-tools/style.css');\n const module = documentModelEditor.documentModelEditorModule;\n return [module] as EditorModule[];\n}\n\nfunction getEditorsFromModules(modules: DocumentModelLib[]) {\n return modules\n .map(module => module.editors)\n .reduce((acc, val) => acc.concat(val), []);\n}\n\nconst baseEditorsAtom = atomWithLazy(loadBaseEditors);\nbaseEditorsAtom.debugLabel = 'baseEditorsAtomInConnect';\nexport const editorsAtom = atom(async get => {\n const baseEditors = await get(baseEditorsAtom);\n const externalModules = await get(externalPackagesAtom);\n const externalEditors = getEditorsFromModules(externalModules);\n\n return externalEditors.concat(baseEditors);\n});\neditorsAtom.debugLabel = 'editorsAtomInConnect';\n\nconst unwrappedEditorsAtom = unwrap(editorsAtom);\nunwrappedEditorsAtom.debugLabel = 'unwrappedEditorsAtomInConnect';\nconst loadableEditorsAtom = loadable(editorsAtom);\nloadableEditorsAtom.debugLabel = 'loadableEditorsAtomInConnect';\n\n// suspends the UI while editors are loading\nexport const useEditors = () => {\n return useAtomValue(editorsAtom);\n};\n\n// will return undefined until editors are initialized. Does not block rendering.\nexport const useUnwrappedEditors = () => {\n return useAtomValue(unwrappedEditorsAtom);\n};\n\n// returns state, data and error, which will cause a rerender when the editors are loaded. Does not suspend the UI\nexport const useLoadableEditors = () => {\n return useAtomValue(loadableEditorsAtom);\n};\n\nexport const useEditorsAsync = () => {\n const editorsPromise = useRef(\n (() => {\n let resolveFn!: (value: EditorModule[]) => void;\n let rejectFn!: (reason?: any) => void;\n\n const promise = new Promise<EditorModule[]>((resolve, reject) => {\n resolveFn = resolve;\n rejectFn = reject;\n });\n\n return { promise, resolve: resolveFn, reject: rejectFn };\n })(),\n );\n\n const editors = useLoadableEditors();\n\n useEffect(() => {\n if (editors.state === 'hasError') {\n editorsPromise.current.reject(editors.error);\n } else if (editors.state === 'hasData') {\n editorsPromise.current.resolve(editors.data);\n }\n }, [editors]);\n return editorsPromise.current.promise;\n};\n\nconst getEditor = (\n documentType: string,\n editors: EditorModule[],\n preferredEditorId?: string,\n) => {\n const preferredEditor = editors.find(\n e =>\n e.config.id === preferredEditorId &&\n e.documentTypes.includes(documentType),\n );\n\n if (preferredEditor) return preferredEditor;\n\n const editor =\n editors.find(e => e.documentTypes.includes(documentType)) ||\n editors.find(e => e.documentTypes.includes('*'));\n\n return editor || null;\n};\n\nexport const useEditor = (documentType: string) => {\n const editors = useUnwrappedEditors();\n if (!editors) {\n return undefined;\n }\n return getEditor(documentType, editors);\n};\n\nexport const useGetEditor = () => {\n const editors = useUnwrappedEditors();\n const [defaultDocumentModelEditor] = useDefaultDocumentModelEditor();\n\n return (documentType: string) =>\n editors\n ? getEditor(documentType, editors, defaultDocumentModelEditor.value)\n : undefined;\n};\n\nexport const usePreloadEditor = () => {\n const editorsPromise = useEditorsAsync();\n return useCallback(\n async (documentType: string) => {\n const editors = await editorsPromise;\n const editor = getEditor(documentType, editors);\n if (editor && 'preload' in editor.Component) {\n console.log(\n `Preloading editor for document '${documentType}': ${editor.config.id}`,\n );\n await (\n editor.Component as { preload: () => Promise<void> }\n ).preload();\n }\n },\n [editorsPromise],\n );\n};\n","const openBrowserUrl = (url: string) => window.open(url, '_blank');\n\nexport const openUrl = window.electronAPI?.openURL ?? openBrowserUrl;\n","import {\n type DocumentModelDocument,\n type PHDocument,\n validateInitialState,\n validateModules,\n validateStateSchemaName,\n type ValidationError,\n} from 'document-model';\nexport const validateDocument = (document: PHDocument) => {\n const errors: ValidationError[] = [];\n\n if (document.header.documentType !== 'powerhouse/document-model') {\n return errors;\n }\n\n const doc = document as DocumentModelDocument;\n const specs = doc.state.global.specifications[0];\n\n // validate initial state errors\n const initialStateErrors = Object.keys(specs.state).reduce<\n ValidationError[]\n >((acc, scopeKey) => {\n const scope = scopeKey as keyof typeof specs.state;\n\n return [\n ...acc,\n ...validateInitialState(\n specs.state[scope].initialValue,\n scope !== 'global',\n ).map(err => ({\n ...err,\n message: `${err.message}. Scope: ${scope}`,\n details: { ...err.details, scope },\n })),\n ];\n }, []);\n\n // validate schema state errors\n const schemaStateErrors = Object.keys(specs.state).reduce<\n ValidationError[]\n >((acc, scopeKey) => {\n const scope = scopeKey as keyof typeof specs.state;\n const isGlobalScope = scope === 'global';\n\n return [\n ...acc,\n ...validateStateSchemaName(\n specs.state[scope].schema,\n doc.header.name || doc.state.global?.name || '',\n !isGlobalScope ? scope : '',\n !isGlobalScope,\n ).map(err => ({\n ...err,\n message: `${err.message}. Scope: ${scope}`,\n details: { ...err.details, scope },\n })),\n ];\n }, []);\n\n // modules validation\n const modulesErrors = validateModules(specs.modules);\n\n return [...initialStateErrors, ...schemaStateErrors, ...modulesErrors];\n};\n","import { DefaultEditorLoader } from '@powerhousedao/design-system';\nimport {\n type ComponentProps,\n type ReactNode,\n useEffect,\n useState,\n} from 'react';\n\ntype Props = ComponentProps<typeof DefaultEditorLoader> & {\n loadingTimeout?: number;\n customEditorLoader?: ReactNode;\n};\nexport function EditorLoader(props: Props) {\n const [showLoading, setShowLoading] = useState(false);\n\n // only shows the loader after some time has passed\n useEffect(() => {\n setTimeout(() => {\n setShowLoading(true);\n }, props.loadingTimeout ?? 200);\n }, [props]);\n\n if (!showLoading) return null;\n\n const { customEditorLoader, ...defaultProps } = props;\n\n if (customEditorLoader) return <>{customEditorLoader}</>;\n\n return <DefaultEditorLoader {...defaultProps} />;\n}\n","import {\n useConnectCrypto,\n useConnectDid,\n useUndoRedoShortcuts,\n useUserPermissions,\n} from '#hooks';\nimport {\n type FileNodeDocument,\n isSameDocument,\n themeAtom,\n useGetDocumentModelModule,\n useGetEditor,\n useUser,\n} from '#store';\nimport {\n addActionContext,\n type DocumentDispatchCallback,\n signOperation,\n useDocumentDispatch,\n} from '#utils';\nimport { getRevisionFromDate, useTimelineItems } from '@powerhousedao/common';\nimport {\n Button,\n DocumentToolbar,\n RevisionHistory,\n type TimelineItem,\n} from '@powerhousedao/design-system';\nimport { logger } from 'document-drive';\nimport {\n type Action,\n type ActionErrorCallback,\n type EditorContext,\n type Operation,\n type PHDocument,\n redo,\n undo,\n} from 'document-model';\nimport { useAtomValue } from 'jotai';\nimport {\n Suspense,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { ErrorBoundary, type FallbackProps } from 'react-error-boundary';\nimport { useNavigate } from 'react-router-dom';\nimport { EditorLoader } from './editor-loader.js';\nimport { useModal } from './modal/index.js';\n\nexport type EditorProps<TDocument extends PHDocument = PHDocument> = {\n fileNodeDocument: FileNodeDocument;\n document: TDocument | undefined;\n onClose: () => void;\n onExport: () => void;\n onAddOperation: (operation: Operation) => Promise<void>;\n onOpenSwitchboardLink?: () => Promise<void>;\n onChange?: (documentId: string, document: TDocument) => void;\n onGetDocumentRevision?: EditorContext['getDocumentRevision'];\n};\n\nfunction EditorError({ message }: { message: React.ReactNode }) {\n return (\n <div className=\"flex size-full items-center justify-center\">\n <h3 className=\"text-lg font-semibold\">{message}</h3>\n </div>\n );\n}\n\nfunction FallbackEditorError(props: FallbackProps) {\n const message =\n props.error instanceof Error\n ? props.error.message\n : (props.error as string);\n return <EditorError message={message} />;\n}\n\nexport const DocumentEditor: React.FC<EditorProps> = props => {\n const {\n fileNodeDocument,\n document: initialDocument,\n onClose,\n onChange,\n onExport,\n onAddOperation,\n onGetDocumentRevision,\n onOpenSwitchboardLink,\n } = props;\n const documentId = fileNodeDocument?.documentId;\n const [selectedTimelineItem, setSelectedTimelineItem] =\n useState<TimelineItem | null>(null);\n\n const [revisionHistoryVisible, setRevisionHistoryVisible] = useState(false);\n const theme = useAtomValue(themeAtom);\n const user = useUser() || undefined;\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n const getDocumentModelModule = useGetDocumentModelModule();\n const getEditor = useGetEditor();\n\n const documentType = fileNodeDocument?.documentType;\n const documentModel = useMemo(\n () => (documentType ? getDocumentModelModule(documentType) : undefined),\n [documentType, getDocumentModelModule],\n );\n\n const editor = useMemo(\n () => (documentType ? getEditor(documentType) : undefined),\n [documentType, getEditor],\n );\n\n const [document, _dispatch, error] = useDocumentDispatch(\n documentModel?.reducer,\n initialDocument,\n );\n const context: EditorContext = useMemo(\n () => ({ theme, user }),\n [theme, user],\n );\n const userPermissions = useUserPermissions();\n\n const timelineItems = useTimelineItems(\n documentId,\n initialDocument?.header.createdAtUtcIso,\n );\n\n const currentDocument = useRef({ ...fileNodeDocument, document });\n useEffect(() => {\n if (!fileNodeDocument?.documentId || !document) return;\n\n // if current document ref is undefined or outdated then updates the ref\n // and doesn't call the onChange callback\n if (\n !('documentId' in currentDocument.current) ||\n currentDocument.current.documentId !== documentId\n ) {\n currentDocument.current = { ...fileNodeDocument, document };\n return;\n }\n\n // if the document is different then calls the onChange callback\n if (!isSameDocument(currentDocument.current.document, document)) {\n currentDocument.current.document = document;\n window.documentEditorDebugTools?.setDocument(document);\n onChange?.(documentId, document);\n }\n }, [document, documentId, fileNodeDocument, onChange]);\n\n const dispatch = useCallback(\n (action: Action, onErrorCallback?: ActionErrorCallback) => {\n const callback: DocumentDispatchCallback<PHDocument> = (\n operation,\n state,\n ) => {\n if (!fileNodeDocument?.documentId) return;\n\n const { prevState } = state;\n\n signOperation(\n operation,\n sign,\n fileNodeDocument.documentId,\n prevState,\n documentModel?.reducer,\n user,\n )\n .then(op => {\n window.documentEditorDebugTools?.pushOperation(\n operation,\n );\n return onAddOperation(op);\n })\n .catch(logger.error);\n };\n\n _dispatch(\n addActionContext(action, connectDid, user),\n callback,\n onErrorCallback,\n );\n },\n [\n _dispatch,\n connectDid,\n documentModel?.reducer,\n onAddOperation,\n fileNodeDocument,\n sign,\n user,\n ],\n );\n\n const showRevisionHistory = useCallback(\n () => setRevisionHistoryVisible(true),\n [],\n );\n\n const hideRevisionHistory = useCallback(\n () => setRevisionHistoryVisible(false),\n [],\n );\n const handleUndo = useCallback(() => {\n dispatch(undo());\n }, [dispatch]);\n\n const handleRedo = useCallback(() => {\n dispatch(redo());\n }, [dispatch]);\n\n const isLoadingDocument =\n fileNodeDocument?.status === 'LOADING' || !document;\n const isLoadingEditor =\n editor === undefined ||\n (!!document &&\n editor &&\n !editor.documentTypes.includes(document.header.documentType) &&\n !editor.documentTypes.includes('*'));\n\n const canUndo =\n !!document &&\n (document.header.revision.global > 0 ||\n document.header.revision.local > 0);\n const canRedo = !!document?.clipboard.length;\n useUndoRedoShortcuts({\n undo: handleUndo,\n redo: handleRedo,\n canUndo,\n canRedo,\n });\n\n useEffect(() => {\n return () => {\n window.documentEditorDebugTools?.clear();\n };\n }, []);\n\n const navigate = useNavigate();\n const { showModal } = useModal();\n\n const [editorError, setEditorError] = useState<\n | {\n error: any;\n info: React.ErrorInfo;\n documentId?: string;\n // clear: () => void;\n }\n | undefined\n >(undefined);\n\n useEffect(() => {\n if (\n editorError &&\n editorError.documentId !== fileNodeDocument?.documentId\n ) {\n setEditorError(undefined);\n }\n }, [editorError, fileNodeDocument, document]);\n\n const handleEditorError = useCallback(\n (error: Error, info: React.ErrorInfo) => {\n setEditorError({\n error,\n documentId,\n info,\n });\n },\n [documentId],\n );\n\n if (fileNodeDocument?.status === 'ERROR') {\n return <EditorError message={'Error loading document'} />;\n }\n\n if (isLoadingDocument || isLoadingEditor) {\n const message = isLoadingDocument\n ? 'Loading document'\n : 'Loading editor';\n return <EditorLoader message={message} />;\n }\n\n if (!fileNodeDocument) {\n return null;\n }\n\n if (!documentModel) {\n return (\n <EditorError\n message={\n <div className=\"text-center leading-10\">\n <p>\n Unable to open the document because the document\n model \"{documentType}\" is not supported.\n </p>\n <p>\n Go to the{' '}\n <button\n type=\"button\"\n className=\"cursor-pointer underline\"\n onClick={() => {\n showModal('settingsModal', {\n onRefresh: () => navigate(0),\n });\n }}\n >\n package manager\n </button>{' '}\n to install this document model\n </p>\n </div>\n }\n />\n );\n }\n\n if (editor === null) {\n return (\n <EditorError\n message={\n <div className=\"text-center leading-10\">\n <p>\n Unable to open the document because no editor has\n been found\n </p>\n <p>\n Go to the{' '}\n <button\n type=\"button\"\n className=\"cursor-pointer underline\"\n onClick={() => {\n showModal('settingsModal', {\n onRefresh: () => navigate(0),\n });\n }}\n >\n package manager\n </button>{' '}\n an editor for the \"${documentType}\" document type\n </p>\n </div>\n }\n />\n );\n }\n\n const EditorComponent = editor.Component;\n const {\n disableExternalControls,\n documentToolbarEnabled,\n showSwitchboardLink,\n timelineEnabled,\n } = editor.config || {};\n\n const handleSwitchboardLinkClick =\n showSwitchboardLink !== false ? onOpenSwitchboardLink : undefined;\n return (\n <div className=\"relative h-full\" id=\"document-editor-context\">\n {documentToolbarEnabled &&\n disableExternalControls &&\n !revisionHistoryVisible && (\n <DocumentToolbar\n onClose={onClose}\n onExport={onExport}\n onShowRevisionHistory={showRevisionHistory}\n title={fileNodeDocument.name || document.header.name}\n onSwitchboardLinkClick={handleSwitchboardLinkClick}\n timelineButtonVisible={timelineEnabled}\n timelineItems={timelineItems.data}\n onTimelineItemClick={setSelectedTimelineItem}\n />\n )}\n {!disableExternalControls && (\n <div className=\"mb-4 flex justify-end gap-10\">\n <Button onClick={onExport}>Export</Button>\n <div className=\"flex gap-4\">\n <Button onClick={handleUndo} disabled={!canUndo}>\n Undo\n </Button>\n <Button onClick={handleRedo} disabled={!canRedo}>\n Redo\n </Button>\n </div>\n <div className=\"flex gap-4\">\n <Button onClick={onClose}>Close</Button>\n </div>\n </div>\n )}\n {revisionHistoryVisible ? (\n <RevisionHistory\n key={documentId}\n documentTitle={document.header.name}\n documentId={fileNodeDocument.documentId}\n globalOperations={document.operations.global}\n localOperations={document.operations.local}\n onClose={hideRevisionHistory}\n />\n ) : (\n <Suspense fallback={<EditorLoader />} name=\"EditorLoader\">\n <ErrorBoundary\n fallbackRender={FallbackEditorError}\n key={documentId}\n onError={handleEditorError}\n >\n {!editorError?.error && (\n <EditorComponent\n key={documentId}\n error={error}\n context={{\n ...context,\n getDocumentRevision: onGetDocumentRevision,\n readMode: !!selectedTimelineItem,\n selectedTimelineRevision:\n getRevisionFromDate(\n selectedTimelineItem?.startDate,\n selectedTimelineItem?.endDate,\n document.operations.global,\n ),\n }}\n document={document}\n documentNodeName={fileNodeDocument.name}\n dispatch={dispatch}\n onClose={onClose}\n onExport={onExport}\n canUndo={canUndo}\n canRedo={canRedo}\n undo={handleUndo}\n redo={handleRedo}\n onSwitchboardLinkClick={\n handleSwitchboardLinkClick\n }\n onShowRevisionHistory={showRevisionHistory}\n isAllowedToCreateDocuments={\n userPermissions?.isAllowedToCreateDocuments ??\n false\n }\n isAllowedToEditDocuments={\n userPermissions?.isAllowedToEditDocuments ??\n false\n }\n />\n )}\n </ErrorBoundary>\n </Suspense>\n )}\n </div>\n );\n};\n","import {\n useDocumentDriveById,\n useDocumentDriveServer,\n useGetDocument,\n} from '#hooks';\nimport { useFileNodeDocument, useGetDocumentModelModule } from '#store';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport { buildDocumentSubgraphUrl } from '@powerhousedao/reactor-browser/utils/switchboard';\nimport { type GetDocumentOptions } from 'document-drive';\nimport {\n type EditorContext,\n type Operation,\n type PHDocument,\n} from 'document-model';\nimport { useCallback, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useModal } from '../components/modal/index.js';\nimport { exportFile, openUrl } from '../utils/index.js';\nimport { validateDocument } from '../utils/validate-document.js';\nimport { DocumentEditor } from './editors.js';\n\nexport function DocumentEditorContainer() {\n const { t } = useTranslation();\n const { showModal } = useModal();\n const {\n selectedDocument,\n fileNodeDocument,\n setSelectedDocument,\n addOperationToSelectedDocument,\n } = useFileNodeDocument();\n const { renameNode } = useDocumentDriveServer();\n const {\n selectedNode,\n selectedDriveNode,\n selectedParentNode,\n setSelectedNode,\n } = useUiNodesContext();\n const { isRemoteDrive, remoteUrl } = useDocumentDriveById(\n selectedDriveNode?.id,\n );\n const getDocumentModelModule = useGetDocumentModelModule();\n\n const getDocument = useGetDocument();\n\n const handleAddOperationToSelectedDocument = useCallback(\n async (operation: Operation) => {\n if (!selectedDocument) {\n throw new Error('No document selected');\n }\n if (!addOperationToSelectedDocument) {\n throw new Error('No add operation function defined');\n }\n await addOperationToSelectedDocument(operation);\n },\n [addOperationToSelectedDocument, selectedDocument],\n );\n\n const onDocumentChangeHandler = useCallback(\n (documentId: string, document: PHDocument) => {\n if (documentId !== fileNodeDocument?.documentId) {\n return;\n }\n setSelectedDocument(document);\n\n if (\n !!selectedNode &&\n document.header.name !== '' &&\n selectedNode.name !== document.header.name\n ) {\n return renameNode(\n selectedNode.driveId,\n selectedNode.id,\n document.header.name,\n );\n }\n },\n [\n fileNodeDocument?.documentId,\n renameNode,\n selectedNode,\n setSelectedDocument,\n ],\n );\n\n const onClose = useCallback(() => {\n setSelectedNode(selectedParentNode);\n }, [selectedParentNode, setSelectedNode]);\n\n const exportDocument = useCallback(\n (document: PHDocument) => {\n const validationErrors = validateDocument(document);\n\n if (validationErrors.length) {\n showModal('confirmationModal', {\n title: t('modals.exportDocumentWithErrors.title'),\n body: (\n <div>\n <p>{t('modals.exportDocumentWithErrors.body')}</p>\n <ul className=\"mt-4 flex list-disc flex-col items-start px-4 text-xs\">\n {validationErrors.map((error, index) => (\n <li key={index}>{error.message}</li>\n ))}\n </ul>\n </div>\n ),\n cancelLabel: t('common.cancel'),\n continueLabel: t('common.export'),\n onCancel(closeModal) {\n closeModal();\n },\n onContinue(closeModal) {\n closeModal();\n return exportFile(document, getDocumentModelModule);\n },\n });\n } else {\n return exportFile(document, getDocumentModelModule);\n }\n },\n [getDocumentModelModule, showModal, t],\n );\n\n const onGetDocumentRevision: EditorContext['getDocumentRevision'] =\n useCallback(\n (options?: GetDocumentOptions) => {\n if (!selectedNode) {\n console.error('No selected node');\n return Promise.reject(new Error('No selected node'));\n }\n return getDocument(\n selectedNode.driveId,\n selectedNode.id,\n options,\n );\n },\n [getDocument, selectedNode],\n );\n\n const onExport = useCallback(() => {\n if (selectedDocument) {\n return exportDocument(selectedDocument);\n }\n }, [exportDocument, selectedDocument]);\n\n const onOpenSwitchboardLink = useMemo(() => {\n return isRemoteDrive\n ? async () => {\n if (!selectedDocument) {\n console.error('No selected document');\n return;\n }\n\n if (!remoteUrl) {\n console.error('No remote drive url found');\n return;\n }\n\n const documentModelModule = getDocumentModelModule(\n selectedDocument.header.documentType,\n );\n\n if (!documentModelModule) {\n console.error('No document model found');\n return;\n }\n\n const url = buildDocumentSubgraphUrl(\n remoteUrl,\n selectedDocument.header.id,\n documentModelModule.documentModel,\n );\n try {\n await openUrl(url);\n } catch (e) {\n console.error('Error opening switchboard link', e);\n }\n }\n : undefined;\n }, [isRemoteDrive, remoteUrl, selectedDocument, getDocumentModelModule]);\n\n if (!fileNodeDocument) return null;\n\n return (\n <div\n key={fileNodeDocument.documentId}\n className=\"flex-1 rounded-2xl bg-gray-50 p-4\"\n >\n <DocumentEditor\n fileNodeDocument={fileNodeDocument}\n document={selectedDocument}\n onChange={onDocumentChangeHandler}\n onClose={onClose}\n onExport={onExport}\n onGetDocumentRevision={onGetDocumentRevision}\n onAddOperation={handleAddOperationToSelectedDocument}\n onOpenSwitchboardLink={onOpenSwitchboardLink}\n />\n </div>\n );\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nexport function useDocumentsState(args) {\n const { reactor, driveId, documentIds, options } = args;\n const [statesByDocumentId, setStatesByDocumentId] = useState({});\n const isInitialized = useRef(false);\n const isSubscribed = useRef(false);\n useEffect(() => {\n async function initialize() {\n if (isInitialized.current)\n return;\n if (!reactor || !driveId)\n return;\n isInitialized.current = true;\n const ids = documentIds ?? (await reactor.getDocuments(driveId));\n const statesByDocumentId = {};\n for (const id of ids) {\n const document = await reactor.getDocument(driveId, id, options);\n statesByDocumentId[id] = {\n ...document.state,\n documentType: document.header.documentType,\n revision: document.header.revision,\n createdAtUtcIso: document.header.createdAtUtcIso,\n lastModifiedAtUtcIso: document.header.lastModifiedAtUtcIso,\n };\n }\n setStatesByDocumentId(statesByDocumentId);\n }\n void initialize();\n }, [reactor, driveId, options]);\n useEffect(() => {\n if (!reactor || !driveId)\n return;\n if (isSubscribed.current)\n return;\n isSubscribed.current = true;\n const unsubscribe = reactor.on(\"strandUpdate\", async (update) => {\n if (update.driveId !== driveId ||\n (documentIds && !documentIds.includes(update.documentId)))\n return;\n const updatedDocument = await reactor.getDocument(driveId, update.documentId, options);\n setStatesByDocumentId((prev) => {\n const newStatesByDocumentId = { ...prev };\n newStatesByDocumentId[update.documentId] = {\n ...updatedDocument.state,\n documentType: updatedDocument.header.documentType,\n revision: updatedDocument.header.revision,\n createdAtUtcIso: updatedDocument.header.createdAtUtcIso,\n lastModifiedAtUtcIso: updatedDocument.header.lastModifiedAtUtcIso,\n };\n return newStatesByDocumentId;\n });\n });\n return unsubscribe;\n }, [reactor, driveId, options]);\n return useMemo(() => statesByDocumentId, [statesByDocumentId]);\n}\nexport function makeDriveDocumentStatesHook(reactor) {\n const useDriveDocumentStates = useCallback((args) => {\n const { driveId, documentIds, options } = args;\n return useDocumentsState({\n reactor,\n driveId,\n documentIds,\n options,\n });\n }, [reactor]);\n return useDriveDocumentStates;\n}\nexport function makeDriveDocumentStateHook(reactor) {\n const useDriveDocumentState = useCallback((args) => {\n const { driveId, documentId } = args;\n return useDocumentState({\n reactor,\n driveId,\n documentId,\n });\n }, [reactor]);\n return useDriveDocumentState;\n}\nexport function useDocumentState(args) {\n const { reactor, driveId, documentId } = args;\n const state = useDocumentsState({\n reactor,\n driveId,\n documentIds: [documentId],\n });\n return useMemo(() => state[documentId], [state, documentId]);\n}\n//# sourceMappingURL=document-state.js.map","import { type GetDocumentOptions } from 'document-drive';\nimport { type PHDocument, type PHDocumentHeader } from 'document-model';\nimport { useEffect, useState } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer';\n\nconst DELETE_NODE_OPERATION_TYPE = 'DELETE_NODE';\n\ntype DeleteOperationInput = { id: string };\n\nexport type HookState = PHDocument['state'] &\n Pick<\n PHDocumentHeader,\n 'documentType' | 'revision' | 'createdAtUtcIso' | 'lastModifiedAtUtcIso'\n >;\n\nexport interface UseGetDriveDocumentsProps {\n driveId?: string;\n documentIds?: string[];\n options?: GetDocumentOptions;\n}\n\nexport function useGetDriveDocuments(props: UseGetDriveDocumentsProps) {\n const { driveId } = props;\n const [documents, setDocuments] = useState<Record<string, HookState>>({});\n\n const { getDocumentsIds, openFile, onOperationsAdded } =\n useDocumentDriveServer();\n\n const fetchDocuments = async (\n _driveId: string,\n _documentIds?: string[],\n _deletedNodes: string[] = [],\n ) => {\n let documentIds = _documentIds;\n\n if (!documentIds || documentIds.length === 0) {\n documentIds = await getDocumentsIds(_driveId);\n }\n\n if (!documentIds) {\n return;\n }\n\n const getDocumentsPromise = documentIds.map<\n Promise<[string, PHDocument]>\n >(async documentId => {\n const document = await openFile(_driveId, documentId);\n return [documentId, document];\n });\n\n const docs = await Promise.all(getDocumentsPromise);\n\n const newDocumentsState = docs.reduce<Record<string, HookState>>(\n (acc, [documentId, document]) => {\n acc[documentId] = {\n ...document.state,\n documentType: document.header.documentType,\n revision: document.header.revision,\n createdAtUtcIso: document.header.createdAtUtcIso,\n lastModifiedAtUtcIso: document.header.lastModifiedAtUtcIso,\n };\n return acc;\n },\n {},\n );\n\n setDocuments(prevState => ({\n ...prevState,\n ...newDocumentsState,\n }));\n\n if (_deletedNodes.length > 0) {\n setDocuments(prevState => {\n const newState = { ...prevState };\n _deletedNodes.forEach(nodeId => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete newState[nodeId];\n });\n return newState;\n });\n }\n };\n\n useEffect(() => {\n if (driveId) {\n fetchDocuments(driveId).catch(console.error);\n }\n }, [driveId]);\n\n useEffect(() => {\n const removeListener = onOperationsAdded(\n (driveId, documentId, operations) => {\n const deletedNodes: string[] = [];\n\n if (driveId === driveId && !documentId) {\n const deletedNodesIds = operations\n .filter(op => op.type === DELETE_NODE_OPERATION_TYPE)\n .map(op => (op.input as DeleteOperationInput).id);\n\n deletedNodes.push(...deletedNodesIds);\n }\n\n if (driveId === driveId) {\n const docId = documentId ? [documentId] : undefined;\n fetchDocuments(driveId, docId, deletedNodes).catch(\n console.error,\n );\n }\n },\n );\n\n return removeListener;\n }, [onOperationsAdded, driveId]);\n\n return [documents, fetchDocuments] as const;\n}\n","import connectConfig from '#connect-config';\nimport {\n useDocumentDriveById,\n useDocumentDriveServer,\n useDocumentEditor,\n useEditorProps,\n useGetDocument,\n useSyncStatus,\n} from '#hooks';\nimport {\n useDriveEditor,\n useFileNodeDocument,\n useFilteredDocumentModels,\n useGetDocumentModelModule,\n useGetEditor,\n useReactor,\n} from '#store';\nimport { useDocumentDispatch } from '#utils';\nimport { GenericDriveExplorer } from '@powerhousedao/common';\nimport { type DriveEditorContext } from '@powerhousedao/reactor-browser';\nimport { makeDriveDocumentStateHook } from '@powerhousedao/reactor-browser/hooks/document-state';\nimport { type IDriveContext } from '@powerhousedao/reactor-browser/hooks/useDriveContext';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport {\n driveDocumentModelModule,\n type GetDocumentOptions,\n} from 'document-drive';\nimport { type DocumentModelModule, type Operation } from 'document-model';\nimport { useCallback, useMemo } from 'react';\nimport { ErrorBoundary, type FallbackProps } from 'react-error-boundary';\nimport { useGetDriveDocuments } from '../hooks/useGetDriveDocuments.js';\nimport { useModal } from './modal/index.js';\n\nfunction DriveEditorError({ error }: FallbackProps) {\n return (\n <div className=\"mx-auto flex max-w-[80%] flex-1 flex-col items-center justify-center\">\n <h1 className=\"mb-2 text-xl font-semibold\">Error</h1>\n <i>{error instanceof Error ? error.message : error}</i>\n <pre>{JSON.stringify(error, null, 2)}</pre>\n </div>\n );\n}\n\nfunction useSelectedDocumentDrive() {\n const { selectedDriveNode } = useUiNodesContext();\n\n if (!selectedDriveNode) {\n throw new Error('No drive node selected');\n }\n\n const documentDrive = useDocumentDriveById(selectedDriveNode.id);\n\n if (!documentDrive.drive) {\n throw new Error(`Drive with id \"${selectedDriveNode.id}\" not found`);\n }\n\n return documentDrive.drive;\n}\n\nexport function DriveEditorContainer() {\n const {\n selectedDriveNode,\n setSelectedNode,\n selectedNode,\n selectedParentNode,\n } = useUiNodesContext();\n const { addOperationToSelectedDrive } = useFileNodeDocument();\n const documentDrive = useSelectedDocumentDrive();\n const [document, _dispatch, error] = useDocumentDispatch(\n driveDocumentModelModule.reducer,\n documentDrive,\n );\n const reactor = useReactor();\n\n const handleAddOperationToSelectedDrive = useCallback(\n async (operation: Operation) => {\n await addOperationToSelectedDrive(operation);\n },\n [addOperationToSelectedDrive],\n );\n\n const editorProps = useEditorProps(\n document,\n selectedDriveNode,\n _dispatch,\n handleAddOperationToSelectedDrive,\n );\n\n const { showModal } = useModal();\n const showCreateDocumentModal = useCallback(\n (documentModel: DocumentModelModule) => {\n if (!selectedDriveNode) {\n throw new Error('No drive node selected');\n }\n\n showModal('createDocument', {\n documentModel,\n selectedParentNode,\n setSelectedNode,\n });\n return Promise.resolve({ name: 'New Document' }); // TODO fix this\n },\n [selectedDriveNode, selectedParentNode, setSelectedNode, showModal],\n );\n\n const { addFile, addDocument } = useDocumentDriveServer();\n const documentModels = useFilteredDocumentModels();\n const useDriveDocumentState = makeDriveDocumentStateHook(reactor);\n const getDocument = useGetDocument();\n const getDocumentModelModule = useGetDocumentModelModule();\n const getEditor = useGetEditor();\n\n const onGetDocumentRevision: DriveEditorContext['getDocumentRevision'] =\n useCallback(\n (documentId: string, options?: GetDocumentOptions) => {\n if (!selectedNode) {\n console.error('No selected node');\n return Promise.reject(new Error('No selected node'));\n }\n return getDocument(selectedNode.driveId, documentId, options);\n },\n [getDocument, selectedNode],\n );\n\n const driveContext: IDriveContext = useMemo(\n () => ({\n showSearchBar: false,\n isAllowedToCreateDocuments: editorProps.isAllowedToCreateDocuments,\n documentModels: documentModels ?? [],\n selectedDriveNode,\n selectedNode,\n selectNode: setSelectedNode,\n addFile,\n showCreateDocumentModal,\n useSyncStatus,\n useDocumentEditorProps: useDocumentEditor,\n useDriveDocumentStates: useGetDriveDocuments,\n useDriveDocumentState,\n addDocument,\n reactor,\n }),\n [\n reactor,\n editorProps.isAllowedToCreateDocuments,\n documentModels,\n selectedNode,\n setSelectedNode,\n addFile,\n addDocument,\n showCreateDocumentModal,\n ],\n );\n\n const driveEditor = useDriveEditor(document?.header.meta?.preferredEditor);\n\n if (!document) {\n return null;\n }\n\n const DriveEditorComponent =\n driveEditor?.Component ?? GenericDriveExplorer.Component;\n\n return (\n <ErrorBoundary\n fallbackRender={DriveEditorError}\n key={selectedDriveNode?.id}\n >\n <DriveEditorComponent\n key={selectedDriveNode?.id}\n {...editorProps}\n context={{\n ...editorProps.context,\n ...driveContext,\n analyticsDatabaseName: connectConfig.analytics.databaseName,\n getDocumentRevision: onGetDocumentRevision,\n getDocumentModelModule,\n getEditor,\n }}\n onSwitchboardLinkClick={undefined} // TODO\n document={document}\n error={error}\n />\n </ErrorBoundary>\n );\n}\n","import { type DocumentDriveState } from 'document-drive';\nimport { useDocumentDriveServer } from './useDocumentDriveServer.js';\n\ntype ExtendedDocumentDriveState = DocumentDriveState & { remoteUrl?: string };\n\nexport function useDocumentDriveById(driveId: string | undefined) {\n const { documentDrives } = useDocumentDriveServer();\n if (!driveId)\n return {\n drive: null,\n remoteUrl: null,\n isRemoteDrive: false,\n };\n\n const drive = documentDrives.find(drive => drive.header.id === driveId);\n\n const pullResponder = drive?.state.local.triggers.find(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n trigger => trigger.type === 'PullResponder',\n );\n\n const { remoteUrl } = (drive?.state.global ||\n {}) as ExtendedDocumentDriveState;\n\n const isRemoteDrive = !!remoteUrl || !!pullResponder;\n\n return {\n drive,\n remoteUrl: remoteUrl || pullResponder?.data?.url,\n isRemoteDrive,\n };\n}\n","import { useUnwrappedReactor } from '#store';\nimport {\n useDocument,\n useDocumentEditorProps,\n type User,\n} from '@powerhousedao/reactor-browser';\nimport { type DocumentModelModule, type PHDocument } from 'document-model';\n\nimport { useConnectCrypto, useConnectDid } from '#hooks';\n\nexport interface DocumentEditorProps {\n driveId: string;\n documentId: string;\n documentType: string;\n documentModelModule: DocumentModelModule<PHDocument>;\n user?: User;\n}\n\nexport function useDocumentEditor(props: DocumentEditorProps) {\n const { driveId, documentId, documentType, documentModelModule, user } =\n props;\n\n const reactor = useUnwrappedReactor();\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n\n const doc = useDocument(reactor, { documentId, driveId, documentType });\n\n const documentEditorProps = useDocumentEditorProps(reactor, {\n nodeId: documentId,\n driveId: driveId,\n document: doc,\n documentModelModule,\n connectDid,\n sign,\n user,\n });\n\n return documentEditorProps;\n}\n","import { useModal } from '#components';\nimport {\n themeAtom,\n useFileNodeDocument,\n useGetDocumentModelModule,\n useUser,\n} from '#store';\nimport {\n addActionContext,\n type DocumentDispatch,\n type DocumentDispatchCallback,\n exportFile,\n signOperation,\n validateDocument,\n} from '#utils';\nimport {\n type UiDriveNode,\n type UiFileNode,\n} from '@powerhousedao/design-system';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser';\nimport { logger } from 'document-drive';\nimport {\n type Action,\n type ActionErrorCallback,\n type EditorContext,\n type Operation,\n type PHDocument,\n redo,\n undo,\n} from 'document-model';\nimport { useAtomValue } from 'jotai';\nimport { useCallback, useMemo, useState } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useConnectCrypto, useConnectDid } from './useConnectCrypto.js';\nimport { useUserPermissions } from './useUserPermissions.js';\n\nexport interface EditorProps {\n context: EditorContext;\n canUndo: boolean;\n canRedo: boolean;\n undo: () => void;\n redo: () => void;\n onClose: () => void;\n onExport: () => void;\n onShowRevisionHistory: () => void;\n isAllowedToCreateDocuments: boolean;\n isAllowedToEditDocuments: boolean;\n}\n\nexport function useEditorDispatch(\n node: UiDriveNode | UiFileNode | null,\n documentDispatch: DocumentDispatch<PHDocument>,\n onAddOperation: (operation: Operation) => Promise<void>,\n) {\n const user = useUser() || undefined;\n const connectDid = useConnectDid();\n const { sign } = useConnectCrypto();\n\n const documentType =\n node?.kind === 'DRIVE'\n ? 'powerhouse/document-drive'\n : node?.documentType;\n const getDocumentModelModule = useGetDocumentModelModule();\n const documentModelModule = useMemo(\n () => (documentType ? getDocumentModelModule(documentType) : undefined),\n [documentType, getDocumentModelModule],\n );\n\n const dispatch = useCallback(\n (action: Action, onErrorCallback?: ActionErrorCallback) => {\n const callback: DocumentDispatchCallback<PHDocument> = (\n operation,\n state,\n ) => {\n if (!node?.id) return;\n\n const { prevState } = state;\n\n signOperation(\n operation,\n sign,\n node.id,\n prevState,\n documentModelModule?.reducer,\n user,\n )\n .then(op => {\n window.documentEditorDebugTools?.pushOperation(\n operation,\n );\n return onAddOperation(op);\n })\n .catch(logger.error);\n };\n\n documentDispatch(\n addActionContext(action, connectDid, user),\n callback,\n onErrorCallback,\n );\n },\n [\n documentDispatch,\n connectDid,\n documentModelModule?.reducer,\n onAddOperation,\n node,\n sign,\n user,\n ],\n );\n\n return dispatch;\n}\n\nexport function useEditorProps(\n document: PHDocument | undefined,\n node: UiDriveNode | UiFileNode | null,\n documentDispatch: DocumentDispatch<PHDocument>,\n onAddOperation: (operation: Operation) => Promise<void>,\n) {\n const { t } = useTranslation();\n const { showModal } = useModal();\n const theme = useAtomValue(themeAtom);\n const user = useUser() || undefined;\n const userPermissions = useUserPermissions();\n\n const context = useMemo(() => ({ theme, user }), [theme, user]);\n const { selectedDocument } = useFileNodeDocument();\n const { selectedParentNode, setSelectedNode } = useUiNodesContext();\n const getDocumentModelModule = useGetDocumentModelModule();\n\n const canUndo =\n !!document &&\n (document.header.revision.global > 0 ||\n document.header.revision.local > 0);\n const canRedo = !!document?.clipboard.length;\n\n const dispatch = useEditorDispatch(node, documentDispatch, onAddOperation);\n\n const handleUndo = useCallback(() => {\n dispatch(undo());\n }, [dispatch]);\n\n const handleRedo = useCallback(() => {\n dispatch(redo());\n }, [dispatch]);\n\n const onClose = useCallback(() => {\n setSelectedNode(selectedParentNode);\n }, [selectedParentNode, setSelectedNode]);\n\n const exportDocument = useCallback(\n (document: PHDocument) => {\n const validationErrors = validateDocument(document);\n\n if (validationErrors.length) {\n showModal('confirmationModal', {\n title: t('modals.exportDocumentWithErrors.title'),\n body: (\n <div>\n <p>{t('modals.exportDocumentWithErrors.body')}</p>\n <ul className=\"mt-4 flex list-disc flex-col items-start px-4 text-xs\">\n {validationErrors.map((error, index) => (\n <li key={index}>{error.message}</li>\n ))}\n </ul>\n </div>\n ),\n cancelLabel: t('common.cancel'),\n continueLabel: t('common.export'),\n onCancel(closeModal) {\n closeModal();\n },\n onContinue(closeModal) {\n closeModal();\n return exportFile(document, getDocumentModelModule);\n },\n });\n } else {\n return exportFile(document, getDocumentModelModule);\n }\n },\n [getDocumentModelModule, showModal, t],\n );\n\n const onExport = useCallback(() => {\n if (selectedDocument) {\n return exportDocument(selectedDocument);\n }\n }, [exportDocument, selectedDocument]);\n\n const [revisionHistoryVisible, setRevisionHistoryVisible] = useState(false);\n const showRevisionHistory = useCallback(\n () => setRevisionHistoryVisible(true),\n [],\n );\n\n return {\n dispatch,\n revisionHistoryVisible,\n context,\n canUndo,\n canRedo,\n undo: handleUndo,\n redo: handleRedo,\n onClose,\n onExport,\n onShowRevisionHistory: showRevisionHistory,\n isAllowedToCreateDocuments:\n userPermissions?.isAllowedToCreateDocuments ?? false,\n isAllowedToEditDocuments:\n userPermissions?.isAllowedToEditDocuments ?? false,\n };\n}\n","import { type GetDocumentOptions } from 'document-drive';\nimport { type PHDocumentHeader, type PHDocument } from 'document-model';\nimport { useCallback } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer';\n\nexport type HookState = PHDocument['state'] &\n Pick<\n PHDocumentHeader,\n 'documentType' | 'revision' | 'createdAtUtcIso' | 'lastModifiedAtUtcIso'\n >;\n\nexport interface UseGetDriveDocumentsProps {\n driveId?: string;\n documentIds?: string[];\n options?: GetDocumentOptions;\n}\n\nexport function useGetDocument() {\n const { openFile } = useDocumentDriveServer();\n\n const getDocument = useCallback(\n async (\n driveId: string,\n documentId: string,\n options?: GetDocumentOptions,\n ) => {\n const document = await openFile(driveId, documentId, options);\n return document;\n },\n [openFile],\n );\n\n return getDocument;\n}\n","import { type SharingType } from '@powerhousedao/design-system';\nimport { type SyncStatus } from 'document-drive';\nimport { useSyncExternalStore } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer.js';\n\nexport function useSyncStatus(\n driveId: string,\n documentId?: string,\n): SyncStatus | undefined {\n const { getSyncStatusSync, onSyncStatus, documentDrives } =\n useDocumentDriveServer();\n\n const syncStatus = useSyncExternalStore(\n onStoreChange => {\n const unsub = onSyncStatus(onStoreChange);\n return unsub;\n },\n () => {\n const drive = documentDrives.find(\n _drive => _drive.header.id === driveId,\n );\n\n if (!drive) return;\n const isReadDrive = 'readContext' in drive;\n const _sharingType = !isReadDrive\n ? drive.state.local.sharingType?.toUpperCase()\n : 'PUBLIC';\n\n const sharingType =\n _sharingType === 'PRIVATE' ? 'LOCAL' : _sharingType;\n\n if (!documentId) {\n const status = getSyncStatusSync(\n driveId,\n sharingType as SharingType,\n );\n\n return status;\n }\n\n const document = drive.state.global.nodes.find(\n node => node.id === documentId,\n );\n\n if (!document) return;\n if (!('synchronizationUnits' in document)) return;\n\n const status = getSyncStatusSync(\n document.synchronizationUnits[0].syncId,\n sharingType as SharingType,\n );\n\n return status;\n },\n );\n\n return syncStatus;\n}\n","import { useContext, createContext, useState, useCallback, useRef, useLayoutEffect, useEffect } from 'react';\nimport { jsx } from 'react/jsx-runtime';\n\nfunction _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\n\nvar reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl'];\nvar mappedKeys = {\n esc: 'escape',\n \"return\": 'enter',\n '.': 'period',\n ',': 'comma',\n '-': 'slash',\n ' ': 'space',\n '`': 'backquote',\n '#': 'backslash',\n '+': 'bracketright',\n ShiftLeft: 'shift',\n ShiftRight: 'shift',\n AltLeft: 'alt',\n AltRight: 'alt',\n MetaLeft: 'meta',\n MetaRight: 'meta',\n OSLeft: 'meta',\n OSRight: 'meta',\n ControlLeft: 'ctrl',\n ControlRight: 'ctrl'\n};\nfunction mapKey(key) {\n return (key && mappedKeys[key] || key || '').trim().toLowerCase().replace(/key|digit|numpad|arrow/, '');\n}\nfunction isHotkeyModifier(key) {\n return reservedModifierKeywords.includes(key);\n}\nfunction parseKeysHookInput(keys, splitKey) {\n if (splitKey === void 0) {\n splitKey = ',';\n }\n return keys.split(splitKey);\n}\nfunction parseHotkey(hotkey, combinationKey, description) {\n if (combinationKey === void 0) {\n combinationKey = '+';\n }\n var keys = hotkey.toLocaleLowerCase().split(combinationKey).map(function (k) {\n return mapKey(k);\n });\n var modifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl') || keys.includes('control'),\n shift: keys.includes('shift'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod')\n };\n var singleCharKeys = keys.filter(function (k) {\n return !reservedModifierKeywords.includes(k);\n });\n return _extends({}, modifiers, {\n keys: singleCharKeys,\n description: description,\n hotkey: hotkey\n });\n}\n\n(function () {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', function (e) {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);\n });\n document.addEventListener('keyup', function (e) {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);\n });\n }\n if (typeof window !== 'undefined') {\n window.addEventListener('blur', function () {\n currentlyPressedKeys.clear();\n });\n }\n})();\nvar currentlyPressedKeys = /*#__PURE__*/new Set();\n// https://github.com/microsoft/TypeScript/issues/17002\nfunction isReadonlyArray(value) {\n return Array.isArray(value);\n}\nfunction isHotkeyPressed(key, splitKey) {\n if (splitKey === void 0) {\n splitKey = ',';\n }\n var hotkeyArray = isReadonlyArray(key) ? key : key.split(splitKey);\n return hotkeyArray.every(function (hotkey) {\n return currentlyPressedKeys.has(hotkey.trim().toLowerCase());\n });\n}\nfunction pushToCurrentlyPressedKeys(key) {\n var hotkeyArray = Array.isArray(key) ? key : [key];\n /*\r\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\r\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\r\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\r\n */\n if (currentlyPressedKeys.has('meta')) {\n currentlyPressedKeys.forEach(function (key) {\n return !isHotkeyModifier(key) && currentlyPressedKeys[\"delete\"](key.toLowerCase());\n });\n }\n hotkeyArray.forEach(function (hotkey) {\n return currentlyPressedKeys.add(hotkey.toLowerCase());\n });\n}\nfunction removeFromCurrentlyPressedKeys(key) {\n var hotkeyArray = Array.isArray(key) ? key : [key];\n /*\r\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\r\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\r\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\r\n */\n if (key === 'meta') {\n currentlyPressedKeys.clear();\n } else {\n hotkeyArray.forEach(function (hotkey) {\n return currentlyPressedKeys[\"delete\"](hotkey.toLowerCase());\n });\n }\n}\n\nfunction maybePreventDefault(e, hotkey, preventDefault) {\n if (typeof preventDefault === 'function' && preventDefault(e, hotkey) || preventDefault === true) {\n e.preventDefault();\n }\n}\nfunction isHotkeyEnabled(e, hotkey, enabled) {\n if (typeof enabled === 'function') {\n return enabled(e, hotkey);\n }\n return enabled === true || enabled === undefined;\n}\nfunction isKeyboardEventTriggeredByInput(ev) {\n return isHotkeyEnabledOnTag(ev, ['input', 'textarea', 'select']);\n}\nfunction isHotkeyEnabledOnTag(event, enabledOnTags) {\n if (enabledOnTags === void 0) {\n enabledOnTags = false;\n }\n var target = event.target,\n composed = event.composed;\n var targetTagName = null;\n if (isCustomElement(target) && composed) {\n targetTagName = event.composedPath()[0] && event.composedPath()[0].tagName;\n } else {\n targetTagName = target && target.tagName;\n }\n if (isReadonlyArray(enabledOnTags)) {\n return Boolean(targetTagName && enabledOnTags && enabledOnTags.some(function (tag) {\n var _targetTagName;\n return tag.toLowerCase() === ((_targetTagName = targetTagName) == null ? void 0 : _targetTagName.toLowerCase());\n }));\n }\n return Boolean(targetTagName && enabledOnTags && enabledOnTags);\n}\nfunction isCustomElement(element) {\n // We just do a basic check w/o any complex RegEx or validation against the list of legacy names containing a hyphen,\n // as none of them is likely to be an event target, and it won't hurt anyway if we miss.\n // see: https://html.spec.whatwg.org/multipage/custom-elements.html#prod-potentialcustomelementname\n return !!element.tagName && !element.tagName.startsWith(\"-\") && element.tagName.includes(\"-\");\n}\nfunction isScopeActive(activeScopes, scopes) {\n if (activeScopes.length === 0 && scopes) {\n console.warn('A hotkey has the \"scopes\" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>');\n return true;\n }\n if (!scopes) {\n return true;\n }\n return activeScopes.some(function (scope) {\n return scopes.includes(scope);\n }) || activeScopes.includes('*');\n}\nvar isHotkeyMatchingKeyboardEvent = function isHotkeyMatchingKeyboardEvent(e, hotkey, ignoreModifiers) {\n if (ignoreModifiers === void 0) {\n ignoreModifiers = false;\n }\n var alt = hotkey.alt,\n meta = hotkey.meta,\n mod = hotkey.mod,\n shift = hotkey.shift,\n ctrl = hotkey.ctrl,\n keys = hotkey.keys;\n var pressedKeyUppercase = e.key,\n code = e.code,\n ctrlKey = e.ctrlKey,\n metaKey = e.metaKey,\n shiftKey = e.shiftKey,\n altKey = e.altKey;\n var keyCode = mapKey(code);\n var pressedKey = pressedKeyUppercase.toLowerCase();\n if (!(keys != null && keys.includes(keyCode)) && !(keys != null && keys.includes(pressedKey)) && !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(keyCode)) {\n return false;\n }\n if (!ignoreModifiers) {\n // We check the pressed keys for compatibility with the keyup event. In keyup events the modifier flags are not set.\n if (alt === !altKey && pressedKey !== 'alt') {\n return false;\n }\n if (shift === !shiftKey && pressedKey !== 'shift') {\n return false;\n }\n // Mod is a special key name that is checking for meta on macOS and ctrl on other platforms\n if (mod) {\n if (!metaKey && !ctrlKey) {\n return false;\n }\n } else {\n if (meta === !metaKey && pressedKey !== 'meta' && pressedKey !== 'os') {\n return false;\n }\n if (ctrl === !ctrlKey && pressedKey !== 'ctrl' && pressedKey !== 'control') {\n return false;\n }\n }\n }\n // All modifiers are correct, now check the key\n // If the key is set, we check for the key\n if (keys && keys.length === 1 && (keys.includes(pressedKey) || keys.includes(keyCode))) {\n return true;\n } else if (keys) {\n // Check if all keys are present in pressedDownKeys set\n return isHotkeyPressed(keys);\n } else if (!keys) {\n // If the key is not set, we only listen for modifiers, that check went alright, so we return true\n return true;\n }\n // There is nothing that matches.\n return false;\n};\n\nvar BoundHotkeysProxyProvider = /*#__PURE__*/createContext(undefined);\nvar useBoundHotkeysProxy = function useBoundHotkeysProxy() {\n return useContext(BoundHotkeysProxyProvider);\n};\nfunction BoundHotkeysProxyProviderProvider(_ref) {\n var addHotkey = _ref.addHotkey,\n removeHotkey = _ref.removeHotkey,\n children = _ref.children;\n return /*#__PURE__*/jsx(BoundHotkeysProxyProvider.Provider, {\n value: {\n addHotkey: addHotkey,\n removeHotkey: removeHotkey\n },\n children: children\n });\n}\n\nfunction deepEqual(x, y) {\n //@ts-ignore\n return x && y && typeof x === 'object' && typeof y === 'object' ? Object.keys(x).length === Object.keys(y).length &&\n //@ts-ignore\n Object.keys(x).reduce(function (isEqual, key) {\n return isEqual && deepEqual(x[key], y[key]);\n }, true) : x === y;\n}\n\nvar HotkeysContext = /*#__PURE__*/createContext({\n hotkeys: [],\n enabledScopes: [],\n toggleScope: function toggleScope() {},\n enableScope: function enableScope() {},\n disableScope: function disableScope() {}\n});\nvar useHotkeysContext = function useHotkeysContext() {\n return useContext(HotkeysContext);\n};\nvar HotkeysProvider = function HotkeysProvider(_ref) {\n var _ref$initiallyActiveS = _ref.initiallyActiveScopes,\n initiallyActiveScopes = _ref$initiallyActiveS === void 0 ? ['*'] : _ref$initiallyActiveS,\n children = _ref.children;\n var _useState = useState((initiallyActiveScopes == null ? void 0 : initiallyActiveScopes.length) > 0 ? initiallyActiveScopes : ['*']),\n internalActiveScopes = _useState[0],\n setInternalActiveScopes = _useState[1];\n var _useState2 = useState([]),\n boundHotkeys = _useState2[0],\n setBoundHotkeys = _useState2[1];\n var enableScope = useCallback(function (scope) {\n setInternalActiveScopes(function (prev) {\n if (prev.includes('*')) {\n return [scope];\n }\n return Array.from(new Set([].concat(prev, [scope])));\n });\n }, []);\n var disableScope = useCallback(function (scope) {\n setInternalActiveScopes(function (prev) {\n if (prev.filter(function (s) {\n return s !== scope;\n }).length === 0) {\n return ['*'];\n } else {\n return prev.filter(function (s) {\n return s !== scope;\n });\n }\n });\n }, []);\n var toggleScope = useCallback(function (scope) {\n setInternalActiveScopes(function (prev) {\n if (prev.includes(scope)) {\n if (prev.filter(function (s) {\n return s !== scope;\n }).length === 0) {\n return ['*'];\n } else {\n return prev.filter(function (s) {\n return s !== scope;\n });\n }\n } else {\n if (prev.includes('*')) {\n return [scope];\n }\n return Array.from(new Set([].concat(prev, [scope])));\n }\n });\n }, []);\n var addBoundHotkey = useCallback(function (hotkey) {\n setBoundHotkeys(function (prev) {\n return [].concat(prev, [hotkey]);\n });\n }, []);\n var removeBoundHotkey = useCallback(function (hotkey) {\n setBoundHotkeys(function (prev) {\n return prev.filter(function (h) {\n return !deepEqual(h, hotkey);\n });\n });\n }, []);\n return /*#__PURE__*/jsx(HotkeysContext.Provider, {\n value: {\n enabledScopes: internalActiveScopes,\n hotkeys: boundHotkeys,\n enableScope: enableScope,\n disableScope: disableScope,\n toggleScope: toggleScope\n },\n children: /*#__PURE__*/jsx(BoundHotkeysProxyProviderProvider, {\n addHotkey: addBoundHotkey,\n removeHotkey: removeBoundHotkey,\n children: children\n })\n });\n};\n\nfunction useDeepEqualMemo(value) {\n var ref = useRef(undefined);\n if (!deepEqual(ref.current, value)) {\n ref.current = value;\n }\n return ref.current;\n}\n\nvar stopPropagation = function stopPropagation(e) {\n e.stopPropagation();\n e.preventDefault();\n e.stopImmediatePropagation();\n};\nvar useSafeLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\nfunction useHotkeys(keys, callback, options, dependencies) {\n var _useState = useState(null),\n ref = _useState[0],\n setRef = _useState[1];\n var hasTriggeredRef = useRef(false);\n var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : undefined;\n var _keys = isReadonlyArray(keys) ? keys.join(_options == null ? void 0 : _options.splitKey) : keys;\n var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined;\n var memoisedCB = useCallback(callback, _deps != null ? _deps : []);\n var cbRef = useRef(memoisedCB);\n if (_deps) {\n cbRef.current = memoisedCB;\n } else {\n cbRef.current = callback;\n }\n var memoisedOptions = useDeepEqualMemo(_options);\n var _useHotkeysContext = useHotkeysContext(),\n enabledScopes = _useHotkeysContext.enabledScopes;\n var proxy = useBoundHotkeysProxy();\n useSafeLayoutEffect(function () {\n if ((memoisedOptions == null ? void 0 : memoisedOptions.enabled) === false || !isScopeActive(enabledScopes, memoisedOptions == null ? void 0 : memoisedOptions.scopes)) {\n return;\n }\n var listener = function listener(e, isKeyUp) {\n var _e$target;\n if (isKeyUp === void 0) {\n isKeyUp = false;\n }\n if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions == null ? void 0 : memoisedOptions.enableOnFormTags)) {\n return;\n }\n // TODO: SINCE THE EVENT IS NOW ATTACHED TO THE REF, THE ACTIVE ELEMENT CAN NEVER BE INSIDE THE REF. THE HOTKEY ONLY TRIGGERS IF THE\n // REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.\n if (ref !== null) {\n var rootNode = ref.getRootNode();\n if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement !== ref && !ref.contains(rootNode.activeElement)) {\n stopPropagation(e);\n return;\n }\n }\n if ((_e$target = e.target) != null && _e$target.isContentEditable && !(memoisedOptions != null && memoisedOptions.enableOnContentEditable)) {\n return;\n }\n parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {\n var _hotkey$keys;\n var hotkey = parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey);\n if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.ignoreModifiers) || (_hotkey$keys = hotkey.keys) != null && _hotkey$keys.includes('*')) {\n if (memoisedOptions != null && memoisedOptions.ignoreEventWhen != null && memoisedOptions.ignoreEventWhen(e)) {\n return;\n }\n if (isKeyUp && hasTriggeredRef.current) {\n return;\n }\n maybePreventDefault(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.preventDefault);\n if (!isHotkeyEnabled(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.enabled)) {\n stopPropagation(e);\n return;\n }\n // Execute the user callback for that hotkey\n cbRef.current(e, hotkey);\n if (!isKeyUp) {\n hasTriggeredRef.current = true;\n }\n }\n });\n };\n var handleKeyDown = function handleKeyDown(event) {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n pushToCurrentlyPressedKeys(mapKey(event.code));\n if ((memoisedOptions == null ? void 0 : memoisedOptions.keydown) === undefined && (memoisedOptions == null ? void 0 : memoisedOptions.keyup) !== true || memoisedOptions != null && memoisedOptions.keydown) {\n listener(event);\n }\n };\n var handleKeyUp = function handleKeyUp(event) {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n removeFromCurrentlyPressedKeys(mapKey(event.code));\n hasTriggeredRef.current = false;\n if (memoisedOptions != null && memoisedOptions.keyup) {\n listener(event, true);\n }\n };\n var domNode = ref || (_options == null ? void 0 : _options.document) || document;\n // @ts-ignore\n domNode.addEventListener('keyup', handleKeyUp, _options == null ? void 0 : _options.eventListenerOptions);\n // @ts-ignore\n domNode.addEventListener('keydown', handleKeyDown, _options == null ? void 0 : _options.eventListenerOptions);\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {\n return proxy.addHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));\n });\n }\n return function () {\n // @ts-ignore\n domNode.removeEventListener('keyup', handleKeyUp, _options == null ? void 0 : _options.eventListenerOptions);\n // @ts-ignore\n domNode.removeEventListener('keydown', handleKeyDown, _options == null ? void 0 : _options.eventListenerOptions);\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {\n return proxy.removeHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));\n });\n }\n };\n }, [ref, _keys, memoisedOptions, enabledScopes]);\n return setRef;\n}\n\nfunction useRecordHotkeys() {\n var _useState = useState(new Set()),\n keys = _useState[0],\n setKeys = _useState[1];\n var _useState2 = useState(false),\n isRecording = _useState2[0],\n setIsRecording = _useState2[1];\n var handler = useCallback(function (event) {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n setKeys(function (prev) {\n var newKeys = new Set(prev);\n newKeys.add(mapKey(event.code));\n return newKeys;\n });\n }, []);\n var stop = useCallback(function () {\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handler);\n setIsRecording(false);\n }\n }, [handler]);\n var start = useCallback(function () {\n setKeys(new Set());\n if (typeof document !== 'undefined') {\n stop();\n document.addEventListener('keydown', handler);\n setIsRecording(true);\n }\n }, [handler, stop]);\n var resetKeys = useCallback(function () {\n setKeys(new Set());\n }, []);\n return [keys, {\n start: start,\n stop: stop,\n resetKeys: resetKeys,\n isRecording: isRecording\n }];\n}\n\nexport { HotkeysProvider, isHotkeyPressed, useHotkeys, useHotkeysContext, useRecordHotkeys };\n//# sourceMappingURL=react-hotkeys-hook.esm.js.map\n","import { useHotkeys } from 'react-hotkeys-hook';\n\nexport interface UseUndoRedoShortcutsProps {\n undo: () => void;\n redo: () => void;\n canUndo: boolean;\n canRedo: boolean;\n}\n\nexport const useUndoRedoShortcuts = (props: UseUndoRedoShortcutsProps) => {\n const { undo, redo, canRedo, canUndo } = props;\n const { isMac } = window.electronAPI?.platformInfo || {};\n\n let undoShortcut = 'ctrl+z';\n let redoShortcut = 'ctrl+y';\n\n if (isMac) {\n undoShortcut = 'mod+z';\n redoShortcut = 'mod+shift+z';\n }\n\n // set handler for undo\n useHotkeys(\n undoShortcut,\n event => {\n event.preventDefault();\n if (canUndo) {\n undo();\n }\n },\n {},\n [canUndo, undo],\n );\n\n // set handler for redo\n useHotkeys(\n redoShortcut,\n event => {\n event.preventDefault();\n if (canRedo) {\n redo();\n }\n },\n {},\n [canRedo, redo],\n );\n};\n","import { useDocumentDrives, useDocumentDriveServer } from '#hooks';\nimport { useFileNodeDocument } from '#store';\n/* import {\n useReactor,\n useDocuments,\n useDrives,\n useSelectedDocument,\n useSelectedDrive,\n useSelectedFolder,\n} from '@powerhousedao/common'; */\nimport { FILE } from '@powerhousedao/design-system';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser';\nimport { useEffect } from 'react';\nimport { useNavigate, useParams } from 'react-router-dom';\nimport { DocumentEditorContainer } from '../components/document-editor-container.js';\nimport { DriveEditorContainer } from '../components/drive-editor-container.js';\nimport { toast } from '../services/toast.js';\n\nexport default function Content() {\n const navigate = useNavigate();\n const { driveId } = useParams();\n const [documentDrives, , , status] = useDocumentDrives();\n const { selectedDriveNode, selectedNode } = useUiNodesContext();\n const { addFile } = useDocumentDriveServer();\n const { fileNodeDocument } = useFileNodeDocument();\n /* const loadableReactor = useReactor();\n const loadableDrives = useDrives();\n const loadableDocuments = useDocuments();\n const loadableSelectedDrive = useSelectedDrive();\n const loadableSelectedFolder = useSelectedFolder();\n const loadableSelectedDocument = useSelectedDocument();\n\n console.log('in content', {\n loadableReactor,\n loadableDrives,\n loadableDocuments,\n loadableSelectedDrive,\n loadableSelectedFolder,\n loadableSelectedDocument,\n }); */\n\n useEffect(() => {\n return window.electronAPI?.handleFileOpen(async file => {\n if (!selectedDriveNode || selectedNode?.kind !== FILE) {\n return;\n }\n\n await addFile(\n file.content,\n selectedDriveNode.id,\n file.name,\n selectedNode.parentFolder,\n );\n });\n }, [selectedDriveNode, selectedNode, addFile]);\n\n // if drives are loaded and route driveId is not found\n // then redirects to homepage\n useEffect(() => {\n if (\n (status === 'LOADED' || status === 'ERROR') &&\n !documentDrives.find(\n d =>\n d.header.id === driveId ||\n d.header.slug === driveId ||\n d.state.global.name === driveId,\n )\n ) {\n toast(<p>Drive {driveId} not found</p>, { type: 'warning' });\n navigate('/');\n }\n }, [status, driveId, documentDrives]);\n\n return (\n <div className=\"flex h-full flex-col overflow-auto\" id=\"content-view\">\n {fileNodeDocument ? (\n <DocumentEditorContainer key={fileNodeDocument.documentId} />\n ) : selectedDriveNode ? (\n <DriveEditorContainer key={selectedDriveNode.id} />\n ) : null}\n </div>\n );\n}\n"],"file":"assets/content.Bm5SXqTG.js"}
|