@powerhousedao/connect 4.1.0-dev.12 → 4.1.0-dev.120
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/.env → .env} +5 -7
- package/README.md +3 -4
- package/assets/icon.icns +0 -0
- package/assets/icon.ico +0 -0
- package/assets/icon.png +0 -0
- package/assets/icons/Atlas-Logomark.svg +24 -0
- package/assets/icons/BBP-logo-hover-dark.svg +14 -0
- package/assets/icons/BBP-logo-hover-light.svg +14 -0
- package/assets/icons/BBP-logo-main.svg +14 -0
- package/assets/icons/collapse.svg +7 -0
- package/assets/icons/connect-small.svg +3 -0
- package/assets/icons/connect.svg +16 -0
- package/assets/icons/cross.svg +4 -0
- package/assets/icons/dark.svg +5 -0
- package/assets/icons/draft.svg +3 -0
- package/assets/icons/file.svg +3 -0
- package/assets/icons/file2.svg +10 -0
- package/assets/icons/folder.svg +3 -0
- package/assets/icons/light.svg +20 -0
- package/assets/icons/logo.svg +11 -0
- package/assets/icons/plus-circle.svg +5 -0
- package/assets/icons/refresh.svg +4 -0
- package/assets/icons/renown.svg +27 -0
- package/assets/icons/settings.svg +6 -0
- package/assets/icons/template.svg +3 -0
- package/assets/info.plist +85 -0
- package/dist/assets/AddDriveModal-taMDAPrQ.js +1 -0
- package/dist/assets/ClearStorageModal-D25tK2Tm.js +1 -0
- package/dist/assets/CookiesPolicyModal-Ba5-1eFa.js +1 -0
- package/dist/assets/CreateDocumentModal-5yovTbYB.js +1 -0
- package/dist/assets/DebugSettingsModal-CAWbTT1p.js +1 -0
- package/dist/assets/DeleteDriveModal-pKVD1qOZ.js +1 -0
- package/dist/assets/DeleteItemModal-CHLRwYTU.js +1 -0
- package/dist/assets/DisclaimerModal-BS1Oo3E6.js +1 -0
- package/dist/assets/DriveSettingsModal-B3VKnJUX.js +1 -0
- package/dist/assets/ExportDocumentWithErrorsModal-CE0T15ar.js +1 -0
- package/dist/assets/SettingsModal-mIaby2OP.js +1 -0
- package/dist/assets/UpgradeDriveModal-BO8Z_H3T.js +1 -0
- package/dist/assets/_virtual_ph_external-packages-CM1tCR4L.js +1 -0
- package/dist/assets/config-CU-aFfVJ.js +1 -0
- package/dist/assets/design_system-eo6iPN5e.js +45 -0
- package/dist/assets/design_system_connect-DmksRnLk.js +45 -0
- package/dist/assets/design_system_ui-CL_VfWpj.js +1 -0
- package/dist/assets/document_drive-BEIKnuGM.js +305 -0
- package/dist/assets/document_engineering-BU6RThU0.js +1 -0
- package/dist/assets/document_model-DXcLJEjZ.js +230 -0
- package/dist/assets/document_model_editor-CUg9Icvc.js +23 -0
- package/dist/assets/drive_explorer-Ce2ufXFz.js +2 -0
- package/dist/assets/graphql-BS4Brs_E.js +75 -0
- package/dist/assets/graphql-editor-CHvNSr7t.js +73 -0
- package/dist/assets/graphql_request-9RNJ00DB.js +3 -0
- package/dist/assets/hmr-LMNkvzP7.js +1 -0
- package/dist/assets/hooks-DhZgS983.js +12 -0
- package/dist/assets/index-BoGd38C_.js +18 -0
- package/dist/assets/index-Br7E7qjt.css +1 -0
- package/dist/assets/json-editor-C3MIGF0C.js +1 -0
- package/dist/assets/react/jsx-runtime-DldvXD6N.js +1 -0
- package/dist/assets/react-DQSxOgtG.js +1 -0
- package/dist/assets/react-dom/client-BVPiT_FE.js +9 -0
- package/dist/assets/react-dom-D6zQJsh6.js +1 -0
- package/dist/assets/reactor_browser-DNPGNjYk.js +25 -0
- package/dist/assets/sentry_browser-B4YoBIIG.js +498 -0
- package/dist/assets/sentry_react-cODD7zWc.js +3 -0
- package/dist/assets/state-schemas-Bd5byQKj.js +2 -0
- package/dist/assets/tailwind_merge-Dr4f9Rms.js +1 -0
- package/dist/assets/zod-C6yxFxyo.js +1 -0
- package/dist/index.html +51 -84
- package/heroku/Dockerfile +98 -0
- package/heroku/Procfile +1 -0
- package/heroku/config/nginx.conf.template +77 -0
- package/heroku/heroku-entrypoint.sh +38 -0
- package/lib/cypress/e2e/navigation.cy.d.ts +2 -0
- package/lib/cypress/e2e/navigation.cy.d.ts.map +1 -0
- package/lib/cypress/e2e/navigation.cy.js +221 -0
- package/lib/cypress/e2e/navigation.cy.js.map +1 -0
- package/lib/cypress/e2e/utils/index.d.ts +15 -0
- package/lib/cypress/e2e/utils/index.d.ts.map +1 -0
- package/lib/cypress/e2e/utils/index.js +121 -0
- package/lib/cypress/e2e/utils/index.js.map +1 -0
- package/lib/cypress/support/commands.d.ts +2 -0
- package/lib/cypress/support/commands.d.ts.map +1 -0
- package/lib/cypress/support/commands.js +29 -0
- package/lib/cypress/support/commands.js.map +1 -0
- package/lib/cypress/support/e2e.d.ts +2 -0
- package/lib/cypress/support/e2e.d.ts.map +1 -0
- package/lib/cypress/support/e2e.js +19 -0
- package/lib/cypress/support/e2e.js.map +1 -0
- package/lib/cypress.config.d.ts +3 -0
- package/lib/cypress.config.d.ts.map +1 -0
- package/lib/cypress.config.js +15 -0
- package/lib/cypress.config.js.map +1 -0
- package/lib/package.copy.json +168 -0
- package/lib/scripts/render-skeleton.d.ts +2 -0
- package/lib/scripts/render-skeleton.d.ts.map +1 -0
- package/lib/scripts/render-skeleton.js +11 -0
- package/lib/scripts/render-skeleton.js.map +1 -0
- package/lib/src/components/analytics.d.ts +8 -0
- package/lib/src/components/analytics.d.ts.map +1 -0
- package/lib/src/components/analytics.js +30 -0
- package/lib/src/components/analytics.js.map +1 -0
- package/lib/src/components/app-loader.d.ts +7 -0
- package/lib/src/components/app-loader.d.ts.map +1 -0
- package/lib/src/components/app-loader.js +20 -0
- package/lib/src/components/app-loader.js.map +1 -0
- package/lib/src/components/app-skeleton.d.ts +3 -0
- package/lib/src/components/app-skeleton.d.ts.map +1 -0
- package/lib/src/components/app-skeleton.js +38 -0
- package/lib/src/components/app-skeleton.js.map +1 -0
- package/lib/src/components/app.d.ts +2 -0
- package/lib/src/components/app.d.ts.map +1 -0
- package/lib/src/components/app.js +18 -0
- package/lib/src/components/app.js.map +1 -0
- package/lib/src/components/button.d.ts +3 -0
- package/lib/src/components/button.d.ts.map +1 -0
- package/lib/src/components/button.js +7 -0
- package/lib/src/components/button.js.map +1 -0
- package/lib/src/components/cookie-banner.d.ts +2 -0
- package/lib/src/components/cookie-banner.d.ts.map +1 -0
- package/lib/src/components/cookie-banner.js +48 -0
- package/lib/src/components/cookie-banner.js.map +1 -0
- package/lib/src/components/document-editor-container.d.ts +2 -0
- package/lib/src/components/document-editor-container.d.ts.map +1 -0
- package/lib/src/components/document-editor-container.js +62 -0
- package/lib/src/components/document-editor-container.js.map +1 -0
- package/lib/src/components/dots-loader.d.ts +2 -0
- package/lib/src/components/dots-loader.d.ts.map +1 -0
- package/lib/src/components/dots-loader.js +15 -0
- package/lib/src/components/dots-loader.js.map +1 -0
- package/lib/src/components/drive-editor-container.d.ts +2 -0
- package/lib/src/components/drive-editor-container.d.ts.map +1 -0
- package/lib/src/components/drive-editor-container.js +25 -0
- package/lib/src/components/drive-editor-container.js.map +1 -0
- package/lib/src/components/drive-icon.d.ts +5 -0
- package/lib/src/components/drive-icon.d.ts.map +1 -0
- package/lib/src/components/drive-icon.js +15 -0
- package/lib/src/components/drive-icon.js.map +1 -0
- package/lib/src/components/editor-loader.d.ts +9 -0
- package/lib/src/components/editor-loader.d.ts.map +1 -0
- package/lib/src/components/editor-loader.js +19 -0
- package/lib/src/components/editor-loader.js.map +1 -0
- package/lib/src/components/editors.d.ts +10 -0
- package/lib/src/components/editors.d.ts.map +1 -0
- package/lib/src/components/editors.js +93 -0
- package/lib/src/components/editors.js.map +1 -0
- package/lib/src/components/footer.d.ts +2 -0
- package/lib/src/components/footer.d.ts.map +1 -0
- package/lib/src/components/footer.js +16 -0
- package/lib/src/components/footer.js.map +1 -0
- package/lib/src/components/index.d.ts +22 -0
- package/lib/src/components/index.d.ts.map +1 -0
- package/lib/src/components/index.js +22 -0
- package/lib/src/components/index.js.map +1 -0
- package/lib/src/components/login.d.ts +2 -0
- package/lib/src/components/login.d.ts.map +1 -0
- package/lib/src/components/login.js +12 -0
- package/lib/src/components/login.js.map +1 -0
- package/lib/src/components/modal/index.d.ts +19 -0
- package/lib/src/components/modal/index.d.ts.map +1 -0
- package/lib/src/components/modal/index.js +19 -0
- package/lib/src/components/modal/index.js.map +1 -0
- package/lib/src/components/modal/modals/AddDriveModal.d.ts +2 -0
- package/lib/src/components/modal/modals/AddDriveModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/AddDriveModal.js +113 -0
- package/lib/src/components/modal/modals/AddDriveModal.js.map +1 -0
- package/lib/src/components/modal/modals/ClearStorageModal.d.ts +2 -0
- package/lib/src/components/modal/modals/ClearStorageModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/ClearStorageModal.js +35 -0
- package/lib/src/components/modal/modals/ClearStorageModal.js.map +1 -0
- package/lib/src/components/modal/modals/CookiesPolicyModal.d.ts +2 -0
- package/lib/src/components/modal/modals/CookiesPolicyModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/CookiesPolicyModal.js +16 -0
- package/lib/src/components/modal/modals/CookiesPolicyModal.js.map +1 -0
- package/lib/src/components/modal/modals/CreateDocumentModal.d.ts +2 -0
- package/lib/src/components/modal/modals/CreateDocumentModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/CreateDocumentModal.js +24 -0
- package/lib/src/components/modal/modals/CreateDocumentModal.js.map +1 -0
- package/lib/src/components/modal/modals/DebugSettingsModal.d.ts +2 -0
- package/lib/src/components/modal/modals/DebugSettingsModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/DebugSettingsModal.js +108 -0
- package/lib/src/components/modal/modals/DebugSettingsModal.js.map +1 -0
- package/lib/src/components/modal/modals/DeleteDriveModal.d.ts +2 -0
- package/lib/src/components/modal/modals/DeleteDriveModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/DeleteDriveModal.js +32 -0
- package/lib/src/components/modal/modals/DeleteDriveModal.js.map +1 -0
- package/lib/src/components/modal/modals/DeleteItemModal.d.ts +3 -0
- package/lib/src/components/modal/modals/DeleteItemModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/DeleteItemModal.js +33 -0
- package/lib/src/components/modal/modals/DeleteItemModal.js.map +1 -0
- package/lib/src/components/modal/modals/DisclaimerModal.d.ts +3 -0
- package/lib/src/components/modal/modals/DisclaimerModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/DisclaimerModal.js +12 -0
- package/lib/src/components/modal/modals/DisclaimerModal.js.map +1 -0
- package/lib/src/components/modal/modals/DriveSettingsModal.d.ts +2 -0
- package/lib/src/components/modal/modals/DriveSettingsModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/DriveSettingsModal.js +28 -0
- package/lib/src/components/modal/modals/DriveSettingsModal.js.map +1 -0
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.d.ts +2 -0
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js +30 -0
- package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js.map +1 -0
- package/lib/src/components/modal/modals/SettingsModal.d.ts +3 -0
- package/lib/src/components/modal/modals/SettingsModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/SettingsModal.js +45 -0
- package/lib/src/components/modal/modals/SettingsModal.js.map +1 -0
- package/lib/src/components/modal/modals/UpgradeDriveModal.d.ts +3 -0
- package/lib/src/components/modal/modals/UpgradeDriveModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/UpgradeDriveModal.js +21 -0
- package/lib/src/components/modal/modals/UpgradeDriveModal.js.map +1 -0
- package/lib/src/components/modal/modals/settings/about.d.ts +2 -0
- package/lib/src/components/modal/modals/settings/about.d.ts.map +1 -0
- package/lib/src/components/modal/modals/settings/about.js +10 -0
- package/lib/src/components/modal/modals/settings/about.js.map +1 -0
- package/lib/src/components/modal/modals/settings/danger-zone.d.ts +2 -0
- package/lib/src/components/modal/modals/settings/danger-zone.d.ts.map +1 -0
- package/lib/src/components/modal/modals/settings/danger-zone.js +15 -0
- package/lib/src/components/modal/modals/settings/danger-zone.js.map +1 -0
- package/lib/src/components/modal/modals/settings/default-editor.d.ts +2 -0
- package/lib/src/components/modal/modals/settings/default-editor.d.ts.map +1 -0
- package/lib/src/components/modal/modals/settings/default-editor.js +18 -0
- package/lib/src/components/modal/modals/settings/default-editor.js.map +1 -0
- package/lib/src/components/modal/modals/settings/package-manager.d.ts +3 -0
- package/lib/src/components/modal/modals/settings/package-manager.d.ts.map +1 -0
- package/lib/src/components/modal/modals/settings/package-manager.js +87 -0
- package/lib/src/components/modal/modals/settings/package-manager.js.map +1 -0
- package/lib/src/components/modal/modals-container.d.ts +2 -0
- package/lib/src/components/modal/modals-container.d.ts.map +1 -0
- package/lib/src/components/modal/modals-container.js +62 -0
- package/lib/src/components/modal/modals-container.js.map +1 -0
- package/lib/src/components/modal/modals-error-boundary.d.ts +18 -0
- package/lib/src/components/modal/modals-error-boundary.d.ts.map +1 -0
- package/lib/src/components/modal/modals-error-boundary.js +22 -0
- package/lib/src/components/modal/modals-error-boundary.js.map +1 -0
- package/lib/src/components/ph-logo.d.ts +2 -0
- package/lib/src/components/ph-logo.d.ts.map +1 -0
- package/lib/src/components/ph-logo.js +7 -0
- package/lib/src/components/ph-logo.js.map +1 -0
- package/lib/src/components/reload-connect-toast.d.ts +2 -0
- package/lib/src/components/reload-connect-toast.d.ts.map +1 -0
- package/lib/src/components/reload-connect-toast.js +7 -0
- package/lib/src/components/reload-connect-toast.js.map +1 -0
- package/lib/src/components/root.d.ts +2 -0
- package/lib/src/components/root.d.ts.map +1 -0
- package/lib/src/components/root.js +8 -0
- package/lib/src/components/root.js.map +1 -0
- package/lib/src/components/router.d.ts +2 -0
- package/lib/src/components/router.d.ts.map +1 -0
- package/lib/src/components/router.js +41 -0
- package/lib/src/components/router.js.map +1 -0
- package/lib/src/components/search-bar.d.ts +2 -0
- package/lib/src/components/search-bar.d.ts.map +1 -0
- package/lib/src/components/search-bar.js +36 -0
- package/lib/src/components/search-bar.js.map +1 -0
- package/lib/src/components/sidebar.d.ts +2 -0
- package/lib/src/components/sidebar.d.ts.map +1 -0
- package/lib/src/components/sidebar.js +27 -0
- package/lib/src/components/sidebar.js.map +1 -0
- package/lib/src/connect.config.d.ts +113 -0
- package/lib/src/connect.config.d.ts.map +1 -0
- package/lib/src/connect.config.js +147 -0
- package/lib/src/connect.config.js.map +1 -0
- package/lib/src/context/index.d.ts +4 -0
- package/lib/src/context/index.d.ts.map +1 -0
- package/lib/src/context/index.js +4 -0
- package/lib/src/context/index.js.map +1 -0
- package/lib/src/context/processor-manager.d.ts +3 -0
- package/lib/src/context/processor-manager.d.ts.map +1 -0
- package/lib/src/context/processor-manager.js +189 -0
- package/lib/src/context/processor-manager.js.map +1 -0
- package/lib/src/context/read-mode.d.ts +2 -0
- package/lib/src/context/read-mode.d.ts.map +1 -0
- package/lib/src/context/read-mode.js +219 -0
- package/lib/src/context/read-mode.js.map +1 -0
- package/lib/src/context/sentry-provider.d.ts +6 -0
- package/lib/src/context/sentry-provider.d.ts.map +1 -0
- package/lib/src/context/sentry-provider.js +6 -0
- package/lib/src/context/sentry-provider.js.map +1 -0
- package/lib/src/feature-flags.d.ts +34 -0
- package/lib/src/feature-flags.d.ts.map +1 -0
- package/lib/src/feature-flags.js +124 -0
- package/lib/src/feature-flags.js.map +1 -0
- package/lib/src/globals.d.ts +9 -0
- package/lib/src/globals.d.ts.map +1 -0
- package/lib/src/globals.js +2 -0
- package/lib/src/globals.js.map +1 -0
- package/lib/src/hmr.d.ts +3 -0
- package/lib/src/hmr.d.ts.map +1 -0
- package/lib/src/hmr.js +2 -0
- package/lib/src/hmr.js.map +1 -0
- package/lib/src/hooks/index.d.ts +10 -0
- package/lib/src/hooks/index.d.ts.map +1 -0
- package/lib/src/hooks/index.js +10 -0
- package/lib/src/hooks/index.js.map +1 -0
- package/lib/src/hooks/useAcceptedCookies.d.ts +9 -0
- package/lib/src/hooks/useAcceptedCookies.d.ts.map +1 -0
- package/lib/src/hooks/useAcceptedCookies.js +34 -0
- package/lib/src/hooks/useAcceptedCookies.js.map +1 -0
- package/lib/src/hooks/useCheckLatestVersion.d.ts +2 -0
- package/lib/src/hooks/useCheckLatestVersion.d.ts.map +1 -0
- package/lib/src/hooks/useCheckLatestVersion.js +33 -0
- package/lib/src/hooks/useCheckLatestVersion.js.map +1 -0
- package/lib/src/hooks/useClientErrorHandler.d.ts +6 -0
- package/lib/src/hooks/useClientErrorHandler.d.ts.map +1 -0
- package/lib/src/hooks/useClientErrorHandler.js +120 -0
- package/lib/src/hooks/useClientErrorHandler.js.map +1 -0
- package/lib/src/hooks/useCookieBanner.d.ts +5 -0
- package/lib/src/hooks/useCookieBanner.d.ts.map +1 -0
- package/lib/src/hooks/useCookieBanner.js +32 -0
- package/lib/src/hooks/useCookieBanner.js.map +1 -0
- package/lib/src/hooks/useInitSentry.d.ts +2 -0
- package/lib/src/hooks/useInitSentry.d.ts.map +1 -0
- package/lib/src/hooks/useInitSentry.js +80 -0
- package/lib/src/hooks/useInitSentry.js.map +1 -0
- package/lib/src/hooks/useNodeActions.d.ts +6 -0
- package/lib/src/hooks/useNodeActions.d.ts.map +1 -0
- package/lib/src/hooks/useNodeActions.js +35 -0
- package/lib/src/hooks/useNodeActions.js.map +1 -0
- package/lib/src/hooks/useUndoRedoShortcuts.d.ts +8 -0
- package/lib/src/hooks/useUndoRedoShortcuts.d.ts.map +1 -0
- package/lib/src/hooks/useUndoRedoShortcuts.js +26 -0
- package/lib/src/hooks/useUndoRedoShortcuts.js.map +1 -0
- package/lib/src/hooks/useWindowSize.d.ts +5 -0
- package/lib/src/hooks/useWindowSize.d.ts.map +1 -0
- package/lib/src/hooks/useWindowSize.js +21 -0
- package/lib/src/hooks/useWindowSize.js.map +1 -0
- package/lib/src/hooks/utils.d.ts +7 -0
- package/lib/src/hooks/utils.d.ts.map +1 -0
- package/lib/src/hooks/utils.js +46 -0
- package/lib/src/hooks/utils.js.map +1 -0
- package/lib/src/i18n/index.d.ts +4 -0
- package/lib/src/i18n/index.d.ts.map +1 -0
- package/lib/src/i18n/index.js +26 -0
- package/lib/src/i18n/index.js.map +1 -0
- package/lib/src/i18n/locales/en.json +114 -0
- package/lib/src/index.d.ts +2 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/src/index.js +2 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/main.d.ts +2 -0
- package/lib/src/main.d.ts.map +1 -0
- package/lib/src/main.js +5 -0
- package/lib/src/main.js.map +1 -0
- package/lib/src/pages/content.d.ts +2 -0
- package/lib/src/pages/content.d.ts.map +1 -0
- package/lib/src/pages/content.js +39 -0
- package/lib/src/pages/content.js.map +1 -0
- package/lib/src/pages/demo/atlas-import.d.ts +2 -0
- package/lib/src/pages/demo/atlas-import.d.ts.map +1 -0
- package/lib/src/pages/demo/atlas-import.js +122 -0
- package/lib/src/pages/demo/atlas-import.js.map +1 -0
- package/lib/src/pages/index.d.ts +4 -0
- package/lib/src/pages/index.d.ts.map +1 -0
- package/lib/src/pages/index.js +4 -0
- package/lib/src/pages/index.js.map +1 -0
- package/lib/src/pages/settings.d.ts +4 -0
- package/lib/src/pages/settings.d.ts.map +1 -0
- package/lib/src/pages/settings.js +9 -0
- package/lib/src/pages/settings.js.map +1 -0
- package/lib/src/service-worker.d.ts +2 -0
- package/lib/src/service-worker.d.ts.map +1 -0
- package/lib/src/service-worker.js +58 -0
- package/lib/src/service-worker.js.map +1 -0
- package/lib/src/services/hmr.d.ts +13 -0
- package/lib/src/services/hmr.d.ts.map +1 -0
- package/lib/src/services/hmr.js +85 -0
- package/lib/src/services/hmr.js.map +1 -0
- package/lib/src/services/index.d.ts +10 -0
- package/lib/src/services/index.d.ts.map +1 -0
- package/lib/src/services/index.js +9 -0
- package/lib/src/services/index.js.map +1 -0
- package/lib/src/services/logger.d.ts +2 -0
- package/lib/src/services/logger.d.ts.map +1 -0
- package/lib/src/services/logger.js +28 -0
- package/lib/src/services/logger.js.map +1 -0
- package/lib/src/services/renown/browser.d.ts +2 -0
- package/lib/src/services/renown/browser.d.ts.map +1 -0
- package/lib/src/services/renown/browser.js +6 -0
- package/lib/src/services/renown/browser.js.map +1 -0
- package/lib/src/services/renown/constants.d.ts +130 -0
- package/lib/src/services/renown/constants.d.ts.map +1 -0
- package/lib/src/services/renown/constants.js +41 -0
- package/lib/src/services/renown/constants.js.map +1 -0
- package/lib/src/services/renown/utils.d.ts +7 -0
- package/lib/src/services/renown/utils.d.ts.map +1 -0
- package/lib/src/services/renown/utils.js +20 -0
- package/lib/src/services/renown/utils.js.map +1 -0
- package/lib/src/services/storage/base-storage.d.ts +9 -0
- package/lib/src/services/storage/base-storage.d.ts.map +1 -0
- package/lib/src/services/storage/base-storage.js +21 -0
- package/lib/src/services/storage/base-storage.js.map +1 -0
- package/lib/src/services/storage/browser.d.ts +5 -0
- package/lib/src/services/storage/browser.d.ts.map +1 -0
- package/lib/src/services/storage/browser.js +25 -0
- package/lib/src/services/storage/browser.js.map +1 -0
- package/lib/src/services/storage/types.d.ts +6 -0
- package/lib/src/services/storage/types.d.ts.map +1 -0
- package/lib/src/services/storage/types.js +2 -0
- package/lib/src/services/storage/types.js.map +1 -0
- package/lib/src/services/toast.d.ts +8 -0
- package/lib/src/services/toast.d.ts.map +1 -0
- package/lib/src/services/toast.js +11 -0
- package/lib/src/services/toast.js.map +1 -0
- package/lib/src/store/document-model.d.ts +3 -0
- package/lib/src/store/document-model.d.ts.map +1 -0
- package/lib/src/store/document-model.js +79 -0
- package/lib/src/store/document-model.js.map +1 -0
- package/lib/src/store/editor.d.ts +5 -0
- package/lib/src/store/editor.d.ts.map +1 -0
- package/lib/src/store/editor.js +31 -0
- package/lib/src/store/editor.js.map +1 -0
- package/lib/src/store/external-packages.d.ts +4 -0
- package/lib/src/store/external-packages.d.ts.map +1 -0
- package/lib/src/store/external-packages.js +36 -0
- package/lib/src/store/external-packages.js.map +1 -0
- package/lib/src/store/index.d.ts +7 -0
- package/lib/src/store/index.d.ts.map +1 -0
- package/lib/src/store/index.js +7 -0
- package/lib/src/store/index.js.map +1 -0
- package/lib/src/store/reactor.d.ts +3 -0
- package/lib/src/store/reactor.d.ts.map +1 -0
- package/lib/src/store/reactor.js +177 -0
- package/lib/src/store/reactor.js.map +1 -0
- package/lib/src/store/user.d.ts +2 -0
- package/lib/src/store/user.d.ts.map +1 -0
- package/lib/src/store/user.js +16 -0
- package/lib/src/store/user.js.map +1 -0
- package/lib/src/store/utils.d.ts +2 -0
- package/lib/src/store/utils.d.ts.map +1 -0
- package/lib/src/store/utils.js +59 -0
- package/lib/src/store/utils.js.map +1 -0
- package/lib/src/utils/browser.d.ts +2 -0
- package/lib/src/utils/browser.d.ts.map +1 -0
- package/lib/src/utils/browser.js +9 -0
- package/lib/src/utils/browser.js.map +1 -0
- package/lib/src/utils/document-editor-debug-tools.d.ts +17 -0
- package/lib/src/utils/document-editor-debug-tools.d.ts.map +1 -0
- package/lib/src/utils/document-editor-debug-tools.js +55 -0
- package/lib/src/utils/document-editor-debug-tools.js.map +1 -0
- package/lib/src/utils/drive-preservation.d.ts +19 -0
- package/lib/src/utils/drive-preservation.d.ts.map +1 -0
- package/lib/src/utils/drive-preservation.js +51 -0
- package/lib/src/utils/drive-preservation.js.map +1 -0
- package/lib/src/utils/drive-sections.d.ts +31 -0
- package/lib/src/utils/drive-sections.d.ts.map +1 -0
- package/lib/src/utils/drive-sections.js +63 -0
- package/lib/src/utils/drive-sections.js.map +1 -0
- package/lib/src/utils/index.d.ts +12 -0
- package/lib/src/utils/index.d.ts.map +1 -0
- package/lib/src/utils/index.js +12 -0
- package/lib/src/utils/index.js.map +1 -0
- package/lib/src/utils/join.d.ts +2 -0
- package/lib/src/utils/join.d.ts.map +1 -0
- package/lib/src/utils/join.js +11 -0
- package/lib/src/utils/join.js.map +1 -0
- package/lib/src/utils/openUrl.d.ts +2 -0
- package/lib/src/utils/openUrl.d.ts.map +1 -0
- package/lib/src/utils/openUrl.js +3 -0
- package/lib/src/utils/openUrl.js.map +1 -0
- package/lib/src/utils/path.d.ts +4 -0
- package/lib/src/utils/path.d.ts.map +1 -0
- package/lib/src/utils/path.js +17 -0
- package/lib/src/utils/path.js.map +1 -0
- package/lib/src/utils/reactor.d.ts +6 -0
- package/lib/src/utils/reactor.d.ts.map +1 -0
- package/lib/src/utils/reactor.js +57 -0
- package/lib/src/utils/reactor.js.map +1 -0
- package/lib/src/utils/registerServiceWorker.d.ts +12 -0
- package/lib/src/utils/registerServiceWorker.d.ts.map +1 -0
- package/lib/src/utils/registerServiceWorker.js +97 -0
- package/lib/src/utils/registerServiceWorker.js.map +1 -0
- package/lib/src/utils/signature.d.ts +4 -0
- package/lib/src/utils/signature.d.ts.map +1 -0
- package/lib/src/utils/signature.js +36 -0
- package/lib/src/utils/signature.js.map +1 -0
- package/lib/src/utils/slug.d.ts +2 -0
- package/lib/src/utils/slug.d.ts.map +1 -0
- package/lib/src/utils/slug.js +4 -0
- package/lib/src/utils/slug.js.map +1 -0
- package/lib/src/workers/pglite-worker.d.ts +2 -0
- package/lib/src/workers/pglite-worker.d.ts.map +1 -0
- package/lib/src/workers/pglite-worker.js +32 -0
- package/lib/src/workers/pglite-worker.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/vite.config.d.ts +3 -0
- package/lib/vite.config.d.ts.map +1 -0
- package/lib/vite.config.js +55 -0
- package/lib/vite.config.js.map +1 -0
- package/package.copy.json +168 -0
- package/package.json +132 -96
- package/public/icon.ico +0 -0
- package/public/robots.txt +3 -0
- package/public/settings.png +0 -0
- package/scripts/render-skeleton.ts +8 -10
- package/src/index.css +4 -0
- package/dist/assets/AddDriveModal.DJ-dAFOA.js +0 -2
- package/dist/assets/AddDriveModal.DJ-dAFOA.js.map +0 -1
- package/dist/assets/AddLocalDriveModal.De9JCy3U.js +0 -2
- package/dist/assets/AddLocalDriveModal.De9JCy3U.js.map +0 -1
- package/dist/assets/AddRemoteDriveModal.Bbso9zlA.js +0 -2
- package/dist/assets/AddRemoteDriveModal.Bbso9zlA.js.map +0 -1
- package/dist/assets/ConfirmationModal.vrZxNEXg.js +0 -2
- package/dist/assets/ConfirmationModal.vrZxNEXg.js.map +0 -1
- package/dist/assets/CookiesPolicyModal._TIEDwTl.js +0 -2
- package/dist/assets/CookiesPolicyModal._TIEDwTl.js.map +0 -1
- package/dist/assets/CreateDocumentModal.6coMTZ5K.js +0 -2
- package/dist/assets/CreateDocumentModal.6coMTZ5K.js.map +0 -1
- package/dist/assets/DebugSettingsModal.CC8h7-01.js +0 -2
- package/dist/assets/DebugSettingsModal.CC8h7-01.js.map +0 -1
- package/dist/assets/DeleteDriveModal.MOCpt-lE.js +0 -2
- package/dist/assets/DeleteDriveModal.MOCpt-lE.js.map +0 -1
- package/dist/assets/DeleteItemModal.D1JNJ3SD.js +0 -2
- package/dist/assets/DeleteItemModal.D1JNJ3SD.js.map +0 -1
- package/dist/assets/DisclaimerModal.CpWL_8dJ.js +0 -2
- package/dist/assets/DisclaimerModal.CpWL_8dJ.js.map +0 -1
- package/dist/assets/DriveSettingsModal.Cq31PlSd.js +0 -2
- package/dist/assets/DriveSettingsModal.Cq31PlSd.js.map +0 -1
- package/dist/assets/SettingsModal.DXSp8FUL.js +0 -2
- package/dist/assets/SettingsModal.DXSp8FUL.js.map +0 -1
- package/dist/assets/Trans.B_Bse39z.js +0 -2
- package/dist/assets/Trans.B_Bse39z.js.map +0 -1
- package/dist/assets/UpgradeDriveModal.Bcaqra-T.js +0 -2
- package/dist/assets/UpgradeDriveModal.Bcaqra-T.js.map +0 -1
- package/dist/assets/app-skeleton.js +0 -11
- package/dist/assets/app-skeleton.js.map +0 -1
- package/dist/assets/atlas-import.CrAV29KX.js +0 -6
- package/dist/assets/atlas-import.CrAV29KX.js.map +0 -1
- package/dist/assets/browser.BkwNmV2Z.js +0 -2
- package/dist/assets/browser.BkwNmV2Z.js.map +0 -1
- package/dist/assets/content.BVfObTK-.js +0 -3
- package/dist/assets/content.BVfObTK-.js.map +0 -1
- package/dist/assets/cookie-banner.CqSpDuL2.js +0 -2
- package/dist/assets/cookie-banner.CqSpDuL2.js.map +0 -1
- package/dist/assets/i18next.CqOP20KE.js +0 -2
- package/dist/assets/i18next.CqOP20KE.js.map +0 -1
- package/dist/assets/index-B7k827uL.css +0 -1
- package/dist/assets/index.Be3reTUB.js +0 -114
- package/dist/assets/index.Be3reTUB.js.map +0 -1
- package/dist/assets/index.C0tp--nk.js +0 -387
- package/dist/assets/index.C0tp--nk.js.map +0 -1
- package/dist/assets/index.CTYq_dOR.js +0 -16
- package/dist/assets/index.CTYq_dOR.js.map +0 -1
- package/dist/assets/index.CW6hXWch.js +0 -333
- package/dist/assets/index.CW6hXWch.js.map +0 -1
- package/dist/assets/index.DNX0QOJs.js +0 -2
- package/dist/assets/index.DNX0QOJs.js.map +0 -1
- package/dist/assets/index.MXCURbo4.js +0 -361
- package/dist/assets/index.MXCURbo4.js.map +0 -1
- package/dist/assets/index.TIUvoczv.js +0 -2
- package/dist/assets/index.TIUvoczv.js.map +0 -1
- package/dist/assets/index.hUDcoha1.js +0 -2
- package/dist/assets/index.hUDcoha1.js.map +0 -1
- package/dist/assets/index.ycvKRDCc.js +0 -2
- package/dist/assets/index.ycvKRDCc.js.map +0 -1
- package/dist/assets/main-CT4nIKNi.css +0 -1
- package/dist/assets/main.CpBKbYrC.js +0 -3
- package/dist/assets/main.CpBKbYrC.js.map +0 -1
- package/dist/assets/modal.B6AxZ1yB.js +0 -3
- package/dist/assets/modal.B6AxZ1yB.js.map +0 -1
- package/dist/assets/modals.jKUpbvJU.js +0 -2
- package/dist/assets/modals.jKUpbvJU.js.map +0 -1
- package/dist/assets/nodefs-CbgXeDrX.js +0 -2
- package/dist/assets/nodefs-CbgXeDrX.js.map +0 -1
- package/dist/assets/nodefs.rxvmn5tR.js +0 -2
- package/dist/assets/nodefs.rxvmn5tR.js.map +0 -1
- package/dist/assets/nodes.CkHD8Mis.js +0 -2
- package/dist/assets/nodes.CkHD8Mis.js.map +0 -1
- package/dist/assets/opfs-ahp-CvqFFNTs.js +0 -4
- package/dist/assets/opfs-ahp-CvqFFNTs.js.map +0 -1
- package/dist/assets/opfs-ahp.BE5Mymun.js +0 -4
- package/dist/assets/opfs-ahp.BE5Mymun.js.map +0 -1
- package/dist/assets/pglite-worker-CBI3hEVN.js +0 -144
- package/dist/assets/pglite-worker-CBI3hEVN.js.map +0 -1
- package/dist/assets/pglite-worker.dssW4LQw.js +0 -2
- package/dist/assets/pglite-worker.dssW4LQw.js.map +0 -1
- package/dist/assets/postgres-CkP7QCDB.data +0 -0
- package/dist/assets/postgres-CyuUVpXN.wasm +0 -0
- package/dist/assets/registerServiceWorker.3WXSlUUt.js +0 -2
- package/dist/assets/registerServiceWorker.3WXSlUUt.js.map +0 -1
- package/dist/assets/root.20yJwNI0.js +0 -6
- package/dist/assets/root.20yJwNI0.js.map +0 -1
- package/dist/assets/style-BkLV0sfQ.css +0 -1
- package/dist/assets/useAcceptedCookies.BEC0OUzL.js +0 -2
- package/dist/assets/useAcceptedCookies.BEC0OUzL.js.map +0 -1
- package/dist/assets/useDefaultDocumentModelEditor.oOnI3BO7.js +0 -2
- package/dist/assets/useDefaultDocumentModelEditor.oOnI3BO7.js.map +0 -1
- package/dist/assets/useInitSentry.DX0S8ltZ.js +0 -368
- package/dist/assets/useInitSentry.DX0S8ltZ.js.map +0 -1
- package/dist/external-packages.js +0 -1
- package/dist/fonts/Inter-Black.ttf +0 -0
- package/dist/fonts/Inter-Bold.ttf +0 -0
- package/dist/fonts/Inter-ExtraBold.ttf +0 -0
- package/dist/fonts/Inter-ExtraLight.ttf +0 -0
- package/dist/fonts/Inter-Light.ttf +0 -0
- package/dist/fonts/Inter-Medium.ttf +0 -0
- package/dist/fonts/Inter-Regular.ttf +0 -0
- package/dist/fonts/Inter-SemiBold.ttf +0 -0
- package/dist/fonts/Inter-Thin.ttf +0 -0
- package/dist/fonts/Inter-VariableFont_slnt,wght.ttf +0 -0
- package/dist/hmr.js +0 -2
- package/dist/hmr.js.map +0 -1
- package/dist/service-worker.js +0 -2
- package/dist/service-worker.js.map +0 -1
- package/dist/swEnv.js +0 -70
- package/dist/vite-envs.sh +0 -494
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index.CTYq_dOR.js","./index.CW6hXWch.js","./index.DNX0QOJs.js","./browser.BkwNmV2Z.js","./app-skeleton.js","./useInitSentry.DX0S8ltZ.js","./useAcceptedCookies.BEC0OUzL.js","./registerServiceWorker.3WXSlUUt.js","./cookie-banner.CqSpDuL2.js","./i18next.CqOP20KE.js","./modal.B6AxZ1yB.js","./Trans.B_Bse39z.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Ff=Object.defineProperty;var ra=t=>{throw TypeError(t)};var Uf=(t,e,n)=>e in t?Ff(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var F=(t,e,n)=>Uf(t,typeof e!="symbol"?e+"":e,n),Hs=(t,e,n)=>e.has(t)||ra("Cannot "+n);var he=(t,e,n)=>(Hs(t,e,"read from private field"),n?n.call(t):e.get(t)),et=(t,e,n)=>e.has(t)?ra("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Yt=(t,e,n,r)=>(Hs(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),ct=(t,e,n)=>(Hs(t,e,"access private method"),n);import{createRoot as Bf}from"react-dom/client";import{p as sa,L as nr,P as jf,a as Vf,g as ws,o as Me,s as de,b as Ii,e as Pc,l as pr,c as Gf,d as Rr,f as zf,i as qf,h as kc,j as Yf,k as $c,m as Hf,n as Jf,q as Et,r as Wf,t as Ve,u as Qf,v as Ft,w as Fc,x as Vr,y as ia,z as Kf,B as Xf,D as Zf,E as ep,F as tp,G as np,I as rp,J as Gr,K as Uc,M as sp,N as ip,O as op,Q as Cr,R as ap,_ as Bt,S as cp,T as up,U as lp,V as dp,W as Di,X as fp,Y as Js}from"./index.CW6hXWch.js";import{jsxs as Zr,jsx as yt}from"react/jsx-runtime";import bs,{useRef as on,createElement as pp,createContext as Xi,useReducer as Bc,useEffect as Ce,useDebugValue as jc,useContext as Zi,useCallback as ae,useState as Rn,useMemo as hr,StrictMode as hp,Suspense as oa,lazy as eo}from"react";import{g as gp}from"./browser.BkwNmV2Z.js";import{A as mp}from"./app-skeleton.js";function yp(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}const tt={verbose:1,debug:2,info:3,warn:4,error:5,silent:6};function Vc(t){return typeof t=="string"&&t in tt}var vp={},Pt,rn,kt,$t,wn;class Gc{constructor(e,n){et(this,$t);et(this,Pt);et(this,rn,"env");et(this,kt);Yt(this,Pt,(e||[]).map(r=>`[${r}]`)),Yt(this,kt,n),this.log=this.log.bind(this),this.info=this.info.bind(this),this.warn=this.warn.bind(this),this.error=this.error.bind(this),this.debug=this.debug.bind(this),this.verbose=this.verbose.bind(this)}get level(){return he(this,rn)}set level(e){if(e!=="env"&&!Vc(e))throw new Error(`Invalid log level: ${JSON.stringify(e)}.
|
|
3
|
-
Must be one of ${Object.keys(tt).concat(["env"]).join(", ")}.`);Yt(this,rn,e)}get errorHandler(){return he(this,kt)}set errorHandler(e){Yt(this,kt,e)}log(...e){return this.debug(...e)}verbose(...e){if(!(he(this,$t,wn)>tt.verbose))return this.debug(...e)}debug(...e){if(!(he(this,$t,wn)>tt.debug))return console.debug(...he(this,Pt),...e)}info(...e){if(!(he(this,$t,wn)>tt.info))return console.info(...he(this,Pt),...e)}warn(...e){if(!(he(this,$t,wn)>tt.warn))return console.warn(...he(this,Pt),...e)}error(...e){if(!(he(this,$t,wn)>tt.error))return he(this,kt)&&he(this,kt).call(this,...e),console.error(...he(this,Pt),...e)}}Pt=new WeakMap,rn=new WeakMap,kt=new WeakMap,$t=new WeakSet,wn=function(){if(he(this,rn)==="env"){const e=typeof sa<"u"&&"env"in sa?vp.LOG_LEVEL:void 0;return!e||!(e in tt)?tt.debug:tt[e]}return tt[he(this,rn)]};const Ss=new Gc;let to="env",zc;Ss.level=to;Ss.errorHandler=zc;const pe=Ss,Ep=t=>{to=t,Ss.level=t},wt=t=>{const e=new Gc(t);return e.level=to,e.errorHandler=zc,e},_p="@powerhousedao/connect",wp="Powerhouse-Connect",bp="4.1.0-dev.12",Sp="Powerhouse Connect",Tp="./dist/index.html",Ip="module",Dp={node:">=22.0.0"},Np=["dist","nginx.conf","nginx.sh","scripts"],Op="AGPL-3.0-only",Ap="acaldas@powerhouse.inc",Rp={type:"git",url:"https://github.com/powerhouse-inc/powerhouse"},Cp={url:"https://github.com/powerhouse-inc/powerhouse/issues"},Lp="https://github.com/powerhouse-inc/powerhouse#readme",xp={"build:tsc":"tsc --build",start:"electron-forge start",package:"electron-forge package",make:"PH_CONNECT_BASE_HREF=./ electron-forge make","make:mac":"PH_CONNECT_BASE_HREF=./ electron-forge make -p darwin","make:linux":"PH_CONNECT_BASE_HREF=./ electron-forge make -p linux","make:windows":"PH_CONNECT_BASE_HREF=./ electron-forge make -p win32","publish:electron":"electron-forge publish",prepublishOnly:"npm run build",lint:"eslint .","lint:fix":"eslint --fix .","lint:nx":"eslint --quiet --fix .",format:'prettier --write "**/*.+(js|ts|jsx|tsx|json)"',dev:"vite -c vite.renderer.config.mts","dev:nocache":"rm -rf node_modules/.vite && rm -rf node_modules/.cache && npm run dev",prebuild:"npm run clean && tsc --build --noEmit",build:"NODE_OPTIONS=--max-old-space-size=6144 vite build -c vite.renderer.config.mts",preview:"vite preview -c vite.renderer.config.mts",e2e:"playwright test","cy:open":"cypress open","build:service-worker":"tsc --build ./tsconfig.sw.json",clean:"rimraf dist","clean:node_modules":"rimraf node_modules","docker:build":"docker build -f ./Dockerfile --tag connect-test-dev --build-arg TAG=dev .","docker:run":"docker run -it -p 4000:4000 -v $(realpath ../../../monorepo):/monorepo -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf.template -e PH_USE_LOCAL=true -e PH_CONNECT_BASE_PATH=/develop/powerhouse/connect -e PORT=4000 connect-test-dev"},Mp={"@didtools/key-webcrypto":"^0.2.0","@electron-forge/cli":"^6.1.1","@electron-forge/maker-deb":"^6.1.1","@electron-forge/maker-rpm":"^6.1.1","@electron-forge/maker-squirrel":"^6.1.1","@electron-forge/maker-zip":"^6.1.1","@electron-forge/plugin-vite":"^6.1.1","@electron-forge/publisher-electron-release-server":"^6.2.1","@electron-forge/publisher-github":"^7.2.0","@electron-forge/shared-types":"^7.7.0","@playwright/test":"^1.41.2","@powerhousedao/builder-tools":"workspace:*","@powerhousedao/common":"workspace:*","@powerhousedao/config":"workspace:*","@powerhousedao/design-system":"workspace:*","@powerhousedao/vetra":"workspace:*","@powerhousedao/diff-analyzer":"^0.0.0-dev.10","@powerhousedao/reactor-browser":"workspace:*","@powerhousedao/state":"workspace:*","@renown/sdk":"workspace:*","@rollup/plugin-node-resolve":"^15.2.3","@sentry/browser":"^9.1.0","@sentry/react":"^7.109.0","@sentry/vite-plugin":"^2.23.0","@tailwindcss/vite":"^4.1.4","@tanstack/react-virtual":"^3.8.1","@types/node":"^22.15.17","@types/react":"^18.2.79","@types/react-dom":"^18.2.18","@types/uuid":"^9.0.7","@types/wicg-file-system-access":"^2020.9.6","@vitejs/plugin-basic-ssl":"^2.0.0","@vitejs/plugin-react":"^4.4.1",asar:"^3.2.0","did-jwt":"^8.0.14","did-jwt-vc":"^4.0.12","did-key-creator":"^1.2.0","document-drive":"workspace:*","document-model":"workspace:*",electron:"30.0.0","electron-is-dev":"^3.0.1","electron-playwright-helpers":"^1.7.1","electron-squirrel-startup":"^1.0.0","electron-store":"^8.1.0",esbuild:"^0.24.0","fast-deep-equal":"^3.1.3",graphql:"^16.11.0","graphql-request":"^6.1.0",i18next:"^23.7.6",jotai:"^2.1.0","jotai-devtools":"^0.12.0","jotai-effect":"^1.1.6",localforage:"^1.10.0",playwright:"^1.41.2","playwright-core":"^1.41.2",react:"^18.3.1","react-dom":"^18.3.1","react-error-boundary":"^4.0.11","react-hotkeys-hook":"^4.5.0","react-i18next":"^13.5.0","react-router-dom":"^6.11.2","tailwind-merge":"^3.0.2",tailwindcss:"^4.1.4",uint8arrays:"^5.1.0",uuid:"^9.0.1",viem:"^2.8.13",vite:"^6.3.3","vite-envs":"^4.6.0","vite-plugin-html":"^3.2.2","vite-plugin-node-polyfills":"^0.23.0","vite-plugin-svgr":"^4.3.0","vite-tsconfig-paths":"^5.1.4","xvfb-maybe":"^0.2.1"},Pp={"@esbuild/linux-x64":"^0.21.4","@rollup/rollup-linux-x64-musl":"4.14.3"},kp={name:_p,productName:wp,version:bp,description:Sp,main:Tp,type:Ip,engines:Dp,files:Np,license:Op,author:Ap,repository:Rp,bugs:Cp,homepage:Lp,scripts:xp,devDependencies:Mp,optionalDependencies:Pp},$p=kp.version,Fp=window.__VITE_ENVS.APP_VERSION||$p,Up=window.__VITE_ENVS.PH_CONNECT_WARN_OUTDATED_APP||"false",Bp=window.__VITE_ENVS.PH_CONNECT_STUDIO_MODE||"false",jp=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_DRIVE||"false",Vp=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_PUBLIC_DRIVES||void 0,Gp=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_CLOUD_DRIVES||void 0,zp=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_LOCAL_DRIVES||void 0,qp=window.__VITE_ENVS.PH_CONNECT_DISABLE_DELETE_PUBLIC_DRIVES||void 0,Yp=window.__VITE_ENVS.PH_CONNECT_DISABLE_DELETE_CLOUD_DRIVES||void 0,Hp=window.__VITE_ENVS.PH_CONNECT_DISABLE_DELETE_LOCAL_DRIVES||void 0,Jp=window.__VITE_ENVS.PH_CONNECT_LOCAL_DRIVES_ENABLED||void 0,Wp=window.__VITE_ENVS.PH_CONNECT_CLOUD_DRIVES_ENABLED||void 0,Qp=window.__VITE_ENVS.PH_CONNECT_PUBLIC_DRIVES_ENABLED||void 0,Kp=window.__VITE_ENVS.PH_CONNECT_SEARCH_BAR_ENABLED||void 0,Xp=window.__VITE_ENVS.PH_CONNECT_HIDE_DOCUMENT_MODEL_SELECTION_SETTINGS||"false",qc=gp()||"/",Zp=window.__VITE_ENVS.PH_CONNECT_SENTRY_DSN||"",eh=window.__VITE_ENVS.PH_CONNECT_SENTRY_ENV||"dev",th=window.__VITE_ENVS.PH_CONNECT_SENTRY_TRACING_ENABLED||"false",nh=window.__VITE_ENVS.PH_CONNECT_GA_TRACKING_ID,rh=window.__VITE_ENVS.PH_CONNECT_CLI_VERSION||void 0,sh=window.__VITE_ENVS.PH_CONNECT_ANALYTICS_DATABASE_NAME||`${qc.replace(/\//g,"")}:analytics`,ih=window.__VITE_ENVS.PH_CONNECT_ANALYTICS_DATABASE_WORKER_DISABLED||"false",oh=window.__VITE_ENVS.PH_CONNECT_DIFF_ANALYTICS_ENABLED||"false",ah=window.__VITE_ENVS.PH_CONNECT_DRIVE_ANALYTICS_ENABLED||"false",ch=window.__VITE_ENVS.PH_CONNECT_EXTERNAL_PROCESSORS_ENABLED||"true",uh=Vc(window.__VITE_ENVS.LOG_LEVEL)?window.__VITE_ENVS.LOG_LEVEL:"info";Ep(uh);pe.debug(`Setting log level to ${window.__VITE_ENVS.LOG_LEVEL}.`);const gr={appVersion:Fp,studioMode:Bp.toString()==="true",warnOutdatedApp:Up==="true",routerBasename:qc,analytics:{databaseName:sh,useWorker:ih!=="true",driveAnalyticsEnabled:ah==="true",diffProcessorEnabled:oh==="true",externalProcessorsEnabled:ch==="true"},sentry:{dsn:Zp,env:eh,tracing:th==="true"},content:{showSearchBar:Kp!=="false",showDocumentModelSelectionSetting:Xp!=="true"},drives:{addDriveEnabled:jp!=="true",sections:{[nr]:{enabled:Jp!=="false",allowAdd:zp!=="true",allowDelete:Hp!=="true"},[Vf]:{enabled:Wp!=="false",allowAdd:Gp!=="true",allowDelete:Yp!=="true"},[jf]:{enabled:Qp!=="false",allowAdd:Vp!=="true",allowDelete:qp!=="true"}}},gaTrackingId:nh,phCliVersion:rh},zn={},aa=(t,e)=>t.unstable_is?t.unstable_is(e):e===t,ca=t=>"init"in t,Ws=t=>!!t.write,ua=t=>"v"in t||"e"in t,Lr=t=>{if("e"in t)throw t.e;if((zn?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v},es=new WeakMap,la=t=>{var e;return ts(t)&&!!((e=es.get(t))!=null&&e[0])},lh=t=>{const e=es.get(t);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(n=>n()))},Yc=(t,e)=>{let n=es.get(t);if(!n){n=[!0,new Set],es.set(t,n);const r=()=>{n[0]=!1};t.then(r,r)}n[1].add(e)},ts=t=>typeof(t==null?void 0:t.then)=="function",Hc=(t,e,n)=>{n.p.has(t)||(n.p.add(t),e.then(()=>{n.p.delete(t)},()=>{n.p.delete(t)}))},Qs=(t,e,n)=>{const r=n(t),s="v"in r,i=r.v;if(ts(e))for(const o of r.d.keys())Hc(t,e,n(o));r.v=e,delete r.e,(!s||!Object.is(i,r.v))&&(++r.n,ts(i)&&lh(i))},da=(t,e,n)=>{var r;const s=new Set;for(const i of((r=n.get(t))==null?void 0:r.t)||[])n.has(i)&&s.add(i);for(const i of e.p)s.add(i);return s},dh=()=>{const t=new Set,e=()=>{t.forEach(n=>n())};return e.add=n=>(t.add(n),()=>{t.delete(n)}),e},Ks=()=>{const t={},e=new WeakMap,n=r=>{var s,i;(s=e.get(t))==null||s.forEach(o=>o(r)),(i=e.get(r))==null||i.forEach(o=>o())};return n.add=(r,s)=>{const i=r||t,o=(e.has(i)?e:e.set(i,new Set)).get(i);return o.add(s),()=>{o==null||o.delete(s),o.size||e.delete(i)}},n},fh=t=>(t.c||(t.c=Ks()),t.m||(t.m=Ks()),t.u||(t.u=Ks()),t.f||(t.f=dh()),t),ph=Symbol(),hh=(t=new WeakMap,e=new WeakMap,n=new WeakMap,r=new Set,s=new Set,i=new Set,o={},a=(f,...h)=>f.read(...h),c=(f,...h)=>f.write(...h),u=(f,h)=>{var m;return(m=f.unstable_onInit)==null?void 0:m.call(f,h)},d=(f,h)=>{var m;return(m=f.onMount)==null?void 0:m.call(f,h)},...l)=>{const f=l[0]||(w=>{if((zn?"production":void 0)!=="production"&&!w)throw new Error("Atom is undefined or null");let $=t.get(w);return $||($={d:new Map,p:new Set,n:0},t.set(w,$),u==null||u(w,X)),$}),h=l[1]||(()=>{const w=[],$=A=>{try{A()}catch(C){w.push(C)}};do{o.f&&$(o.f);const A=new Set,C=A.add.bind(A);r.forEach(L=>{var O;return(O=e.get(L))==null?void 0:O.l.forEach(C)}),r.clear(),i.forEach(C),i.clear(),s.forEach(C),s.clear(),A.forEach($),r.size&&m()}while(r.size||i.size||s.size);if(w.length)throw new AggregateError(w)}),m=l[2]||(()=>{const w=[],$=new WeakSet,A=new WeakSet,C=Array.from(r);for(;C.length;){const L=C[C.length-1],O=f(L);if(A.has(L)){C.pop();continue}if($.has(L)){if(n.get(L)===O.n)w.push([L,O]);else if((zn?"production":void 0)!=="production"&&n.has(L))throw new Error("[Bug] invalidated atom exists");A.add(L),C.pop();continue}$.add(L);for(const re of da(L,O,e))$.has(re)||C.push(re)}for(let L=w.length-1;L>=0;--L){const[O,re]=w[L];let ie=!1;for(const I of re.d.keys())if(I!==O&&r.has(I)){ie=!0;break}ie&&(E(O),B(O)),n.delete(O)}}),E=l[3]||(w=>{var $;const A=f(w);if(ua(A)&&(e.has(w)&&n.get(w)!==A.n||Array.from(A.d).every(([Y,j])=>E(Y).n===j)))return A;A.d.clear();let C=!0;const L=()=>{e.has(w)&&(B(w),m(),h())},O=Y=>{var j;if(aa(w,Y)){const V=f(Y);if(!ua(V))if(ca(Y))Qs(Y,Y.init,f);else throw new Error("no atom init");return Lr(V)}const q=E(Y);try{return Lr(q)}finally{A.d.set(Y,q.n),la(A.v)&&Hc(w,A.v,q),(j=e.get(Y))==null||j.t.add(w),C||L()}};let re,ie;const I={get signal(){return re||(re=new AbortController),re.signal},get setSelf(){return(zn?"production":void 0)!=="production"&&!Ws(w)&&console.warn("setSelf function cannot be used with read-only atom"),!ie&&Ws(w)&&(ie=(...Y)=>{if((zn?"production":void 0)!=="production"&&C&&console.warn("setSelf function cannot be called in sync"),!C)try{return P(w,...Y)}finally{m(),h()}}),ie}},k=A.n;try{const Y=a(w,O,I);return Qs(w,Y,f),ts(Y)&&(Yc(Y,()=>re==null?void 0:re.abort()),Y.then(L,L)),A}catch(Y){return delete A.v,A.e=Y,++A.n,A}finally{C=!1,k!==A.n&&n.get(w)===k&&(n.set(w,A.n),r.add(w),($=o.c)==null||$.call(o,w))}}),D=l[4]||(w=>{const $=[w];for(;$.length;){const A=$.pop(),C=f(A);for(const L of da(A,C,e)){const O=f(L);n.set(L,O.n),$.push(L)}}}),P=l[5]||((w,...$)=>{let A=!0;const C=O=>Lr(E(O)),L=(O,...re)=>{var ie;const I=f(O);try{if(aa(w,O)){if(!ca(O))throw new Error("atom not writable");const k=I.n,Y=re[0];Qs(O,Y,f),B(O),k!==I.n&&(r.add(O),(ie=o.c)==null||ie.call(o,O),D(O));return}else return P(O,...re)}finally{A||(m(),h())}};try{return c(w,C,L,...$)}finally{A=!1}}),B=l[6]||(w=>{var $;const A=f(w),C=e.get(w);if(C&&!la(A.v)){for(const[L,O]of A.d)if(!C.d.has(L)){const re=f(L);R(L).t.add(w),C.d.add(L),O!==re.n&&(r.add(L),($=o.c)==null||$.call(o,L),D(L))}for(const L of C.d||[])if(!A.d.has(L)){C.d.delete(L);const O=Q(L);O==null||O.t.delete(w)}}}),R=l[7]||(w=>{var $;const A=f(w);let C=e.get(w);if(!C){E(w);for(const L of A.d.keys())R(L).t.add(w);if(C={l:new Set,d:new Set(A.d.keys()),t:new Set},e.set(w,C),($=o.m)==null||$.call(o,w),Ws(w)){const L=()=>{let O=!0;const re=(...ie)=>{try{return P(w,...ie)}finally{O||(m(),h())}};try{const ie=d(w,re);ie&&(C.u=()=>{O=!0;try{ie()}finally{O=!1}})}finally{O=!1}};s.add(L)}}return C}),Q=l[8]||(w=>{var $;const A=f(w);let C=e.get(w);if(C&&!C.l.size&&!Array.from(C.t).some(L=>{var O;return(O=e.get(L))==null?void 0:O.d.has(w)})){C.u&&i.add(C.u),C=void 0,e.delete(w),($=o.u)==null||$.call(o,w);for(const L of A.d.keys()){const O=Q(L);O==null||O.t.delete(w)}return}return C}),N=[t,e,n,r,s,i,o,a,c,u,d,f,h,m,E,D,P,B,R,Q],X={get:w=>Lr(E(w)),set:(w,...$)=>{try{return P(w,...$)}finally{m(),h()}},sub:(w,$)=>{const C=R(w).l;return C.add($),h(),()=>{C.delete($),Q(w),h()}}};return Object.defineProperty(X,ph,{value:N}),X},Jc=hh,gh=fh,fa=Yc,no={};let mh=0;function Pe(t,e){const n=`atom${++mh}`,r={toString(){return(no?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof t=="function"?r.read=t:(r.init=t,r.read=yh,r.write=vh),e&&(r.write=e),r}function yh(t){return t(this)}function vh(t,e,n){return e(this,typeof n=="function"?n(t(this)):n)}const Eh=()=>{let t=0;const e=gh({}),n=new WeakMap,r=new WeakMap,s=Jc(n,r,void 0,void 0,void 0,void 0,e,void 0,(a,c,u,...d)=>t?u(a,...d):a.write(c,u,...d)),i=new Set;return e.m.add(void 0,a=>{i.add(a);const c=n.get(a);c.m=r.get(a)}),e.u.add(void 0,a=>{i.delete(a);const c=n.get(a);delete c.m}),Object.assign(s,{dev4_get_internal_weak_map:()=>(console.log("Deprecated: Use devstore from the devtools library"),n),dev4_get_mounted_atoms:()=>i,dev4_restore_atoms:a=>{const c={read:()=>null,write:(u,d)=>{++t;try{for(const[l,f]of a)"init"in l&&d(l,f)}finally{--t}}};s.set(c)}})};function Wc(){return(no?"production":void 0)!=="production"?Eh():Jc()}let Bn;function _h(){return Bn||(Bn=Wc(),(no?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=Bn),globalThis.__JOTAI_DEFAULT_STORE__!==Bn&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),Bn}const wh={},Qc=Xi(void 0);function Kc(t){return Zi(Qc)||_h()}function bh({children:t,store:e}){const n=on(void 0);return!e&&!n.current&&(n.current=Wc()),pp(Qc.Provider,{value:e||n.current},t)}const Ni=t=>typeof(t==null?void 0:t.then)=="function",Oi=t=>{t.status||(t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}))},Sh=bs.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(Oi(t),t)}),Xs=new WeakMap,pa=(t,e)=>{let n=Xs.get(t);return n||(n=new Promise((r,s)=>{let i=t;const o=u=>d=>{i===u&&r(d)},a=u=>d=>{i===u&&s(d)},c=()=>{try{const u=e();Ni(u)?(Xs.set(u,n),i=u,u.then(o(u),a(u)),fa(u,c)):r(u)}catch(u){s(u)}};t.then(o(t),a(t)),fa(t,c)}),Xs.set(t,n)),n};function jt(t,e){const{delay:n,unstable_promiseStatus:r=!bs.use}={},s=Kc(),[[i,o,a],c]=Bc(d=>{const l=s.get(t);return Object.is(d[0],l)&&d[1]===s&&d[2]===t?d:[l,s,t]},void 0,()=>[s.get(t),s,t]);let u=i;if((o!==s||a!==t)&&(c(),u=s.get(t)),Ce(()=>{const d=s.sub(t,()=>{if(r)try{const l=s.get(t);Ni(l)&&Oi(pa(l,()=>s.get(t)))}catch{}if(typeof n=="number"){setTimeout(c,n);return}c()});return c(),d},[s,t,n,r]),jc(u),Ni(u)){const d=pa(u,()=>s.get(t));return r&&Oi(d),Sh(d)}return u}function Th(t,e){const n=Kc();return ae((...s)=>{if((wh?"production":void 0)!=="production"&&!("write"in t))throw new Error("not writable atom");return n.set(t,...s)},[n,t])}function an(t,e){return[jt(t),Th(t)]}const Ih=Pe(gr);function Dh(){return an(Ih)}const qn={},ha=(t,e)=>t.unstable_is?t.unstable_is(e):e===t,ga=t=>"init"in t,Zs=t=>!!t.write,ma=t=>"v"in t||"e"in t,xr=t=>{if("e"in t)throw t.e;if((qn?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v},ns=new WeakMap,ya=t=>{var e;return rs(t)&&!!((e=ns.get(t))!=null&&e[0])},Nh=t=>{const e=ns.get(t);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(n=>n()))},Xc=(t,e)=>{let n=ns.get(t);if(!n){n=[!0,new Set],ns.set(t,n);const r=()=>{n[0]=!1};t.then(r,r)}n[1].add(e)},rs=t=>typeof(t==null?void 0:t.then)=="function",Zc=(t,e,n)=>{n.p.has(t)||(n.p.add(t),e.then(()=>{n.p.delete(t)},()=>{n.p.delete(t)}))},ei=(t,e,n)=>{const r=n(t),s="v"in r,i=r.v;if(rs(e))for(const o of r.d.keys())Zc(t,e,n(o));r.v=e,delete r.e,(!s||!Object.is(i,r.v))&&(++r.n,rs(i)&&Nh(i))},va=(t,e,n)=>{var r;const s=new Set;for(const i of((r=n.get(t))==null?void 0:r.t)||[])n.has(i)&&s.add(i);for(const i of e.p)s.add(i);return s},Oh=()=>{const t=new Set,e=()=>{t.forEach(n=>n())};return e.add=n=>(t.add(n),()=>{t.delete(n)}),e},ti=()=>{const t={},e=new WeakMap,n=r=>{var s,i;(s=e.get(t))==null||s.forEach(o=>o(r)),(i=e.get(r))==null||i.forEach(o=>o())};return n.add=(r,s)=>{const i=r||t,o=(e.has(i)?e:e.set(i,new Set)).get(i);return o.add(s),()=>{o==null||o.delete(s),o.size||e.delete(i)}},n},Ah=t=>(t.c||(t.c=ti()),t.m||(t.m=ti()),t.u||(t.u=ti()),t.f||(t.f=Oh()),t),Rh=Symbol(),Ch=(t=new WeakMap,e=new WeakMap,n=new WeakMap,r=new Set,s=new Set,i=new Set,o={},a=(f,...h)=>f.read(...h),c=(f,...h)=>f.write(...h),u=(f,h)=>{var m;return(m=f.unstable_onInit)==null?void 0:m.call(f,h)},d=(f,h)=>{var m;return(m=f.onMount)==null?void 0:m.call(f,h)},...l)=>{const f=l[0]||(w=>{if((qn?"production":void 0)!=="production"&&!w)throw new Error("Atom is undefined or null");let $=t.get(w);return $||($={d:new Map,p:new Set,n:0},t.set(w,$),u==null||u(w,X)),$}),h=l[1]||(()=>{const w=[],$=A=>{try{A()}catch(C){w.push(C)}};do{o.f&&$(o.f);const A=new Set,C=A.add.bind(A);r.forEach(L=>{var O;return(O=e.get(L))==null?void 0:O.l.forEach(C)}),r.clear(),i.forEach(C),i.clear(),s.forEach(C),s.clear(),A.forEach($),r.size&&m()}while(r.size||i.size||s.size);if(w.length)throw new AggregateError(w)}),m=l[2]||(()=>{const w=[],$=new WeakSet,A=new WeakSet,C=Array.from(r);for(;C.length;){const L=C[C.length-1],O=f(L);if(A.has(L)){C.pop();continue}if($.has(L)){if(n.get(L)===O.n)w.push([L,O]);else if((qn?"production":void 0)!=="production"&&n.has(L))throw new Error("[Bug] invalidated atom exists");A.add(L),C.pop();continue}$.add(L);for(const re of va(L,O,e))$.has(re)||C.push(re)}for(let L=w.length-1;L>=0;--L){const[O,re]=w[L];let ie=!1;for(const I of re.d.keys())if(I!==O&&r.has(I)){ie=!0;break}ie&&(E(O),B(O)),n.delete(O)}}),E=l[3]||(w=>{var $;const A=f(w);if(ma(A)&&(e.has(w)&&n.get(w)!==A.n||Array.from(A.d).every(([Y,j])=>E(Y).n===j)))return A;A.d.clear();let C=!0;const L=()=>{e.has(w)&&(B(w),m(),h())},O=Y=>{var j;if(ha(w,Y)){const V=f(Y);if(!ma(V))if(ga(Y))ei(Y,Y.init,f);else throw new Error("no atom init");return xr(V)}const q=E(Y);try{return xr(q)}finally{A.d.set(Y,q.n),ya(A.v)&&Zc(w,A.v,q),(j=e.get(Y))==null||j.t.add(w),C||L()}};let re,ie;const I={get signal(){return re||(re=new AbortController),re.signal},get setSelf(){return(qn?"production":void 0)!=="production"&&!Zs(w)&&console.warn("setSelf function cannot be used with read-only atom"),!ie&&Zs(w)&&(ie=(...Y)=>{if((qn?"production":void 0)!=="production"&&C&&console.warn("setSelf function cannot be called in sync"),!C)try{return P(w,...Y)}finally{m(),h()}}),ie}},k=A.n;try{const Y=a(w,O,I);return ei(w,Y,f),rs(Y)&&(Xc(Y,()=>re==null?void 0:re.abort()),Y.then(L,L)),A}catch(Y){return delete A.v,A.e=Y,++A.n,A}finally{C=!1,k!==A.n&&n.get(w)===k&&(n.set(w,A.n),r.add(w),($=o.c)==null||$.call(o,w))}}),D=l[4]||(w=>{const $=[w];for(;$.length;){const A=$.pop(),C=f(A);for(const L of va(A,C,e)){const O=f(L);n.set(L,O.n),$.push(L)}}}),P=l[5]||((w,...$)=>{let A=!0;const C=O=>xr(E(O)),L=(O,...re)=>{var ie;const I=f(O);try{if(ha(w,O)){if(!ga(O))throw new Error("atom not writable");const k=I.n,Y=re[0];ei(O,Y,f),B(O),k!==I.n&&(r.add(O),(ie=o.c)==null||ie.call(o,O),D(O));return}else return P(O,...re)}finally{A||(m(),h())}};try{return c(w,C,L,...$)}finally{A=!1}}),B=l[6]||(w=>{var $;const A=f(w),C=e.get(w);if(C&&!ya(A.v)){for(const[L,O]of A.d)if(!C.d.has(L)){const re=f(L);R(L).t.add(w),C.d.add(L),O!==re.n&&(r.add(L),($=o.c)==null||$.call(o,L),D(L))}for(const L of C.d||[])if(!A.d.has(L)){C.d.delete(L);const O=Q(L);O==null||O.t.delete(w)}}}),R=l[7]||(w=>{var $;const A=f(w);let C=e.get(w);if(!C){E(w);for(const L of A.d.keys())R(L).t.add(w);if(C={l:new Set,d:new Set(A.d.keys()),t:new Set},e.set(w,C),($=o.m)==null||$.call(o,w),Zs(w)){const L=()=>{let O=!0;const re=(...ie)=>{try{return P(w,...ie)}finally{O||(m(),h())}};try{const ie=d(w,re);ie&&(C.u=()=>{O=!0;try{ie()}finally{O=!1}})}finally{O=!1}};s.add(L)}}return C}),Q=l[8]||(w=>{var $;const A=f(w);let C=e.get(w);if(C&&!C.l.size&&!Array.from(C.t).some(L=>{var O;return(O=e.get(L))==null?void 0:O.d.has(w)})){C.u&&i.add(C.u),C=void 0,e.delete(w),($=o.u)==null||$.call(o,w);for(const L of A.d.keys()){const O=Q(L);O==null||O.t.delete(w)}return}return C}),N=[t,e,n,r,s,i,o,a,c,u,d,f,h,m,E,D,P,B,R,Q],X={get:w=>xr(E(w)),set:(w,...$)=>{try{return P(w,...$)}finally{m(),h()}},sub:(w,$)=>{const C=R(w).l;return C.add($),h(),()=>{C.delete($),Q(w),h()}}};return Object.defineProperty(X,Rh,{value:N}),X},eu=Ch,Lh=Ah,Ea=Xc,ro={};let xh=0;function Ie(t,e){const n=`atom${++xh}`,r={toString(){return(ro?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof t=="function"?r.read=t:(r.init=t,r.read=Mh,r.write=Ph),e&&(r.write=e),r}function Mh(t){return t(this)}function Ph(t,e,n){return e(this,typeof n=="function"?n(t(this)):n)}const kh=()=>{let t=0;const e=Lh({}),n=new WeakMap,r=new WeakMap,s=eu(n,r,void 0,void 0,void 0,void 0,e,void 0,(a,c,u,...d)=>t?u(a,...d):a.write(c,u,...d)),i=new Set;return e.m.add(void 0,a=>{i.add(a);const c=n.get(a);c.m=r.get(a)}),e.u.add(void 0,a=>{i.delete(a);const c=n.get(a);delete c.m}),Object.assign(s,{dev4_get_internal_weak_map:()=>(console.log("Deprecated: Use devstore from the devtools library"),n),dev4_get_mounted_atoms:()=>i,dev4_restore_atoms:a=>{const c={read:()=>null,write:(u,d)=>{++t;try{for(const[l,f]of a)"init"in l&&d(l,f)}finally{--t}}};s.set(c)}})};function $h(){return(ro?"production":void 0)!=="production"?kh():eu()}let jn;function Fh(){return jn||(jn=$h(),(ro?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=jn),globalThis.__JOTAI_DEFAULT_STORE__!==jn&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),jn}const Uh={},Bh=Xi(void 0);function tu(t){return Zi(Bh)||Fh()}const Ai=t=>typeof(t==null?void 0:t.then)=="function",Ri=t=>{t.status||(t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}))},jh=bs.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(Ri(t),t)}),ni=new WeakMap,_a=(t,e)=>{let n=ni.get(t);return n||(n=new Promise((r,s)=>{let i=t;const o=u=>d=>{i===u&&r(d)},a=u=>d=>{i===u&&s(d)},c=()=>{try{const u=e();Ai(u)?(ni.set(u,n),i=u,u.then(o(u),a(u)),Ea(u,c)):r(u)}catch(u){s(u)}};t.then(o(t),a(t)),Ea(t,c)}),ni.set(t,n)),n};function At(t,e){const{delay:n,unstable_promiseStatus:r=!bs.use}={},s=tu(),[[i,o,a],c]=Bc(d=>{const l=s.get(t);return Object.is(d[0],l)&&d[1]===s&&d[2]===t?d:[l,s,t]},void 0,()=>[s.get(t),s,t]);let u=i;if((o!==s||a!==t)&&(c(),u=s.get(t)),Ce(()=>{const d=s.sub(t,()=>{if(r)try{const l=s.get(t);Ai(l)&&Ri(_a(l,()=>s.get(t)))}catch{}if(typeof n=="number"){setTimeout(c,n);return}c()});return c(),d},[s,t,n,r]),jc(u),Ai(u)){const d=_a(u,()=>s.get(t));return r&&Ri(d),jh(d)}return u}function cn(t,e){const n=tu();return ae((...s)=>{if((Uh?"production":void 0)!=="production"&&!("write"in t))throw new Error("not writable atom");return n.set(t,...s)},[n,t])}var ri,wa;function Vh(){return wa||(wa=1,ri=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),ri}var Gh=Vh();const nu=ws(Gh),rr={},zh=t=>typeof(t==null?void 0:t.then)=="function";function qh(t=()=>{try{return window.localStorage}catch(n){(rr?"production":void 0)!=="production"&&typeof window<"u"&&console.warn(n);return}},e){var n;let r,s;const i={getItem:(c,u)=>{var d,l;const f=m=>{if(m=m||"",r!==m){try{s=JSON.parse(m,void 0)}catch{return u}r=m}return s},h=(l=(d=t())==null?void 0:d.getItem(c))!=null?l:null;return zh(h)?h.then(f):f(h)},setItem:(c,u)=>{var d;return(d=t())==null?void 0:d.setItem(c,JSON.stringify(u,void 0))},removeItem:c=>{var u;return(u=t())==null?void 0:u.removeItem(c)}},o=c=>(u,d,l)=>c(u,f=>{let h;try{h=JSON.parse(f||"")}catch{h=l}d(h)});let a;try{a=(n=t())==null?void 0:n.subscribe}catch{}return!a&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(a=(c,u)=>{if(!(t()instanceof window.Storage))return()=>{};const d=l=>{l.storageArea===t()&&l.key===c&&u(l.newValue)};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}}),a&&(i.subscribe=o(a)),i}qh();const si=new WeakMap,Yh=(t,e)=>(si.has(e)?si:si.set(e,t())).get(e),Hh=t=>typeof(t==null?void 0:t.then)=="function",ba={state:"loading"};function gn(t){return Yh(()=>{const e=new WeakMap,n=Ie(0);(rr?"production":void 0)!=="production"&&(n.debugPrivate=!0);const r=Ie((s,{setSelf:i})=>{s(n);let o;try{o=s(t)}catch(d){return{state:"hasError",error:d}}if(!Hh(o))return{state:"hasData",data:o};const a=o,c=e.get(a);if(c)return c;a.then(d=>{e.set(a,{state:"hasData",data:d}),i()},d=>{e.set(a,{state:"hasError",error:d}),i()});const u=e.get(a);return u||(e.set(a,ba),ba)},(s,i)=>{i(n,o=>o+1)});return(rr?"production":void 0)!=="production"&&(r.debugPrivate=!0),Ie(s=>s(r))},t)}const Sa=(t,e,n)=>(e.has(n)?e:e.set(n,t())).get(n),Jh=new WeakMap,Wh=(t,e,n)=>{const r=Sa(()=>new WeakMap,Jh,e);return Sa(t,r,n)},Qh=t=>typeof(t==null?void 0:t.then)=="function",Kh=()=>{};function mn(t,e=Kh){return Wh(()=>{const n=new WeakMap,r=new WeakMap,s=Ie(0);(rr?"production":void 0)!=="production"&&(s.debugPrivate=!0);const i=Ie((o,{setSelf:a})=>{o(s);const c=o(i),u=o(t);if(!Qh(u))return{v:u};if(u!==(c==null?void 0:c.p)&&u.then(d=>{r.set(u,d),a()},d=>{n.set(u,d),a()}),n.has(u))throw n.get(u);return r.has(u)?{p:u,v:r.get(u)}:c&&"v"in c?{p:u,f:e(c.v),v:c.v}:{p:u,f:e()}},(o,a)=>{a(s,c=>c+1)});return i.init=void 0,(rr?"production":void 0)!=="production"&&(i.debugPrivate=!0),Ie(o=>{const a=o(i);return"f"in a?a.f:a.v},(o,a,...c)=>a(t,...c))},t,e)}function Ci(t){if(!t)return"PUBLIC";const e="readContext"in t,{sharingType:n}=e?{sharingType:"PUBLIC"}:t.state.local,r=n==null?void 0:n.toUpperCase();return r==="PRIVATE"?"LOCAL":r}function Xh(t){if(!t)return!1;const e="readContext"in t,{availableOffline:n}=e?{availableOffline:!1}:t.state.local;return n??!1}function yb(t){if(t)return{id:t.header.id,name:t.state.global.name,kind:"FOLDER",parentFolder:null}}async function Zh(t,e){if(!t||!e)return[];const n=await t.getDocuments(e);return await Promise.all(n.map(s=>t.getDocument(s)))}async function eg(t){if(!t)return[];const e=await t.getDrives();return await Promise.all(e.map(r=>t.getDrive(r)))}function vb(t){return t.toSorted((e,n)=>e.name.localeCompare(n.name))}function Eb(t){return t?t.kind.toUpperCase()==="FILE":!1}function tg(t){return t?t.kind.toUpperCase()==="FOLDER":!1}const Ye="NOT_SET";function mr(){return new Promise(()=>{})}const ss=Ie(Ye);ss.debugLabel="baseProcessorManagerAtom";const ru=Ie(t=>t(ss)!==Ye);ru.debugLabel="processorManagerInitializedAtom";const Ts=Ie(t=>{const e=t(ss);return e===Ye?mr():e},(t,e,n)=>{e(ss,n)});Ts.debugLabel="processorManagerAtom";const ng=gn(Ts);ng.debugLabel="loadableProcessorManagerAtom";const rg=mn(Ts);rg.debugLabel="unwrappedProcessorManagerAtom";const Kn=Ie(Ye);Kn.debugLabel="baseDrivesAtom";const su=Ie(t=>t(Kn)!==Ye);su.debugLabel="drivesInitializedAtom";const yr=Ie(async t=>{const e=t(Kn);return e===Ye?mr():e},async(t,e)=>{const n=t(Kn),r=window.reactor,s=await eg(r);nu(s,n)||e(Kn,s)});yr.debugLabel="drivesAtom";const sg=gn(yr);sg.debugLabel="loadableDrivesAtom";const iu=mn(yr);iu.debugLabel="unwrappedDrivesAtom";const is=Ie(Ye);is.debugLabel="selectedDriveIdAtom";const so=Ie(t=>t(is)!==Ye);so.debugLabel="driveIdInitializedAtom";const Ln=Ie(async t=>{const e=t(is),n=await t(yr);return e===Ye?mr():n==null?void 0:n.find(s=>s.header.id===e)},(t,e,n)=>{e(is,n),e(sr,void 0)});Ln.debugLabel="selectedDriveAtom";const ou=gn(Ln);ou.debugLabel="loadableSelectedDriveAtom";const au=mn(Ln);au.debugLabel="unwrappedSelectedDriveAtom";const vr=Ie(async t=>{const e=await t(Ln);return e==null?void 0:e.state.global.nodes});vr.debugLabel="nodesAtom";const ig=gn(vr);ig.debugLabel="loadableNodesAtom";const og=mn(vr);og.debugLabel="unwrappedNodesAtom";const sr=Ie(Ye);sr.debugLabel="selectedNodeIdAtom";const cu=Ie(t=>t(sr)!==Ye);cu.debugLabel="selectedNodeIdInitializedAtom";const Er=Ie(async t=>{const e=t(sr),n=await t(vr);return e===Ye?mr():n==null?void 0:n.find(r=>r.id===e)},(t,e,n)=>{e(sr,n)});Er.debugLabel="selectedNodeAtom";const io=Ie(async t=>{const e=await t(vr),n=await t(Er),r=e==null?void 0:e.filter(tg);return r==null?void 0:r.find(s=>s.id===(n==null?void 0:n.id))});io.debugLabel="selectedFolderAtom";const ag=gn(io);ag.debugLabel="loadableSelectedFolderAtom";const cg=mn(io);cg.debugLabel="unwrappedSelectedFolderAtom";const Xn=Ie(Ye);Xn.debugLabel="baseDocumentsAtom";const uu=Ie(t=>t(Xn)!==Ye);uu.debugLabel="documentsInitializedAtom";const _r=Ie(t=>{const e=t(Xn);return e===Ye?mr():e},async(t,e,n)=>{const r=t(Xn),s=window.reactor,i=await Zh(s,n);nu(i,r)||e(Xn,i)});_r.debugLabel="documentsAtom";const ug=gn(_r);ug.debugLabel="loadableDocumentsAtom";const lg=mn(_r);lg.debugLabel="unwrappedDocumentsAtom";const oo=Ie(async t=>{const e=await t(_r),n=await t(Er);return e==null?void 0:e.find(r=>r.header.id===(n==null?void 0:n.id))});oo.debugLabel="selectedDocumentAtom";const dg=gn(oo);dg.debugLabel="loadableSelectedDocumentAtom";const fg=mn(oo);fg.debugLabel="unwrappedSelectedDocumentAtom";const Ta=t=>{const e=t.operations.global.map(r=>(delete r.resultingState,r)),n=t.operations.local.map(r=>(delete r.resultingState,r));return{...t,operations:{global:e,local:n}}};class pg{constructor(e){F(this,"index",0);F(this,"cache");this.cache=e}createStorage(){const e=this.index;this.index+=1;function n(s){return`${e}-${s}`}const r={get:s=>this.cache.get(n(s)),set:(s,i)=>(this.cache.set(n(s),i),r),delete:s=>this.cache.delete(n(s)),clear:()=>{this.cache.clear()}};return r}}class lu{constructor(e=new Map){F(this,"cache");F(this,"cacheStorageManager");F(this,"idToDocument");F(this,"idToDrive");F(this,"slugToDriveId");this.cache=e,this.cacheStorageManager=new pg(e),this.idToDocument=this.cacheStorageManager.createStorage(),this.idToDrive=this.cacheStorageManager.createStorage(),this.slugToDriveId=this.cacheStorageManager.createStorage()}clear(){this.idToDocument.clear(),this.idToDrive.clear(),this.slugToDriveId.clear()}async setDocument(e,n){const r=Ta(n);this.idToDocument.set(e,r)}async getDocument(e){return this.idToDocument.get(e)}async deleteDocument(e){return this.idToDocument.delete(e)}async setDrive(e,n){const r=Ta(n);this.idToDrive.set(e,r)}async getDrive(e){return this.idToDrive.get(e)}async deleteDrive(e){const n=this.idToDrive.get(e);if(!n)return!1;const r=n.header.slug.length>0?n.header.slug:e;return r&&this.slugToDriveId.delete(r),this.idToDrive.delete(e)}async setDriveBySlug(e,n){const r=n.header.id;this.slugToDriveId.set(e,r),this.setDrive(r,n)}async getDriveBySlug(e){const n=this.slugToDriveId.get(e);if(n)return this.getDrive(n)}async deleteDriveBySlug(e){const n=this.slugToDriveId.get(e);return n?(this.slugToDriveId.delete(e),this.deleteDrive(n)):!1}}const du={id:"powerhouse/document-drive",name:"DocumentDrive",extension:"phdd",description:"",author:{name:"Powerhouse Inc",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type FolderNode {
|
|
4
|
-
id: String!
|
|
5
|
-
name: String!
|
|
6
|
-
kind: String!
|
|
7
|
-
parentFolder: String
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type FileNode {
|
|
11
|
-
id: String!
|
|
12
|
-
name: String!
|
|
13
|
-
kind: String!
|
|
14
|
-
documentType: String!
|
|
15
|
-
parentFolder: String
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
union Node = FolderNode | FileNode
|
|
19
|
-
|
|
20
|
-
type DocumentDriveState {
|
|
21
|
-
name: String!
|
|
22
|
-
nodes: [Node!]!
|
|
23
|
-
icon: String
|
|
24
|
-
}`,initialValue:'"{\\"name\\":\\"\\",\\"nodes\\":[],\\"icon\\":null}"',examples:[]},local:{schema:`type ListenerFilter {
|
|
25
|
-
documentType: [String!]!
|
|
26
|
-
documentId: [ID!]
|
|
27
|
-
scope: [String!]
|
|
28
|
-
branch: [String!]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
enum TransmitterType {
|
|
32
|
-
Internal,
|
|
33
|
-
SwitchboardPush,
|
|
34
|
-
PullResponder,
|
|
35
|
-
SecureConnect,
|
|
36
|
-
MatrixConnect,
|
|
37
|
-
RESTWebhook
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
type ListenerCallInfo {
|
|
41
|
-
transmitterType: TransmitterType
|
|
42
|
-
name: String
|
|
43
|
-
data: String
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type Listener {
|
|
47
|
-
listenerId: ID!
|
|
48
|
-
label: String
|
|
49
|
-
block: Boolean!
|
|
50
|
-
system: Boolean!
|
|
51
|
-
filter: ListenerFilter!
|
|
52
|
-
callInfo: ListenerCallInfo
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
enum TriggerType {
|
|
56
|
-
PullResponder
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type PullResponderTriggerData {
|
|
60
|
-
listenerId: ID!
|
|
61
|
-
url: String!
|
|
62
|
-
interval: String!
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
union TriggerData = PullResponderTriggerData
|
|
66
|
-
|
|
67
|
-
type Trigger {
|
|
68
|
-
id: ID!
|
|
69
|
-
type: TriggerType!
|
|
70
|
-
data: TriggerData
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
type DocumentDriveLocalState{
|
|
74
|
-
sharingType: String
|
|
75
|
-
listeners: [Listener!]!
|
|
76
|
-
triggers: [Trigger!]!
|
|
77
|
-
availableOffline: Boolean!
|
|
78
|
-
}`,initialValue:'"{ \\"listeners\\": [], \\"triggers\\": [], \\"sharingType\\": \\"private\\", \\"availableOffline\\": false}"',examples:[]}},modules:[{id:"GRzuvv78tBvmB6ciitokLfonNHA=",name:"Node",description:"",operations:[{id:"7xiTdxonc9yEASR8sfV/KnbSV10=",name:"ADD_FILE",description:"",schema:`input AddFileInput {
|
|
79
|
-
id: ID!
|
|
80
|
-
name: String!
|
|
81
|
-
documentType: String!
|
|
82
|
-
parentFolder: ID
|
|
83
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"4lzNMMKKdIAtEU6i12xLgi9hp+U=",name:"ADD_FOLDER",description:"",schema:`input AddFolderInput {
|
|
84
|
-
id: ID!
|
|
85
|
-
name: String!
|
|
86
|
-
parentFolder: ID
|
|
87
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"53jH2/3TWTTcgCJiv2C+BmuC6i0=",name:"DELETE_NODE",description:"",schema:`input DeleteNodeInput {
|
|
88
|
-
id: ID!
|
|
89
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"pNn+Y1/HVq/GNMk7t0u3g3gtMLE=",name:"UPDATE_FILE",description:"",schema:`input UpdateFileInput {
|
|
90
|
-
id: ID!
|
|
91
|
-
parentFolder: ID
|
|
92
|
-
name: String
|
|
93
|
-
documentType: String
|
|
94
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"P0x1M8Mnt+Q/+9nggkwgVbfybsc=",name:"UPDATE_NODE",description:"",schema:`input UpdateNodeInput {
|
|
95
|
-
id: ID!
|
|
96
|
-
parentFolder: ID
|
|
97
|
-
name: String
|
|
98
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"vnQ7OB5b3wGLgjhbgJqAIpA+JLE=",name:"COPY_NODE",description:"",schema:`input CopyNodeInput {
|
|
99
|
-
srcId: ID!
|
|
100
|
-
targetId: ID!
|
|
101
|
-
targetName: String
|
|
102
|
-
targetParentFolder: ID
|
|
103
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"VNyiD/sNGzk6k9A1Qe7s8dmrJxA=",name:"MOVE_NODE",description:"",schema:`input MoveNodeInput {
|
|
104
|
-
srcFolder: ID!
|
|
105
|
-
targetParentFolder: ID
|
|
106
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"}]},{id:"0dHwHlxOM9x0vMZ+gLnKxf2qTEo=",name:"Drive",description:"",operations:[{id:"qGCiPGpTt/cyz3HzyrBn92z1dsU=",name:"SET_DRIVE_NAME",description:"",schema:`input SetDriveNameInput {
|
|
107
|
-
name: String!
|
|
108
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"qGCiPGpTt/cyz3HzyrBn92z30dsU=",name:"SET_DRIVE_ICON",description:"",schema:`input SetDriveIconInput {
|
|
109
|
-
icon: String!
|
|
110
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"qGCiPGpTt/cyz3HzyrBn92z2dsU=",name:"SET_SHARING_TYPE",description:"",schema:`input SetSharingTypeInput {
|
|
111
|
-
type: String!
|
|
112
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z3dsU=",name:"SET_AVAILABLE_OFFLINE",description:"",schema:`input SetAvailableOfflineInput {
|
|
113
|
-
availableOffline: Boolean!
|
|
114
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z9dsU=",name:"ADD_LISTENER",description:"",schema:`input AddListenerInput {
|
|
115
|
-
listener: Listener!
|
|
116
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z10dsU=",name:"REMOVE_LISTENER",description:"",schema:`input RemoveListenerInput {
|
|
117
|
-
listenerId: String!
|
|
118
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z20dsU=",name:"ADD_TRIGGER",description:"",schema:`input AddTriggerInput {
|
|
119
|
-
trigger: Trigger!
|
|
120
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z30dsU=",name:"REMOVE_TRIGGER",description:"",schema:`input RemoveTriggerInput {
|
|
121
|
-
triggerId: String!
|
|
122
|
-
}`,template:"",reducer:"",errors:[],examples:[],scope:"local"}]}]}]},ao=du.id,hg=t=>t!=null;Gf().refine(t=>hg(t));const gg=Pc(["Internal","MatrixConnect","PullResponder","RESTWebhook","SecureConnect","SwitchboardPush"]),mg=Pc(["PullResponder"]);function fu(){return Me({documentType:de(),id:de(),name:de(),parentFolder:de().nullish()})}function pu(){return Me({id:de(),name:de(),parentFolder:de().nullish()})}function hu(){return Me({listener:yg()})}function gu(){return Me({trigger:wg()})}function mu(){return Me({srcId:de(),targetId:de(),targetName:de().nullish(),targetParentFolder:de().nullish()})}function yu(){return Me({id:de()})}function yg(){return Me({__typename:pr("Listener").optional(),block:Ii(),callInfo:vg().nullable(),filter:Eg(),label:de().nullable(),listenerId:de(),system:Ii()})}function vg(){return Me({__typename:pr("ListenerCallInfo").optional(),data:de().nullable(),name:de().nullable(),transmitterType:gg.nullable()})}function Eg(){return Me({__typename:pr("ListenerFilter").optional(),branch:Rr(de()).nullable(),documentId:Rr(de()).nullable(),documentType:Rr(de()),scope:Rr(de()).nullable()})}function vu(){return Me({srcFolder:de(),targetParentFolder:de().nullish()})}function _g(){return Me({__typename:pr("PullResponderTriggerData").optional(),interval:de(),listenerId:de(),url:de()})}function Eu(){return Me({listenerId:de()})}function _u(){return Me({triggerId:de()})}function wu(){return Me({availableOffline:Ii()})}function bu(){return Me({icon:de()})}function Su(){return Me({name:de()})}function Tu(){return Me({type:de()})}function wg(){return Me({__typename:pr("Trigger").optional(),data:bg().nullable(),id:de(),type:mg})}function bg(){return _g()}function Iu(){return Me({documentType:de().nullish(),id:de(),name:de().nullish(),parentFolder:de().nullish()})}function Du(){return Me({id:de(),name:de().nullish(),parentFolder:de().nullish()})}const Mt={setDriveNameOperation(t,e,n){t.name=e.input.name},setDriveIconOperation(t,e,n){t.icon=e.input.icon},setSharingTypeOperation(t,e,n){t.sharingType=e.input.type},setAvailableOfflineOperation(t,e,n){t.availableOffline=e.input.availableOffline},addListenerOperation(t,e,n){if(t.listeners.find(r=>r.listenerId===e.input.listener.listenerId))throw new Error(`A listener with Id: ${e.input.listener.listenerId} already exists`);t.listeners.push(e.input.listener)},removeListenerOperation(t,e,n){t.listeners=t.listeners.filter(r=>r.listenerId!==e.input.listenerId)},addTriggerOperation(t,e,n){if(t.triggers.find(r=>r.id===e.input.trigger.id))throw new Error(`A trigger with Id: ${e.input.trigger.id} already exists`);t.triggers.push(e.input.trigger)},removeTriggerOperation(t,e,n){t.triggers=t.triggers.filter(r=>r.id!==e.input.triggerId)}};class Sg extends Error{constructor(n,r){super(`Document model "${n}" not found`,{cause:r});F(this,"id");this.id=n}}class Ge extends Error{constructor(n,r,s,i){super(s,{cause:i??r});F(this,"status");F(this,"operation");this.status=n,this.operation=r,i instanceof Error&&(this.stack=i.stack)}}class Tg extends Ge{constructor(e,n){super("CONFLICT",n,`Conflicting operation on index ${n.index}`,{existingOperation:e,newOperation:n})}}class os extends Error{constructor(e){super(`Invalid document id: ${e}`)}}class Nu extends Error{constructor(e){super(`Invalid slug: ${e}`)}}class bn extends Error{constructor(n){super(`Document with id ${n} uses id or slug that already exists`);F(this,"documentId");this.documentId=n}}class Nt extends Error{constructor(n){super(`Document with id ${n} not found`);F(this,"documentId");this.documentId=n}}class Li extends Error{constructor(n){super(`Sync unit ${JSON.stringify(n)} not found`);F(this,"syncUnitId");this.syncUnitId=n}}const as=t=>t&&t.length>0&&/^[a-zA-Z0-9_-]+$/.test(t),Ou=t=>t&&t.length>0&&/^[a-zA-Z0-9_-]+$/.test(t),Vn=t=>t&&t.length>0&&!t.includes("*")?new Set(t):null,Au=t=>({parentId:Vn(t.parentId),documentId:Vn(t.documentId),documentModelType:Vn(t.documentModelType),scope:Vn(t.scope),branch:Vn(t.branch)});function ir(t){return t.kind==="file"}function co(t){return t.kind==="folder"}function Ru(t,e){if(t.parentFolder){const n=e.find(r=>r.id===t.parentFolder);if(!n)throw new Error(`Parent node with id ${t.parentFolder} not found`);return[n,...Ru(n,e)]}else return[]}function or(t,e){const n=e.filter(s=>s.parentFolder===t.id),r=n.map(s=>or(s,e));return[...n,...r.flat()]}function Cu(t,e,n){const r=n.find(c=>c.id===t.srcId);if(!r)throw new Error(`Node with id ${t.srcId} not found`);const s=[{...r,name:t.targetName||r.name,parentFolder:t.targetParentFolder||null},...or(r,n)],i={};t.targetParentFolder&&(i[t.targetParentFolder]=t.targetParentFolder);const o=c=>{let u=i[c.id];if(!u){const d=c.id;u=e(c),i[d]=u}return u};return s.map(c=>({srcId:c.id,targetId:o(c),targetName:c.name,targetParentFolder:c.parentFolder?i[c.parentFolder]:null}))}function Lu(t,e){let n=0;const r=new RegExp(`^${xu(e)} \\(copy\\)(?: (\\d+))?$`);for(const s of t){const i=s.match(r);if(i){const o=i[1]?parseInt(i[1],10):1;o>n&&(n=o)}}return n+1}function xu(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kt(t){const{nodes:e,targetParentFolder:n,srcName:r}=t,s=e.filter(a=>n===""?a.parentFolder===null:a.parentFolder===n).map(a=>a.name);return s.includes(r)?`${r} (copy) ${Lu(s,r)}`:r}const Ig=Object.freeze(Object.defineProperty({__proto__:null,escapeRegExp:xu,generateNodesCopy:Cu,getAncestors:Ru,getDescendants:or,getNextCopyNumber:Lu,handleTargetNameCollisions:Kt,isFileNode:ir,isFolderNode:co},Symbol.toStringTag,{value:"Module"})),Ht={addFileOperation(t,e,n){if(t.nodes.find(i=>i.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);if(!as(e.input.id))throw new os(e.input.id);const r=Kt({nodes:t.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null}),s={id:e.input.id,name:r,kind:"file",parentFolder:e.input.parentFolder??null,documentType:e.input.documentType};t.nodes.push(s),n==null||n({type:"CREATE_CHILD_DOCUMENT",input:{id:e.input.id,documentType:e.input.documentType}})},addFolderOperation(t,e){if(t.nodes.find(r=>r.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);const n=Kt({nodes:t.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null});t.nodes.push({...e.input,name:n,kind:"folder",parentFolder:e.input.parentFolder??null})},deleteNodeOperation(t,e,n){const r=t.nodes.find(i=>i.id===e.input.id);if(!r)throw new Error(`Node with id ${e.input.id} not found`);const s=or(r,t.nodes);t.nodes=t.nodes.filter(i=>i.id!==e.input.id&&!s.find(o=>o.id===i.id)),[r,...s].filter(i=>ir(i)).forEach(i=>{n==null||n({type:"DELETE_CHILD_DOCUMENT",input:{id:i.id}})})},updateFileOperation(t,e){t.nodes=t.nodes.map(n=>n.id===e.input.id?{...n,name:Kt({nodes:t.nodes,srcName:e.input.name??n.name,targetParentFolder:e.input.parentFolder||null}),documentType:e.input.documentType??n.documentType}:n)},updateNodeOperation(t,e){t.nodes=t.nodes.map(n=>n.id===e.input.id?{...n,name:Kt({nodes:t.nodes,srcName:e.input.name??n.name,targetParentFolder:e.input.parentFolder||null}),parentFolder:e.input.parentFolder===null?null:n.parentFolder}:n)},copyNodeOperation(t,e,n){const r=t.nodes.find(c=>c.id===e.input.srcId);if(!r)throw new Error(`Node with id ${e.input.srcId} not found`);if(!as(e.input.targetId))throw new os(e.input.targetId);if(t.nodes.find(c=>c.id===e.input.targetId))throw new Error(`Node with id ${e.input.targetId} already exists`);const i=Kt({nodes:t.nodes,srcName:e.input.targetName||r.name,targetParentFolder:e.input.targetParentFolder||null}),o={...r,id:e.input.targetId,slug:e.input.targetId,name:i,parentFolder:e.input.targetParentFolder||null};t.nodes.push(o),ir(o)&&(n==null||n({type:"COPY_CHILD_DOCUMENT",input:{id:e.input.srcId,newId:e.input.targetId}}))},moveNodeOperation(t,e){if(e.input.srcFolder===e.input.targetParentFolder)throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");const n=t.nodes.find(s=>s.id===e.input.srcFolder);if(!n)throw new Error(`Node with id ${e.input.srcFolder} not found`);const r=Kt({nodes:t.nodes,srcName:n.name,targetParentFolder:e.input.targetParentFolder||null});if(co(n)&&or(n,t.nodes).find(i=>i.id===e.input.targetParentFolder))throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");t.nodes=t.nodes.map(s=>s.id===e.input.srcFolder?{...s,name:r,parentFolder:e.input.targetParentFolder||null}:s)}},Dg=(t,e,n)=>{if(qf(e))return t;const r=e;switch(r.type){case"ADD_FILE":fu().parse(r.input),Ht.addFileOperation(t[r.scope],e,n);break;case"ADD_FOLDER":pu().parse(r.input),Ht.addFolderOperation(t[r.scope],e,n);break;case"DELETE_NODE":yu().parse(r.input),Ht.deleteNodeOperation(t[r.scope],e,n);break;case"UPDATE_FILE":Iu().parse(r.input),Ht.updateFileOperation(t[r.scope],e,n);break;case"UPDATE_NODE":Du().parse(r.input),Ht.updateNodeOperation(t[r.scope],e,n);break;case"COPY_NODE":mu().parse(r.input),Ht.copyNodeOperation(t[r.scope],e,n);break;case"MOVE_NODE":vu().parse(r.input),Ht.moveNodeOperation(t[r.scope],e,n);break;case"SET_DRIVE_NAME":Su().parse(r.input),Mt.setDriveNameOperation(t[r.scope],e,n);break;case"SET_DRIVE_ICON":bu().parse(r.input),Mt.setDriveIconOperation(t[r.scope],e,n);break;case"SET_SHARING_TYPE":Tu().parse(r.input),Mt.setSharingTypeOperation(t[r.scope],e,n);break;case"SET_AVAILABLE_OFFLINE":wu().parse(r.input),Mt.setAvailableOfflineOperation(t[r.scope],e,n);break;case"ADD_LISTENER":hu().parse(r.input),Mt.addListenerOperation(t[r.scope],e,n);break;case"REMOVE_LISTENER":Eu().parse(r.input),Mt.removeListenerOperation(t[r.scope],e,n);break;case"ADD_TRIGGER":gu().parse(r.input),Mt.addTriggerOperation(t[r.scope],e,n);break;case"REMOVE_TRIGGER":_u().parse(r.input),Mt.removeTriggerOperation(t[r.scope],e,n);break;default:return t}},ar=zf(Dg),Ng={name:"",nodes:[],icon:null},Og={listeners:[],triggers:[],sharingType:"private",availableOffline:!1},Sn={fileExtension:"phdd",createState(t){return{global:{...Ng,...t==null?void 0:t.global},local:{...Og,...t==null?void 0:t.local}}},createExtendedState(t){return Wf({...t},Sn.createState)},createDocument(t){const e=Jf(Sn.createExtendedState(t),Sn.createState);return e.header.documentType=ao,e.header.id=Et(),e},saveToFile(t,e,n){return Hf(t,e,"phdd",n)},saveToFileHandle(t,e){return $c(t,e)},loadFromFile(t){return Yf(t,ar)},loadFromInput(t){return kc(t,ar)}},Ag=Sn.createDocument;function Mu(t){return t&&typeof t=="object"&&"synchronizationUnits"in t?Ve("ADD_FILE",{...t},void 0,void 0,"global"):Ve("ADD_FILE",{...t},void 0,fu,"global")}const Pu=t=>Ve("ADD_FOLDER",{...t},void 0,pu,"global"),ku=t=>Ve("DELETE_NODE",{...t},void 0,yu,"global"),$u=t=>Ve("UPDATE_FILE",{...t},void 0,Iu,"global"),Fu=t=>Ve("UPDATE_NODE",{...t},void 0,Du,"global"),Uu=t=>Ve("COPY_NODE",{...t},void 0,mu,"global"),Bu=t=>Ve("MOVE_NODE",{...t},void 0,vu,"global"),ju=t=>Ve("SET_DRIVE_NAME",{...t},void 0,Su,"global"),Rg=t=>Ve("SET_DRIVE_ICON",{...t},void 0,bu,"global"),uo=t=>Ve("SET_SHARING_TYPE",{...t},void 0,Tu,"local"),Vu=t=>Ve("SET_AVAILABLE_OFFLINE",{...t},void 0,wu,"local"),Cg=t=>Ve("ADD_LISTENER",{...t},void 0,hu,"local"),Gu=t=>Ve("REMOVE_LISTENER",{...t},void 0,Eu,"local"),zu=t=>Ve("ADD_TRIGGER",{...t},void 0,gu,"local"),lo=t=>Ve("REMOVE_TRIGGER",{...t},void 0,_u,"local"),Lg=Object.freeze(Object.defineProperty({__proto__:null,addFile:Mu,addFolder:Pu,addListener:Cg,addTrigger:zu,copyNode:Uu,deleteNode:ku,moveNode:Bu,removeListener:Gu,removeTrigger:lo,setAvailableOffline:Vu,setDriveIcon:Rg,setDriveName:ju,setSharingType:uo,updateFile:$u,updateNode:Fu},Symbol.toStringTag,{value:"Module"})),xg={...Sn,...Ig},Mg={...Qf,...Lg},qu={reducer:ar,actions:Mg,utils:xg,documentModel:du},Pg=qu;let Yu=()=>({emit(t,...e){for(let n=this.events[t]||[],r=0,s=n.length;r<s;r++)n[r](...e)},events:{},on(t,e){var n;return((n=this.events)[t]||(n[t]=[])).push(e),()=>{var r;this.events[t]=(r=this.events[t])==null?void 0:r.filter(s=>e!==s)}}});class kg{constructor(e){F(this,"id");F(this,"running",!1);F(this,"deleted",!1);F(this,"items",[]);F(this,"dependencies",new Array);this.id=e}async isRunning(){return this.running}async setRunning(e){this.running=e}async setDeleted(e){this.deleted=e}async isDeleted(){return this.deleted}async addJob(e){return this.items.push(e),Promise.resolve()}async getNextJob(){const e=this.items.shift();return Promise.resolve(e)}async amountOfJobs(){return Promise.resolve(this.items.length)}getId(){return this.id}async isBlocked(){return this.running||this.deleted||this.dependencies.length>0}async getJobs(){return this.items}async addDependency(e){this.dependencies.includes(e.jobId)||this.dependencies.push(e.jobId)}async removeDependency(e){const n=this.dependencies.indexOf(e.jobId);n>-1&&this.dependencies.splice(n,1)}}function zr(t){return"documentType"in t}function Hu(t){return"operations"in t}function $g(t){return"actions"in t}class Ju{constructor(e=1,n=0){F(this,"logger",wt(["EventQueueManager"]));F(this,"emitter",Yu());F(this,"queues",new Map);F(this,"globalQueue",new Array);F(this,"isFindingJob",!1);F(this,"maxWorkers");F(this,"workers");F(this,"runningJobs",new Array);F(this,"timeout");F(this,"delegate");F(this,"onError");this.maxWorkers=e,this.workers=0,this.timeout=n}async init(e,n){this.delegate=e,this.onError=n;function r(s){return async(...i)=>{try{await s(...i)}catch(o){throw o instanceof Error?o:new Error(JSON.stringify(o))}}}return this.emitter.on("jobAdded",r(async s=>{this.logger.verbose("Added job",s),await this.processNextJob()})),this.emitter.on("jobStarted",r(async s=>{this.logger.verbose("Started job",s.jobId),this.runningJobs.push(s),await this.processNextJob()})),this.emitter.on("jobCompleted",r(async(s,i)=>{this.logger.verbose("Completed job",s.jobId),await this.handleJobCompleted(s,i)})),this.emitter.on("jobFailed",r(async(s,i)=>{this.logger.error("Failed job",s,i),this.removeJob(s),n(i),await this.processNextJob()})),Promise.resolve()}async addJob(e){var c;if(!this.delegate)throw new Error("No server delegate defined");const n=Et(),r=zr(e),s=zr(e)?void 0:Hu(e)?e.operations:e.actions;if(!r&&!(s!=null&&s.length))throw new Error("Job has no operations or actions: "+JSON.stringify(e));const i=((c=s==null?void 0:s.at(0))==null?void 0:c.scope)??"global";if(s!=null&&s.find(u=>u.scope!==i))throw new Error("Job has actions with different scopes");const o=this.getQueue(e.documentId,i);if(!zr(e)&&await o.isDeleted())throw new Error("Job has operations for deleted document");const a=Object.freeze({jobId:n,...e});return await o.addJob(a),this.globalQueue.push({jobId:n,documentId:e.documentId,scope:i,timestamp:new Date().toUTCString()}),this.emit("jobAdded",a),n}getQueue(e,n){let r=this.queues.get(e);r||(r=new Map,this.queues.set(e,r));let s=r.get(n);return s||(s=new kg(n),r.set(n,s)),s}getDocumentQueues(e){return this.queues.get(e)}removeQueue(e,n){const r=this.queues.get(e),s=r==null?void 0:r.delete(n);return s&&this.emit("queueRemoved",{documentId:e,scope:n}),s}removeDocumentQueues(e){const n=this.queues.get(e);n==null||n.keys().forEach(r=>{this.removeQueue(e,r)})}removeJob(e){const n=this.runningJobs.findIndex(s=>s.jobId===e.jobId);n===-1&&this.logger.warn("Running job not found",e.jobId),this.runningJobs.splice(n,1);const r=this.globalQueue.findIndex(s=>s.jobId===e.jobId);r===-1&&this.logger.warn("Job not found on global queue",e.jobId),this.globalQueue.splice(r,1)}async handleJobCompleted(e,n){return this.removeJob(e),this.processNextJob()}isBusy(){return this.workers>=this.maxWorkers}async processNextJob(){if(this.isFindingJob)return;if(!this.delegate)throw new Error("No server delegate defined");if(this.globalQueue.length===0||this.isBusy())return;this.isFindingJob=!0,this.workers++;let e,n;try{const r=await this.findNextJob();e=r==null?void 0:r.queue,n=r==null?void 0:r.job}catch(r){pe.error("Error finding next job",r)}if(!e||!n){this.workers--,this.isFindingJob=!1;return}try{await e.setRunning(!0),this.isFindingJob=!1,this.emit("jobStarted",n);const r=await this.delegate.processJob(n);this.workers--,await e.setRunning(!1),this.emit("jobCompleted",n,r)}catch(r){pe.error("Job failed",r),this.workers--,this.isFindingJob=!1,await e.setRunning(!1),this.emit("jobFailed",n,r instanceof Error?r:new Error(JSON.stringify(r)))}}async findNextJob(){const e=new Set;for(const n of this.globalQueue){const r=this.getQueue(n.documentId,n.scope),s=r.getId();if(e.has(s))continue;if(await r.isBlocked()){e.add(r.getId());continue}const i=await r.getNextJob();if((i==null?void 0:i.jobId)!==n.jobId){pe.warn("Queue has different job waiting to be picked up"),pe.error(n,i);continue}return{queue:r,job:i}}}emit(e,...n){this.emitter.emit(e,...n)}on(e,n){return this.emitter.on(e,n)}}class Is extends Error{}class Jt extends Is{constructor(e){super(`Read drive ${e} not found.`)}}class Fg extends Is{constructor(e){super(`Read drive with slug ${e} not found.`)}}class Ia extends Is{constructor(e,n){super(`Document with id ${n} not found on read drive ${e}.`)}}function ye(t,e){if(!!!t)throw new Error(e)}function un(t){return typeof t=="object"&&t!==null}function ht(t,e){if(!!!t)throw new Error(e??"Unexpected invariant triggered.")}const Ug=/\r\n|[\n\r]/g;function xi(t,e){let n=0,r=1;for(const s of t.body.matchAll(Ug)){if(typeof s.index=="number"||ht(!1),s.index>=e)break;n=s.index+s[0].length,r+=1}return{line:r,column:e+1-n}}function Bg(t){return Wu(t.source,xi(t.source,t.start))}function Wu(t,e){const n=t.locationOffset.column-1,r="".padStart(n)+t.body,s=e.line-1,i=t.locationOffset.line-1,o=e.line+i,a=e.line===1?n:0,c=e.column+a,u=`${t.name}:${o}:${c}
|
|
123
|
-
`,d=r.split(/\r\n|[\n\r]/g),l=d[s];if(l.length>120){const f=Math.floor(c/80),h=c%80,m=[];for(let E=0;E<l.length;E+=80)m.push(l.slice(E,E+80));return u+Da([[`${o} |`,m[0]],...m.slice(1,f+1).map(E=>["|",E]),["|","^".padStart(h)],["|",m[f+1]]])}return u+Da([[`${o-1} |`,d[s-1]],[`${o} |`,l],["|","^".padStart(c)],[`${o+1} |`,d[s+1]]])}function Da(t){const e=t.filter(([r,s])=>s!==void 0),n=Math.max(...e.map(([r])=>r.length));return e.map(([r,s])=>r.padStart(n)+(s?" "+s:"")).join(`
|
|
124
|
-
`)}function jg(t){const e=t[0];return e==null||"kind"in e||"length"in e?{nodes:e,source:t[1],positions:t[2],path:t[3],originalError:t[4],extensions:t[5]}:e}class z extends Error{constructor(e,...n){var r,s,i;const{nodes:o,source:a,positions:c,path:u,originalError:d,extensions:l}=jg(n);super(e),this.name="GraphQLError",this.path=u??void 0,this.originalError=d??void 0,this.nodes=Na(Array.isArray(o)?o:o?[o]:void 0);const f=Na((r=this.nodes)===null||r===void 0?void 0:r.map(m=>m.loc).filter(m=>m!=null));this.source=a??(f==null||(s=f[0])===null||s===void 0?void 0:s.source),this.positions=c??(f==null?void 0:f.map(m=>m.start)),this.locations=c&&a?c.map(m=>xi(a,m)):f==null?void 0:f.map(m=>xi(m.source,m.start));const h=un(d==null?void 0:d.extensions)?d==null?void 0:d.extensions:void 0;this.extensions=(i=l??h)!==null&&i!==void 0?i:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),d!=null&&d.stack?Object.defineProperty(this,"stack",{value:d.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,z):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+=`
|
|
125
|
-
|
|
126
|
-
`+Bg(n.loc));else if(this.source&&this.locations)for(const n of this.locations)e+=`
|
|
127
|
-
|
|
128
|
-
`+Wu(this.source,n);return e}toJSON(){const e={message:this.message};return this.locations!=null&&(e.locations=this.locations),this.path!=null&&(e.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function Na(t){return t===void 0||t.length===0?void 0:t}function Fe(t,e,n){return new z(`Syntax Error: ${n}`,{source:t,positions:[e]})}class Vg{constructor(e,n,r){this.start=e.start,this.end=n.end,this.startToken=e,this.endToken=n,this.source=r}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class Qu{constructor(e,n,r,s,i,o){this.kind=e,this.start=n,this.end=r,this.line=s,this.column=i,this.value=o,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const Ku={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Gg=new Set(Object.keys(Ku));function Mi(t){const e=t==null?void 0:t.kind;return typeof e=="string"&&Gg.has(e)}var qe;(function(t){t.QUERY="query",t.MUTATION="mutation",t.SUBSCRIPTION="subscription"})(qe||(qe={}));var se;(function(t){t.QUERY="QUERY",t.MUTATION="MUTATION",t.SUBSCRIPTION="SUBSCRIPTION",t.FIELD="FIELD",t.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",t.FRAGMENT_SPREAD="FRAGMENT_SPREAD",t.INLINE_FRAGMENT="INLINE_FRAGMENT",t.VARIABLE_DEFINITION="VARIABLE_DEFINITION",t.SCHEMA="SCHEMA",t.SCALAR="SCALAR",t.OBJECT="OBJECT",t.FIELD_DEFINITION="FIELD_DEFINITION",t.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",t.INTERFACE="INTERFACE",t.UNION="UNION",t.ENUM="ENUM",t.ENUM_VALUE="ENUM_VALUE",t.INPUT_OBJECT="INPUT_OBJECT",t.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"})(se||(se={}));var y;(function(t){t.NAME="Name",t.DOCUMENT="Document",t.OPERATION_DEFINITION="OperationDefinition",t.VARIABLE_DEFINITION="VariableDefinition",t.SELECTION_SET="SelectionSet",t.FIELD="Field",t.ARGUMENT="Argument",t.FRAGMENT_SPREAD="FragmentSpread",t.INLINE_FRAGMENT="InlineFragment",t.FRAGMENT_DEFINITION="FragmentDefinition",t.VARIABLE="Variable",t.INT="IntValue",t.FLOAT="FloatValue",t.STRING="StringValue",t.BOOLEAN="BooleanValue",t.NULL="NullValue",t.ENUM="EnumValue",t.LIST="ListValue",t.OBJECT="ObjectValue",t.OBJECT_FIELD="ObjectField",t.DIRECTIVE="Directive",t.NAMED_TYPE="NamedType",t.LIST_TYPE="ListType",t.NON_NULL_TYPE="NonNullType",t.SCHEMA_DEFINITION="SchemaDefinition",t.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",t.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",t.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",t.FIELD_DEFINITION="FieldDefinition",t.INPUT_VALUE_DEFINITION="InputValueDefinition",t.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",t.UNION_TYPE_DEFINITION="UnionTypeDefinition",t.ENUM_TYPE_DEFINITION="EnumTypeDefinition",t.ENUM_VALUE_DEFINITION="EnumValueDefinition",t.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",t.DIRECTIVE_DEFINITION="DirectiveDefinition",t.SCHEMA_EXTENSION="SchemaExtension",t.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",t.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",t.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",t.UNION_TYPE_EXTENSION="UnionTypeExtension",t.ENUM_TYPE_EXTENSION="EnumTypeExtension",t.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(y||(y={}));function Pi(t){return t===9||t===32}function cr(t){return t>=48&&t<=57}function Xu(t){return t>=97&&t<=122||t>=65&&t<=90}function fo(t){return Xu(t)||t===95}function Zu(t){return Xu(t)||cr(t)||t===95}function zg(t){var e;let n=Number.MAX_SAFE_INTEGER,r=null,s=-1;for(let o=0;o<t.length;++o){var i;const a=t[o],c=qg(a);c!==a.length&&(r=(i=r)!==null&&i!==void 0?i:o,s=o,o!==0&&c<n&&(n=c))}return t.map((o,a)=>a===0?o:o.slice(n)).slice((e=r)!==null&&e!==void 0?e:0,s+1)}function qg(t){let e=0;for(;e<t.length&&Pi(t.charCodeAt(e));)++e;return e}function _b(t){if(t==="")return!0;let e=!0,n=!1,r=!0,s=!1;for(let i=0;i<t.length;++i)switch(t.codePointAt(i)){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 11:case 12:case 14:case 15:return!1;case 13:return!1;case 10:if(e&&!s)return!1;s=!0,e=!0,n=!1;break;case 9:case 32:n||(n=e);break;default:r&&(r=n),e=!1}return!(e||r&&s)}function Yg(t,e){const n=t.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),s=r.length===1,i=r.length>1&&r.slice(1).every(h=>h.length===0||Pi(h.charCodeAt(0))),o=n.endsWith('\\"""'),a=t.endsWith('"')&&!o,c=t.endsWith("\\"),u=a||c,d=!s||t.length>70||u||i||o;let l="";const f=s&&Pi(t.charCodeAt(0));return(d&&!f||i)&&(l+=`
|
|
129
|
-
`),l+=n,(d||u)&&(l+=`
|
|
130
|
-
`),'"""'+l+'"""'}var M;(function(t){t.SOF="<SOF>",t.EOF="<EOF>",t.BANG="!",t.DOLLAR="$",t.AMP="&",t.PAREN_L="(",t.PAREN_R=")",t.SPREAD="...",t.COLON=":",t.EQUALS="=",t.AT="@",t.BRACKET_L="[",t.BRACKET_R="]",t.BRACE_L="{",t.PIPE="|",t.BRACE_R="}",t.NAME="Name",t.INT="Int",t.FLOAT="Float",t.STRING="String",t.BLOCK_STRING="BlockString",t.COMMENT="Comment"})(M||(M={}));class Hg{constructor(e){const n=new Qu(M.SOF,0,0,0,0);this.source=e,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==M.EOF)do if(e.next)e=e.next;else{const n=Wg(this,e.end);e.next=n,n.prev=e,e=n}while(e.kind===M.COMMENT);return e}}function Jg(t){return t===M.BANG||t===M.DOLLAR||t===M.AMP||t===M.PAREN_L||t===M.PAREN_R||t===M.SPREAD||t===M.COLON||t===M.EQUALS||t===M.AT||t===M.BRACKET_L||t===M.BRACKET_R||t===M.BRACE_L||t===M.PIPE||t===M.BRACE_R}function xn(t){return t>=0&&t<=55295||t>=57344&&t<=1114111}function Ds(t,e){return el(t.charCodeAt(e))&&tl(t.charCodeAt(e+1))}function el(t){return t>=55296&&t<=56319}function tl(t){return t>=56320&&t<=57343}function ln(t,e){const n=t.source.body.codePointAt(e);if(n===void 0)return M.EOF;if(n>=32&&n<=126){const r=String.fromCodePoint(n);return r==='"'?`'"'`:`"${r}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function xe(t,e,n,r,s){const i=t.line,o=1+n-t.lineStart;return new Qu(e,n,r,i,o,s)}function Wg(t,e){const n=t.source.body,r=n.length;let s=e;for(;s<r;){const i=n.charCodeAt(s);switch(i){case 65279:case 9:case 32:case 44:++s;continue;case 10:++s,++t.line,t.lineStart=s;continue;case 13:n.charCodeAt(s+1)===10?s+=2:++s,++t.line,t.lineStart=s;continue;case 35:return Qg(t,s);case 33:return xe(t,M.BANG,s,s+1);case 36:return xe(t,M.DOLLAR,s,s+1);case 38:return xe(t,M.AMP,s,s+1);case 40:return xe(t,M.PAREN_L,s,s+1);case 41:return xe(t,M.PAREN_R,s,s+1);case 46:if(n.charCodeAt(s+1)===46&&n.charCodeAt(s+2)===46)return xe(t,M.SPREAD,s,s+3);break;case 58:return xe(t,M.COLON,s,s+1);case 61:return xe(t,M.EQUALS,s,s+1);case 64:return xe(t,M.AT,s,s+1);case 91:return xe(t,M.BRACKET_L,s,s+1);case 93:return xe(t,M.BRACKET_R,s,s+1);case 123:return xe(t,M.BRACE_L,s,s+1);case 124:return xe(t,M.PIPE,s,s+1);case 125:return xe(t,M.BRACE_R,s,s+1);case 34:return n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34?nm(t,s):Xg(t,s)}if(cr(i)||i===45)return Kg(t,s,i);if(fo(i))return rm(t,s);throw Fe(t.source,s,i===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:xn(i)||Ds(n,s)?`Unexpected character: ${ln(t,s)}.`:`Invalid character: ${ln(t,s)}.`)}return xe(t,M.EOF,r,r)}function Qg(t,e){const n=t.source.body,r=n.length;let s=e+1;for(;s<r;){const i=n.charCodeAt(s);if(i===10||i===13)break;if(xn(i))++s;else if(Ds(n,s))s+=2;else break}return xe(t,M.COMMENT,e,s,n.slice(e+1,s))}function Kg(t,e,n){const r=t.source.body;let s=e,i=n,o=!1;if(i===45&&(i=r.charCodeAt(++s)),i===48){if(i=r.charCodeAt(++s),cr(i))throw Fe(t.source,s,`Invalid number, unexpected digit after 0: ${ln(t,s)}.`)}else s=ii(t,s,i),i=r.charCodeAt(s);if(i===46&&(o=!0,i=r.charCodeAt(++s),s=ii(t,s,i),i=r.charCodeAt(s)),(i===69||i===101)&&(o=!0,i=r.charCodeAt(++s),(i===43||i===45)&&(i=r.charCodeAt(++s)),s=ii(t,s,i),i=r.charCodeAt(s)),i===46||fo(i))throw Fe(t.source,s,`Invalid number, expected digit but got: ${ln(t,s)}.`);return xe(t,o?M.FLOAT:M.INT,e,s,r.slice(e,s))}function ii(t,e,n){if(!cr(n))throw Fe(t.source,e,`Invalid number, expected digit but got: ${ln(t,e)}.`);const r=t.source.body;let s=e+1;for(;cr(r.charCodeAt(s));)++s;return s}function Xg(t,e){const n=t.source.body,r=n.length;let s=e+1,i=s,o="";for(;s<r;){const a=n.charCodeAt(s);if(a===34)return o+=n.slice(i,s),xe(t,M.STRING,e,s+1,o);if(a===92){o+=n.slice(i,s);const c=n.charCodeAt(s+1)===117?n.charCodeAt(s+2)===123?Zg(t,s):em(t,s):tm(t,s);o+=c.value,s+=c.size,i=s;continue}if(a===10||a===13)break;if(xn(a))++s;else if(Ds(n,s))s+=2;else throw Fe(t.source,s,`Invalid character within String: ${ln(t,s)}.`)}throw Fe(t.source,s,"Unterminated string.")}function Zg(t,e){const n=t.source.body;let r=0,s=3;for(;s<12;){const i=n.charCodeAt(e+s++);if(i===125){if(s<5||!xn(r))break;return{value:String.fromCodePoint(r),size:s}}if(r=r<<4|Yn(i),r<0)break}throw Fe(t.source,e,`Invalid Unicode escape sequence: "${n.slice(e,e+s)}".`)}function em(t,e){const n=t.source.body,r=Oa(n,e+2);if(xn(r))return{value:String.fromCodePoint(r),size:6};if(el(r)&&n.charCodeAt(e+6)===92&&n.charCodeAt(e+7)===117){const s=Oa(n,e+8);if(tl(s))return{value:String.fromCodePoint(r,s),size:12}}throw Fe(t.source,e,`Invalid Unicode escape sequence: "${n.slice(e,e+6)}".`)}function Oa(t,e){return Yn(t.charCodeAt(e))<<12|Yn(t.charCodeAt(e+1))<<8|Yn(t.charCodeAt(e+2))<<4|Yn(t.charCodeAt(e+3))}function Yn(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:-1}function tm(t,e){const n=t.source.body;switch(n.charCodeAt(e+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:`
|
|
131
|
-
`,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw Fe(t.source,e,`Invalid character escape sequence: "${n.slice(e,e+2)}".`)}function nm(t,e){const n=t.source.body,r=n.length;let s=t.lineStart,i=e+3,o=i,a="";const c=[];for(;i<r;){const u=n.charCodeAt(i);if(u===34&&n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34){a+=n.slice(o,i),c.push(a);const d=xe(t,M.BLOCK_STRING,e,i+3,zg(c).join(`
|
|
132
|
-
`));return t.line+=c.length-1,t.lineStart=s,d}if(u===92&&n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34&&n.charCodeAt(i+3)===34){a+=n.slice(o,i),o=i+1,i+=4;continue}if(u===10||u===13){a+=n.slice(o,i),c.push(a),u===13&&n.charCodeAt(i+1)===10?i+=2:++i,a="",o=i,s=i;continue}if(xn(u))++i;else if(Ds(n,i))i+=2;else throw Fe(t.source,i,`Invalid character within String: ${ln(t,i)}.`)}throw Fe(t.source,i,"Unterminated string.")}function rm(t,e){const n=t.source.body,r=n.length;let s=e+1;for(;s<r;){const i=n.charCodeAt(s);if(Zu(i))++s;else break}return xe(t,M.NAME,e,s,n.slice(e,s))}const sm=10,nl=2;function ee(t){return Ns(t,[])}function Ns(t,e){switch(typeof t){case"string":return JSON.stringify(t);case"function":return t.name?`[function ${t.name}]`:"[function]";case"object":return im(t,e);default:return String(t)}}function im(t,e){if(t===null)return"null";if(e.includes(t))return"[Circular]";const n=[...e,t];if(om(t)){const r=t.toJSON();if(r!==t)return typeof r=="string"?r:Ns(r,n)}else if(Array.isArray(t))return cm(t,n);return am(t,n)}function om(t){return typeof t.toJSON=="function"}function am(t,e){const n=Object.entries(t);return n.length===0?"{}":e.length>nl?"["+um(t)+"]":"{ "+n.map(([s,i])=>s+": "+Ns(i,e)).join(", ")+" }"}function cm(t,e){if(t.length===0)return"[]";if(e.length>nl)return"[Array]";const n=Math.min(sm,t.length),r=t.length-n,s=[];for(let i=0;i<n;++i)s.push(Ns(t[i],e));return r===1?s.push("... 1 more item"):r>1&&s.push(`... ${r} more items`),"["+s.join(", ")+"]"}function um(t){const e=Object.prototype.toString.call(t).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof t.constructor=="function"){const n=t.constructor.name;if(typeof n=="string"&&n!=="")return n}return e}const lm=globalThis.process&&!0,gt=lm?function(e,n){return e instanceof n}:function(e,n){if(e instanceof n)return!0;if(typeof e=="object"&&e!==null){var r;const s=n.prototype[Symbol.toStringTag],i=Symbol.toStringTag in e?e[Symbol.toStringTag]:(r=e.constructor)===null||r===void 0?void 0:r.name;if(s===i){const o=ee(e);throw new Error(`Cannot use ${s} "${o}" from another module or realm.
|
|
133
|
-
|
|
134
|
-
Ensure that there is only one instance of "graphql" in the node_modules
|
|
135
|
-
directory. If different versions of "graphql" are the dependencies of other
|
|
136
|
-
relied on modules, use "resolutions" to ensure only one version is installed.
|
|
137
|
-
|
|
138
|
-
https://yarnpkg.com/en/docs/selective-version-resolutions
|
|
139
|
-
|
|
140
|
-
Duplicate "graphql" modules cannot be used at the same time since different
|
|
141
|
-
versions may have different capabilities and behavior. The data from one
|
|
142
|
-
version used in the function from another could produce confusing and
|
|
143
|
-
spurious results.`)}}return!1};class rl{constructor(e,n="GraphQL request",r={line:1,column:1}){typeof e=="string"||ye(!1,`Body must be a string. Received: ${ee(e)}.`),this.body=e,this.name=n,this.locationOffset=r,this.locationOffset.line>0||ye(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||ye(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function dm(t){return gt(t,rl)}function sl(t,e){const n=new fm(t,e),r=n.parseDocument();return Object.defineProperty(r,"tokenCount",{enumerable:!1,value:n.tokenCount}),r}class fm{constructor(e,n={}){const r=dm(e)?e:new rl(e);this._lexer=new Hg(r),this._options=n,this._tokenCounter=0}get tokenCount(){return this._tokenCounter}parseName(){const e=this.expectToken(M.NAME);return this.node(e,{kind:y.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:y.DOCUMENT,definitions:this.many(M.SOF,this.parseDefinition,M.EOF)})}parseDefinition(){if(this.peek(M.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),n=e?this._lexer.lookahead():this._lexer.token;if(n.kind===M.NAME){switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(e)throw Fe(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(n.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(n)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(M.BRACE_L))return this.node(e,{kind:y.OPERATION_DEFINITION,operation:qe.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const n=this.parseOperationType();let r;return this.peek(M.NAME)&&(r=this.parseName()),this.node(e,{kind:y.OPERATION_DEFINITION,operation:n,name:r,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(M.NAME);switch(e.value){case"query":return qe.QUERY;case"mutation":return qe.MUTATION;case"subscription":return qe.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(M.PAREN_L,this.parseVariableDefinition,M.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:y.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(M.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(M.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(M.DOLLAR),this.node(e,{kind:y.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:y.SELECTION_SET,selections:this.many(M.BRACE_L,this.parseSelection,M.BRACE_R)})}parseSelection(){return this.peek(M.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,n=this.parseName();let r,s;return this.expectOptionalToken(M.COLON)?(r=n,s=this.parseName()):s=n,this.node(e,{kind:y.FIELD,alias:r,name:s,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(M.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const n=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(M.PAREN_L,n,M.PAREN_R)}parseArgument(e=!1){const n=this._lexer.token,r=this.parseName();return this.expectToken(M.COLON),this.node(n,{kind:y.ARGUMENT,name:r,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(M.SPREAD);const n=this.expectOptionalKeyword("on");return!n&&this.peek(M.NAME)?this.node(e,{kind:y.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:y.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(e,{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(e){const n=this._lexer.token;switch(n.kind){case M.BRACKET_L:return this.parseList(e);case M.BRACE_L:return this.parseObject(e);case M.INT:return this.advanceLexer(),this.node(n,{kind:y.INT,value:n.value});case M.FLOAT:return this.advanceLexer(),this.node(n,{kind:y.FLOAT,value:n.value});case M.STRING:case M.BLOCK_STRING:return this.parseStringLiteral();case M.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:y.BOOLEAN,value:!0});case"false":return this.node(n,{kind:y.BOOLEAN,value:!1});case"null":return this.node(n,{kind:y.NULL});default:return this.node(n,{kind:y.ENUM,value:n.value})}case M.DOLLAR:if(e)if(this.expectToken(M.DOLLAR),this._lexer.token.kind===M.NAME){const r=this._lexer.token.value;throw Fe(this._lexer.source,n.start,`Unexpected variable "$${r}" in constant value.`)}else throw this.unexpected(n);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:y.STRING,value:e.value,block:e.kind===M.BLOCK_STRING})}parseList(e){const n=()=>this.parseValueLiteral(e);return this.node(this._lexer.token,{kind:y.LIST,values:this.any(M.BRACKET_L,n,M.BRACKET_R)})}parseObject(e){const n=()=>this.parseObjectField(e);return this.node(this._lexer.token,{kind:y.OBJECT,fields:this.any(M.BRACE_L,n,M.BRACE_R)})}parseObjectField(e){const n=this._lexer.token,r=this.parseName();return this.expectToken(M.COLON),this.node(n,{kind:y.OBJECT_FIELD,name:r,value:this.parseValueLiteral(e)})}parseDirectives(e){const n=[];for(;this.peek(M.AT);)n.push(this.parseDirective(e));return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const n=this._lexer.token;return this.expectToken(M.AT),this.node(n,{kind:y.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let n;if(this.expectOptionalToken(M.BRACKET_L)){const r=this.parseTypeReference();this.expectToken(M.BRACKET_R),n=this.node(e,{kind:y.LIST_TYPE,type:r})}else n=this.parseNamedType();return this.expectOptionalToken(M.BANG)?this.node(e,{kind:y.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:y.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(M.STRING)||this.peek(M.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");const r=this.parseConstDirectives(),s=this.many(M.BRACE_L,this.parseOperationTypeDefinition,M.BRACE_R);return this.node(e,{kind:y.SCHEMA_DEFINITION,description:n,directives:r,operationTypes:s})}parseOperationTypeDefinition(){const e=this._lexer.token,n=this.parseOperationType();this.expectToken(M.COLON);const r=this.parseNamedType();return this.node(e,{kind:y.OPERATION_TYPE_DEFINITION,operation:n,type:r})}parseScalarTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");const r=this.parseName(),s=this.parseConstDirectives();return this.node(e,{kind:y.SCALAR_TYPE_DEFINITION,description:n,name:r,directives:s})}parseObjectTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");const r=this.parseName(),s=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:y.OBJECT_TYPE_DEFINITION,description:n,name:r,interfaces:s,directives:i,fields:o})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(M.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(M.BRACE_L,this.parseFieldDefinition,M.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,n=this.parseDescription(),r=this.parseName(),s=this.parseArgumentDefs();this.expectToken(M.COLON);const i=this.parseTypeReference(),o=this.parseConstDirectives();return this.node(e,{kind:y.FIELD_DEFINITION,description:n,name:r,arguments:s,type:i,directives:o})}parseArgumentDefs(){return this.optionalMany(M.PAREN_L,this.parseInputValueDef,M.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,n=this.parseDescription(),r=this.parseName();this.expectToken(M.COLON);const s=this.parseTypeReference();let i;this.expectOptionalToken(M.EQUALS)&&(i=this.parseConstValueLiteral());const o=this.parseConstDirectives();return this.node(e,{kind:y.INPUT_VALUE_DEFINITION,description:n,name:r,type:s,defaultValue:i,directives:o})}parseInterfaceTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");const r=this.parseName(),s=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:y.INTERFACE_TYPE_DEFINITION,description:n,name:r,interfaces:s,directives:i,fields:o})}parseUnionTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");const r=this.parseName(),s=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:y.UNION_TYPE_DEFINITION,description:n,name:r,directives:s,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(M.EQUALS)?this.delimitedMany(M.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");const r=this.parseName(),s=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:y.ENUM_TYPE_DEFINITION,description:n,name:r,directives:s,values:i})}parseEnumValuesDefinition(){return this.optionalMany(M.BRACE_L,this.parseEnumValueDefinition,M.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,n=this.parseDescription(),r=this.parseEnumValueName(),s=this.parseConstDirectives();return this.node(e,{kind:y.ENUM_VALUE_DEFINITION,description:n,name:r,directives:s})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw Fe(this._lexer.source,this._lexer.token.start,`${Mr(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");const r=this.parseName(),s=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:y.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:r,directives:s,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(M.BRACE_L,this.parseInputValueDef,M.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===M.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.optionalMany(M.BRACE_L,this.parseOperationTypeDefinition,M.BRACE_R);if(n.length===0&&r.length===0)throw this.unexpected();return this.node(e,{kind:y.SCHEMA_EXTENSION,directives:n,operationTypes:r})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();if(r.length===0)throw this.unexpected();return this.node(e,{kind:y.SCALAR_TYPE_EXTENSION,name:n,directives:r})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(r.length===0&&s.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:y.OBJECT_TYPE_EXTENSION,name:n,interfaces:r,directives:s,fields:i})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(r.length===0&&s.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:y.INTERFACE_TYPE_EXTENSION,name:n,interfaces:r,directives:s,fields:i})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),s=this.parseUnionMemberTypes();if(r.length===0&&s.length===0)throw this.unexpected();return this.node(e,{kind:y.UNION_TYPE_EXTENSION,name:n,directives:r,types:s})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),s=this.parseEnumValuesDefinition();if(r.length===0&&s.length===0)throw this.unexpected();return this.node(e,{kind:y.ENUM_TYPE_EXTENSION,name:n,directives:r,values:s})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),s=this.parseInputFieldsDefinition();if(r.length===0&&s.length===0)throw this.unexpected();return this.node(e,{kind:y.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:r,fields:s})}parseDirectiveDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(M.AT);const r=this.parseName(),s=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return this.node(e,{kind:y.DIRECTIVE_DEFINITION,description:n,name:r,arguments:s,repeatable:i,locations:o})}parseDirectiveLocations(){return this.delimitedMany(M.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,n=this.parseName();if(Object.prototype.hasOwnProperty.call(se,n.value))return n;throw this.unexpected(e)}node(e,n){return this._options.noLocation!==!0&&(n.loc=new Vg(e,this._lexer.lastToken,this._lexer.source)),n}peek(e){return this._lexer.token.kind===e}expectToken(e){const n=this._lexer.token;if(n.kind===e)return this.advanceLexer(),n;throw Fe(this._lexer.source,n.start,`Expected ${il(e)}, found ${Mr(n)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e?(this.advanceLexer(),!0):!1}expectKeyword(e){const n=this._lexer.token;if(n.kind===M.NAME&&n.value===e)this.advanceLexer();else throw Fe(this._lexer.source,n.start,`Expected "${e}", found ${Mr(n)}.`)}expectOptionalKeyword(e){const n=this._lexer.token;return n.kind===M.NAME&&n.value===e?(this.advanceLexer(),!0):!1}unexpected(e){const n=e??this._lexer.token;return Fe(this._lexer.source,n.start,`Unexpected ${Mr(n)}.`)}any(e,n,r){this.expectToken(e);const s=[];for(;!this.expectOptionalToken(r);)s.push(n.call(this));return s}optionalMany(e,n,r){if(this.expectOptionalToken(e)){const s=[];do s.push(n.call(this));while(!this.expectOptionalToken(r));return s}return[]}many(e,n,r){this.expectToken(e);const s=[];do s.push(n.call(this));while(!this.expectOptionalToken(r));return s}delimitedMany(e,n){this.expectOptionalToken(e);const r=[];do r.push(n.call(this));while(this.expectOptionalToken(e));return r}advanceLexer(){const{maxTokens:e}=this._options,n=this._lexer.advance();if(n.kind!==M.EOF&&(++this._tokenCounter,e!==void 0&&this._tokenCounter>e))throw Fe(this._lexer.source,n.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function Mr(t){const e=t.value;return il(t.kind)+(e!=null?` "${e}"`:"")}function il(t){return Jg(t)?`"${t}"`:t}const pm=5;function Vt(t,e){const[n,r]=e?[t,e]:[void 0,t];let s=" Did you mean ";n&&(s+=n+" ");const i=r.map(c=>`"${c}"`);switch(i.length){case 0:return"";case 1:return s+i[0]+"?";case 2:return s+i[0]+" or "+i[1]+"?"}const o=i.slice(0,pm),a=o.pop();return s+o.join(", ")+", or "+a+"?"}function Aa(t){return t}function dn(t,e){const n=Object.create(null);for(const r of t)n[e(r)]=r;return n}function po(t,e,n){const r=Object.create(null);for(const s of t)r[e(s)]=n(s);return r}function Ot(t,e){const n=Object.create(null);for(const r of Object.keys(t))n[r]=e(t[r],r);return n}function ho(t,e){let n=0,r=0;for(;n<t.length&&r<e.length;){let s=t.charCodeAt(n),i=e.charCodeAt(r);if(Pr(s)&&Pr(i)){let o=0;do++n,o=o*10+s-ki,s=t.charCodeAt(n);while(Pr(s)&&o>0);let a=0;do++r,a=a*10+i-ki,i=e.charCodeAt(r);while(Pr(i)&&a>0);if(o<a)return-1;if(o>a)return 1}else{if(s<i)return-1;if(s>i)return 1;++n,++r}}return t.length-e.length}const ki=48,hm=57;function Pr(t){return!isNaN(t)&&ki<=t&&t<=hm}function yn(t,e){const n=Object.create(null),r=new gm(t),s=Math.floor(t.length*.4)+1;for(const i of e){const o=r.measure(i,s);o!==void 0&&(n[i]=o)}return Object.keys(n).sort((i,o)=>{const a=n[i]-n[o];return a!==0?a:ho(i,o)})}class gm{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=Ra(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,n){if(this._input===e)return 0;const r=e.toLowerCase();if(this._inputLowerCase===r)return 1;let s=Ra(r),i=this._inputArray;if(s.length<i.length){const d=s;s=i,i=d}const o=s.length,a=i.length;if(o-a>n)return;const c=this._rows;for(let d=0;d<=a;d++)c[0][d]=d;for(let d=1;d<=o;d++){const l=c[(d-1)%3],f=c[d%3];let h=f[0]=d;for(let m=1;m<=a;m++){const E=s[d-1]===i[m-1]?0:1;let D=Math.min(l[m]+1,f[m-1]+1,l[m-1]+E);if(d>1&&m>1&&s[d-1]===i[m-2]&&s[d-2]===i[m-1]){const P=c[(d-2)%3][m-2];D=Math.min(D,P+1)}D<h&&(h=D),f[m]=D}if(h>n)return}const u=c[o%3][a];return u<=n?u:void 0}}function Ra(t){const e=t.length,n=new Array(e);for(let r=0;r<e;++r)n[r]=t.charCodeAt(r);return n}function at(t){if(t==null)return Object.create(null);if(Object.getPrototypeOf(t)===null)return t;const e=Object.create(null);for(const[n,r]of Object.entries(t))e[n]=r;return e}function mm(t){return`"${t.replace(ym,vm)}"`}const ym=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function vm(t){return Em[t.charCodeAt(0)]}const Em=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],Hn=Object.freeze({});function Os(t,e,n=Ku){const r=new Map;for(const P of Object.values(y))r.set(P,cs(e,P));let s,i=Array.isArray(t),o=[t],a=-1,c=[],u=t,d,l;const f=[],h=[];do{a++;const P=a===o.length,B=P&&c.length!==0;if(P){if(d=h.length===0?void 0:f[f.length-1],u=l,l=h.pop(),B)if(i){u=u.slice();let Q=0;for(const[N,X]of c){const w=N-Q;X===null?(u.splice(w,1),Q++):u[w]=X}}else{u={...u};for(const[Q,N]of c)u[Q]=N}a=s.index,o=s.keys,c=s.edits,i=s.inArray,s=s.prev}else if(l){if(d=i?a:o[a],u=l[d],u==null)continue;f.push(d)}let R;if(!Array.isArray(u)){var m,E;Mi(u)||ye(!1,`Invalid AST Node: ${ee(u)}.`);const Q=P?(m=r.get(u.kind))===null||m===void 0?void 0:m.leave:(E=r.get(u.kind))===null||E===void 0?void 0:E.enter;if(R=Q==null?void 0:Q.call(e,u,d,l,f,h),R===Hn)break;if(R===!1){if(!P){f.pop();continue}}else if(R!==void 0&&(c.push([d,R]),!P))if(Mi(R))u=R;else{f.pop();continue}}if(R===void 0&&B&&c.push([d,u]),P)f.pop();else{var D;s={inArray:i,index:a,keys:o,edits:c,prev:s},i=Array.isArray(u),o=i?u:(D=n[u.kind])!==null&&D!==void 0?D:[],a=-1,c=[],l&&h.push(l),l=u}}while(s!==void 0);return c.length!==0?c[c.length-1][1]:t}function ol(t){const e=new Array(t.length).fill(null),n=Object.create(null);for(const r of Object.values(y)){let s=!1;const i=new Array(t.length).fill(void 0),o=new Array(t.length).fill(void 0);for(let c=0;c<t.length;++c){const{enter:u,leave:d}=cs(t[c],r);s||(s=u!=null||d!=null),i[c]=u,o[c]=d}if(!s)continue;const a={enter(...c){const u=c[0];for(let l=0;l<t.length;l++)if(e[l]===null){var d;const f=(d=i[l])===null||d===void 0?void 0:d.apply(t[l],c);if(f===!1)e[l]=u;else if(f===Hn)e[l]=Hn;else if(f!==void 0)return f}},leave(...c){const u=c[0];for(let l=0;l<t.length;l++)if(e[l]===null){var d;const f=(d=o[l])===null||d===void 0?void 0:d.apply(t[l],c);if(f===Hn)e[l]=Hn;else if(f!==void 0&&f!==!1)return f}else e[l]===u&&(e[l]=null)}};n[r]=a}return n}function cs(t,e){const n=t[e];return typeof n=="object"?n:typeof n=="function"?{enter:n,leave:void 0}:{enter:t.enter,leave:t.leave}}function ke(t){return Os(t,wm)}const _m=80,wm={Name:{leave:t=>t.value},Variable:{leave:t=>"$"+t.name},Document:{leave:t=>te(t.definitions,`
|
|
144
|
-
|
|
145
|
-
`)},OperationDefinition:{leave(t){const e=ge("(",te(t.variableDefinitions,", "),")"),n=te([t.operation,te([t.name,e]),te(t.directives," ")]," ");return(n==="query"?"":n+" ")+t.selectionSet}},VariableDefinition:{leave:({variable:t,type:e,defaultValue:n,directives:r})=>t+": "+e+ge(" = ",n)+ge(" ",te(r," "))},SelectionSet:{leave:({selections:t})=>ut(t)},Field:{leave({alias:t,name:e,arguments:n,directives:r,selectionSet:s}){const i=ge("",t,": ")+e;let o=i+ge("(",te(n,", "),")");return o.length>_m&&(o=i+ge(`(
|
|
146
|
-
`,qr(te(n,`
|
|
147
|
-
`)),`
|
|
148
|
-
)`)),te([o,te(r," "),s]," ")}},Argument:{leave:({name:t,value:e})=>t+": "+e},FragmentSpread:{leave:({name:t,directives:e})=>"..."+t+ge(" ",te(e," "))},InlineFragment:{leave:({typeCondition:t,directives:e,selectionSet:n})=>te(["...",ge("on ",t),te(e," "),n]," ")},FragmentDefinition:{leave:({name:t,typeCondition:e,variableDefinitions:n,directives:r,selectionSet:s})=>`fragment ${t}${ge("(",te(n,", "),")")} on ${e} ${ge("",te(r," ")," ")}`+s},IntValue:{leave:({value:t})=>t},FloatValue:{leave:({value:t})=>t},StringValue:{leave:({value:t,block:e})=>e?Yg(t):mm(t)},BooleanValue:{leave:({value:t})=>t?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:t})=>t},ListValue:{leave:({values:t})=>"["+te(t,", ")+"]"},ObjectValue:{leave:({fields:t})=>"{"+te(t,", ")+"}"},ObjectField:{leave:({name:t,value:e})=>t+": "+e},Directive:{leave:({name:t,arguments:e})=>"@"+t+ge("(",te(e,", "),")")},NamedType:{leave:({name:t})=>t},ListType:{leave:({type:t})=>"["+t+"]"},NonNullType:{leave:({type:t})=>t+"!"},SchemaDefinition:{leave:({description:t,directives:e,operationTypes:n})=>ge("",t,`
|
|
149
|
-
`)+te(["schema",te(e," "),ut(n)]," ")},OperationTypeDefinition:{leave:({operation:t,type:e})=>t+": "+e},ScalarTypeDefinition:{leave:({description:t,name:e,directives:n})=>ge("",t,`
|
|
150
|
-
`)+te(["scalar",e,te(n," ")]," ")},ObjectTypeDefinition:{leave:({description:t,name:e,interfaces:n,directives:r,fields:s})=>ge("",t,`
|
|
151
|
-
`)+te(["type",e,ge("implements ",te(n," & ")),te(r," "),ut(s)]," ")},FieldDefinition:{leave:({description:t,name:e,arguments:n,type:r,directives:s})=>ge("",t,`
|
|
152
|
-
`)+e+(Ca(n)?ge(`(
|
|
153
|
-
`,qr(te(n,`
|
|
154
|
-
`)),`
|
|
155
|
-
)`):ge("(",te(n,", "),")"))+": "+r+ge(" ",te(s," "))},InputValueDefinition:{leave:({description:t,name:e,type:n,defaultValue:r,directives:s})=>ge("",t,`
|
|
156
|
-
`)+te([e+": "+n,ge("= ",r),te(s," ")]," ")},InterfaceTypeDefinition:{leave:({description:t,name:e,interfaces:n,directives:r,fields:s})=>ge("",t,`
|
|
157
|
-
`)+te(["interface",e,ge("implements ",te(n," & ")),te(r," "),ut(s)]," ")},UnionTypeDefinition:{leave:({description:t,name:e,directives:n,types:r})=>ge("",t,`
|
|
158
|
-
`)+te(["union",e,te(n," "),ge("= ",te(r," | "))]," ")},EnumTypeDefinition:{leave:({description:t,name:e,directives:n,values:r})=>ge("",t,`
|
|
159
|
-
`)+te(["enum",e,te(n," "),ut(r)]," ")},EnumValueDefinition:{leave:({description:t,name:e,directives:n})=>ge("",t,`
|
|
160
|
-
`)+te([e,te(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:t,name:e,directives:n,fields:r})=>ge("",t,`
|
|
161
|
-
`)+te(["input",e,te(n," "),ut(r)]," ")},DirectiveDefinition:{leave:({description:t,name:e,arguments:n,repeatable:r,locations:s})=>ge("",t,`
|
|
162
|
-
`)+"directive @"+e+(Ca(n)?ge(`(
|
|
163
|
-
`,qr(te(n,`
|
|
164
|
-
`)),`
|
|
165
|
-
)`):ge("(",te(n,", "),")"))+(r?" repeatable":"")+" on "+te(s," | ")},SchemaExtension:{leave:({directives:t,operationTypes:e})=>te(["extend schema",te(t," "),ut(e)]," ")},ScalarTypeExtension:{leave:({name:t,directives:e})=>te(["extend scalar",t,te(e," ")]," ")},ObjectTypeExtension:{leave:({name:t,interfaces:e,directives:n,fields:r})=>te(["extend type",t,ge("implements ",te(e," & ")),te(n," "),ut(r)]," ")},InterfaceTypeExtension:{leave:({name:t,interfaces:e,directives:n,fields:r})=>te(["extend interface",t,ge("implements ",te(e," & ")),te(n," "),ut(r)]," ")},UnionTypeExtension:{leave:({name:t,directives:e,types:n})=>te(["extend union",t,te(e," "),ge("= ",te(n," | "))]," ")},EnumTypeExtension:{leave:({name:t,directives:e,values:n})=>te(["extend enum",t,te(e," "),ut(n)]," ")},InputObjectTypeExtension:{leave:({name:t,directives:e,fields:n})=>te(["extend input",t,te(e," "),ut(n)]," ")}};function te(t,e=""){var n;return(n=t==null?void 0:t.filter(r=>r).join(e))!==null&&n!==void 0?n:""}function ut(t){return ge(`{
|
|
166
|
-
`,qr(te(t,`
|
|
167
|
-
`)),`
|
|
168
|
-
}`)}function ge(t,e,n=""){return e!=null&&e!==""?t+e+n:""}function qr(t){return ge(" ",t.replace(/\n/g,`
|
|
169
|
-
`))}function Ca(t){var e;return(e=t==null?void 0:t.some(n=>n.includes(`
|
|
170
|
-
`)))!==null&&e!==void 0?e:!1}function $i(t,e){switch(t.kind){case y.NULL:return null;case y.INT:return parseInt(t.value,10);case y.FLOAT:return parseFloat(t.value);case y.STRING:case y.ENUM:case y.BOOLEAN:return t.value;case y.LIST:return t.values.map(n=>$i(n,e));case y.OBJECT:return po(t.fields,n=>n.name.value,n=>$i(n.value,e));case y.VARIABLE:return e==null?void 0:e[t.name.value]}}function mt(t){if(t!=null||ye(!1,"Must provide name."),typeof t=="string"||ye(!1,"Expected name to be a string."),t.length===0)throw new z("Expected name to be a non-empty string.");for(let e=1;e<t.length;++e)if(!Zu(t.charCodeAt(e)))throw new z(`Names must only contain [_a-zA-Z0-9] but "${t}" does not.`);if(!fo(t.charCodeAt(0)))throw new z(`Names must start with [_a-zA-Z] but "${t}" does not.`);return t}function bm(t){if(t==="true"||t==="false"||t==="null")throw new z(`Enum values cannot be named: ${t}`);return mt(t)}function go(t){return qt(t)||De(t)||Oe(t)||it(t)||Ke(t)||Ue(t)||je(t)||we(t)}function qt(t){return gt(t,Ct)}function De(t){return gt(t,st)}function Oe(t){return gt(t,Fi)}function it(t){return gt(t,In)}function Ke(t){return gt(t,ur)}function Ue(t){return gt(t,Ui)}function je(t){return gt(t,ze)}function we(t){return gt(t,ce)}function _t(t){return qt(t)||Ke(t)||Ue(t)||mo(t)&&_t(t.ofType)}function Zn(t){return qt(t)||De(t)||Oe(t)||it(t)||Ke(t)||mo(t)&&Zn(t.ofType)}function Cn(t){return qt(t)||Ke(t)}function Gt(t){return De(t)||Oe(t)||it(t)}function Ut(t){return Oe(t)||it(t)}function wb(t){if(!Ut(t))throw new Error(`Expected ${ee(t)} to be a GraphQL abstract type.`);return t}class ze{constructor(e){go(e)||ye(!1,`Expected ${ee(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class ce{constructor(e){al(e)||ye(!1,`Expected ${ee(e)} to be a GraphQL nullable type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function mo(t){return je(t)||we(t)}function al(t){return go(t)&&!we(t)}function cl(t){if(t)return we(t)?t.ofType:t}function Sm(t){return qt(t)||De(t)||Oe(t)||it(t)||Ke(t)||Ue(t)}function ft(t){if(t){let e=t;for(;mo(e);)e=e.ofType;return e}}function ul(t){return typeof t=="function"?t():t}function ll(t){return typeof t=="function"?t():t}class Ct{constructor(e){var n,r,s,i;const o=(n=e.parseValue)!==null&&n!==void 0?n:Aa;this.name=mt(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=(r=e.serialize)!==null&&r!==void 0?r:Aa,this.parseValue=o,this.parseLiteral=(s=e.parseLiteral)!==null&&s!==void 0?s:(a,c)=>o($i(a,c)),this.extensions=at(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(i=e.extensionASTNodes)!==null&&i!==void 0?i:[],e.specifiedByURL==null||typeof e.specifiedByURL=="string"||ye(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${ee(e.specifiedByURL)}.`),e.serialize==null||typeof e.serialize=="function"||ye(!1,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),e.parseLiteral&&(typeof e.parseValue=="function"&&typeof e.parseLiteral=="function"||ye(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return"GraphQLScalarType"}toConfig(){return{name:this.name,description:this.description,specifiedByURL:this.specifiedByURL,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class st{constructor(e){var n;this.name=mt(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=at(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=()=>fl(e),this._interfaces=()=>dl(e),e.isTypeOf==null||typeof e.isTypeOf=="function"||ye(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${ee(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:hl(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function dl(t){var e;const n=ul((e=t.interfaces)!==null&&e!==void 0?e:[]);return Array.isArray(n)||ye(!1,`${t.name} interfaces must be an Array or a function which returns an Array.`),n}function fl(t){const e=ll(t.fields);return Tn(e)||ye(!1,`${t.name} fields must be an object with field names as keys or a function which returns such an object.`),Ot(e,(n,r)=>{var s;Tn(n)||ye(!1,`${t.name}.${r} field config must be an object.`),n.resolve==null||typeof n.resolve=="function"||ye(!1,`${t.name}.${r} field resolver must be a function if provided, but got: ${ee(n.resolve)}.`);const i=(s=n.args)!==null&&s!==void 0?s:{};return Tn(i)||ye(!1,`${t.name}.${r} args must be an object with argument names as keys.`),{name:mt(r),description:n.description,type:n.type,args:pl(i),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:at(n.extensions),astNode:n.astNode}})}function pl(t){return Object.entries(t).map(([e,n])=>({name:mt(e),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:at(n.extensions),astNode:n.astNode}))}function Tn(t){return un(t)&&!Array.isArray(t)}function hl(t){return Ot(t,e=>({description:e.description,type:e.type,args:gl(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}))}function gl(t){return po(t,e=>e.name,e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}))}function wr(t){return we(t.type)&&t.defaultValue===void 0}class Fi{constructor(e){var n;this.name=mt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=at(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=fl.bind(void 0,e),this._interfaces=dl.bind(void 0,e),e.resolveType==null||typeof e.resolveType=="function"||ye(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:hl(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class In{constructor(e){var n;this.name=mt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=at(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._types=Tm.bind(void 0,e),e.resolveType==null||typeof e.resolveType=="function"||ye(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}getTypes(){return typeof this._types=="function"&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Tm(t){const e=ul(t.types);return Array.isArray(e)||ye(!1,`Must provide Array of types or a function which returns such an array for Union ${t.name}.`),e}class ur{constructor(e){var n;this.name=mt(e.name),this.description=e.description,this.extensions=at(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._values=typeof e.values=="function"?e.values:La(this.name,e.values),this._valueLookup=null,this._nameLookup=null}get[Symbol.toStringTag](){return"GraphQLEnumType"}getValues(){return typeof this._values=="function"&&(this._values=La(this.name,this._values())),this._values}getValue(e){return this._nameLookup===null&&(this._nameLookup=dn(this.getValues(),n=>n.name)),this._nameLookup[e]}serialize(e){this._valueLookup===null&&(this._valueLookup=new Map(this.getValues().map(r=>[r.value,r])));const n=this._valueLookup.get(e);if(n===void 0)throw new z(`Enum "${this.name}" cannot represent value: ${ee(e)}`);return n.name}parseValue(e){if(typeof e!="string"){const r=ee(e);throw new z(`Enum "${this.name}" cannot represent non-string value: ${r}.`+kr(this,r))}const n=this.getValue(e);if(n==null)throw new z(`Value "${e}" does not exist in "${this.name}" enum.`+kr(this,e));return n.value}parseLiteral(e,n){if(e.kind!==y.ENUM){const s=ke(e);throw new z(`Enum "${this.name}" cannot represent non-enum value: ${s}.`+kr(this,s),{nodes:e})}const r=this.getValue(e.value);if(r==null){const s=ke(e);throw new z(`Value "${s}" does not exist in "${this.name}" enum.`+kr(this,s),{nodes:e})}return r.value}toConfig(){const e=po(this.getValues(),n=>n.name,n=>({description:n.description,value:n.value,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function kr(t,e){const n=t.getValues().map(s=>s.name),r=yn(e,n);return Vt("the enum value",r)}function La(t,e){return Tn(e)||ye(!1,`${t} values must be an object with value names as keys.`),Object.entries(e).map(([n,r])=>(Tn(r)||ye(!1,`${t}.${n} must refer to an object with a "value" key representing an internal value but got: ${ee(r)}.`),{name:bm(n),description:r.description,value:r.value!==void 0?r.value:n,deprecationReason:r.deprecationReason,extensions:at(r.extensions),astNode:r.astNode}))}class Ui{constructor(e){var n,r;this.name=mt(e.name),this.description=e.description,this.extensions=at(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this.isOneOf=(r=e.isOneOf)!==null&&r!==void 0?r:!1,this._fields=Im.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}toConfig(){const e=Ot(this.getFields(),n=>({description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,isOneOf:this.isOneOf}}toString(){return this.name}toJSON(){return this.toString()}}function Im(t){const e=ll(t.fields);return Tn(e)||ye(!1,`${t.name} fields must be an object with field names as keys or a function which returns such an object.`),Ot(e,(n,r)=>(!("resolve"in n)||ye(!1,`${t.name}.${r} field has a resolve property, but Input Types cannot define resolvers.`),{name:mt(r),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:at(n.extensions),astNode:n.astNode}))}function ml(t){return we(t.type)&&t.defaultValue===void 0}function Bi(t,e){return t===e?!0:we(t)&&we(e)||je(t)&&je(e)?Bi(t.ofType,e.ofType):!1}function Dn(t,e,n){return e===n?!0:we(n)?we(e)?Dn(t,e.ofType,n.ofType):!1:we(e)?Dn(t,e.ofType,n):je(n)?je(e)?Dn(t,e.ofType,n.ofType):!1:je(e)?!1:Ut(n)&&(Oe(e)||De(e))&&t.isSubType(n,e)}function xa(t,e,n){return e===n?!0:Ut(e)?Ut(n)?t.getPossibleTypes(e).some(r=>t.isSubType(n,r)):t.isSubType(e,n):Ut(n)?t.isSubType(n,e):!1}const oi=2147483647,ai=-2147483648,Dm=new Ct({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize(t){const e=br(t);if(typeof e=="boolean")return e?1:0;let n=e;if(typeof e=="string"&&e!==""&&(n=Number(e)),typeof n!="number"||!Number.isInteger(n))throw new z(`Int cannot represent non-integer value: ${ee(e)}`);if(n>oi||n<ai)throw new z("Int cannot represent non 32-bit signed integer value: "+ee(e));return n},parseValue(t){if(typeof t!="number"||!Number.isInteger(t))throw new z(`Int cannot represent non-integer value: ${ee(t)}`);if(t>oi||t<ai)throw new z(`Int cannot represent non 32-bit signed integer value: ${t}`);return t},parseLiteral(t){if(t.kind!==y.INT)throw new z(`Int cannot represent non-integer value: ${ke(t)}`,{nodes:t});const e=parseInt(t.value,10);if(e>oi||e<ai)throw new z(`Int cannot represent non 32-bit signed integer value: ${t.value}`,{nodes:t});return e}}),Nm=new Ct({name:"Float",description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize(t){const e=br(t);if(typeof e=="boolean")return e?1:0;let n=e;if(typeof e=="string"&&e!==""&&(n=Number(e)),typeof n!="number"||!Number.isFinite(n))throw new z(`Float cannot represent non numeric value: ${ee(e)}`);return n},parseValue(t){if(typeof t!="number"||!Number.isFinite(t))throw new z(`Float cannot represent non numeric value: ${ee(t)}`);return t},parseLiteral(t){if(t.kind!==y.FLOAT&&t.kind!==y.INT)throw new z(`Float cannot represent non numeric value: ${ke(t)}`,t);return parseFloat(t.value)}}),Re=new Ct({name:"String",description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize(t){const e=br(t);if(typeof e=="string")return e;if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number"&&Number.isFinite(e))return e.toString();throw new z(`String cannot represent value: ${ee(t)}`)},parseValue(t){if(typeof t!="string")throw new z(`String cannot represent a non string value: ${ee(t)}`);return t},parseLiteral(t){if(t.kind!==y.STRING)throw new z(`String cannot represent a non string value: ${ke(t)}`,{nodes:t});return t.value}}),Qe=new Ct({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(t){const e=br(t);if(typeof e=="boolean")return e;if(Number.isFinite(e))return e!==0;throw new z(`Boolean cannot represent a non boolean value: ${ee(e)}`)},parseValue(t){if(typeof t!="boolean")throw new z(`Boolean cannot represent a non boolean value: ${ee(t)}`);return t},parseLiteral(t){if(t.kind!==y.BOOLEAN)throw new z(`Boolean cannot represent a non boolean value: ${ke(t)}`,{nodes:t});return t.value}}),yl=new Ct({name:"ID",description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize(t){const e=br(t);if(typeof e=="string")return e;if(Number.isInteger(e))return String(e);throw new z(`ID cannot represent value: ${ee(t)}`)},parseValue(t){if(typeof t=="string")return t;if(typeof t=="number"&&Number.isInteger(t))return t.toString();throw new z(`ID cannot represent value: ${ee(t)}`)},parseLiteral(t){if(t.kind!==y.STRING&&t.kind!==y.INT)throw new z("ID cannot represent a non-string and non-integer value: "+ke(t),{nodes:t});return t.value}}),yo=Object.freeze([Re,Dm,Nm,Qe,yl]);function Om(t){return yo.some(({name:e})=>t.name===e)}function br(t){if(un(t)){if(typeof t.valueOf=="function"){const e=t.valueOf();if(!un(e))return e}if(typeof t.toJSON=="function")return t.toJSON()}return t}function vl(t){return gt(t,zt)}class zt{constructor(e){var n,r;this.name=mt(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=(n=e.isRepeatable)!==null&&n!==void 0?n:!1,this.extensions=at(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||ye(!1,`@${e.name} locations must be an Array.`);const s=(r=e.args)!==null&&r!==void 0?r:{};un(s)&&!Array.isArray(s)||ye(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=pl(s)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:gl(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const El=new zt({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[se.FIELD,se.FRAGMENT_SPREAD,se.INLINE_FRAGMENT],args:{if:{type:new ce(Qe),description:"Included when true."}}}),_l=new zt({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[se.FIELD,se.FRAGMENT_SPREAD,se.INLINE_FRAGMENT],args:{if:{type:new ce(Qe),description:"Skipped when true."}}}),Am="No longer supported",vo=new zt({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[se.FIELD_DEFINITION,se.ARGUMENT_DEFINITION,se.INPUT_FIELD_DEFINITION,se.ENUM_VALUE],args:{reason:{type:Re,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:Am}}}),wl=new zt({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[se.SCALAR],args:{url:{type:new ce(Re),description:"The URL that specifies the behavior of this scalar."}}}),bl=new zt({name:"oneOf",description:"Indicates exactly one field must be supplied and this field must not be `null`.",locations:[se.INPUT_OBJECT],args:{}}),vn=Object.freeze([El,_l,vo,wl,bl]);function bb(t){return vn.some(({name:e})=>e===t.name)}function Rm(t){return typeof t=="object"&&typeof(t==null?void 0:t[Symbol.iterator])=="function"}function Jn(t,e){if(we(e)){const n=Jn(t,e.ofType);return(n==null?void 0:n.kind)===y.NULL?null:n}if(t===null)return{kind:y.NULL};if(t===void 0)return null;if(je(e)){const n=e.ofType;if(Rm(t)){const r=[];for(const s of t){const i=Jn(s,n);i!=null&&r.push(i)}return{kind:y.LIST,values:r}}return Jn(t,n)}if(Ue(e)){if(!un(t))return null;const n=[];for(const r of Object.values(e.getFields())){const s=Jn(t[r.name],r.type);s&&n.push({kind:y.OBJECT_FIELD,name:{kind:y.NAME,value:r.name},value:s})}return{kind:y.OBJECT,fields:n}}if(Cn(e)){const n=e.serialize(t);if(n==null)return null;if(typeof n=="boolean")return{kind:y.BOOLEAN,value:n};if(typeof n=="number"&&Number.isFinite(n)){const r=String(n);return Ma.test(r)?{kind:y.INT,value:r}:{kind:y.FLOAT,value:r}}if(typeof n=="string")return Ke(e)?{kind:y.ENUM,value:n}:e===yl&&Ma.test(n)?{kind:y.INT,value:n}:{kind:y.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${ee(n)}.`)}ht(!1,"Unexpected input type: "+ee(e))}const Ma=/^-?(?:0|[1-9][0-9]*)$/,Eo=new st({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Re,resolve:t=>t.description},types:{description:"A list of all types supported by this server.",type:new ce(new ze(new ce(pt))),resolve(t){return Object.values(t.getTypeMap())}},queryType:{description:"The type that query operations will be rooted at.",type:new ce(pt),resolve:t=>t.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:pt,resolve:t=>t.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:pt,resolve:t=>t.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new ce(new ze(new ce(Sl))),resolve:t=>t.getDirectives()}})}),Sl=new st({name:"__Directive",description:`A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
|
|
171
|
-
|
|
172
|
-
In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.`,fields:()=>({name:{type:new ce(Re),resolve:t=>t.name},description:{type:Re,resolve:t=>t.description},isRepeatable:{type:new ce(Qe),resolve:t=>t.isRepeatable},locations:{type:new ce(new ze(new ce(Tl))),resolve:t=>t.locations},args:{type:new ce(new ze(new ce(As))),args:{includeDeprecated:{type:Qe,defaultValue:!1}},resolve(t,{includeDeprecated:e}){return e?t.args:t.args.filter(n=>n.deprecationReason==null)}}})}),Tl=new ur({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:se.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:se.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:se.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:se.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:se.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:se.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:se.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:se.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:se.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:se.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:se.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:se.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:se.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:se.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:se.UNION,description:"Location adjacent to a union definition."},ENUM:{value:se.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:se.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:se.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:se.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),pt=new st({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new ce(Nl),resolve(t){if(qt(t))return $e.SCALAR;if(De(t))return $e.OBJECT;if(Oe(t))return $e.INTERFACE;if(it(t))return $e.UNION;if(Ke(t))return $e.ENUM;if(Ue(t))return $e.INPUT_OBJECT;if(je(t))return $e.LIST;if(we(t))return $e.NON_NULL;ht(!1,`Unexpected type: "${ee(t)}".`)}},name:{type:Re,resolve:t=>"name"in t?t.name:void 0},description:{type:Re,resolve:t=>"description"in t?t.description:void 0},specifiedByURL:{type:Re,resolve:t=>"specifiedByURL"in t?t.specifiedByURL:void 0},fields:{type:new ze(new ce(Il)),args:{includeDeprecated:{type:Qe,defaultValue:!1}},resolve(t,{includeDeprecated:e}){if(De(t)||Oe(t)){const n=Object.values(t.getFields());return e?n:n.filter(r=>r.deprecationReason==null)}}},interfaces:{type:new ze(new ce(pt)),resolve(t){if(De(t)||Oe(t))return t.getInterfaces()}},possibleTypes:{type:new ze(new ce(pt)),resolve(t,e,n,{schema:r}){if(Ut(t))return r.getPossibleTypes(t)}},enumValues:{type:new ze(new ce(Dl)),args:{includeDeprecated:{type:Qe,defaultValue:!1}},resolve(t,{includeDeprecated:e}){if(Ke(t)){const n=t.getValues();return e?n:n.filter(r=>r.deprecationReason==null)}}},inputFields:{type:new ze(new ce(As)),args:{includeDeprecated:{type:Qe,defaultValue:!1}},resolve(t,{includeDeprecated:e}){if(Ue(t)){const n=Object.values(t.getFields());return e?n:n.filter(r=>r.deprecationReason==null)}}},ofType:{type:pt,resolve:t=>"ofType"in t?t.ofType:void 0},isOneOf:{type:Qe,resolve:t=>{if(Ue(t))return t.isOneOf}}})}),Il=new st({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:()=>({name:{type:new ce(Re),resolve:t=>t.name},description:{type:Re,resolve:t=>t.description},args:{type:new ce(new ze(new ce(As))),args:{includeDeprecated:{type:Qe,defaultValue:!1}},resolve(t,{includeDeprecated:e}){return e?t.args:t.args.filter(n=>n.deprecationReason==null)}},type:{type:new ce(pt),resolve:t=>t.type},isDeprecated:{type:new ce(Qe),resolve:t=>t.deprecationReason!=null},deprecationReason:{type:Re,resolve:t=>t.deprecationReason}})}),As=new st({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:()=>({name:{type:new ce(Re),resolve:t=>t.name},description:{type:Re,resolve:t=>t.description},type:{type:new ce(pt),resolve:t=>t.type},defaultValue:{type:Re,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(t){const{type:e,defaultValue:n}=t,r=Jn(n,e);return r?ke(r):null}},isDeprecated:{type:new ce(Qe),resolve:t=>t.deprecationReason!=null},deprecationReason:{type:Re,resolve:t=>t.deprecationReason}})}),Dl=new st({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:()=>({name:{type:new ce(Re),resolve:t=>t.name},description:{type:Re,resolve:t=>t.description},isDeprecated:{type:new ce(Qe),resolve:t=>t.deprecationReason!=null},deprecationReason:{type:Re,resolve:t=>t.deprecationReason}})});var $e;(function(t){t.SCALAR="SCALAR",t.OBJECT="OBJECT",t.INTERFACE="INTERFACE",t.UNION="UNION",t.ENUM="ENUM",t.INPUT_OBJECT="INPUT_OBJECT",t.LIST="LIST",t.NON_NULL="NON_NULL"})($e||($e={}));const Nl=new ur({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:$e.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:$e.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:$e.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:$e.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:$e.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:$e.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:$e.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:$e.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Pa={name:"__schema",type:new ce(Eo),description:"Access the current type schema of this server.",args:[],resolve:(t,e,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},ka={name:"__type",type:pt,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new ce(Re),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(t,{name:e},n,{schema:r})=>r.getType(e),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},$a={name:"__typename",type:new ce(Re),description:"The name of the current Object type at runtime.",args:[],resolve:(t,e,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},_o=Object.freeze([Eo,Sl,Tl,pt,Il,As,Dl,Nl]);function Ol(t){return _o.some(({name:e})=>t.name===e)}function Cm(t){return gt(t,Al)}function Lm(t){if(!Cm(t))throw new Error(`Expected ${ee(t)} to be a GraphQL schema.`);return t}class Al{constructor(e){var n,r;this.__validationErrors=e.assumeValid===!0?[]:void 0,un(e)||ye(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||ye(!1,`"types" must be Array if provided but got: ${ee(e.types)}.`),!e.directives||Array.isArray(e.directives)||ye(!1,`"directives" must be Array if provided but got: ${ee(e.directives)}.`),this.description=e.description,this.extensions=at(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=(r=e.directives)!==null&&r!==void 0?r:vn;const s=new Set(e.types);if(e.types!=null)for(const i of e.types)s.delete(i),dt(i,s);this._queryType!=null&&dt(this._queryType,s),this._mutationType!=null&&dt(this._mutationType,s),this._subscriptionType!=null&&dt(this._subscriptionType,s);for(const i of this._directives)if(vl(i))for(const o of i.args)dt(o.type,s);dt(Eo,s),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const i of s){if(i==null)continue;const o=i.name;if(o||ye(!1,"One of the provided types for building the Schema is missing a name."),this._typeMap[o]!==void 0)throw new Error(`Schema must contain uniquely named types but contains multiple types named "${o}".`);if(this._typeMap[o]=i,Oe(i)){for(const a of i.getInterfaces())if(Oe(a)){let c=this._implementationsMap[a.name];c===void 0&&(c=this._implementationsMap[a.name]={objects:[],interfaces:[]}),c.interfaces.push(i)}}else if(De(i)){for(const a of i.getInterfaces())if(Oe(a)){let c=this._implementationsMap[a.name];c===void 0&&(c=this._implementationsMap[a.name]={objects:[],interfaces:[]}),c.objects.push(i)}}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case qe.QUERY:return this.getQueryType();case qe.MUTATION:return this.getMutationType();case qe.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return it(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const n=this._implementationsMap[e.name];return n??{objects:[],interfaces:[]}}isSubType(e,n){let r=this._subTypeMap[e.name];if(r===void 0){if(r=Object.create(null),it(e))for(const s of e.getTypes())r[s.name]=!0;else{const s=this.getImplementations(e);for(const i of s.objects)r[i.name]=!0;for(const i of s.interfaces)r[i.name]=!0}this._subTypeMap[e.name]=r}return r[n.name]!==void 0}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find(n=>n.name===e)}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:this.__validationErrors!==void 0}}}function dt(t,e){const n=ft(t);if(!e.has(n)){if(e.add(n),it(n))for(const r of n.getTypes())dt(r,e);else if(De(n)||Oe(n)){for(const r of n.getInterfaces())dt(r,e);for(const r of Object.values(n.getFields())){dt(r.type,e);for(const s of r.args)dt(s.type,e)}}else if(Ue(n))for(const r of Object.values(n.getFields()))dt(r.type,e)}return e}function xm(t){if(Lm(t),t.__validationErrors)return t.__validationErrors;const e=new Pm(t);km(e),$m(e),Fm(e);const n=e.getErrors();return t.__validationErrors=n,n}function Mm(t){const e=xm(t);if(e.length!==0)throw new Error(e.map(n=>n.message).join(`
|
|
173
|
-
|
|
174
|
-
`))}class Pm{constructor(e){this._errors=[],this.schema=e}reportError(e,n){const r=Array.isArray(n)?n.filter(Boolean):n;this._errors.push(new z(e,{nodes:r}))}getErrors(){return this._errors}}function km(t){const e=t.schema,n=e.getQueryType();if(!n)t.reportError("Query root type must be provided.",e.astNode);else if(!De(n)){var r;t.reportError(`Query root type must be Object type, it cannot be ${ee(n)}.`,(r=ci(e,qe.QUERY))!==null&&r!==void 0?r:n.astNode)}const s=e.getMutationType();if(s&&!De(s)){var i;t.reportError(`Mutation root type must be Object type if provided, it cannot be ${ee(s)}.`,(i=ci(e,qe.MUTATION))!==null&&i!==void 0?i:s.astNode)}const o=e.getSubscriptionType();if(o&&!De(o)){var a;t.reportError(`Subscription root type must be Object type if provided, it cannot be ${ee(o)}.`,(a=ci(e,qe.SUBSCRIPTION))!==null&&a!==void 0?a:o.astNode)}}function ci(t,e){var n;return(n=[t.astNode,...t.extensionASTNodes].flatMap(r=>{var s;return(s=r==null?void 0:r.operationTypes)!==null&&s!==void 0?s:[]}).find(r=>r.operation===e))===null||n===void 0?void 0:n.type}function $m(t){for(const n of t.schema.getDirectives()){if(!vl(n)){t.reportError(`Expected directive but got: ${ee(n)}.`,n==null?void 0:n.astNode);continue}fn(t,n),n.locations.length===0&&t.reportError(`Directive @${n.name} must include 1 or more locations.`,n.astNode);for(const r of n.args)if(fn(t,r),_t(r.type)||t.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${ee(r.type)}.`,r.astNode),wr(r)&&r.deprecationReason!=null){var e;t.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[wo(r.astNode),(e=r.astNode)===null||e===void 0?void 0:e.type])}}}function fn(t,e){e.name.startsWith("__")&&t.reportError(`Name "${e.name}" must not begin with "__", which is reserved by GraphQL introspection.`,e.astNode)}function Fm(t){const e=qm(t),n=t.schema.getTypeMap();for(const r of Object.values(n)){if(!Sm(r)){t.reportError(`Expected GraphQL named type but got: ${ee(r)}.`,r.astNode);continue}Ol(r)||fn(t,r),De(r)||Oe(r)?(Fa(t,r),Ua(t,r)):it(r)?jm(t,r):Ke(r)?Vm(t,r):Ue(r)&&(Gm(t,r),e(r))}}function Fa(t,e){const n=Object.values(e.getFields());n.length===0&&t.reportError(`Type ${e.name} must define one or more fields.`,[e.astNode,...e.extensionASTNodes]);for(const o of n){if(fn(t,o),!Zn(o.type)){var r;t.reportError(`The type of ${e.name}.${o.name} must be Output Type but got: ${ee(o.type)}.`,(r=o.astNode)===null||r===void 0?void 0:r.type)}for(const a of o.args){const c=a.name;if(fn(t,a),!_t(a.type)){var s;t.reportError(`The type of ${e.name}.${o.name}(${c}:) must be Input Type but got: ${ee(a.type)}.`,(s=a.astNode)===null||s===void 0?void 0:s.type)}if(wr(a)&&a.deprecationReason!=null){var i;t.reportError(`Required argument ${e.name}.${o.name}(${c}:) cannot be deprecated.`,[wo(a.astNode),(i=a.astNode)===null||i===void 0?void 0:i.type])}}}}function Ua(t,e){const n=Object.create(null);for(const r of e.getInterfaces()){if(!Oe(r)){t.reportError(`Type ${ee(e)} must only implement Interface types, it cannot implement ${ee(r)}.`,er(e,r));continue}if(e===r){t.reportError(`Type ${e.name} cannot implement itself because it would create a circular reference.`,er(e,r));continue}if(n[r.name]){t.reportError(`Type ${e.name} can only implement ${r.name} once.`,er(e,r));continue}n[r.name]=!0,Bm(t,e,r),Um(t,e,r)}}function Um(t,e,n){const r=e.getFields();for(const c of Object.values(n.getFields())){const u=c.name,d=r[u];if(!d){t.reportError(`Interface field ${n.name}.${u} expected but ${e.name} does not provide it.`,[c.astNode,e.astNode,...e.extensionASTNodes]);continue}if(!Dn(t.schema,d.type,c.type)){var s,i;t.reportError(`Interface field ${n.name}.${u} expects type ${ee(c.type)} but ${e.name}.${u} is type ${ee(d.type)}.`,[(s=c.astNode)===null||s===void 0?void 0:s.type,(i=d.astNode)===null||i===void 0?void 0:i.type])}for(const l of c.args){const f=l.name,h=d.args.find(m=>m.name===f);if(!h){t.reportError(`Interface field argument ${n.name}.${u}(${f}:) expected but ${e.name}.${u} does not provide it.`,[l.astNode,d.astNode]);continue}if(!Bi(l.type,h.type)){var o,a;t.reportError(`Interface field argument ${n.name}.${u}(${f}:) expects type ${ee(l.type)} but ${e.name}.${u}(${f}:) is type ${ee(h.type)}.`,[(o=l.astNode)===null||o===void 0?void 0:o.type,(a=h.astNode)===null||a===void 0?void 0:a.type])}}for(const l of d.args){const f=l.name;!c.args.find(m=>m.name===f)&&wr(l)&&t.reportError(`Object field ${e.name}.${u} includes required argument ${f} that is missing from the Interface field ${n.name}.${u}.`,[l.astNode,c.astNode])}}}function Bm(t,e,n){const r=e.getInterfaces();for(const s of n.getInterfaces())r.includes(s)||t.reportError(s===e?`Type ${e.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${e.name} must implement ${s.name} because it is implemented by ${n.name}.`,[...er(n,s),...er(e,n)])}function jm(t,e){const n=e.getTypes();n.length===0&&t.reportError(`Union type ${e.name} must define one or more member types.`,[e.astNode,...e.extensionASTNodes]);const r=Object.create(null);for(const s of n){if(r[s.name]){t.reportError(`Union type ${e.name} can only include type ${s.name} once.`,Ba(e,s.name));continue}r[s.name]=!0,De(s)||t.reportError(`Union type ${e.name} can only include Object types, it cannot include ${ee(s)}.`,Ba(e,String(s)))}}function Vm(t,e){const n=e.getValues();n.length===0&&t.reportError(`Enum type ${e.name} must define one or more values.`,[e.astNode,...e.extensionASTNodes]);for(const r of n)fn(t,r)}function Gm(t,e){const n=Object.values(e.getFields());n.length===0&&t.reportError(`Input Object type ${e.name} must define one or more fields.`,[e.astNode,...e.extensionASTNodes]);for(const i of n){if(fn(t,i),!_t(i.type)){var r;t.reportError(`The type of ${e.name}.${i.name} must be Input Type but got: ${ee(i.type)}.`,(r=i.astNode)===null||r===void 0?void 0:r.type)}if(ml(i)&&i.deprecationReason!=null){var s;t.reportError(`Required input field ${e.name}.${i.name} cannot be deprecated.`,[wo(i.astNode),(s=i.astNode)===null||s===void 0?void 0:s.type])}e.isOneOf&&zm(e,i,t)}}function zm(t,e,n){if(we(e.type)){var r;n.reportError(`OneOf input field ${t.name}.${e.name} must be nullable.`,(r=e.astNode)===null||r===void 0?void 0:r.type)}e.defaultValue!==void 0&&n.reportError(`OneOf input field ${t.name}.${e.name} cannot have a default value.`,e.astNode)}function qm(t){const e=Object.create(null),n=[],r=Object.create(null);return s;function s(i){if(e[i.name])return;e[i.name]=!0,r[i.name]=n.length;const o=Object.values(i.getFields());for(const a of o)if(we(a.type)&&Ue(a.type.ofType)){const c=a.type.ofType,u=r[c.name];if(n.push(a),u===void 0)s(c);else{const d=n.slice(u),l=d.map(f=>f.name).join(".");t.reportError(`Cannot reference Input Object "${c.name}" within itself through a series of non-null fields: "${l}".`,d.map(f=>f.astNode))}n.pop()}r[i.name]=void 0}}function er(t,e){const{astNode:n,extensionASTNodes:r}=t;return(n!=null?[n,...r]:r).flatMap(i=>{var o;return(o=i.interfaces)!==null&&o!==void 0?o:[]}).filter(i=>i.name.value===e.name)}function Ba(t,e){const{astNode:n,extensionASTNodes:r}=t;return(n!=null?[n,...r]:r).flatMap(i=>{var o;return(o=i.types)!==null&&o!==void 0?o:[]}).filter(i=>i.name.value===e)}function wo(t){var e;return t==null||(e=t.directives)===null||e===void 0?void 0:e.find(n=>n.name.value===vo.name)}function ot(t,e){switch(e.kind){case y.LIST_TYPE:{const n=ot(t,e.type);return n&&new ze(n)}case y.NON_NULL_TYPE:{const n=ot(t,e.type);return n&&new ce(n)}case y.NAMED_TYPE:return t.getType(e.name.value)}}class Rl{constructor(e,n,r){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=r??Ym,n&&(_t(n)&&this._inputTypeStack.push(n),Gt(n)&&this._parentTypeStack.push(n),Zn(n)&&this._typeStack.push(n))}get[Symbol.toStringTag](){return"TypeInfo"}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(e){const n=this._schema;switch(e.kind){case y.SELECTION_SET:{const s=ft(this.getType());this._parentTypeStack.push(Gt(s)?s:void 0);break}case y.FIELD:{const s=this.getParentType();let i,o;s&&(i=this._getFieldDef(n,s,e),i&&(o=i.type)),this._fieldDefStack.push(i),this._typeStack.push(Zn(o)?o:void 0);break}case y.DIRECTIVE:this._directive=n.getDirective(e.name.value);break;case y.OPERATION_DEFINITION:{const s=n.getRootType(e.operation);this._typeStack.push(De(s)?s:void 0);break}case y.INLINE_FRAGMENT:case y.FRAGMENT_DEFINITION:{const s=e.typeCondition,i=s?ot(n,s):ft(this.getType());this._typeStack.push(Zn(i)?i:void 0);break}case y.VARIABLE_DEFINITION:{const s=ot(n,e.type);this._inputTypeStack.push(_t(s)?s:void 0);break}case y.ARGUMENT:{var r;let s,i;const o=(r=this.getDirective())!==null&&r!==void 0?r:this.getFieldDef();o&&(s=o.args.find(a=>a.name===e.name.value),s&&(i=s.type)),this._argument=s,this._defaultValueStack.push(s?s.defaultValue:void 0),this._inputTypeStack.push(_t(i)?i:void 0);break}case y.LIST:{const s=cl(this.getInputType()),i=je(s)?s.ofType:s;this._defaultValueStack.push(void 0),this._inputTypeStack.push(_t(i)?i:void 0);break}case y.OBJECT_FIELD:{const s=ft(this.getInputType());let i,o;Ue(s)&&(o=s.getFields()[e.name.value],o&&(i=o.type)),this._defaultValueStack.push(o?o.defaultValue:void 0),this._inputTypeStack.push(_t(i)?i:void 0);break}case y.ENUM:{const s=ft(this.getInputType());let i;Ke(s)&&(i=s.getValue(e.value)),this._enumValue=i;break}}}leave(e){switch(e.kind){case y.SELECTION_SET:this._parentTypeStack.pop();break;case y.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case y.DIRECTIVE:this._directive=null;break;case y.OPERATION_DEFINITION:case y.INLINE_FRAGMENT:case y.FRAGMENT_DEFINITION:this._typeStack.pop();break;case y.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case y.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case y.LIST:case y.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case y.ENUM:this._enumValue=null;break}}}function Ym(t,e,n){const r=n.name.value;if(r===Pa.name&&t.getQueryType()===e)return Pa;if(r===ka.name&&t.getQueryType()===e)return ka;if(r===$a.name&&Gt(e))return $a;if(De(e)||Oe(e))return e.getFields()[r]}function Cl(t,e){return{enter(...n){const r=n[0];t.enter(r);const s=cs(e,r.kind).enter;if(s){const i=s.apply(e,n);return i!==void 0&&(t.leave(r),Mi(i)&&t.enter(i)),i}},leave(...n){const r=n[0],s=cs(e,r.kind).leave;let i;return s&&(i=s.apply(e,n)),t.leave(r),i}}}function Hm(t){return t.kind===y.OPERATION_DEFINITION||t.kind===y.FRAGMENT_DEFINITION}function Jm(t){return t.kind===y.SCHEMA_DEFINITION||Sr(t)||t.kind===y.DIRECTIVE_DEFINITION}function Sr(t){return t.kind===y.SCALAR_TYPE_DEFINITION||t.kind===y.OBJECT_TYPE_DEFINITION||t.kind===y.INTERFACE_TYPE_DEFINITION||t.kind===y.UNION_TYPE_DEFINITION||t.kind===y.ENUM_TYPE_DEFINITION||t.kind===y.INPUT_OBJECT_TYPE_DEFINITION}function Wm(t){return t.kind===y.SCHEMA_EXTENSION||bo(t)}function bo(t){return t.kind===y.SCALAR_TYPE_EXTENSION||t.kind===y.OBJECT_TYPE_EXTENSION||t.kind===y.INTERFACE_TYPE_EXTENSION||t.kind===y.UNION_TYPE_EXTENSION||t.kind===y.ENUM_TYPE_EXTENSION||t.kind===y.INPUT_OBJECT_TYPE_EXTENSION}function Qm(t){return{Document(e){for(const n of e.definitions)if(!Hm(n)){const r=n.kind===y.SCHEMA_DEFINITION||n.kind===y.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';t.reportError(new z(`The ${r} definition is not executable.`,{nodes:n}))}return!1}}}function Km(t){return{Field(e){const n=t.getParentType();if(n&&!t.getFieldDef()){const s=t.getSchema(),i=e.name.value;let o=Vt("to use an inline fragment on",Xm(s,n,i));o===""&&(o=Vt(Zm(n,i))),t.reportError(new z(`Cannot query field "${i}" on type "${n.name}".`+o,{nodes:e}))}}}}function Xm(t,e,n){if(!Ut(e))return[];const r=new Set,s=Object.create(null);for(const o of t.getPossibleTypes(e))if(o.getFields()[n]){r.add(o),s[o.name]=1;for(const a of o.getInterfaces()){var i;a.getFields()[n]&&(r.add(a),s[a.name]=((i=s[a.name])!==null&&i!==void 0?i:0)+1)}}return[...r].sort((o,a)=>{const c=s[a.name]-s[o.name];return c!==0?c:Oe(o)&&t.isSubType(o,a)?-1:Oe(a)&&t.isSubType(a,o)?1:ho(o.name,a.name)}).map(o=>o.name)}function Zm(t,e){if(De(t)||Oe(t)){const n=Object.keys(t.getFields());return yn(e,n)}return[]}function ey(t){return{InlineFragment(e){const n=e.typeCondition;if(n){const r=ot(t.getSchema(),n);if(r&&!Gt(r)){const s=ke(n);t.reportError(new z(`Fragment cannot condition on non composite type "${s}".`,{nodes:n}))}}},FragmentDefinition(e){const n=ot(t.getSchema(),e.typeCondition);if(n&&!Gt(n)){const r=ke(e.typeCondition);t.reportError(new z(`Fragment "${e.name.value}" cannot condition on non composite type "${r}".`,{nodes:e.typeCondition}))}}}}function ty(t){return{...Ll(t),Argument(e){const n=t.getArgument(),r=t.getFieldDef(),s=t.getParentType();if(!n&&r&&s){const i=e.name.value,o=r.args.map(c=>c.name),a=yn(i,o);t.reportError(new z(`Unknown argument "${i}" on field "${s.name}.${r.name}".`+Vt(a),{nodes:e}))}}}}function Ll(t){const e=Object.create(null),n=t.getSchema(),r=n?n.getDirectives():vn;for(const o of r)e[o.name]=o.args.map(a=>a.name);const s=t.getDocument().definitions;for(const o of s)if(o.kind===y.DIRECTIVE_DEFINITION){var i;const a=(i=o.arguments)!==null&&i!==void 0?i:[];e[o.name.value]=a.map(c=>c.name.value)}return{Directive(o){const a=o.name.value,c=e[a];if(o.arguments&&c)for(const u of o.arguments){const d=u.name.value;if(!c.includes(d)){const l=yn(d,c);t.reportError(new z(`Unknown argument "${d}" on directive "@${a}".`+Vt(l),{nodes:u}))}}return!1}}}function xl(t){const e=Object.create(null),n=t.getSchema(),r=n?n.getDirectives():vn;for(const i of r)e[i.name]=i.locations;const s=t.getDocument().definitions;for(const i of s)i.kind===y.DIRECTIVE_DEFINITION&&(e[i.name.value]=i.locations.map(o=>o.value));return{Directive(i,o,a,c,u){const d=i.name.value,l=e[d];if(!l){t.reportError(new z(`Unknown directive "@${d}".`,{nodes:i}));return}const f=ny(u);f&&!l.includes(f)&&t.reportError(new z(`Directive "@${d}" may not be used on ${f}.`,{nodes:i}))}}}function ny(t){const e=t[t.length-1];switch("kind"in e||ht(!1),e.kind){case y.OPERATION_DEFINITION:return ry(e.operation);case y.FIELD:return se.FIELD;case y.FRAGMENT_SPREAD:return se.FRAGMENT_SPREAD;case y.INLINE_FRAGMENT:return se.INLINE_FRAGMENT;case y.FRAGMENT_DEFINITION:return se.FRAGMENT_DEFINITION;case y.VARIABLE_DEFINITION:return se.VARIABLE_DEFINITION;case y.SCHEMA_DEFINITION:case y.SCHEMA_EXTENSION:return se.SCHEMA;case y.SCALAR_TYPE_DEFINITION:case y.SCALAR_TYPE_EXTENSION:return se.SCALAR;case y.OBJECT_TYPE_DEFINITION:case y.OBJECT_TYPE_EXTENSION:return se.OBJECT;case y.FIELD_DEFINITION:return se.FIELD_DEFINITION;case y.INTERFACE_TYPE_DEFINITION:case y.INTERFACE_TYPE_EXTENSION:return se.INTERFACE;case y.UNION_TYPE_DEFINITION:case y.UNION_TYPE_EXTENSION:return se.UNION;case y.ENUM_TYPE_DEFINITION:case y.ENUM_TYPE_EXTENSION:return se.ENUM;case y.ENUM_VALUE_DEFINITION:return se.ENUM_VALUE;case y.INPUT_OBJECT_TYPE_DEFINITION:case y.INPUT_OBJECT_TYPE_EXTENSION:return se.INPUT_OBJECT;case y.INPUT_VALUE_DEFINITION:{const n=t[t.length-3];return"kind"in n||ht(!1),n.kind===y.INPUT_OBJECT_TYPE_DEFINITION?se.INPUT_FIELD_DEFINITION:se.ARGUMENT_DEFINITION}default:ht(!1,"Unexpected kind: "+ee(e.kind))}}function ry(t){switch(t){case qe.QUERY:return se.QUERY;case qe.MUTATION:return se.MUTATION;case qe.SUBSCRIPTION:return se.SUBSCRIPTION}}function sy(t){return{FragmentSpread(e){const n=e.name.value;t.getFragment(n)||t.reportError(new z(`Unknown fragment "${n}".`,{nodes:e.name}))}}}function Ml(t){const e=t.getSchema(),n=e?e.getTypeMap():Object.create(null),r=Object.create(null);for(const i of t.getDocument().definitions)Sr(i)&&(r[i.name.value]=!0);const s=[...Object.keys(n),...Object.keys(r)];return{NamedType(i,o,a,c,u){const d=i.name.value;if(!n[d]&&!r[d]){var l;const f=(l=u[2])!==null&&l!==void 0?l:a,h=f!=null&&iy(f);if(h&&ja.includes(d))return;const m=yn(d,h?ja.concat(s):s);t.reportError(new z(`Unknown type "${d}".`+Vt(m),{nodes:i}))}}}}const ja=[...yo,..._o].map(t=>t.name);function iy(t){return"kind"in t&&(Jm(t)||Wm(t))}function oy(t){let e=0;return{Document(n){e=n.definitions.filter(r=>r.kind===y.OPERATION_DEFINITION).length},OperationDefinition(n){!n.name&&e>1&&t.reportError(new z("This anonymous operation must be the only defined operation.",{nodes:n}))}}}function ay(t){var e,n,r;const s=t.getSchema(),i=(e=(n=(r=s==null?void 0:s.astNode)!==null&&r!==void 0?r:s==null?void 0:s.getQueryType())!==null&&n!==void 0?n:s==null?void 0:s.getMutationType())!==null&&e!==void 0?e:s==null?void 0:s.getSubscriptionType();let o=0;return{SchemaDefinition(a){if(i){t.reportError(new z("Cannot define a new schema within a schema extension.",{nodes:a}));return}o>0&&t.reportError(new z("Must provide only one schema definition.",{nodes:a})),++o}}}const cy=3;function uy(t){function e(n,r=Object.create(null),s=0){if(n.kind===y.FRAGMENT_SPREAD){const i=n.name.value;if(r[i]===!0)return!1;const o=t.getFragment(i);if(!o)return!1;try{return r[i]=!0,e(o,r,s)}finally{r[i]=void 0}}if(n.kind===y.FIELD&&(n.name.value==="fields"||n.name.value==="interfaces"||n.name.value==="possibleTypes"||n.name.value==="inputFields")&&(s++,s>=cy))return!0;if("selectionSet"in n&&n.selectionSet){for(const i of n.selectionSet.selections)if(e(i,r,s))return!0}return!1}return{Field(n){if((n.name.value==="__schema"||n.name.value==="__type")&&e(n))return t.reportError(new z("Maximum introspection depth exceeded",{nodes:[n]})),!1}}}function ly(t){const e=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(i){return s(i),!1}};function s(i){if(e[i.name.value])return;const o=i.name.value;e[o]=!0;const a=t.getFragmentSpreads(i.selectionSet);if(a.length!==0){r[o]=n.length;for(const c of a){const u=c.name.value,d=r[u];if(n.push(c),d===void 0){const l=t.getFragment(u);l&&s(l)}else{const l=n.slice(d),f=l.slice(0,-1).map(h=>'"'+h.name.value+'"').join(", ");t.reportError(new z(`Cannot spread fragment "${u}" within itself`+(f!==""?` via ${f}.`:"."),{nodes:l}))}n.pop()}r[o]=void 0}}}function dy(t){let e=Object.create(null);return{OperationDefinition:{enter(){e=Object.create(null)},leave(n){const r=t.getRecursiveVariableUsages(n);for(const{node:s}of r){const i=s.name.value;e[i]!==!0&&t.reportError(new z(n.name?`Variable "$${i}" is not defined by operation "${n.name.value}".`:`Variable "$${i}" is not defined.`,{nodes:[s,n]}))}}},VariableDefinition(n){e[n.variable.name.value]=!0}}}function fy(t){const e=[],n=[];return{OperationDefinition(r){return e.push(r),!1},FragmentDefinition(r){return n.push(r),!1},Document:{leave(){const r=Object.create(null);for(const s of e)for(const i of t.getRecursivelyReferencedFragments(s))r[i.name.value]=!0;for(const s of n){const i=s.name.value;r[i]!==!0&&t.reportError(new z(`Fragment "${i}" is never used.`,{nodes:s}))}}}}}function py(t){let e=[];return{OperationDefinition:{enter(){e=[]},leave(n){const r=Object.create(null),s=t.getRecursiveVariableUsages(n);for(const{node:i}of s)r[i.name.value]=!0;for(const i of e){const o=i.variable.name.value;r[o]!==!0&&t.reportError(new z(n.name?`Variable "$${o}" is never used in operation "${n.name.value}".`:`Variable "$${o}" is never used.`,{nodes:i}))}}},VariableDefinition(n){e.push(n)}}}function So(t){switch(t.kind){case y.OBJECT:return{...t,fields:hy(t.fields)};case y.LIST:return{...t,values:t.values.map(So)};case y.INT:case y.FLOAT:case y.STRING:case y.BOOLEAN:case y.NULL:case y.ENUM:case y.VARIABLE:return t}}function hy(t){return t.map(e=>({...e,value:So(e.value)})).sort((e,n)=>ho(e.name.value,n.name.value))}function Pl(t){return Array.isArray(t)?t.map(([e,n])=>`subfields "${e}" conflict because `+Pl(n)).join(" and "):t}function gy(t){const e=new Fl,n=new wy,r=new Map;return{SelectionSet(s){const i=my(t,r,e,n,t.getParentType(),s);for(const[[o,a],c,u]of i){const d=Pl(a);t.reportError(new z(`Fields "${o}" conflict because ${d}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:c.concat(u)}))}}}}function my(t,e,n,r,s,i){const o=[],[a,c]=ds(t,e,s,i);if(vy(t,o,e,n,r,a),c.length!==0)for(let u=0;u<c.length;u++){us(t,o,e,n,r,!1,a,c[u]);for(let d=u+1;d<c.length;d++)ls(t,o,e,n,r,!1,c[u],c[d])}return o}function us(t,e,n,r,s,i,o,a){if(r.has(o,a,i))return;r.add(o,a,i);const c=t.getFragment(a);if(!c)return;const[u,d]=Vi(t,n,c);if(o!==u){To(t,e,n,r,s,i,o,u);for(const l of d)us(t,e,n,r,s,i,o,l)}}function ls(t,e,n,r,s,i,o,a){if(o===a||s.has(o,a,i))return;s.add(o,a,i);const c=t.getFragment(o),u=t.getFragment(a);if(!c||!u)return;const[d,l]=Vi(t,n,c),[f,h]=Vi(t,n,u);To(t,e,n,r,s,i,d,f);for(const m of h)ls(t,e,n,r,s,i,o,m);for(const m of l)ls(t,e,n,r,s,i,m,a)}function yy(t,e,n,r,s,i,o,a,c){const u=[],[d,l]=ds(t,e,i,o),[f,h]=ds(t,e,a,c);To(t,u,e,n,r,s,d,f);for(const m of h)us(t,u,e,n,r,s,d,m);for(const m of l)us(t,u,e,n,r,s,f,m);for(const m of l)for(const E of h)ls(t,u,e,n,r,s,m,E);return u}function vy(t,e,n,r,s,i){for(const[o,a]of Object.entries(i))if(a.length>1)for(let c=0;c<a.length;c++)for(let u=c+1;u<a.length;u++){const d=kl(t,n,r,s,!1,o,a[c],a[u]);d&&e.push(d)}}function To(t,e,n,r,s,i,o,a){for(const[c,u]of Object.entries(o)){const d=a[c];if(d)for(const l of u)for(const f of d){const h=kl(t,n,r,s,i,c,l,f);h&&e.push(h)}}}function kl(t,e,n,r,s,i,o,a){const[c,u,d]=o,[l,f,h]=a,m=s||c!==l&&De(c)&&De(l);if(!m){const R=u.name.value,Q=f.name.value;if(R!==Q)return[[i,`"${R}" and "${Q}" are different fields`],[u],[f]];if(!Ey(u,f))return[[i,"they have differing arguments"],[u],[f]]}const E=d==null?void 0:d.type,D=h==null?void 0:h.type;if(E&&D&&ji(E,D))return[[i,`they return conflicting types "${ee(E)}" and "${ee(D)}"`],[u],[f]];const P=u.selectionSet,B=f.selectionSet;if(P&&B){const R=yy(t,e,n,r,m,ft(E),P,ft(D),B);return _y(R,i,u,f)}}function Ey(t,e){const n=t.arguments,r=e.arguments;if(n===void 0||n.length===0)return r===void 0||r.length===0;if(r===void 0||r.length===0||n.length!==r.length)return!1;const s=new Map(r.map(({name:i,value:o})=>[i.value,o]));return n.every(i=>{const o=i.value,a=s.get(i.name.value);return a===void 0?!1:Va(o)===Va(a)})}function Va(t){return ke(So(t))}function ji(t,e){return je(t)?je(e)?ji(t.ofType,e.ofType):!0:je(e)?!0:we(t)?we(e)?ji(t.ofType,e.ofType):!0:we(e)?!0:Cn(t)||Cn(e)?t!==e:!1}function ds(t,e,n,r){const s=e.get(r);if(s)return s;const i=Object.create(null),o=Object.create(null);$l(t,n,r,i,o);const a=[i,Object.keys(o)];return e.set(r,a),a}function Vi(t,e,n){const r=e.get(n.selectionSet);if(r)return r;const s=ot(t.getSchema(),n.typeCondition);return ds(t,e,s,n.selectionSet)}function $l(t,e,n,r,s){for(const i of n.selections)switch(i.kind){case y.FIELD:{const o=i.name.value;let a;(De(e)||Oe(e))&&(a=e.getFields()[o]);const c=i.alias?i.alias.value:o;r[c]||(r[c]=[]),r[c].push([e,i,a]);break}case y.FRAGMENT_SPREAD:s[i.name.value]=!0;break;case y.INLINE_FRAGMENT:{const o=i.typeCondition,a=o?ot(t.getSchema(),o):e;$l(t,a,i.selectionSet,r,s);break}}}function _y(t,e,n,r){if(t.length>0)return[[e,t.map(([s])=>s)],[n,...t.map(([,s])=>s).flat()],[r,...t.map(([,,s])=>s).flat()]]}class Fl{constructor(){this._data=new Map}has(e,n,r){var s;const i=(s=this._data.get(e))===null||s===void 0?void 0:s.get(n);return i===void 0?!1:r?!0:r===i}add(e,n,r){const s=this._data.get(e);s===void 0?this._data.set(e,new Map([[n,r]])):s.set(n,r)}}class wy{constructor(){this._orderedPairSet=new Fl}has(e,n,r){return e<n?this._orderedPairSet.has(e,n,r):this._orderedPairSet.has(n,e,r)}add(e,n,r){e<n?this._orderedPairSet.add(e,n,r):this._orderedPairSet.add(n,e,r)}}function by(t){return{InlineFragment(e){const n=t.getType(),r=t.getParentType();if(Gt(n)&&Gt(r)&&!xa(t.getSchema(),n,r)){const s=ee(r),i=ee(n);t.reportError(new z(`Fragment cannot be spread here as objects of type "${s}" can never be of type "${i}".`,{nodes:e}))}},FragmentSpread(e){const n=e.name.value,r=Sy(t,n),s=t.getParentType();if(r&&s&&!xa(t.getSchema(),r,s)){const i=ee(s),o=ee(r);t.reportError(new z(`Fragment "${n}" cannot be spread here as objects of type "${i}" can never be of type "${o}".`,{nodes:e}))}}}}function Sy(t,e){const n=t.getFragment(e);if(n){const r=ot(t.getSchema(),n.typeCondition);if(Gt(r))return r}}function Ty(t){const e=t.getSchema(),n=Object.create(null);for(const s of t.getDocument().definitions)Sr(s)&&(n[s.name.value]=s);return{ScalarTypeExtension:r,ObjectTypeExtension:r,InterfaceTypeExtension:r,UnionTypeExtension:r,EnumTypeExtension:r,InputObjectTypeExtension:r};function r(s){const i=s.name.value,o=n[i],a=e==null?void 0:e.getType(i);let c;if(o?c=Iy[o.kind]:a&&(c=Dy(a)),c){if(c!==s.kind){const u=Ny(s.kind);t.reportError(new z(`Cannot extend non-${u} type "${i}".`,{nodes:o?[o,s]:s}))}}else{const u=Object.keys({...n,...e==null?void 0:e.getTypeMap()}),d=yn(i,u);t.reportError(new z(`Cannot extend type "${i}" because it is not defined.`+Vt(d),{nodes:s.name}))}}}const Iy={[y.SCALAR_TYPE_DEFINITION]:y.SCALAR_TYPE_EXTENSION,[y.OBJECT_TYPE_DEFINITION]:y.OBJECT_TYPE_EXTENSION,[y.INTERFACE_TYPE_DEFINITION]:y.INTERFACE_TYPE_EXTENSION,[y.UNION_TYPE_DEFINITION]:y.UNION_TYPE_EXTENSION,[y.ENUM_TYPE_DEFINITION]:y.ENUM_TYPE_EXTENSION,[y.INPUT_OBJECT_TYPE_DEFINITION]:y.INPUT_OBJECT_TYPE_EXTENSION};function Dy(t){if(qt(t))return y.SCALAR_TYPE_EXTENSION;if(De(t))return y.OBJECT_TYPE_EXTENSION;if(Oe(t))return y.INTERFACE_TYPE_EXTENSION;if(it(t))return y.UNION_TYPE_EXTENSION;if(Ke(t))return y.ENUM_TYPE_EXTENSION;if(Ue(t))return y.INPUT_OBJECT_TYPE_EXTENSION;ht(!1,"Unexpected type: "+ee(t))}function Ny(t){switch(t){case y.SCALAR_TYPE_EXTENSION:return"scalar";case y.OBJECT_TYPE_EXTENSION:return"object";case y.INTERFACE_TYPE_EXTENSION:return"interface";case y.UNION_TYPE_EXTENSION:return"union";case y.ENUM_TYPE_EXTENSION:return"enum";case y.INPUT_OBJECT_TYPE_EXTENSION:return"input object";default:ht(!1,"Unexpected kind: "+ee(t))}}function Oy(t){return{...Ul(t),Field:{leave(e){var n;const r=t.getFieldDef();if(!r)return!1;const s=new Set((n=e.arguments)===null||n===void 0?void 0:n.map(i=>i.name.value));for(const i of r.args)if(!s.has(i.name)&&wr(i)){const o=ee(i.type);t.reportError(new z(`Field "${r.name}" argument "${i.name}" of type "${o}" is required, but it was not provided.`,{nodes:e}))}}}}}function Ul(t){var e;const n=Object.create(null),r=t.getSchema(),s=(e=r==null?void 0:r.getDirectives())!==null&&e!==void 0?e:vn;for(const a of s)n[a.name]=dn(a.args.filter(wr),c=>c.name);const i=t.getDocument().definitions;for(const a of i)if(a.kind===y.DIRECTIVE_DEFINITION){var o;const c=(o=a.arguments)!==null&&o!==void 0?o:[];n[a.name.value]=dn(c.filter(Ay),u=>u.name.value)}return{Directive:{leave(a){const c=a.name.value,u=n[c];if(u){var d;const l=(d=a.arguments)!==null&&d!==void 0?d:[],f=new Set(l.map(h=>h.name.value));for(const[h,m]of Object.entries(u))if(!f.has(h)){const E=go(m.type)?ee(m.type):ke(m.type);t.reportError(new z(`Directive "@${c}" argument "${h}" of type "${E}" is required, but it was not provided.`,{nodes:a}))}}}}}}function Ay(t){return t.type.kind===y.NON_NULL_TYPE&&t.defaultValue==null}function Ry(t){return{Field(e){const n=t.getType(),r=e.selectionSet;if(n)if(Cn(ft(n))){if(r){const s=e.name.value,i=ee(n);t.reportError(new z(`Field "${s}" must not have a selection since type "${i}" has no subfields.`,{nodes:r}))}}else if(r){if(r.selections.length===0){const s=e.name.value,i=ee(n);t.reportError(new z(`Field "${s}" of type "${i}" must have at least one field selected.`,{nodes:e}))}}else{const s=e.name.value,i=ee(n);t.reportError(new z(`Field "${s}" of type "${i}" must have a selection of subfields. Did you mean "${s} { ... }"?`,{nodes:e}))}}}}function tn(t,e,n){if(t){if(t.kind===y.VARIABLE){const r=t.name.value;if(n==null||n[r]===void 0)return;const s=n[r];return s===null&&we(e)?void 0:s}if(we(e))return t.kind===y.NULL?void 0:tn(t,e.ofType,n);if(t.kind===y.NULL)return null;if(je(e)){const r=e.ofType;if(t.kind===y.LIST){const i=[];for(const o of t.values)if(Ga(o,n)){if(we(r))return;i.push(null)}else{const a=tn(o,r,n);if(a===void 0)return;i.push(a)}return i}const s=tn(t,r,n);return s===void 0?void 0:[s]}if(Ue(e)){if(t.kind!==y.OBJECT)return;const r=Object.create(null),s=dn(t.fields,i=>i.name.value);for(const i of Object.values(e.getFields())){const o=s[i.name];if(!o||Ga(o.value,n)){if(i.defaultValue!==void 0)r[i.name]=i.defaultValue;else if(we(i.type))return;continue}const a=tn(o.value,i.type,n);if(a===void 0)return;r[i.name]=a}if(e.isOneOf){const i=Object.keys(r);if(i.length!==1||r[i[0]]===null)return}return r}if(Cn(e)){let r;try{r=e.parseLiteral(t,n)}catch{return}return r===void 0?void 0:r}ht(!1,"Unexpected input type: "+ee(e))}}function Ga(t,e){return t.kind===y.VARIABLE&&(e==null||e[t.name.value]===void 0)}function Cy(t,e,n){var r;const s={},i=(r=e.arguments)!==null&&r!==void 0?r:[],o=dn(i,a=>a.name.value);for(const a of t.args){const c=a.name,u=a.type,d=o[c];if(!d){if(a.defaultValue!==void 0)s[c]=a.defaultValue;else if(we(u))throw new z(`Argument "${c}" of required type "${ee(u)}" was not provided.`,{nodes:e});continue}const l=d.value;let f=l.kind===y.NULL;if(l.kind===y.VARIABLE){const m=l.name.value;if(n==null||!Ly(n,m)){if(a.defaultValue!==void 0)s[c]=a.defaultValue;else if(we(u))throw new z(`Argument "${c}" of required type "${ee(u)}" was provided the variable "$${m}" which was not provided a runtime value.`,{nodes:l});continue}f=n[m]==null}if(f&&we(u))throw new z(`Argument "${c}" of non-null type "${ee(u)}" must not be null.`,{nodes:l});const h=tn(l,u,n);if(h===void 0)throw new z(`Argument "${c}" has invalid value ${ke(l)}.`,{nodes:l});s[c]=h}return s}function lr(t,e,n){var r;const s=(r=e.directives)===null||r===void 0?void 0:r.find(i=>i.name.value===t.name);if(s)return Cy(t,s,n)}function Ly(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function xy(t,e,n,r,s){const i=new Map;return Gi(t,e,n,r,s,i,new Set),i}function Gi(t,e,n,r,s,i,o){for(const a of s.selections)switch(a.kind){case y.FIELD:{if(!ui(n,a))continue;const c=My(a),u=i.get(c);u!==void 0?u.push(a):i.set(c,[a]);break}case y.INLINE_FRAGMENT:{if(!ui(n,a)||!za(t,a,r))continue;Gi(t,e,n,r,a.selectionSet,i,o);break}case y.FRAGMENT_SPREAD:{const c=a.name.value;if(o.has(c)||!ui(n,a))continue;o.add(c);const u=e[c];if(!u||!za(t,u,r))continue;Gi(t,e,n,r,u.selectionSet,i,o);break}}}function ui(t,e){const n=lr(_l,e,t);if((n==null?void 0:n.if)===!0)return!1;const r=lr(El,e,t);return(r==null?void 0:r.if)!==!1}function za(t,e,n){const r=e.typeCondition;if(!r)return!0;const s=ot(t,r);return s===n?!0:Ut(s)?t.isSubType(s,n):!1}function My(t){return t.alias?t.alias.value:t.name.value}function Py(t){return{OperationDefinition(e){if(e.operation==="subscription"){const n=t.getSchema(),r=n.getSubscriptionType();if(r){const s=e.name?e.name.value:null,i=Object.create(null),o=t.getDocument(),a=Object.create(null);for(const u of o.definitions)u.kind===y.FRAGMENT_DEFINITION&&(a[u.name.value]=u);const c=xy(n,a,i,r,e.selectionSet);if(c.size>1){const l=[...c.values()].slice(1).flat();t.reportError(new z(s!=null?`Subscription "${s}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",{nodes:l}))}for(const u of c.values())u[0].name.value.startsWith("__")&&t.reportError(new z(s!=null?`Subscription "${s}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",{nodes:u}))}}}}}function Io(t,e){const n=new Map;for(const r of t){const s=e(r),i=n.get(s);i===void 0?n.set(s,[r]):i.push(r)}return n}function ky(t){return{DirectiveDefinition(r){var s;const i=(s=r.arguments)!==null&&s!==void 0?s:[];return n(`@${r.name.value}`,i)},InterfaceTypeDefinition:e,InterfaceTypeExtension:e,ObjectTypeDefinition:e,ObjectTypeExtension:e};function e(r){var s;const i=r.name.value,o=(s=r.fields)!==null&&s!==void 0?s:[];for(const c of o){var a;const u=c.name.value,d=(a=c.arguments)!==null&&a!==void 0?a:[];n(`${i}.${u}`,d)}return!1}function n(r,s){const i=Io(s,o=>o.name.value);for(const[o,a]of i)a.length>1&&t.reportError(new z(`Argument "${r}(${o}:)" can only be defined once.`,{nodes:a.map(c=>c.name)}));return!1}}function Bl(t){return{Field:e,Directive:e};function e(n){var r;const s=(r=n.arguments)!==null&&r!==void 0?r:[],i=Io(s,o=>o.name.value);for(const[o,a]of i)a.length>1&&t.reportError(new z(`There can be only one argument named "${o}".`,{nodes:a.map(c=>c.name)}))}}function $y(t){const e=Object.create(null),n=t.getSchema();return{DirectiveDefinition(r){const s=r.name.value;if(n!=null&&n.getDirective(s)){t.reportError(new z(`Directive "@${s}" already exists in the schema. It cannot be redefined.`,{nodes:r.name}));return}return e[s]?t.reportError(new z(`There can be only one directive named "@${s}".`,{nodes:[e[s],r.name]})):e[s]=r.name,!1}}}function jl(t){const e=Object.create(null),n=t.getSchema(),r=n?n.getDirectives():vn;for(const a of r)e[a.name]=!a.isRepeatable;const s=t.getDocument().definitions;for(const a of s)a.kind===y.DIRECTIVE_DEFINITION&&(e[a.name.value]=!a.repeatable);const i=Object.create(null),o=Object.create(null);return{enter(a){if(!("directives"in a)||!a.directives)return;let c;if(a.kind===y.SCHEMA_DEFINITION||a.kind===y.SCHEMA_EXTENSION)c=i;else if(Sr(a)||bo(a)){const u=a.name.value;c=o[u],c===void 0&&(o[u]=c=Object.create(null))}else c=Object.create(null);for(const u of a.directives){const d=u.name.value;e[d]&&(c[d]?t.reportError(new z(`The directive "@${d}" can only be used once at this location.`,{nodes:[c[d],u]})):c[d]=u)}}}}function Fy(t){const e=t.getSchema(),n=e?e.getTypeMap():Object.create(null),r=Object.create(null);return{EnumTypeDefinition:s,EnumTypeExtension:s};function s(i){var o;const a=i.name.value;r[a]||(r[a]=Object.create(null));const c=(o=i.values)!==null&&o!==void 0?o:[],u=r[a];for(const d of c){const l=d.name.value,f=n[a];Ke(f)&&f.getValue(l)?t.reportError(new z(`Enum value "${a}.${l}" already exists in the schema. It cannot also be defined in this type extension.`,{nodes:d.name})):u[l]?t.reportError(new z(`Enum value "${a}.${l}" can only be defined once.`,{nodes:[u[l],d.name]})):u[l]=d.name}return!1}}function Uy(t){const e=t.getSchema(),n=e?e.getTypeMap():Object.create(null),r=Object.create(null);return{InputObjectTypeDefinition:s,InputObjectTypeExtension:s,InterfaceTypeDefinition:s,InterfaceTypeExtension:s,ObjectTypeDefinition:s,ObjectTypeExtension:s};function s(i){var o;const a=i.name.value;r[a]||(r[a]=Object.create(null));const c=(o=i.fields)!==null&&o!==void 0?o:[],u=r[a];for(const d of c){const l=d.name.value;By(n[a],l)?t.reportError(new z(`Field "${a}.${l}" already exists in the schema. It cannot also be defined in this type extension.`,{nodes:d.name})):u[l]?t.reportError(new z(`Field "${a}.${l}" can only be defined once.`,{nodes:[u[l],d.name]})):u[l]=d.name}return!1}}function By(t,e){return De(t)||Oe(t)||Ue(t)?t.getFields()[e]!=null:!1}function jy(t){const e=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return e[r]?t.reportError(new z(`There can be only one fragment named "${r}".`,{nodes:[e[r],n.name]})):e[r]=n.name,!1}}}function Vl(t){const e=[];let n=Object.create(null);return{ObjectValue:{enter(){e.push(n),n=Object.create(null)},leave(){const r=e.pop();r||ht(!1),n=r}},ObjectField(r){const s=r.name.value;n[s]?t.reportError(new z(`There can be only one input field named "${s}".`,{nodes:[n[s],r.name]})):n[s]=r.name}}}function Vy(t){const e=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(e[r.value]?t.reportError(new z(`There can be only one operation named "${r.value}".`,{nodes:[e[r.value],r]})):e[r.value]=r),!1},FragmentDefinition:()=>!1}}function Gy(t){const e=t.getSchema(),n=Object.create(null),r=e?{query:e.getQueryType(),mutation:e.getMutationType(),subscription:e.getSubscriptionType()}:{};return{SchemaDefinition:s,SchemaExtension:s};function s(i){var o;const a=(o=i.operationTypes)!==null&&o!==void 0?o:[];for(const c of a){const u=c.operation,d=n[u];r[u]?t.reportError(new z(`Type for ${u} already defined in the schema. It cannot be redefined.`,{nodes:c})):d?t.reportError(new z(`There can be only one ${u} type in schema.`,{nodes:[d,c]})):n[u]=c}return!1}}function zy(t){const e=Object.create(null),n=t.getSchema();return{ScalarTypeDefinition:r,ObjectTypeDefinition:r,InterfaceTypeDefinition:r,UnionTypeDefinition:r,EnumTypeDefinition:r,InputObjectTypeDefinition:r};function r(s){const i=s.name.value;if(n!=null&&n.getType(i)){t.reportError(new z(`Type "${i}" already exists in the schema. It cannot also be defined in this type definition.`,{nodes:s.name}));return}return e[i]?t.reportError(new z(`There can be only one type named "${i}".`,{nodes:[e[i],s.name]})):e[i]=s.name,!1}}function qy(t){return{OperationDefinition(e){var n;const r=(n=e.variableDefinitions)!==null&&n!==void 0?n:[],s=Io(r,i=>i.variable.name.value);for(const[i,o]of s)o.length>1&&t.reportError(new z(`There can be only one variable named "$${i}".`,{nodes:o.map(a=>a.variable.name)}))}}}function Yy(t){let e={};return{OperationDefinition:{enter(){e={}}},VariableDefinition(n){e[n.variable.name.value]=n},ListValue(n){const r=cl(t.getParentInputType());if(!je(r))return Wt(t,n),!1},ObjectValue(n){const r=ft(t.getInputType());if(!Ue(r))return Wt(t,n),!1;const s=dn(n.fields,i=>i.name.value);for(const i of Object.values(r.getFields()))if(!s[i.name]&&ml(i)){const a=ee(i.type);t.reportError(new z(`Field "${r.name}.${i.name}" of required type "${a}" was not provided.`,{nodes:n}))}r.isOneOf&&Hy(t,n,r,s,e)},ObjectField(n){const r=ft(t.getParentInputType());if(!t.getInputType()&&Ue(r)){const i=yn(n.name.value,Object.keys(r.getFields()));t.reportError(new z(`Field "${n.name.value}" is not defined by type "${r.name}".`+Vt(i),{nodes:n}))}},NullValue(n){const r=t.getInputType();we(r)&&t.reportError(new z(`Expected value of type "${ee(r)}", found ${ke(n)}.`,{nodes:n}))},EnumValue:n=>Wt(t,n),IntValue:n=>Wt(t,n),FloatValue:n=>Wt(t,n),StringValue:n=>Wt(t,n),BooleanValue:n=>Wt(t,n)}}function Wt(t,e){const n=t.getInputType();if(!n)return;const r=ft(n);if(!Cn(r)){const s=ee(n);t.reportError(new z(`Expected value of type "${s}", found ${ke(e)}.`,{nodes:e}));return}try{if(r.parseLiteral(e,void 0)===void 0){const i=ee(n);t.reportError(new z(`Expected value of type "${i}", found ${ke(e)}.`,{nodes:e}))}}catch(s){const i=ee(n);s instanceof z?t.reportError(s):t.reportError(new z(`Expected value of type "${i}", found ${ke(e)}; `+s.message,{nodes:e,originalError:s}))}}function Hy(t,e,n,r,s){var i;const o=Object.keys(r);if(o.length!==1){t.reportError(new z(`OneOf Input Object "${n.name}" must specify exactly one key.`,{nodes:[e]}));return}const c=(i=r[o[0]])===null||i===void 0?void 0:i.value,u=!c||c.kind===y.NULL,d=(c==null?void 0:c.kind)===y.VARIABLE;if(u){t.reportError(new z(`Field "${n.name}.${o[0]}" must be non-null.`,{nodes:[e]}));return}if(d){const l=c.name.value;s[l].type.kind!==y.NON_NULL_TYPE&&t.reportError(new z(`Variable "${l}" must be non-nullable to be used for OneOf Input Object "${n.name}".`,{nodes:[e]}))}}function Jy(t){return{VariableDefinition(e){const n=ot(t.getSchema(),e.type);if(n!==void 0&&!_t(n)){const r=e.variable.name.value,s=ke(e.type);t.reportError(new z(`Variable "$${r}" cannot be non-input type "${s}".`,{nodes:e.type}))}}}}function Wy(t){let e=Object.create(null);return{OperationDefinition:{enter(){e=Object.create(null)},leave(n){const r=t.getRecursiveVariableUsages(n);for(const{node:s,type:i,defaultValue:o,parentType:a}of r){const c=s.name.value,u=e[c];if(u&&i){const d=t.getSchema(),l=ot(d,u.type);if(l&&!Qy(d,l,u.defaultValue,i,o)){const f=ee(l),h=ee(i);t.reportError(new z(`Variable "$${c}" of type "${f}" used in position expecting type "${h}".`,{nodes:[u,s]}))}Ue(a)&&a.isOneOf&&al(l)&&t.reportError(new z(`Variable "$${c}" is of type "${l}" but must be non-nullable to be used for OneOf Input Object "${a}".`,{nodes:[u,s]}))}}}},VariableDefinition(n){e[n.variable.name.value]=n}}}function Qy(t,e,n,r,s){if(we(r)&&!we(e)){if(!(n!=null&&n.kind!==y.NULL)&&!(s!==void 0))return!1;const a=r.ofType;return Dn(t,e,a)}return Dn(t,e,r)}const Ky=Object.freeze([uy]),Xy=Object.freeze([Qm,Vy,oy,Py,Ml,ey,Jy,Ry,Km,jy,sy,fy,by,ly,qy,dy,py,xl,jl,ty,Bl,Yy,Oy,Wy,gy,Vl,...Ky]),Zy=Object.freeze([ay,Gy,zy,Fy,Uy,ky,$y,Ml,xl,jl,Ty,Ll,Bl,Vl,Ul]);class Gl{constructor(e,n){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=n}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let n;if(this._fragments)n=this._fragments;else{n=Object.create(null);for(const r of this.getDocument().definitions)r.kind===y.FRAGMENT_DEFINITION&&(n[r.name.value]=r);this._fragments=n}return n[e]}getFragmentSpreads(e){let n=this._fragmentSpreads.get(e);if(!n){n=[];const r=[e];let s;for(;s=r.pop();)for(const i of s.selections)i.kind===y.FRAGMENT_SPREAD?n.push(i):i.selectionSet&&r.push(i.selectionSet);this._fragmentSpreads.set(e,n)}return n}getRecursivelyReferencedFragments(e){let n=this._recursivelyReferencedFragments.get(e);if(!n){n=[];const r=Object.create(null),s=[e.selectionSet];let i;for(;i=s.pop();)for(const o of this.getFragmentSpreads(i)){const a=o.name.value;if(r[a]!==!0){r[a]=!0;const c=this.getFragment(a);c&&(n.push(c),s.push(c.selectionSet))}}this._recursivelyReferencedFragments.set(e,n)}return n}}class ev extends Gl{constructor(e,n,r){super(e,r),this._schema=n}get[Symbol.toStringTag](){return"SDLValidationContext"}getSchema(){return this._schema}}class tv extends Gl{constructor(e,n,r,s){super(n,s),this._schema=e,this._typeInfo=r,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let n=this._variableUsages.get(e);if(!n){const r=[],s=new Rl(this._schema);Os(e,Cl(s,{VariableDefinition:()=>!1,Variable(i){r.push({node:i,type:s.getInputType(),defaultValue:s.getDefaultValue(),parentType:s.getParentInputType()})}})),n=r,this._variableUsages.set(e,n)}return n}getRecursiveVariableUsages(e){let n=this._recursiveVariableUsages.get(e);if(!n){n=this.getVariableUsages(e);for(const r of this.getRecursivelyReferencedFragments(e))n=n.concat(this.getVariableUsages(r));this._recursiveVariableUsages.set(e,n)}return n}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function Sb(t,e,n=Xy,r,s=new Rl(t)){var i;const o=(i=void 0)!==null&&i!==void 0?i:100;e||ye(!1,"Must provide document."),Mm(t);const a=Object.freeze({}),c=[],u=new tv(t,e,s,l=>{if(c.length>=o)throw c.push(new z("Too many validation errors, error limit reached. Validation aborted.")),a;c.push(l)}),d=ol(n.map(l=>l(u)));try{Os(e,Cl(s,d))}catch(l){if(l!==a)throw l}return c}function nv(t,e,n=Zy){const r=[],s=new ev(t,e,o=>{r.push(o)}),i=n.map(o=>o(s));return Os(t,ol(i)),r}function rv(t){const e=nv(t);if(e.length!==0)throw new Error(e.map(n=>n.message).join(`
|
|
175
|
-
|
|
176
|
-
`))}function sv(t,e,n){var r,s,i,o;const a=[],c=Object.create(null),u=[];let d;const l=[];for(const S of e.definitions)if(S.kind===y.SCHEMA_DEFINITION)d=S;else if(S.kind===y.SCHEMA_EXTENSION)l.push(S);else if(Sr(S))a.push(S);else if(bo(S)){const W=S.name.value,U=c[W];c[W]=U?U.concat([S]):[S]}else S.kind===y.DIRECTIVE_DEFINITION&&u.push(S);if(Object.keys(c).length===0&&a.length===0&&u.length===0&&l.length===0&&d==null)return t;const f=Object.create(null);for(const S of t.types)f[S.name]=B(S);for(const S of a){var h;const W=S.name.value;f[W]=(h=qa[W])!==null&&h!==void 0?h:oe(S)}const m={query:t.query&&D(t.query),mutation:t.mutation&&D(t.mutation),subscription:t.subscription&&D(t.subscription),...d&&L([d]),...L(l)};return{description:(r=d)===null||r===void 0||(s=r.description)===null||s===void 0?void 0:s.value,...m,types:Object.values(f),directives:[...t.directives.map(P),...u.map(ie)],extensions:Object.create(null),astNode:(i=d)!==null&&i!==void 0?i:t.astNode,extensionASTNodes:t.extensionASTNodes.concat(l),assumeValid:(o=n==null?void 0:n.assumeValid)!==null&&o!==void 0?o:!1};function E(S){return je(S)?new ze(E(S.ofType)):we(S)?new ce(E(S.ofType)):D(S)}function D(S){return f[S.name]}function P(S){const W=S.toConfig();return new zt({...W,args:Ot(W.args,C)})}function B(S){if(Ol(S)||Om(S))return S;if(qt(S))return N(S);if(De(S))return X(S);if(Oe(S))return w(S);if(it(S))return $(S);if(Ke(S))return Q(S);if(Ue(S))return R(S);ht(!1,"Unexpected type: "+ee(S))}function R(S){var W;const U=S.toConfig(),K=(W=c[U.name])!==null&&W!==void 0?W:[];return new Ui({...U,fields:()=>({...Ot(U.fields,me=>({...me,type:E(me.type)})),...Y(K)}),extensionASTNodes:U.extensionASTNodes.concat(K)})}function Q(S){var W;const U=S.toConfig(),K=(W=c[S.name])!==null&&W!==void 0?W:[];return new ur({...U,values:{...U.values,...j(K)},extensionASTNodes:U.extensionASTNodes.concat(K)})}function N(S){var W;const U=S.toConfig(),K=(W=c[U.name])!==null&&W!==void 0?W:[];let me=U.specifiedByURL;for(const ve of K){var ue;me=(ue=Ya(ve))!==null&&ue!==void 0?ue:me}return new Ct({...U,specifiedByURL:me,extensionASTNodes:U.extensionASTNodes.concat(K)})}function X(S){var W;const U=S.toConfig(),K=(W=c[U.name])!==null&&W!==void 0?W:[];return new st({...U,interfaces:()=>[...S.getInterfaces().map(D),...q(K)],fields:()=>({...Ot(U.fields,A),...I(K)}),extensionASTNodes:U.extensionASTNodes.concat(K)})}function w(S){var W;const U=S.toConfig(),K=(W=c[U.name])!==null&&W!==void 0?W:[];return new Fi({...U,interfaces:()=>[...S.getInterfaces().map(D),...q(K)],fields:()=>({...Ot(U.fields,A),...I(K)}),extensionASTNodes:U.extensionASTNodes.concat(K)})}function $(S){var W;const U=S.toConfig(),K=(W=c[U.name])!==null&&W!==void 0?W:[];return new In({...U,types:()=>[...S.getTypes().map(D),...V(K)],extensionASTNodes:U.extensionASTNodes.concat(K)})}function A(S){return{...S,type:E(S.type),args:S.args&&Ot(S.args,C)}}function C(S){return{...S,type:E(S.type)}}function L(S){const W={};for(const K of S){var U;const me=(U=K.operationTypes)!==null&&U!==void 0?U:[];for(const ue of me)W[ue.operation]=O(ue.type)}return W}function O(S){var W;const U=S.name.value,K=(W=qa[U])!==null&&W!==void 0?W:f[U];if(K===void 0)throw new Error(`Unknown type: "${U}".`);return K}function re(S){return S.kind===y.LIST_TYPE?new ze(re(S.type)):S.kind===y.NON_NULL_TYPE?new ce(re(S.type)):O(S)}function ie(S){var W;return new zt({name:S.name.value,description:(W=S.description)===null||W===void 0?void 0:W.value,locations:S.locations.map(({value:U})=>U),isRepeatable:S.repeatable,args:k(S.arguments),astNode:S})}function I(S){const W=Object.create(null);for(const me of S){var U;const ue=(U=me.fields)!==null&&U!==void 0?U:[];for(const ve of ue){var K;W[ve.name.value]={type:re(ve.type),description:(K=ve.description)===null||K===void 0?void 0:K.value,args:k(ve.arguments),deprecationReason:$r(ve),astNode:ve}}}return W}function k(S){const W=S??[],U=Object.create(null);for(const me of W){var K;const ue=re(me.type);U[me.name.value]={type:ue,description:(K=me.description)===null||K===void 0?void 0:K.value,defaultValue:tn(me.defaultValue,ue),deprecationReason:$r(me),astNode:me}}return U}function Y(S){const W=Object.create(null);for(const me of S){var U;const ue=(U=me.fields)!==null&&U!==void 0?U:[];for(const ve of ue){var K;const Xe=re(ve.type);W[ve.name.value]={type:Xe,description:(K=ve.description)===null||K===void 0?void 0:K.value,defaultValue:tn(ve.defaultValue,Xe),deprecationReason:$r(ve),astNode:ve}}}return W}function j(S){const W=Object.create(null);for(const me of S){var U;const ue=(U=me.values)!==null&&U!==void 0?U:[];for(const ve of ue){var K;W[ve.name.value]={description:(K=ve.description)===null||K===void 0?void 0:K.value,deprecationReason:$r(ve),astNode:ve}}}return W}function q(S){return S.flatMap(W=>{var U,K;return(U=(K=W.interfaces)===null||K===void 0?void 0:K.map(O))!==null&&U!==void 0?U:[]})}function V(S){return S.flatMap(W=>{var U,K;return(U=(K=W.types)===null||K===void 0?void 0:K.map(O))!==null&&U!==void 0?U:[]})}function oe(S){var W;const U=S.name.value,K=(W=c[U])!==null&&W!==void 0?W:[];switch(S.kind){case y.OBJECT_TYPE_DEFINITION:{var me;const We=[S,...K];return new st({name:U,description:(me=S.description)===null||me===void 0?void 0:me.value,interfaces:()=>q(We),fields:()=>I(We),astNode:S,extensionASTNodes:K})}case y.INTERFACE_TYPE_DEFINITION:{var ue;const We=[S,...K];return new Fi({name:U,description:(ue=S.description)===null||ue===void 0?void 0:ue.value,interfaces:()=>q(We),fields:()=>I(We),astNode:S,extensionASTNodes:K})}case y.ENUM_TYPE_DEFINITION:{var ve;const We=[S,...K];return new ur({name:U,description:(ve=S.description)===null||ve===void 0?void 0:ve.value,values:j(We),astNode:S,extensionASTNodes:K})}case y.UNION_TYPE_DEFINITION:{var Xe;const We=[S,...K];return new In({name:U,description:(Xe=S.description)===null||Xe===void 0?void 0:Xe.value,types:()=>V(We),astNode:S,extensionASTNodes:K})}case y.SCALAR_TYPE_DEFINITION:{var bt;return new Ct({name:U,description:(bt=S.description)===null||bt===void 0?void 0:bt.value,specifiedByURL:Ya(S),astNode:S,extensionASTNodes:K})}case y.INPUT_OBJECT_TYPE_DEFINITION:{var St;const We=[S,...K];return new Ui({name:U,description:(St=S.description)===null||St===void 0?void 0:St.value,fields:()=>Y(We),astNode:S,extensionASTNodes:K,isOneOf:iv(S)})}}}}const qa=dn([...yo,..._o],t=>t.name);function $r(t){const e=lr(vo,t);return e==null?void 0:e.reason}function Ya(t){const e=lr(wl,t);return e==null?void 0:e.url}function iv(t){return!!lr(bl,t)}function ov(t,e){t!=null&&t.kind===y.DOCUMENT||ye(!1,"Must provide valid Document AST."),(e==null?void 0:e.assumeValid)!==!0&&(e==null?void 0:e.assumeValidSDL)!==!0&&rv(t);const r=sv({description:void 0,types:[],directives:[],extensions:Object.create(null),extensionASTNodes:[],assumeValid:!1},t,e);if(r.astNode==null)for(const i of r.types)switch(i.name){case"Query":r.query=i;break;case"Mutation":r.mutation=i;break;case"Subscription":r.subscription=i;break}const s=[...r.directives,...vn.filter(i=>r.directives.every(o=>o.name!==i.name))];return new Al({...r,directives:s})}function av(t,e){const n=sl(t,{noLocation:void 0,allowLegacyFragmentVariables:void 0});return ov(n,{assumeValidSDL:void 0,assumeValid:void 0})}const Do=JSON,cv=t=>t.toUpperCase(),uv=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},lv=(t,e,n)=>t.document?t:{document:t,variables:e,requestHeaders:n,signal:void 0},dv=(t,e,n)=>t.query?t:{query:t,variables:e,requestHeaders:n,signal:void 0},fv=(t,e)=>t.documents?t:{documents:t,requestHeaders:e,signal:void 0},pv=(t,e,...n)=>{const[r,s]=n;return t.document?t:{url:t,document:e,variables:r,requestHeaders:s,signal:void 0}},Ha=t=>{var r,s;let e;const n=t.definitions.filter(i=>i.kind==="OperationDefinition");return n.length===1&&(e=(s=(r=n[0])==null?void 0:r.name)==null?void 0:s.value),e},li=t=>{if(typeof t=="string"){let n;try{const r=sl(t);n=Ha(r)}catch{}return{query:t,operationName:n}}const e=Ha(t);return{query:ke(t),operationName:e}};class Nn extends Error{constructor(e,n){const r=`${Nn.extractMessage(e)}: ${JSON.stringify({response:e,request:n})}`;super(r),Object.setPrototypeOf(this,Nn.prototype),this.response=e,this.request=n,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Nn)}static extractMessage(e){var n,r;return((r=(n=e.errors)==null?void 0:n[0])==null?void 0:r.message)??`GraphQL Error (Code: ${e.status})`}}var Fr={exports:{}},Ja;function hv(){return Ja||(Ja=1,function(t,e){var n=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ft<"u"&&Ft,r=function(){function i(){this.fetch=!1,this.DOMException=n.DOMException}return i.prototype=n,new i}();(function(i){(function(o){var a=typeof i<"u"&&i||typeof self<"u"&&self||typeof Ft<"u"&&Ft||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function u(I){return I&&DataView.prototype.isPrototypeOf(I)}if(c.arrayBuffer)var d=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(I){return I&&d.indexOf(Object.prototype.toString.call(I))>-1};function f(I){if(typeof I!="string"&&(I=String(I)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(I)||I==="")throw new TypeError('Invalid character in header field name: "'+I+'"');return I.toLowerCase()}function h(I){return typeof I!="string"&&(I=String(I)),I}function m(I){var k={next:function(){var Y=I.shift();return{done:Y===void 0,value:Y}}};return c.iterable&&(k[Symbol.iterator]=function(){return k}),k}function E(I){this.map={},I instanceof E?I.forEach(function(k,Y){this.append(Y,k)},this):Array.isArray(I)?I.forEach(function(k){if(k.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+k.length);this.append(k[0],k[1])},this):I&&Object.getOwnPropertyNames(I).forEach(function(k){this.append(k,I[k])},this)}E.prototype.append=function(I,k){I=f(I),k=h(k);var Y=this.map[I];this.map[I]=Y?Y+", "+k:k},E.prototype.delete=function(I){delete this.map[f(I)]},E.prototype.get=function(I){return I=f(I),this.has(I)?this.map[I]:null},E.prototype.has=function(I){return this.map.hasOwnProperty(f(I))},E.prototype.set=function(I,k){this.map[f(I)]=h(k)},E.prototype.forEach=function(I,k){for(var Y in this.map)this.map.hasOwnProperty(Y)&&I.call(k,this.map[Y],Y,this)},E.prototype.keys=function(){var I=[];return this.forEach(function(k,Y){I.push(Y)}),m(I)},E.prototype.values=function(){var I=[];return this.forEach(function(k){I.push(k)}),m(I)},E.prototype.entries=function(){var I=[];return this.forEach(function(k,Y){I.push([Y,k])}),m(I)},c.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function D(I){if(!I._noBody){if(I.bodyUsed)return Promise.reject(new TypeError("Already read"));I.bodyUsed=!0}}function P(I){return new Promise(function(k,Y){I.onload=function(){k(I.result)},I.onerror=function(){Y(I.error)}})}function B(I){var k=new FileReader,Y=P(k);return k.readAsArrayBuffer(I),Y}function R(I){var k=new FileReader,Y=P(k),j=/charset=([A-Za-z0-9_-]+)/.exec(I.type),q=j?j[1]:"utf-8";return k.readAsText(I,q),Y}function Q(I){for(var k=new Uint8Array(I),Y=new Array(k.length),j=0;j<k.length;j++)Y[j]=String.fromCharCode(k[j]);return Y.join("")}function N(I){if(I.slice)return I.slice(0);var k=new Uint8Array(I.byteLength);return k.set(new Uint8Array(I)),k.buffer}function X(){return this.bodyUsed=!1,this._initBody=function(I){this.bodyUsed=this.bodyUsed,this._bodyInit=I,I?typeof I=="string"?this._bodyText=I:c.blob&&Blob.prototype.isPrototypeOf(I)?this._bodyBlob=I:c.formData&&FormData.prototype.isPrototypeOf(I)?this._bodyFormData=I:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(I)?this._bodyText=I.toString():c.arrayBuffer&&c.blob&&u(I)?(this._bodyArrayBuffer=N(I.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(I)||l(I))?this._bodyArrayBuffer=N(I):this._bodyText=I=Object.prototype.toString.call(I):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof I=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(I)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var I=D(this);if(I)return I;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var I=D(this);return I||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(B);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var I=D(this);if(I)return I;if(this._bodyBlob)return R(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(Q(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(C)}),this.json=function(){return this.text().then(JSON.parse)},this}var w=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function $(I){var k=I.toUpperCase();return w.indexOf(k)>-1?k:I}function A(I,k){if(!(this instanceof A))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');k=k||{};var Y=k.body;if(I instanceof A){if(I.bodyUsed)throw new TypeError("Already read");this.url=I.url,this.credentials=I.credentials,k.headers||(this.headers=new E(I.headers)),this.method=I.method,this.mode=I.mode,this.signal=I.signal,!Y&&I._bodyInit!=null&&(Y=I._bodyInit,I.bodyUsed=!0)}else this.url=String(I);if(this.credentials=k.credentials||this.credentials||"same-origin",(k.headers||!this.headers)&&(this.headers=new E(k.headers)),this.method=$(k.method||this.method||"GET"),this.mode=k.mode||this.mode||null,this.signal=k.signal||this.signal||function(){if("AbortController"in a){var V=new AbortController;return V.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&Y)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(Y),(this.method==="GET"||this.method==="HEAD")&&(k.cache==="no-store"||k.cache==="no-cache")){var j=/([?&])_=[^&]*/;if(j.test(this.url))this.url=this.url.replace(j,"$1_="+new Date().getTime());else{var q=/\?/;this.url+=(q.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}A.prototype.clone=function(){return new A(this,{body:this._bodyInit})};function C(I){var k=new FormData;return I.trim().split("&").forEach(function(Y){if(Y){var j=Y.split("="),q=j.shift().replace(/\+/g," "),V=j.join("=").replace(/\+/g," ");k.append(decodeURIComponent(q),decodeURIComponent(V))}}),k}function L(I){var k=new E,Y=I.replace(/\r?\n[\t ]+/g," ");return Y.split("\r").map(function(j){return j.indexOf(`
|
|
177
|
-
`)===0?j.substr(1,j.length):j}).forEach(function(j){var q=j.split(":"),V=q.shift().trim();if(V){var oe=q.join(":").trim();try{k.append(V,oe)}catch(S){console.warn("Response "+S.message)}}}),k}X.call(A.prototype);function O(I,k){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(k||(k={}),this.type="default",this.status=k.status===void 0?200:k.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=k.statusText===void 0?"":""+k.statusText,this.headers=new E(k.headers),this.url=k.url||"",this._initBody(I)}X.call(O.prototype),O.prototype.clone=function(){return new O(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},O.error=function(){var I=new O(null,{status:200,statusText:""});return I.ok=!1,I.status=0,I.type="error",I};var re=[301,302,303,307,308];O.redirect=function(I,k){if(re.indexOf(k)===-1)throw new RangeError("Invalid status code");return new O(null,{status:k,headers:{location:I}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(k,Y){this.message=k,this.name=Y;var j=Error(k);this.stack=j.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function ie(I,k){return new Promise(function(Y,j){var q=new A(I,k);if(q.signal&&q.signal.aborted)return j(new o.DOMException("Aborted","AbortError"));var V=new XMLHttpRequest;function oe(){V.abort()}V.onload=function(){var U={statusText:V.statusText,headers:L(V.getAllResponseHeaders()||"")};q.url.indexOf("file://")===0&&(V.status<200||V.status>599)?U.status=200:U.status=V.status,U.url="responseURL"in V?V.responseURL:U.headers.get("X-Request-URL");var K="response"in V?V.response:V.responseText;setTimeout(function(){Y(new O(K,U))},0)},V.onerror=function(){setTimeout(function(){j(new TypeError("Network request failed"))},0)},V.ontimeout=function(){setTimeout(function(){j(new TypeError("Network request timed out"))},0)},V.onabort=function(){setTimeout(function(){j(new o.DOMException("Aborted","AbortError"))},0)};function S(U){try{return U===""&&a.location.href?a.location.href:U}catch{return U}}if(V.open(q.method,S(q.url),!0),q.credentials==="include"?V.withCredentials=!0:q.credentials==="omit"&&(V.withCredentials=!1),"responseType"in V&&(c.blob?V.responseType="blob":c.arrayBuffer&&(V.responseType="arraybuffer")),k&&typeof k.headers=="object"&&!(k.headers instanceof E||a.Headers&&k.headers instanceof a.Headers)){var W=[];Object.getOwnPropertyNames(k.headers).forEach(function(U){W.push(f(U)),V.setRequestHeader(U,h(k.headers[U]))}),q.headers.forEach(function(U,K){W.indexOf(K)===-1&&V.setRequestHeader(K,U)})}else q.headers.forEach(function(U,K){V.setRequestHeader(K,U)});q.signal&&(q.signal.addEventListener("abort",oe),V.onreadystatechange=function(){V.readyState===4&&q.signal.removeEventListener("abort",oe)}),V.send(typeof q._bodyInit>"u"?null:q._bodyInit)})}return ie.polyfill=!0,a.fetch||(a.fetch=ie,a.Headers=E,a.Request=A,a.Response=O),o.Headers=E,o.Request=A,o.Response=O,o.fetch=ie,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var s=n.fetch?n:r;e=s.fetch,e.default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e}(Fr,Fr.exports)),Fr.exports}var fs=hv();const Yr=ws(fs),gv=yp({__proto__:null,default:Yr},[fs]),_n=t=>{let e={};return t&&(typeof Headers<"u"&&t instanceof Headers||gv&&fs.Headers&&t instanceof fs.Headers?e=uv(t):Array.isArray(t)?t.forEach(([n,r])=>{n&&r!==void 0&&(e[n]=r)}):e=t),e},Wa=t=>t.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),mv=t=>{if(!Array.isArray(t.query)){const r=t,s=[`query=${encodeURIComponent(Wa(r.query))}`];return t.variables&&s.push(`variables=${encodeURIComponent(r.jsonSerializer.stringify(r.variables))}`),r.operationName&&s.push(`operationName=${encodeURIComponent(r.operationName)}`),s.join("&")}if(typeof t.variables<"u"&&!Array.isArray(t.variables))throw new Error("Cannot create query with given variable type, array expected");const e=t,n=t.query.reduce((r,s,i)=>(r.push({query:Wa(s),variables:e.variables?e.jsonSerializer.stringify(e.variables[i]):void 0}),r),[]);return`query=${encodeURIComponent(e.jsonSerializer.stringify(n))}`},yv=t=>async e=>{const{url:n,query:r,variables:s,operationName:i,fetch:o,fetchOptions:a,middleware:c}=e,u={...e.headers};let d="",l;t==="POST"?(l=vv(r,s,i,a.jsonSerializer),typeof l=="string"&&(u["Content-Type"]="application/json")):d=mv({query:r,variables:s,operationName:i,jsonSerializer:a.jsonSerializer??Do});const f={method:t,headers:u,body:l,...a};let h=n,m=f;if(c){const E=await Promise.resolve(c({...f,url:n,operationName:i,variables:s})),{url:D,...P}=E;h=D,m=P}return d&&(h=`${h}?${d}`),await o(h,m)};class zl{constructor(e,n={}){this.url=e,this.requestConfig=n,this.rawRequest=async(...r)=>{const[s,i,o]=r,a=dv(s,i,o),{headers:c,fetch:u=Yr,method:d="POST",requestMiddleware:l,responseMiddleware:f,...h}=this.requestConfig,{url:m}=this;a.signal!==void 0&&(h.signal=a.signal);const{operationName:E}=li(a.query);return di({url:m,query:a.query,variables:a.variables,headers:{..._n(fi(c)),..._n(a.requestHeaders)},operationName:E,fetch:u,method:d,fetchOptions:h,middleware:l}).then(D=>(f&&f(D),D)).catch(D=>{throw f&&f(D),D})}}async request(e,...n){const[r,s]=n,i=lv(e,r,s),{headers:o,fetch:a=Yr,method:c="POST",requestMiddleware:u,responseMiddleware:d,...l}=this.requestConfig,{url:f}=this;i.signal!==void 0&&(l.signal=i.signal);const{query:h,operationName:m}=li(i.document);return di({url:f,query:h,variables:i.variables,headers:{..._n(fi(o)),..._n(i.requestHeaders)},operationName:m,fetch:a,method:c,fetchOptions:l,middleware:u}).then(E=>(d&&d(E),E.data)).catch(E=>{throw d&&d(E),E})}batchRequests(e,n){const r=fv(e,n),{headers:s,...i}=this.requestConfig;r.signal!==void 0&&(i.signal=r.signal);const o=r.documents.map(({document:c})=>li(c).query),a=r.documents.map(({variables:c})=>c);return di({url:this.url,query:o,variables:a,headers:{..._n(fi(s)),..._n(r.requestHeaders)},operationName:void 0,fetch:this.requestConfig.fetch??Yr,method:this.requestConfig.method||"POST",fetchOptions:i,middleware:this.requestConfig.requestMiddleware}).then(c=>(this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(c),c.data)).catch(c=>{throw this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(c),c})}setHeaders(e){return this.requestConfig.headers=e,this}setHeader(e,n){const{headers:r}=this.requestConfig;return r?r[e]=n:this.requestConfig.headers={[e]:n},this}setEndpoint(e){return this.url=e,this}}const di=async t=>{const{query:e,variables:n,fetchOptions:r}=t,s=yv(cv(t.method??"post")),i=Array.isArray(t.query),o=await s(t),a=await Ev(o,r.jsonSerializer??Do),c=Array.isArray(a)?!a.some(({data:d})=>!d):!!a.data,u=Array.isArray(a)||!a.errors||Array.isArray(a.errors)&&!a.errors.length||r.errorPolicy==="all"||r.errorPolicy==="ignore";if(o.ok&&u&&c){const{errors:d,...l}=(Array.isArray(a),a),f=r.errorPolicy==="ignore"?l:a;return{...i?{data:f}:f,headers:o.headers,status:o.status}}else{const d=typeof a=="string"?{error:a}:a;throw new Nn({...d,status:o.status,headers:o.headers},{query:e,variables:n})}};async function Tb(t,e,...n){const r=pv(t,e,...n);return new zl(r.url).request({...r})}const vv=(t,e,n,r)=>{const s=r??Do;if(!Array.isArray(t))return s.stringify({query:t,variables:e,operationName:n});if(typeof e<"u"&&!Array.isArray(e))throw new Error("Cannot create request body with given variable type, array expected");const i=t.reduce((o,a,c)=>(o.push({query:a,variables:e?e[c]:void 0}),o),[]);return s.stringify(i)},Ev=async(t,e)=>{let n;return t.headers.forEach((r,s)=>{s.toLowerCase()==="content-type"&&(n=r)}),n&&(n.toLowerCase().startsWith("application/json")||n.toLowerCase().startsWith("application/graphql+json")||n.toLowerCase().startsWith("application/graphql-response+json"))?e.parse(await t.text()):t.text()},fi=t=>typeof t=="function"?t():t,Dt=(t,...e)=>t.reduce((n,r,s)=>`${n}${r}${s in e?String(e[s]):""}`,"");async function nt(t,e,n,r){const s=new zl(t,{fetch,headers:r||{}}),{errors:i,...o}=await s.request(e,n),a={...o};return i!=null&&i.length&&(a.errors=i.map(({message:c,...u})=>new z(c,u))),a}function Hr(t,e){return t instanceof st?Object.entries(t.getFields()).map(([n,r])=>{const s=r.type instanceof ce?r.type.ofType:r.type;if(s instanceof st||s instanceof In)return`${n} { ${Hr(s,e)} }`;if(s instanceof ze){const i=s.ofType instanceof ce?s.ofType.ofType:s.ofType;if(i instanceof Ct)return n;if(i instanceof st||i instanceof In)return`${n} { ${Hr(i,e)} }`;throw new Error(`List item type ${i.toString()} is not handled`)}return n}).join(" "):t instanceof In?t.getTypes().map(n=>`... on ${e?`${e}_`:""}${n.name} { ${Hr(n,e)} }`).join(" "):""}function ql(t,e,n){const r=Fc(t.name),s=t.specifications.at(-1);if(!s)throw new Error("No document model specification found");const i=`${s.state.global.schema} type Query { ${r}: ${r}State }`,a=av(i).getQueryType();if(!a)throw new Error("No query type found");const u=a.getFields()[r];if(!u)throw new Error("No state query found");return Hr(u.type,e)}async function Wn(t,e){var s;const n=await((s=e.generateJwtHandler)==null?void 0:s.call(e,t)),r=n?{Authorization:`Bearer ${n}`}:{};return Yl(t,r)}async function Yl(t,e){var r,s;let n;try{const i=await nt(t,Dt`
|
|
178
|
-
query getDrive {
|
|
179
|
-
drive {
|
|
180
|
-
id
|
|
181
|
-
name
|
|
182
|
-
icon
|
|
183
|
-
slug
|
|
184
|
-
meta {
|
|
185
|
-
preferredEditor
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
`,void 0,e);if((r=i.errors)!=null&&r.length||!i.drive)throw((s=i.errors)==null?void 0:s.at(0))??new Error("Drive not found");n=i.drive}catch(i){throw pe.error(i),new Error("Couldn't find drive info")}return n}async function Qa(t,e,n){var u;const{documentModel:r,utils:s}=n,i=Fc(r.name),o=ql(r,i),a=await nt(t,Dt`
|
|
190
|
-
query ($id: String!) {
|
|
191
|
-
document(id: $id) {
|
|
192
|
-
id
|
|
193
|
-
name
|
|
194
|
-
created
|
|
195
|
-
documentType
|
|
196
|
-
lastModified
|
|
197
|
-
revision
|
|
198
|
-
operations {
|
|
199
|
-
id
|
|
200
|
-
error
|
|
201
|
-
hash
|
|
202
|
-
index
|
|
203
|
-
skip
|
|
204
|
-
timestamp
|
|
205
|
-
type
|
|
206
|
-
inputText
|
|
207
|
-
context {
|
|
208
|
-
signer {
|
|
209
|
-
user {
|
|
210
|
-
address
|
|
211
|
-
networkId
|
|
212
|
-
chainId
|
|
213
|
-
}
|
|
214
|
-
app {
|
|
215
|
-
name
|
|
216
|
-
key
|
|
217
|
-
}
|
|
218
|
-
signatures
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
... on ${i} {
|
|
223
|
-
state {
|
|
224
|
-
${o}
|
|
225
|
-
}
|
|
226
|
-
initialState {
|
|
227
|
-
${o}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
`,{id:e}),c=a.document?{clipboard:a.document.clipboard,header:a.document.header,initialState:{...s.createExtendedState({state:s.createState({global:a.document.initialState})})},operations:{global:a.document.operations.map(({inputText:d,...l})=>({...l,error:l.error??void 0,scope:"global",input:JSON.parse(d)})),local:[]},state:a.document.state}:null;return(u=a==null?void 0:a.document)!=null&&u.attachments&&(c.attachments=a.document.attachments),{...a,document:c}}var fr,lt,hn,zi,Hl;class _v{constructor(e){et(this,hn);et(this,fr);et(this,lt,new Map);Yt(this,fr,e)}async fetchDrive(e){const n=he(this,lt).get(e);if(!n)return new Jt(e);const r=await this.fetchDocument(e,e,ao);if(r instanceof Error)return r;const s={...r,readContext:n.context};return n.drive=s,s}async fetchDocument(e,n,r){const s=he(this,lt).get(e);if(!s)return new Jt(e);let i;try{i=he(this,fr).call(this,r)}catch(u){return new Sg(r,u)}const{url:o}=s.context,{errors:a,document:c}=await Qa(o,n,i);if(a){const u=ct(this,hn,zi).call(this,a,e,n);if(u instanceof Is)return u;if(u)throw u}return c||new Ia(e,n)}async addReadDrive(e,n){let r;n!=null&&n.expectedDriveInfo?r=n.expectedDriveInfo.id:r=(await Yl(e)).id;const s=await ct(this,hn,Hl).call(this,r,e);if(s instanceof Error)throw s;if(!s)throw new Jt(r);he(this,lt).set(r,{drive:s,context:{...n,url:e}})}async getReadDrives(){return Promise.resolve([...he(this,lt).keys()])}async getReadDrive(e){const n=he(this,lt).get(e);return Promise.resolve(n?{...n.drive,readContext:n.context}:new Jt(e))}async getReadDriveBySlug(e){const n=[...he(this,lt).values()].find(({drive:r})=>r.header.slug===e);return Promise.resolve(n?{...n.drive,readContext:n.context}:new Fg(e))}getReadDriveContext(e){var n;return Promise.resolve(((n=he(this,lt).get(e))==null?void 0:n.context)??new Jt(e))}deleteReadDrive(e){const n=he(this,lt).delete(e);return Promise.resolve(n?void 0:new Jt(e))}}fr=new WeakMap,lt=new WeakMap,hn=new WeakSet,zi=function(e,n,r){for(const i of e){if(i.message===`Drive with id ${n} not found`)return new Jt(n);if(r&&i.message===`Document with id ${r} not found`)return new Ia(n,r)}const s=e.at(0);if(s)return s},Hl=async function(e,n){const{errors:r,document:s}=await Qa(n,e,Pg);return(r?ct(this,hn,zi).call(this,r,e):void 0)||s};function wv(t){var e,n,r,Jr,Wr,o;return o=class extends t{constructor(...u){super(...u);et(this,r);et(this,e);et(this,n,new Set);Yt(this,e,new _v(this.getDocumentModelModule.bind(this))),ct(this,r,Jr).call(this).then(d=>{d.length&&ct(this,r,Wr).call(this,d,"add")}).catch(pe.error)}getReadDrives(){return he(this,e).getReadDrives()}getReadDrive(u){return he(this,e).getReadDrive(u)}getReadDriveBySlug(u){return he(this,e).getReadDriveBySlug(u)}getReadDriveContext(u){return he(this,e).getReadDriveContext(u)}async addReadDrive(u,d){await he(this,e).addReadDrive(u,d),ct(this,r,Wr).call(this,await ct(this,r,Jr).call(this),"add")}fetchDrive(u){return he(this,e).fetchDrive(u)}fetchDocument(u,d,l){return he(this,e).fetchDocument(u,d,l)}async deleteReadDrive(u){const d=await he(this,e).deleteReadDrive(u);if(d)return d;ct(this,r,Wr).call(this,await ct(this,r,Jr).call(this),"delete")}async migrateReadDrive(u,d){const l=await this.getReadDriveContext(u);if(l instanceof Error)return l;const{url:f,...h}=l;try{return await this.addRemoteDrive(f,d)}catch(m){throw pe.error(m),await this.addReadDrive(l.url,h),m}}onReadDrivesUpdate(u){return he(this,n).add(u),Promise.resolve(()=>he(this,n).delete(u))}},e=new WeakMap,n=new WeakMap,r=new WeakSet,Jr=async function(){const u=await this.getReadDrives();return(await Promise.all(u.map(l=>this.getReadDrive(l)))).filter(l=>!(l instanceof Error))},Wr=function(u,d){he(this,n).forEach(l=>l(u,d))},o}function bv(t){return typeof t.getReadDrives=="function"}class Sv{constructor(e,n,r){F(this,"server");F(this,"delegate");F(this,"defaultRemoteDrives",new Map);F(this,"removeOldRemoteDrivesConfig");var s,i;if(this.server=e,this.delegate=n,(s=r==null?void 0:r.defaultDrives)!=null&&s.remoteDrives)for(const o of r.defaultDrives.remoteDrives)this.defaultRemoteDrives.set(o.url,{...o,status:"PENDING"});this.removeOldRemoteDrivesConfig=((i=r==null?void 0:r.defaultDrives)==null?void 0:i.removeOldRemoteDrives)||{strategy:"preserve-all"}}getDefaultRemoteDrives(){return new Map(JSON.parse(JSON.stringify(Array.from(this.defaultRemoteDrives))))}async deleteDriveById(e){try{await this.server.deleteDrive(e)}catch(n){pe.error(n)}}async preserveDrivesById(e,n,r="detach"){const s=n.map(a=>this.server.getDrive(a)),o=(await Promise.all(s)).filter(a=>a.state.local.listeners.length>0||a.state.local.triggers.length>0).filter(a=>!e.includes(a.header.id)).map(a=>a.header.id);r==="detach"?await this.detachDrivesById(o):await this.removeDrivesById(o)}async removeDrivesById(e){for(const n of e)await this.deleteDriveById(n)}async detachDrivesById(e){const n=e.map(r=>this.delegate.detachDrive(r));await Promise.all(n)}async removeOldremoteDrives(){const e=await this.server.getDrives();switch(this.removeOldRemoteDrivesConfig.strategy){case"preserve-by-id-and-detach":case"preserve-by-id":{const n=this.removeOldRemoteDrivesConfig.strategy==="preserve-by-id-and-detach"?"detach":"remove";await this.preserveDrivesById(this.removeOldRemoteDrivesConfig.ids,e,n);break}case"preserve-by-url-and-detach":case"preserve-by-url":{const n=this.removeOldRemoteDrivesConfig.strategy==="preserve-by-url-and-detach"?"detach":"remove",r=this.removeOldRemoteDrivesConfig.urls.map(i=>Wn(i,this.server)),s=(await Promise.all(r)).map(i=>i.id);await this.preserveDrivesById(s,e,n);break}case"remove-by-id":{const n=this.removeOldRemoteDrivesConfig.ids.filter(r=>e.includes(r));await this.removeDrivesById(n);break}case"remove-by-url":{const n=this.removeOldRemoteDrivesConfig.urls.map(i=>Wn(i,this.server)),s=(await Promise.all(n)).map(i=>i.id).filter(i=>e.includes(i));await this.removeDrivesById(s);break}case"remove-all":{const n=e.map(i=>this.server.getDrive(i)),s=(await Promise.all(n)).filter(i=>i.state.local.listeners.length>0||i.state.local.triggers.length>0).map(i=>i.header.id);await this.removeDrivesById(s);break}case"detach-by-id":{const r=this.removeOldRemoteDrivesConfig.ids.filter(s=>e.includes(s)).map(s=>this.delegate.detachDrive(s));await Promise.all(r);break}case"detach-by-url":{const n=this.removeOldRemoteDrivesConfig.urls.map(o=>Wn(o,this.server)),i=(await Promise.all(n)).map(o=>o.id).filter(o=>e.includes(o)).map(o=>this.delegate.detachDrive(o));await Promise.all(i);break}}}async setAllDefaultDrivesAccessLevel(e){const n=this.defaultRemoteDrives.values();for(const r of n)await this.setDefaultDriveAccessLevel(r.url,e)}async setDefaultDriveAccessLevel(e,n){const r=this.defaultRemoteDrives.get(e);if(r&&r.options.accessLevel!==n){const s={...r,options:{...r.options,accessLevel:n}};this.defaultRemoteDrives.set(e,s),await this.initializeDefaultRemoteDrives([s])}}async initializeDefaultRemoteDrives(e=Array.from(this.defaultRemoteDrives.values())){const n=await this.server.getDrives(),r=bv(this.server)?this.server:void 0,s=await(r==null?void 0:r.getReadDrives());for(const i of e){let o={...i};try{const a=i.metadata??await Wn(i.url,this.server);o={...i,metadata:a},this.defaultRemoteDrives.set(i.url,o);const c=n.includes(a.id),u=s==null?void 0:s.includes(a.id),d=i.options.accessLevel!==void 0,l=r&&i.options.accessLevel==="READ",f=l?u:c;if(d&&(l?c:u))try{await(l?this.server.deleteDrive(a.id):r==null?void 0:r.deleteReadDrive(a.id))}catch(m){pe.error(m)}if(f){o.status="ALREADY_ADDED",this.defaultRemoteDrives.set(i.url,o),this.delegate.emit("ALREADY_ADDED",this.defaultRemoteDrives,o,a.id,a.name);continue}o.status="ADDING",this.defaultRemoteDrives.set(i.url,o),this.delegate.emit("ADDING",this.defaultRemoteDrives,o),i.options.accessLevel==="READ"&&r||l?await r.addReadDrive(i.url,{...i.options,expectedDriveInfo:a}):await this.server.addRemoteDrive(i.url,{...i.options,expectedDriveInfo:a}),o.status="SUCCESS",this.defaultRemoteDrives.set(i.url,o),this.delegate.emit("SUCCESS",this.defaultRemoteDrives,o,a.id,a.name)}catch(a){o.status="ERROR",this.defaultRemoteDrives.set(i.url,o),this.delegate.emit("ERROR",this.defaultRemoteDrives,o,void 0,void 0,a)}}}}var sn;(function(t){t.useMessageChannel=typeof MessageChannel>"u"?new Error("MessageChannel is not supported"):r=>{const s=new AbortController,i=s.signal,o=new MessageChannel;return o.port1.postMessage(null),o.port2.addEventListener("message",()=>{r(),o.port1.close(),o.port2.close()},{once:!0,signal:i}),o.port2.start(),()=>s.abort()},t.usePostMessage=(()=>{const r=typeof window=="object"&&window||typeof global=="object"&&global||typeof self=="object"&&self;if(!r)return new Error("No global object found");const s=r;if(!s.postMessage||!s.addEventListener||s.importScripts)return new Error("postMessage is not supported");let i=0;const o=new Map;function a(){return i===9007199254740991?0:++i}const c="com.usePostMessage"+Math.random();return s.addEventListener("message",u=>{const d=u;if(typeof d.data!="string"||d.source!==s||!d.data.startsWith(c))return;const l=d.data.split(":").at(1);if(l===void 0)return;const f=+l,h=o.get(f);h&&(h(),o.delete(f))},!1),u=>{const d=a();return o.set(d,u),s.postMessage(c+":"+d,{targetOrigin:"*"}),()=>{o.delete(d)}}})(),t.useSetImmediate=typeof window<"u"?new Error("setImmediate is not supported on the browser"):typeof setImmediate>"u"?new Error("setImmediate is not supported"):r=>{const s=setImmediate(r);return()=>clearImmediate(s)},t.useSetTimeout=r=>{const s=setTimeout(r,0);return()=>clearTimeout(s)};function e(r){return t.useSetImmediate instanceof Error?t.useMessageChannel instanceof Error?t.usePostMessage instanceof Error?t.useSetTimeout(r):t.usePostMessage(r):t.useMessageChannel(r):t.useSetImmediate(r)}t.runAsap=e;function n(r,s=e){if(s instanceof Error)throw new Error("queueMethod is not supported",{cause:s});return new Promise((i,o)=>{s(()=>{r().then(i).catch(o)})})}t.runAsapAsync=n})(sn||(sn={}));const Tv=sn.runAsapAsync;function Tt(t){return t.header.documentType===ao}function ps(t,e){const n=Object.keys(t).reduce((s,i)=>{var a;const o=i;return s[o]=((a=t[o].at(-1))==null?void 0:a.index)??0,s},{}),r=e.find(s=>s.index<(n[s.scope]??0));if(r)throw new Ge("ERROR",r,`Tried to add operation with index ${r.index} and document is at index ${n[r.scope]}`);return e.sort((s,i)=>s.index-i.index).reduce((s,i)=>{const o=s[i.scope]||[];return{...s,[i.scope]:[...o,i]}},t)}function Iv(t,e){return new Date(t)<new Date(e)}function Mn(t){const e=t==null?void 0:t.at(-1);return e?e.index+1:0}const Dv=1500,Ka=100,Nv=50;let pi;const fe=()=>(pi||(pi=wt(["PullResponderTransmitter","static"])),pi);class He{constructor(e,n){F(this,"logger",wt(["PullResponderTransmitter",Math.floor(Math.random()*999).toString()]));F(this,"listener");F(this,"manager");this.listener=e,this.manager=n,this.logger.verbose(`constructor(listener: ${e.listenerId})`)}static async getAuthHeaders(e,n){if(!(n!=null&&n.generateJwtHandler))return fe().verbose(`No JWT handler available for ${e}`),{};try{const r=await n.generateJwtHandler(e);return r?{Authorization:`Bearer ${r}`}:(fe().verbose(`No JWT generated for ${e}`),{})}catch(r){return fe().error(`Error generating JWT for ${e}:`,r),{}}}async requestWithAuth(e,n,r){var a;const s=await He.getAuthHeaders(e,this.manager),i=await nt(e,n,r,s),o=(a=i.errors)==null?void 0:a.at(0);if(o!=null&&o.message.includes("Unauthorized")){const c=await He.getAuthHeaders(e,this.manager);return nt(e,n,r,c)}return i}getStrands(e){return this.logger.verbose(`[SYNC DEBUG] PullResponderTransmitter.getStrands called for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}, options: ${JSON.stringify(e||{})}`),this.manager.getStrands(this.listener.driveId,this.listener.listenerId,e).then(n=>{if(this.logger.verbose(`[SYNC DEBUG] PullResponderTransmitter.getStrands returning ${n.length} strands for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}`),n.length===0)this.logger.verbose(`[SYNC DEBUG] No strands returned for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}`);else for(const r of n)this.logger.verbose(`[SYNC DEBUG] Strand for drive: ${r.driveId}, document: ${r.documentId}, scope: ${r.scope}, operations: ${r.operations.length}`);return n})}disconnect(){return Promise.resolve()}async processAcknowledge(e,n,r){this.logger.verbose(`processAcknowledge(drive: ${e}, listener: ${n})`,r);let s=!0;for(const i of r)try{await this.manager.updateListenerRevision(n,e,{documentId:i.documentId,scope:i.scope,branch:i.branch},i.revision)}catch(o){this.logger.warn("Error acknowledging sync unit",o,i),s=!1;continue}return s}static async registerPullResponder(e,n,r,s,i){var u,d;fe().verbose(`registerPullResponder(url: ${n})`,r);const o=await this.getAuthHeaders(n,i),a=await nt(n,Dt`
|
|
233
|
-
mutation registerPullResponderListener(
|
|
234
|
-
$filter: InputListenerFilter!
|
|
235
|
-
$listenerId: String
|
|
236
|
-
) {
|
|
237
|
-
registerPullResponderListener(
|
|
238
|
-
filter: $filter
|
|
239
|
-
listenerId: $listenerId
|
|
240
|
-
) {
|
|
241
|
-
listenerId
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
`,{filter:r,listenerId:s},o),c=(u=a.errors)==null?void 0:u.at(0);if(c){if(c.message.includes("Unauthorized")){const l=await this.getAuthHeaders(n,i),f=await nt(n,Dt`
|
|
245
|
-
mutation registerPullResponderListener(
|
|
246
|
-
$filter: InputListenerFilter!
|
|
247
|
-
$listenerId: String
|
|
248
|
-
) {
|
|
249
|
-
registerPullResponderListener(
|
|
250
|
-
filter: $filter
|
|
251
|
-
listenerId: $listenerId
|
|
252
|
-
) {
|
|
253
|
-
listenerId
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
`,{filter:r,listenerId:s},l);if((d=f.errors)!=null&&d.at(0))throw f.errors[0];if(!f.registerPullResponderListener)throw new Error("Error registering listener");return f.registerPullResponderListener.listenerId}throw c}if(!a.registerPullResponderListener)throw new Error("Error registering listener");return a.registerPullResponderListener.listenerId}static async pullStrands(e,n,r,s,i){var d,l;fe().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands called for drive: ${e}, url: ${n}, listener: ${r}, options: ${JSON.stringify(s||{})}`);const o=await this.getAuthHeaders(n,i),a=await nt(n,Dt`
|
|
257
|
-
query strands($listenerId: ID!) {
|
|
258
|
-
system {
|
|
259
|
-
sync {
|
|
260
|
-
strands(listenerId: $listenerId) {
|
|
261
|
-
driveId
|
|
262
|
-
documentId
|
|
263
|
-
documentType
|
|
264
|
-
scope
|
|
265
|
-
branch
|
|
266
|
-
operations {
|
|
267
|
-
id
|
|
268
|
-
timestamp
|
|
269
|
-
skip
|
|
270
|
-
type
|
|
271
|
-
input
|
|
272
|
-
hash
|
|
273
|
-
index
|
|
274
|
-
context {
|
|
275
|
-
signer {
|
|
276
|
-
user {
|
|
277
|
-
address
|
|
278
|
-
networkId
|
|
279
|
-
chainId
|
|
280
|
-
}
|
|
281
|
-
app {
|
|
282
|
-
name
|
|
283
|
-
key
|
|
284
|
-
}
|
|
285
|
-
signatures
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
`,{listenerId:r},o),c=(d=a.errors)==null?void 0:d.at(0);if(c){if(c.message.includes("Unauthorized")){const f=await this.getAuthHeaders(n,i),h=await nt(n,Dt`
|
|
294
|
-
query strands($listenerId: ID!) {
|
|
295
|
-
system {
|
|
296
|
-
sync {
|
|
297
|
-
strands(listenerId: $listenerId) {
|
|
298
|
-
driveId
|
|
299
|
-
documentId
|
|
300
|
-
documentType
|
|
301
|
-
scope
|
|
302
|
-
branch
|
|
303
|
-
operations {
|
|
304
|
-
id
|
|
305
|
-
timestamp
|
|
306
|
-
skip
|
|
307
|
-
type
|
|
308
|
-
input
|
|
309
|
-
hash
|
|
310
|
-
index
|
|
311
|
-
context {
|
|
312
|
-
signer {
|
|
313
|
-
user {
|
|
314
|
-
address
|
|
315
|
-
networkId
|
|
316
|
-
chainId
|
|
317
|
-
}
|
|
318
|
-
app {
|
|
319
|
-
name
|
|
320
|
-
key
|
|
321
|
-
}
|
|
322
|
-
signatures
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
`,{listenerId:r},f);if((l=h.errors)!=null&&l.at(0))throw h.errors[0];return h.system?h.system.sync.strands.map(m=>({...m,operations:m.operations.map(E=>({...E,input:JSON.parse(E.input)}))})):[]}throw c}if(!a.system)return fe().verbose(`[SYNC DEBUG] No system data returned when pulling strands for drive: ${e}, listener: ${r}`),[];const u=a.system.sync.strands.map(f=>({...f,operations:f.operations.map(h=>({...h,input:JSON.parse(h.input)}))}));return fe().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands returning ${u.length} strands for drive: ${e}, listener: ${r}`),u.length>0&&fe().verbose(`[SYNC DEBUG] Strands being returned: ${u.map(f=>`${f.documentId}:${f.scope}`).join(", ")}`),u}static async acknowledgeStrands(e,n,r,s){fe().verbose(`acknowledgeStrands(url: ${e}, listener: ${n})`,r);const i=[];for(let u=0;u<r.length;u+=Ka)i.push(r.slice(u,u+Ka));i.length>1&&fe().verbose(`Breaking strand acknowledgement into ${i.length} chunks...`);const o=await this.getAuthHeaders(e,s);if((await Promise.allSettled(i.map(async u=>{var f,h;const d=await nt(e,Dt`
|
|
331
|
-
mutation acknowledge(
|
|
332
|
-
$listenerId: String!
|
|
333
|
-
$revisions: [ListenerRevisionInput]
|
|
334
|
-
) {
|
|
335
|
-
acknowledge(listenerId: $listenerId, revisions: $revisions)
|
|
336
|
-
}
|
|
337
|
-
`,{listenerId:n,revisions:u},o),l=(f=d.errors)==null?void 0:f.at(0);if(l){if(l.message.includes("Unauthorized")){const m=await this.getAuthHeaders(e,s),E=await nt(e,Dt`
|
|
338
|
-
mutation acknowledge(
|
|
339
|
-
$listenerId: String!
|
|
340
|
-
$revisions: [ListenerRevisionInput]
|
|
341
|
-
) {
|
|
342
|
-
acknowledge(listenerId: $listenerId, revisions: $revisions)
|
|
343
|
-
}
|
|
344
|
-
`,{listenerId:n,revisions:u},m);if((h=E.errors)!=null&&h.at(0))throw E.errors[0];if(E.acknowledge===null||!E.acknowledge)throw new Error("Error acknowledging strands");return}throw l}if(d.acknowledge===null||!d.acknowledge)throw new Error("Error acknowledging strands")}))).filter(u=>u.status==="rejected").length>0)throw new Error("Error acknowledging strands")}static async executePull(e,n,r,s,i,o,a){var m;fe().verbose(`executePull(driveId: ${e}), trigger:`,n),fe().debug(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${e}, listenerId: ${n.data.listenerId}`);const{url:c}=n.data;let u,d;const l=n.data.listenerId;try{u=await He.pullStrands(e,c,l,void 0,a)}catch(E){d=E;const P=((m=d.response)==null?void 0:m.errors)??[];for(const B of P)if(B.message==="Listener not found"){fe().verbose(`[SYNC DEBUG] Auto-registering pull responder for drive: ${e}`),await He.registerPullResponder(n.driveId,c,n.filter,l);try{u=await He.pullStrands(e,c,l,void 0,a),fe().verbose(`Successfully auto-registered and pulled strands for drive: ${e}, listenerId: ${l}`)}catch(R){return fe().error(`Could not resolve 'Listener not found' error by registering a new pull responder for drive: ${e}, listenerId: ${l}: ${R}`),s(R),!1}break}}if(!u)return fe().error(`Error pulling strands for drive, and could not auto-register: ${e}, listenerId: ${n.data.listenerId}: ${d}`),s(d),!1;if(!u.length){fe().verbose(`[SYNC DEBUG] No strands returned in pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);try{i==null||i([])}catch(E){fe().error(`Error calling onRevisions for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),s(E)}return!1}fe().verbose(`[SYNC DEBUG] Processing ${u.length} strands in pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);const f=[];for(const E of u){const D=E.operations.map(B=>({...B,scope:E.scope,branch:E.branch}));fe().verbose(`[SYNC DEBUG] Processing strand for drive: ${E.driveId}, document: ${E.documentId}, scope: ${E.scope}, with ${D.length} operations`);let P;try{const B=await r(E,{type:"trigger",trigger:n});if(B.error)throw B.error}catch(B){fe().error(`Error processing strand for drive: ${E.driveId}, document: ${E.documentId}, scope: ${E.scope}, with ${D.length} operations: ${B}`),P=B,s(P)}f.push({branch:E.branch,documentId:E.documentId||"",documentType:E.documentType,driveId:E.driveId,revision:Mn(D),scope:E.scope,status:P?P instanceof Ge?P.status:"ERROR":"SUCCESS",error:P})}fe().verbose("Processed strands...");try{i==null||i(f)}catch(E){fe().error(`Error calling onRevisions for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),s(E)}fe().verbose(`[SYNC DEBUG] Acknowledging ${f.length} strands for drive: ${e}, listenerId: ${n.data.listenerId}`);let h=!1;try{await He.acknowledgeStrands(c,n.data.listenerId,f.map(E=>{const{error:D,...P}=E;return P}),a),h=!0}catch(E){fe().error(`Error acknowledging strands for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),s(E)}h?fe().verbose(`[SYNC DEBUG] Successfully acknowledged strands for drive: ${e}, listenerId: ${n.data.listenerId}`):fe().error("Failed to acknowledge strands");try{o==null||o(h)}catch(E){fe().error(`Error calling onAcknowledge for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),s(E)}return u.length>0}static setupPull(e,n,r,s,i,o,a){fe().verbose(`[SYNC DEBUG] PullResponderTransmitter.setupPull initiated for drive: ${e}, listenerId: ${n.data.listenerId}`);const{interval:c}=n.data;let u=Dv;if(c)try{const h=parseInt(c);h&&(u=h)}catch{}fe().verbose(`[SYNC DEBUG] Pull interval set to ${u}ms for drive: ${e}, listenerId: ${n.data.listenerId}`);let d=!1,l;return(async()=>{for(;!d;){fe().verbose(`[SYNC DEBUG] Starting pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);let h=0,m=!0;for(;m&&!d&&h<Nv;)h++,m=await this.executePull(e,n,r,s,i,o,a),m&&fe().verbose(`[SYNC DEBUG] More strands available, continuing pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);fe().verbose(`[SYNC DEBUG] Completed pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}, waiting ${u}ms for next cycle`),await new Promise(E=>{fe().verbose(`Scheduling next pull in ${u} ms`),l=setTimeout(E,u)})}})().catch(h=>{fe().error(`Error in executeLoop for drive: ${e}, listenerId: ${n.data.listenerId}: ${h}`)}),()=>{fe().verbose(`[SYNC DEBUG] Cancelling pull loop for drive: ${e}, listenerId: ${n.data.listenerId}`),d=!0,l!==void 0&&clearTimeout(l)}}static async createPullResponderTrigger(e,n,r,s){fe().verbose(`createPullResponderTrigger(drive: ${e}, url: ${n})`);const{pullFilter:i,pullInterval:o}=r,a=i??{documentId:["*"],documentType:["*"],branch:["*"],scope:["*"]},c=await He.registerPullResponder(e,n,a,void 0,s);return{id:Et(),type:"PullResponder",driveId:e,filter:a,data:{url:n,listenerId:c,interval:(o==null?void 0:o.toString())??""}}}static isPullResponderTrigger(e){return e.type==="PullResponder"}}var hi,Xa;function Ov(){return Xa||(Xa=1,hi={space:"",cycles:!1,replacer:(t,e)=>e,stringify:JSON.stringify}),hi}var gi,Za;function Qt(){return Za||(Za=1,gi={isArray:Array.isArray,assign:Object.assign,isObject:t=>typeof t=="object",isFunction:t=>typeof t=="function",isBoolean:t=>typeof t=="boolean",isRegex:t=>t instanceof RegExp,keys:Object.keys}),gi}var mi,ec;function Av(){if(ec)return mi;ec=1;const t=Ov(),e=Qt().isFunction,n=Qt().isBoolean,r=Qt().isObject,s=Qt().isArray,i=Qt().isRegex,o=Qt().assign,a=Qt().keys;function c(d){return d==null?d:i(d)?d.toString():d.toJSON?d.toJSON():d}function u(d,l){l=l||o({},t),e(l)&&(l={compare:l});const f=l.space||t.space,h=n(l.cycles)?l.cycles:t.cycles,m=l.replacer||t.replacer,E=l.stringify||t.stringify,D=l.compare&&function(B){return function(R){return function(Q,N){const X={key:Q,value:R[Q]},w={key:N,value:R[N]};return B(X,w)}}}(l.compare);h||E(d);const P=[];return function B(R,Q,N,X){const w=f?`
|
|
345
|
-
`+new Array(X+1).join(f):"",$=f?": ":":";if(N=c(N),N=m.call(R,Q,N),N!==void 0){if(!r(N)||N===null)return E(N);if(s(N)){const A=[];for(let C=0;C<N.length;C++){const L=B(N,C,N[C],X+1)||E(null);A.push(w+f+L)}return"["+A.join(",")+w+"]"}else{if(h){if(P.indexOf(N)!==-1)return E("[Circular]");P.push(N)}const A=a(N).sort(D&&D(N)),C=[];for(let L=0;L<A.length;L++){const O=A[L],re=B(N,O,N[O],X+1);if(!re)continue;const ie=E(O)+$+re;C.push(w+f+ie)}return P.splice(P.indexOf(N),1),"{"+C.join(",")+w+"}"}}}({"":d},"",d,0)}return mi=u,mi}var Rv=Av();const Cv=ws(Rv),tc=10;class Jl{constructor(e,n){F(this,"targetURL");F(this,"manager");F(this,"logger",wt(["SwitchboardPushTransmitter",Math.floor(Math.random()*999).toString()]));this.targetURL=e,this.manager=n}async getAuthHeaders(){var e;if(!((e=this.manager)!=null&&e.generateJwtHandler))return this.logger.verbose(`No JWT handler available for ${this.targetURL}`),{};try{const n=await this.manager.generateJwtHandler(this.targetURL);return n?{Authorization:`Bearer ${n}`}:(this.logger.verbose(`No JWT generated for ${this.targetURL}`),{})}catch(n){return this.logger.error(`Error generating JWT for ${this.targetURL}:`,n),{}}}async requestWithAuth(e,n){var o;const r=await this.getAuthHeaders(),s=await nt(this.targetURL,e,n,r),i=(o=s.errors)==null?void 0:o.at(0);if(i!=null&&i.message.includes("Unauthorized")){const a=await this.getAuthHeaders();return nt(this.targetURL,e,n,a)}return s}async transmit(e,n){var i;if(n.type==="trigger"&&((i=n.trigger.data)==null?void 0:i.url)===this.targetURL)return this.logger.verbose(`Cutting trigger loop from ${this.targetURL}.`),e.map(o=>({driveId:o.driveId,documentId:o.documentId,documentType:o.documentType,scope:o.scope,branch:o.branch,status:"SUCCESS",revision:Mn(o.operations)}));const r=[];let s=0;for(let o=0;s<=tc&&o<e.length;o++){const a=e.at(o);if(!a)break;const c=Math.min(tc-s,a.operations.length);r.push({...a,operations:a.operations.slice(0,c)}),s+=c}this.logger.verbose(` Total update: [${e.map(o=>o.operations.length).join(", ")}] operations`),this.logger.verbose(`Culled update: [${r.map(o=>o.operations.length).join(", ")}] operations`);try{const o=await this.requestWithAuth(Dt`
|
|
346
|
-
mutation pushUpdates($strands: [InputStrandUpdate!]) {
|
|
347
|
-
pushUpdates(strands: $strands) {
|
|
348
|
-
driveId
|
|
349
|
-
documentId
|
|
350
|
-
documentType
|
|
351
|
-
scope
|
|
352
|
-
branch
|
|
353
|
-
status
|
|
354
|
-
revision
|
|
355
|
-
error
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
`,{strands:r.map(a=>({...a,operations:a.operations.map(c=>({...c,input:Cv(c.input)}))}))});if(!o.pushUpdates)throw new Error("Couldn't update listener revision");return o.pushUpdates}catch(o){throw this.logger.error(o),o}}}var nc;(function(t){t[t.Internal=0]="Internal",t[t.SwitchboardPush=1]="SwitchboardPush",t[t.PullResponder=2]="PullResponder",t[t.SecureConnect=3]="SecureConnect",t[t.MatrixConnect=4]="MatrixConnect",t[t.RESTWebhook=5]="RESTWebhook"})(nc||(nc={}));const hs={sequentialUpdates:!0};function rc(t,e){return e?Object.keys(t).reduce((n,r)=>{const s=e[r];return s!==void 0&&(n[r]=t[r].filter(i=>i.index<=s)),n},{global:[],local:[]}):t}function yi(t,e){return!e||Object.entries(e).find(([n,r])=>{const s=t.operations[n].at(-1);return r===-1?s!==void 0:(s==null?void 0:s.index)!==r})===void 0}function sc(t){return{id:Lv(t),documentType:xv(t),document:Mv(t)}}function Lv(t){return"id"in t?t.id:"header"in t?t.header.id:"document"in t?t.document.header.id:void 0}function xv(t){return"documentType"in t?t.documentType:"header"in t?t.header.documentType:t.document.header.documentType}function Mv(t){return"document"in t?t.document:void 0}class Pv{constructor(e,n,r,s,i,o,a,c,u){F(this,"logger",wt(["BaseDocumentDriveServer"]));F(this,"documentModelModules");F(this,"legacyStorage");F(this,"documentStorage");F(this,"cache");F(this,"queueManager");F(this,"eventEmitter");F(this,"options");F(this,"listenerManager");F(this,"synchronizationManager");F(this,"generateJwtHandler");F(this,"defaultDrivesManager");F(this,"defaultDrivesManagerDelegate",{detachDrive:this.detachDrive.bind(this),emit:(...e)=>this.eventEmitter.emit("defaultRemoteDrive",...e)});F(this,"queueDelegate",{exists:e=>this.documentStorage.exists(e),processOperationJob:async({documentId:e,operations:n,options:r})=>{const s=await this.getDocument(e);return Tt(s)?this.processDriveOperations(e,n,r):this.processOperations(e,n,r)},processActionJob:async({documentId:e,actions:n,options:r})=>{const s=await this.getDocument(e);return Tt(s)?this.processDriveActions(e,n,r):this.processActions(e,n,r)},processDocumentJob:async({documentId:e,documentType:n,initialState:r,options:s})=>{const o=this.getDocumentModelModule(n).utils.createDocument({...r}),a=Vr(e,n);o.header.id=e,o.header.sig=a.sig,o.header.documentType=n;try{const c=await this.createDocument({document:o},(s==null?void 0:s.source)??{type:"local"},r==null?void 0:r.header.meta);return{status:"SUCCESS",operations:[],document:c,signals:[]}}catch(c){const u=c instanceof Error?c:new Error(JSON.stringify(c));return{status:"ERROR",error:new Ge("ERROR",void 0,`Error creating document: ${u.message}`,u),operations:[],document:void 0,signals:[]}}},processJob:async e=>{if(Hu(e))return this.queueDelegate.processOperationJob(e);if($g(e))return this.queueDelegate.processActionJob(e);if(zr(e))return this.queueDelegate.processDocumentJob(e);throw new Error("Unknown job type",e)}});F(this,"triggerMap",new Map);F(this,"initializePromise");this.documentModelModules=e,this.legacyStorage=n,this.documentStorage=r,this.cache=s,this.queueManager=i,this.eventEmitter=o,this.synchronizationManager=a,this.listenerManager=c,this.options={...u,defaultDrives:{...u==null?void 0:u.defaultDrives},listenerManager:{...hs,...u==null?void 0:u.listenerManager},jwtHandler:(u==null?void 0:u.jwtHandler)===void 0?()=>Promise.resolve(""):u.jwtHandler,taskQueueMethod:(u==null?void 0:u.taskQueueMethod)===void 0?sn.runAsap:u.taskQueueMethod},this.defaultDrivesManager=new Sv(this,this.defaultDrivesManagerDelegate,u),this.initializePromise=this._initialize()}get listeners(){return this.listenerManager}initialize(){return this.initializePromise}async _initialize(){await this.listenerManager.initialize(this.handleListenerError.bind(this)),await this.queueManager.init(this.queueDelegate,r=>{this.logger.error("Error initializing queue manager",r),e.push(r)});try{await this.defaultDrivesManager.removeOldremoteDrives()}catch(r){this.logger.error(r)}const e=[],n=await this.getDrives();for(const r of n)await this._initializeDrive(r).catch(s=>{this.logger.error(`Error initializing drive ${r}`,s),e.push(s)});return this.options.defaultDrives.loadOnInit!==!1&&await this.defaultDrivesManager.initializeDefaultRemoteDrives(),e.length===0?null:e}setDocumentModelModules(e){this.documentModelModules=[...e],this.synchronizationManager.setDocumentModelModules([...e]),this.eventEmitter.emit("documentModelModules",[...e])}initializeDefaultRemoteDrives(){return this.defaultDrivesManager.initializeDefaultRemoteDrives()}getDefaultRemoteDrives(){return this.defaultDrivesManager.getDefaultRemoteDrives()}setDefaultDriveAccessLevel(e,n){return this.defaultDrivesManager.setDefaultDriveAccessLevel(e,n)}setAllDefaultDrivesAccessLevel(e){return this.defaultDrivesManager.setAllDefaultDrivesAccessLevel(e)}getOperationSource(e){return e.type==="local"?"push":"pull"}handleListenerError(e,n,r){this.logger.error(`Listener ${r.listener.label??r.listener.listenerId} error:`,e);const s=e instanceof Ge?e.status:"ERROR";this.synchronizationManager.updateSyncStatus(n,{push:s},e)}shouldSyncRemoteDrive(e){return e.state.local.availableOffline&&e.state.local.triggers.length>0}async startSyncRemoteDrive(e){let n=this.triggerMap.get(e);const r=await this.synchronizationManager.getSynchronizationUnitsIds(e),s=await this.getDrive(e);for(const i of s.state.local.triggers)if(!(n!=null&&n.get(i.id))){n||(n=new Map),this.synchronizationManager.updateSyncStatus(e,{pull:"SYNCING"});for(const o of r)this.synchronizationManager.updateSyncStatus(o,{pull:"SYNCING"});if(He.isPullResponderTrigger(i)){let o=!0;const a=He.setupPull(e,i,this.saveStrand.bind(this),c=>{const u=c instanceof Ge?c.status:"ERROR";this.synchronizationManager.updateSyncStatus(e,{pull:u},c),c instanceof Nn&&this.eventEmitter.emit("clientStrandsError",e,i,c.response.status,c.message)},async c=>{c.filter(d=>d.status!=="SUCCESS").length<1&&this.synchronizationManager.updateSyncStatus(e,{pull:"SUCCESS"});for(const d of c){const{documentId:l,scope:f,branch:h,status:m,error:E}=d;this.synchronizationManager.updateSyncStatus({documentId:l,scope:f,branch:h},{pull:m},E)}if(o){o=!1,(await this.synchronizationManager.getSynchronizationUnitsIds(e)).filter(h=>!c.find(m=>m.documentId===h.documentId&&m.scope===h.scope&&m.branch===h.branch)).forEach(h=>{this.synchronizationManager.updateSyncStatus(h,{pull:"SUCCESS"})});const f=s.state.local.listeners.find(h=>{var m;return i.data.url===((m=h.callInfo)==null?void 0:m.data)});if(f)for(const h of c){const{documentId:m,scope:E,branch:D}=h;this.listenerManager.updateListenerRevision(f.listenerId,e,{documentId:m,scope:E,branch:D},h.revision).catch(this.logger.error)}}},void 0,this.listeners);n.set(i.id,a),this.triggerMap.set(e,n)}}}async stopSyncRemoteDrive(e){const n=this.triggerMap.get(e);n==null||n.forEach(s=>s()),this.synchronizationManager.updateSyncStatus(e,null);const r=await this.synchronizationManager.getSynchronizationUnitsIds(e);for(const s of r)this.synchronizationManager.updateSyncStatus(s,null);return this.triggerMap.delete(e)}async _initializeDrive(e){var r,s,i;const n=await this.getDrive(e);this.logger.verbose(`[SYNC DEBUG] Initializing drive ${e} with slug "${n.header.slug}"`),await this.synchronizationManager.initializeDriveSyncStatus(e,n),this.shouldSyncRemoteDrive(n)&&(this.logger.verbose(`[SYNC DEBUG] Starting sync for remote drive ${e}`),await this.startSyncRemoteDrive(e)),this.logger.verbose(`[SYNC DEBUG] Processing ${n.state.local.listeners.length} listeners for drive ${e}`);for(const o of n.state.local.listeners)if(((r=o.callInfo)==null?void 0:r.transmitterType)==="SwitchboardPush"){this.logger.verbose(`[SYNC DEBUG] Setting up SwitchboardPush listener ${o.listenerId} for drive ${e}`);const a=new Jl(o.callInfo.data??"",this.listeners);this.logger.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${o.callInfo.data||"none"}`),await this.listenerManager.setListener(e,{block:o.block,driveId:n.header.id,filter:{branch:o.filter.branch??[],documentId:o.filter.documentId??[],documentType:o.filter.documentType??[],scope:o.filter.scope??[]},listenerId:o.listenerId,callInfo:o.callInfo,system:o.system,label:o.label??"",transmitter:a}).then(()=>{this.logger.verbose(`[SYNC DEBUG] Successfully set up listener ${o.listenerId} for drive ${e}`)})}else if(((s=o.callInfo)==null?void 0:s.transmitterType)==="PullResponder"){this.logger.verbose(`[SYNC DEBUG] Setting up PullResponder listener ${o.listenerId} for drive ${e}`);const a={driveId:e,listenerId:o.listenerId,block:!1,filter:o.filter,system:!1,label:`PullResponder #${o.listenerId}`,callInfo:{data:"",name:"PullResponder",transmitterType:"PullResponder"}},c=new He(a,this.listenerManager);a.transmitter=c,await this.listenerManager.setListener(e,a)}else this.logger.error(`Skipping listener ${o.listenerId} with unsupported type ${((i=o.callInfo)==null?void 0:i.transmitterType)||"unknown"}`)}getDocumentModelModule(e){const n=this.documentModelModules.find(r=>r.documentModel.id===e);if(!n)throw new Error(`Document type ${e} not supported`);return n}getDocumentModelModules(){return[...this.documentModelModules]}addDocument(e,n){const r=typeof e=="string"?{documentType:e}:{document:e};return this.createDocument(r,{type:"local"},n)}async addDrive(e,n){const r=Ag({state:{global:{icon:e.global.icon??null,name:e.global.name},local:e.local??{}}});e.id&&e.id.length>0&&(r.header.id=e.id),e.slug&&e.slug.length>0&&(r.header.slug=e.slug);const s=e.preferredEditor||n;return s&&(r.header.meta={preferredEditor:s}),await this.documentStorage.create(r),e.slug&&e.slug.length>0&&await this.cache.deleteDriveBySlug(e.slug),await this._initializeDrive(r.header.id),this.eventEmitter.emit("driveAdded",r),r}async addRemoteDrive(e,n){var E;await((E=this.generateJwtHandler)==null?void 0:E.call(this,e));const{id:r,name:s,slug:i,icon:o,meta:a}=n.expectedDriveInfo||await Wn(e,this),{pullFilter:c,pullInterval:u,availableOffline:d,sharingType:l,listeners:f,triggers:h}=n,m=await He.createPullResponderTrigger(r,e,{pullFilter:c,pullInterval:u},this.listeners);return await this.addDrive({id:r,slug:i,global:{name:s,icon:o},local:{triggers:[...h,m],listeners:f,availableOffline:d,sharingType:l}},a==null?void 0:a.preferredEditor)}async deleteDrive(e){const n=await Promise.allSettled([this.stopSyncRemoteDrive(e),this.listenerManager.removeDrive(e),this.cache.deleteDrive(e),this.documentStorage.delete(e)]);this.eventEmitter.emit("driveDeleted",e),n.forEach(r=>{if(r.status==="rejected")throw r.reason})}async getDrives(){const e=[];let n;do{const{documents:r,nextCursor:s}=await this.documentStorage.findByType("powerhouse/document-drive",100,n);e.push(...r),n=s}while(n);return e}async getDrivesSlugs(){const e=await this.getDrives();return this.documentStorage.resolveSlugs(e)}async getDrive(e,n){let r;try{const o=await this.cache.getDrive(e);if(o&&Tt(o)&&(r=o,yi(r,n==null?void 0:n.revisions)))return r}catch(o){this.logger.error("Error getting drive from cache",o)}const s=r??await this.documentStorage.get(e),i=this._buildDocument(s,n);if(Tt(i))return n!=null&&n.revisions||(this.cache.setDocument(e,i).catch(this.logger.error),this.cache.setDrive(e,i).catch(this.logger.error)),i;throw new Error(`Document with id ${e} is not a Document Drive`)}async getDriveBySlug(e,n){try{const i=await this.cache.getDriveBySlug(e);if(i)return i}catch(i){this.logger.error("Error getting drive from cache",i)}const r=await this.documentStorage.getBySlug(e),s=this._buildDocument(r,n);if(Tt(s))return this.cache.setDriveBySlug(e,s).catch(this.logger.error),s;throw new Error(`Document with slug ${e} is not a Document Drive`)}async getDriveIdBySlug(e){try{const r=await this.cache.getDriveBySlug(e);if(r)return r.header.id}catch(r){this.logger.error("Error getting drive from cache",r)}return(await this.documentStorage.getBySlug(e)).header.id}getDocument(e,n,r){const s=typeof n=="string"?n:e,i=typeof n=="object"?n:r;return this._getDocument(s,i)}async _getDocument(e,n){let r;try{if(r=await this.cache.getDocument(e),r&&yi(r,n==null?void 0:n.revisions))return r}catch(o){this.logger.error("Error getting document from cache",o)}const s=r??await this.documentStorage.get(e),i=this._buildDocument(s,n);return n!=null&&n.revisions||this.cache.setDocument(e,i).catch(this.logger.error),i}getDocuments(e){return this.documentStorage.getChildren(e)}async addChild(e,n){try{await this.documentStorage.addChild(e,n)}catch(r){throw this.logger.error("Error adding child document",r),r}}async removeChild(e,n){try{const r=await this.synchronizationManager.getSynchronizationUnitsIds(e,[n]);await this.listenerManager.removeSyncUnits(e,r)}catch(r){this.logger.warn("Error removing sync units of child",r)}try{await this.documentStorage.removeChild(e,n)}catch(r){throw this.logger.error("Error adding child document",r),r}}async createDocument(e,n,r){const{documentType:s,document:i}=sc(e);let o;if(i){if("documentType"in e&&s!==i.header.documentType)throw new Error(`Provided document is not ${s}`);o=this._buildDocument(i).state}const a=i??this.getDocumentModelModule(s).utils.createDocument({state:o});let c;if("id"in e&&e.id)i?(c=a.header,a.header.id=e.id,this.logger.warn("Assigning an id to a document is deprecated. Use the header field instead.")):(this.logger.warn("Creating a document with an id is deprecated. Use the header field instead."),c=Vr(e.id,s));else if("header"in e)await ia(e.header),c=e.header;else if(i!=null&&i.header){if(!i.header.id)throw new Error("Document header id is required");if(!i.header.documentType)throw new Error("Document header documentType is required");if(!i.header.createdAtUtcIso)throw new Error("Document header createdAtUtcIso is required");i.header.sig.nonce?await ia(i.header):this.logger.warn("Creating a document with an unsigned id is deprecated. Use createSignedHeaderForSigner."),c=i.header}else c=Vr(void 0,s);r&&(c.meta={...c.meta,...r});const u={header:c,history:a.history,operations:{global:[],local:[]},initialState:a.initialState,clipboard:[],attachments:a.attachments,state:o??a.state};await this.documentStorage.create(u);const d=Object.values(a.operations).flat();return d.length&&(Tt(a)?await this.legacyStorage.addDriveOperations(c.id,d,a):await this.legacyStorage.addDocumentOperations(c.id,d,a)),await this.getDocument(u.header.id)}async deleteDocument(e){try{const n=await this.synchronizationManager.getSynchronizationUnitsIds(void 0,[e]);for(const s of n)this.synchronizationManager.updateSyncStatus(s,null);const r=await this.documentStorage.getParents(e);for(const s of r)this.listenerManager.removeSyncUnits(s,n).catch(this.logger.warn)}catch(n){this.logger.warn("Error deleting document",n)}await this.cache.deleteDocument(e),await this.documentStorage.delete(e)}async _processOperations(e,n,r){const s=[],i=[],o=await this._addDocumentResultingStage(n,e);let a=this._buildDocument(o),c;const u=Kf(r);for(const d of Object.keys(u)){const l=n.operations[d],f=Xf(u[d]||[],l);if(f.length<1)continue;const h=Zf(ep(l)),[m,E]=tp(h,f),P=(E.length<1?m:np(h,m,ip)).filter(B=>h.length<1||rp(h[h.length-1],B));for(const B of P){let R=!1;if(E.length>0){const Q=r.find(N=>N.hash===B.hash);R=!Q||Q.index!==B.index||Q.skip!==B.skip}try{const Q=this.options.taskQueueMethod,N=()=>this._performOperation(e,a,B,R),X=await(Q?Tv(N,Q):N());a=X.document,i.push(...X.signals),s.push(X.operation)}catch(Q){c=Q instanceof Ge?Q:new Ge("ERROR",B,Q.message,Q.cause);break}}}return{document:a,operationsApplied:s,signals:i,error:c}}async _addDocumentResultingStage(e,n,r){var o,a,c,u;const s=(r==null?void 0:r.revisions)!==void 0?rc(e.operations,r.revisions):e.operations,i=Gr(s);for(const d of Object.keys(i)){const l=i[d].at(-1);l&&!l.resultingState&&(l.resultingState=await(Tt(e)?(a=(o=this.legacyStorage).getOperationResultingState)==null?void 0:a.call(o,n,l.index,l.scope,"main"):(u=(c=this.legacyStorage).getDriveOperationResultingState)==null?void 0:u.call(c,n,l.index,l.scope,"main")))}return{...e,operations:i}}_buildDocument(e,n){if(e.state&&(!n||n.checkHashes===!1)&&yi(e,n==null?void 0:n.revisions))return e;const r=this.getDocumentModelModule(e.header.documentType),s=(n==null?void 0:n.revisions)!==void 0?rc(e.operations,n.revisions):e.operations,i=Gr(s);return Uc(e.initialState,i,r.reducer,void 0,e.header,void 0,{...n,checkHashes:(n==null?void 0:n.checkHashes)??!0,reuseOperationResultingState:(n==null?void 0:n.checkHashes)??!0})}async _performOperation(e,n,r,s=!1){var m,E,D,P;const i=this.getDocumentModelModule(n.header.documentType),o=[];let a=n;const c=r.scope,d=Gr({...n.operations,[c]:sp(n.operations[c],r)})[c].at(-1);d&&!d.resultingState&&(d.resultingState=await(Tt(n)?(E=(m=this.legacyStorage).getOperationResultingState)==null?void 0:E.call(m,e,d.index,d.scope,"main"):(P=(D=this.legacyStorage).getDriveOperationResultingState)==null?void 0:P.call(D,e,d.index,d.scope,"main")));const l=[];a=i.reducer(a,r,B=>{let R;switch(B.type){case"CREATE_CHILD_DOCUMENT":R=()=>this.addChild(e,B.input.id);break;case"DELETE_CHILD_DOCUMENT":R=()=>this.removeChild(e,B.input.id);break;case"COPY_CHILD_DOCUMENT":R=()=>this.addChild(e,B.input.newId);break}R&&l.push(()=>R().then(Q=>({signal:B,result:Q})))},{skip:r.skip,reuseOperationResultingState:!0});const h=a.operations[r.scope].filter(B=>B.index==r.index&&B.skip==r.skip).at(0);if(!h)throw new Ge("ERROR",r,`Operation with index ${r.index}:${r.skip} was not applied.`);if(!h.error&&h.hash!==r.hash&&!s)throw this.logger.warn(JSON.stringify(h,null,2)),new Tg(r,h);for(const B of l){const R=await B();o.push(R)}return{document:a,signals:o,operation:h}}addOperation(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this.addOperations(i,[o],a)}async _addOperations(e,n){if(this.legacyStorage.addDocumentOperationsWithTransaction)await this.legacyStorage.addDocumentOperationsWithTransaction(e,n);else{const r=await this.documentStorage.get(e),s=await n(r);s.operations.length>0&&await this.legacyStorage.addDocumentOperations(e,s.operations,s.document)}}async queueDocument(e,n){const{id:r,documentType:s,document:i}=sc(e);if(!r)throw new Error("Document id is required",{cause:e});if(!s)throw new Error("Document type is required",{cause:e});if(await this.documentStorage.exists(r))throw new bn(r);let a;const c=new Promise((u,d)=>{const l=this.queueManager.on("jobCompleted",(h,m)=>{h.jobId===a&&(l(),f(),u(m))}),f=this.queueManager.on("jobFailed",(h,m)=>{h.jobId===a&&(l(),f(),d(m))})});try{a=await this.queueManager.addJob({documentId:r,documentType:s,initialState:i,options:n})}catch(u){throw this.logger.error("Error adding job",u),u}return c}queueOperation(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this._queueOperations(i,[o],a)}async resultIfExistingOperations(e,n){try{const r=await this.getDocument(e);return n.find(i=>!i.id||!r.operations[i.scope].find(o=>o.id===i.id&&o.index===i.index&&o.type===i.type&&o.hash===i.hash))?void 0:{status:"SUCCESS",document:r,operations:n,signals:[]}}catch(r){r.message.includes(`Document with id ${e} not found`)||console.error(r);return}}queueOperations(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this._queueOperations(i,o,a)}async _queueOperations(e,n,r){const s=await this.resultIfExistingOperations(e,n);if(s)return s;let i;const o=new Promise((a,c)=>{const u=this.queueManager.on("jobCompleted",(l,f)=>{l.jobId===i&&(u(),d(),a(f))}),d=this.queueManager.on("jobFailed",(l,f)=>{l.jobId===i&&(u(),d(),c(f))})});try{i=await this.queueManager.addJob({documentId:e,operations:n,options:r})}catch(a){throw this.logger.error("Error adding job",a),a}return o}queueAction(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this._queueActions(i,[o],a)}queueActions(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this._queueActions(i,o,a)}async _queueActions(e,n,r){try{const s=await this.queueManager.addJob({documentId:e,actions:n,options:r});return await new Promise((i,o)=>{const a=this.queueManager.on("jobCompleted",(u,d)=>{u.jobId===s&&(a(),c(),i(d))}),c=this.queueManager.on("jobFailed",(u,d)=>{u.jobId===s&&(a(),c(),o(d))})})}catch(s){throw this.logger.error("Error adding job",s),s}}async queueDriveAction(e,n,r){return this.queueDriveActions(e,[n],r)}async queueDriveActions(e,n,r){try{const s=await this.queueManager.addJob({documentId:e,actions:n,options:r});return await new Promise((i,o)=>{const a=this.queueManager.on("jobCompleted",(u,d)=>{u.jobId===s&&(a(),c(),i(d))}),c=this.queueManager.on("jobFailed",(u,d)=>{u.jobId===s&&(a(),c(),o(d))})})}catch(s){throw this.logger.error("Error adding drive job",s),s}}addOperations(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this._queueOperations(i,o,a)}async processOperations(e,n,r){const s=await this.resultIfExistingOperations(e,n);if(s)return s;let i;const o=[],a=[];let c;try{await this._addOperations(e,async h=>{const m=await this._processOperations(e,h,n);if(!m.document)throw this.logger.error("Invalid document"),m.error??new Error("Invalid document");return i=m.document,c=m.error,a.push(...m.signals),o.push(...m.operationsApplied),{operations:m.operationsApplied,document:m.document}});const u=new Array;if(i){this.cache.setDocument(e,i).catch(this.logger.error);for(const h of o){const m={documentId:e,documentType:i.header.documentType,scope:h.scope,branch:"main",revision:h.index+1,lastUpdated:h.timestamp};u.some(D=>D.documentId===m.documentId&&D.scope===m.scope&&D.branch===m.branch)||u.push(m)}}const l=o.find(h=>!n.find(m=>m.id===h.id&&m.index===h.index&&m.skip===h.skip&&m.hash===h.hash))?{type:"local"}:(r==null?void 0:r.source)??{type:"local"},f=this.getOperationSource(l);if(u.length&&this.listenerManager.updateSynchronizationRevisions(u,l,()=>{this.synchronizationManager.updateSyncStatus(e,{[f]:"SYNCING"});for(const h of u)this.synchronizationManager.updateSyncStatus(h,{[f]:"SYNCING"})},this.handleListenerError.bind(this),(r==null?void 0:r.forceSync)??l.type==="local").then(h=>{h.length&&this.synchronizationManager.updateSyncStatus(e,{[f]:"SUCCESS"});for(const m of u)this.synchronizationManager.updateSyncStatus(m,{[f]:"SUCCESS"})}).catch(h=>{this.logger.error("Non handled error updating sync revision",h),this.synchronizationManager.updateSyncStatus(e,{[f]:"ERROR"},h);for(const m of u)this.synchronizationManager.updateSyncStatus(m,{[f]:"ERROR"},h)}),c)throw c;return this.eventEmitter.emit("documentOperationsAdded",e,n),this.eventEmitter.emit("operationsAdded",e,n),{status:"SUCCESS",document:i,operations:o,signals:a}}catch(u){const d=u instanceof Ge?u:new Ge("ERROR",void 0,u.message,u.cause);return{status:d.status,error:d,document:i,operations:o,signals:a}}}addDriveOperation(e,n,r){return this.addDriveOperations(e,[n],r)}async _addDriveOperations(e,n){if(this.legacyStorage.addDriveOperationsWithTransaction)return this.legacyStorage.addDriveOperationsWithTransaction(e,n);{const r=await this.documentStorage.get(e),s=await n(r);return s.operations.length>0&&await this.legacyStorage.addDriveOperations(e,s.operations,s.document),s}}queueDriveOperation(e,n,r){return this.queueDriveOperations(e,[n],r)}async resultIfExistingDriveOperations(e,n){try{const r=await this.getDrive(e);return n.find(i=>!i.id||!r.operations[i.scope].find(o=>o.id===i.id&&o.index===i.index&&o.type===i.type&&o.hash===i.hash))?void 0:{status:"SUCCESS",document:r,operations:n,signals:[]}}catch(r){console.error(r);return}}async queueDriveOperations(e,n,r){const s=await this.resultIfExistingDriveOperations(e,n);if(s)return s;try{const i=await this.queueManager.addJob({documentId:e,operations:n,options:r});return await new Promise((o,a)=>{const c=this.queueManager.on("jobCompleted",(d,l)=>{d.jobId===i&&(c(),u(),o(l))}),u=this.queueManager.on("jobFailed",(d,l)=>{d.jobId===i&&(c(),u(),a(l))})})}catch(i){throw this.logger.error("Error adding drive job",i),i}}async addDriveOperations(e,n,r){return this.queueDriveOperations(e,n,r)}async processDriveOperations(e,n,r){let s;const i=[],o=[];let a;const c=await this.resultIfExistingDriveOperations(e,n);if(c)return c;try{if(await this._addDriveOperations(e,async d=>{const l=await this._processOperations(e,d,n.slice());return s=l.document,i.push(...l.operationsApplied),o.push(...l.signals),a=l.error,{operations:l.operationsApplied,document:l.document}}),!s||!Tt(s))throw a??new Error("Invalid Document Drive document");this.cache.setDocument(e,s).catch(this.logger.error),this.cache.setDrive(e,s).catch(this.logger.error);const u=i.filter(d=>d.scope==="global").slice().pop();if(u){const l=i.find(h=>!n.find(m=>m.id===h.id&&m.index===h.index&&m.skip===h.skip&&m.hash===h.hash))?{type:"local"}:(r==null?void 0:r.source)??{type:"local"},f=this.getOperationSource(l);this.listenerManager.updateSynchronizationRevisions([{documentId:e,documentType:s.header.documentType,scope:"global",branch:"main",lastUpdated:u.timestamp,revision:u.index}],l,()=>{this.synchronizationManager.updateSyncStatus(e,{[f]:"SYNCING"})},this.handleListenerError.bind(this),(r==null?void 0:r.forceSync)??l.type==="local").then(h=>{h.length&&this.synchronizationManager.updateSyncStatus(e,{[f]:"SUCCESS"})}).catch(h=>{this.logger.error("Non handled error updating sync revision",h),this.synchronizationManager.updateSyncStatus(e,{[f]:"ERROR"},h)})}if(this.shouldSyncRemoteDrive(s)?this.startSyncRemoteDrive(e).catch(this.logger.error):this.stopSyncRemoteDrive(e).catch(this.logger.error),a)throw a;return this.eventEmitter.emit("driveOperationsAdded",e,n),this.eventEmitter.emit("operationsAdded",e,n),{status:"SUCCESS",document:s,operations:i,signals:o}}catch(u){const d=u instanceof Ge?u:new Ge("ERROR",void 0,u.message,u);return{status:d.status,error:d,document:s,operations:i,signals:o}}}_buildOperations(e,n){const r=[],{reducer:s}=this.getDocumentModelModule(e.header.documentType);for(const i of n){e=s(e,i);const o=e.operations[i.scope].slice().pop();if(!o)throw new Error("Error creating operations");r.push(o)}return r}addAction(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this._addAction(i,o,a)}async _addAction(e,n,r){return this.addActions(e,[n],r)}addActions(e,n,r,s){let i,o,a;return typeof n=="string"?(i=n,o=r,a=s):(i=e,o=n,a=r),this._queueActions(i,o,a)}async processActions(e,n,r){const s=await this.getDocument(e),i=this._buildOperations(s,n);return this.processOperations(e,i,r)}async addDriveAction(e,n,r){return"synchronizationUnits"in n.input?this._legacyAddFileAction(e,n,r):this.addDriveActions(e,[n],r)}async _legacyAddFileAction(e,n,r){const s=this.getDocumentModelModule(n.input.documentType).utils.createDocument({...n.input.document});s.header.id=n.input.id,s.header.name=n.input.name,s.header.documentType=n.input.documentType,await this.queueDocument({document:s},{source:(r==null?void 0:r.source)||{type:"local"}});const i={...n,input:{id:n.input.id,documentType:s.header.documentType,name:n.input.name,parentFolder:n.input.parentFolder}};return await this.addAction(e,i,r)}async addDriveActions(e,n,r){return this.queueDriveActions(e,n,r)}async processDriveActions(e,n,r){const s=await this.getDrive(e),i=this._buildOperations(s,n);return this.processDriveOperations(e,i,r)}async detachDrive(e){const n=await this.getDrive(e),r=n.state.local.listeners||[],s=n.state.local.triggers||[];for(const i of r)await this.addDriveAction(e,Gu({listenerId:i.listenerId}));for(const i of s)await this.addDriveAction(e,lo({triggerId:i.id}));await this.addDriveAction(e,uo({type:"LOCAL"}))}getSyncStatus(e,n,r){return this.synchronizationManager.getSyncStatus(e,n,r)}on(e,n){return this.eventEmitter.on(e,n)}emit(e,...n){return this.eventEmitter.emit(e,...n)}updateSyncStatus(e,n,r){this.synchronizationManager.updateSyncStatus(e,n,r)}initializeDriveSyncStatus(e,n){return this.synchronizationManager.initializeDriveSyncStatus(e,n)}getCombinedSyncUnitStatus(e){return this.synchronizationManager.getCombinedSyncUnitStatus(e)}async saveStrand(e,n){const r=!await this.documentStorage.exists(e.documentId);let s;r&&(s=await this.queueDocument({id:e.documentId,documentType:e.documentType}));const i=e.operations.map(o=>({...o,scope:e.scope,branch:e.branch}));if((!r||(s==null?void 0:s.status)==="SUCCESS")&&i.length)try{s=await this.queueOperations(e.documentId,i,{source:n})}catch(o){throw this.logger.error("Error queueing operations",o),o}if(!s)return this.logger.debug(`Document ${e.documentId} already exists`),{status:"SUCCESS",document:await this.getDocument(e.documentId),operations:[],signals:[]};if(s.status==="ERROR"){const o=this.getOperationSource(n);this.synchronizationManager.updateSyncStatus({documentId:e.documentId||e.driveId,scope:e.scope,branch:e.branch},{[o]:s.status},s.error)}return this.eventEmitter.emit("strandUpdate",e),s}setGenerateJwtHandler(e){this.generateJwtHandler=e,this.listenerManager.setGenerateJwtHandler(e)}removeJwtHandler(){this.generateJwtHandler=void 0,this.listenerManager.removeJwtHandler()}}const kv=wv(Pv);class gs extends Error{constructor(e){super(e||"Aborted"),this.name="AbortError"}}class $v{constructor(){F(this,"documents");F(this,"driveManifests");F(this,"slugToDocumentId");this.documents={},this.driveManifests={},this.slugToDocumentId={}}resolveIds(e,n){const r=[];for(const s of e){const i=this.slugToDocumentId[s];if(!i)throw new Nt(s);r.push(i)}if(n!=null&&n.aborted)throw new gs("Aborted");return Promise.resolve(r)}resolveSlugs(e,n){const r=[];for(const s of e){const i=this.documents[s];if(!i)throw new Nt(s);r.push(i.header.slug)}if(n!=null&&n.aborted)throw new gs("Aborted");return Promise.resolve(r)}exists(e){return Promise.resolve(!!this.documents[e])}create(e){var s;const n=e.header.id;if(!as(n))throw new os(n);if(this.documents[n])throw new bn(n);const r=((s=e.header.slug)==null?void 0:s.length)>0?e.header.slug:n;if(!Ou(r))throw new Nu(r);if(r&&this.slugToDocumentId[r])throw new bn(n);if(e.header.slug=r,this.documents[n]=e,r){if(this.slugToDocumentId[r])throw new bn(n);this.slugToDocumentId[r]=n}return e.header.documentType==="powerhouse/document-drive"&&this.updateDriveManifest(n,{documentIds:new Set}),Promise.resolve()}get(e){const n=this.documents[e];return n?Promise.resolve(n):Promise.reject(new Nt(e))}getBySlug(e){const n=this.slugToDocumentId[e];return n?this.get(n):Promise.reject(new Nt(e))}async findByType(e,n=100,r){const s=Object.entries(this.documents).filter(([c,u])=>u.header.documentType===e).map(([c,u])=>({id:c,document:u}));s.sort((c,u)=>{const d=new Date(c.document.header.createdAtUtcIso),l=new Date(u.document.header.createdAtUtcIso);if(d.getTime()===l.getTime()){const f=c.id,h=u.id;return f.localeCompare(h)}return d.getTime()-l.getTime()});let i=0;if(r){const c=s.findIndex(({id:u})=>u===r);c!==-1&&(i=c)}const o=Math.min(i+n,s.length);let a;return o<s.length&&(a=s[o].id),{documents:s.slice(i,o).map(({id:c})=>c),nextCursor:a}}async delete(e){var s;const n=this.documents[e];if(n){const i=((s=n.header.slug)==null?void 0:s.length)>0?n.header.slug:e;i&&this.slugToDocumentId[i]===e&&delete this.slugToDocumentId[i]}const r=await this.getParents(e);for(const i of r)await this.removeChild(i,e);return delete this.driveManifests[e],this.documents[e]?(delete this.documents[e],Promise.resolve(!0)):Promise.resolve(!1)}async addChild(e,n){if(e===n)return Promise.reject(new Error("Cannot associate a document with itself"));if((await this.getChildren(n)).includes(e))return Promise.reject(new Error("Cannot associate a document with its child"));const s=this.getManifest(e);return s.documentIds.add(n),this.updateDriveManifest(e,s),Promise.resolve()}async removeChild(e,n){const r=this.getManifest(e);return r.documentIds.delete(n)?(this.updateDriveManifest(e,r),Promise.resolve(!0)):Promise.resolve(!1)}async getChildren(e){return[...this.getManifest(e).documentIds]}async getParents(e){const n=[];for(const[r,s]of Object.entries(this.driveManifests))s.documentIds.has(e)&&n.push(r);return n}async clear(){this.documents={},this.driveManifests={},this.slugToDocumentId={}}async addDocumentOperations(e,n,r){const s=await this.get(e);if(!r)return Promise.reject(new Nt(e));const i=ps(s.operations,n);this.documents[e]={...s,...r,operations:i}}async addDriveOperations(e,n,r){const s=await this.get(e),i=ps(s.operations,n);this.documents[e]={...s,...r,operations:i}}async getSynchronizationUnitsRevision(e){return(await Promise.allSettled(e.map(async r=>{var s;try{const i=await this.get(r.documentId);if(!i||!Object.keys(i.state).includes(r.scope))return;const o=i.operations[r.scope];return{documentId:r.documentId,documentType:r.documentType,scope:r.scope,branch:r.branch,lastUpdated:((s=o.at(-1))==null?void 0:s.timestamp)??i.header.createdAtUtcIso,revision:Mn(o)}}catch{return}}))).reduce((r,s)=>(s.status==="fulfilled"&&s.value!==void 0&&r.push(s.value),r),[])}async findStorageUnitsBy(e,n,r){const s=[],{parentId:i,documentId:o,documentModelType:a,scope:c}=Au(e);let u;if(i){const h=new Set;for(const m of i)(await this.getChildren(m)).forEach(D=>h.add(D));u=i.union(h)}else u=new Set(Object.keys(this.documents));u=o?o.intersection(u):u;for(const h of u){const m=this.documents[h];if(m&&!(a&&!a.has(m.header.documentType)))for(const[E]of Object.entries(m.state))c&&!c.has(E)||s.push({documentId:h,documentModelType:m.header.documentType,scope:E,branch:"main"})}let d=0;if(r){const h=s.findIndex(m=>m.documentId===r);h!==-1&&(d=h)}const l=Math.min(d+n,s.length),f=l<s.length?s[l].documentId:void 0;return{units:s.slice(d,l),nextCursor:f}}getManifest(e){return this.driveManifests[e]||(this.driveManifests[e]={documentIds:new Set}),this.driveManifests[e]}updateDriveManifest(e,n){this.driveManifests[e]=n}}class Fv{constructor(){F(this,"emitter",Yu())}emit(e,...n){return this.emitter.emit(e,...n)}on(e,n){return this.emitter.on(e,n)}}const Te=class Te{constructor(){F(this,"internalMap",new Map)}static escape(e){return e.replace(/\|/g,"\\|")}static unescape(e){return e.replace(/\\\|/g,"|")}static buildKey(e){return`${Te.escape(e.documentId)}${Te.keySeparator}${Te.escape(e.scope)}${Te.keySeparator}${Te.escape(e.branch)}`}static parseKey(e){const n=e.split(new RegExp("(?<!\\\\)\\|")).map(o=>Te.unescape(o)),[r,s,i]=n;return{documentId:r,scope:s,branch:i}}set(e,n){return this.internalMap.set(Te.buildKey(e),n),this}get(e){return this.internalMap.get(Te.buildKey(e))}has(e){return this.internalMap.has(Te.buildKey(e))}delete(e){return this.internalMap.delete(Te.buildKey(e))}clear(){this.internalMap.clear()}get size(){return this.internalMap.size}keys(e){const n=this.internalMap.keys();return{[Symbol.iterator](){return this},next(){for(;;){const r=n.next();if(r.done)return{done:!0,value:void 0};const s=r.value,i=Te.parseKey(s);if(!(e&&(i.documentId!==e.documentId||e.scope!==void 0&&i.scope!==e.scope)))return{done:!1,value:i}}}}}values(e){const n=this.internalMap.entries();return{[Symbol.iterator](){return this},next(){for(;;){const r=n.next();if(r.done)return{done:!0,value:void 0};const[s,i]=r.value,o=Te.parseKey(s);if(!(e&&(o.documentId!==e.documentId||e.scope!==void 0&&o.scope!==e.scope)))return{done:!1,value:i}}}}}entries(e){const n=this.internalMap.entries();return{[Symbol.iterator](){return this},next(){for(;;){const r=n.next();if(r.done)return{done:!0,value:void 0};const[s,i]=r.value,o=Te.parseKey(s);if(!(e&&(o.documentId!==e.documentId||e.scope!==void 0&&o.scope!==e.scope)))return{done:!1,value:[o,i]}}}}}[Symbol.iterator](){return this.entries()}forEach(e,n){for(const[r,s]of this.entries())e.call(n,s,r,this)}deleteByDocumentId(e){for(const n of this.internalMap.keys())n.startsWith(e+Te.keySeparator)&&this.internalMap.delete(n)}deleteByDocumentIdAndScope(e,n){const r=`${e}${Te.keySeparator}${n}${Te.keySeparator}`;for(const s of this.internalMap.keys())s.startsWith(r)&&this.internalMap.delete(s)}getAllByDocumentId(e){const n=[];for(const[r,s]of this.internalMap.entries())r.startsWith(e+Te.keySeparator)&&n.push([Te.parseKey(r),s]);return n}getAllByDocumentIdAndScope(e,n){const r=`${e}${Te.keySeparator}${n}${Te.keySeparator}`,s=[];for(const[i,o]of this.internalMap.entries())i.startsWith(r)&&s.push([Te.parseKey(i),o]);return s}};F(Te,"keySeparator","|");let ms=Te;function Uv(t,e=250){let n;return(r=!1,...s)=>(n&&clearTimeout(n),new Promise((i,o)=>{r?t(...s).then(i).catch(o):n=setTimeout(()=>{t(...s).then(i).catch(o)},e)}))}const Es=class Es{constructor(e,n=hs){F(this,"logger",wt(["ListenerManager",Math.floor(Math.random()*999).toString()]));F(this,"syncManager");F(this,"options");F(this,"generateJwtHandler");F(this,"listenerStateByDriveId",new Map);F(this,"triggerUpdate",Uv(this._triggerUpdate.bind(this),Es.LISTENER_UPDATE_DELAY));this.syncManager=e,this.options={...hs,...n},this.logger.verbose("constructor(...)")}setGenerateJwtHandler(e){this.generateJwtHandler=e}removeJwtHandler(){this.generateJwtHandler=void 0}async initialize(e){this.logger.verbose("initialize(...)"),typeof window<"u"&&window.addEventListener("online",()=>{this.triggerUpdate(!1,{type:"local"},void 0,e).catch(n=>{this.logger.error("Non handled error updating listeners",n)})})}driveHasListeners(e){return this.listenerStateByDriveId.has(e)}async setListener(e,n){if(this.logger.verbose(`setListener(drive: ${e}, listener: ${n.listenerId})`),e!==n.driveId)throw new Error("Drive ID mismatch");let r;try{r=this.getListenerState(e,n.listenerId)}catch{r={}}this.setListenerState(e,n.listenerId,{...r,block:n.block,driveId:n.driveId,pendingTimeout:"0",listener:n,listenerStatus:"CREATED",syncUnits:new ms}),await this.triggerUpdate(!0,{type:"local"})}async removeListener(e,n){this.logger.verbose("setListener()");const r=this.listenerStateByDriveId.get(e);return r?Promise.resolve(r.delete(n)):!1}async removeSyncUnits(e,n){const r=this.listenerStateByDriveId.get(e);if(r){for(const[,s]of r)for(const i of n)s.syncUnits.delete(i);return Promise.resolve()}}async updateSynchronizationRevisions(e,n,r,s,i=!1){const o=this.listenerStateByDriveId.values(),a=[];for(const[[c,u]]of o){if(a.find(l=>l.listenerId===u.listener.listenerId))continue;const d=u.listener.transmitter;if(d!=null&&d.transmit)for(const l of e){if(!this._checkFilter(u.listener.filter,l))continue;const f=u.syncUnits.get(l);if(!f||f.listenerRev<l.revision){a.push(u.listener);break}}}return this.triggerUpdate(i,n,r,s)}async updateListenerRevision(e,n,r,s){const i=this.listenerStateByDriveId.get(n);if(!i)return;const o=i.get(e);if(!o)return;const a=new Date().toISOString();return o.syncUnits.set(r,{listenerRev:s,lastUpdated:a}),Promise.resolve()}async _triggerUpdate(e,n,r,s=500){var o,a;if(this.logger.verbose(`_triggerUpdate(source: ${e.type}, maxContinues: ${s})`,this.listenerStateByDriveId),s<0)throw new Error("Maximum retries exhausted.");const i=[];for(const[c,u]of this.listenerStateByDriveId)for(const[d,l]of u){const f=l.listener.transmitter;if(!(f!=null&&f.transmit))continue;const h=await this.getListenerSyncUnits(c,d),m=[];this.logger.verbose("syncUnits",h);const E=h.map(D=>async()=>{const P=l.syncUnits.get(D);if(P&&P.listenerRev>=D.revision){this.logger.verbose(`Abandoning push for sync unit ${JSON.stringify(D)}: already up-to-date (${P.listenerRev} >= ${D.revision})`);return}else this.logger.verbose(`Listener out-of-date for sync unit (${D.scope}, ${D.documentId}): ${P==null?void 0:P.listenerRev} < ${D.revision}`);const B=[];if(D.revision>0){try{const R=await this.syncManager.getOperationData(D,{fromRevision:P==null?void 0:P.listenerRev});B.push(...R)}catch(R){this.logger.error(R)}if(!B.length){this.logger.verbose(`Abandoning push for ${JSON.stringify(D)}: no operations found`);return}}m.push({driveId:c,documentType:D.documentType,documentId:D.documentId,branch:D.branch,operations:B,scope:D.scope})});if(this.options.sequentialUpdates){this.logger.verbose(`Collecting ${E.length} syncUnit strandUpdates in sequence`);for(const D of E)await D()}else this.logger.verbose(`Collecting ${E.length} syncUnit strandUpdates in parallel`),await Promise.all(E.map(D=>D()));if(m.length==0){this.logger.verbose(`No strandUpdates needed for listener ${d}`);continue}l.pendingTimeout=new Date(new Date().getTime()/1e3+300).toISOString(),l.listenerStatus="PENDING";try{this.logger.verbose(`_triggerUpdate(source: ${e.type}) > transmitter.transmit`);const D=await f.transmit(m,e);this.logger.verbose(`_triggerUpdate(source: ${e.type}) > transmission succeeded`,D),l.pendingTimeout="0",l.listenerStatus="PENDING";const P=new Date().toISOString();let B=!1;for(const R of D){const Q=h.find(N=>R.documentId===N.documentId&&R.scope===N.scope&&R.branch===N.branch);if(Q){l.syncUnits.set(Q,{lastUpdated:P,listenerRev:R.revision});const N=m.find(X=>X.driveId===R.driveId&&X.documentId===R.documentId&&X.scope===R.scope&&X.branch===R.branch);if(N&&N.operations.length>0){const X=(o=N.operations.at(-1))==null?void 0:o.index;X!==R.revision?(this.logger.verbose(`Revision still out-of-date for ${N.documentId}:${N.scope}:${N.branch} ${X} <> ${R.revision}`),B=!0):this.logger.verbose(`Revision match for ${N.documentId}:${N.scope}:${N.branch} ${X}`)}}else this.logger.warn(`Received revision for untracked unit for listener ${l.listener.listenerId}`,R)}for(const R of D){const Q=R.status==="ERROR";if((a=R.error)!=null&&a.includes("Missing operations"))B=!0;else if(Q)throw new Ge(R.status,void 0,R.error,R.error)}if(!B)i.push({listenerId:l.listener.listenerId,listenerRevisions:D});else{const R=await this._triggerUpdate(e,n,r,s-1);i.push(...R)}l.listenerStatus="SUCCESS"}catch(D){r==null||r(D,c,l),l.listenerStatus=D instanceof Ge?D.status:"ERROR"}}return this.logger.verbose(`Returning listener updates (maxContinues: ${s})`,i),i}_checkFilter(e,n){const{branch:r,documentId:s,scope:i,documentType:o}=n;return!!((!e.branch||e.branch.includes(r)||e.branch.includes("*"))&&(!e.documentId||e.documentId.includes(s)||e.documentId.includes("*"))&&(!e.scope||e.scope.includes(i)||e.scope.includes("*"))&&(!e.documentType||e.documentType.includes(o)||e.documentType.includes("*")))}getListenerSyncUnits(e,n){var i;const r=(i=this.listenerStateByDriveId.get(e))==null?void 0:i.get(n);if(!r)return[];const s=r.listener.filter;return this.syncManager.getSynchronizationUnits(e,s.documentId??["*"],s.scope??["*"],s.branch??["*"],s.documentType??["*"])}async removeDrive(e){var r,s;const n=this.listenerStateByDriveId.get(e);if(n){this.listenerStateByDriveId.delete(e);for(const[i,o]of n)try{await((s=(r=o.listener.transmitter)==null?void 0:r.disconnect)==null?void 0:s.call(r))}catch(a){this.logger.error(a)}}}async getStrands(e,n,r){this.logger.verbose(`[SYNC DEBUG] ListenerManager.getStrands called for drive: ${e}, listener: ${n}, options: ${JSON.stringify(r||{})}`);let s;try{s=this.getListenerState(e,n),this.logger.verbose(`[SYNC DEBUG] Found listener state for drive: ${e}, listener: ${n}, status: ${s.listenerStatus}`)}catch(o){throw this.logger.error(`[SYNC DEBUG] Failed to find listener state for drive: ${e}, listener: ${n}. Error: ${o}`),o}const i=[];try{const o=await this.getListenerSyncUnits(e,n);this.logger.verbose(`[SYNC DEBUG] Retrieved ${o.length} sync units for drive: ${e}, listener: ${n}`);const a=r==null?void 0:r.limit;let c=0;const u=o.map(d=>async()=>{if(a&&c>=a)return;if(d.revision<0){this.logger.verbose(`[SYNC DEBUG] Skipping sync unit with negative revision: ${JSON.stringify(d)}, revision: ${d.revision}`);return}const l=s.syncUnits.get(d);if(l&&l.listenerRev>=d.revision){this.logger.verbose(`[SYNC DEBUG] Skipping sync unit - listener already up to date: ${JSON.stringify(d)}, listenerRev: ${l.listenerRev}, revision: ${d.revision}`);return}const{documentId:f,scope:h,branch:m}=d;let E=[];try{d.revision>0&&(this.logger.verbose(`[SYNC DEBUG] Getting operations for syncUnit: ${JSON.stringify(d)}`),E=await this.syncManager.getOperationData(d,{since:r==null?void 0:r.since,fromRevision:(r==null?void 0:r.fromRevision)??(l==null?void 0:l.listenerRev),limit:a?a-c:void 0})),this.logger.verbose(`[SYNC DEBUG] Retrieved ${E.length} operations for syncUnit: ${JSON.stringify(d)}`),c+=E.length,i.push({driveId:e,documentId:f,documentType:d.documentType,scope:h,branch:m,operations:E}),this.logger.verbose(`[SYNC DEBUG] Added strand with ${E.length} operations for syncUnit: ${JSON.stringify(d)}`)}catch(D){this.logger.error(`Error getting operations for syncUnit: ${JSON.stringify(d)}, error: ${D}`);return}});if(this.options.sequentialUpdates){this.logger.verbose(`[SYNC DEBUG] Processing ${u.length} sync units sequentially`);for(const d of u)await d()}else this.logger.verbose(`[SYNC DEBUG] Processing ${u.length} sync units in parallel`),await Promise.all(u.map(d=>d()))}catch(o){this.logger.error(`Error in getStrands: ${o}`)}return this.logger.verbose(`ListenerManager.getStrands returning ${i.length} strands for drive: ${e}, listener: ${n}`),i}getListenerState(e,n){let r=this.listenerStateByDriveId.get(e);r||(r=new Map,this.listenerStateByDriveId.set(e,r));const s=r.get(n);if(!s)throw new Error("Listener not found");return s}setListenerState(e,n,r){let s=this.listenerStateByDriveId.get(e);s||(s=new Map,this.listenerStateByDriveId.set(e,s)),s.set(n,r)}};F(Es,"LISTENER_UPDATE_DELAY",250);let qi=Es;class Bv{constructor(e){F(this,"listenerManager");this.listenerManager=e}instance(e,n,r){var s;switch(e){case"SwitchboardPush":{if(!((s=n.callInfo)!=null&&s.data))throw new Error("No call info data: "+JSON.stringify(n));return new Jl(n.callInfo.data,this.listenerManager)}case"Internal":throw new Error("Internal transmitter not implemented");default:return new He(n,this.listenerManager)}}}class jv{constructor(e,n,r,s,i){F(this,"storage");F(this,"documentStorage");F(this,"cache");F(this,"documentModelModules");F(this,"eventEmitter");F(this,"syncStatus",new ms);F(this,"logger",wt(["SynchronizationManager"]));this.storage=e,this.documentStorage=n,this.cache=r,this.documentModelModules=s,this.eventEmitter=i}async getSynchronizationUnits(e,n,r,s,i){const o=await this.getSynchronizationUnitsIds(e,n,r,s,i);return this.logger.verbose(`getSynchronizationUnits query: ${JSON.stringify(o)}`),(await this.getSynchronizationUnitsRevision(o)).filter(c=>typeof c<"u")}async getSynchronizationUnitsRevision(e){const n=await this.storage.getSynchronizationUnitsRevision(e);return this.logger.verbose(`getSynchronizationUnitsRevision: ${JSON.stringify(n)}`),e.map(r=>n.find(s=>s.documentId===r.documentId&&s.scope===r.scope&&s.branch===r.branch))}async getSynchronizationUnitsIds(e,n,r,s,i){const o={parentId:e?[e]:void 0,documentId:n,documentModelType:i,scope:r,branch:s};let a;const c=[];do{const{units:u,nextCursor:d}=await this.documentStorage.findStorageUnitsBy(o,100,a);c.push(...u),a=d}while(a);return c.reduce((u,{documentModelType:d,...l})=>l.scope==="local"?u:u.concat([{...l,documentType:d}]),new Array)}async getSynchronizationUnit(e){const{scope:n,branch:r,documentId:s}=e,i=await this.getDocument(s);if(!Object.keys(i.state).includes(n))return;const o=i.operations[n]??[],a=o.at(-1);return{scope:n,branch:r,documentId:s,documentType:i.header.documentType,lastUpdated:(a==null?void 0:a.timestamp)??i.header.lastModifiedAtUtcIso,revision:Mn(o)}}async getOperationData(e,n){this.logger.verbose(`[SYNC DEBUG] SynchronizationManager.getOperationData called for syncId: ${JSON.stringify(e)}, filter: ${JSON.stringify(n)}`);const r=await this.getDocument(e.documentId);this.logger.verbose(`[SYNC DEBUG] Retrieved document ${r.header.id} with type: ${r.header.documentType}`);const s=r.operations[e.scope]??[];this.logger.verbose(`[SYNC DEBUG] Found ${s.length} total operations in scope ${e.scope}`);const i=s.filter(a=>Object.keys(n).length===0||(n.since===void 0||Iv(n.since,a.timestamp))&&(n.fromRevision===void 0||a.index>=n.fromRevision));this.logger.verbose(`[SYNC DEBUG] Filtered to ${i.length} operations based on filter criteria`+(n.fromRevision!==void 0?` (fromRevision: ${n.fromRevision})`:""));const o=n.limit?i.slice(0,n.limit):i;if(this.logger.verbose(`[SYNC DEBUG] Returning ${o.length} operations after applying limit`),o.length>0){const a=o[0],c=o[o.length-1];this.logger.verbose(`[SYNC DEBUG] First operation: index=${a.index}, type=${a.type}`),this.logger.verbose(`[SYNC DEBUG] Last operation: index=${c.index}, type=${c.type}`)}return o.map(a=>{var c;return{hash:a.hash,index:a.index,timestamp:a.timestamp,type:a.type,input:a.input,skip:a.skip,context:(c=a.action)==null?void 0:c.context,id:a.id}})}async getDocument(e){try{const r=await this.cache.getDocument(e);if(r)return r}catch(r){this.logger.error("Error getting document from cache",r)}const n=await this.documentStorage.get(e);return this._buildDocument(n)}_buildDocument(e){const n=this.getDocumentModelModule(e.header.documentType),r=Gr(e.operations);return Uc(e.initialState,r,n.reducer,void 0,e.header,void 0,{checkHashes:!0,reuseOperationResultingState:!0})}setDocumentModelModules(e){this.documentModelModules=e}getDocumentModelModule(e){const n=this.documentModelModules.find(r=>r.documentModel.id===e);if(!n)throw new Error(`Document type ${e} not supported`);return n}getCombinedSyncUnitStatus(e){if(!e.pull&&!e.push||e.pull==="INITIAL_SYNC")return"INITIAL_SYNC";if(e.push==="INITIAL_SYNC")return e.pull||"INITIAL_SYNC";const n=["ERROR","MISSING","CONFLICT","SYNCING","SUCCESS"];return Object.values(e).sort((s,i)=>n.indexOf(s)-n.indexOf(i))[0]}getSyncStatus(e,n="global",r="main"){const s=typeof e=="string"?{documentId:e,scope:n,branch:r}:e,i=this.syncStatus.get(s);return i?this.getCombinedSyncUnitStatus(i):new Li(s)}updateSyncStatus(e,n,r,s="global",i="main"){const o=typeof e=="string"?{documentId:e,scope:s,branch:i}:e;if(n===null){this.syncStatus.delete(o);return}const a=this.syncStatus.get(o);if(!a){this.initSyncStatus(o,n);return}if(Object.entries(n).some(([u,d])=>a[u]!==d)){const u=Object.entries(n).reduce((f,[h,m])=>({...f,[h]:f[h]==="INITIAL_SYNC"&&m==="SYNCING"?"INITIAL_SYNC":m}),a),d=this.getCombinedSyncUnitStatus(a),l=this.getCombinedSyncUnitStatus(u);this.syncStatus.set(o,u),d!==l&&this.eventEmitter&&this.eventEmitter.emit("syncStatus",o.documentId,this.getCombinedSyncUnitStatus(u),r,u,o.scope,o.branch)}}initSyncStatus(e,n){const r=Object.entries(n).reduce((s,[i,o])=>({...s,[i]:o!=="SYNCING"?o:"INITIAL_SYNC"}),{});this.syncStatus.set(e,r),this.eventEmitter&&this.eventEmitter.emit("syncStatus",e.documentId,this.getCombinedSyncUnitStatus(r),void 0,r,e.scope,e.branch)}async initializeDriveSyncStatus(e,n){const r=await this.getSynchronizationUnitsIds(e),s={pull:n.state.local.triggers.length>0?"INITIAL_SYNC":void 0,push:n.state.local.listeners.length>0?"SUCCESS":void 0};if(!s.pull&&!s.push)return;const i=[{documentId:e,scope:"global",branch:"main"},...r];for(const o of i)this.initSyncStatus(o,s)}}class Vv{constructor(e){F(this,"documentModelModules",[]);F(this,"storage");F(this,"cache");F(this,"queueManager");F(this,"eventEmitter");F(this,"options");F(this,"synchronizationManager");F(this,"listenerManager");F(this,"transmitterFactory");this.documentModelModules=e}withStorage(e){return this.storage=e,this}withCache(e){return this.cache=e,this}withQueueManager(e){return this.queueManager=e,this}withEventEmitter(e){return this.eventEmitter=e,this}withSynchronizationManager(e){return this.synchronizationManager=e,this}withListenerManager(e){return this.listenerManager=e,this}withTransmitterFactory(e){return this.transmitterFactory=e,this}withOptions(e){return this.options=e,this}build(){var e;if(this.storage||(this.storage=new $v),this.cache||(this.cache=new lu),this.queueManager||(this.queueManager=new Ju),this.eventEmitter||(this.eventEmitter=new Fv),this.synchronizationManager||(this.synchronizationManager=new jv(this.storage,this.storage,this.cache,this.documentModelModules,this.eventEmitter)),!this.listenerManager){const n={...hs,...(e=this.options)==null?void 0:e.listenerManager};this.listenerManager=new qi(this.synchronizationManager,n)}return this.transmitterFactory||(this.transmitterFactory=new Bv(this.listenerManager)),new kv(this.documentModelModules,this.storage,this.storage,this.cache,this.queueManager,this.eventEmitter,this.synchronizationManager,this.listenerManager,this.options)}}var _s,Wl;class Gv{constructor(e,n,r){et(this,_s);F(this,"drive");F(this,"processor");F(this,"taskQueueMethod");F(this,"transmitQueue");this.drive=e,this.processor=n,this.taskQueueMethod=r===void 0?sn.runAsap:r}async transmit(e,n){var s;const r=async()=>{var o;const i=[];for(const a of e){const c=await ct(this,_s,Wl).call(this,a),u=await this.drive.getDocument(a.documentId),d=((o=c.at(-1))==null?void 0:o.state)??{};i.push({...a,documentType:u.header.documentType,operations:c,state:d})}try{return await this.processor.onStrands(i),e.map(({operations:a,...c})=>({...c,status:"SUCCESS",revision:Mn(a)}))}catch(a){return pe.error(a),e.map(({operations:c,...u})=>{var d;return{...u,status:"ERROR",revision:((d=c.at(0))==null?void 0:d.index)??0}})}};return this.transmitQueue=((s=this.transmitQueue)==null?void 0:s.then(()=>r()))??r(),this.transmitQueue}async disconnect(){await this.processor.onDisconnect()}}_s=new WeakSet,Wl=async function(e){const n=[],r=new Map,s=async i=>{const o=r.get(i);if(o)return o;const a={revisions:{[e.scope]:i},checkHashes:!1},c=await(e.documentId===e.driveId?this.drive.getDrive(e.driveId,a):this.drive.getDocument(e.documentId,a));return i<0?r.set(i,c.initialState.state[e.scope]):r.set(i,c.state[e.scope]),r.get(i)};for(const i of e.operations){const o=()=>s(i.index),a=await(this.taskQueueMethod?sn.runAsapAsync(o,this.taskQueueMethod):o()),c=()=>s(i.index-1),u=await(this.taskQueueMethod?sn.runAsapAsync(c,this.taskQueueMethod):c());n.push({...i,state:a,previousState:u})}return n};const zv=Sn.createState;let Qr;typeof window<"u"?window.btoa?Qr=function(t){return btoa(unescape(encodeURIComponent(t)))}:Qr=function(t){const e=unescape(encodeURIComponent(t+""));let n="";for(let r,s,i=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.charAt(i|0)||(o="=",i%1);n+=o.charAt(63&r>>8-i%1*8)){if(s=e.charCodeAt(i+=3/4),s>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|s}return n}:Qr=function(t){return Buffer.from(t).toString("base64")};function be(t,e){let n=ic(t,e);return(e&&e.fallback!==void 0?e.fallback:be.defaults.fallback)===!0&&n===""&&(n=ic(Qr(t),e)),n}const Ql={bg:{Й:"Y",й:"y",X:"H",x:"h",Ц:"Ts",ц:"ts",Щ:"Sht",щ:"sht",Ъ:"A",ъ:"a",Ь:"Y",ь:"y"},de:{Ä:"AE",ä:"ae",Ö:"OE",ö:"oe",Ü:"UE",ü:"ue"},sr:{đ:"dj",Đ:"DJ"},uk:{И:"Y",и:"y",Й:"Y",й:"y",Ц:"Ts",ц:"ts",Х:"Kh",х:"kh",Щ:"Shch",щ:"shch",Г:"H",г:"h"}};let No={};function ic(t,e){if(typeof t!="string")throw new Error("slug() requires a string argument, received "+typeof t);if(!t.isWellFormed())throw new Error("slug() received a malformed string with lone surrogates");typeof e=="string"&&(e={replacement:e}),e=e?Object.assign({},e):{},e.mode=e.mode||be.defaults.mode;const n=be.defaults.modes[e.mode],r=["replacement","multicharmap","charmap","remove","lower","trim"];for(let c,u=0,d=r.length;u<d;u++)c=r[u],e[c]=c in e?e[c]:n[c];const s=Ql[e.locale]||No;let i=[];for(const c in e.multicharmap){if(!Object.prototype.hasOwnProperty.call(e.multicharmap,c))continue;const u=c.length;i.indexOf(u)===-1&&i.push(u)}i=i.sort(function(c,u){return u-c});const o=e.mode==="rfc3986"?/[^\w\s\-.~]/:/[^A-Za-z0-9\s]/;let a="";for(let c,u=0,d=t.length;u<d;u++){c=t[u];let l=!1;for(let f=0;f<i.length;f++){const h=i[f],m=t.substr(u,h);if(e.multicharmap[m]){u+=h-1,c=e.multicharmap[m],l=!0;break}}l||(s[c]?c=s[c]:e.charmap[c]?c=e.charmap[c].replace(e.replacement," "):c.includes(e.replacement)?c=c.replace(e.replacement," "):c=c.replace(o,"")),a+=c}return e.remove&&(a=a.replace(e.remove,"")),e.trim&&(a=a.trim()),a=a.replace(/\s+/g,e.replacement),e.lower&&(a=a.toLowerCase()),a}const Kl={फ़:"Fi",ग़:"Ghi",ख़:"Khi",क़:"Qi",ड़:"ugDha",ढ़:"ugDhha",य़:"Yi",ज़:"Za",בִי:"i",בֵ:"e",בֵי:"e",בֶ:"e",בַ:"a",בָ:"a",בֹ:"o",וֹ:"o",בֻ:"u",וּ:"u",בּ:"b",כּ:"k",ךּ:"k",פּ:"p",שׁ:"sh",שׂ:"s",בְ:"e",חֱ:"e",חֲ:"a",חֳ:"o",בִ:"i"},Xl={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Æ:"AE",Ç:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ő:"O",Ø:"O",Ō:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ű:"U",Ý:"Y",Þ:"TH",ß:"ss",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",æ:"ae",ç:"c",è:"e",é:"e",ê:"e",ë:"e",ì:"i",í:"i",î:"i",ï:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ő:"o",ø:"o",ō:"o",Œ:"OE",œ:"oe",ù:"u",ú:"u",û:"u",ü:"u",ű:"u",ý:"y",þ:"th",ÿ:"y","ẞ":"SS",α:"a",β:"b",γ:"g",δ:"d",ε:"e",ζ:"z",η:"h",θ:"th",ι:"i",κ:"k",λ:"l",μ:"m",ν:"n",ξ:"3",ο:"o",π:"p",ρ:"r",σ:"s",τ:"t",υ:"y",φ:"f",χ:"x",ψ:"ps",ω:"w",ά:"a",έ:"e",ί:"i",ό:"o",ύ:"y",ή:"h",ώ:"w",ς:"s",ϊ:"i",ΰ:"y",ϋ:"y",ΐ:"i",Α:"A",Β:"B",Γ:"G",Δ:"D",Ε:"E",Ζ:"Z",Η:"H",Θ:"Th",Ι:"I",Κ:"K",Λ:"L",Μ:"M",Ν:"N",Ξ:"3",Ο:"O",Π:"P",Ρ:"R",Σ:"S",Τ:"T",Υ:"Y",Φ:"F",Χ:"X",Ψ:"PS",Ω:"W",Ά:"A",Έ:"E",Ί:"I",Ό:"O",Ύ:"Y",Ή:"H",Ώ:"W",Ϊ:"I",Ϋ:"Y",ş:"s",Ş:"S",ı:"i",İ:"I",ğ:"g",Ğ:"G",а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"yo",ж:"zh",з:"z",и:"i",й:"j",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"h",ц:"c",ч:"ch",ш:"sh",щ:"sh",ъ:"u",ы:"y",ь:"",э:"e",ю:"yu",я:"ya",А:"A",Б:"B",В:"V",Г:"G",Д:"D",Е:"E",Ё:"Yo",Ж:"Zh",З:"Z",И:"I",Й:"J",К:"K",Л:"L",М:"M",Н:"N",О:"O",П:"P",Р:"R",С:"S",Т:"T",У:"U",Ф:"F",Х:"H",Ц:"C",Ч:"Ch",Ш:"Sh",Щ:"Sh",Ъ:"U",Ы:"Y",Ь:"",Э:"E",Ю:"Yu",Я:"Ya",Є:"Ye",І:"I",Ї:"Yi",Ґ:"G",є:"ye",і:"i",ї:"yi",ґ:"g",č:"c",ď:"d",ě:"e",ň:"n",ř:"r",š:"s",ť:"t",ů:"u",ž:"z",Č:"C",Ď:"D",Ě:"E",Ň:"N",Ř:"R",Š:"S",Ť:"T",Ů:"U",Ž:"Z",ľ:"l",ĺ:"l",ŕ:"r",Ľ:"L",Ĺ:"L",Ŕ:"R",ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ś:"s",ź:"z",ż:"z",Ą:"A",Ć:"C",Ę:"E",Ł:"L",Ń:"N",Ś:"S",Ź:"Z",Ż:"Z",ā:"a",ē:"e",ģ:"g",ī:"i",ķ:"k",ļ:"l",ņ:"n",ū:"u",Ā:"A",Ē:"E",Ģ:"G",Ī:"I",Ķ:"K",Ļ:"L",Ņ:"N",Ū:"U",أ:"a",إ:"i",ب:"b",ت:"t",ث:"th",ج:"g",ح:"h",خ:"kh",د:"d",ذ:"th",ر:"r",ز:"z",س:"s",ش:"sh",ص:"s",ض:"d",ط:"t",ظ:"th",ع:"aa",غ:"gh",ف:"f",ق:"k",ك:"k",ل:"l",م:"m",ن:"n",ه:"h",و:"o",ي:"y",ء:"aa",ة:"a",آ:"a",ا:"a",پ:"p",ژ:"zh",گ:"g",چ:"ch",ک:"k",ی:"i",ė:"e",į:"i",ų:"u",Ė:"E",Į:"I",Ų:"U",ț:"t",Ț:"T",ţ:"t",Ţ:"T",ș:"s",Ș:"S",ă:"a",Ă:"A",Ạ:"A",Ả:"A",Ầ:"A",Ấ:"A",Ậ:"A",Ẩ:"A",Ẫ:"A",Ằ:"A",Ắ:"A",Ặ:"A",Ẳ:"A",Ẵ:"A",Ẹ:"E",Ẻ:"E",Ẽ:"E",Ề:"E",Ế:"E",Ệ:"E",Ể:"E",Ễ:"E",Ị:"I",Ỉ:"I",Ĩ:"I",Ọ:"O",Ỏ:"O",Ồ:"O",Ố:"O",Ộ:"O",Ổ:"O",Ỗ:"O",Ơ:"O",Ờ:"O",Ớ:"O",Ợ:"O",Ở:"O",Ỡ:"O",Ụ:"U",Ủ:"U",Ũ:"U",Ư:"U",Ừ:"U",Ứ:"U",Ự:"U",Ử:"U",Ữ:"U",Ỳ:"Y",Ỵ:"Y",Ỷ:"Y",Ỹ:"Y",Đ:"D",ạ:"a",ả:"a",ầ:"a",ấ:"a",ậ:"a",ẩ:"a",ẫ:"a",ằ:"a",ắ:"a",ặ:"a",ẳ:"a",ẵ:"a",ẹ:"e",ẻ:"e",ẽ:"e",ề:"e",ế:"e",ệ:"e",ể:"e",ễ:"e",ị:"i",ỉ:"i",ĩ:"i",ọ:"o",ỏ:"o",ồ:"o",ố:"o",ộ:"o",ổ:"o",ỗ:"o",ơ:"o",ờ:"o",ớ:"o",ợ:"o",ở:"o",ỡ:"o",ụ:"u",ủ:"u",ũ:"u",ư:"u",ừ:"u",ứ:"u",ự:"u",ử:"u",ữ:"u",ỳ:"y",ỵ:"y",ỷ:"y",ỹ:"y",đ:"d",Ә:"AE",ә:"ae",Ғ:"GH",ғ:"gh",Қ:"KH",қ:"kh",Ң:"NG",ң:"ng",Ү:"UE",ү:"ue",Ұ:"U",ұ:"u",Һ:"H",һ:"h",Ө:"OE",ө:"oe",ђ:"dj",ј:"j",љ:"lj",њ:"nj",ћ:"c",џ:"dz",Ђ:"Dj",Ј:"j",Љ:"Lj",Њ:"Nj",Ћ:"C",Џ:"Dz",nj:"nj",lj:"lj",Nj:"NJ",Lj:"LJ",अ:"a",आ:"aa",ए:"e",ई:"ii",ऍ:"ei",ऎ:"ae",ऐ:"ai",इ:"i",ओ:"o",ऑ:"oi",ऒ:"oii",ऊ:"uu",औ:"ou",उ:"u",ब:"B",भ:"Bha",च:"Ca",छ:"Chha",ड:"Da",ढ:"Dha",फ:"Fa",ग:"Ga",घ:"Gha",ग़:"Ghi",ह:"Ha",ज:"Ja",झ:"Jha",क:"Ka",ख:"Kha",ख़:"Khi",ल:"L",ळ:"Li",ऌ:"Li",ऴ:"Lii",ॡ:"Lii",म:"Ma",न:"Na",ङ:"Na",ञ:"Nia",ण:"Nae",ऩ:"Ni",ॐ:"oms",प:"Pa",क़:"Qi",र:"Ra",ऋ:"Ri",ॠ:"Ri",ऱ:"Ri",स:"Sa",श:"Sha",ष:"Shha",ट:"Ta",त:"Ta",ठ:"Tha",द:"Tha",थ:"Tha",ध:"Thha",ड़:"ugDha",ढ़:"ugDhha",व:"Va",य:"Ya",य़:"Yi",ज़:"Za",ə:"e",Ə:"E",ა:"a",ბ:"b",გ:"g",დ:"d",ე:"e",ვ:"v",ზ:"z",თ:"t",ი:"i",კ:"k",ლ:"l",მ:"m",ნ:"n",ო:"o",პ:"p",ჟ:"zh",რ:"r",ს:"s",ტ:"t",უ:"u",ფ:"p",ქ:"k",ღ:"gh",ყ:"q",შ:"sh",ჩ:"ch",ც:"ts",ძ:"dz",წ:"ts",ჭ:"ch",ხ:"kh",ჯ:"j",ჰ:"h",ב:"v",גּ:"g",ג:"g",ד:"d",דּ:"d",ה:"h",ו:"v",ז:"z",ח:"h",ט:"t",י:"y",כ:"kh",ך:"kh",ל:"l",מ:"m",ם:"m",נ:"n",ן:"n",ס:"s",פ:"f",ף:"f",ץ:"ts",צ:"ts",ק:"k",ר:"r",תּ:"t",ת:"t"};be.charmap=Object.assign({},Xl);be.multicharmap=Object.assign({},Kl);be.defaults={charmap:be.charmap,mode:"pretty",modes:{rfc3986:{replacement:"-",remove:null,lower:!0,charmap:be.charmap,multicharmap:be.multicharmap,trim:!0},pretty:{replacement:"-",remove:null,lower:!0,charmap:be.charmap,multicharmap:be.multicharmap,trim:!0}},multicharmap:be.multicharmap,fallback:!0};be.reset=function(){be.defaults.modes.rfc3986.charmap=be.defaults.modes.pretty.charmap=be.charmap=be.defaults.charmap=Object.assign({},Xl),be.defaults.modes.rfc3986.multicharmap=be.defaults.modes.pretty.multicharmap=be.multicharmap=be.defaults.multicharmap=Object.assign({},Kl),No=""};be.extend=function(t){const e=Object.keys(t),n={},r={};for(let s=0;s<e.length;s++)e[s].length>1?n[e[s]]=t[e[s]]:r[e[s]]=t[e[s]];Object.assign(be.charmap,r),Object.assign(be.multicharmap,n)};be.setLocale=function(t){No=Ql[t]||{}};function qv(t){return t?`/d/${be(t.header.slug)}`:""}function Yv(t){if(!t)return"";const e=t.name;return be(e?`${e}-${t.id}`:t.id)}function Hv(t){const e=/^\/d\/[^/]+\/([^/]+)$/.exec(t);return e?e[1]:void 0}function Jv(t){if(!t)return;const n=/\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(t);return n?n[0]:void 0}function Wv(t){const e=Hv(t),n=Jv(e);return n||e}function Zl(t){const e=/^\/d\/([^/]+)/.exec(t);return e?e[1]:null}function Qv(t){return t.replaceAll(/\s/g,"-")}function Kv(t){const e=new CustomEvent("ph:setDrive",{detail:{driveId:t}});window.dispatchEvent(e)}function Xv(t,e){const n=t.detail.driveId;if(e(n),typeof window>"u")return;if(!n){window.history.pushState(null,"","/");return}const r=window.reactor;r&&r.getDrive(n).then(s=>{const i=qv(s);window.history.pushState(null,"",i)}).catch(s=>pe.error(s))}function Db(t){const e=new CustomEvent("ph:setNode",{detail:{nodeId:t}});window.dispatchEvent(e)}function Zv(t,e){const n=t.detail.nodeId;if(e(n),typeof window>"u")return;const r=window.reactor;if(!r)return;const s=Zl(window.location.pathname);if(s){if(!n){window.history.pushState(null,"",`/d/${s}`);return}r.getDriveBySlug(s).then(i=>{const a=i.state.global.nodes.find(u=>u.id===n),c=Yv(a);window.history.pushState(null,"",`/d/${s}/${c}`)}).catch(i=>pe.error(i))}}function Tr(){return At(iu)}function Rs(t){const e=Tr();if(t)return e==null?void 0:e.find(n=>n.header.id===t)}function ed(){return At(au)}function Nb(){return At(ou)}function Ob(){return ae(t=>{Kv(t)},[])}function td(){const t=ed();return t==null?void 0:t.header.id}function eE(t){const e=Rs(t),n=tE(t);if(e){if("remoteUrl"in e.state.global){const r=e.state.global.remoteUrl;if(typeof r=="string")return r}return n}}function nd(t){const e=Rs(t);return e==null?void 0:e.state.local.triggers.find(r=>r.type==="PullResponder")}function tE(t){var n;const e=nd(t);return(n=e==null?void 0:e.data)==null?void 0:n.url}function Ab(t){const e=eE(t),n=nd(t);return e!==void 0||n!==void 0}function Rb(t){const e=Rs(t);if(e)return Ci(e)}function Cb(t){const e=Rs(t);return e?Xh(e):!1}function Pn(){return window.reactor}const Oo={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},rd={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},sd=new globalThis.TextEncoder;function nE(t,e){const n=Oo[e];let r=rd[e];for(let s=0;s<t.length;s++)r^=BigInt(t[s]),r=BigInt.asUintN(e,r*n);return r}function rE(t,e,n){if(n.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");const r=Oo[e];let s=rd[e],i=t;for(;i.length>0;){const o=sd.encodeInto(i,n);i=i.slice(o.read);for(let a=0;a<o.written;a++)s^=BigInt(n[a]),s=BigInt.asUintN(e,s*r)}return s}function sE(t,{size:e=32,utf8Buffer:n}={}){if(!Oo[e])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof t=="string"){if(n)return rE(t,e,n);t=sd.encode(t)}return nE(t,e)}const iE=[32,64,128,256,512,1024],oE=Math.log2(26);function id(t,e=10,n="fnv1a"){if(n==="fnv1a"){const r=Math.ceil(e*oE),s=iE.find(o=>o&&o>=r)??1024,i=sE(t,{size:s});return aE(i,e)}else throw new Error(`Unsupported hashing algorithm: ${n}`)}function aE(t,e=10){const n="abcdefghijklmnopqrstuvwxyz";let r="";for(;t>0n&&r.length<e;)r=n[Number(t%26n)]+r,t/=26n;return r.padStart(e,"a")}function Lb(t,e){const n=t;return n.createNamespace=(r,s)=>cE(t,r,s??e),n.queryNamespace=(r,s)=>uE(t,r,s??e),n}async function cE(t,e,n){const s=(n==null?void 0:n.hashNamespace)??!0?id(e):e;return await t.schema.createSchema(s).ifNotExists().execute(),t.withSchema(s)}function uE(t,e,n){const s=(n==null?void 0:n.hashNamespace)??!0?id(e):e,i=t.withSchema(s);return Ao(i)}function Ao(t){return{selectFrom:t.selectFrom.bind(t),selectNoFrom:t.selectNoFrom.bind(t),with:t.with.bind(t),withRecursive:t.withRecursive.bind(t),withSchema:e=>Ao(t.withSchema(e))}}function oc(t){return od.is(t)}const ac=Symbol.for("ph.IS_RELATIONAL_DB_PROCESSOR");var Mc;Mc=ac;class od{constructor(e,n,r){F(this,"_namespace");F(this,"_filter");F(this,"relationalDb");this._namespace=e,this._filter=n,this.relationalDb=r}static is(e){var r;let n=Object.getPrototypeOf(e);for(;n;){if((r=n.constructor)!=null&&r[ac])return!0;n=Object.getPrototypeOf(n)}return!1}static getNamespace(e){return`${this.name}_${e.replaceAll("-","_")}`}static query(e,n){return n.queryNamespace(this.getNamespace(e))}get filter(){return this._filter}get namespace(){return this._namespace}get query(){return Ao(this.relationalDb)}}F(od,Mc,!0);class lE{constructor(e,n){F(this,"listeners");F(this,"drive");F(this,"logger",wt(["document-drive","processor-manager"]));F(this,"processorsByDrive",new Map);F(this,"idToFactory",new Map);F(this,"identifierToListeners",new Map);this.listeners=e,this.drive=n}async registerFactory(e,n){this.logger.debug(`Registering factory '${e}'.`),this.idToFactory.set(e,n);const r=await this.drive.getDrives();for(const s of r)await this.createProcessors(s,e,n)}async unregisterFactory(e){var r;const n=this.identifierToListeners.get(e)??[];for(const s of n)await this.listeners.removeListener(s.driveId,s.listenerId).catch(this.logger.error),(r=s.transmitter)!=null&&r.disconnect&&await s.transmitter.disconnect();this.identifierToListeners.set(e,[])}async registerDrive(e){this.logger.debug(`Registering drive '${e}'.`);for(const[n,r]of this.idToFactory)await this.createProcessors(e,n,r)}async createProcessors(e,n,r){let s=this.identifierToListeners.get(n);s||(s=[],this.identifierToListeners.set(n,s));let i=this.processorsByDrive.get(e);i||(i=[],this.processorsByDrive.set(e,i));let o=[];try{o=await r(e)}catch(a){this.logger.error(`Error creating processors for drive ${e}:`,a);return}for(const{filter:a,processor:c}of o){const u=oc(c);if(u&&i.some(f=>oc(f.processor)&&f.processor.namespace===c.namespace)){this.logger.warn(`Processor with namespace '${c.namespace}' already registered for drive '${e}'.`);continue}u&&await c.initAndUpgrade();const d=Et(),l={driveId:e,listenerId:d,block:!1,system:!1,filter:a,callInfo:void 0,transmitter:new Gv(this.drive,c)};await this.listeners.setListener(e,l),s.push(l),i.push({filter:a,processor:c})}}}function dE(){const t=Pn(),e=At(ru),n=cn(Ts);Ce(()=>{if(e||!t)return;const r=new lE(t.listeners,t);t.on("driveAdded",async s=>{await r.registerDrive(s.header.id)}),n(r)},[e,t,n])}function ad(){return cn(_r)}function fE(){const t=td(),e=ad();return ae(()=>{e(t).catch(n=>pe.error(n))},[e,t])}function cd(){return cn(yr)}function pE(){const t=cd();return ae(()=>{t().catch(e=>pe.error(e))},[t])}function hE(t){const[e,n]=Rn(!!window.reactor),r=At(su),s=At(so),i=td(),o=At(uu),a=cd(),c=ad();Ce(()=>{if(e)return;async function u(){const d=await(t==null?void 0:t());window.reactor=d,n(!0)}u().catch(pe.error)},[t,e]),Ce(()=>{if(!e||r)return;async function u(){await a()}u().catch(pe.error)},[e,a,r]),Ce(()=>{if(!e||!s||o)return;async function u(){await c(i)}u().catch(pe.error)},[e,o,s,i,c])}function gE(){const t=cn(Ln),e=cn(Er),n=ae(s=>{Xv(s,t)},[t]),r=ae(s=>{Zv(s,e)},[e]);Ce(()=>{if(!(typeof window>"u"))return window.addEventListener("ph:setDrive",n),()=>{window.removeEventListener("ph:setDrive",n)}},[n]),Ce(()=>{if(!(typeof window>"u"))return window.addEventListener("ph:setNode",r),()=>{window.removeEventListener("ph:setNode",r)}},[r])}function mE(){const t=pE(),e=fE(),n=Pn();Ce(()=>{if(!n)return;const r=[n.on("syncStatus",(...s)=>{pe.verbose("syncStatus",...s),t(),e()}),n.on("strandUpdate",(...s)=>{pe.verbose("strandUpdate",...s),t(),e()}),n.on("defaultRemoteDrive",(...s)=>{pe.verbose("defaultRemoteDrive",...s),t(),e()}),n.on("clientStrandsError",(...s)=>{pe.verbose("clientStrandsError",...s),t(),e()}),n.on("driveAdded",(...s)=>{pe.verbose("driveAdded",...s),t(),e()}),n.on("driveDeleted",(...s)=>{pe.verbose("driveDeleted",...s),t(),e()}),n.on("documentModelModules",(...s)=>{pe.verbose("documentModelModules",...s),t(),e()}),n.on("documentOperationsAdded",(...s)=>{pe.verbose("documentOperationsAdded",...s),t(),e()}),n.on("driveOperationsAdded",(...s)=>{console.log("driveOperationsAdded",...s),pe.verbose("driveOperationsAdded",...s),t(),e()}),n.on("operationsAdded",(...s)=>{console.log("operationsAdded",...s),pe.verbose("operationsAdded",...s),t(),e()})];return()=>{r.forEach(s=>s())}},[t,e,n])}function yE(){const t=cn(Ln),e=cn(Er),n=At(so),r=At(cu),s=Pn();Ce(()=>{async function i(){if(typeof window>"u"||!s||n)return;const o=window.location.pathname,a=await vE(s,o,t);a&&(r||EE(a,o,e))}i().catch(pe.error)},[s,n,r,t,e])}async function vE(t,e,n){const r=Zl(e),s=await t.getDrives(),o=(await Promise.all(s.map(a=>t.getDrive(a)))).find(a=>a.header.slug===r||a.header.id===r);return n(o==null?void 0:o.header.id),o}function EE(t,e,n){const r=Wv(e),s=t==null?void 0:t.state.global.nodes,i=s==null?void 0:s.find(o=>o.id===r||Qv(o.name)===r);n(i==null?void 0:i.id)}function _E(t){hE(t),mE(),gE(),dE(),yE()}const Qn=wt(["utils/document-model",Math.floor(Math.random()*999).toString()]),wE=parseInt(window.__VITE_ENVS.FILE_UPLOAD_OPERATIONS_CHUNK_SIZE||"50");function xb(t,e,n=Qn.error){const[r,s]=Rn(e),[i,o]=Rn(),a=u=>{o(u),n(u)};return Ce(()=>{s(e),o(void 0)},[e]),[r,(u,d,l)=>{o(void 0),s(f=>{if(!t||!f)return f;try{const h=t(f,u),m=u.scope??"global",E=h.operations[m],D=E[E.length-1];if(D.error){const P=new Error(D.error);a(P),l==null||l(P)}return d==null||d(D,{prevState:{...f},newState:{...h}}),h}catch(h){return a(h),l==null||l(h),f}})},i]}async function bE(t,e,n,r){const s=(r==null?void 0:r.operationsLimit)||wE;Qn.verbose(`uploadDocumentOperations(documentId:${t}, ops: ${Object.keys(e.operations).join(",")}, limit:${s})`);for(const i of Object.values(e.operations))for(let o=0;o<i.length;o+=s){Qn.verbose(`uploadDocumentOperations:for(i:${o}, ops:${i.length}, limit:${s}): START`);const a=i.slice(o,o+s),c=a.at(-1);if(!c)break;const{scope:u}=c;await n(t,a),Qn.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}:${u} rev ${c.index}): NEXT`)}Qn.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}): END`)}const SE=async t=>{op(t).generateAsync({type:"blob"}).then(n=>{const r=window.document.createElement("a");r.style.display="none",r.href=URL.createObjectURL(n),r.download=`${t.header.name||"Untitled"}.zip`,window.document.body.appendChild(r),r.click(),window.document.body.removeChild(r)}).catch(pe.error)};async function Mb(t,e){var s,i;const n=e(t.header.documentType);if(!n)throw new Error(`Document model not supported: ${t.header.documentType}`);const r=n.documentModel.extension;if(!window.showSaveFilePicker){await SE(t);return}try{const o=await window.showSaveFilePicker({suggestedName:`${t.name||((s=t.state.global)==null?void 0:s.name)||"Untitled"}.${r?`${r}.`:""}zip`});await $c(t,o);const a=(await o.getFile()).path;return typeof window<"u"&&((i=window.electronAPI)==null||i.fileSaved(t,a)),a}catch(o){if(!(o instanceof DOMException&&o.name==="AbortError"))throw o}}async function TE(t,e){const n=await kc(t,s=>s,{checkHashes:!0}),r=e(n.header.documentType);if(!r)throw new Error(`Document "${n.header.documentType}" is not supported`);return r.utils.loadFromInput(t)}function cc(t){let e=!1;const n=Object.entries(t.operations).reduce((r,[s,i])=>{const o=s;for(const a of i){const c=IE(a);r[o].push(c),c!==a&&(e=!0)}return r},{global:[],local:[]});return e?{...t,operations:n}:t}function IE(t){var i,o,a;let e=!1,n={...t};const r=(i=t.context)==null?void 0:i.signer,s=(a=(o=t.action)==null?void 0:o.context)==null?void 0:a.signer;if(r){if("signature"in r){const c=r.signature;n={...n,context:{...n.context,signer:{user:r.user,app:r.app,signatures:c!=null&&c.length?[c]:[]}}},e=!0}else if(r.signatures){const c=r.signatures.filter(u=>u&&u.length>0);c.length!==r.signatures.length&&(n={...n,context:{...n.context,signer:{...r,signatures:c}}},e=!0)}}if(s){if("signature"in s){const c=s.signature,u={...n.action.context,signer:{user:s.user,app:s.app,signatures:c!=null&&c.length?[c]:[]}};n={...n,action:{...n.action,context:u},context:u},e=!0}else if(s.signatures){const c=s.signatures.filter(u=>u&&u.length>0);if(c.length!==s.signatures.length){const u={...n.action.context,signer:{...s,signatures:c}};n={...n,action:{...n.action,context:u},context:u},e=!0}}}return e?n:t}var vi={exports:{}};/*!
|
|
359
|
-
localForage -- Offline Storage, Improved
|
|
360
|
-
Version 1.10.0
|
|
361
|
-
https://localforage.github.io/localForage
|
|
362
|
-
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
363
|
-
*/var uc;function DE(){return uc||(uc=1,function(t,e){(function(n){t.exports=n()})(function(){return function n(r,s,i){function o(u,d){if(!s[u]){if(!r[u]){var l=typeof Cr=="function"&&Cr;if(!d&&l)return l(u,!0);if(a)return a(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var h=s[u]={exports:{}};r[u][0].call(h.exports,function(m){var E=r[u][1][m];return o(E||m)},h,h.exports,n,r,s,i)}return s[u].exports}for(var a=typeof Cr=="function"&&Cr,c=0;c<i.length;c++)o(i[c]);return o}({1:[function(n,r,s){(function(i){var o=i.MutationObserver||i.WebKitMutationObserver,a;if(o){var c=0,u=new o(m),d=i.document.createTextNode("");u.observe(d,{characterData:!0}),a=function(){d.data=c=++c%2}}else if(!i.setImmediate&&typeof i.MessageChannel<"u"){var l=new i.MessageChannel;l.port1.onmessage=m,a=function(){l.port2.postMessage(0)}}else"document"in i&&"onreadystatechange"in i.document.createElement("script")?a=function(){var D=i.document.createElement("script");D.onreadystatechange=function(){m(),D.onreadystatechange=null,D.parentNode.removeChild(D),D=null},i.document.documentElement.appendChild(D)}:a=function(){setTimeout(m,0)};var f,h=[];function m(){f=!0;for(var D,P,B=h.length;B;){for(P=h,h=[],D=-1;++D<B;)P[D]();B=h.length}f=!1}r.exports=E;function E(D){h.push(D)===1&&!f&&a()}}).call(this,typeof Ft<"u"?Ft:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,r,s){var i=n(1);function o(){}var a={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];r.exports=l;function l(N){if(typeof N!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,N!==o&&E(this,N)}l.prototype.catch=function(N){return this.then(null,N)},l.prototype.then=function(N,X){if(typeof N!="function"&&this.state===u||typeof X!="function"&&this.state===c)return this;var w=new this.constructor(o);if(this.state!==d){var $=this.state===u?N:X;h(w,$,this.outcome)}else this.queue.push(new f(w,N,X));return w};function f(N,X,w){this.promise=N,typeof X=="function"&&(this.onFulfilled=X,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}f.prototype.callFulfilled=function(N){a.resolve(this.promise,N)},f.prototype.otherCallFulfilled=function(N){h(this.promise,this.onFulfilled,N)},f.prototype.callRejected=function(N){a.reject(this.promise,N)},f.prototype.otherCallRejected=function(N){h(this.promise,this.onRejected,N)};function h(N,X,w){i(function(){var $;try{$=X(w)}catch(A){return a.reject(N,A)}$===N?a.reject(N,new TypeError("Cannot resolve promise with itself")):a.resolve(N,$)})}a.resolve=function(N,X){var w=D(m,X);if(w.status==="error")return a.reject(N,w.value);var $=w.value;if($)E(N,$);else{N.state=u,N.outcome=X;for(var A=-1,C=N.queue.length;++A<C;)N.queue[A].callFulfilled(X)}return N},a.reject=function(N,X){N.state=c,N.outcome=X;for(var w=-1,$=N.queue.length;++w<$;)N.queue[w].callRejected(X);return N};function m(N){var X=N&&N.then;if(N&&(typeof N=="object"||typeof N=="function")&&typeof X=="function")return function(){X.apply(N,arguments)}}function E(N,X){var w=!1;function $(O){w||(w=!0,a.reject(N,O))}function A(O){w||(w=!0,a.resolve(N,O))}function C(){X(A,$)}var L=D(C);L.status==="error"&&$(L.value)}function D(N,X){var w={};try{w.value=N(X),w.status="success"}catch($){w.status="error",w.value=$}return w}l.resolve=P;function P(N){return N instanceof this?N:a.resolve(new this(o),N)}l.reject=B;function B(N){var X=new this(o);return a.reject(X,N)}l.all=R;function R(N){var X=this;if(Object.prototype.toString.call(N)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=N.length,$=!1;if(!w)return this.resolve([]);for(var A=new Array(w),C=0,L=-1,O=new this(o);++L<w;)re(N[L],L);return O;function re(ie,I){X.resolve(ie).then(k,function(Y){$||($=!0,a.reject(O,Y))});function k(Y){A[I]=Y,++C===w&&!$&&($=!0,a.resolve(O,A))}}}l.race=Q;function Q(N){var X=this;if(Object.prototype.toString.call(N)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=N.length,$=!1;if(!w)return this.resolve([]);for(var A=-1,C=new this(o);++A<w;)L(N[A]);return C;function L(O){X.resolve(O).then(function(re){$||($=!0,a.resolve(C,re))},function(re){$||($=!0,a.reject(C,re))})}}},{1:1}],3:[function(n,r,s){(function(i){typeof i.Promise!="function"&&(i.Promise=n(2))}).call(this,typeof Ft<"u"?Ft:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,r,s){var i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function o(p,v){if(!(p instanceof v))throw new TypeError("Cannot call a class as a function")}function a(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var c=a();function u(){try{if(!c||!c.open)return!1;var p=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),v=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||v)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function d(p,v){p=p||[],v=v||{};try{return new Blob(p,v)}catch(_){if(_.name!=="TypeError")throw _;for(var g=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,b=new g,T=0;T<p.length;T+=1)b.append(p[T]);return b.getBlob(v.type)}}typeof Promise>"u"&&n(3);var l=Promise;function f(p,v){v&&p.then(function(g){v(null,g)},function(g){v(g)})}function h(p,v,g){typeof v=="function"&&p.then(v),typeof g=="function"&&p.catch(g)}function m(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function E(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var D="local-forage-detect-blob-support",P=void 0,B={},R=Object.prototype.toString,Q="readonly",N="readwrite";function X(p){for(var v=p.length,g=new ArrayBuffer(v),b=new Uint8Array(g),T=0;T<v;T++)b[T]=p.charCodeAt(T);return g}function w(p){return new l(function(v){var g=p.transaction(D,N),b=d([""]);g.objectStore(D).put(b,"key"),g.onabort=function(T){T.preventDefault(),T.stopPropagation(),v(!1)},g.oncomplete=function(){var T=navigator.userAgent.match(/Chrome\/(\d+)/),_=navigator.userAgent.match(/Edge\//);v(_||!T||parseInt(T[1],10)>=43)}}).catch(function(){return!1})}function $(p){return typeof P=="boolean"?l.resolve(P):w(p).then(function(v){return P=v,P})}function A(p){var v=B[p.name],g={};g.promise=new l(function(b,T){g.resolve=b,g.reject=T}),v.deferredOperations.push(g),v.dbReady?v.dbReady=v.dbReady.then(function(){return g.promise}):v.dbReady=g.promise}function C(p){var v=B[p.name],g=v.deferredOperations.pop();if(g)return g.resolve(),g.promise}function L(p,v){var g=B[p.name],b=g.deferredOperations.pop();if(b)return b.reject(v),b.promise}function O(p,v){return new l(function(g,b){if(B[p.name]=B[p.name]||S(),p.db)if(v)A(p),p.db.close();else return g(p.db);var T=[p.name];v&&T.push(p.version);var _=c.open.apply(c,T);v&&(_.onupgradeneeded=function(x){var G=_.result;try{G.createObjectStore(p.storeName),x.oldVersion<=1&&G.createObjectStore(D)}catch(H){if(H.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+x.oldVersion+" to version "+x.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw H}}),_.onerror=function(x){x.preventDefault(),b(_.error)},_.onsuccess=function(){var x=_.result;x.onversionchange=function(G){G.target.close()},g(x),C(p)}})}function re(p){return O(p,!1)}function ie(p){return O(p,!0)}function I(p,v){if(!p.db)return!0;var g=!p.db.objectStoreNames.contains(p.storeName),b=p.version<p.db.version,T=p.version>p.db.version;if(b&&(p.version!==v&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),T||g){if(g){var _=p.db.version+1;_>p.version&&(p.version=_)}return!0}return!1}function k(p){return new l(function(v,g){var b=new FileReader;b.onerror=g,b.onloadend=function(T){var _=btoa(T.target.result||"");v({__local_forage_encoded_blob:!0,data:_,type:p.type})},b.readAsBinaryString(p)})}function Y(p){var v=X(atob(p.data));return d([v],{type:p.type})}function j(p){return p&&p.__local_forage_encoded_blob}function q(p){var v=this,g=v._initReady().then(function(){var b=B[v._dbInfo.name];if(b&&b.dbReady)return b.dbReady});return h(g,p,p),g}function V(p){A(p);for(var v=B[p.name],g=v.forages,b=0;b<g.length;b++){var T=g[b];T._dbInfo.db&&(T._dbInfo.db.close(),T._dbInfo.db=null)}return p.db=null,re(p).then(function(_){return p.db=_,I(p)?ie(p):_}).then(function(_){p.db=v.db=_;for(var x=0;x<g.length;x++)g[x]._dbInfo.db=_}).catch(function(_){throw L(p,_),_})}function oe(p,v,g,b){b===void 0&&(b=1);try{var T=p.db.transaction(p.storeName,v);g(null,T)}catch(_){if(b>0&&(!p.db||_.name==="InvalidStateError"||_.name==="NotFoundError"))return l.resolve().then(function(){if(!p.db||_.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),ie(p)}).then(function(){return V(p).then(function(){oe(p,v,g,b-1)})}).catch(g);g(_)}}function S(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function W(p){var v=this,g={db:null};if(p)for(var b in p)g[b]=p[b];var T=B[g.name];T||(T=S(),B[g.name]=T),T.forages.push(v),v._initReady||(v._initReady=v.ready,v.ready=q);var _=[];function x(){return l.resolve()}for(var G=0;G<T.forages.length;G++){var H=T.forages[G];H!==v&&_.push(H._initReady().catch(x))}var J=T.forages.slice(0);return l.all(_).then(function(){return g.db=T.db,re(g)}).then(function(Z){return g.db=Z,I(g,v._defaultConfig.version)?ie(g):Z}).then(function(Z){g.db=T.db=Z,v._dbInfo=g;for(var ne=0;ne<J.length;ne++){var le=J[ne];le!==v&&(le._dbInfo.db=g.db,le._dbInfo.version=g.version)}})}function U(p,v){var g=this;p=m(p);var b=new l(function(T,_){g.ready().then(function(){oe(g._dbInfo,Q,function(x,G){if(x)return _(x);try{var H=G.objectStore(g._dbInfo.storeName),J=H.get(p);J.onsuccess=function(){var Z=J.result;Z===void 0&&(Z=null),j(Z)&&(Z=Y(Z)),T(Z)},J.onerror=function(){_(J.error)}}catch(Z){_(Z)}})}).catch(_)});return f(b,v),b}function K(p,v){var g=this,b=new l(function(T,_){g.ready().then(function(){oe(g._dbInfo,Q,function(x,G){if(x)return _(x);try{var H=G.objectStore(g._dbInfo.storeName),J=H.openCursor(),Z=1;J.onsuccess=function(){var ne=J.result;if(ne){var le=ne.value;j(le)&&(le=Y(le));var Ee=p(le,ne.key,Z++);Ee!==void 0?T(Ee):ne.continue()}else T()},J.onerror=function(){_(J.error)}}catch(ne){_(ne)}})}).catch(_)});return f(b,v),b}function me(p,v,g){var b=this;p=m(p);var T=new l(function(_,x){var G;b.ready().then(function(){return G=b._dbInfo,R.call(v)==="[object Blob]"?$(G.db).then(function(H){return H?v:k(v)}):v}).then(function(H){oe(b._dbInfo,N,function(J,Z){if(J)return x(J);try{var ne=Z.objectStore(b._dbInfo.storeName);H===null&&(H=void 0);var le=ne.put(H,p);Z.oncomplete=function(){H===void 0&&(H=null),_(H)},Z.onabort=Z.onerror=function(){var Ee=le.error?le.error:le.transaction.error;x(Ee)}}catch(Ee){x(Ee)}})}).catch(x)});return f(T,g),T}function ue(p,v){var g=this;p=m(p);var b=new l(function(T,_){g.ready().then(function(){oe(g._dbInfo,N,function(x,G){if(x)return _(x);try{var H=G.objectStore(g._dbInfo.storeName),J=H.delete(p);G.oncomplete=function(){T()},G.onerror=function(){_(J.error)},G.onabort=function(){var Z=J.error?J.error:J.transaction.error;_(Z)}}catch(Z){_(Z)}})}).catch(_)});return f(b,v),b}function ve(p){var v=this,g=new l(function(b,T){v.ready().then(function(){oe(v._dbInfo,N,function(_,x){if(_)return T(_);try{var G=x.objectStore(v._dbInfo.storeName),H=G.clear();x.oncomplete=function(){b()},x.onabort=x.onerror=function(){var J=H.error?H.error:H.transaction.error;T(J)}}catch(J){T(J)}})}).catch(T)});return f(g,p),g}function Xe(p){var v=this,g=new l(function(b,T){v.ready().then(function(){oe(v._dbInfo,Q,function(_,x){if(_)return T(_);try{var G=x.objectStore(v._dbInfo.storeName),H=G.count();H.onsuccess=function(){b(H.result)},H.onerror=function(){T(H.error)}}catch(J){T(J)}})}).catch(T)});return f(g,p),g}function bt(p,v){var g=this,b=new l(function(T,_){if(p<0){T(null);return}g.ready().then(function(){oe(g._dbInfo,Q,function(x,G){if(x)return _(x);try{var H=G.objectStore(g._dbInfo.storeName),J=!1,Z=H.openKeyCursor();Z.onsuccess=function(){var ne=Z.result;if(!ne){T(null);return}p===0||J?T(ne.key):(J=!0,ne.advance(p))},Z.onerror=function(){_(Z.error)}}catch(ne){_(ne)}})}).catch(_)});return f(b,v),b}function St(p){var v=this,g=new l(function(b,T){v.ready().then(function(){oe(v._dbInfo,Q,function(_,x){if(_)return T(_);try{var G=x.objectStore(v._dbInfo.storeName),H=G.openKeyCursor(),J=[];H.onsuccess=function(){var Z=H.result;if(!Z){b(J);return}J.push(Z.key),Z.continue()},H.onerror=function(){T(H.error)}}catch(Z){T(Z)}})}).catch(T)});return f(g,p),g}function We(p,v){v=E.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var b=this,T;if(!p.name)T=l.reject("Invalid arguments");else{var _=p.name===g.name&&b._dbInfo.db,x=_?l.resolve(b._dbInfo.db):re(p).then(function(G){var H=B[p.name],J=H.forages;H.db=G;for(var Z=0;Z<J.length;Z++)J[Z]._dbInfo.db=G;return G});p.storeName?T=x.then(function(G){if(G.objectStoreNames.contains(p.storeName)){var H=G.version+1;A(p);var J=B[p.name],Z=J.forages;G.close();for(var ne=0;ne<Z.length;ne++){var le=Z[ne];le._dbInfo.db=null,le._dbInfo.version=H}var Ee=new l(function(_e,Le){var Ae=c.open(p.name,H);Ae.onerror=function(Ze){var Un=Ae.result;Un.close(),Le(Ze)},Ae.onupgradeneeded=function(){var Ze=Ae.result;Ze.deleteObjectStore(p.storeName)},Ae.onsuccess=function(){var Ze=Ae.result;Ze.close(),_e(Ze)}});return Ee.then(function(_e){J.db=_e;for(var Le=0;Le<Z.length;Le++){var Ae=Z[Le];Ae._dbInfo.db=_e,C(Ae._dbInfo)}}).catch(function(_e){throw(L(p,_e)||l.resolve()).catch(function(){}),_e})}}):T=x.then(function(G){A(p);var H=B[p.name],J=H.forages;G.close();for(var Z=0;Z<J.length;Z++){var ne=J[Z];ne._dbInfo.db=null}var le=new l(function(Ee,_e){var Le=c.deleteDatabase(p.name);Le.onerror=function(){var Ae=Le.result;Ae&&Ae.close(),_e(Le.error)},Le.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},Le.onsuccess=function(){var Ae=Le.result;Ae&&Ae.close(),Ee(Ae)}});return le.then(function(Ee){H.db=Ee;for(var _e=0;_e<J.length;_e++){var Le=J[_e];C(Le._dbInfo)}}).catch(function(Ee){throw(L(p,Ee)||l.resolve()).catch(function(){}),Ee})})}return f(T,v),T}var Qd={_driver:"asyncStorage",_initStorage:W,_support:u(),iterate:K,getItem:U,setItem:me,removeItem:ue,clear:ve,length:Xe,key:bt,keys:St,dropInstance:We};function Kd(){return typeof openDatabase=="function"}var Lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xd="~~local_forage_type~",Fo=/^~~local_forage_type~([^~]+)~/,Or="__lfsc__:",Fs=Or.length,Us="arbf",Bs="blob",Uo="si08",Bo="ui08",jo="uic8",Vo="si16",Go="si32",zo="ur16",qo="ui32",Yo="fl32",Ho="fl64",Jo=Fs+Us.length,Wo=Object.prototype.toString;function Qo(p){var v=p.length*.75,g=p.length,b,T=0,_,x,G,H;p[p.length-1]==="="&&(v--,p[p.length-2]==="="&&v--);var J=new ArrayBuffer(v),Z=new Uint8Array(J);for(b=0;b<g;b+=4)_=Lt.indexOf(p[b]),x=Lt.indexOf(p[b+1]),G=Lt.indexOf(p[b+2]),H=Lt.indexOf(p[b+3]),Z[T++]=_<<2|x>>4,Z[T++]=(x&15)<<4|G>>2,Z[T++]=(G&3)<<6|H&63;return J}function js(p){var v=new Uint8Array(p),g="",b;for(b=0;b<v.length;b+=3)g+=Lt[v[b]>>2],g+=Lt[(v[b]&3)<<4|v[b+1]>>4],g+=Lt[(v[b+1]&15)<<2|v[b+2]>>6],g+=Lt[v[b+2]&63];return v.length%3===2?g=g.substring(0,g.length-1)+"=":v.length%3===1&&(g=g.substring(0,g.length-2)+"=="),g}function Zd(p,v){var g="";if(p&&(g=Wo.call(p)),p&&(g==="[object ArrayBuffer]"||p.buffer&&Wo.call(p.buffer)==="[object ArrayBuffer]")){var b,T=Or;p instanceof ArrayBuffer?(b=p,T+=Us):(b=p.buffer,g==="[object Int8Array]"?T+=Uo:g==="[object Uint8Array]"?T+=Bo:g==="[object Uint8ClampedArray]"?T+=jo:g==="[object Int16Array]"?T+=Vo:g==="[object Uint16Array]"?T+=zo:g==="[object Int32Array]"?T+=Go:g==="[object Uint32Array]"?T+=qo:g==="[object Float32Array]"?T+=Yo:g==="[object Float64Array]"?T+=Ho:v(new Error("Failed to get type for BinaryArray"))),v(T+js(b))}else if(g==="[object Blob]"){var _=new FileReader;_.onload=function(){var x=Xd+p.type+"~"+js(this.result);v(Or+Bs+x)},_.readAsArrayBuffer(p)}else try{v(JSON.stringify(p))}catch(x){console.error("Couldn't convert value into a JSON string: ",p),v(null,x)}}function ef(p){if(p.substring(0,Fs)!==Or)return JSON.parse(p);var v=p.substring(Jo),g=p.substring(Fs,Jo),b;if(g===Bs&&Fo.test(v)){var T=v.match(Fo);b=T[1],v=v.substring(T[0].length)}var _=Qo(v);switch(g){case Us:return _;case Bs:return d([_],{type:b});case Uo:return new Int8Array(_);case Bo:return new Uint8Array(_);case jo:return new Uint8ClampedArray(_);case Vo:return new Int16Array(_);case zo:return new Uint16Array(_);case Go:return new Int32Array(_);case qo:return new Uint32Array(_);case Yo:return new Float32Array(_);case Ho:return new Float64Array(_);default:throw new Error("Unkown type: "+g)}}var Vs={serialize:Zd,deserialize:ef,stringToBuffer:Qo,bufferToString:js};function Ko(p,v,g,b){p.executeSql("CREATE TABLE IF NOT EXISTS "+v.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],g,b)}function tf(p){var v=this,g={db:null};if(p)for(var b in p)g[b]=typeof p[b]!="string"?p[b].toString():p[b];var T=new l(function(_,x){try{g.db=openDatabase(g.name,String(g.version),g.description,g.size)}catch(G){return x(G)}g.db.transaction(function(G){Ko(G,g,function(){v._dbInfo=g,_()},function(H,J){x(J)})},x)});return g.serializer=Vs,T}function xt(p,v,g,b,T,_){p.executeSql(g,b,T,function(x,G){G.code===G.SYNTAX_ERR?x.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[v.storeName],function(H,J){J.rows.length?_(H,G):Ko(H,v,function(){H.executeSql(g,b,T,_)},_)},_):_(x,G)},_)}function nf(p,v){var g=this;p=m(p);var b=new l(function(T,_){g.ready().then(function(){var x=g._dbInfo;x.db.transaction(function(G){xt(G,x,"SELECT * FROM "+x.storeName+" WHERE key = ? LIMIT 1",[p],function(H,J){var Z=J.rows.length?J.rows.item(0).value:null;Z&&(Z=x.serializer.deserialize(Z)),T(Z)},function(H,J){_(J)})})}).catch(_)});return f(b,v),b}function rf(p,v){var g=this,b=new l(function(T,_){g.ready().then(function(){var x=g._dbInfo;x.db.transaction(function(G){xt(G,x,"SELECT * FROM "+x.storeName,[],function(H,J){for(var Z=J.rows,ne=Z.length,le=0;le<ne;le++){var Ee=Z.item(le),_e=Ee.value;if(_e&&(_e=x.serializer.deserialize(_e)),_e=p(_e,Ee.key,le+1),_e!==void 0){T(_e);return}}T()},function(H,J){_(J)})})}).catch(_)});return f(b,v),b}function Xo(p,v,g,b){var T=this;p=m(p);var _=new l(function(x,G){T.ready().then(function(){v===void 0&&(v=null);var H=v,J=T._dbInfo;J.serializer.serialize(v,function(Z,ne){ne?G(ne):J.db.transaction(function(le){xt(le,J,"INSERT OR REPLACE INTO "+J.storeName+" (key, value) VALUES (?, ?)",[p,Z],function(){x(H)},function(Ee,_e){G(_e)})},function(le){if(le.code===le.QUOTA_ERR){if(b>0){x(Xo.apply(T,[p,H,g,b-1]));return}G(le)}})})}).catch(G)});return f(_,g),_}function sf(p,v,g){return Xo.apply(this,[p,v,g,1])}function of(p,v){var g=this;p=m(p);var b=new l(function(T,_){g.ready().then(function(){var x=g._dbInfo;x.db.transaction(function(G){xt(G,x,"DELETE FROM "+x.storeName+" WHERE key = ?",[p],function(){T()},function(H,J){_(J)})})}).catch(_)});return f(b,v),b}function af(p){var v=this,g=new l(function(b,T){v.ready().then(function(){var _=v._dbInfo;_.db.transaction(function(x){xt(x,_,"DELETE FROM "+_.storeName,[],function(){b()},function(G,H){T(H)})})}).catch(T)});return f(g,p),g}function cf(p){var v=this,g=new l(function(b,T){v.ready().then(function(){var _=v._dbInfo;_.db.transaction(function(x){xt(x,_,"SELECT COUNT(key) as c FROM "+_.storeName,[],function(G,H){var J=H.rows.item(0).c;b(J)},function(G,H){T(H)})})}).catch(T)});return f(g,p),g}function uf(p,v){var g=this,b=new l(function(T,_){g.ready().then(function(){var x=g._dbInfo;x.db.transaction(function(G){xt(G,x,"SELECT key FROM "+x.storeName+" WHERE id = ? LIMIT 1",[p+1],function(H,J){var Z=J.rows.length?J.rows.item(0).key:null;T(Z)},function(H,J){_(J)})})}).catch(_)});return f(b,v),b}function lf(p){var v=this,g=new l(function(b,T){v.ready().then(function(){var _=v._dbInfo;_.db.transaction(function(x){xt(x,_,"SELECT key FROM "+_.storeName,[],function(G,H){for(var J=[],Z=0;Z<H.rows.length;Z++)J.push(H.rows.item(Z).key);b(J)},function(G,H){T(H)})})}).catch(T)});return f(g,p),g}function df(p){return new l(function(v,g){p.transaction(function(b){b.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(T,_){for(var x=[],G=0;G<_.rows.length;G++)x.push(_.rows.item(G).name);v({db:p,storeNames:x})},function(T,_){g(_)})},function(b){g(b)})})}function ff(p,v){v=E.apply(this,arguments);var g=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||g.name,p.storeName=p.storeName||g.storeName);var b=this,T;return p.name?T=new l(function(_){var x;p.name===g.name?x=b._dbInfo.db:x=openDatabase(p.name,"","",0),p.storeName?_({db:x,storeNames:[p.storeName]}):_(df(x))}).then(function(_){return new l(function(x,G){_.db.transaction(function(H){function J(Ee){return new l(function(_e,Le){H.executeSql("DROP TABLE IF EXISTS "+Ee,[],function(){_e()},function(Ae,Ze){Le(Ze)})})}for(var Z=[],ne=0,le=_.storeNames.length;ne<le;ne++)Z.push(J(_.storeNames[ne]));l.all(Z).then(function(){x()}).catch(function(Ee){G(Ee)})},function(H){G(H)})})}):T=l.reject("Invalid arguments"),f(T,v),T}var pf={_driver:"webSQLStorage",_initStorage:tf,_support:Kd(),iterate:rf,getItem:nf,setItem:sf,removeItem:of,clear:af,length:cf,key:uf,keys:lf,dropInstance:ff};function hf(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Zo(p,v){var g=p.name+"/";return p.storeName!==v.storeName&&(g+=p.storeName+"/"),g}function gf(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch{return!0}}function mf(){return!gf()||localStorage.length>0}function yf(p){var v=this,g={};if(p)for(var b in p)g[b]=p[b];return g.keyPrefix=Zo(p,v._defaultConfig),mf()?(v._dbInfo=g,g.serializer=Vs,l.resolve()):l.reject()}function vf(p){var v=this,g=v.ready().then(function(){for(var b=v._dbInfo.keyPrefix,T=localStorage.length-1;T>=0;T--){var _=localStorage.key(T);_.indexOf(b)===0&&localStorage.removeItem(_)}});return f(g,p),g}function Ef(p,v){var g=this;p=m(p);var b=g.ready().then(function(){var T=g._dbInfo,_=localStorage.getItem(T.keyPrefix+p);return _&&(_=T.serializer.deserialize(_)),_});return f(b,v),b}function _f(p,v){var g=this,b=g.ready().then(function(){for(var T=g._dbInfo,_=T.keyPrefix,x=_.length,G=localStorage.length,H=1,J=0;J<G;J++){var Z=localStorage.key(J);if(Z.indexOf(_)===0){var ne=localStorage.getItem(Z);if(ne&&(ne=T.serializer.deserialize(ne)),ne=p(ne,Z.substring(x),H++),ne!==void 0)return ne}}});return f(b,v),b}function wf(p,v){var g=this,b=g.ready().then(function(){var T=g._dbInfo,_;try{_=localStorage.key(p)}catch{_=null}return _&&(_=_.substring(T.keyPrefix.length)),_});return f(b,v),b}function bf(p){var v=this,g=v.ready().then(function(){for(var b=v._dbInfo,T=localStorage.length,_=[],x=0;x<T;x++){var G=localStorage.key(x);G.indexOf(b.keyPrefix)===0&&_.push(G.substring(b.keyPrefix.length))}return _});return f(g,p),g}function Sf(p){var v=this,g=v.keys().then(function(b){return b.length});return f(g,p),g}function Tf(p,v){var g=this;p=m(p);var b=g.ready().then(function(){var T=g._dbInfo;localStorage.removeItem(T.keyPrefix+p)});return f(b,v),b}function If(p,v,g){var b=this;p=m(p);var T=b.ready().then(function(){v===void 0&&(v=null);var _=v;return new l(function(x,G){var H=b._dbInfo;H.serializer.serialize(v,function(J,Z){if(Z)G(Z);else try{localStorage.setItem(H.keyPrefix+p,J),x(_)}catch(ne){(ne.name==="QuotaExceededError"||ne.name==="NS_ERROR_DOM_QUOTA_REACHED")&&G(ne),G(ne)}})})});return f(T,g),T}function Df(p,v){if(v=E.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var g=this.config();p.name=p.name||g.name,p.storeName=p.storeName||g.storeName}var b=this,T;return p.name?T=new l(function(_){p.storeName?_(Zo(p,b._defaultConfig)):_(p.name+"/")}).then(function(_){for(var x=localStorage.length-1;x>=0;x--){var G=localStorage.key(x);G.indexOf(_)===0&&localStorage.removeItem(G)}}):T=l.reject("Invalid arguments"),f(T,v),T}var Nf={_driver:"localStorageWrapper",_initStorage:yf,_support:hf(),iterate:_f,getItem:Ef,setItem:If,removeItem:Tf,clear:vf,length:Sf,key:wf,keys:bf,dropInstance:Df},Of=function(v,g){return v===g||typeof v=="number"&&typeof g=="number"&&isNaN(v)&&isNaN(g)},Af=function(v,g){for(var b=v.length,T=0;T<b;){if(Of(v[T],g))return!0;T++}return!1},ea=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Fn={},ta={},En={INDEXEDDB:Qd,WEBSQL:pf,LOCALSTORAGE:Nf},Rf=[En.INDEXEDDB._driver,En.WEBSQL._driver,En.LOCALSTORAGE._driver],Ar=["dropInstance"],Gs=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Ar),Cf={description:"",driver:Rf.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Lf(p,v){p[v]=function(){var g=arguments;return p.ready().then(function(){return p[v].apply(p,g)})}}function zs(){for(var p=1;p<arguments.length;p++){var v=arguments[p];if(v)for(var g in v)v.hasOwnProperty(g)&&(ea(v[g])?arguments[0][g]=v[g].slice():arguments[0][g]=v[g])}return arguments[0]}var xf=function(){function p(v){o(this,p);for(var g in En)if(En.hasOwnProperty(g)){var b=En[g],T=b._driver;this[g]=T,Fn[T]||this.defineDriver(b)}this._defaultConfig=zs({},Cf),this._config=zs({},this._defaultConfig,v),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(g){if((typeof g>"u"?"undefined":i(g))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in g){if(b==="storeName"&&(g[b]=g[b].replace(/\W/g,"_")),b==="version"&&typeof g[b]!="number")return new Error("Database version must be a number.");this._config[b]=g[b]}return"driver"in g&&g.driver?this.setDriver(this._config.driver):!0}else return typeof g=="string"?this._config[g]:this._config},p.prototype.defineDriver=function(g,b,T){var _=new l(function(x,G){try{var H=g._driver,J=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!g._driver){G(J);return}for(var Z=Gs.concat("_initStorage"),ne=0,le=Z.length;ne<le;ne++){var Ee=Z[ne],_e=!Af(Ar,Ee);if((_e||g[Ee])&&typeof g[Ee]!="function"){G(J);return}}var Le=function(){for(var Un=function(kf){return function(){var $f=new Error("Method "+kf+" is not implemented by the current driver"),na=l.reject($f);return f(na,arguments[arguments.length-1]),na}},qs=0,Pf=Ar.length;qs<Pf;qs++){var Ys=Ar[qs];g[Ys]||(g[Ys]=Un(Ys))}};Le();var Ae=function(Un){Fn[H]&&console.info("Redefining LocalForage driver: "+H),Fn[H]=g,ta[H]=Un,x()};"_support"in g?g._support&&typeof g._support=="function"?g._support().then(Ae,G):Ae(!!g._support):Ae(!0)}catch(Ze){G(Ze)}});return h(_,b,T),_},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(g,b,T){var _=Fn[g]?l.resolve(Fn[g]):l.reject(new Error("Driver not found."));return h(_,b,T),_},p.prototype.getSerializer=function(g){var b=l.resolve(Vs);return h(b,g),b},p.prototype.ready=function(g){var b=this,T=b._driverSet.then(function(){return b._ready===null&&(b._ready=b._initDriver()),b._ready});return h(T,g,g),T},p.prototype.setDriver=function(g,b,T){var _=this;ea(g)||(g=[g]);var x=this._getSupportedDrivers(g);function G(){_._config.driver=_.driver()}function H(ne){return _._extend(ne),G(),_._ready=_._initStorage(_._config),_._ready}function J(ne){return function(){var le=0;function Ee(){for(;le<ne.length;){var _e=ne[le];return le++,_._dbInfo=null,_._ready=null,_.getDriver(_e).then(H).catch(Ee)}G();var Le=new Error("No available storage method found.");return _._driverSet=l.reject(Le),_._driverSet}return Ee()}}var Z=this._driverSet!==null?this._driverSet.catch(function(){return l.resolve()}):l.resolve();return this._driverSet=Z.then(function(){var ne=x[0];return _._dbInfo=null,_._ready=null,_.getDriver(ne).then(function(le){_._driver=le._driver,G(),_._wrapLibraryMethodsWithReady(),_._initDriver=J(x)})}).catch(function(){G();var ne=new Error("No available storage method found.");return _._driverSet=l.reject(ne),_._driverSet}),h(this._driverSet,b,T),this._driverSet},p.prototype.supports=function(g){return!!ta[g]},p.prototype._extend=function(g){zs(this,g)},p.prototype._getSupportedDrivers=function(g){for(var b=[],T=0,_=g.length;T<_;T++){var x=g[T];this.supports(x)&&b.push(x)}return b},p.prototype._wrapLibraryMethodsWithReady=function(){for(var g=0,b=Gs.length;g<b;g++)Lf(this,Gs[g])},p.prototype.createInstance=function(g){return new p(g)},p}(),Mf=new xf;r.exports=Mf},{3:3}]},{},[4])(4)})}(vi)),vi.exports}var NE=DE();const lc=ws(NE),Se=class Se{constructor(e){F(this,"db");this.db=lc.ready().then(()=>lc.createInstance({name:e?`${e}:${Se.DBName}`:Se.DBName}))}async findStorageUnitsBy(e,n,r){const s=[],{parentId:i,documentId:o,documentModelType:a,scope:c}=Au(e),l=(await(await this.db).keys()).filter(D=>D.startsWith(`${Se.DOCUMENT_KEY}${Se.SEP}`)).map(D=>D.slice(Se.DOCUMENT_KEY.length+Se.SEP.length));let f;if(i){const D=new Set;for(const P of i)(await this.getChildren(P)).forEach(R=>D.add(R));f=i.union(D)}else f=new Set(l);f=o?o.intersection(f):f;for(const D of f){const P=await this.get(D).catch(()=>null);if(P&&!(a&&!a.has(P.header.documentType)))for(const[B]of Object.entries(P.state))c&&!c.has(B)||s.push({documentId:D,documentModelType:P.header.documentType,scope:B,branch:"main"})}let h=0;if(r){const D=s.findIndex(P=>P.documentId===r);D!==-1&&(h=D)}const m=Math.min(h+n,s.length),E=m<s.length?s[m].documentId:void 0;return{units:s.slice(h,m),nextCursor:E}}async resolveIds(e,n){const r=await this.getSlugManifest();if(n!=null&&n.aborted)throw new gs("Aborted");const s=[];for(const i of e){const o=r.slugToId[i];if(!o)throw new Nt(i);s.push(o)}return Promise.resolve(s)}async resolveSlugs(e,n){const r=await this.getSlugManifest();if(n!=null&&n.aborted)throw new gs("Aborted");const s=[];for(const i of e){let o=!1;for(const[a,c]of Object.entries(r.slugToId))if(c===i){s.push(a),o=!0;break}if(!o)throw new Nt(i)}return Promise.resolve(s)}async clear(){await(await this.db).clear()}async exists(e){return!!await(await this.db).getItem(this.buildDocumentKey(e))}async create(e){const n=e.header.id;if(!as(n))throw new os(n);const r=await this.db;if(await this.exists(n))throw new bn(n);const s=e.header.slug&&e.header.slug.length>0?e.header.slug:n;if(!Ou(s))throw new Nu(s);if((await this.getSlugManifest()).slugToId[s])throw new bn(n);if(e.header.slug=s,await r.setItem(this.buildDocumentKey(n),e),s){const o=await this.getSlugManifest();if(o.slugToId[s])throw new Error(`Document with slug ${s} already exists`);o.slugToId[s]=n,await this.updateSlugManifest(o)}e.header.documentType==="powerhouse/document-drive"&&this.updateDriveManifest(n,{documentIds:[]})}async get(e){const r=await(await this.db).getItem(this.buildDocumentKey(e));return r||Promise.reject(new Nt(e))}async getBySlug(e){const r=(await this.getSlugManifest()).slugToId[e];return r?this.get(r):Promise.reject(new Nt(e))}async findByType(e,n=100,r){const s=await this.db,o=(await s.keys()).filter(l=>l.startsWith(`${Se.DOCUMENT_KEY}${Se.SEP}`)),a=[];for(const l of o){const f=l.slice(Se.DOCUMENT_KEY.length+Se.SEP.length);try{const h=await s.getItem(l);if(!h||h.header.documentType!==e)continue;a.push({id:f,document:h})}catch{continue}}a.sort((l,f)=>{const h=new Date(l.document.header.createdAtUtcIso),m=new Date(f.document.header.createdAtUtcIso);return h.getTime()===m.getTime()?l.id.localeCompare(f.id):h.getTime()-m.getTime()});let c=0;if(r){const l=a.findIndex(({id:f})=>f===r);l!==-1&&(c=l)}const u=Math.min(c+n,a.length);let d;return u<a.length&&(d=a[u].id),{documents:a.slice(c,u).map(({id:l})=>l),nextCursor:d}}async delete(e){var o;const n=await this.db,r=await n.getItem(this.buildDocumentKey(e));if(!r)return!1;const s=((o=r.header.slug)==null?void 0:o.length)>0?r.header.slug:e;try{if(s){const a=await this.getSlugManifest();a.slugToId[s]===e&&(delete a.slugToId[s],await this.updateSlugManifest(a))}}catch{}const i=await this.getParents(e);for(const a of i)await this.removeChild(a,e);return await n.removeItem(this.buildManifestKey(e)),await n.removeItem(this.buildDocumentKey(e)),!0}async removeChild(e,n){const r=await this.getManifest(e),s=r.documentIds.indexOf(n);return s!==-1?(r.documentIds.splice(s,1),await this.updateDriveManifest(e,r),!0):!1}async addChild(e,n){if(e===n)throw new Error("Cannot associate a document with itself");if((await this.getChildren(n)).includes(e))throw new Error("Cannot associate a document with its child");const s=await this.getManifest(e);s.documentIds.includes(n)||(s.documentIds.push(n),await this.updateDriveManifest(e,s))}async getChildren(e){return(await this.getManifest(e)).documentIds}async getParents(e){const r=await(await this.db).keys(),s=[],i=r.filter(o=>o.startsWith(`${Se.MANIFEST_KEY}${Se.SEP}`));for(const o of i){const a=o.slice(Se.MANIFEST_KEY.length+Se.SEP.length);(await this.getManifest(a)).documentIds.includes(e)&&s.push(a)}return s}async getManifest(e){return await(await this.db).getItem(this.buildManifestKey(e))||{documentIds:[]}}async updateDriveManifest(e,n){await(await this.db).setItem(this.buildManifestKey(e),n)}async getSlugManifest(){return await(await this.db).getItem(Se.SLUG_MANIFEST_KEY)||{slugToId:{}}}async updateSlugManifest(e){await(await this.db).setItem(Se.SLUG_MANIFEST_KEY,e)}async addDocumentOperations(e,n,r){const s=await this.get(e);if(!s)throw new Error(`Document with id ${e} not found`);const i=ps(s.operations,n);await(await this.db).setItem(this.buildDocumentKey(e),{...s,...r,operations:i})}async addDriveOperations(e,n,r){const s=await this.get(e),i=ps(s.operations,n);await(await this.db).setItem(this.buildDocumentKey(e),{...s,...r,operations:i})}async getSynchronizationUnitsRevision(e){return(await Promise.allSettled(e.map(async r=>{var s;try{const i=await this.get(r.documentId);if(!i||!i.operations[r.scope])return;const o=i.operations[r.scope];return{documentId:r.documentId,documentType:r.documentType,scope:r.scope,branch:r.branch,lastUpdated:((s=o.at(-1))==null?void 0:s.timestamp)??i.header.createdAtUtcIso,revision:Mn(o)}}catch{return}}))).reduce((r,s)=>(s.status==="fulfilled"&&s.value!==void 0&&r.push(s.value),r),[])}async migrateOperationSignatures(){let e;do{const{documents:n,nextCursor:r}=await this.findByType("powerhouse/document-drive",100,e);for(const s of n){await this.migrateDrive(s);const i=await this.getChildren(s);await Promise.all(i.map(async o=>this.migrateDocument(s,o)))}e=r}while(e)}async migrateDrive(e){const n=await this.get(e),r=cc(n);if(r!==n)return(await this.db).setItem(this.buildDocumentKey(e),r)}async migrateDocument(e,n){const r=await this.get(n),s=cc(r);if(s!==r)return(await this.db).setItem(this.buildDocumentKey(n),s)}buildDocumentKey(e){return`${Se.DOCUMENT_KEY}${Se.SEP}${e}`}buildManifestKey(e){return`${Se.MANIFEST_KEY}${Se.SEP}${e}`}};F(Se,"DBName","DOCUMENT_DRIVES"),F(Se,"SEP",":"),F(Se,"DOCUMENT_KEY","DOCUMENT"),F(Se,"MANIFEST_KEY","MANIFEST"),F(Se,"SLUG_MANIFEST_KEY","SLUG_MANIFEST");let Yi=Se;const dc=window.__VITE_ENVS.PH_CONNECT_DEFAULT_DRIVES_URL||void 0,Ei=dc?dc.split(","):[],OE=()=>({defaultDrives:{remoteDrives:Ei.map(e=>({url:e,options:{sharingType:"PUBLIC",availableOffline:!0,listeners:[{block:!0,callInfo:{data:e,name:"switchboard-push",transmitterType:"SwitchboardPush"},filter:{branch:["main"],documentId:["*"],documentType:["*"],scope:["global"]},label:"Switchboard Sync",listenerId:"1",system:!0}],triggers:[]}})),removeOldRemoteDrives:Ei.length>0?{strategy:"preserve-by-url-and-detach",urls:Ei}:{strategy:"preserve-all"}}});function AE(t){return new Yi(t)}function RE(t,e){return new Vv(t).withStorage(e).withCache(new lu).withQueueManager(new Ju).withOptions({...OE()}).build()}async function CE(t,e,n,r,s,i){var c;if(!i||!((c=t.action)!=null&&c.context)||!t.action.context.signer)return t;if(!s)return pe.error(`Document model '${r.header.documentType}' does not have a reducer`),t;const o=t.action.context.signer;return await ap(t,s,r,o,e)}function LE(t,e,n){return n?{context:{signer:{app:{name:"Connect",key:e||""},user:{address:n.address,networkId:n.networkId,chainId:n.chainId},signatures:[]}},...t}:t}async function Cs(){if(import.meta.hot)return import.meta.hot;try{return(await Bt(()=>import("../hmr.js"),[],import.meta.url)).hmr}catch{return}}async function Pb(t){const e=await Cs();if(!e)throw new Error("HMR not available.");return new Promise(n=>{function r(s){t===s.name&&(n(),e==null||e.off("studio:external-package-added",r))}e.on("studio:external-package-added",r),e.send("studio:add-external-package",{name:t})})}async function kb(t){const e=await Cs();if(!e)throw new Error("HMR not available.");return new Promise(n=>{function r(s){t===s.name&&(n(),e==null||e.off("studio:external-package-removed",r))}e.on("studio:external-package-removed",r),e.send("studio:remove-external-package",{name:t})})}async function xE(t){const e=await Cs(),n=r=>{const s=Bt(()=>import(`${r.url}?t=${r.timestamp}`),[],import.meta.url);t(s.then(i=>i.default))};return e==null||e.on("studio:external-packages-updated",n),()=>{e==null||e.off("studio:external-packages-updated",n)}}const ud=Object.prototype.toString;function ME(t){switch(ud.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return Ls(t,Error)}}function kn(t,e){return ud.call(t)===`[object ${e}]`}function $b(t){return kn(t,"ErrorEvent")}function Fb(t){return kn(t,"DOMError")}function Ub(t){return kn(t,"DOMException")}function ys(t){return kn(t,"String")}function PE(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function Bb(t){return t===null||PE(t)||typeof t!="object"&&typeof t!="function"}function Ro(t){return kn(t,"Object")}function kE(t){return typeof Event<"u"&&Ls(t,Event)}function $E(t){return typeof Element<"u"&&Ls(t,Element)}function FE(t){return kn(t,"RegExp")}function Co(t){return!!(t&&t.then&&typeof t.then=="function")}function UE(t){return Ro(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function BE(t){return typeof t=="number"&&t!==t}function Ls(t,e){try{return t instanceof e}catch{return!1}}function ld(t){return!!(typeof t=="object"&&t!==null&&(t.__isVue||t._isVue))}function tr(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function _i(t,e){let n=t;const r=n.length;if(r<=150)return n;e>r&&(e=r);let s=Math.max(e-60,0);s<5&&(s=0);let i=Math.min(s+140,r);return i>r-5&&(i=r),i===r&&(s=Math.max(i-140,0)),n=n.slice(s,i),s>0&&(n=`'{snip} ${n}`),i<r&&(n+=" {snip}"),n}function jb(t,e){if(!Array.isArray(t))return"";const n=[];for(let r=0;r<t.length;r++){const s=t[r];try{ld(s)?n.push("[VueViewModel]"):n.push(String(s))}catch{n.push("[value cannot be serialized]")}}return n.join(e)}function jE(t,e,n=!1){return ys(t)?FE(e)?e.test(t):ys(e)?n?t===e:t.includes(e):!1:!1}function Vb(t,e=[],n=!1){return e.some(r=>jE(t,r,n))}function Ur(t){return t&&t.Math==Math?t:void 0}const Je=typeof globalThis=="object"&&Ur(globalThis)||typeof window=="object"&&Ur(window)||typeof self=="object"&&Ur(self)||typeof global=="object"&&Ur(global)||function(){return this}()||{};function VE(){return Je}function dd(t,e,n){const r=n||Je,s=r.__SENTRY__=r.__SENTRY__||{};return s[t]||(s[t]=e())}const On=VE(),GE=80;function zE(t,e={}){if(!t)return"<unknown>";try{let n=t;const r=5,s=[];let i=0,o=0;const a=" > ",c=a.length;let u;const d=Array.isArray(e)?e:e.keyAttrs,l=!Array.isArray(e)&&e.maxStringLength||GE;for(;n&&i++<r&&(u=qE(n,d),!(u==="html"||i>1&&o+s.length*c+u.length>=l));)s.push(u),o+=u.length,n=n.parentNode;return s.reverse().join(a)}catch{return"<unknown>"}}function qE(t,e){const n=t,r=[];let s,i,o,a,c;if(!n||!n.tagName)return"";if(On.HTMLElement&&n instanceof HTMLElement&&n.dataset&&n.dataset.sentryComponent)return n.dataset.sentryComponent;r.push(n.tagName.toLowerCase());const u=e&&e.length?e.filter(l=>n.getAttribute(l)).map(l=>[l,n.getAttribute(l)]):null;if(u&&u.length)u.forEach(l=>{r.push(`[${l[0]}="${l[1]}"]`)});else if(n.id&&r.push(`#${n.id}`),s=n.className,s&&ys(s))for(i=s.split(/\s+/),c=0;c<i.length;c++)r.push(`.${i[c]}`);const d=["aria-label","type","name","title","alt"];for(c=0;c<d.length;c++)o=d[c],a=n.getAttribute(o),a&&r.push(`[${o}="${a}"]`);return r.join("")}function Gb(){try{return On.document.location.href}catch{return""}}function zb(t){return On.document&&On.document.querySelector?On.document.querySelector(t):null}function qb(t){if(!On.HTMLElement)return null;let e=t;const n=5;for(let r=0;r<n;r++){if(!e)return null;if(e instanceof HTMLElement&&e.dataset.sentryComponent)return e.dataset.sentryComponent;e=e.parentNode}return null}const Lo=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,YE="Sentry Logger ",fc=["debug","info","warn","error","log","assert","trace"],pc={};function fd(t){if(!("console"in Je))return t();const e=Je.console,n={},r=Object.keys(pc);r.forEach(s=>{const i=pc[s];n[s]=e[s],e[s]=i});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function HE(){let t=!1;const e={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return Lo?fc.forEach(n=>{e[n]=(...r)=>{t&&fd(()=>{Je.console[n](`${YE}[${n}]:`,...r)})}}):fc.forEach(n=>{e[n]=()=>{}}),e}const rt=HE();function Yb(t,e,n){if(!(e in t))return;const r=t[e],s=n(r);typeof s=="function"&&JE(s,r),t[e]=s}function pd(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{Lo&&rt.log(`Failed to add non-enumerable property "${e}" to object`,t)}}function JE(t,e){try{const n=e.prototype||{};t.prototype=e.prototype=n,pd(t,"__sentry_original__",e)}catch{}}function Hb(t){return t.__sentry_original__}function Jb(t){return Object.keys(t).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&")}function hd(t){if(ME(t))return{message:t.message,name:t.name,stack:t.stack,...gc(t)};if(kE(t)){const e={type:t.type,target:hc(t.target),currentTarget:hc(t.currentTarget),...gc(t)};return typeof CustomEvent<"u"&&Ls(t,CustomEvent)&&(e.detail=t.detail),e}else return t}function hc(t){try{return $E(t)?zE(t):Object.prototype.toString.call(t)}catch{return"<unknown>"}}function gc(t){if(typeof t=="object"&&t!==null){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}else return{}}function Wb(t,e=40){const n=Object.keys(hd(t));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=e)return tr(n[0],e);for(let r=n.length;r>0;r--){const s=n.slice(0,r).join(", ");if(!(s.length>e))return r===n.length?s:tr(s,e)}return""}function nn(t){return Hi(t,new Map)}function Hi(t,e){if(WE(t)){const n=e.get(t);if(n!==void 0)return n;const r={};e.set(t,r);for(const s of Object.keys(t))typeof t[s]<"u"&&(r[s]=Hi(t[s],e));return r}if(Array.isArray(t)){const n=e.get(t);if(n!==void 0)return n;const r=[];return e.set(t,r),t.forEach(s=>{r.push(Hi(s,e))}),r}return t}function WE(t){if(!Ro(t))return!1;try{const e=Object.getPrototypeOf(t).constructor.name;return!e||e==="Object"}catch{return!0}}const gd=50,mc=/\(error: (.*)\)/,yc=/captureMessage|captureException/;function QE(...t){const e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0)=>{const s=[],i=n.split(`
|
|
364
|
-
`);for(let o=r;o<i.length;o++){const a=i[o];if(a.length>1024)continue;const c=mc.test(a)?a.replace(mc,"$1"):a;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){s.push(d);break}}if(s.length>=gd)break}}return KE(s)}}function Qb(t){return Array.isArray(t)?QE(...t):t}function KE(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(e[e.length-1].function||"")&&e.pop(),e.reverse(),yc.test(e[e.length-1].function||"")&&(e.pop(),yc.test(e[e.length-1].function||"")&&e.pop()),e.slice(0,gd).map(n=>({...n,filename:n.filename||e[e.length-1].filename,function:n.function||"?"}))}const wi="<anonymous>";function XE(t){try{return!t||typeof t!="function"?wi:t.name||wi}catch{return wi}}function Ne(){const t=Je,e=t.crypto||t.msCrypto;let n=()=>Math.random()*16;try{if(e&&e.randomUUID)return e.randomUUID().replace(/-/g,"");e&&e.getRandomValues&&(n=()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]})}catch{}return("10000000100040008000"+1e11).replace(/[018]/g,r=>(r^(n()&15)>>r/4).toString(16))}function md(t){return t.exception&&t.exception.values?t.exception.values[0]:void 0}function Kb(t){const{message:e,event_id:n}=t;if(e)return e;const r=md(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function Xb(t,e,n){const r=t.exception=t.exception||{},s=r.values=r.values||[],i=s[0]=s[0]||{};i.value||(i.value=e||""),i.type||(i.type="Error")}function ZE(t,e){const n=md(t);if(!n)return;const r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism={...r,...s,...e},e&&"data"in e){const i={...s&&s.data,...e.data};n.mechanism.data=i}}function Zb(t,e,n=5){if(e.lineno===void 0)return;const r=t.length,s=Math.max(Math.min(r-1,e.lineno-1),0);e.pre_context=t.slice(Math.max(0,s-n),s).map(i=>_i(i,0)),e.context_line=_i(t[Math.min(r-1,s)],e.colno||0),e.post_context=t.slice(Math.min(s+1,r),s+1+n).map(i=>_i(i,0))}function eS(t){if(t&&t.__sentry_captured__)return!0;try{pd(t,"__sentry_captured__",!0)}catch{}return!1}function e_(t){return Array.isArray(t)?t:[t]}function t_(){const t=typeof WeakSet=="function",e=t?new WeakSet:[];function n(s){if(t)return e.has(s)?!0:(e.add(s),!1);for(let i=0;i<e.length;i++)if(e[i]===s)return!0;return e.push(s),!1}function r(s){if(t)e.delete(s);else for(let i=0;i<e.length;i++)if(e[i]===s){e.splice(i,1);break}}return[n,r]}function Xt(t,e=100,n=1/0){try{return Ji("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function n_(t,e=3,n=100*1024){const r=Xt(t,e);return o_(r)>n?n_(t,e-1,n):r}function Ji(t,e,n=1/0,r=1/0,s=t_()){const[i,o]=s;if(e==null||["number","boolean","string"].includes(typeof e)&&!BE(e))return e;const a=r_(t,e);if(!a.startsWith("[object "))return a;if(e.__sentry_skip_normalization__)return e;const c=typeof e.__sentry_override_normalization_depth__=="number"?e.__sentry_override_normalization_depth__:n;if(c===0)return a.replace("object ","");if(i(e))return"[Circular ~]";const u=e;if(u&&typeof u.toJSON=="function")try{const h=u.toJSON();return Ji("",h,c-1,r,s)}catch{}const d=Array.isArray(e)?[]:{};let l=0;const f=hd(e);for(const h in f){if(!Object.prototype.hasOwnProperty.call(f,h))continue;if(l>=r){d[h]="[MaxProperties ~]";break}const m=f[h];d[h]=Ji(h,m,c-1,r,s),l++}return o(e),d}function r_(t,e){try{if(t==="domain"&&e&&typeof e=="object"&&e._events)return"[Domain]";if(t==="domainEmitter")return"[DomainEmitter]";if(typeof global<"u"&&e===global)return"[Global]";if(typeof window<"u"&&e===window)return"[Window]";if(typeof document<"u"&&e===document)return"[Document]";if(ld(e))return"[VueViewModel]";if(UE(e))return"[SyntheticEvent]";if(typeof e=="number"&&e!==e)return"[NaN]";if(typeof e=="function")return`[Function: ${XE(e)}]`;if(typeof e=="symbol")return`[${String(e)}]`;if(typeof e=="bigint")return`[BigInt: ${String(e)}]`;const n=s_(e);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(n){return`**non-serializable** (${n})`}}function s_(t){const e=Object.getPrototypeOf(t);return e?e.constructor.name:"null prototype"}function i_(t){return~-encodeURI(t).split(/%..|./).length}function o_(t){return i_(JSON.stringify(t))}var It;(function(t){t[t.PENDING=0]="PENDING";const n=1;t[t.RESOLVED=n]="RESOLVED";const r=2;t[t.REJECTED=r]="REJECTED"})(It||(It={}));function tS(t){return new vt(e=>{e(t)})}function nS(t){return new vt((e,n)=>{n(t)})}class vt{constructor(e){vt.prototype.__init.call(this),vt.prototype.__init2.call(this),vt.prototype.__init3.call(this),vt.prototype.__init4.call(this),this._state=It.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(n){this._reject(n)}}then(e,n){return new vt((r,s)=>{this._handlers.push([!1,i=>{if(!e)r(i);else try{r(e(i))}catch(o){s(o)}},i=>{if(!n)s(i);else try{r(n(i))}catch(o){s(o)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new vt((n,r)=>{let s,i;return this.then(o=>{i=!1,s=o,e&&e()},o=>{i=!0,s=o,e&&e()}).then(()=>{if(i){r(s);return}n(s)})})}__init(){this._resolve=e=>{this._setResult(It.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(It.REJECTED,e)}}__init3(){this._setResult=(e,n)=>{if(this._state===It.PENDING){if(Co(n)){n.then(this._resolve,this._reject);return}this._state=e,this._value=n,this._executeHandlers()}}}__init4(){this._executeHandlers=()=>{if(this._state===It.PENDING)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===It.RESOLVED&&n[1](this._value),this._state===It.REJECTED&&n[2](this._value),n[0]=!0)})}}}const yd=1e3;function xs(){return Date.now()/yd}function a_(){const{performance:t}=Je;if(!t||!t.now)return xs;const e=Date.now()-t.now(),n=t.timeOrigin==null?e:t.timeOrigin;return()=>(n+t.now())/yd}const xo=a_(),rS=(()=>{const{performance:t}=Je;if(!t||!t.now)return;const e=3600*1e3,n=t.now(),r=Date.now(),s=t.timeOrigin?Math.abs(t.timeOrigin+n-r):e,i=s<e,o=t.timing&&t.timing.navigationStart,c=typeof o=="number"?Math.abs(o+n-r):e,u=c<e;return i||u?s<=c?t.timeOrigin:o:r})(),sS="baggage",vd="sentry-",c_=/^sentry-/,u_=8192;function Ed(t){if(!ys(t)&&!Array.isArray(t))return;let e={};if(Array.isArray(t))e=t.reduce((r,s)=>{const i=vc(s);for(const o of Object.keys(i))r[o]=i[o];return r},{});else{if(!t)return;e=vc(t)}const n=Object.entries(e).reduce((r,[s,i])=>{if(s.match(c_)){const o=s.slice(vd.length);r[o]=i}return r},{});if(Object.keys(n).length>0)return n}function iS(t){if(!t)return;const e=Object.entries(t).reduce((n,[r,s])=>(s&&(n[`${vd}${r}`]=s),n),{});return l_(e)}function vc(t){return t.split(",").map(e=>e.split("=").map(n=>decodeURIComponent(n.trim()))).reduce((e,[n,r])=>(e[n]=r,e),{})}function l_(t){if(Object.keys(t).length!==0)return Object.entries(t).reduce((e,[n,r],s)=>{const i=`${encodeURIComponent(n)}=${encodeURIComponent(r)}`,o=s===0?i:`${e},${i}`;return o.length>u_?(Lo&&rt.warn(`Not adding key: ${n} with val: ${r} to baggage header due to exceeding baggage size limits.`),e):o},"")}const d_=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function _d(t){if(!t)return;const e=t.match(d_);if(!e)return;let n;return e[3]==="1"?n=!0:e[3]==="0"&&(n=!1),{traceId:e[1],parentSampled:n,parentSpanId:e[2]}}function oS(t,e){const n=_d(t),r=Ed(e),{traceId:s,parentSpanId:i,parentSampled:o}=n||{};return n?{traceparentData:n,dynamicSamplingContext:r||{},propagationContext:{traceId:s||Ne(),parentSpanId:i||Ne().substring(16),spanId:Ne().substring(16),sampled:o,dsc:r||{}}}:{traceparentData:n,dynamicSamplingContext:void 0,propagationContext:{traceId:s||Ne(),spanId:Ne().substring(16)}}}function aS(t,e){const n=_d(t),r=Ed(e),{traceId:s,parentSpanId:i,parentSampled:o}=n||{};return n?{traceId:s||Ne(),parentSpanId:i||Ne().substring(16),spanId:Ne().substring(16),sampled:o,dsc:r||{}}:{traceId:s||Ne(),spanId:Ne().substring(16)}}function f_(t=Ne(),e=Ne().substring(16),n){let r="";return n!==void 0&&(r=n?"-1":"-0"),`${t}-${e}${r}`}const An=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Ms="production";function Mo(){return dd("globalEventProcessors",()=>[])}function cS(t){Mo().push(t)}function vs(t,e,n,r=0){return new vt((s,i)=>{const o=t[r];if(e===null||typeof o!="function")s(e);else{const a=o({...e},n);An&&o.id&&a===null&&rt.log(`Event processor "${o.id}" dropped event`),Co(a)?a.then(c=>vs(t,c,n,r+1).then(s)).then(null,i):vs(t,a,n,r+1).then(s).then(null,i)}})}function wd(t){const e=xo(),n={sid:Ne(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>p_(n)};return t&&Ir(n,t),n}function Ir(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||xo(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:Ne()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}function bd(t,e){let n={};t.status==="ok"&&(n={status:"exited"}),Ir(t,n)}function p_(t){return nn({sid:`${t.sid}`,init:t.init,started:new Date(t.started*1e3).toISOString(),timestamp:new Date(t.timestamp*1e3).toISOString(),status:t.status,errors:t.errors,did:typeof t.did=="number"||typeof t.did=="string"?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}})}const uS=0,h_=1;function g_(t){const{spanId:e,traceId:n}=t.spanContext(),{data:r,op:s,parent_span_id:i,status:o,tags:a,origin:c}=dr(t);return nn({data:r,op:s,parent_span_id:i,span_id:e,status:o,tags:a,trace_id:n,origin:c})}function lS(t){const{traceId:e,spanId:n}=t.spanContext(),r=Sd(t);return f_(e,n,r)}function dS(t){return typeof t=="number"?Ec(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Ec(t.getTime()):xo()}function Ec(t){return t>9999999999?t/1e3:t}function dr(t){return m_(t)?t.getSpanJSON():typeof t.toJSON=="function"?t.toJSON():{}}function m_(t){return typeof t.getSpanJSON=="function"}function Sd(t){const{traceFlags:e}=t.spanContext();return!!(e&h_)}function fS(t,e,n,r,s,i){const{normalizeDepth:o=3,normalizeMaxBreadth:a=1e3}=t,c={...e,event_id:e.event_id||n.event_id||Ne(),timestamp:e.timestamp||xs()},u=n.integrations||t.integrations.map(D=>D.name);y_(c,t),__(c,u),e.type===void 0&&v_(c,t.stackParser);const d=b_(r,n.captureContext);n.mechanism&&ZE(c,n.mechanism);const l=s&&s.getEventProcessors?s.getEventProcessors():[],f=$_().getScopeData();if(i){const D=i.getScopeData();wc(f,D)}if(d){const D=d.getScopeData();wc(f,D)}const h=[...n.attachments||[],...f.attachments];h.length&&(n.attachments=h),Nd(c,f);const m=[...l,...Mo(),...f.eventProcessors];return vs(m,c,n).then(D=>(D&&E_(D),typeof o=="number"&&o>0?w_(D,o,a):D))}function y_(t,e){const{environment:n,release:r,dist:s,maxValueLength:i=250}=e;"environment"in t||(t.environment="environment"in e?n:Ms),t.release===void 0&&r!==void 0&&(t.release=r),t.dist===void 0&&s!==void 0&&(t.dist=s),t.message&&(t.message=tr(t.message,i));const o=t.exception&&t.exception.values&&t.exception.values[0];o&&o.value&&(o.value=tr(o.value,i));const a=t.request;a&&a.url&&(a.url=tr(a.url,i))}const _c=new WeakMap;function v_(t,e){const n=Je._sentryDebugIds;if(!n)return;let r;const s=_c.get(e);s?r=s:(r=new Map,_c.set(e,r));const i=Object.keys(n).reduce((o,a)=>{let c;const u=r.get(a);u?c=u:(c=e(a),r.set(a,c));for(let d=c.length-1;d>=0;d--){const l=c[d];if(l.filename){o[l.filename]=n[a];break}}return o},{});try{t.exception.values.forEach(o=>{o.stacktrace.frames.forEach(a=>{a.filename&&(a.debug_id=i[a.filename])})})}catch{}}function E_(t){const e={};try{t.exception.values.forEach(r=>{r.stacktrace.frames.forEach(s=>{s.debug_id&&(s.abs_path?e[s.abs_path]=s.debug_id:s.filename&&(e[s.filename]=s.debug_id),delete s.debug_id)})})}catch{}if(Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const n=t.debug_meta.images;Object.keys(e).forEach(r=>{n.push({type:"sourcemap",code_file:r,debug_id:e[r]})})}function __(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function w_(t,e,n){if(!t)return null;const r={...t,...t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(s=>({...s,...s.data&&{data:Xt(s.data,e,n)}}))},...t.user&&{user:Xt(t.user,e,n)},...t.contexts&&{contexts:Xt(t.contexts,e,n)},...t.extra&&{extra:Xt(t.extra,e,n)}};return t.contexts&&t.contexts.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=Xt(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(s=>{const i=dr(s).data;return i&&(s.data=Xt(i,e,n)),s})),r}function b_(t,e){if(!e)return t;const n=t?t.clone():new Rt;return n.update(e),n}function S_(t){if(t)return T_(t)?{captureContext:t}:D_(t)?{captureContext:t}:t}function T_(t){return t instanceof Rt||typeof t=="function"}const I_=["user","level","extra","contexts","tags","fingerprint","requestSession","propagationContext"];function D_(t){return Object.keys(t).some(e=>I_.includes(e))}function pS(t,e){return Be().captureException(t,S_(e))}function hS(t,e){const n=typeof e=="string"?e:void 0,r=typeof e!="string"?{captureContext:e}:void 0;return Be().captureMessage(t,n,r)}function gS(t,e){return Be().captureEvent(t,e)}function mS(t){Be().configureScope(t)}function yS(t,e){Be().addBreadcrumb(t,e)}function vS(t,e){Be().setContext(t,e)}function ES(t){Be().setExtras(t)}function _S(t,e){Be().setExtra(t,e)}function wS(t){Be().setTags(t)}function bS(t,e){Be().setTag(t,e)}function N_(t){Be().setUser(t)}function O_(...t){const e=Be();if(t.length===2){const[n,r]=t;return n?e.withScope(()=>(e.getStackTop().scope=n,r(n))):e.withScope(r)}return e.withScope(t[0])}function SS(t){return j_(()=>t(ks()))}function TS(t,e){return O_(n=>(n.setSpan(t),e(n)))}function IS(t,e){return Be().startTransaction({...t},e)}async function DS(t){const e=$n();return e?e.flush(t):(An&&rt.warn("Cannot flush events. No client defined."),Promise.resolve(!1))}async function NS(t){const e=$n();return e?e.close(t):(An&&rt.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))}function OS(){return Be().lastEventId()}function $n(){return Be().getClient()}function AS(){return!!$n()}function Ps(){return Be().getScope()}function RS(t){const e=$n(),n=ks(),r=Ps(),{release:s,environment:i=Ms}=e&&e.getOptions()||{},{userAgent:o}=Je.navigator||{},a=wd({release:s,environment:i,user:r.getUser()||n.getUser(),...o&&{userAgent:o},...t}),c=n.getSession();return c&&c.status==="ok"&&Ir(c,{status:"exited"}),Td(),n.setSession(a),r.setSession(a),a}function Td(){const t=ks(),e=Ps(),n=e.getSession()||t.getSession();n&&bd(n),Id(),t.setSession(),e.setSession()}function Id(){const t=ks(),e=Ps(),n=$n(),r=e.getSession()||t.getSession();r&&n&&n.captureSession&&n.captureSession(r)}function CS(t=!1){if(t){Td();return}Id()}function Dd(t){return t.transaction}function A_(t,e,n){const r=e.getOptions(),{publicKey:s}=e.getDsn()||{},{segment:i}=n&&n.getUser()||{},o=nn({environment:r.environment||Ms,release:r.release,user_segment:i,public_key:s,trace_id:t});return e.emit&&e.emit("createDsc",o),o}function R_(t){const e=$n();if(!e)return{};const n=A_(dr(t).trace_id||"",e,Ps()),r=Dd(t);if(!r)return n;const s=r&&r._frozenDynamicSamplingContext;if(s)return s;const{sampleRate:i,source:o}=r.metadata;i!=null&&(n.sample_rate=`${i}`);const a=dr(r);return o&&o!=="url"&&(n.transaction=a.description),n.sampled=String(Sd(r)),e.emit&&e.emit("createDsc",n),n}function Nd(t,e){const{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:i}=e;C_(t,e),r&&M_(t,r),P_(t,n),L_(t,s),x_(t,i)}function wc(t,e){const{extra:n,tags:r,user:s,contexts:i,level:o,sdkProcessingMetadata:a,breadcrumbs:c,fingerprint:u,eventProcessors:d,attachments:l,propagationContext:f,transactionName:h,span:m}=e;Gn(t,"extra",n),Gn(t,"tags",r),Gn(t,"user",s),Gn(t,"contexts",i),Gn(t,"sdkProcessingMetadata",a),o&&(t.level=o),h&&(t.transactionName=h),m&&(t.span=m),c.length&&(t.breadcrumbs=[...t.breadcrumbs,...c]),u.length&&(t.fingerprint=[...t.fingerprint,...u]),d.length&&(t.eventProcessors=[...t.eventProcessors,...d]),l.length&&(t.attachments=[...t.attachments,...l]),t.propagationContext={...t.propagationContext,...f}}function Gn(t,e,n){if(n&&Object.keys(n).length){t[e]={...t[e]};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[e][r]=n[r])}}function C_(t,e){const{extra:n,tags:r,user:s,contexts:i,level:o,transactionName:a}=e,c=nn(n);c&&Object.keys(c).length&&(t.extra={...c,...t.extra});const u=nn(r);u&&Object.keys(u).length&&(t.tags={...u,...t.tags});const d=nn(s);d&&Object.keys(d).length&&(t.user={...d,...t.user});const l=nn(i);l&&Object.keys(l).length&&(t.contexts={...l,...t.contexts}),o&&(t.level=o),a&&(t.transaction=a)}function L_(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function x_(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}function M_(t,e){t.contexts={trace:g_(e),...t.contexts};const n=Dd(e);if(n){t.sdkProcessingMetadata={dynamicSamplingContext:R_(e),...t.sdkProcessingMetadata};const r=dr(n).description;r&&(t.tags={transaction:r,...t.tags})}}function P_(t,e){t.fingerprint=t.fingerprint?e_(t.fingerprint):[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint&&!t.fingerprint.length&&delete t.fingerprint}const k_=100;let bi;class Rt{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=bc()}static clone(e){return e?e.clone():new Rt}clone(){const e=new Rt;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._span=this._span,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e}setClient(e){this._client=e}getClient(){return this._client}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,segment:void 0,username:void 0},this._session&&Ir(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,n){return this._tags={...this._tags,[e]:n},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,n){return this._extra={...this._extra,[e]:n},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,n){return n===null?delete this._contexts[e]:this._contexts[e]=n,this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const e=this._span;return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const n=typeof e=="function"?e(this):e;if(n instanceof Rt){const r=n.getScopeData();this._tags={...this._tags,...r.tags},this._extra={...this._extra,...r.extra},this._contexts={...this._contexts,...r.contexts},r.user&&Object.keys(r.user).length&&(this._user=r.user),r.level&&(this._level=r.level),r.fingerprint.length&&(this._fingerprint=r.fingerprint),n.getRequestSession()&&(this._requestSession=n.getRequestSession()),r.propagationContext&&(this._propagationContext=r.propagationContext)}else if(Ro(n)){const r=e;this._tags={...this._tags,...r.tags},this._extra={...this._extra,...r.extra},this._contexts={...this._contexts,...r.contexts},r.user&&(this._user=r.user),r.level&&(this._level=r.level),r.fingerprint&&(this._fingerprint=r.fingerprint),r.requestSession&&(this._requestSession=r.requestSession),r.propagationContext&&(this._propagationContext=r.propagationContext)}return this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=bc(),this}addBreadcrumb(e,n){const r=typeof n=="number"?n:k_;if(r<=0)return this;const s={timestamp:xs(),...e},i=this._breadcrumbs;return i.push(s),this._breadcrumbs=i.length>r?i.slice(-r):i,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this.getScopeData().attachments}clearAttachments(){return this._attachments=[],this}getScopeData(){const{_breadcrumbs:e,_attachments:n,_contexts:r,_tags:s,_extra:i,_user:o,_level:a,_fingerprint:c,_eventProcessors:u,_propagationContext:d,_sdkProcessingMetadata:l,_transactionName:f,_span:h}=this;return{breadcrumbs:e,attachments:n,contexts:r,tags:s,extra:i,user:o,level:a,fingerprint:c||[],eventProcessors:u,propagationContext:d,sdkProcessingMetadata:l,transactionName:f,span:h}}applyToEvent(e,n={},r=[]){Nd(e,this.getScopeData());const s=[...r,...Mo(),...this._eventProcessors];return vs(s,e,n)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){const r=n&&n.event_id?n.event_id:Ne();if(!this._client)return rt.warn("No client configured on scope - will not capture exception!"),r;const s=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:s,...n,event_id:r},this),r}captureMessage(e,n,r){const s=r&&r.event_id?r.event_id:Ne();if(!this._client)return rt.warn("No client configured on scope - will not capture message!"),s;const i=new Error(e);return this._client.captureMessage(e,n,{originalException:e,syntheticException:i,...r,event_id:s},this),s}captureEvent(e,n){const r=n&&n.event_id?n.event_id:Ne();return this._client?(this._client.captureEvent(e,{...n,event_id:r},this),r):(rt.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}}function $_(){return bi||(bi=new Rt),bi}function bc(){return{traceId:Ne(),spanId:Ne().substring(16)}}const F_="7.120.3",Od=parseFloat(F_),U_=100;class Ad{constructor(e,n,r,s=Od){this._version=s;let i;n?i=n:(i=new Rt,i.setClient(e));let o;r?o=r:(o=new Rt,o.setClient(e)),this._stack=[{scope:i}],e&&this.bindClient(e),this._isolationScope=o}isOlderThan(e){return this._version<e}bindClient(e){const n=this.getStackTop();n.client=e,n.scope.setClient(e),e&&e.setupIntegrations&&e.setupIntegrations()}pushScope(){const e=this.getScope().clone();return this.getStack().push({client:this.getClient(),scope:e}),e}popScope(){return this.getStack().length<=1?!1:!!this.getStack().pop()}withScope(e){const n=this.pushScope();let r;try{r=e(n)}catch(s){throw this.popScope(),s}return Co(r)?r.then(s=>(this.popScope(),s),s=>{throw this.popScope(),s}):(this.popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,n){const r=this._lastEventId=n&&n.event_id?n.event_id:Ne(),s=new Error("Sentry syntheticException");return this.getScope().captureException(e,{originalException:e,syntheticException:s,...n,event_id:r}),r}captureMessage(e,n,r){const s=this._lastEventId=r&&r.event_id?r.event_id:Ne(),i=new Error(e);return this.getScope().captureMessage(e,n,{originalException:e,syntheticException:i,...r,event_id:s}),s}captureEvent(e,n){const r=n&&n.event_id?n.event_id:Ne();return e.type||(this._lastEventId=r),this.getScope().captureEvent(e,{...n,event_id:r}),r}lastEventId(){return this._lastEventId}addBreadcrumb(e,n){const{scope:r,client:s}=this.getStackTop();if(!s)return;const{beforeBreadcrumb:i=null,maxBreadcrumbs:o=U_}=s.getOptions&&s.getOptions()||{};if(o<=0)return;const c={timestamp:xs(),...e},u=i?fd(()=>i(c,n)):c;u!==null&&(s.emit&&s.emit("beforeAddBreadcrumb",u,n),r.addBreadcrumb(u,o))}setUser(e){this.getScope().setUser(e),this.getIsolationScope().setUser(e)}setTags(e){this.getScope().setTags(e),this.getIsolationScope().setTags(e)}setExtras(e){this.getScope().setExtras(e),this.getIsolationScope().setExtras(e)}setTag(e,n){this.getScope().setTag(e,n),this.getIsolationScope().setTag(e,n)}setExtra(e,n){this.getScope().setExtra(e,n),this.getIsolationScope().setExtra(e,n)}setContext(e,n){this.getScope().setContext(e,n),this.getIsolationScope().setContext(e,n)}configureScope(e){const{scope:n,client:r}=this.getStackTop();r&&e(n)}run(e){const n=Sc(this);try{e(this)}finally{Sc(n)}}getIntegration(e){const n=this.getClient();if(!n)return null;try{return n.getIntegration(e)}catch{return An&&rt.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,n){const r=this._callExtensionMethod("startTransaction",e,n);return An&&!r&&(this.getClient()?rt.warn(`Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':
|
|
365
|
-
Sentry.addTracingExtensions();
|
|
366
|
-
Sentry.init({...});
|
|
367
|
-
`):rt.warn("Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'")),r}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){const n=this.getStackTop().scope,r=n.getSession();r&&bd(r),this._sendSessionUpdate(),n.setSession()}startSession(e){const{scope:n,client:r}=this.getStackTop(),{release:s,environment:i=Ms}=r&&r.getOptions()||{},{userAgent:o}=Je.navigator||{},a=wd({release:s,environment:i,user:n.getUser(),...o&&{userAgent:o},...e}),c=n.getSession&&n.getSession();return c&&c.status==="ok"&&Ir(c,{status:"exited"}),this.endSession(),n.setSession(a),a}shouldSendDefaultPii(){const e=this.getClient(),n=e&&e.getOptions();return!!(n&&n.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:n}=this.getStackTop(),r=e.getSession();r&&n&&n.captureSession&&n.captureSession(r)}_callExtensionMethod(e,...n){const s=Dr().__SENTRY__;if(s&&s.extensions&&typeof s.extensions[e]=="function")return s.extensions[e].apply(this,n);An&&rt.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function Dr(){return Je.__SENTRY__=Je.__SENTRY__||{extensions:{},hub:void 0},Je}function Sc(t){const e=Dr(),n=Wi(e);return Rd(e,t),n}function Be(){const t=Dr();if(t.__SENTRY__&&t.__SENTRY__.acs){const e=t.__SENTRY__.acs.getCurrentHub();if(e)return e}return B_(t)}function ks(){return Be().getIsolationScope()}function B_(t=Dr()){return(!V_(t)||Wi(t).isOlderThan(Od))&&Rd(t,new Ad),Wi(t)}function j_(t,e={}){const n=Dr();return n.__SENTRY__&&n.__SENTRY__.acs?n.__SENTRY__.acs.runWithAsyncContext(t,e):t()}function V_(t){return!!(t&&t.__SENTRY__&&t.__SENTRY__.hub)}function Wi(t){return dd("hub",()=>new Ad,t)}function Rd(t,e){if(!t)return!1;const n=t.__SENTRY__=t.__SENTRY__||{};return n.hub=e,!0}const G_=window.__VITE_ENVS.PH_CONNECT_RENOWN_URL||"https://www.renown.id",z_=window.__VITE_ENVS.PH_CONNECT_RENOWN_NETWORK_ID||"eip155",q_=window.__VITE_ENVS.PH_CONNECT_RENOWN_CHAIN_ID||"1",pn={},Y_=Symbol((pn?"production":void 0)!=="production"?"RESET":""),Cd=t=>typeof(t==null?void 0:t.then)=="function";function H_(t=()=>{try{return window.localStorage}catch(n){(pn?"production":void 0)!=="production"&&typeof window<"u"&&console.warn(n);return}},e){var n;let r,s;const i={getItem:(c,u)=>{var d,l;const f=m=>{if(m=m||"",r!==m){try{s=JSON.parse(m,void 0)}catch{return u}r=m}return s},h=(l=(d=t())==null?void 0:d.getItem(c))!=null?l:null;return Cd(h)?h.then(f):f(h)},setItem:(c,u)=>{var d;return(d=t())==null?void 0:d.setItem(c,JSON.stringify(u,void 0))},removeItem:c=>{var u;return(u=t())==null?void 0:u.removeItem(c)}},o=c=>(u,d,l)=>c(u,f=>{let h;try{h=JSON.parse(f||"")}catch{h=l}d(h)});let a;try{a=(n=t())==null?void 0:n.subscribe}catch{}return!a&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(a=(c,u)=>{if(!(t()instanceof window.Storage))return()=>{};const d=l=>{l.storageArea===t()&&l.key===c&&u(l.newValue)};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}}),a&&(i.subscribe=o(a)),i}const J_=H_();function Ld(t,e,n=J_,r){const s=Pe(e);return(pn?"production":void 0)!=="production"&&(s.debugPrivate=!0),s.onMount=o=>{o(n.getItem(t,e));let a;return n.subscribe&&(a=n.subscribe(t,o,e)),a},Pe(o=>o(s),(o,a,c)=>{const u=typeof c=="function"?c(o(s)):c;return u===Y_?(a(s,e),n.removeItem(t)):Cd(u)?u.then(d=>(a(s,d),n.setItem(t,d))):(a(s,u),n.setItem(t,u))})}const Si=new WeakMap,W_=(t,e)=>(Si.has(e)?Si:Si.set(e,t())).get(e),Q_=t=>typeof(t==null?void 0:t.then)=="function",Tc={state:"loading"};function LS(t){return W_(()=>{const e=new WeakMap,n=Pe(0);(pn?"production":void 0)!=="production"&&(n.debugPrivate=!0);const r=Pe((s,{setSelf:i})=>{s(n);let o;try{o=s(t)}catch(d){return{state:"hasError",error:d}}if(!Q_(o))return{state:"hasData",data:o};const a=o,c=e.get(a);if(c)return c;a.then(d=>{e.set(a,{state:"hasData",data:d}),i()},d=>{e.set(a,{state:"hasError",error:d}),i()});const u=e.get(a);return u||(e.set(a,Tc),Tc)},(s,i)=>{i(n,o=>o+1)});return(pn?"production":void 0)!=="production"&&(r.debugPrivate=!0),Pe(s=>s(r))},t)}const Ic=(t,e,n)=>(e.has(n)?e:e.set(n,t())).get(n),K_=new WeakMap,X_=(t,e,n)=>{const r=Ic(()=>new WeakMap,K_,e);return Ic(t,r,n)},Z_=t=>typeof(t==null?void 0:t.then)=="function",ew=()=>{};function tw(t,e=ew){return X_(()=>{const n=new WeakMap,r=new WeakMap,s=Pe(0);(pn?"production":void 0)!=="production"&&(s.debugPrivate=!0);const i=Pe((o,{setSelf:a})=>{o(s);const c=o(i),u=o(t);if(!Z_(u))return{v:u};if(u!==(c==null?void 0:c.p)&&u.then(d=>{r.set(u,d),a()},d=>{n.set(u,d),a()}),n.has(u))throw n.get(u);return r.has(u)?{p:u,v:r.get(u)}:c&&"v"in c?{p:u,f:e(c.v),v:c.v}:{p:u,f:e()}},(o,a)=>{a(s,c=>c+1)});return i.init=void 0,(pn?"production":void 0)!=="production"&&(i.debugPrivate=!0),Pe(o=>{const a=o(i);return"f"in a?a.f:a.v},(o,a,...c)=>a(t,...c))},t,e)}function nw(t){const e=Pe(void 0);return delete e.init,Object.defineProperty(e,"init",{get(){return t()}}),e}const rw=gr.routerBasename+"external-packages.js",sw=window.__VITE_ENVS.PROD;async function iw(){try{return sw?(await import(rw)).default??[]:[]}catch(t){return console.error(t),[]}}const xd=Pe(async()=>typeof await Cs()<"u");xd.debugLabel="hmrAvailableAtom";const xS=()=>jt(xd),Nr=nw(iw);Nr.debugLabel="externalPackagesAtomInConnect";let Dc;Nr.onMount=t=>{Dc||(Dc=xE(e=>{t(e)}))};const ow=()=>jt(Nr),aw={id:"powerhouse/common",name:"Generic Drive Explorer",driveEditor:"GenericDriveExplorer"},Md=Pe(async t=>{const e=await t(Nr);return[aw,...e.map(n=>n.manifest.apps).filter(n=>n!==void 0).flat()]});Md.debugLabel="appsAtomInConnect";const cw=()=>jt(Md),MS=()=>{const t=cw();return ae(e=>{if(!e)return;const n=t.find(r=>r.driveEditor===e);return n==null?void 0:n.name},[t])},PS=t=>{const e=ow();return hr(()=>{if(!t)return;const n=e.find(r=>{var s;return(s=r.manifest.apps)==null?void 0:s.find(i=>i.driveEditor===t)});return n==null?void 0:n.editors.find(r=>r.config.id===t)},[e,t])};let Br;async function uw(){const{ConnectCrypto:t}=await Bt(async()=>{const{ConnectCrypto:r}=await import("./index.CTYq_dOR.js");return{ConnectCrypto:r}},__vite__mapDeps([0,1,2,3,4]),import.meta.url),{BrowserKeyStorage:e}=await Bt(async()=>{const{BrowserKeyStorage:r}=await import("./index.CTYq_dOR.js");return{BrowserKeyStorage:r}},__vite__mapDeps([0,1,2,3,4]),import.meta.url),n=new t(new e);return await n.did(),n}function Zt(){return window.connectCrypto?Promise.resolve(window.connectCrypto):Br||(Br=uw(),Br)}function Po(){return hr(()=>({async regenerateDid(){return(await Zt()).regenerateDid()},async did(){return(await Zt()).did()},sign:async t=>await(await Zt()).sign(t),async getIssuer(){return(await Zt()).getIssuer()},async getBearerToken(t,e,n=!1){return(await Zt()).getBearerToken(t,e,n)}}),[])}const Pd=Pe(void 0);Pd.debugLabel="didAtomInConnect";function lw(){const[t,e]=an(Pd);return Ce(()=>{t||Zt().then(n=>n.did()).then(n=>e(n)).catch(pe.error)}),t}const kd=Pe("idle");kd.debugLabel="renownStatusAtomInConnect";const $d=Pe(window.renown?Promise.resolve(window.renown):void 0);$d.debugLabel="renownAtomInConnect";function $s(){const[t,e]=an($d),[n,r]=an(kd),{did:s}=Po();async function i(o){r("loading");try{const a=await o();if(!a){r("error");return}const{initRenownBrowser:c}=await Bt(async()=>{const{initRenownBrowser:l}=await import("./index.DNX0QOJs.js").then(f=>f.b);return{initRenownBrowser:l}},__vite__mapDeps([2,1]),import.meta.url),u=c(a),d={user:function(){return Promise.resolve(u.user)},login:function(l){return u.login(l)},logout(){return Promise.resolve(u.logout())},on:{user(l){return u.on("user",l)}}};return r("finished"),d}catch(a){console.error("Error initializing renown:",a instanceof Error?a.message:"Unknown error"),r("error");return}}return!t&&n==="idle"&&e(i(s)),t}function dw(){if(console&&console.warn){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];typeof e[0]=="string"&&(e[0]=`react-i18next:: ${e[0]}`),console.warn(...e)}}const Nc={};function Qi(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];typeof e[0]=="string"&&Nc[e[0]]||(typeof e[0]=="string"&&(Nc[e[0]]=new Date),dw(...e))}const Fd=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}};function Oc(t,e,n){t.loadNamespaces(e,Fd(t,n))}function Ac(t,e,n,r){typeof n=="string"&&(n=[n]),n.forEach(s=>{t.options.ns.indexOf(s)<0&&t.options.ns.push(s)}),t.loadLanguages(e,Fd(t,r))}function fw(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=e.languages[0],s=e.options?e.options.fallbackLng:!1,i=e.languages[e.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(a,c)=>{const u=e.services.backendConnector.state[`${a}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!o(e.isLanguageChangingTo,t)?!1:!!(e.hasResourceBundle(r,t)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||o(r,t)&&(!s||o(i,t)))}function pw(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!e.languages||!e.languages.length?(Qi("i18n.languages were undefined or empty",e.languages),!0):e.options.ignoreJSONStructure!==void 0?e.hasLoadedNamespace(t,{lng:n.lng,precheck:(s,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!i(s.isLanguageChangingTo,t))return!1}}):fw(t,e,n)}const hw=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,gw={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},mw=t=>gw[t],yw=t=>t.replace(hw,mw);let Ki={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:yw};function kS(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ki={...Ki,...t}}function vw(){return Ki}let Ud;function $S(t){Ud=t}function Ew(){return Ud}const _w=Xi();class ww{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const bw=(t,e)=>{const n=on();return Ce(()=>{n.current=t},[t,e]),n.current};function Bd(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=e,{i18n:r,defaultNS:s}=Zi(_w)||{},i=n||r||Ew();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new ww),!i){Qi("You will need to pass in an i18next instance by using initReactI18next");const R=(N,X)=>typeof X=="string"?X:X&&typeof X=="object"&&typeof X.defaultValue=="string"?X.defaultValue:Array.isArray(N)?N[N.length-1]:N,Q=[R,{},!1];return Q.t=R,Q.i18n={},Q.ready=!1,Q}i.options.react&&i.options.react.wait!==void 0&&Qi("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...vw(),...i.options.react,...e},{useSuspense:a,keyPrefix:c}=o;let u=s||i.options&&i.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(u);const d=(i.isInitialized||i.initializedStoreOnce)&&u.every(R=>pw(R,i,o));function l(){return i.getFixedT(e.lng||null,o.nsMode==="fallback"?u:u[0],c)}const[f,h]=Rn(l);let m=u.join();e.lng&&(m=`${e.lng}${m}`);const E=bw(m),D=on(!0);Ce(()=>{const{bindI18n:R,bindI18nStore:Q}=o;D.current=!0,!d&&!a&&(e.lng?Ac(i,e.lng,u,()=>{D.current&&h(l)}):Oc(i,u,()=>{D.current&&h(l)})),d&&E&&E!==m&&D.current&&h(l);function N(){D.current&&h(l)}return R&&i&&i.on(R,N),Q&&i&&i.store.on(Q,N),()=>{D.current=!1,R&&i&&R.split(" ").forEach(X=>i.off(X,N)),Q&&i&&Q.split(" ").forEach(X=>i.store.off(X,N))}},[i,m]);const P=on(!0);Ce(()=>{D.current&&!P.current&&h(l),P.current=!1},[i,c]);const B=[f,i,d];if(B.t=f,B.i18n=i,B.ready=d,d||!d&&!a)return B;throw new Promise(R=>{e.lng?Ac(i,e.lng,u,()=>R()):Oc(i,u,()=>R())})}const Sw="connect";function Ti(t,e){const{type:n="default",containerId:r=Sw,...s}=e||{};return cp(t,{type:n,containerId:r,...s})}const en=gr.routerBasename,Tw=(t,e,n,r)=>{const s=Ld(`${en}:${t}`,e,void 0);return s.debugLabel=`storageAtom:${en}:${t}`,s},FS=(t,e,n)=>{const r=Ld(t,e,{getItem(s,i){const o=localStorage.getItem(`${en}:${s}`);return o?JSON.parse(o):i},setItem(s,i){localStorage.setItem(`${en}:${s}`,JSON.stringify(i)),n(i)},removeItem(s){localStorage.removeItem(`${en}:${s}`)},subscribe(s,i){if(typeof window.addEventListener>"u")return()=>null;function o(a){a.storageArea===localStorage&&a.key===`${en}:${s}`&&i(a.newValue??"")}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)}});return r.debugLabel=`storageAtomWithCallback:${en}:${t}`,r},Iw=[qu,up],Dw=Iw;function Nw(...t){const e=new Map;for(const n of t)e.set(n.documentModel.id,n);return Array.from(e.values())}function Ow(t){return t.map(e=>e.documentModels).reduce((e,n)=>e.concat(n),[])}const ko=Pe(async t=>{const e=await t(Nr),n=Ow(e),r=[];try{const o=await import("@powerhousedao/vetra/document-models");r.push(o.VetraPackage,o.DocumentEditor)}catch(i){console.warn("Vetra document models not available:",i)}return Nw(...Dw,...r,...n)});ko.debugLabel="documentModelsAtomInConnect";const jd=tw(ko);jd.debugLabel="unwrappedDocumentModelsAtomInConnect";const Vd=()=>jt(jd);function Aw(t,e){return e==null?void 0:e.find(n=>n.documentModel.id===t)}const Rw=()=>{const t=Vd();return e=>Aw(e,t)},US=()=>{const t=Vd(),{config:e}=Qw(),{enabledEditors:n,disabledEditors:r}=e.editors;if(!t)return;const s=t.filter(i=>i.documentModel.id!=="powerhouse/document-drive");return n==="*"?t:r==="*"?[]:r?s.filter(i=>!r.includes(i.documentModel.id)):n?s.filter(i=>n.includes(i.documentModel.id)):s};async function Cw(t,e){await xw(t,e);const n=await t.initialize(),r=n==null?void 0:n.at(0);if(r)throw r}function Lw(){const t=gr.drives.sections.LOCAL.enabled,e=Pn(),n=Tr(),r=on(!1);Ce(()=>{r.current||t&&e!==void 0&&n!==void 0&&(n.length>0||(e.addDrive({id:Et(),slug:"my-local-drive",global:{name:"My Local Drive",icon:null},local:{availableOffline:!1,sharingType:"private",listeners:[],triggers:[]}}).catch(pe.error),r.current=!0))},[t,e,n])}async function xw(t,e){const n=await(e==null?void 0:e.user()),r=await Zt();n!=null&&n.address&&t.setGenerateJwtHandler(async s=>r.getBearerToken(s,n.address))}async function Mw(t,e,n){const r=RE(e,t);return await Cw(r,n),r}const $o=Pe(AE(gr.routerBasename));$o.debugLabel="storageAtomInConnect";const Pw=()=>jt($o);let jr=!1;const Gd=Pe(void 0);Gd.debugLabel="userAtomInConnect";const zd=()=>{const[t,e]=an(Gd),n=$s();return Ce(()=>{var s;let r=null;if(t){const{credential:i,...o}=t;r={id:o.did,username:(s=o.ens)==null?void 0:s.name,...o}}N_(r)},[t]),Ce(()=>{if(jr)return;jr=!0,n==null||n.user().then(s=>{e(s||null)}).catch(()=>{e(null)});const r=n==null?void 0:n.on.user(s=>{e(s||null)});return()=>{r==null||r(),jr=!1}},[n,jr]),t};async function Rc(t,e){if(!t)return;const n=t.split("/");n.pop(),n.pop(),n.push("drives");const r=n.join("/");return(await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
|
|
368
|
-
query getDriveIdBySlug($slug: String!) {
|
|
369
|
-
driveIdBySlug(slug: $slug)
|
|
370
|
-
}
|
|
371
|
-
`,variables:{slug:e}})})).json()).data.driveIdBySlug}function kw(t){return t.split("/").pop()}function $w(t){const e=t.split("/");return e.pop(),e.pop(),e.push("graphql"),e.join("/")}function Fw(t){const e=ql(t,"document");return`query getDocument($documentId: PHID!, $driveId: String) {
|
|
372
|
-
${t.name} {
|
|
373
|
-
getDocument(docId: $documentId, driveId: $driveId) {
|
|
374
|
-
id
|
|
375
|
-
created
|
|
376
|
-
lastModified
|
|
377
|
-
name
|
|
378
|
-
revision
|
|
379
|
-
state {
|
|
380
|
-
${e}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}`}function Uw(t,e,n){const r=kw(t),s=Fw(n),i={documentId:e,driveId:r};return dp.compressToEncodedURIComponent(JSON.stringify({document:s.trim(),variables:JSON.stringify(i,null,2)}))}function BS(t,e,n){const r=$w(t),s=lp(n.name),i=Uw(t,e,n);return`${r}/${s}?explorerURLState=${i}`}const Bw=()=>{const{t}=Bd();return Zr("div",{children:[yt("p",{className:"font-medium",children:t("notifications.reloadApp")}),Zr("button",{onClick:()=>location.reload(),className:"underline decoration-solid underline-offset-2",children:[t("common.reloadConnect")," 🔄"]})]})},qd=Pe("initial");qd.debugLabel="loginStatusAtomInConnect";const jw=()=>{const[t,e]=an(qd),n=zd(),r=$s(),{did:s,getBearerToken:i}=Po(),o=Pn(),a=ae(async()=>{var f;const d=await s(),l=new URL(G_);if(l.searchParams.set("connect",d),l.searchParams.set("network",z_),l.searchParams.set("chain",q_),window.electronAPI){const h=await window.electronAPI.protocol();l.searchParams.set("deeplink",h),await window.electronAPI.openURL(l.toString())}else{const h=new URL(window.location.pathname,window.location.origin);l.searchParams.set("returnUrl",h.toJSON()),(f=window.open(l,"_self"))==null||f.focus()}},[s]),c=ae(async d=>{if(r)try{e("checking");const l=await r.user();if((l==null?void 0:l.did)===d)return e("authorized"),l;const f=await r.login(d);if(f)return e("authorized"),o==null||o.setGenerateJwtHandler(async h=>i(h,f.address)),f;e("not-authorized")}catch(l){e("not-authorized"),pe.error(l)}},[r,o,i]);Ce(()=>{n&&t!=="authorized"&&e("authorized")},[n,t]);const u=ae(async()=>{e("initial"),await(r==null?void 0:r.logout()),o==null||o.removeJwtHandler()},[r,o]);return hr(()=>({openRenown:a,user:n,status:n?"authorized":t,login:r?c:void 0,logout:u}),[r,a,n,t,c,u])};function Vw(){const{user:t,status:e}=jw(),n=window.__VITE_ENVS.PH_CONNECT_ARBITRUM_ALLOW_LIST,r=window.__VITE_ENVS.PH_CONNECT_RWA_ALLOW_LIST,s=!!n&&n!=="",i=!!r&&r!=="";if(s&&i)throw new Error("Both Arbitrum and RWA allow lists are defined. Please only define one.");if(!s&&!i)return{isAllowed:!0,allowListType:"none"};if(t!==void 0){if(s){const o=n.split(",");return e!=="authorized"||!t?{isAllowed:!1,allowListType:"arbitrum"}:o.includes(t.address)?{isAllowed:!0,allowListType:"arbitrum"}:{isAllowed:!1,allowListType:"arbitrum"}}if(i){const o=r.split(",");return e!=="authorized"||!t?{isAllowed:!1,allowListType:"rwa"}:o.includes(t.address)?{isAllowed:!0,allowListType:"rwa"}:{isAllowed:!1,allowListType:"rwa"}}return{isAllowed:!0,allowListType:"none"}}}function Gw(){const t=Vw();if(!t)return;const{allowListType:e,isAllowed:n}=t;return e==="arbitrum"?{isAllowedToCreateDocuments:n,isAllowedToEditDocuments:!0}:e==="rwa"?{isAllowedToCreateDocuments:n,isAllowedToEditDocuments:n}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}function Cc(t,e){const n={};for(const o of Object.keys(t))n[o]=new Set(t[o].map(a=>a.index));const r=[];for(const o of e){const a=o.scope,c=o.index;if(n[a].has(c)){const u=t[a].find(l=>l.index===c),d=r.find(l=>l.index===c);console.warn("skipping duplicate operation"),u&&console.warn("duplicate existing operation",u),d&&console.warn("duplicate new operation",d);continue}r.push(o),n[a].add(c)}const s=new Set,i=[];for(const[o,a]of Object.entries(t))for(const c of a){const u=c.hash;if(s.has(u)){console.warn("skipping existing operation with duplicate hash in scope",o,c);continue}s.add(u)}for(const o of r){const a=o.hash;if(s.has(a)){console.warn("skipping new operation with duplicate hash in scope",o.scope,o);continue}s.add(a),i.push(o)}return i}function Yd(){const t=wt(["useDocumentDriveServer",Math.floor(Math.random()*999).toString()]),{isAllowedToCreateDocuments:e}=Gw()||{isAllowedToCreateDocuments:!1},n=zd()||void 0,r=lw(),{sign:s}=Po(),i=Pn(),o=Pw(),a=Rw(),c=Tr(),u=ed(),d=ae(async(j,q)=>i?await i.getDocument(j,q):void 0,[i]),l=ae(async(j,q)=>{if(!i)return;const V=c==null?void 0:c.find(ue=>ue.header.id===j);if(!V)return;const oe={...V},S=ar(V,LE(q,r,n)),W=q.scope,K=S.operations[W].findLast(ue=>ue.type===q.type);if(!K)throw new Error("There was an error applying the operation");const me=await CE(K,s,j,oe,ar,n);try{const ue=await i.queueOperation(j,me);return ue.status!=="SUCCESS"&&t.error(ue.error),ue.document}catch(ue){return t.error(ue),V}},[i,c,s,n,r]),f=ae(async(j,q)=>{if(!i)return;const V=await i.getDrive(j),oe=Cc(V.operations,q),S=await i.queueOperations(j,oe);return S.status!=="SUCCESS"&&t.error(S.error),S.document},[i]),h=ae(async(j,q)=>{if(!i)return;const V=await i.getDocument(j),oe=Cc(V.operations,q),S=await i.queueOperations(j,oe);return S.status!=="SUCCESS"&&t.error(S.error),S.document},[i]),m=ae(async(j,q,V,oe,S,W)=>{if(!i)throw new Error("Reactor is not loaded");if(!e)throw new Error("User is not allowed to create documents");if(!(c==null?void 0:c.find(St=>St.header.id===j)))return;const K=W??Et(),me=a(V);if(!me)throw new Error(`Document model module for type ${V} not found`);const ue=me.utils.createDocument({...S});ue.header=Vr(K,V),ue.header.name=q,await i.addDocument(ue);const ve=Mu({id:K,name:q,documentType:V,parentFolder:oe??null}),Xe=await l(j,ve),bt=Xe==null?void 0:Xe.state.global.nodes.find(St=>St.id===K);if(!bt||!ir(bt))throw new Error("There was an error adding document");return bt},[l,c,e]),E=ae(async(j,q,V,oe)=>{if(t.verbose(`addFile(drive: ${q}, name: ${V}, folder: ${oe})`),!i)return;if(!e)throw new Error("User is not allowed to create files");const S=await TE(j,a),W={header:S.header,history:S.history,initialState:S.initialState,state:S.initialState.state,operations:{global:[],local:[]},clipboard:[]},U=await m(q,V||(typeof j=="string"?S.header.name:j.name),S.header.documentType,oe,W);if(!U)throw new Error("There was an error adding file");c==null||c.find(K=>K.header.id===q),bE(U.id,S,h,{}).catch(K=>{throw K})},[m,h,a,c,e,i]),D=ae(async(j,q,V,oe,S)=>{if(!e)throw new Error("User is not allowed to update files");const W=await l(j,$u({id:q,name:oe||void 0,parentFolder:S,documentType:V})),U=W==null?void 0:W.state.global.nodes.find(K=>K.id===q);if(!U||!ir(U))throw new Error("There was an error updating document");return U},[l,e]),P=ae(async(j,q,V)=>{if(!e)throw new Error("User is not allowed to create folders");const oe=Et(),S=await l(j,Pu({id:oe,name:q,parentFolder:V})),W=S==null?void 0:S.state.global.nodes.find(U=>U.id===oe);if(!W||!co(W))throw new Error("There was an error adding folder");return W},[l,e]),B=ae(async(j,q)=>{if(!e)throw new Error("User is not allowed to delete documents");await l(j,ku({id:q}))},[l,e]),R=ae(async(j,q,V)=>{if(!e)throw new Error("User is not allowed to rename documents");const oe=await l(j,Fu({id:q,name:V})),S=oe==null?void 0:oe.state.global.nodes.find(W=>W.id===q);if(!S)throw new Error("There was an error renaming node");return S},[l,e]),Q=ae(async(j,q)=>{if(!e)throw new Error("User is not allowed to move documents");u!=null&&u.header.id&&await l(u.header.id,Bu({srcFolder:j.id,targetParentFolder:q==null?void 0:q.id}))},[l,e,u==null?void 0:u.header.id]),N=ae(async(j,q)=>{if(!i||!u)return;if(!e)throw new Error("User is not allowed to copy documents");const oe=Cu({srcId:j.id,targetParentFolder:q==null?void 0:q.id,targetName:j.name},()=>Et(),u.state.global.nodes).map(W=>Uu(W)),S=await i.addActions(u.header.id,oe);return S.status!=="SUCCESS"&&t.error(`Error copying files: ${S.status}`,S.error),S.document},[e,i,u]),X=ae(async(j,q)=>{if(!i)return;if(!e)throw new Error("User is not allowed to create drives");const V=j.id||Et(),oe=zv(j);return await i.addDrive({global:oe.global,local:oe.local,id:V},q)},[e,i]),w=ae(async(j,q)=>i?await i.addRemoteDrive(j,q):void 0,[e,i]),$=ae(async j=>{if(i){if(!e)throw new Error("User is not allowed to delete drives");await i.deleteDrive(j)}},[e,i]),A=ae(async(j,q)=>{if(!e)throw new Error("User is not allowed to rename drives");return await l(j,ju({name:q}))},[l,e]),C=ae(async(j,q)=>{if(!e)throw new Error("User is not allowed to change drive availability");return await l(j,Vu({availableOffline:q}))},[l,e]),L=ae(async(j,q)=>{if(!e)throw new Error("User is not allowed to change drive availability");return await l(j,uo({type:q}))},[l,e]),O=ae(async(j,q)=>{if(q!==nr&&i)try{const V=i.getSyncStatus(j);return V instanceof Li?"INITIAL_SYNC":V}catch(V){return console.error(V),Di}},[i]),re=ae((j,q)=>{if(q!==nr&&i)try{const V=i.getSyncStatus(j);return V instanceof Li?"INITIAL_SYNC":V}catch(V){return console.error(V),Di}},[i]),ie=ae(async()=>{i&&await o.clear()},[i,o]),I=ae(async(j,q)=>{const V=await l(j,lo({triggerId:q}));if(V==null?void 0:V.state.local.triggers.find(S=>S.id===q))throw new Error(`There was an error removing trigger ${q}`)},[l]),k=ae(async(j,q,V)=>{var U,K,me,ue;if(!i)return;const oe=Et(),S={driveId:j,listenerId:oe,block:!1,filter:{branch:((U=V.pullFilter)==null?void 0:U.branch)??[],documentId:((K=V.pullFilter)==null?void 0:K.documentId)??[],documentType:((me=V.pullFilter)==null?void 0:me.documentType)??[],scope:((ue=V.pullFilter)==null?void 0:ue.scope)??[]},system:!1,label:`Pullresponder #${oe}`,callInfo:{data:"",name:"PullResponder",transmitterType:"PullResponder"}},W=i.listeners;S.transmitter=new He(S,W);try{await W.setListener(j,S)}catch(ve){throw new Error(`Listener couldn't be registered: ${ve}`)}return{driveId:j,filter:S.filter,data:{interval:`${V.pullInterval}`||"1000",listenerId:oe,url:q},id:oe,type:"PullResponder"}},[i]),Y=ae(async(j,q)=>{const V=await l(j,zu({trigger:q}));if(!(V==null?void 0:V.state.local.triggers.find(S=>S.id===S.id)))throw new Error(`There was an error adding the trigger ${q.id}`)},[l]);return hr(()=>({addDocument:m,addDocumentOperations:h,addDriveOperation:l,addDriveOperations:f,addFile:E,addFolder:P,openFile:d,updateFile:D,deleteNode:B,renameNode:R,moveNode:Q,copyNode:N,addDrive:X,addRemoteDrive:w,deleteDrive:$,renameDrive:A,setDriveAvailableOffline:C,setDriveSharingType:L,getSyncStatus:O,getSyncStatusSync:re,clearStorage:ie,removeTrigger:I,addTrigger:Y,registerNewPullResponderTrigger:k}),[m,h,l,f,E,P,d,D,B,R,Q,N,X,w,$,A,C,L,O,re,ie,I,Y,k])}const zw=1e5,qw=(t,e)=>e?t.toLocaleLowerCase().includes(`transmitter ${e} not found`):!1,Yw=()=>{const[t,e]=Rn([]),[n,r]=Rn(new Map),{addTrigger:s,removeTrigger:i,registerNewPullResponderTrigger:o,renameDrive:a,addRemoteDrive:c,setDriveSharingType:u}=Yd(),d=Tr(),l=on(new Map),f=ae(async(E,D,P)=>{e(R=>[...R,P]);const B=D.data;if(B)try{let R=n.get(P);if(!R){if(R=await o(E,B.url,{pullInterval:Number(B.interval)||3e3}),!R)return;n.set(P,R),r(n)}await i(E,D.id),await s(E,R),l.current.delete(P)}catch(R){const Q=l.current.get(P)||1;l.current.set(P,Q===zw?Q:Q*10),pe.error(R)}finally{e(R=>R.filter(Q=>Q!==P))}},[n,i,s,l,o]),h=ae(async(E,D,P)=>{var B;e(R=>[...R,P]);try{const R=d==null?void 0:d.find(Q=>Q.header.id===E);if(!R)return;if(await i(E,D.id),await a(E,R.state.global.name+` (${R.header.id})`),await u(E,nr),(B=D.data)!=null&&B.url&&R.header.slug){const Q=await Rc(D.data.url,R.header.slug);if(Q){const N=D.data.url.split("/");N[N.length-1]=Q;const X=N.join("/");await c(X,{availableOffline:!0,sharingType:"PUBLIC",listeners:[],triggers:[]})}}}catch(R){pe.error(R)}finally{e(R=>R.filter(Q=>Q!==P))}},[d,i,a,u,Rc,c]),m=ae(async(E,D,P,B)=>{var R;switch(P){case 400:{if(qw(B,(R=D.data)==null?void 0:R.listenerId)){if(!(localStorage.getItem("AUTO_REGISTER_PULL_RESPONDER")!=="false"))return;const N=`strands:${E}:${P}`;if(t.includes(N)||!D.data)return;const X=l.current.get(N)||0;setTimeout(()=>f(E,D,N),X)}break}case 404:{const Q=`strands:${E}:${P}`;if(t.includes(Q))return;setTimeout(()=>h(E,D,Q),0);break}}},[h,f,t]);return hr(()=>({strandsErrorHandler:m}),[m])},Hw="feature-flags-config",Kr=window.__VITE_ENVS.PH_CONNECT_ENABLED_EDITORS||void 0,Jw=Kr==null?void 0:Kr.split(","),Xr=window.__VITE_ENVS.PH_CONNECT_DISABLED_EDITORS||"powerhouse/document-drive",Ww=Xr==null?void 0:Xr.split(","),Hd={editors:{enabledEditors:Kr==="*"?"*":Jw,disabledEditors:Xr==="*"?"*":Ww}},Jd=Tw(Hw,Hd);Jd.debugLabel="featureFlagAtomInConnect";const Qw=()=>{const[t,e]=an(Jd);return{config:{...Hd,...t},setConfig:e}},Lc=window.__VITE_ENVS.APP_VERSION,jS=window.navigator.userAgent.includes("Electron"),VS=window.navigator.appVersion.includes("Mac"),xc={"staging/makerdao":"deployments/staging/makerdao","staging/arbitrum":"arb-ltip","staging/powerhouse":"staging",makerdao:"deployments/makerdao",arbitrum:"deployments/arbitrum",arbgrants:"deployments/arbitrum",localhost:"develop"},Kw=()=>{const t="https://raw.githubusercontent.com/powerhouse-inc/connect",e=window.location.href,n=Object.keys(xc).find(s=>e.includes(s)),r=n?xc[n]:void 0;if(r)return`${t}/${r}/package.json`},Xw=async()=>{const t=Kw();if(!t)return;const n=await(await fetch(t)).json(),{version:r}=n;return r},Zw=async()=>{const t=await Xw();return t?{isLatest:t===Lc,currentVersion:Lc,latestVersion:t}:null},eb=()=>{const{t}=Bd(),{getSyncStatusSync:e}=Yd(),n=on([]),r=Tr();Yw();const[s]=Dh();async function i(){const a=await Zw();if(a!==null){if(a.isLatest||a.currentVersion.includes("-"))return!0;window.__VITE_ENVS.MODE==="development"||s.studioMode||!s.warnOutdatedApp?pe.warn(`Connect is outdated:
|
|
385
|
-
Current: ${a.currentVersion}
|
|
386
|
-
Latest: ${a.latestVersion}`):Ti(yt(Bw,{}),{type:"connect-warning",toastId:"outdated-app",autoClose:!1})}}Ce(()=>{i().catch(console.error)},[]);const o=ae(async(a,c)=>{a.forEach(u=>{const d=n.current.find(m=>m.header.id===u.header.id);if(!d)return;const l=Ci(u),f=e(d.header.id,l),h=e(u.header.id,l);if(l!==nr&&h===fp&&n.current.includes(u))return n.current=n.current.filter(m=>m.header.id!==u.header.id),Ti(c("notifications.driveSyncSuccess"),{type:"connect-success"});(h===Js||h===Di)&&h!==f&&n.current.push(u)}),n.current.length>0&&await i()&&n.current.forEach(d=>{const l=Ci(d),f=e(d.header.id,l);Ti(c(`notifications.${f===Js?"driveSyncConflict":"driveSyncError"}`,{drive:d.header.name}),{type:"connect-warning",toastId:`${f===Js?"driveSyncConflict":"driveSyncError"}-${d.header.id}`})})},[]);Ce(()=>{o(r??[],t).catch(console.error)},[r,t,o])};var tb=()=>null;function nb(){const t=jt($o),e=jt(ko),n=$s();_E(()=>Mw(t,e,n)),Lw()}const rb=eo(()=>Bt(()=>import("./useInitSentry.DX0S8ltZ.js").then(t=>t.r),__vite__mapDeps([5,1,6,7]),import.meta.url)),sb=eo(()=>Bt(()=>import("./cookie-banner.CqSpDuL2.js"),__vite__mapDeps([8,6,9,10,1,11,3,4]),import.meta.url).then(t=>({default:t.CookieBanner}))),ib=eo(()=>Bt(()=>import("./modal.B6AxZ1yB.js"),__vite__mapDeps([10,1]),import.meta.url).then(t=>({default:t.ModalManager})));function ob(){return eb(),nb(),$s(),null}const ab=yt(hp,{children:Zr(bh,{children:[window.__VITE_ENVS.DEV&&yt(tb,{}),Zr(oa,{fallback:yt(mp,{}),name:"AppLoader",children:[yt(ob,{}),yt(rb,{})]}),yt(oa,{name:"CookieBanner",children:yt(ib,{children:yt(sb,{})})})]})});function cb(t){Bf(t).render(ab)}const Wd=document.getElementById("app");if(!Wd)throw new Error("#app element not found!");cb(Wd);const GS=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{Ti as $,yb as A,zd as B,lw as C,Po as D,Rw as E,xb as F,Gw as G,LE as H,CE as I,Yd as J,Ab as K,eE as L,Mb as M,BS as N,US as O,PS as P,qu as Q,G_ as R,Pn as S,Tr as T,Nb as U,Ob as V,MS as W,jw as X,jS as Y,VS as Z,cw as _,At as a,sS as a$,Dt as a0,Tb as a1,Ls as a2,tr as a3,fd as a4,Lo as a5,rt as a6,XE as a7,Je as a8,fc as a9,xo as aA,h_ as aB,uS as aC,Dd as aD,lS as aE,g_ as aF,BE as aG,Dr as aH,Jb as aI,e_ as aJ,cS as aK,eS as aL,Bb as aM,Ir as aN,fS as aO,A_ as aP,PE as aQ,Ro as aR,F_ as aS,Kb as aT,Vb as aU,Hb as aV,rS as aW,zE as aX,qb as aY,f_ as aZ,iS as a_,Yb as aa,pc as ab,pd as ac,Ne as ad,VE as ae,ys as af,vt as ag,tS as ah,nS as ai,nn as aj,Xt as ak,xs as al,_d as am,Be as an,An as ao,Co as ap,$n as aq,Ps as ar,oS as as,j_ as at,dS as au,ks as av,R_ as aw,Sd as ax,O_ as ay,dr as az,rg as b,vw as b$,aS as b0,zb as b1,JE as b2,Xb as b3,ZE as b4,pS as b5,$b as b6,Fb as b7,Ub as b8,ME as b9,Sc as bA,_S as bB,ES as bC,bS as bD,wS as bE,N_ as bF,IS as bG,SS as bH,Yl as bI,Rb as bJ,Cb as bK,kp as bL,ow as bM,xS as bN,Tw as bO,an as bP,fg as bQ,dg as bR,Db as bS,cg as bT,tg as bU,og as bV,ag as bW,vb as bX,Eb as bY,Qi as bZ,Ew as b_,kE as ba,n_ as bb,Wb as bc,QE as bd,yS as be,jb as bf,gS as bg,Gb as bh,Qb as bi,RS as bj,CS as bk,vS as bl,hS as bm,Zb as bn,Ms as bo,TS as bp,$_ as bq,Ad as br,Rt as bs,NS as bt,mS as bu,Td as bv,DS as bw,Wi as bx,AS as by,OS as bz,wt as c,dw as c0,_w as c1,ee as c2,z as c3,ft as c4,ht as c5,Ue as c6,qt as c7,De as c8,Oe as c9,ce as cA,Sm as cB,cl as cC,Cn as cD,Al as cE,av as cF,ov as cG,sl as cH,Sb as cI,Os as cJ,Ut as cK,Hn as cL,Pa as cM,ka as cN,$a as cO,Gt as cP,Zn as cQ,_t as cR,wb as cS,xa as cT,se as cU,fy as cV,Qm as cW,xm as cX,GS as cY,it as ca,Ke as cb,ke as cc,_b as cd,y as ce,Jn as cf,Am as cg,bb as ch,Om as ci,Ol as cj,Xy as ck,yl as cl,Qe as cm,Re as cn,Nm as co,Dm as cp,zt as cq,st as cr,Fi as cs,In as ct,Ui as cu,ur as cv,Ct as cw,je as cx,ze as cy,we as cz,Lb as d,jt as e,Pe as f,Nr as g,gr as h,$S as i,Bd as j,Cs as k,Pb as l,xE as m,z_ as n,q_ as o,pe as p,Tv as q,kb as r,kS as s,FS as t,Dh as u,tw as v,nw as w,LS as x,ed as y,Ci as z};
|
|
387
|
-
//# sourceMappingURL=index.C0tp--nk.js.map
|