braian 0.0.5 → 0.0.7
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/bin/braian.mjs +2 -0
- package/bin/node-version.mjs +72 -0
- package/dist/agent/graph-agent.service.js +43 -0
- package/dist/app.module.js +2 -0
- package/dist/auth/auth.controller.js +2 -2
- package/dist/auth/auth.guard.js +34 -5
- package/dist/auth/auth.module.js +13 -2
- package/dist/auth/auth.service.js +8 -2
- package/dist/auth/link-route-policies.js +267 -0
- package/dist/auth/link-route-policy.js +27 -0
- package/dist/auth/vault-access-denied.filter.js +30 -0
- package/dist/auth/vault-access.interceptor.js +45 -0
- package/dist/auth/vault-link-principal.js +15 -0
- package/dist/auth/vault-link-sessions.service.js +186 -0
- package/dist/bootstrap.js +6 -1
- package/dist/collab/collab.service.js +12 -2
- package/dist/desktop/exposure.js +7 -1
- package/dist/entity/entity.controller.js +9 -1
- package/dist/events/vault-events.service.js +17 -4
- package/dist/files/dto/vault-files.dto.js +113 -6
- package/dist/files/file-url-signer.js +37 -11
- package/dist/files/files-http-error.js +1 -1
- package/dist/files/vault-file-archive.service.js +19 -4
- package/dist/files/vault-file-content.controller.js +29 -1
- package/dist/files/vault-file-content.service.js +18 -2
- package/dist/http/api-controllers.js +6 -0
- package/dist/http/log-redaction.js +23 -0
- package/dist/http/published-page-address.js +58 -0
- package/dist/http/request-guards.js +51 -1
- package/dist/http/security-headers.js +2 -1
- package/dist/journal/active-journal.dto.js +4 -3
- package/dist/logging/logging.middleware.js +3 -3
- package/dist/navigation/navigation.service.js +16 -1
- package/dist/providers/claude-messages-model.js +2 -2
- package/dist/providers/model-provider.service.js +71 -8
- package/dist/providers/provider-catalog-storage.js +4 -3
- package/dist/providers/provider-model-catalog.js +46 -0
- package/dist/providers/provider.controller.js +83 -0
- package/dist/rss/rss-profiles.dto.js +4 -3
- package/dist/search/search-database.service.js +40 -24
- package/dist/search/search-embedding-settings.controller.js +82 -0
- package/dist/search/search-embedding.service.js +33 -28
- package/dist/search/search-index-health.js +1 -1
- package/dist/search/search-sync.service.js +8 -0
- package/dist/search/search.controller.js +34 -54
- package/dist/search/search.module.js +3 -3
- package/dist/sessions/agent-runs.controller.js +3 -3
- package/dist/sessions/dto/graph-session.dto.js +6 -5
- package/dist/sessions/sessions.service.js +33 -1
- package/dist/settings/settings.controller.js +11 -0
- package/dist/settings/settings.dto.js +29 -24
- package/dist/settings/settings.service.js +6 -0
- package/dist/shares/share-http-error.js +2 -2
- package/dist/shares/share.dto.js +74 -16
- package/dist/shares/shared-webpage-headers.js +45 -0
- package/dist/shares/shared-webpage.controller.js +179 -0
- package/dist/shares/shares.controller.js +3 -3
- package/dist/shares/shares.module.js +2 -1
- package/dist/shares/shares.service.js +11 -4
- package/dist/sqlite-files/vault-sqlite.service.js +1 -0
- package/dist/vault-access/vault-access.controller.js +73 -0
- package/dist/vault-access/vault-access.dto.js +28 -0
- package/dist/vault-access/vault-access.module.js +19 -0
- package/dist/vault-access/vault-access.service.js +49 -0
- package/dist/vaults/vault.controller.js +20 -0
- package/dist/vaults/vault.dto.js +114 -50
- package/dist/vaults/vaults.service.js +30 -2
- package/dist/versioning/versioning.service.js +47 -8
- package/node_modules/@braian/ai-providers/dist/index.js +10 -3
- package/node_modules/@braian/ai-providers/dist/openrouter-catalog.js +57 -0
- package/node_modules/@braian/ai-providers/dist/provider-catalog.js +47 -2
- package/node_modules/@braian/ai-providers/dist/providers-models.js +27 -7
- package/node_modules/@braian/graph-agent/assets/agent-instructions/default/26-schema.md +1 -1
- package/node_modules/@braian/graph-agent/dist/agent-features.js +1 -1
- package/node_modules/@braian/graph-agent/dist/agent-profiles/registry.js +9 -0
- package/node_modules/@braian/graph-agent/dist/agent-runs/run-registry.js +1 -1
- package/node_modules/@braian/graph-agent/dist/auth-registry.js +29 -0
- package/node_modules/@braian/graph-agent/dist/boards/boards-settings.js +20 -0
- package/node_modules/@braian/graph-agent/dist/boards/index.js +5 -0
- package/node_modules/@braian/graph-agent/dist/data-workspace.js +127 -14
- package/node_modules/@braian/graph-agent/dist/feature-switch.js +6 -2
- package/node_modules/@braian/graph-agent/dist/files-settings.js +10 -2
- package/node_modules/@braian/graph-agent/dist/ide/ide-settings.js +58 -0
- package/node_modules/@braian/graph-agent/dist/ide/index.js +6 -0
- package/node_modules/@braian/graph-agent/dist/ide-layout.js +1 -1
- package/node_modules/@braian/graph-agent/dist/index.js +30 -13
- package/node_modules/@braian/graph-agent/dist/journal-reflection.js +2 -1
- package/node_modules/@braian/graph-agent/dist/locked-graph-store.js +11 -2
- package/node_modules/@braian/graph-agent/dist/mentioned-notes-input.js +1 -1
- package/node_modules/@braian/graph-agent/dist/navigation-settings.js +20 -14
- package/node_modules/@braian/graph-agent/dist/note-collab-policy.js +4 -1
- package/node_modules/@braian/graph-agent/dist/note-collab-projection.js +4 -3
- package/node_modules/@braian/graph-agent/dist/note-collab-registry.js +12 -9
- package/node_modules/@braian/graph-agent/dist/note-collab-session.js +2 -1
- package/node_modules/@braian/graph-agent/dist/note-editor/index.js +13 -0
- package/node_modules/@braian/graph-agent/dist/note-editor/note-editor-settings.js +98 -0
- package/node_modules/@braian/graph-agent/dist/note-key-settings.js +34 -2
- package/node_modules/@braian/graph-agent/dist/rss/index.js +3 -1
- package/node_modules/@braian/graph-agent/dist/rss/rss-feed-parse.js +18 -1
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-store.js +9 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-use-cases.js +2 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-settings.js +15 -0
- package/node_modules/@braian/graph-agent/dist/screen-context-input.js +1 -1
- package/node_modules/@braian/graph-agent/dist/secret-masking.js +54 -15
- package/node_modules/@braian/graph-agent/dist/secret-vault.js +48 -3
- package/node_modules/@braian/graph-agent/dist/session-registry.js +3 -2
- package/node_modules/@braian/graph-agent/dist/settings-registry.js +21 -178
- package/node_modules/@braian/graph-agent/dist/settings-reset/index.js +9 -0
- package/node_modules/@braian/graph-agent/dist/settings-reset/settings-reset.js +85 -0
- package/node_modules/@braian/graph-agent/dist/share-edit-references.js +15 -14
- package/node_modules/@braian/graph-agent/dist/share-policy.js +86 -21
- package/node_modules/@braian/graph-agent/dist/share-registry.js +18 -11
- package/node_modules/@braian/graph-agent/dist/share-target-description.js +6 -0
- package/node_modules/@braian/graph-agent/dist/share-use-cases.js +99 -3
- package/node_modules/@braian/graph-agent/dist/share-webpage-links.js +40 -0
- package/node_modules/@braian/graph-agent/dist/shared-dashboard-view.js +2 -1
- package/node_modules/@braian/graph-agent/dist/spotlight-settings.js +2 -15
- package/node_modules/@braian/graph-agent/dist/standalone-pages.js +111 -0
- package/node_modules/@braian/graph-agent/dist/tools.js +4 -2
- package/node_modules/@braian/graph-agent/dist/types.js +7 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/index.js +36 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-access-policy.js +127 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-access-scope.js +60 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-link-features.js +48 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-link-grant.js +47 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-settings-access.js +44 -0
- package/node_modules/@braian/graph-agent/dist/vault-files.js +73 -14
- package/node_modules/@braian/graph-agent/dist/vault-settings-operations.js +41 -12
- package/node_modules/@braian/graph-agent/dist/vault-settings-registry.js +111 -20
- package/node_modules/@braian/html-standalone/dist/css.js +44 -0
- package/node_modules/@braian/html-standalone/dist/data-uri.js +48 -0
- package/node_modules/@braian/html-standalone/dist/html.js +118 -0
- package/node_modules/@braian/html-standalone/dist/index.js +9 -0
- package/node_modules/@braian/html-standalone/dist/local-reference.js +64 -0
- package/node_modules/@braian/html-standalone/dist/standalone.js +143 -0
- package/node_modules/@braian/html-standalone/package.json +22 -0
- package/node_modules/@braian/sqlite-browser/dist/execute.js +47 -2
- package/node_modules/@braian/vault-fs-sdk/dist/fs-vault-strategy.js +23 -0
- package/node_modules/@braian/vault-fs-sdk/dist/index.js +5 -1
- package/node_modules/@braian/vault-fs-sdk/dist/vault-index.js +5 -0
- package/package.json +5 -2
- package/public/assets/{ArrowClockwise.es-DWqWLk15.js → ArrowClockwise.es-3-WDmIeI.js} +1 -1
- package/public/assets/{ArrowDown.es-COHGTGu_.js → ArrowDown.es--soRLxEp.js} +1 -1
- package/public/assets/{ArrowLeft.es-Dvz_4AVp.js → ArrowLeft.es-CbZG51Gr.js} +1 -1
- package/public/assets/{ArrowSquareOut.es-ssfQ7LE-.js → ArrowSquareOut.es-yh2fX_Cs.js} +1 -1
- package/public/assets/{ArrowUp.es-DflnZKsA.js → ArrowUp.es-CIIkDrf9.js} +1 -1
- package/public/assets/{ArrowsClockwise.es-DSXy5pW3.js → ArrowsClockwise.es-D0399ubU.js} +1 -1
- package/public/assets/{ArrowsIn.es-B4Aie-uw.js → ArrowsIn.es-B54L_O6A.js} +1 -1
- package/public/assets/Browser.es-BqZU_2qv.js +1 -0
- package/public/assets/Circle.es-j7f1_WI9.js +1 -0
- package/public/assets/{Clock.es-D6bs8ZLR.js → Clock.es-DkUjmG8U.js} +1 -1
- package/public/assets/{Copy.es-CglRiQSZ.js → Copy.es-DfOdr0jv.js} +1 -1
- package/public/assets/CopySimple.es-BBthx5Du.js +1 -0
- package/public/assets/CornersOut.es-Cd9DgMlt.js +1 -0
- package/public/assets/Crosshair.es-9qdLaRA1.js +1 -0
- package/public/assets/{Desktop.es-DVtEXtRb.js → Desktop.es-DSRSg0hy.js} +1 -1
- package/public/assets/{DotsSixVertical.es-B7kGbvvH.js → DotsSixVertical.es-Cg2wLxmG.js} +1 -1
- package/public/assets/{Eye.es-DKoV8w-8.js → Eye.es-CxGbwLRS.js} +1 -1
- package/public/assets/{EyeSlash.es-C_H7lJGL.js → EyeSlash.es-DfTto7s1.js} +1 -1
- package/public/assets/{File.es-47KQbmb4.js → File.es-D3fdUSmS.js} +1 -1
- package/public/assets/FloppyDisk.es-CVEXDdFf.js +1 -0
- package/public/assets/{Folder.es-DKrkcRQj.js → Folder.es-BUMi6qzZ.js} +1 -1
- package/public/assets/{FolderOpen.es-DaW9wv8-.js → FolderOpen.es-FcjULnXZ.js} +1 -1
- package/public/assets/{FolderPlus.es-D0scempH.js → FolderPlus.es-Deuvtys5.js} +1 -1
- package/public/assets/GearSix.es-CWRB8Up2.js +1 -0
- package/public/assets/List.es-C0rMRBfB.js +1 -0
- package/public/assets/{ListBullets.es-DGeupXZ3.js → ListBullets.es-B7JvZb2M.js} +1 -1
- package/public/assets/{LockSimple.es-DiQO6y_F.js → LockSimple.es-D5Ul9U6c.js} +1 -1
- package/public/assets/LockSimpleOpen.es-C2JGRKEE.js +1 -0
- package/public/assets/{MagnifyingGlass.es-CHks7m9E.js → MagnifyingGlass.es-BPnvTl_3.js} +1 -1
- package/public/assets/{Microphone.es-CQat-MJ8.js → Microphone.es-BXBLW9YD.js} +1 -1
- package/public/assets/{Play.es-h1Fhb5wo.js → Play.es-BT5cMJ7L.js} +1 -1
- package/public/assets/{Plus.es-B-svcAlu.js → Plus.es-aakfbgmy.js} +1 -1
- package/public/assets/{Prohibit.es-M5ljYyQ3.js → Prohibit.es-pwiGfWLj.js} +1 -1
- package/public/assets/{QrCode.es-CVlyfpjq.js → QrCode.es-DCPGPGYZ.js} +1 -1
- package/public/assets/ShareNetwork-CTDRol5F.css +1 -0
- package/public/assets/ShareNetwork.es-Do0IWaE9.js +3 -0
- package/public/assets/SidebarSimple.es-UdNMyfL-.js +1 -0
- package/public/assets/{SlidersHorizontal.es-DkPz8o7o.js → SlidersHorizontal.es-957OxRrd.js} +1 -1
- package/public/assets/{TextAa.es-CymAJ91v.js → TextAa.es-8d8-rRe1.js} +1 -1
- package/public/assets/{Trash.es-B7UVM9v_.js → Trash.es-chxTwNhO.js} +1 -1
- package/public/assets/WarningCircle.es-CF4lQ1bU.js +1 -0
- package/public/assets/advanced-security-B_SegWCz.js +1 -0
- package/public/assets/agent-profiles-settings-DZv5BUzj.js +1 -0
- package/public/assets/appearance-settings-module-DlOVkZXP.js +1 -0
- package/public/assets/{ar-SA-G6X2FPQ2-R9ND2Rw0.js → ar-SA-G6X2FPQ2-DZP7qz6u.js} +1 -1
- package/public/assets/{attachment-embed-Bt5qCuKC.css → attachment-embed-CJkoG50a.css} +1 -1
- package/public/assets/attachment-embed-DVbcGTLJ.js +1 -0
- package/public/assets/attachments-settings-BuqoRFuK.js +1 -0
- package/public/assets/az-AZ-76LH7QW2-ByX_zd4F.js +1 -0
- package/public/assets/{bg-BG-XCXSNQG7-WKBfRf7q.js → bg-BG-XCXSNQG7-wxiUF1_6.js} +1 -1
- package/public/assets/blue-pgMgVzKw.css +1 -0
- package/public/assets/{bn-BD-2XOGV67Q-BmT7jnvl.js → bn-BD-2XOGV67Q-BBIhV1oq.js} +1 -1
- package/public/assets/{board-workspace-D9prroo0.css → board-workspace-CUeGZca9.css} +1 -1
- package/public/assets/board-workspace-pt2JAfWJ.js +1 -0
- package/public/assets/boards-settings-module-CaOcLdGN.js +1 -0
- package/public/assets/{boards-view-3JR36W_w.js → boards-view-DEVAYmzH.js} +1 -1
- package/public/assets/{ca-ES-6MX7JW3Y-CBR9ytrG.js → ca-ES-6MX7JW3Y-CKplVKfE.js} +1 -1
- package/public/assets/calendar-view-B-w_4BV-.js +1 -0
- package/public/assets/calendar-workspace-BiPYwfJr.js +1 -0
- package/public/assets/{calendars-settings-module-BWI1k_YA.js → calendars-settings-module-DuwhjpAm.js} +1 -1
- package/public/assets/card-fields-BJ9YVWI0.css +1 -0
- package/public/assets/{card-fields-eo7dqj1P.js → card-fields-iDvc1GXx.js} +1 -1
- package/public/assets/{chat-composer-editor-DCmWVP16.js → chat-composer-editor-CPfqqfXn.js} +1 -1
- package/public/assets/{chat-message-list-DPXjDBw1.js → chat-message-list-Ds52ru39.js} +1 -1
- package/public/assets/chunk-6U3AYISY-C6-Mtja1.js +12 -0
- package/public/assets/{chunk-EIO257PC-Bfdsn_q8.js → chunk-EIO257PC-DvUJi4Nw.js} +1 -1
- package/public/assets/chunk-K2UTITRG-ZTIxemJp.js +41 -0
- package/public/assets/chunk-SRAX5OIU-wzfotNc-.js +1 -0
- package/public/assets/chunk-Z3N5DIM6-D9TMVU7m.js +1 -0
- package/public/assets/{code-editor-CxLqzVwa.js → code-editor-BTcitmHE.js} +1 -1
- package/public/assets/code-editor-DIB7VOIc.css +1 -0
- package/public/assets/{color-picker-Cmg2HIDb.css → color-picker-BV0aOd4w.css} +1 -1
- package/public/assets/{color-picker-DK8V_DI0.js → color-picker-WHiWktCJ.js} +1 -1
- package/public/assets/{contents-view-DHRWEBwV.js → contents-view-DOVe1FVg.js} +1 -1
- package/public/assets/contents-view-XuasBH0m.css +1 -0
- package/public/assets/{conversation-debug-panel-zsrBEMxW.js → conversation-debug-panel-C73_GL9P.js} +1 -1
- package/public/assets/{settings-view-Bd65kLGK.css → core-settings-module-DNS3W-dj.css} +1 -1
- package/public/assets/core-settings-module-_wQSD6hP.js +4 -0
- package/public/assets/create-note-popup-B-wM8Q5O.js +1 -0
- package/public/assets/{cs-CZ-2BRQDIVT-fiabtlu1.js → cs-CZ-2BRQDIVT-CHlJO48i.js} +1 -1
- package/public/assets/{cypher-editor-ef6RdDgm.js → cypher-editor-M9g--02t.js} +1 -1
- package/public/assets/{da-DK-5WZEPLOC-C-5tRCvs.js → da-DK-5WZEPLOC-B2KbOKlk.js} +1 -1
- package/public/assets/daily-notes-settings-CrgXHhLI.js +1 -0
- package/public/assets/{dashboard-grid-DKMK4z_a.js → dashboard-grid-BZ8kYdV4.js} +2 -2
- package/public/assets/dashboard-workspace-CIhpZ3rj.js +4 -0
- package/public/assets/dashboard-workspace-ChhR6uFw.css +1 -0
- package/public/assets/{dashboards-settings-module-DmE0Krje.js → dashboards-settings-module-CUyrJjUX.js} +1 -1
- package/public/assets/dashboards-view-CkheD5RG.js +1 -0
- package/public/assets/{de-DE-XR44H4JA-4wneKMQi.js → de-DE-XR44H4JA-CraH52sB.js} +1 -1
- package/public/assets/{desktop-server-settings-DDd8PcxW.js → desktop-server-settings-CDuPB2R6.js} +1 -1
- package/public/assets/discovery-create-popup-aCpL7caq.js +1 -0
- package/public/assets/discovery-import-popup-qmw9XOW8.js +1 -0
- package/public/assets/{discovery-settings-module-DQMZismj.js → discovery-settings-module-BiY4ib2N.js} +1 -1
- package/public/assets/discovery-view-CPYP4CTN.js +1 -0
- package/public/assets/discovery-workspace-COn6jS_C.js +2 -0
- package/public/assets/{dist-B58c6eJE.js → dist-BmY58onI.js} +1 -1
- package/public/assets/drag-preview-i140CAXv.js +1 -0
- package/public/assets/{drawing-note-BytzAih9.js → drawing-note-CZIRcZb4.js} +1 -1
- package/public/assets/{el-GR-BZB4AONW-BUDxOK9m.js → el-GR-BZB4AONW-hWxkjrdo.js} +1 -1
- package/public/assets/en-B4ZKOASM-CDD2_KUt.js +1 -0
- package/public/assets/{es-ES-U4NZUMDT-gXLOOlpz.js → es-ES-U4NZUMDT-D3W7yrM9.js} +1 -1
- package/public/assets/{esm-BSlSeh8A.js → esm-BwVJXUDM.js} +1 -1
- package/public/assets/{eu-ES-A7QVB2H4-4kiV_opo.js → eu-ES-A7QVB2H4-C6t3pMxo.js} +1 -1
- package/public/assets/export-formats-BEyzF7fr.js +1 -0
- package/public/assets/{fa-IR-HGAKTJCU-C7F0Dl4h.js → fa-IR-HGAKTJCU-DJOOVnVh.js} +1 -1
- package/public/assets/{feature-switch-section-617S6UWP.js → feature-switch-section-DWkHmh9Q.js} +1 -1
- package/public/assets/{fi-FI-Z5N7JZ37-DEUSwc4a.js → fi-FI-Z5N7JZ37-DEhnpOQb.js} +1 -1
- package/public/assets/file-editor-BMcxRFx_.css +1 -0
- package/public/assets/file-editor-WXaKLCia.js +3 -0
- package/public/assets/{file-language-DjeubQk3.js → file-language-BAXzYrUs.js} +1 -1
- package/public/assets/file-picker-Bo4sE6ud.css +1 -0
- package/public/assets/file-picker-DalNc5HP.js +1 -0
- package/public/assets/file-preview-B2sjiYV9.css +1 -0
- package/public/assets/file-preview-CBXgB9qm.js +1 -0
- package/public/assets/{file-preview-media-DL2hGeeZ.js → file-preview-media-D5_7dD-7.js} +1 -1
- package/public/assets/file-references-api-IoK82adM.js +1 -0
- package/public/assets/files-settings-module-DTmzlXAF.js +1 -0
- package/public/assets/files-view-D7awxVSV.js +3 -0
- package/public/assets/{files-view-B6_Mlm9V.css → files-view-DyPI1vLx.css} +1 -1
- package/public/assets/{format-panel-value-vueBm4DQ.js → format-panel-value-Qry4ewBT.js} +1 -1
- package/public/assets/format-rules-BFnbjJsr.js +1 -0
- package/public/assets/{fr-FR-RHASNOE6-BKLo10bn.js → fr-FR-RHASNOE6-D9pFTuqa.js} +1 -1
- package/public/assets/{gl-ES-HMX3MZ6V-D_nHnidC.js → gl-ES-HMX3MZ6V-CIK6mfAj.js} +1 -1
- package/public/assets/graph-explorer-DEddRhZU.js +329 -0
- package/public/assets/graph-settings-module-CdwcXpWv.js +1 -0
- package/public/assets/{he-IL-6SHJWFNN-BXKK7JWx.js → he-IL-6SHJWFNN-sIPLWf4m.js} +1 -1
- package/public/assets/{hi-IN-IWLTKZ5I-D2utCBQM.js → hi-IN-IWLTKZ5I-BUJucdSj.js} +1 -1
- package/public/assets/{hu-HU-A5ZG7DT2-BENIngFF.js → hu-HU-A5ZG7DT2-B29-4soS.js} +1 -1
- package/public/assets/icons-BQSaMzmI.js +1 -0
- package/public/assets/{id-ID-SAP4L64H-Bw77jJOj.js → id-ID-SAP4L64H-CyIfHt3t.js} +1 -1
- package/public/assets/ide-settings-module-DmJJdyaW.js +1 -0
- package/public/assets/ide-view-BhQVUYYS.js +1 -0
- package/public/assets/ide-view-Cou_U3E6.css +1 -0
- package/public/assets/image-GAAHSSAO-BxryKUrU.js +1 -0
- package/public/assets/imap-accounts-my6l8ble.js +1 -0
- package/public/assets/index-CfVw4gte.js +9 -0
- package/public/assets/index-CuWXx5Sr.css +1 -0
- package/public/assets/{it-IT-JPQ66NNP-DiG4G8vQ.js → it-IT-JPQ66NNP-Dq23HshR.js} +1 -1
- package/public/assets/{ja-JP-DBVTYXUO-CILN9NGs.js → ja-JP-DBVTYXUO-8NNxRVWb.js} +1 -1
- package/public/assets/journal-create-popup-DsFTus7q.js +1 -0
- package/public/assets/journal-day-route-BX4-KaSl.js +1 -0
- package/public/assets/journal-folder-field-hSCfQuop.js +1 -0
- package/public/assets/journal-page-CoLcbMGG.css +1 -0
- package/public/assets/journal-page-CuUs4DCL.js +2 -0
- package/public/assets/journal-settings-BeM9sz5z.js +1 -0
- package/public/assets/journal-typography-BB4TqmXu.js +1 -0
- package/public/assets/journal-writing-route-Ba7mqWJS.js +1 -0
- package/public/assets/journals-view-Cf89lTyQ.js +1 -0
- package/public/assets/kaa-6HZHGXH3-DWQlZzTI.js +1 -0
- package/public/assets/{kab-KAB-ZGHBKWFO-yPJB-J7N.js → kab-KAB-ZGHBKWFO-BCP7pvXg.js} +1 -1
- package/public/assets/kk-KZ-P5N5QNE5-xOkOQsTw.js +1 -0
- package/public/assets/{km-KH-HSX4SM5Z-CSZjabru.js → km-KH-HSX4SM5Z-D0xjNROe.js} +1 -1
- package/public/assets/{ko-KR-MTYHY66A-CGEXYXZz.js → ko-KR-MTYHY66A-E5aEyLj-.js} +1 -1
- package/public/assets/{ku-TR-6OUDTVRD-DOfuZRKI.js → ku-TR-6OUDTVRD-CDQOo-yR.js} +1 -1
- package/public/assets/link-choices-CRTxLpuA.js +1 -0
- package/public/assets/link-entry-route-C1tWLndS.js +1 -0
- package/public/assets/link-file-browser-RuO2yY0g.js +1 -0
- package/public/assets/{link-kind-icon-BMfHfR_C.js → link-kind-icon-BgeZ5N-E.js} +1 -1
- package/public/assets/link-picker-CWK41zM0.js +2 -0
- package/public/assets/locked-shares-prompt-eH6sWg93.js +1 -0
- package/public/assets/{logging-settings-contribution-BLHCBnwO.js → logging-settings-contribution-Btq9ioZn.js} +1 -1
- package/public/assets/logic-CiFwn-O5.js +28 -0
- package/public/assets/long-press-C_vMz2E6.js +1 -0
- package/public/assets/{lt-LT-XHIRWOB4-CmbJTJAh.js → lt-LT-XHIRWOB4-CZPudjgc.js} +1 -1
- package/public/assets/{lv-LV-5QDEKY6T-Br-VqxTs.js → lv-LV-5QDEKY6T-BFIvtooB.js} +1 -1
- package/public/assets/markdown-message-BmuXZdEl.js +3 -0
- package/public/assets/markdown-message-CEFw-l9n.css +1 -0
- package/public/assets/markdown-task-toggle-BdNMBrC0.css +1 -0
- package/public/assets/markdown-task-toggle-j4VvSqsD.js +4 -0
- package/public/assets/{matrices-settings-module-DKGdrCad.js → matrices-settings-module-CoOYPwEU.js} +1 -1
- package/public/assets/matrices-view-CcjCls3L.js +1 -0
- package/public/assets/matrix-workspace-98WdHTfO.js +1 -0
- package/public/assets/{maximize-2-DATMN9kx.js → maximize-2-BOW9VTPW.js} +1 -1
- package/public/assets/mermaid-diagram-kld9fHwj.js +1 -0
- package/public/assets/{mobile-file-text-meniSeto.js → mobile-file-text-BqyOwF0N.js} +1 -1
- package/public/assets/mobile-note-content-editor-BPxespTd.js +2 -0
- package/public/assets/{mobile-panel-layer-2EcEm-JB.js → mobile-panel-layer-CA_yph77.js} +1 -1
- package/public/assets/model-provider-settings-contribution-CECr7FiG.js +1 -0
- package/public/assets/model-providers-Ptlz_trq.js +1 -0
- package/public/assets/move-destination-2AXvBdlJ.js +1 -0
- package/public/assets/move-entries-dialog-BEJJSv8J.js +1 -0
- package/public/assets/{mr-IN-CRQNXWMA-DwF8SFQB.js → mr-IN-CRQNXWMA-DmnSBhlL.js} +1 -1
- package/public/assets/my-MM-5M5IBNSE-DDu4zmzX.js +1 -0
- package/public/assets/{nb-NO-T6EIAALU-BelWzTQs.js → nb-NO-T6EIAALU-BLzt9sXj.js} +1 -1
- package/public/assets/{nl-NL-IS3SIHDZ-Ce06PPL4.js → nl-NL-IS3SIHDZ-FtFhrALS.js} +1 -1
- package/public/assets/{nn-NO-6E72VCQL-BbXlzJzR.js → nn-NO-6E72VCQL-B_SymEE5.js} +1 -1
- package/public/assets/note-body-focus-d1lrm6Vw.js +1 -0
- package/public/assets/note-collab-provider-B5sEpjH1.js +1 -0
- package/public/assets/note-collab-transport-HTl4Zdug.js +1 -0
- package/public/assets/note-create-settings-module-iEVdyRFV.js +1 -0
- package/public/assets/{note-documents-CcJDTkta.js → note-documents-BPTwtsVi.js} +2 -2
- package/public/assets/note-editor-container-Ct9S4xJq.css +1 -0
- package/public/assets/note-editor-container-DzXoYKkT.js +2 -0
- package/public/assets/note-editor-settings-module-BZalej3y.js +1 -0
- package/public/assets/note-excalidraw-editor-CYHK-nyq.js +118 -0
- package/public/assets/note-excalidraw-editor-DVHMAsgJ.css +1 -0
- package/public/assets/{note-export-api-CwuXGV0y.js → note-export-api-Cdb5DLzA.js} +1 -1
- package/public/assets/note-export-flow-CfLnfRzg.js +1 -0
- package/public/assets/{note-filter-rule-rows-DFSWBwql.js → note-filter-rule-rows-DmVis2Dw.js} +1 -1
- package/public/assets/note-folds-settings-module-DeVre4gm.js +1 -0
- package/public/assets/note-frontmatter-summary-DNdQjzv5.js +1 -0
- package/public/assets/note-history-retention-B5aE8fKh.js +1 -0
- package/public/assets/note-link-list-C2i2SrSh.css +1 -0
- package/public/assets/note-link-list-DD4FzeUb.js +2 -0
- package/public/assets/note-markdown-editor-BlWCUXb9.js +26 -0
- package/public/assets/note-markdown-editor-Dp1k8dWQ.css +1 -0
- package/public/assets/{note-outline-BFidIp-8.js → note-outline-C-dPTJrB.js} +2 -2
- package/public/assets/note-outline-DTpLzjGU.css +1 -0
- package/public/assets/note-page-content-CZH9UDn0.js +2 -0
- package/public/assets/{note-page-editor-BgcMK_4q.css → note-page-editor-D7Wt_Giv.css} +1 -1
- package/public/assets/{note-page-editor-DpVUxkCx.js → note-page-editor-D8M6gjmG.js} +4 -4
- package/public/assets/note-path-breadcrumb-CLfo-0XG.js +1 -0
- package/public/assets/{note-path-breadcrumb-YC4bHnwX.css → note-path-breadcrumb-Drkebhvm.css} +1 -1
- package/public/assets/{note-picker-B5i41l1u.js → note-picker-DIFcqGgZ.js} +1 -1
- package/public/assets/note-picker-KBB6aonj.css +1 -0
- package/public/assets/{note-picker-popover-B9VTeHiM.js → note-picker-popover-CoT73GG-.js} +1 -1
- package/public/assets/note-shares-popup-CmUAI6V-.js +1 -0
- package/public/assets/note-side-panel-BFno3955.js +1 -0
- package/public/assets/note-side-panel-DLOy2dVw.css +1 -0
- package/public/assets/note-side-panel-host-iIfi_4c4.js +1 -0
- package/public/assets/note-source-editor-CVo_ZXww.js +1 -0
- package/public/assets/{note-type-grid-CRCfpYZy.js → note-type-grid-Bfdc8U-T.js} +2 -2
- package/public/assets/{note-type-grid-BM33ZYF-.css → note-type-grid-BzMZLAzW.css} +1 -1
- package/public/assets/{note-values-6D6wWXPg.js → note-values-C4A12_CE.js} +1 -1
- package/public/assets/notes-settings-module-DBSeNBYj.js +1 -0
- package/public/assets/notes-view-C_mX24NH.js +1 -0
- package/public/assets/notes-view-D212ymqf.css +1 -0
- package/public/assets/{oc-FR-POXYY2M6-CyRgkETq.js → oc-FR-POXYY2M6-DM9hsX9Q.js} +1 -1
- package/public/assets/{open-journal-writing-Bub8Zn13.js → open-journal-writing-Da9CBYtR.js} +1 -1
- package/public/assets/{pa-IN-N4M65BXN-A1_Q9748.js → pa-IN-N4M65BXN-CJJQ9oPk.js} +1 -1
- package/public/assets/page-content-27iX_YpJ.js +1 -0
- package/public/assets/page-content-CdioJybS.css +1 -0
- package/public/assets/page-export-api-BqvyvK1O.js +1 -0
- package/public/assets/page-export-flow-HzZ0AmjW.js +1 -0
- package/public/assets/page-files-C30eoBCR.js +1 -0
- package/public/assets/page-note-7Oo1OmH0.js +1 -0
- package/public/assets/pane-layout-BaHTn1Oz.js +1 -0
- package/public/assets/{panel-columns-fields-ZlW6A4My.js → panel-columns-fields-B9Biz8Xm.js} +1 -1
- package/public/assets/pdf-view-B5Y12R4H.js +1 -0
- package/public/assets/pdf-view-X71jeHKm.css +1 -0
- package/public/assets/{pencil-xxFNyZzr.js → pencil-BQzjBcpa.js} +1 -1
- package/public/assets/percentages-BXMCSKIN-DRPvI3O-.js +1 -0
- package/public/assets/{phone-numbers-BQgyhfcH.js → phone-numbers-lV_IC3Pq.js} +1 -1
- package/public/assets/{pl-PL-T2D74RX3-DaINIVjz.js → pl-PL-T2D74RX3-BLAcchR-.js} +1 -1
- package/public/assets/progress-bar-BxjnW3uQ.js +1 -0
- package/public/assets/provider-configuration-DBW3Pa0C.js +8 -0
- package/public/assets/provider-configuration-dpnYrEZm.css +1 -0
- package/public/assets/provider-use-select-C0EI8kSQ.js +1 -0
- package/public/assets/{pt-BR-5N22H2LF-ENVHjTz_.js → pt-BR-5N22H2LF-BiLQ-V_W.js} +1 -1
- package/public/assets/{pt-PT-UZXXM6DQ-D5Uqv0Vz.js → pt-PT-UZXXM6DQ-DKEXacg3.js} +1 -1
- package/public/assets/qr-code-DgTUKCej.js +2 -0
- package/public/assets/{qr-code-svg-8ENstC8b.js → qr-code-svg-DdWw4ovA.js} +1 -1
- package/public/assets/qr-defaults-settings-BbbzxV5k.js +1 -0
- package/public/assets/qr-settings-fields-C8GCAxa_.js +1 -0
- package/public/assets/qr-viewer-DTCnaLOP.js +1 -0
- package/public/assets/queryOptions-Dfvzj6n2.js +1 -0
- package/public/assets/{reader-clock-7x7Yvzv1.js → reader-clock-s4x6Qtz_.js} +1 -1
- package/public/assets/{recording-bar-BcuvYwhh.js → recording-bar-C5jkIsLX.js} +1 -1
- package/public/assets/{recording-setup-D_MgrYb7.js → recording-setup-fZ6fe1MX.js} +1 -1
- package/public/assets/{recordings-api-Ds77lFsk.js → recordings-api-CxuXFNaM.js} +1 -1
- package/public/assets/{resource-overview-card-BainFWKz.js → resource-overview-card-CAxT9QxY.js} +1 -1
- package/public/assets/{ro-RO-JPDTUUEW-Dq_ouOp1.js → ro-RO-JPDTUUEW-DPtQ18Fr.js} +1 -1
- package/public/assets/rss-settings-module-Bg7BBsC4.js +1 -0
- package/public/assets/rss-view-DeSvhXEa.js +3 -0
- package/public/assets/{ru-RU-B4JR7IUQ-CqqISqJC.js → ru-RU-B4JR7IUQ-n-7DhzM7.js} +1 -1
- package/public/assets/{safe-block-copy-BOVhmncw.js → safe-block-copy-B7NrP_YX.js} +1 -1
- package/public/assets/{safe-block-qr-button-CD7cJG3N.js → safe-block-qr-button-DomQCK7l.js} +1 -1
- package/public/assets/safe-block-reader-BGmIVIwN.js +1 -0
- package/public/assets/safe-folder-conversion-Re-4B3nf.js +1 -0
- package/public/assets/{safe-folders-DmvM6dtV.js → safe-folders-B4zJo8qB.js} +1 -1
- package/public/assets/{safe-move-leaving-BT5e1h3p.js → safe-move-leaving-D4dKIwTJ.js} +1 -1
- package/public/assets/{safe-note-locked-BDCeVwpK.js → safe-note-locked-BGUjggd4.js} +1 -1
- package/public/assets/safe-notes-settings-module-zJbcwdU7.js +1 -0
- package/public/assets/{markdown-task-toggle-CuRdtBn0.css → safe-text-B4Q6DSRg.css} +1 -1
- package/public/assets/safe-text-MPRw9KNQ.js +2 -0
- package/public/assets/search-settings-module-CMWbEyvZ.js +1 -0
- package/public/assets/{secret-form-B-YAlbZf.js → secret-form-DoNXw27T.js} +1 -1
- package/public/assets/secret-popup-Vn5Xkv4s.js +1 -0
- package/public/assets/section-navigation-1mCyY2Gm.js +1 -0
- package/public/assets/{security-settings-contribution-BmcZq1hf.js → security-settings-contribution-BrPrGp5q.js} +1 -1
- package/public/assets/settings-CxK-AM0A.js +1 -0
- package/public/assets/settings-actions-DnTiS3-h.js +1 -0
- package/public/assets/{settings-edit-dialog-C_AeTz9Y.js → settings-edit-dialog-CE5ZTszW.js} +1 -1
- package/public/assets/settings-panel-BF5baIMl.js +1 -0
- package/public/assets/settings-surface-CDwMuN24.js +3 -0
- package/public/assets/settings-surface-DzW4lcds.css +1 -0
- package/public/assets/{setup-prompt-BbpHVdla.js → setup-prompt-Bmv_QxoH.js} +1 -1
- package/public/assets/{share-access-control-CzAVEv6b.js → share-access-control-CB7J42Dn.js} +1 -1
- package/public/assets/shared-board-CLRkwNKE.js +1 -0
- package/public/assets/shared-board-lanes-OZo3pA9j.js +1 -0
- package/public/assets/{shared-calendar-view-DTzDjSs0.js → shared-calendar-view-BSmK0NDE.js} +1 -1
- package/public/assets/shared-note-route-CnykVAYu.css +1 -0
- package/public/assets/shared-note-route-DtZVqLMu.js +4 -0
- package/public/assets/shared-note-text-C6nccM7z.js +1 -0
- package/public/assets/{shares-settings-module-pIdBLmCq.js → shares-settings-module-gI5s2PT6.js} +1 -1
- package/public/assets/si-LK-N5RQ5JYF-BpI-kBDz.js +1 -0
- package/public/assets/{sk-SK-C5VTKIMK-YiOZ-xKA.js → sk-SK-C5VTKIMK-BRXRBgRU.js} +1 -1
- package/public/assets/{sl-SI-NN7IZMDC-BKb37Hlu.js → sl-SI-NN7IZMDC-BXKt0fnN.js} +1 -1
- package/public/assets/{spaces-settings-module-BLU1RsTS.js → spaces-settings-module-BOkTwY_Z.js} +1 -1
- package/public/assets/spaces-view-K5_OKPoW.js +2 -0
- package/public/assets/sqlite-browser-BVA27ofB.css +1 -0
- package/public/assets/sqlite-browser-DCKBF2SI.js +2 -0
- package/public/assets/stack-widgets-CLUFu_vQ.js +1 -0
- package/public/assets/store-attachments-DQ63HVZo.js +1 -0
- package/public/assets/stored-color-picker-BLs1gClm.css +1 -0
- package/public/assets/stored-color-picker-CZ66rDog.js +1 -0
- package/public/assets/style-DPV_jdGg.css +1 -0
- package/public/assets/subset-shared.chunk-DYH4c2c2.js +1 -0
- package/public/assets/subset-worker.chunk-yCTTgC3G.js +1 -0
- package/public/assets/{sv-SE-XGPEYMSR-VT0snW-T.js → sv-SE-XGPEYMSR-nBH8YjQ4.js} +1 -1
- package/public/assets/{ta-IN-2NMHFXQM--MqIf2Jf.js → ta-IN-2NMHFXQM-f0oprEqN.js} +1 -1
- package/public/assets/{text-diff-BmKfp7mY.js → text-diff-BMS8apwf.js} +1 -1
- package/public/assets/th-TH-HPSO5L25-CUOH0u8u.js +2 -0
- package/public/assets/{theme-colors-zbTaiYL0.js → theme-colors-BcoD3SUn.js} +1 -1
- package/public/assets/{toolbar-items-DLi0bl0c.js → toolbar-items-DtGvJf3U.js} +1 -1
- package/public/assets/{topology-code-editor-CNnSyUQ3.js → topology-code-editor-ClyHjN--.js} +1 -1
- package/public/assets/topology-designer-DmhzdlOY.js +1 -0
- package/public/assets/{topology-editor-DUaww3cM.css → topology-editor-CZnvLbBi.css} +1 -1
- package/public/assets/topology-editor-YK_2uGkR.js +8 -0
- package/public/assets/{topology-folder-migration-popup-C0Wc3ViK.js → topology-folder-migration-popup-AZFR8-44.js} +1 -1
- package/public/assets/{tr-TR-DEFEU3FU-BVLSiyVW.js → tr-TR-DEFEU3FU-CTsS8Qy-.js} +1 -1
- package/public/assets/{transcription-settings-BldPwHO7.js → transcription-settings-D7_ViMfp.js} +2 -2
- package/public/assets/tree-header-CmCmDZKG.js +1 -0
- package/public/assets/tree-header-DlATpadF.css +1 -0
- package/public/assets/types-settings-module-L4wPTMty.js +1 -0
- package/public/assets/{uk-UA-QMV73CPH-DQ4YsZml.js → uk-UA-QMV73CPH-BJo17WQM.js} +1 -1
- package/public/assets/{unlock-prompt-CkkcVo9g.js → unlock-prompt-BQVrb-4k.js} +1 -1
- package/public/assets/{use-candidate-notes-jH4-EW29.js → use-candidate-notes-YOxWyJCJ.js} +1 -1
- package/public/assets/{directory-picker-columns-BpDkvDO0.css → use-directory-columns-DILivjwk.css} +1 -1
- package/public/assets/use-directory-columns-DYequGsf.js +1 -0
- package/public/assets/use-directory-listing-Bj3F5kA3.js +1 -0
- package/public/assets/use-folding-enabled-N7w9iIqy.js +1 -0
- package/public/assets/use-heading-location-BZ9wUH2j.js +1 -0
- package/public/assets/{use-live-document-D4PkZrbU.js → use-live-document-4fc8FCW3.js} +1 -1
- package/public/assets/use-mobile-layer-navigation-Il_7QdXn.js +1 -0
- package/public/assets/{use-note-attachments-Bew073Hl.js → use-note-attachments-DAFyHvYo.js} +1 -1
- package/public/assets/{use-note-delete-fFNH1Glk.js → use-note-delete-JQISrVQ4.js} +1 -1
- package/public/assets/{use-note-editor-session-R1wm0xDf.js → use-note-editor-session-BlLoBd41.js} +1 -1
- package/public/assets/use-note-maximize-offer-DpU6Ms0_.js +1 -0
- package/public/assets/use-note-side-column-CFBvrpKH.css +1 -0
- package/public/assets/use-note-side-column-CVs74c26.js +1 -0
- package/public/assets/use-provider-dialogs-BRoAomhX.css +1 -0
- package/public/assets/use-provider-dialogs-HkxDcuJv.js +1 -0
- package/public/assets/{use-reflection-request-C1DxtaYX.js → use-reflection-request-BuFnMuQC.js} +4 -4
- package/public/assets/use-safe-folder-moves-CjbmSWSM.js +1 -0
- package/public/assets/use-safe-folders-apply-D_7a5l_T.js +1 -0
- package/public/assets/{use-screen-source-CF-48NnC.js → use-screen-source-BZ0GGtml.js} +1 -1
- package/public/assets/use-share-actions-DBYaF7Wp.css +1 -0
- package/public/assets/use-share-actions-Tfr6NI4j.js +1 -0
- package/public/assets/use-tab-style-B5YK0cIz.js +2 -0
- package/public/assets/use-tab-style-CRx5AnD1.css +1 -0
- package/public/assets/use-vault-file-link-BCQahdir.js +1 -0
- package/public/assets/{use-voice-questions-DGVQlAST.js → use-voice-questions-DmxYfc8M.js} +1 -1
- package/public/assets/vault-entries-api-CZHdxv7-.js +1 -0
- package/public/assets/vault-file-links-D1RzhVkx.js +1 -0
- package/public/assets/vault-folder-field-C5b24MNS.js +1 -0
- package/public/assets/vault-folder-field-X-B1weCe.css +1 -0
- package/public/assets/vault-links-popup-zkFCHyoP.js +1 -0
- package/public/assets/vault-manager-CZnYayEU.js +1 -0
- package/public/assets/{vault-settings-module-CCMMSy4B.js → vault-settings-module-CL2DHG69.js} +1 -1
- package/public/assets/vault-shares-popup-Cnew0vMQ.js +1 -0
- package/public/assets/vault-workspace-settings-module-D_n4aQfC.js +1 -0
- package/public/assets/{versioning-preferences-DrNq-y_0.js → versioning-preferences-BK-mZYhi.js} +1 -1
- package/public/assets/{versioning-settings-module-Ddug486c.js → versioning-settings-module-lq4k7b3C.js} +1 -1
- package/public/assets/versioning-view-BdEZaF8n.js +2 -0
- package/public/assets/{vi-VN-M7AON7JQ-B-fHV7o8.js → vi-VN-M7AON7JQ-DpgVSDWc.js} +1 -1
- package/public/assets/video-recording-dialog-ByevPvCN.js +1 -0
- package/public/assets/{video-recording-settings-B2iE6IdW.js → video-recording-settings-Ce2plgiG.js} +1 -1
- package/public/assets/widget-frame-DzlpiABF.js +1 -0
- package/public/assets/widget-layouts-DS7nWc80.js +1 -0
- package/public/assets/workspace-layout-3hjN1Wng.js +1 -0
- package/public/assets/{zh-CN-LNUGB5OW-CUgxiiUV.js → zh-CN-LNUGB5OW-Cfb6--Ow.js} +1 -1
- package/public/assets/zh-HK-E62DVLB3-vaMRVwdL.js +1 -0
- package/public/assets/{zh-TW-RAJ6MFWO-BVaf47B6.js → zh-TW-RAJ6MFWO-CNUUB_PG.js} +1 -1
- package/public/index.html +6 -6
- package/dist/search/embedding-connection-migration.js +0 -57
- package/node_modules/@braian/ai-providers/dist/legacy-embedding-migration.js +0 -21
- package/public/assets/FileText.es-4c63tWmA.js +0 -1
- package/public/assets/TerminalWindow.es-DwLjQ_88.js +0 -1
- package/public/assets/Warning.es-4HWtj9Nt.js +0 -1
- package/public/assets/agent-profiles-settings-yElCnMJo.js +0 -1
- package/public/assets/appearance-settings-module-BFDKE-mZ.js +0 -1
- package/public/assets/attachment-embed-BX0XSPNZ.js +0 -1
- package/public/assets/attachments-settings-CSEjOoFg.js +0 -1
- package/public/assets/az-AZ-76LH7QW2-DpGlptKS.js +0 -1
- package/public/assets/blue-ezN0uv0j.css +0 -1
- package/public/assets/board-workspace-CmetKvXF.js +0 -1
- package/public/assets/boards-settings-module-Bh5dh9jG.js +0 -1
- package/public/assets/calendar-view-Cr1VSpj0.js +0 -1
- package/public/assets/calendar-workspace-B-2Himdy.js +0 -1
- package/public/assets/card-fields-C1JCmDVz.css +0 -1
- package/public/assets/code-editor-wFimHbMT.css +0 -1
- package/public/assets/contents-view-EQyMaey-.css +0 -1
- package/public/assets/create-note-popup-C9IB_IZr.js +0 -1
- package/public/assets/daily-notes-settings-CCotd1Iq.js +0 -1
- package/public/assets/dashboard-workspace-4u-QaXby.js +0 -4
- package/public/assets/dashboard-workspace-CW4tbadO.css +0 -1
- package/public/assets/dashboards-view-DxUAl6zg.js +0 -1
- package/public/assets/directory-picker-columns-CqPZNMT8.js +0 -1
- package/public/assets/discovery-create-popup-BSOSYM4o.js +0 -1
- package/public/assets/discovery-import-popup-NodFxSW1.js +0 -1
- package/public/assets/discovery-view-PiwStXSa.js +0 -1
- package/public/assets/discovery-workspace-BTrjBF19.js +0 -2
- package/public/assets/drag-preview-D61OK7zr.js +0 -1
- package/public/assets/en-B4ZKOASM-jB7I34Md.js +0 -1
- package/public/assets/file-editor-B-9eXvH3.css +0 -1
- package/public/assets/file-editor-DvP7rRI9.js +0 -3
- package/public/assets/file-preview-AkYowAab.js +0 -1
- package/public/assets/file-preview-Dynm8laQ.css +0 -1
- package/public/assets/file-references-api-C2G0bSy9.js +0 -1
- package/public/assets/files-settings-module-DsylYhrR.js +0 -1
- package/public/assets/files-view-DPSrj_WW.js +0 -3
- package/public/assets/folder-picker-dialog-CxiRBtQb.css +0 -1
- package/public/assets/folder-picker-dialog-D_VCqm_i.js +0 -1
- package/public/assets/format-rules-GzYB7Vvh.js +0 -1
- package/public/assets/graph-explorer-CHz-bFkx.js +0 -329
- package/public/assets/graph-settings-module-9hY9bkdT.js +0 -1
- package/public/assets/icons-CxH3_W-q.js +0 -1
- package/public/assets/ide-settings-module-BbIX3okW.js +0 -1
- package/public/assets/ide-view-0vK2duKI.js +0 -2
- package/public/assets/ide-view-isgMvraA.css +0 -1
- package/public/assets/image-GAAHSSAO-D4NDL8F6.js +0 -1
- package/public/assets/imap-accounts-BRbnITJv.js +0 -1
- package/public/assets/index-BVDhmwI8.js +0 -11
- package/public/assets/index-DjUUY3gd.css +0 -1
- package/public/assets/journal-create-popup-39y9ieVG.js +0 -1
- package/public/assets/journal-day-route-CYlyL-u0.js +0 -1
- package/public/assets/journal-folder-field-B8yNmuTt.css +0 -1
- package/public/assets/journal-folder-field-BfO-_ied.js +0 -1
- package/public/assets/journal-page-CAXrq4hj.css +0 -1
- package/public/assets/journal-page-TgyVFaPE.js +0 -2
- package/public/assets/journal-settings-CfjXOXzF.js +0 -1
- package/public/assets/journal-typography-D3O3AK2U.js +0 -1
- package/public/assets/journal-writing-route-CYhXzipC.js +0 -1
- package/public/assets/journals-view-DNomC0nF.js +0 -1
- package/public/assets/kaa-6HZHGXH3-BUua-YiR.js +0 -1
- package/public/assets/kk-KZ-P5N5QNE5-CAitSjw5.js +0 -1
- package/public/assets/link-file-browser-A_Mappx0.js +0 -1
- package/public/assets/link-picker-BfwWXJZg.js +0 -2
- package/public/assets/locked-shares-prompt-BsM-ai_V.js +0 -1
- package/public/assets/logic-DtHJ5GlU.js +0 -28
- package/public/assets/markdown-message-BIo2pHhE.js +0 -3
- package/public/assets/markdown-message-C2w22wrW.css +0 -1
- package/public/assets/markdown-task-toggle-9k1EldDD.js +0 -5
- package/public/assets/matrices-view-DYF7e5ES.js +0 -1
- package/public/assets/matrix-workspace-JZhH-HQ5.js +0 -1
- package/public/assets/mermaid-diagram-gUL2-JyE.js +0 -1
- package/public/assets/mobile-note-content-editor-C6TUyA4F.js +0 -2
- package/public/assets/model-provider-settings-contribution-CfHiu3nS.js +0 -1
- package/public/assets/model-providers-cQOCMmwX.js +0 -1
- package/public/assets/my-MM-5M5IBNSE-BEiMo9eJ.js +0 -1
- package/public/assets/note-body-focus-BKKGEgBj.js +0 -1
- package/public/assets/note-collab-provider-B9DpnE58.js +0 -1
- package/public/assets/note-collab-transport-BHZ891IL.js +0 -1
- package/public/assets/note-create-settings-module-rIZc1DjQ.js +0 -1
- package/public/assets/note-editor-container-8DkvXTPN.css +0 -1
- package/public/assets/note-editor-container-DL3yLdYs.js +0 -2
- package/public/assets/note-editor-settings-module-DI0jRyPy.js +0 -1
- package/public/assets/note-excalidraw-editor-CKSC5Oww.css +0 -1
- package/public/assets/note-excalidraw-editor-fDQ1JVBh.js +0 -168
- package/public/assets/note-export-flow-DcBoI5Pp.js +0 -1
- package/public/assets/note-folds-settings-module-CFfVg1Cp.js +0 -1
- package/public/assets/note-frontmatter-summary-iubFPHA_.js +0 -1
- package/public/assets/note-link-list-CI9-GM_3.js +0 -1
- package/public/assets/note-link-list-hmCbBMA2.css +0 -1
- package/public/assets/note-markdown-editor-DlBj1yv3.css +0 -1
- package/public/assets/note-markdown-editor-lG6gZT9i.js +0 -26
- package/public/assets/note-outline-CAyXKuOh.css +0 -1
- package/public/assets/note-page-content-8gzPBWMV.js +0 -2
- package/public/assets/note-path-breadcrumb-HmtWyYZP.js +0 -1
- package/public/assets/note-picker-BURTnmWF.css +0 -1
- package/public/assets/note-shares-popup-aUO1SNLN.js +0 -1
- package/public/assets/note-source-editor-BXPR_-41.js +0 -1
- package/public/assets/notes-settings-module-DcP9Hid-.js +0 -1
- package/public/assets/page-content-B3fNjwr-.js +0 -1
- package/public/assets/page-content-lnIaLh4X.css +0 -1
- package/public/assets/page-files-CSqFupDZ.js +0 -1
- package/public/assets/page-note-nmiinGCs.js +0 -1
- package/public/assets/pane-keys-DiGU3yVB.css +0 -1
- package/public/assets/pane-keys-osajBGnu.js +0 -1
- package/public/assets/pdf-view-BATpBLO5.js +0 -1
- package/public/assets/pdf-view-BK5qKL4y.css +0 -1
- package/public/assets/percentages-BXMCSKIN-DzsiA6IB.js +0 -1
- package/public/assets/provider-configuration-CSnNV6ps.css +0 -1
- package/public/assets/provider-configuration-DaFovElx.js +0 -8
- package/public/assets/provider-use-select-D-lJiZ2W.js +0 -1
- package/public/assets/qr-code-CDBCi1Cu.js +0 -2
- package/public/assets/qr-defaults-settings-C_8ybA4R.js +0 -1
- package/public/assets/qr-settings-fields-C2-DGF6a.js +0 -1
- package/public/assets/qr-viewer-DAOzDI8d.js +0 -1
- package/public/assets/rss-preferences-BafuZ3Ku.js +0 -1
- package/public/assets/rss-settings-module-Df-YS9tr.js +0 -1
- package/public/assets/rss-view-BORHnuIQ.js +0 -3
- package/public/assets/safe-block-reader-BkilW4Hj.js +0 -1
- package/public/assets/safe-folder-conversion-DWTRwvTH.js +0 -1
- package/public/assets/safe-notes-settings-module-BrZreYgf.js +0 -1
- package/public/assets/search-settings-module-CPnculiI.js +0 -1
- package/public/assets/secret-popup-CoVpeLZV.js +0 -1
- package/public/assets/settings-CU8YR8di.js +0 -1
- package/public/assets/settings-panel-Ds7lOtnD.js +0 -1
- package/public/assets/settings-view-BTz2XbnW.js +0 -4
- package/public/assets/share-label-CbjQ9iMF.js +0 -1
- package/public/assets/shared-board-lanes-CAbJAFk6.js +0 -1
- package/public/assets/shared-note-route-B5rcAeES.css +0 -1
- package/public/assets/shared-note-route-B_gfX0Nl.js +0 -4
- package/public/assets/shared-note-text-DFBEyL8Z.js +0 -1
- package/public/assets/si-LK-N5RQ5JYF-DmhE8IT5.js +0 -1
- package/public/assets/spaces-view-BhWD3mAw.js +0 -2
- package/public/assets/sqlite-browser-BKjuAUqe.css +0 -1
- package/public/assets/sqlite-browser-C98PFoRG.js +0 -2
- package/public/assets/store-attachments-DbqF7LgE.js +0 -1
- package/public/assets/stored-color-picker-BoVzUatG.css +0 -1
- package/public/assets/stored-color-picker-DLX-e5Nq.js +0 -1
- package/public/assets/style-DLioOiRN.css +0 -1
- package/public/assets/subset-shared.chunk-D8M638AI.js +0 -1
- package/public/assets/subset-worker.chunk-B9ZhBm-P.js +0 -1
- package/public/assets/th-TH-HPSO5L25-CTKAmQrO.js +0 -2
- package/public/assets/topology-designer-T54LYLYv.js +0 -1
- package/public/assets/topology-editor-aGtCktzA.js +0 -8
- package/public/assets/topology-settings-module-Dp-Sm37Z.js +0 -1
- package/public/assets/use-directory-listing-Cn9t21ra.js +0 -1
- package/public/assets/use-folding-enabled-DKvri2UA.js +0 -1
- package/public/assets/use-mobile-layer-navigation-BIC7HlT_.js +0 -1
- package/public/assets/use-note-export-flow-Dm7yhW5s.js +0 -2
- package/public/assets/use-provider-dialogs-CrxN9JCo.js +0 -1
- package/public/assets/use-safe-folder-moves-DjQUnMvz.js +0 -1
- package/public/assets/use-safe-folders-apply-B1V8l7WU.js +0 -1
- package/public/assets/use-share-actions-RxO2M3y0.css +0 -1
- package/public/assets/use-share-actions-kb7uFat_.js +0 -1
- package/public/assets/use-vault-file-link-B-ZRcKDu.js +0 -1
- package/public/assets/vault-entries-api-pFsJiGnJ.js +0 -1
- package/public/assets/vault-manager-YKz_Ib18.js +0 -1
- package/public/assets/vault-shares-popup-CaGnEIJA.js +0 -1
- package/public/assets/versioning-view-PR4R4gks.js +0 -2
- package/public/assets/video-recording-dialog-CxRs1eLE.js +0 -1
- package/public/assets/widget-frame-DiF4946k.js +0 -1
- package/public/assets/zh-HK-E62DVLB3-D-87W8QH.js +0 -1
- /package/public/assets/{blue-CDYoCZOg.js → blue-DQyE4k0K.js} +0 -0
- /package/public/assets/{use-safe-folders-apply-DGWTaX5A.css → progress-bar-DGWTaX5A.css} +0 -0
- /package/public/assets/{style-DA65Bz1d.js → style-CXzDJL_q.js} +0 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cypher-editor-M9g--02t.js","assets/rolldown-runtime-COiEfhsA.js","assets/codemirror-BqrpJAnL.js","assets/react-B3NTyEzE.js","assets/code-editor-BTcitmHE.js","assets/index-CfVw4gte.js","assets/logic-CiFwn-O5.js","assets/state-9kAy-W2i.js","assets/icons-BQSaMzmI.js","assets/interaction-BeNMN0Kn.js","assets/motion-DVTefdmR.js","assets/index-CuWXx5Sr.css","assets/file-language-BAXzYrUs.js","assets/dist-BmY58onI.js","assets/code-editor-DIB7VOIc.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,n as t,t as n}from"./rolldown-runtime-COiEfhsA.js";import{m as r,t as i}from"./react-B3NTyEzE.js";import{Bn as a,Cn as o,Er as s,Tr as c,br as l,gt as u,hr as d,ur as f,vr as p,wr as m,xr as h}from"./index-CfVw4gte.js";import{$ as g,Bl as _,Cc as v,Od as y,Rl as b,Sl as x,Wl as S,jd as C,kd as w}from"./logic-CiFwn-O5.js";import{t as ee}from"./ArrowsIn.es-B54L_O6A.js";import{B as te,L as ne,v as re}from"./icons-BQSaMzmI.js";import{t as ie}from"./Crosshair.es-9qdLaRA1.js";import{t as ae}from"./MagnifyingGlass.es-BPnvTl_3.js";import{t as oe}from"./SlidersHorizontal.es-957OxRrd.js";import{t as se}from"./ListBullets.es-B7JvZb2M.js";import{t as ce}from"./Play.es-BT5cMJ7L.js";import{t as le}from"./theme-colors-BcoD3SUn.js";import{t as ue}from"./note-open-intent-l6SCo3MI.js";var de=n(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),T=e(r(),1),fe=de();function pe(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let n in arguments[t])e[n]=arguments[t][n];return e}var me=pe;typeof Object.assign==`function`&&(me=Object.assign);function he(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(a=r===`mixed`?i.out&&i.out[n]||i.undirected&&i.undirected[n]:r===`directed`?i.out&&i.out[n]:i.undirected&&i.undirected[n]),a}function ge(e){return typeof e==`object`&&!!e}function _e(e){let t;for(t in e)return!1;return!0}function ve(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function ye(e,t,n){let r={enumerable:!0,configurable:!0};typeof n==`function`?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function be(e){return!(!ge(e)||e.attributes&&!Array.isArray(e.attributes))}function xe(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function Se(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done)t=null;else break}while(1);return r}}}function Ce(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var we=class extends Error{constructor(e){super(),this.name=`GraphError`,this.message=e}},E=class e extends we{constructor(t){super(t),this.name=`InvalidArgumentsGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},D=class e extends we{constructor(t){super(t),this.name=`NotFoundGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},O=class e extends we{constructor(t){super(t),this.name=`UsageGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}};function Te(e,t){this.key=e,this.attributes=t,this.clear()}Te.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Ee(e,t){this.key=e,this.attributes=t,this.clear()}Ee.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function De(e,t){this.key=e,this.attributes=t,this.clear()}De.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Oe(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Oe.prototype.attach=function(){let e=`out`,t=`in`;this.undirected&&(e=t=`undirected`);let n=this.source.key,r=this.target.key;this.source[e][r]=this,this.undirected&&n===r||(this.target[t][n]=this)},Oe.prototype.attachMulti=function(){let e=`out`,t=`in`,n=this.source.key,r=this.target.key;this.undirected&&(e=t=`undirected`);let i=this.source[e],a=i[r];a===void 0?(i[r]=this,this.undirected&&n===r||(this.target[t][n]=this)):(a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this)},Oe.prototype.detach=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),delete this.source[n][t],delete this.target[r][e]},Oe.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var ke=0,Ae=1,je=2,Me=3;function Ne(e,t,n,r,i,a,o){let s,c,l,u;if(r=``+r,n===ke){if(s=e._nodes.get(r),!s)throw new D(`Graph.${t}: could not find the "${r}" node in the graph.`);l=i,u=a}else if(n===Me){if(i=``+i,c=e._edges.get(i),!c)throw new D(`Graph.${t}: could not find the "${i}" edge in the graph.`);let n=c.source.key,d=c.target.key;if(r===n)s=c.target;else if(r===d)s=c.source;else throw new D(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${n}, ${d}).`);l=a,u=o}else{if(c=e._edges.get(r),!c)throw new D(`Graph.${t}: could not find the "${r}" edge in the graph.`);s=n===Ae?c.source:c.target,l=i,u=a}return[s,l,u]}function Pe(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ne(this,t,n,e,r,i);return a.attributes[o]}}function Fe(e,t,n){e.prototype[t]=function(e,r){let[i]=Ne(this,t,n,e,r);return i.attributes}}function Ie(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ne(this,t,n,e,r,i);return a.attributes.hasOwnProperty(o)}}function Le(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=Ne(this,t,n,e,r,i,a);return o.attributes[s]=c,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function Re(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=Ne(this,t,n,e,r,i,a);if(typeof c!=`function`)throw new E(`Graph.${t}: updater should be a function.`);let l=o.attributes;return l[s]=c(l[s]),this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function ze(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ne(this,t,n,e,r,i);return delete a.attributes[o],this.emit(`nodeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:o}),this}}function Be(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ne(this,t,n,e,r,i);if(!ge(o))throw new E(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=o,this.emit(`nodeAttributesUpdated`,{key:a.key,type:`replace`,attributes:a.attributes}),this}}function Ve(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ne(this,t,n,e,r,i);if(!ge(o))throw new E(`Graph.${t}: provided attributes are not a plain object.`);return me(a.attributes,o),this.emit(`nodeAttributesUpdated`,{key:a.key,type:`merge`,attributes:a.attributes,data:o}),this}}function He(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ne(this,t,n,e,r,i);if(typeof o!=`function`)throw new E(`Graph.${t}: provided updater is not a function.`);return a.attributes=o(a.attributes),this.emit(`nodeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}var Ue=[{name:e=>`get${e}Attribute`,attacher:Pe},{name:e=>`get${e}Attributes`,attacher:Fe},{name:e=>`has${e}Attribute`,attacher:Ie},{name:e=>`set${e}Attribute`,attacher:Le},{name:e=>`update${e}Attribute`,attacher:Re},{name:e=>`remove${e}Attribute`,attacher:ze},{name:e=>`replace${e}Attributes`,attacher:Be},{name:e=>`merge${e}Attributes`,attacher:Ve},{name:e=>`update${e}Attributes`,attacher:He}];function We(e){Ue.forEach(function({name:t,attacher:n}){n(e,t(`Node`),ke),n(e,t(`Source`),Ae),n(e,t(`Target`),je),n(e,t(`Opposite`),Me)})}function Ge(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=he(this,a,o,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return i.attributes[r]}}function Ke(e,t,n){e.prototype[t]=function(e){let r;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let i=``+e,a=``+arguments[1];if(r=he(this,i,a,n),!r)throw new D(`Graph.${t}: could not find an edge for the given path ("${i}" - "${a}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,r=this._edges.get(e),!r)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return r.attributes}}function qe(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=he(this,a,o,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return i.attributes.hasOwnProperty(r)}}function Je(e,t,n){e.prototype[t]=function(e,r,i){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],i=arguments[3],a=he(this,o,s,n),!a)throw new D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes[r]=i,this.emit(`edgeAttributesUpdated`,{key:a.key,type:`set`,attributes:a.attributes,name:r}),this}}function Ye(e,t,n){e.prototype[t]=function(e,r,i){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],i=arguments[3],a=he(this,o,s,n),!a)throw new D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof i!=`function`)throw new E(`Graph.${t}: updater should be a function.`);return a.attributes[r]=i(a.attributes[r]),this.emit(`edgeAttributesUpdated`,{key:a.key,type:`set`,attributes:a.attributes,name:r}),this}}function Xe(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=he(this,a,o,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return delete i.attributes[r],this.emit(`edgeAttributesUpdated`,{key:i.key,type:`remove`,attributes:i.attributes,name:r}),this}}function Ze(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=he(this,a,o,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!ge(r))throw new E(`Graph.${t}: provided attributes are not a plain object.`);return i.attributes=r,this.emit(`edgeAttributesUpdated`,{key:i.key,type:`replace`,attributes:i.attributes}),this}}function Qe(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=he(this,a,o,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!ge(r))throw new E(`Graph.${t}: provided attributes are not a plain object.`);return me(i.attributes,r),this.emit(`edgeAttributesUpdated`,{key:i.key,type:`merge`,attributes:i.attributes,data:r}),this}}function $e(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new O(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=he(this,a,o,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new O(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new D(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof r!=`function`)throw new E(`Graph.${t}: provided updater is not a function.`);return i.attributes=r(i.attributes),this.emit(`edgeAttributesUpdated`,{key:i.key,type:`update`,attributes:i.attributes}),this}}var et=[{name:e=>`get${e}Attribute`,attacher:Ge},{name:e=>`get${e}Attributes`,attacher:Ke},{name:e=>`has${e}Attribute`,attacher:qe},{name:e=>`set${e}Attribute`,attacher:Je},{name:e=>`update${e}Attribute`,attacher:Ye},{name:e=>`remove${e}Attribute`,attacher:Xe},{name:e=>`replace${e}Attributes`,attacher:Ze},{name:e=>`merge${e}Attributes`,attacher:Qe},{name:e=>`update${e}Attributes`,attacher:$e}];function tt(e){et.forEach(function({name:t,attacher:n}){n(e,t(`Edge`),`mixed`),n(e,t(`DirectedEdge`),`directed`),n(e,t(`UndirectedEdge`),`undirected`)})}var nt=[{name:`edges`,type:`mixed`},{name:`inEdges`,type:`directed`,direction:`in`},{name:`outEdges`,type:`directed`,direction:`out`},{name:`inboundEdges`,type:`mixed`,direction:`in`},{name:`outboundEdges`,type:`mixed`,direction:`out`},{name:`directedEdges`,type:`directed`},{name:`undirectedEdges`,type:`undirected`}];function rt(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function it(e,t,n,r){let i,a,o,s=!1;for(let c in t)if(c!==r){i=t[c];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function at(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function ot(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function st(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function ct(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function lt(e,t){if(e.size===0)return[];if(t===`mixed`||t===e.type)return Array.from(e._edges.keys());let n=t===`undirected`?e.undirectedSize:e.directedSize,r=Array(n),i=t===`undirected`,a=e._edges.values(),o=0,s,c;for(;s=a.next(),s.done!==!0;)c=s.value,c.undirected===i&&(r[o++]=c.key);return r}function ut(e,t,n,r){if(t.size===0)return;let i=n!==`mixed`&&n!==t.type,a=n===`undirected`,o,s,c=!1,l=t._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:t,attributes:n,source:l,target:u}=s;if(c=r(t,n,l.key,u.key,l.attributes,u.attributes,s.undirected),e&&c)return t}}function dt(e,t){if(e.size===0)return Ce();let n=t!==`mixed`&&t!==e.type,r=t===`undirected`,i=e._edges.values();return{[Symbol.iterator](){return this},next(){let e,t;for(;;){if(e=i.next(),e.done)return e;if(t=e.value,!(n&&t.undirected!==r))break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}}}function ft(e,t,n,r,i,a){let o=t?it:rt,s;if(n!==`undirected`&&(r!==`out`&&(s=o(e,i.in,a),e&&s)||r!==`in`&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!==`directed`&&(s=o(e,i.undirected,a),e&&s))return s}function pt(e,t,n,r){let i=[];return ft(!1,e,t,n,r,function(e){i.push(e)}),i}function mt(e,t,n){let r=Ce();return e!==`undirected`&&(t!==`out`&&n.in!==void 0&&(r=Se(r,at(n.in))),t!==`in`&&n.out!==void 0&&(r=Se(r,at(n.out,t?void 0:n.key)))),e!==`directed`&&n.undirected!==void 0&&(r=Se(r,at(n.undirected))),r}function ht(e,t,n,r,i,a,o){let s=n?st:ot,c;if(t!==`undirected`&&(i.in!==void 0&&r!==`out`&&(c=s(e,i.in,a,o),e&&c)||i.out!==void 0&&r!==`in`&&(r||i.key!==a)&&(c=s(e,i.out,a,o),e&&c))||t!==`directed`&&i.undirected!==void 0&&(c=s(e,i.undirected,a,o),e&&c))return c}function gt(e,t,n,r,i){let a=[];return ht(!1,e,t,n,r,i,function(e){a.push(e)}),a}function _t(e,t,n,r){let i=Ce();return e!==`undirected`&&(n.in!==void 0&&t!==`out`&&r in n.in&&(i=Se(i,ct(n.in,r))),n.out!==void 0&&t!==`in`&&r in n.out&&(t||n.key!==r)&&(i=Se(i,ct(n.out,r)))),e!==`directed`&&n.undirected!==void 0&&r in n.undirected&&(i=Se(i,ct(n.undirected,r))),i}function vt(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];if(!arguments.length)return lt(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new D(`Graph.${n}: could not find the "${e}" node in the graph.`);return pt(this.multi,r===`mixed`?this.type:r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let a=this._nodes.get(e);if(!a)throw new D(`Graph.${n}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new D(`Graph.${n}: could not find the "${t}" target node in the graph.`);return gt(r,this.multi,i,a,t)}throw new E(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function yt(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r===`mixed`||this.type===`mixed`||r===this.type){if(arguments.length===1)return n=e,ut(!1,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new D(`Graph.${a}: could not find the "${e}" node in the graph.`);return ft(!1,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new D(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new D(`Graph.${a}: could not find the "${t}" target node in the graph.`);return ht(!1,r,this.multi,i,o,t,n)}throw new E(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n;if(e.length===0){let i=0;r!==`directed`&&(i+=this.undirectedSize),r!==`undirected`&&(i+=this.directedSize),n=Array(i);let a=0;e.push((e,r,i,o,s,c,l)=>{n[a++]=t(e,r,i,o,s,c,l)})}else n=[],e.push((e,r,i,a,o,s,c)=>{n.push(t(e,r,i,a,o,s,c))});return this[a].apply(this,e),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((e,r,i,a,o,s,c)=>{t(e,r,i,a,o,s,c)&&n.push(e)}),this[a].apply(this,e),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let e=Array.prototype.slice.call(arguments);if(e.length<2||e.length>4)throw new E(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${e.length}).`);if(typeof e[e.length-1]==`function`&&typeof e[e.length-2]!=`function`)throw new E(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let t,n;e.length===2?(t=e[0],n=e[1],e=[]):e.length===3?(t=e[1],n=e[2],e=[e[0]]):e.length===4&&(t=e[2],n=e[3],e=[e[0],e[1]]);let r=n;return e.push((e,n,i,a,o,s,c)=>{r=t(r,e,n,i,a,o,s,c)}),this[a].apply(this,e),r}}function bt(e,t){let{name:n,type:r,direction:i}=t,a=`find`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return!1;if(arguments.length===1)return n=e,ut(!0,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new D(`Graph.${a}: could not find the "${e}" node in the graph.`);return ft(!0,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new D(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new D(`Graph.${a}: could not find the "${t}" target node in the graph.`);return ht(!0,r,this.multi,i,o,t,n)}throw new E(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o=`some`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>t(e,n,r,i,a,o,s)),!!this[a].apply(this,e)};let s=`every`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>!t(e,n,r,i,a,o,s)),!this[a].apply(this,e)}}function xt(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return Ce();if(!arguments.length)return dt(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.${a}: could not find the "${e}" node in the graph.`);return mt(r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new D(`Graph.${a}: could not find the "${t}" target node in the graph.`);return _t(r,i,n,t)}throw new E(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function St(e){nt.forEach(t=>{vt(e,t),yt(e,t),bt(e,t),xt(e,t)})}var Ct=[{name:`neighbors`,type:`mixed`},{name:`inNeighbors`,type:`directed`,direction:`in`},{name:`outNeighbors`,type:`directed`,direction:`out`},{name:`inboundNeighbors`,type:`mixed`,direction:`in`},{name:`outboundNeighbors`,type:`mixed`,direction:`out`},{name:`directedNeighbors`,type:`directed`},{name:`undirectedNeighbors`,type:`undirected`}];function wt(){this.A=null,this.B=null}wt.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)},wt.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Tt(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,c=o.target,l=s===n?c:s;if(t&&t.has(l.key))continue;let u=i(l.key,l.attributes);if(e&&u)return l.key}}function Et(e,t,n,r,i){if(t!==`mixed`){if(t===`undirected`)return Tt(e,null,r,r.undirected,i);if(typeof n==`string`)return Tt(e,null,r,r[n],i)}let a=new wt,o;if(t!==`undirected`){if(n!==`out`){if(o=Tt(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!==`in`){if(o=Tt(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!==`directed`&&(o=Tt(e,a,r,r.undirected,i),e&&o))return o}function Dt(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Object.keys(n.undirected);if(typeof t==`string`)return Object.keys(n[t])}let r=[];return Et(!1,e,t,n,function(e){r.push(e)}),r}function Ot(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],c=s.source,l=s.target;o=c===t?l:c,e&&e.has(o.key)&&(o=null)}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function kt(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Ot(null,n,n.undirected);if(typeof t==`string`)return Ot(null,n,n[t])}let r=Ce(),i=new wt;return e!==`undirected`&&(t!==`out`&&(r=Se(r,Ot(i,n,n.in))),t!==`in`&&(r=Se(r,Ot(i,n,n.out)))),e!==`directed`&&(r=Se(r,Ot(i,n,n.undirected))),r}function At(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new D(`Graph.${n}: could not find the "${e}" node in the graph.`);return Dt(r===`mixed`?this.type:r,i,t)}}function jt(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new D(`Graph.${a}: could not find the "${e}" node in the graph.`);Et(!1,r===`mixed`?this.type:r,i,n,t)};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(e,t){let n=[];return this[a](e,(e,r)=>{n.push(t(e,r))}),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(e,t){let n=[];return this[a](e,(e,r)=>{t(e,r)&&n.push(e)}),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(e,t,n){if(arguments.length<3)throw new E(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let r=n;return this[a](e,(e,n)=>{r=t(r,e,n)}),r}}function Mt(e,t){let{name:n,type:r,direction:i}=t,a=n[0].toUpperCase()+n.slice(1,-1),o=`find`+a;e.prototype[o]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new D(`Graph.${o}: could not find the "${e}" node in the graph.`);return Et(!0,r===`mixed`?this.type:r,i,n,t)};let s=`some`+a;e.prototype[s]=function(e,t){return!!this[o](e,t)};let c=`every`+a;e.prototype[c]=function(e,t){return!this[o](e,(e,n)=>!t(e,n))}}function Nt(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return Ce();e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new D(`Graph.${a}: could not find the "${e}" node in the graph.`);return kt(r===`mixed`?this.type:r,i,t)}}function Pt(e){Ct.forEach(t=>{At(e,t),jt(e,t),Mt(e,t),Nt(e,t)})}function Ft(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,c,l,u,d,f,p;for(;s=a.next(),s.done!==!0;){let r=!1;if(c=s.value,o!==`undirected`)for(l in u=c.out,u){d=u[l];do{if(f=d.target,r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}if(o!==`directed`){for(l in u=c.undirected,u)if(!(t&&c.key>l)){d=u[l];do{if(f=d.target,f.key!==l&&(f=d.source),r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}}if(n&&!r&&(p=i(c.key,null,c.attributes,null,null,null,null),e&&p))return null}}function It(e,t){let n={key:e};return _e(t.attributes)||(n.attributes=me({},t.attributes)),n}function Lt(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return _e(n.attributes)||(r.attributes=me({},n.attributes)),e===`mixed`&&n.undirected&&(r.undirected=!0),r}function Rt(e){if(!ge(e))throw new E(`Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.`);if(!(`key`in e))throw new E(`Graph.import: serialized node is missing its key.`);if(`attributes`in e&&(!ge(e.attributes)||e.attributes===null))throw new E(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`)}function zt(e){if(!ge(e))throw new E(`Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.`);if(!(`source`in e))throw new E(`Graph.import: serialized edge is missing its source.`);if(!(`target`in e))throw new E(`Graph.import: serialized edge is missing its target.`);if(`attributes`in e&&(!ge(e.attributes)||e.attributes===null))throw new E(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`);if(`undirected`in e&&typeof e.undirected!=`boolean`)throw new E(`Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.`)}var Bt=xe(),Vt=new Set([`directed`,`undirected`,`mixed`]),Ht=new Set([`domain`,`_events`,`_eventsCount`,`_maxListeners`]),Ut=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:`directed`},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:`undirected`},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:`directed`},{name:e=>`${e}UndirectedEdgeWithKey`,type:`undirected`}],Wt={allowSelfLoops:!0,multi:!1,type:`mixed`};function Gt(e,t,n){if(n&&!ge(n))throw new E(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=``+t,n||={},e._nodes.has(t))throw new O(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function Kt(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function qt(e,t,n,r,i,a,o,s){if(!r&&e.type===`undirected`)throw new O(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type===`directed`)throw new O(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!ge(s))throw new E(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(a=``+a,o=``+o,s||={},!e.allowSelfLoops&&a===o)throw new O(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=e._nodes.get(a),l=e._nodes.get(o);if(!c)throw new D(`Graph.${t}: source node "${a}" not found.`);if(!l)throw new D(`Graph.${t}: target node "${o}" not found.`);let u={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=``+i,e._edges.has(i))throw new O(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?c.undirected[o]!==void 0:c.out[o]!==void 0))throw new O(`Graph.${t}: an edge linking "${a}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let d=new Oe(r,i,c,l,s);e._edges.set(i,d);let f=a===o;return r?(c.undirectedDegree++,l.undirectedDegree++,f&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,l.inDegree++,f&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,u.key=i,e.emit(`edgeAdded`,u),i}function Jt(e,t,n,r,i,a,o,s,c){if(!r&&e.type===`undirected`)throw new O(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type===`directed`)throw new O(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(c){if(typeof s!=`function`)throw new E(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!ge(s))throw new E(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}a=``+a,o=``+o;let l;if(c&&(l=s,s=void 0),!e.allowSelfLoops&&a===o)throw new O(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=e._nodes.get(a),d=e._nodes.get(o),f,p;if(!n&&(f=e._edges.get(i),f)){if((f.source.key!==a||f.target.key!==o)&&(!r||f.source.key!==o||f.target.key!==a))throw new O(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${f.source.key}", "${f.target.key}").`);p=f}if(!p&&!e.multi&&u&&(p=r?u.undirected[o]:u.out[o]),p){let t=[p.key,!1,!1,!1];if(c?!l:!s)return t;if(c){let t=p.attributes;p.attributes=l(t),e.emit(`edgeAttributesUpdated`,{type:`replace`,key:p.key,attributes:p.attributes})}else me(p.attributes,s),e.emit(`edgeAttributesUpdated`,{type:`merge`,key:p.key,attributes:p.attributes,data:s});return t}s||={},c&&l&&(s=l(s));let m={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=``+i,e._edges.has(i))throw new O(`Graph.${t}: the "${i}" edge already exists in the graph.`);let h=!1,g=!1;u||(u=Kt(e,a,{}),h=!0,a===o&&(d=u,g=!0)),d||(d=Kt(e,o,{}),g=!0),f=new Oe(r,i,u,d,s),e._edges.set(i,f);let _=a===o;return r?(u.undirectedDegree++,d.undirectedDegree++,_&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,d.inDegree++,_&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,m.key=i,e.emit(`edgeAdded`,m),[i,!0,h,g]}function Yt(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit(`edgeDropped`,{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var k=class e extends fe.EventEmitter{constructor(e){if(super(),e=me({},Wt,e),typeof e.multi!=`boolean`)throw new E(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Vt.has(e.type))throw new E(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=`boolean`)throw new E(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type===`mixed`?Te:e.type===`directed`?Ee:De;ve(this,`NodeDataClass`,t);let n=`geid_`+Bt()+`_`,r=0;ve(this,`_attributes`,{}),ve(this,`_nodes`,new Map),ve(this,`_edges`,new Map),ve(this,`_directedSize`,0),ve(this,`_undirectedSize`,0),ve(this,`_directedSelfLoopCount`,0),ve(this,`_undirectedSelfLoopCount`,0),ve(this,`_edgeKeyGenerator`,()=>{let e;do e=n+r++;while(this._edges.has(e));return e}),ve(this,`_options`,e),Ht.forEach(e=>ve(this,e,this[e])),ye(this,`order`,()=>this._nodes.size),ye(this,`size`,()=>this._edges.size),ye(this,`directedSize`,()=>this._directedSize),ye(this,`undirectedSize`,()=>this._undirectedSize),ye(this,`selfLoopCount`,()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ye(this,`directedSelfLoopCount`,()=>this._directedSelfLoopCount),ye(this,`undirectedSelfLoopCount`,()=>this._undirectedSelfLoopCount),ye(this,`multi`,this._options.multi),ye(this,`type`,this._options.type),ye(this,`allowSelfLoops`,this._options.allowSelfLoops),ye(this,`implementation`,()=>`graphology`)}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(``+e)}hasDirectedEdge(e,t){if(this.type===`undirected`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&!n.undirected}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new E(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type===`directed`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&n.undirected}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new E(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){let t=``+e;return this._edges.has(t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out!==void 0&&n.out.hasOwnProperty(t)||n.undirected!==void 0&&n.undirected.hasOwnProperty(t):!1}throw new E(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type===`undirected`)return;if(e=``+e,t=``+t,this.multi)throw new O(`Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new D(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new D(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||void 0;if(r)return r.key}undirectedEdge(e,t){if(this.type===`directed`)return;if(e=``+e,t=``+t,this.multi)throw new O(`Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new D(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new D(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let r=n.undirected&&n.undirected[t]||void 0;if(r)return r.key}edge(e,t){if(this.multi)throw new O(`Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.`);e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new D(`Graph.edge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key}areDirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out}areInNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in}areUndirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`directed`&&t in n.undirected}areNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&(t in n.in||t in n.out)||this.type!==`directed`&&t in n.undirected}areInboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in||this.type!==`directed`&&t in n.undirected}areOutboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new D(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out||this.type!==`directed`&&t in n.undirected}inDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree}outDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree}directedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree}undirectedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree}inboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree),n}outboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.outDegree),n}degree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree,r+=t.directedLoops),n-r}outboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.outDegree,r+=t.directedLoops),n-r}degreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree,r+=t.directedLoops*2),n-r}source(e){e=``+e;let t=this._edges.get(e);if(!t)throw new D(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=``+e;let t=this._edges.get(e);if(!t)throw new D(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=``+e;let t=this._edges.get(e);if(!t)throw new D(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=``+e,t=``+t;let n=this._edges.get(t);if(!n)throw new D(`Graph.opposite: could not find the "${t}" edge in the graph.`);let r=n.source.key,i=n.target.key;if(e===r)return i;if(e===i)return r;throw new D(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${i}).`)}hasExtremity(e,t){e=``+e,t=``+t;let n=this._edges.get(e);if(!n)throw new D(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new D(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new D(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=``+e;let t=this._edges.get(e);if(!t)throw new D(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return Gt(this,e,t).key}mergeNode(e,t){if(t&&!ge(t))throw new E(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=``+e,t||={};let n=this._nodes.get(e);return n?(t&&(me(n.attributes,t),this.emit(`nodeAttributesUpdated`,{type:`merge`,key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!=`function`)throw new E(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=``+e;let n=this._nodes.get(e);if(n){if(t){let r=n.attributes;n.attributes=t(r),this.emit(`nodeAttributesUpdated`,{type:`replace`,key:e,attributes:n.attributes})}return[e,!1]}let r=t?t({}):{};return n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:r}),[e,!0]}dropNode(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new D(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!==`undirected`){for(let e in t.out){n=t.out[e];do Yt(this,n),n=n.next;while(n)}for(let e in t.in){n=t.in[e];do Yt(this,n),n=n.next;while(n)}}if(this.type!==`directed`)for(let e in t.undirected){n=t.undirected[e];do Yt(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit(`nodeDropped`,{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let e=``+arguments[0],n=``+arguments[1];if(t=he(this,e,n,this.type),!t)throw new D(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(e=``+e,t=this._edges.get(e),!t)throw new D(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Yt(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new O(`Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new O(`Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);e=``+e,t=``+t;let n=he(this,e,t,`directed`);if(!n)throw new D(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Yt(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new O(`Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new O(`Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);let n=he(this,e,t,`undirected`);if(!n)throw new D(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Yt(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit(`cleared`)}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit(`edgesCleared`)}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!=`function`)throw new E(`Graph.updateAttribute: updater should be a function.`);let n=this._attributes[e];return this._attributes[e]=t(n),this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit(`attributesUpdated`,{type:`remove`,attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!ge(e))throw new E(`Graph.replaceAttributes: provided attributes are not a plain object.`);return this._attributes=e,this.emit(`attributesUpdated`,{type:`replace`,attributes:this._attributes}),this}mergeAttributes(e){if(!ge(e))throw new E(`Graph.mergeAttributes: provided attributes are not a plain object.`);return me(this._attributes,e),this.emit(`attributesUpdated`,{type:`merge`,attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=`function`)throw new E(`Graph.updateAttributes: provided updater is not a function.`);return this._attributes=e(this._attributes),this.emit(`attributesUpdated`,{type:`update`,attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!=`function`)throw new E(`Graph.updateEachNodeAttributes: expecting an updater function.`);if(t&&!be(t))throw new E(`Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,i.attributes=e(i.key,i.attributes);this.emit(`eachNodeAttributesUpdated`,{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!=`function`)throw new E(`Graph.updateEachEdgeAttributes: expecting an updater function.`);if(t&&!be(t))throw new E(`Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._edges.values(),r,i,a,o;for(;r=n.next(),r.done!==!0;)i=r.value,a=i.source,o=i.target,i.attributes=e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected);this.emit(`eachEdgeAttributesUpdated`,{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!=`function`)throw new E(`Graph.forEachAdjacencyEntry: expecting a callback.`);Ft(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new E(`Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.`);Ft(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=`function`)throw new E(`Graph.forEachAssymetricAdjacencyEntry: expecting a callback.`);Ft(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new E(`Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.`);Ft(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=`function`)throw new E(`Graph.forEachNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!=`function`)throw new E(`Graph.findNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!=`function`)throw new E(`Graph.mapNode: expecting a callback.`);let t=this._nodes.values(),n,r,i=Array(this.order),a=0;for(;n=t.next(),n.done!==!0;)r=n.value,i[a++]=e(r.key,r.attributes);return i}someNode(e){if(typeof e!=`function`)throw new E(`Graph.someNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!=`function`)throw new E(`Graph.everyNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!=`function`)throw new E(`Graph.filterNodes: expecting a callback.`);let t=this._nodes.values(),n,r,i=[];for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)&&i.push(r.key);return i}reduceNodes(e,t){if(typeof e!=`function`)throw new E(`Graph.reduceNodes: expecting a callback.`);if(arguments.length<2)throw new E(`Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let n=t,r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,n=e(n,a.key,a.attributes);return n}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){let e=Array(this._nodes.size),t=0;this._nodes.forEach((n,r)=>{e[t++]=It(r,n)});let n=Array(this._edges.size);return t=0,this._edges.forEach((e,r)=>{n[t++]=Lt(this.type,r,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(t,n=!1){if(t instanceof e)return t.forEachNode((e,t)=>{n?this.mergeNode(e,t):this.addNode(e,t)}),t.forEachEdge((e,t,r,i,a,o,s)=>{n?s?this.mergeUndirectedEdgeWithKey(e,r,i,t):this.mergeDirectedEdgeWithKey(e,r,i,t):s?this.addUndirectedEdgeWithKey(e,r,i,t):this.addDirectedEdgeWithKey(e,r,i,t)}),this;if(!ge(t))throw new E(`Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.`);if(t.attributes){if(!ge(t.attributes))throw new E(`Graph.import: invalid attributes. Expecting a plain object.`);n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,a,o,s;if(t.nodes){if(a=t.nodes,!Array.isArray(a))throw new E(`Graph.import: invalid nodes. Expecting an array.`);for(r=0,i=a.length;r<i;r++){o=a[r],Rt(o);let{key:e,attributes:t}=o;n?this.mergeNode(e,t):this.addNode(e,t)}}if(t.edges){let e=!1;if(this.type===`undirected`&&(e=!0),a=t.edges,!Array.isArray(a))throw new E(`Graph.import: invalid edges. Expecting an array.`);for(r=0,i=a.length;r<i;r++){s=a[r],zt(s);let{source:t,target:i,attributes:o,undirected:c=e}=s,l;`key`in s?(l=n?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,l.call(this,s.key,t,i,o)):(l=n?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,l.call(this,t,i,o))}}return this}nullCopy(t){let n=new e(me({},this._options,t));return n.replaceAttributes(me({},this.getAttributes())),n}emptyCopy(e){let t=this.nullCopy(e);return this._nodes.forEach((e,n)=>{let r=me({},e.attributes);e=new t.NodeDataClass(n,r),t._nodes.set(n,e)}),t}copy(e){if(e||={},typeof e.type==`string`&&e.type!==this.type&&e.type!==`mixed`)throw new O(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi==`boolean`&&e.multi!==this.multi&&e.multi!==!0)throw new O(`Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.`);if(typeof e.allowSelfLoops==`boolean`&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new O(`Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.`);let t=this.emptyCopy(e),n=this._edges.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,qt(t,`copy`,!1,i.undirected,i.key,i.source.key,i.target.key,me({},i.attributes));return t}toJSON(){return this.export()}toString(){return`[object Graph]`}inspect(){let e={};this._nodes.forEach((t,n)=>{e[n]=t.attributes});let t={},n={};this._edges.forEach((e,r)=>{let i=e.undirected?`--`:`->`,a=``,o=e.source.key,s=e.target.key,c;e.undirected&&o>s&&(c=o,o=s,s=c);let l=`(${o})${i}(${s})`;r.startsWith(`geid_`)?this.multi&&(n[l]===void 0?n[l]=0:n[l]++,a+=`${n[l]}. `):a+=`[${r}]: `,a+=l,t[a]=e.attributes});let r={};for(let e in this)this.hasOwnProperty(e)&&!Ht.has(e)&&typeof this[e]!=`function`&&typeof e!=`symbol`&&(r[e]=this[e]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,ve(r,`constructor`,this.constructor),r}};typeof Symbol<`u`&&(k.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=k.prototype.inspect),Ut.forEach(e=>{[`add`,`merge`,`update`].forEach(t=>{let n=e.name(t),r=t===`add`?qt:Jt;e.generateKey?k.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)===`undirected`,null,i,a,o,t===`update`)}:k.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)===`undirected`,i,a,o,s,t===`update`)}})}),We(k),tt(k),St(k),Pt(k);var Xt=class extends k{constructor(e){let t=me({type:`directed`},e);if(`multi`in t&&t.multi!==!1)throw new E(`DirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`directed`)throw new E(`DirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},Zt=class extends k{constructor(e){let t=me({type:`undirected`},e);if(`multi`in t&&t.multi!==!1)throw new E(`UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`undirected`)throw new E(`UndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},Qt=class extends k{constructor(e){let t=me({multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new E(`MultiGraph.from: inconsistent indication that the graph should be simple in given options!`);super(t)}},$t=class extends k{constructor(e){let t=me({type:`directed`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new E(`MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`directed`)throw new E(`MultiDirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},en=class extends k{constructor(e){let t=me({type:`undirected`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new E(`MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`undirected`)throw new E(`MultiUndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}};function tn(e){e.from=function(t,n){let r=new e(me({},t.options,n));return r.import(t),r}}tn(k),tn(Xt),tn(Zt),tn(Qt),tn($t),tn(en),k.Graph=k,k.DirectedGraph=Xt,k.UndirectedGraph=Zt,k.MultiGraph=Qt,k.MultiDirectedGraph=$t,k.MultiUndirectedGraph=en,k.InvalidArgumentsGraphError=E,k.NotFoundGraphError=D,k.UsageGraphError=O;function nn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function rn(e){var t=nn(e,`string`);return typeof t==`symbol`?t:t+``}function an(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function on(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,rn(r.key),r)}}function sn(e,t,n){return t&&on(e.prototype,t),n&&on(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function cn(e){return cn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},cn(e)}function ln(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ln=function(){return!!e})()}function un(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function dn(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return un(e)}function fn(e,t,n){return t=cn(t),dn(e,ln()?Reflect.construct(t,n||[],cn(e).constructor):t.apply(e,n))}function pn(e,t){return pn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},pn(e,t)}function mn(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&pn(e,t)}function hn(e){if(Array.isArray(e))return e}function gn(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function _n(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function vn(e,t){if(e){if(typeof e==`string`)return _n(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_n(e,t):void 0}}function yn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bn(e,t){return hn(e)||gn(e,t)||vn(e,t)||yn()}var xn={black:`#000000`,silver:`#C0C0C0`,gray:`#808080`,grey:`#808080`,white:`#FFFFFF`,maroon:`#800000`,red:`#FF0000`,purple:`#800080`,fuchsia:`#FF00FF`,green:`#008000`,lime:`#00FF00`,olive:`#808000`,yellow:`#FFFF00`,navy:`#000080`,blue:`#0000FF`,teal:`#008080`,aqua:`#00FFFF`,darkblue:`#00008B`,mediumblue:`#0000CD`,darkgreen:`#006400`,darkcyan:`#008B8B`,deepskyblue:`#00BFFF`,darkturquoise:`#00CED1`,mediumspringgreen:`#00FA9A`,springgreen:`#00FF7F`,cyan:`#00FFFF`,midnightblue:`#191970`,dodgerblue:`#1E90FF`,lightseagreen:`#20B2AA`,forestgreen:`#228B22`,seagreen:`#2E8B57`,darkslategray:`#2F4F4F`,darkslategrey:`#2F4F4F`,limegreen:`#32CD32`,mediumseagreen:`#3CB371`,turquoise:`#40E0D0`,royalblue:`#4169E1`,steelblue:`#4682B4`,darkslateblue:`#483D8B`,mediumturquoise:`#48D1CC`,indigo:`#4B0082`,darkolivegreen:`#556B2F`,cadetblue:`#5F9EA0`,cornflowerblue:`#6495ED`,rebeccapurple:`#663399`,mediumaquamarine:`#66CDAA`,dimgray:`#696969`,dimgrey:`#696969`,slateblue:`#6A5ACD`,olivedrab:`#6B8E23`,slategray:`#708090`,slategrey:`#708090`,lightslategray:`#778899`,lightslategrey:`#778899`,mediumslateblue:`#7B68EE`,lawngreen:`#7CFC00`,chartreuse:`#7FFF00`,aquamarine:`#7FFFD4`,skyblue:`#87CEEB`,lightskyblue:`#87CEFA`,blueviolet:`#8A2BE2`,darkred:`#8B0000`,darkmagenta:`#8B008B`,saddlebrown:`#8B4513`,darkseagreen:`#8FBC8F`,lightgreen:`#90EE90`,mediumpurple:`#9370DB`,darkviolet:`#9400D3`,palegreen:`#98FB98`,darkorchid:`#9932CC`,yellowgreen:`#9ACD32`,sienna:`#A0522D`,brown:`#A52A2A`,darkgray:`#A9A9A9`,darkgrey:`#A9A9A9`,lightblue:`#ADD8E6`,greenyellow:`#ADFF2F`,paleturquoise:`#AFEEEE`,lightsteelblue:`#B0C4DE`,powderblue:`#B0E0E6`,firebrick:`#B22222`,darkgoldenrod:`#B8860B`,mediumorchid:`#BA55D3`,rosybrown:`#BC8F8F`,darkkhaki:`#BDB76B`,mediumvioletred:`#C71585`,indianred:`#CD5C5C`,peru:`#CD853F`,chocolate:`#D2691E`,tan:`#D2B48C`,lightgray:`#D3D3D3`,lightgrey:`#D3D3D3`,thistle:`#D8BFD8`,orchid:`#DA70D6`,goldenrod:`#DAA520`,palevioletred:`#DB7093`,crimson:`#DC143C`,gainsboro:`#DCDCDC`,plum:`#DDA0DD`,burlywood:`#DEB887`,lightcyan:`#E0FFFF`,lavender:`#E6E6FA`,darksalmon:`#E9967A`,violet:`#EE82EE`,palegoldenrod:`#EEE8AA`,lightcoral:`#F08080`,khaki:`#F0E68C`,aliceblue:`#F0F8FF`,honeydew:`#F0FFF0`,azure:`#F0FFFF`,sandybrown:`#F4A460`,wheat:`#F5DEB3`,beige:`#F5F5DC`,whitesmoke:`#F5F5F5`,mintcream:`#F5FFFA`,ghostwhite:`#F8F8FF`,salmon:`#FA8072`,antiquewhite:`#FAEBD7`,linen:`#FAF0E6`,lightgoldenrodyellow:`#FAFAD2`,oldlace:`#FDF5E6`,magenta:`#FF00FF`,deeppink:`#FF1493`,orangered:`#FF4500`,tomato:`#FF6347`,hotpink:`#FF69B4`,coral:`#FF7F50`,darkorange:`#FF8C00`,lightsalmon:`#FFA07A`,orange:`#FFA500`,lightpink:`#FFB6C1`,pink:`#FFC0CB`,gold:`#FFD700`,peachpuff:`#FFDAB9`,navajowhite:`#FFDEAD`,moccasin:`#FFE4B5`,bisque:`#FFE4C4`,mistyrose:`#FFE4E1`,blanchedalmond:`#FFEBCD`,papayawhip:`#FFEFD5`,lavenderblush:`#FFF0F5`,seashell:`#FFF5EE`,cornsilk:`#FFF8DC`,lemonchiffon:`#FFFACD`,floralwhite:`#FFFAF0`,snow:`#FFFAFA`,lightyellow:`#FFFFE0`,ivory:`#FFFFF0`},Sn=new Int8Array(4),Cn=new Int32Array(Sn.buffer,0,1),wn=new Float32Array(Sn.buffer,0,1),Tn=/^\s*rgba?\s*\(/,En=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Dn(e){var t=0,n=0,r=0,i=1;if(e[0]===`#`)e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(Tn.test(e)){var a=e.match(En);a&&(t=+a[1],n=+a[2],r=+a[3],a[4]&&(i=+a[4]))}return{r:t,g:n,b:r,a:i}}var On={};for(var kn in xn)On[kn]=jn(xn[kn]),On[xn[kn]]=On[kn];function An(e,t,n,r,i){return Cn[0]=r<<24|n<<16|t<<8|e,i&&(Cn[0]&=4278190079),wn[0]}function jn(e){if(e=e.toLowerCase(),On[e]!==void 0)return On[e];var t=Dn(e),n=t.r,r=t.g,i=t.b,a=t.a;a=a*255|0;var o=An(n,r,i,a,!0);return On[e]=o,o}var Mn={};function Nn(e){if(Mn[e]!==void 0)return Mn[e];var t=An((e&16711680)>>>16,(e&65280)>>>8,e&255,255,!0);return Mn[e]=t,t}function Pn(e,t,n,r){return n+(t<<8)+(e<<16)}function Fn(e,t,n,r,i,a){var o=Math.floor(n/a*i),s=Math.floor(e.drawingBufferHeight/a-r/a*i),c=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(o,s,1,1,e.RGBA,e.UNSIGNED_BYTE,c);var l=bn(c,4);return[l[0],l[1],l[2],l[3]]}function A(e,t,n){return(t=rn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function In(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?In(Object(n),!0).forEach(function(t){A(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):In(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ln(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=cn(e))!==null;);return e}function Rn(){return Rn=typeof Reflect<`u`&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=Ln(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},Rn.apply(null,arguments)}function zn(e,t,n,r){var i=Rn(cn(1&r?e.prototype:e),t,n);return 2&r&&typeof i==`function`?function(e){return i.apply(n,e)}:i}function Bn(e){return e.normalized?1:e.size}function Vn(e){var t=0;return e.forEach(function(e){return t+=Bn(e)}),t}function Hn(e,t,n){var r=e===`VERTEX`?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw Error(`loadShader: error while creating the shader`);if(t.shaderSource(i,n),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){var a=t.getShaderInfoLog(i);throw t.deleteShader(i),Error(`loadShader: error while compiling the shader:
|
|
4
|
+
${a}
|
|
5
|
+
${n}`)}return i}function Un(e,t){return Hn(`VERTEX`,e,t)}function Wn(e,t){return Hn(`FRAGMENT`,e,t)}function Gn(e,t){var n=e.createProgram();if(n===null)throw Error(`loadProgram: error while creating the program.`);for(var r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);if(e.linkProgram(n),!e.getProgramParameter(n,e.LINK_STATUS)){var a=e.getProgramInfoLog(n);throw e.deleteProgram(n),Error(`loadProgram: error while linking the program: ${a}`)}return n}function Kn(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,a=e.fragmentShader;t.deleteShader(i),t.deleteShader(a),t.deleteProgram(r),t.deleteBuffer(n)}var qn=`#define PICKING_MODE
|
|
6
|
+
`,Jn=A(A(A(A(A(A(A(A({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),Yn=function(){function e(t,n,r){an(this,e),A(this,`array`,new Float32Array),A(this,`constantArray`,new Float32Array),A(this,`capacity`,0),A(this,`verticesCount`,0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES=`CONSTANT_ATTRIBUTES`in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA=`CONSTANT_DATA`in i?i.CONSTANT_DATA:[],this.isInstanced=`CONSTANT_ATTRIBUTES`in i,this.ATTRIBUTES_ITEMS_COUNT=Vn(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo(`normal`,t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo(`pick`,t,qn+i.VERTEX_SHADER_SOURCE,qn+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var a=Vn(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw Error(`Program: error while getting constant data (expected ${this.VERTICES} items, received ${this.CONSTANT_DATA.length} instead)`);this.constantArray=new Float32Array(this.CONSTANT_DATA.length*a);for(var o=0;o<this.CONSTANT_DATA.length;o++){var s=this.CONSTANT_DATA[o];if(s.length!==a)throw Error(`Program: error while getting constant data (one vector has ${s.length} items instead of ${a})`);for(var c=0;c<s.length;c++)this.constantArray[o*a+c]=s[c]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return sn(e,[{key:`kill`,value:function(){Kn(this.normalProgram),this.pickProgram&&=(Kn(this.pickProgram),null)}},{key:`getProgramInfo`,value:function(e,t,n,r,i){var a=this.getDefinition(),o=t.createBuffer();if(o===null)throw Error(`Program: error while creating the WebGL buffer.`);var s=Un(t,n),c=Wn(t,r),l=Gn(t,[s,c]),u={};a.UNIFORMS.forEach(function(e){var n=t.getUniformLocation(l,e);n&&(u[e]=n)});var d={};a.ATTRIBUTES.forEach(function(e){d[e.name]=t.getAttribLocation(l,e.name)});var f;if(`CONSTANT_ATTRIBUTES`in a&&(a.CONSTANT_ATTRIBUTES.forEach(function(e){d[e.name]=t.getAttribLocation(l,e.name)}),f=t.createBuffer(),f===null))throw Error(`Program: error while creating the WebGL constant buffer.`);return{name:e,program:l,gl:t,frameBuffer:i,buffer:o,constantBuffer:f||{},uniformLocations:u,attributeLocations:d,isPicking:e===`pick`,vertexShader:s,fragmentShader:c}}},{key:`bindProgram`,value:function(e){var t=this,n=0,r=e.gl,i=e.buffer;this.isInstanced?(r.bindBuffer(r.ARRAY_BUFFER,e.constantBuffer),n=0,this.CONSTANT_ATTRIBUTES.forEach(function(r){return n+=t.bindAttribute(r,e,n,!1)}),r.bufferData(r.ARRAY_BUFFER,this.constantArray,r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,e.buffer),n=0,this.ATTRIBUTES.forEach(function(r){return n+=t.bindAttribute(r,e,n,!0)}),r.bufferData(r.ARRAY_BUFFER,this.array,r.DYNAMIC_DRAW)):(r.bindBuffer(r.ARRAY_BUFFER,i),n=0,this.ATTRIBUTES.forEach(function(r){return n+=t.bindAttribute(r,e,n)}),r.bufferData(r.ARRAY_BUFFER,this.array,r.DYNAMIC_DRAW)),r.bindBuffer(r.ARRAY_BUFFER,null)}},{key:`unbindProgram`,value:function(e){var t=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!1)}),this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!0)})):this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e)})}},{key:`bindAttribute`,value:function(e,t,n,r){var i=Jn[e.type];if(typeof i!=`number`)throw Error(`Program.bind: yet unsupported attribute type "${e.type}"`);var a=t.attributeLocations[e.name],o=t.gl;if(a!==-1){o.enableVertexAttribArray(a);var s=this.isInstanced?(r?this.ATTRIBUTES_ITEMS_COUNT:Vn(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(o.vertexAttribPointer(a,e.size,e.type,e.normalized||!1,s,n),this.isInstanced&&r){if(o instanceof WebGL2RenderingContext)o.vertexAttribDivisor(a,1);else{var c=o.getExtension(`ANGLE_instanced_arrays`);c&&c.vertexAttribDivisorANGLE(a,1)}}}return e.size*i}},{key:`unbindAttribute`,value:function(e,t,n){var r=t.attributeLocations[e.name],i=t.gl;if(r!==-1&&(i.disableVertexAttribArray(r),this.isInstanced&&n)){if(i instanceof WebGL2RenderingContext)i.vertexAttribDivisor(r,0);else{var a=i.getExtension(`ANGLE_instanced_arrays`);a&&a.vertexAttribDivisorANGLE(r,0)}}}},{key:`reallocate`,value:function(e){e!==this.capacity&&(this.capacity=e,this.verticesCount=this.VERTICES*e,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:`hasNothingToRender`,value:function(){return this.verticesCount===0}},{key:`renderProgram`,value:function(e,t){var n=t.gl,r=t.program;n.enable(n.BLEND),n.useProgram(r),this.setUniforms(e,t),this.drawWebGL(this.METHOD,t)}},{key:`render`,value:function(e){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,e.width*e.pixelRatio/e.downSizingRatio,e.height*e.pixelRatio/e.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(j(j({},e),{},{pixelRatio:e.pixelRatio/e.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,e.width*e.pixelRatio,e.height*e.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(e,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:`drawWebGL`,value:function(e,t){var n=t.gl,r=t.frameBuffer;if(n.bindFramebuffer(n.FRAMEBUFFER,r),!this.isInstanced)n.drawArrays(e,0,this.verticesCount);else if(n instanceof WebGL2RenderingContext)n.drawArraysInstanced(e,0,this.VERTICES,this.capacity);else{var i=n.getExtension(`ANGLE_instanced_arrays`);i&&i.drawArraysInstancedANGLE(e,0,this.VERTICES,this.capacity)}}}])}(),Xn=function(e){function t(){return an(this,t),fn(this,t,arguments)}return mn(t,e),sn(t,[{key:`kill`,value:function(){zn(t,`kill`,this,3)([])}},{key:`process`,value:function(e,t,n){var r=t*this.STRIDE;if(n.hidden)for(var i=r+this.STRIDE;r<i;r++)this.array[r]=0;else return this.processVisibleItem(Nn(e),r,n)}}])}(Yn),Zn=function(e){function t(){var e;an(this,t);var n=[...arguments];return e=fn(this,t,[].concat(n)),A(e,`drawLabel`,void 0),e}return mn(t,e),sn(t,[{key:`kill`,value:function(){zn(t,`kill`,this,3)([])}},{key:`process`,value:function(e,t,n,r,i){var a=t*this.STRIDE;if(i.hidden||n.hidden||r.hidden)for(var o=a+this.STRIDE;a<o;a++)this.array[a]=0;else return this.processVisibleItem(Nn(e),a,n,r,i)}}])}(Yn);function Qn(e,t){return function(){function n(r,i,a){an(this,n),A(this,`drawLabel`,t),this.programs=e.map(function(e){return new e(r,i,a)})}return sn(n,[{key:`reallocate`,value:function(e){this.programs.forEach(function(t){return t.reallocate(e)})}},{key:`process`,value:function(e,t,n,r,i){this.programs.forEach(function(a){return a.process(e,t,n,r,i)})}},{key:`render`,value:function(e){this.programs.forEach(function(t){return t.render(e)})}},{key:`kill`,value:function(){this.programs.forEach(function(e){return e.kill()})}}])}()}function $n(e,t,n,r,i){var a=i.edgeLabelSize,o=i.edgeLabelFont,s=i.edgeLabelWeight,c=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||`#000`:i.edgeLabelColor.color,l=t.label;if(l){e.fillStyle=c,e.font=`${s} ${a}px ${o}`;var u=n.size,d=r.size,f=n.x,p=n.y,m=r.x,h=r.y,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=Math.sqrt(v*v+y*y);if(!(b<u+d)){f+=v*u/b,p+=y*u/b,m-=v*d/b,h-=y*d/b,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=Math.sqrt(v*v+y*y);var x=e.measureText(l).width;if(x>b){var S=`…`;for(l+=S,x=e.measureText(l).width;x>b&&l.length>1;)l=l.slice(0,-2)+S,x=e.measureText(l).width;if(l.length<4)return}var C=v>0?y>0?Math.acos(v/b):Math.asin(y/b):y>0?Math.acos(v/b)+Math.PI:Math.asin(v/b)+Math.PI/2;e.save(),e.translate(g,_),e.rotate(C),e.fillText(l,-x/2,t.size/2+a),e.restore()}}}function er(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,a=n.labelWeight;e.fillStyle=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||`#000`:n.labelColor.color,e.font=`${a} ${r}px ${i}`,e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function tr(e,t,n){var r=n.labelSize,i=n.labelFont;e.font=`${n.labelWeight} ${r}px ${i}`,e.fillStyle=`#FFF`,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor=`#000`;var a=2;if(typeof t.label==`string`){var o=e.measureText(t.label).width,s=Math.round(o+5),c=Math.round(r+2*a),l=Math.max(t.size,r/2)+a,u=Math.asin(c/2/l),d=Math.sqrt(Math.abs(l**2-(c/2)**2));e.beginPath(),e.moveTo(t.x+d,t.y+c/2),e.lineTo(t.x+l+s,t.y+c/2),e.lineTo(t.x+l+s,t.y-c/2),e.lineTo(t.x+d,t.y-c/2),e.arc(t.x,t.y,l,u,-u),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+a,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,er(e,t,n)}var nr=`
|
|
7
|
+
precision highp float;
|
|
8
|
+
|
|
9
|
+
varying vec4 v_color;
|
|
10
|
+
varying vec2 v_diffVector;
|
|
11
|
+
varying float v_radius;
|
|
12
|
+
|
|
13
|
+
uniform float u_correctionRatio;
|
|
14
|
+
|
|
15
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
16
|
+
|
|
17
|
+
void main(void) {
|
|
18
|
+
float border = u_correctionRatio * 2.0;
|
|
19
|
+
float dist = length(v_diffVector) - v_radius + border;
|
|
20
|
+
|
|
21
|
+
// No antialiasing for picking mode:
|
|
22
|
+
#ifdef PICKING_MODE
|
|
23
|
+
if (dist > border)
|
|
24
|
+
gl_FragColor = transparent;
|
|
25
|
+
else
|
|
26
|
+
gl_FragColor = v_color;
|
|
27
|
+
|
|
28
|
+
#else
|
|
29
|
+
float t = 0.0;
|
|
30
|
+
if (dist > border)
|
|
31
|
+
t = 1.0;
|
|
32
|
+
else if (dist > 0.0)
|
|
33
|
+
t = dist / border;
|
|
34
|
+
|
|
35
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
38
|
+
`,rr=`
|
|
39
|
+
attribute vec4 a_id;
|
|
40
|
+
attribute vec4 a_color;
|
|
41
|
+
attribute vec2 a_position;
|
|
42
|
+
attribute float a_size;
|
|
43
|
+
attribute float a_angle;
|
|
44
|
+
|
|
45
|
+
uniform mat3 u_matrix;
|
|
46
|
+
uniform float u_sizeRatio;
|
|
47
|
+
uniform float u_correctionRatio;
|
|
48
|
+
|
|
49
|
+
varying vec4 v_color;
|
|
50
|
+
varying vec2 v_diffVector;
|
|
51
|
+
varying float v_radius;
|
|
52
|
+
varying float v_border;
|
|
53
|
+
|
|
54
|
+
const float bias = 255.0 / 254.0;
|
|
55
|
+
|
|
56
|
+
void main() {
|
|
57
|
+
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
58
|
+
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
59
|
+
vec2 position = a_position + diffVector;
|
|
60
|
+
gl_Position = vec4(
|
|
61
|
+
(u_matrix * vec3(position, 1)).xy,
|
|
62
|
+
0,
|
|
63
|
+
1
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
v_diffVector = diffVector;
|
|
67
|
+
v_radius = size / 2.0;
|
|
68
|
+
|
|
69
|
+
#ifdef PICKING_MODE
|
|
70
|
+
// For picking mode, we use the ID as the color:
|
|
71
|
+
v_color = a_id;
|
|
72
|
+
#else
|
|
73
|
+
// For normal mode, we use the color:
|
|
74
|
+
v_color = a_color;
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
v_color.a *= bias;
|
|
78
|
+
}
|
|
79
|
+
`,ir=WebGLRenderingContext,ar=ir.UNSIGNED_BYTE,or=ir.FLOAT,sr=[`u_sizeRatio`,`u_correctionRatio`,`u_matrix`],cr=function(e){function t(){return an(this,t),fn(this,t,arguments)}return mn(t,e),sn(t,[{key:`getDefinition`,value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:rr,FRAGMENT_SHADER_SOURCE:nr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:sr,ATTRIBUTES:[{name:`a_position`,size:2,type:or},{name:`a_size`,size:1,type:or},{name:`a_color`,size:4,type:ar,normalized:!0},{name:`a_id`,size:4,type:ar,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:`a_angle`,size:1,type:or}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:`processVisibleItem`,value:function(e,t,n){var r=this.array,i=jn(n.color);r[t++]=n.x,r[t++]=n.y,r[t++]=n.size,r[t++]=i,r[t++]=e}},{key:`setUniforms`,value:function(e,t){var n=t.gl,r=t.uniformLocations,i=r.u_sizeRatio,a=r.u_correctionRatio,o=r.u_matrix;n.uniform1f(a,e.correctionRatio),n.uniform1f(i,e.sizeRatio),n.uniformMatrix3fv(o,!1,e.matrix)}}])}(Xn);A(cr,`ANGLE_1`,0),A(cr,`ANGLE_2`,2*Math.PI/3),A(cr,`ANGLE_3`,4*Math.PI/3);var lr=`
|
|
80
|
+
precision mediump float;
|
|
81
|
+
|
|
82
|
+
varying vec4 v_color;
|
|
83
|
+
|
|
84
|
+
void main(void) {
|
|
85
|
+
gl_FragColor = v_color;
|
|
86
|
+
}
|
|
87
|
+
`,ur=`
|
|
88
|
+
attribute vec2 a_position;
|
|
89
|
+
attribute vec2 a_normal;
|
|
90
|
+
attribute float a_radius;
|
|
91
|
+
attribute vec3 a_barycentric;
|
|
92
|
+
|
|
93
|
+
#ifdef PICKING_MODE
|
|
94
|
+
attribute vec4 a_id;
|
|
95
|
+
#else
|
|
96
|
+
attribute vec4 a_color;
|
|
97
|
+
#endif
|
|
98
|
+
|
|
99
|
+
uniform mat3 u_matrix;
|
|
100
|
+
uniform float u_sizeRatio;
|
|
101
|
+
uniform float u_correctionRatio;
|
|
102
|
+
uniform float u_minEdgeThickness;
|
|
103
|
+
uniform float u_lengthToThicknessRatio;
|
|
104
|
+
uniform float u_widenessToThicknessRatio;
|
|
105
|
+
|
|
106
|
+
varying vec4 v_color;
|
|
107
|
+
|
|
108
|
+
const float bias = 255.0 / 254.0;
|
|
109
|
+
|
|
110
|
+
void main() {
|
|
111
|
+
float minThickness = u_minEdgeThickness;
|
|
112
|
+
|
|
113
|
+
float normalLength = length(a_normal);
|
|
114
|
+
vec2 unitNormal = a_normal / normalLength;
|
|
115
|
+
|
|
116
|
+
// These first computations are taken from edge.vert.glsl and
|
|
117
|
+
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
118
|
+
// happening:
|
|
119
|
+
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
120
|
+
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
121
|
+
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
122
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
123
|
+
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
124
|
+
|
|
125
|
+
float da = a_barycentric.x;
|
|
126
|
+
float db = a_barycentric.y;
|
|
127
|
+
float dc = a_barycentric.z;
|
|
128
|
+
|
|
129
|
+
vec2 delta = vec2(
|
|
130
|
+
da * (webGLNodeRadius * unitNormal.y)
|
|
131
|
+
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
132
|
+
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
133
|
+
|
|
134
|
+
da * (-webGLNodeRadius * unitNormal.x)
|
|
135
|
+
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
136
|
+
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
140
|
+
|
|
141
|
+
gl_Position = vec4(position, 0, 1);
|
|
142
|
+
|
|
143
|
+
#ifdef PICKING_MODE
|
|
144
|
+
// For picking mode, we use the ID as the color:
|
|
145
|
+
v_color = a_id;
|
|
146
|
+
#else
|
|
147
|
+
// For normal mode, we use the color:
|
|
148
|
+
v_color = a_color;
|
|
149
|
+
#endif
|
|
150
|
+
|
|
151
|
+
v_color.a *= bias;
|
|
152
|
+
}
|
|
153
|
+
`,dr=WebGLRenderingContext,fr=dr.UNSIGNED_BYTE,pr=dr.FLOAT,mr=[`u_matrix`,`u_sizeRatio`,`u_correctionRatio`,`u_minEdgeThickness`,`u_lengthToThicknessRatio`,`u_widenessToThicknessRatio`],hr={extremity:`target`,lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function gr(e){var t=j(j({},hr),e||{});return function(e){function n(){return an(this,n),fn(this,n,arguments)}return mn(n,e),sn(n,[{key:`getDefinition`,value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:ur,FRAGMENT_SHADER_SOURCE:lr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:mr,ATTRIBUTES:[{name:`a_position`,size:2,type:pr},{name:`a_normal`,size:2,type:pr},{name:`a_radius`,size:1,type:pr},{name:`a_color`,size:4,type:fr,normalized:!0},{name:`a_id`,size:4,type:fr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:`a_barycentric`,size:3,type:pr}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:`processVisibleItem`,value:function(e,n,r,i,a){if(t.extremity===`source`){var o=[i,r];r=o[0],i=o[1]}var s=a.size||1,c=i.size||1,l=r.x,u=r.y,d=i.x,f=i.y,p=jn(a.color),m=d-l,h=f-u,g=m*m+h*h,_=0,v=0;g&&(g=1/Math.sqrt(g),_=-h*g*s,v=m*g*s);var y=this.array;y[n++]=d,y[n++]=f,y[n++]=-_,y[n++]=-v,y[n++]=c,y[n++]=p,y[n++]=e}},{key:`setUniforms`,value:function(e,n){var r=n.gl,i=n.uniformLocations,a=i.u_matrix,o=i.u_sizeRatio,s=i.u_correctionRatio,c=i.u_minEdgeThickness,l=i.u_lengthToThicknessRatio,u=i.u_widenessToThicknessRatio;r.uniformMatrix3fv(a,!1,e.matrix),r.uniform1f(o,e.sizeRatio),r.uniform1f(s,e.correctionRatio),r.uniform1f(c,e.minEdgeThickness),r.uniform1f(l,t.lengthToThicknessRatio),r.uniform1f(u,t.widenessToThicknessRatio)}}])}(Zn)}gr();var _r=`
|
|
154
|
+
precision mediump float;
|
|
155
|
+
|
|
156
|
+
varying vec4 v_color;
|
|
157
|
+
varying vec2 v_normal;
|
|
158
|
+
varying float v_thickness;
|
|
159
|
+
varying float v_feather;
|
|
160
|
+
|
|
161
|
+
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
162
|
+
|
|
163
|
+
void main(void) {
|
|
164
|
+
// We only handle antialiasing for normal mode:
|
|
165
|
+
#ifdef PICKING_MODE
|
|
166
|
+
gl_FragColor = v_color;
|
|
167
|
+
#else
|
|
168
|
+
float dist = length(v_normal) * v_thickness;
|
|
169
|
+
|
|
170
|
+
float t = smoothstep(
|
|
171
|
+
v_thickness - v_feather,
|
|
172
|
+
v_thickness,
|
|
173
|
+
dist
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
gl_FragColor = mix(v_color, transparent, t);
|
|
177
|
+
#endif
|
|
178
|
+
}
|
|
179
|
+
`,vr=`
|
|
180
|
+
attribute vec4 a_id;
|
|
181
|
+
attribute vec4 a_color;
|
|
182
|
+
attribute vec2 a_normal;
|
|
183
|
+
attribute float a_normalCoef;
|
|
184
|
+
attribute vec2 a_positionStart;
|
|
185
|
+
attribute vec2 a_positionEnd;
|
|
186
|
+
attribute float a_positionCoef;
|
|
187
|
+
attribute float a_radius;
|
|
188
|
+
attribute float a_radiusCoef;
|
|
189
|
+
|
|
190
|
+
uniform mat3 u_matrix;
|
|
191
|
+
uniform float u_zoomRatio;
|
|
192
|
+
uniform float u_sizeRatio;
|
|
193
|
+
uniform float u_pixelRatio;
|
|
194
|
+
uniform float u_correctionRatio;
|
|
195
|
+
uniform float u_minEdgeThickness;
|
|
196
|
+
uniform float u_lengthToThicknessRatio;
|
|
197
|
+
uniform float u_feather;
|
|
198
|
+
|
|
199
|
+
varying vec4 v_color;
|
|
200
|
+
varying vec2 v_normal;
|
|
201
|
+
varying float v_thickness;
|
|
202
|
+
varying float v_feather;
|
|
203
|
+
|
|
204
|
+
const float bias = 255.0 / 254.0;
|
|
205
|
+
|
|
206
|
+
void main() {
|
|
207
|
+
float minThickness = u_minEdgeThickness;
|
|
208
|
+
|
|
209
|
+
float radius = a_radius * a_radiusCoef;
|
|
210
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
211
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
212
|
+
|
|
213
|
+
float normalLength = length(normal);
|
|
214
|
+
vec2 unitNormal = normal / normalLength;
|
|
215
|
+
|
|
216
|
+
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
217
|
+
// get better comments on what's happening:
|
|
218
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
219
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
220
|
+
|
|
221
|
+
// Here, we move the point to leave space for the arrow head:
|
|
222
|
+
float direction = sign(radius);
|
|
223
|
+
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
224
|
+
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
225
|
+
|
|
226
|
+
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
227
|
+
|
|
228
|
+
// Here is the proper position of the vertex
|
|
229
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
230
|
+
|
|
231
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
232
|
+
|
|
233
|
+
v_normal = unitNormal;
|
|
234
|
+
|
|
235
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
236
|
+
|
|
237
|
+
#ifdef PICKING_MODE
|
|
238
|
+
// For picking mode, we use the ID as the color:
|
|
239
|
+
v_color = a_id;
|
|
240
|
+
#else
|
|
241
|
+
// For normal mode, we use the color:
|
|
242
|
+
v_color = a_color;
|
|
243
|
+
#endif
|
|
244
|
+
|
|
245
|
+
v_color.a *= bias;
|
|
246
|
+
}
|
|
247
|
+
`,yr=WebGLRenderingContext,br=yr.UNSIGNED_BYTE,xr=yr.FLOAT,Sr=[`u_matrix`,`u_zoomRatio`,`u_sizeRatio`,`u_correctionRatio`,`u_pixelRatio`,`u_feather`,`u_minEdgeThickness`,`u_lengthToThicknessRatio`],Cr={lengthToThicknessRatio:hr.lengthToThicknessRatio};function wr(e){var t=j(j({},Cr),e||{});return function(e){function n(){return an(this,n),fn(this,n,arguments)}return mn(n,e),sn(n,[{key:`getDefinition`,value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:vr,FRAGMENT_SHADER_SOURCE:_r,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Sr,ATTRIBUTES:[{name:`a_positionStart`,size:2,type:xr},{name:`a_positionEnd`,size:2,type:xr},{name:`a_normal`,size:2,type:xr},{name:`a_color`,size:4,type:br,normalized:!0},{name:`a_id`,size:4,type:br,normalized:!0},{name:`a_radius`,size:1,type:xr}],CONSTANT_ATTRIBUTES:[{name:`a_positionCoef`,size:1,type:xr},{name:`a_normalCoef`,size:1,type:xr},{name:`a_radiusCoef`,size:1,type:xr}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:`processVisibleItem`,value:function(e,t,n,r,i){var a=i.size||1,o=n.x,s=n.y,c=r.x,l=r.y,u=jn(i.color),d=c-o,f=l-s,p=r.size||1,m=d*d+f*f,h=0,g=0;m&&(m=1/Math.sqrt(m),h=-f*m*a,g=d*m*a);var _=this.array;_[t++]=o,_[t++]=s,_[t++]=c,_[t++]=l,_[t++]=h,_[t++]=g,_[t++]=u,_[t++]=e,_[t++]=p}},{key:`setUniforms`,value:function(e,n){var r=n.gl,i=n.uniformLocations,a=i.u_matrix,o=i.u_zoomRatio,s=i.u_feather,c=i.u_pixelRatio,l=i.u_correctionRatio,u=i.u_sizeRatio,d=i.u_minEdgeThickness,f=i.u_lengthToThicknessRatio;r.uniformMatrix3fv(a,!1,e.matrix),r.uniform1f(o,e.zoomRatio),r.uniform1f(u,e.sizeRatio),r.uniform1f(l,e.correctionRatio),r.uniform1f(c,e.pixelRatio),r.uniform1f(s,e.antiAliasingFeather),r.uniform1f(d,e.minEdgeThickness),r.uniform1f(f,t.lengthToThicknessRatio)}}])}(Zn)}wr();function Tr(e){return Qn([wr(e),gr(e)])}var Er=Tr(),Dr=`
|
|
248
|
+
attribute vec4 a_id;
|
|
249
|
+
attribute vec4 a_color;
|
|
250
|
+
attribute vec2 a_normal;
|
|
251
|
+
attribute float a_normalCoef;
|
|
252
|
+
attribute vec2 a_positionStart;
|
|
253
|
+
attribute vec2 a_positionEnd;
|
|
254
|
+
attribute float a_positionCoef;
|
|
255
|
+
|
|
256
|
+
uniform mat3 u_matrix;
|
|
257
|
+
uniform float u_sizeRatio;
|
|
258
|
+
uniform float u_zoomRatio;
|
|
259
|
+
uniform float u_pixelRatio;
|
|
260
|
+
uniform float u_correctionRatio;
|
|
261
|
+
uniform float u_minEdgeThickness;
|
|
262
|
+
uniform float u_feather;
|
|
263
|
+
|
|
264
|
+
varying vec4 v_color;
|
|
265
|
+
varying vec2 v_normal;
|
|
266
|
+
varying float v_thickness;
|
|
267
|
+
varying float v_feather;
|
|
268
|
+
|
|
269
|
+
const float bias = 255.0 / 254.0;
|
|
270
|
+
|
|
271
|
+
void main() {
|
|
272
|
+
float minThickness = u_minEdgeThickness;
|
|
273
|
+
|
|
274
|
+
vec2 normal = a_normal * a_normalCoef;
|
|
275
|
+
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
276
|
+
|
|
277
|
+
float normalLength = length(normal);
|
|
278
|
+
vec2 unitNormal = normal / normalLength;
|
|
279
|
+
|
|
280
|
+
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
281
|
+
// (so we need to compensate the size ratio):
|
|
282
|
+
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
283
|
+
|
|
284
|
+
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
285
|
+
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
286
|
+
// ratio:
|
|
287
|
+
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
288
|
+
|
|
289
|
+
// Here is the proper position of the vertex
|
|
290
|
+
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
291
|
+
|
|
292
|
+
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
293
|
+
// correction ratio into account (as in webGLThickness), but so that the
|
|
294
|
+
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
295
|
+
// another thickness version:
|
|
296
|
+
v_thickness = webGLThickness / u_zoomRatio;
|
|
297
|
+
|
|
298
|
+
v_normal = unitNormal;
|
|
299
|
+
|
|
300
|
+
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
301
|
+
|
|
302
|
+
#ifdef PICKING_MODE
|
|
303
|
+
// For picking mode, we use the ID as the color:
|
|
304
|
+
v_color = a_id;
|
|
305
|
+
#else
|
|
306
|
+
// For normal mode, we use the color:
|
|
307
|
+
v_color = a_color;
|
|
308
|
+
#endif
|
|
309
|
+
|
|
310
|
+
v_color.a *= bias;
|
|
311
|
+
}
|
|
312
|
+
`,Or=WebGLRenderingContext,kr=Or.UNSIGNED_BYTE,Ar=Or.FLOAT,jr=[`u_matrix`,`u_zoomRatio`,`u_sizeRatio`,`u_correctionRatio`,`u_pixelRatio`,`u_feather`,`u_minEdgeThickness`],Mr=function(e){function t(){return an(this,t),fn(this,t,arguments)}return mn(t,e),sn(t,[{key:`getDefinition`,value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Dr,FRAGMENT_SHADER_SOURCE:_r,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:jr,ATTRIBUTES:[{name:`a_positionStart`,size:2,type:Ar},{name:`a_positionEnd`,size:2,type:Ar},{name:`a_normal`,size:2,type:Ar},{name:`a_color`,size:4,type:kr,normalized:!0},{name:`a_id`,size:4,type:kr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:`a_positionCoef`,size:1,type:Ar},{name:`a_normalCoef`,size:1,type:Ar}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:`processVisibleItem`,value:function(e,t,n,r,i){var a=i.size||1,o=n.x,s=n.y,c=r.x,l=r.y,u=jn(i.color),d=c-o,f=l-s,p=d*d+f*f,m=0,h=0;p&&(p=1/Math.sqrt(p),m=-f*p*a,h=d*p*a);var g=this.array;g[t++]=o,g[t++]=s,g[t++]=c,g[t++]=l,g[t++]=m,g[t++]=h,g[t++]=u,g[t++]=e}},{key:`setUniforms`,value:function(e,t){var n=t.gl,r=t.uniformLocations,i=r.u_matrix,a=r.u_zoomRatio,o=r.u_feather,s=r.u_pixelRatio,c=r.u_correctionRatio,l=r.u_sizeRatio,u=r.u_minEdgeThickness;n.uniformMatrix3fv(i,!1,e.matrix),n.uniform1f(a,e.zoomRatio),n.uniform1f(l,e.sizeRatio),n.uniform1f(c,e.correctionRatio),n.uniform1f(s,e.pixelRatio),n.uniform1f(o,e.antiAliasingFeather),n.uniform1f(u,e.minEdgeThickness)}}])}(Zn),Nr=function(e){function t(){var e;return an(this,t),e=fn(this,t),e.rawEmitter=e,e}return mn(t,e),sn(t)}(fe.EventEmitter),Pr=n(((e,t)=>{t.exports=function(e){return typeof e==`object`&&!!e&&typeof e.addUndirectedEdgeWithKey==`function`&&typeof e.dropNode==`function`&&typeof e.multi==`boolean`}})),Fr=e(Pr()),Ir={linear:function(e){return e},quadraticIn:function(e){return e*e},quadraticOut:function(e){return e*(2-e)},quadraticInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:function(e){return e*e*e},cubicOut:function(e){return--e*e*e+1},cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Lr={easing:`quadraticInOut`,duration:150};function Rr(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function zr(e,t,n){return e[0]=t,e[4]=typeof n==`number`?n:t,e}function Br(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function Vr(e,t,n){return e[6]=t,e[7]=n,e}function Hr(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],d=t[0],f=t[1],p=t[2],m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8];return e[0]=d*n+f*a+p*c,e[1]=d*r+f*o+p*l,e[2]=d*i+f*s+p*u,e[3]=m*n+h*a+g*c,e[4]=m*r+h*o+g*l,e[5]=m*i+h*s+g*u,e[6]=_*n+v*a+y*c,e[7]=_*r+v*o+y*l,e[8]=_*i+v*s+y*u,e}function Ur(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],a=e[3],o=e[4],s=e[6],c=e[7],l=t.x,u=t.y;return{x:l*r+u*a+s*n,y:l*i+u*o+c*n}}function Wr(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Gr(e,t,n,r,i){var a=e.angle,o=e.ratio,s=e.x,c=e.y,l=t.width,u=t.height,d=Rr(),f=Math.min(l,u)-2*r,p=Wr(t,n);return i?(Hr(d,Vr(Rr(),s,c)),Hr(d,zr(Rr(),o)),Hr(d,Br(Rr(),a)),Hr(d,zr(Rr(),l/f/2/p,u/f/2/p))):(Hr(d,zr(Rr(),f/l*2*p,f/u*2*p)),Hr(d,Br(Rr(),-a)),Hr(d,zr(Rr(),1/o)),Hr(d,Vr(Rr(),-s,-c))),d}function Kr(e,t,n){var r=Ur(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,a=r.y;return 1/Math.sqrt(i**2+a**2)/n.width}function qr(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(e,a){var o=a.x,s=a.y;o<t&&(t=o),o>n&&(n=o),s<r&&(r=s),s>i&&(i=s)}),{x:[t,n],y:[r,i]}}function Jr(e){if(!(0,Fr.default)(e))throw Error(`Sigma: invalid graph instance.`);e.forEachNode(function(e,t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw Error(`Sigma: Coordinates of node ${e} are invalid. A node must have a numeric 'x' and 'y' attribute.`)})}function Yr(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var a in n)r.setAttribute(a,n[a]);return r}function Xr(){return window.devicePixelRatio===void 0?1:window.devicePixelRatio}function Zr(e,t,n){return n.sort(function(e,n){var r=t(e)||0,i=t(n)||0;return r<i?-1:+(r>i)})}function Qr(e){var t=bn(e.x,2),n=t[0],r=t[1],i=bn(e.y,2),a=i[0],o=i[1],s=Math.max(r-n,o-a),c=(r+n)/2,l=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(c)&&(c=0),isNaN(l)&&(l=0);var u=function(e){return{x:.5+(e.x-c)/s,y:.5+(e.y-l)/s}};return u.applyTo=function(e){e.x=.5+(e.x-c)/s,e.y=.5+(e.y-l)/s},u.inverse=function(e){return{x:c+s*(e.x-.5),y:l+s*(e.y-.5)}},u.ratio=s,u}function $r(e){"@babel/helpers - typeof";return $r=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},$r(e)}function ei(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(t){e[r+i]=t,i++})}}function ti(e){e||={};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var ni={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:`#999`,defaultNodeType:`circle`,defaultEdgeColor:`#ccc`,defaultEdgeType:`line`,labelFont:`Arial`,labelSize:14,labelWeight:`normal`,labelColor:{color:`#000`},edgeLabelFont:`Arial`,edgeLabelSize:14,edgeLabelWeight:`normal`,edgeLabelColor:{attribute:`color`},stagePadding:30,defaultDrawEdgeLabel:$n,defaultDrawNodeLabel:er,defaultDrawNodeHover:tr,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:`screen`,autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},ri={circle:cr},ii={arrow:Er,line:Mr};function ai(e){if(typeof e.labelDensity!=`number`||e.labelDensity<0)throw Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t==`number`&&typeof n==`number`&&n<t)throw Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function oi(e){var t=ti({},ni,e);return t.nodeProgramClasses=ti({},ri,t.nodeProgramClasses),t.edgeProgramClasses=ti({},ii,t.edgeProgramClasses),t}var si=1.5,ci=function(e){function t(){var e;return an(this,t),e=fn(this,t),A(e,`x`,.5),A(e,`y`,.5),A(e,`angle`,0),A(e,`ratio`,1),A(e,`minRatio`,null),A(e,`maxRatio`,null),A(e,`enabledZooming`,!0),A(e,`enabledPanning`,!0),A(e,`enabledRotation`,!0),A(e,`clean`,null),A(e,`nextFrame`,null),A(e,`previousState`,null),A(e,`enabled`,!0),e.previousState=e.getState(),e}return mn(t,e),sn(t,[{key:`enable`,value:function(){return this.enabled=!0,this}},{key:`disable`,value:function(){return this.enabled=!1,this}},{key:`getState`,value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:`hasState`,value:function(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}},{key:`getPreviousState`,value:function(){var e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}},{key:`getBoundedRatio`,value:function(e){var t=e;return typeof this.minRatio==`number`&&(t=Math.max(t,this.minRatio)),typeof this.maxRatio==`number`&&(t=Math.min(t,this.maxRatio)),t}},{key:`validateState`,value:function(e){var t={};return this.enabledPanning&&typeof e.x==`number`&&(t.x=e.x),this.enabledPanning&&typeof e.y==`number`&&(t.y=e.y),this.enabledZooming&&typeof e.ratio==`number`&&(t.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle==`number`&&(t.angle=e.angle),this.clean?this.clean(j(j({},this.getState()),t)):t}},{key:`isAnimated`,value:function(){return!!this.nextFrame}},{key:`setState`,value:function(e){if(!this.enabled)return this;this.previousState=this.getState();var t=this.validateState(e);return typeof t.x==`number`&&(this.x=t.x),typeof t.y==`number`&&(this.y=t.y),typeof t.ratio==`number`&&(this.ratio=t.ratio),typeof t.angle==`number`&&(this.angle=t.angle),this.hasState(this.previousState)||this.emit(`updated`,this.getState()),this}},{key:`updateState`,value:function(e){return this.setState(e(this.getState())),this}},{key:`animate`,value:function(e){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if(!r)return new Promise(function(r){return t.animate(e,n,r)});if(this.enabled){var i=j(j({},Lr),n),a=this.validateState(e),o=typeof i.easing==`function`?i.easing:Ir[i.easing],s=Date.now(),c=this.getState(),l=function(){var e=(Date.now()-s)/i.duration;if(e>=1)t.nextFrame=null,t.setState(a),t.animationCallback&&=(t.animationCallback.call(null),void 0);else{var n=o(e),r={};typeof a.x==`number`&&(r.x=c.x+(a.x-c.x)*n),typeof a.y==`number`&&(r.y=c.y+(a.y-c.y)*n),t.enabledRotation&&typeof a.angle==`number`&&(r.angle=c.angle+(a.angle-c.angle)*n),typeof a.ratio==`number`&&(r.ratio=c.ratio+(a.ratio-c.ratio)*n),t.setState(r),t.nextFrame=requestAnimationFrame(l)}};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(l)):l(),this.animationCallback=r}}},{key:`animatedZoom`,value:function(e){return e?typeof e==`number`?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||si)},e):this.animate({ratio:this.ratio/si})}},{key:`animatedUnzoom`,value:function(e){return e?typeof e==`number`?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||si)},e):this.animate({ratio:this.ratio*si})}},{key:`animatedReset`,value:function(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}},{key:`copy`,value:function(){return t.from(this.getState())}}],[{key:`from`,value:function(e){return new t().setState(e)}}])}(Nr);function li(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function ui(e,t){var n=j(j({},li(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function di(e){var t=`x`in e?e:j(j({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function fi(e,t){return j(j({},ui(e,t)),{},{delta:gi(e)})}var pi=2;function mi(e){for(var t=[],n=0,r=Math.min(e.length,pi);n<r;n++)t.push(e[n]);return t}function hi(e,t,n){var r={touches:mi(e.touches).map(function(e){return li(e,n)}),previousTouches:t.map(function(e){return li(e,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function gi(e){if(e.deltaY!==void 0)return e.deltaY*-3/360;if(e.detail!==void 0)return e.detail/-9;throw Error(`Captor: could not extract delta from event.`)}var _i=function(e){function t(e,n){var r;return an(this,t),r=fn(this,t),r.container=e,r.renderer=n,r}return mn(t,e),sn(t)}(Nr),vi=[`doubleClickTimeout`,`doubleClickZoomingDuration`,`doubleClickZoomingRatio`,`dragTimeout`,`draggedEventsTolerance`,`inertiaDuration`,`inertiaRatio`,`zoomDuration`,`zoomingRatio`].reduce(function(e,t){return j(j({},e),{},A({},t,ni[t]))},{}),yi=function(e){function t(e,n){var r;return an(this,t),r=fn(this,t,[e,n]),A(r,`enabled`,!0),A(r,`draggedEvents`,0),A(r,`downStartTime`,null),A(r,`lastMouseX`,null),A(r,`lastMouseY`,null),A(r,`isMouseDown`,!1),A(r,`isMoving`,!1),A(r,`movingTimeout`,null),A(r,`startCameraState`,null),A(r,`clicks`,0),A(r,`doubleClickTimeout`,null),A(r,`currentWheelDirection`,0),A(r,`settings`,vi),r.handleClick=r.handleClick.bind(r),r.handleRightClick=r.handleRightClick.bind(r),r.handleDown=r.handleDown.bind(r),r.handleUp=r.handleUp.bind(r),r.handleMove=r.handleMove.bind(r),r.handleWheel=r.handleWheel.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleEnter=r.handleEnter.bind(r),e.addEventListener(`click`,r.handleClick,{capture:!1}),e.addEventListener(`contextmenu`,r.handleRightClick,{capture:!1}),e.addEventListener(`mousedown`,r.handleDown,{capture:!1}),e.addEventListener(`wheel`,r.handleWheel,{capture:!1}),e.addEventListener(`mouseleave`,r.handleLeave,{capture:!1}),e.addEventListener(`mouseenter`,r.handleEnter,{capture:!1}),document.addEventListener(`mousemove`,r.handleMove,{capture:!1}),document.addEventListener(`mouseup`,r.handleUp,{capture:!1}),r}return mn(t,e),sn(t,[{key:`kill`,value:function(){var e=this.container;e.removeEventListener(`click`,this.handleClick),e.removeEventListener(`contextmenu`,this.handleRightClick),e.removeEventListener(`mousedown`,this.handleDown),e.removeEventListener(`wheel`,this.handleWheel),e.removeEventListener(`mouseleave`,this.handleLeave),e.removeEventListener(`mouseenter`,this.handleEnter),document.removeEventListener(`mousemove`,this.handleMove),document.removeEventListener(`mouseup`,this.handleUp)}},{key:`handleClick`,value:function(e){var t=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout==`number`&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(e);setTimeout(function(){t.clicks=0,t.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit(`click`,ui(e,this.container))}}},{key:`handleRightClick`,value:function(e){this.enabled&&this.emit(`rightClick`,ui(e,this.container))}},{key:`handleDoubleClick`,value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var t=ui(e,this.container);if(this.emit(`doubleClick`,t),!t.sigmaDefaultPrevented){var n=this.renderer.getCamera(),r=n.getBoundedRatio(n.getState().ratio/this.settings.doubleClickZoomingRatio);n.animate(this.renderer.getViewportZoomedState(li(e,this.container),r),{easing:`quadraticInOut`,duration:this.settings.doubleClickZoomingDuration})}}}},{key:`handleDown`,value:function(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();var t=li(e,this.container),n=t.x,r=t.y;this.lastMouseX=n,this.lastMouseY=r,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit(`mousedown`,ui(e,this.container))}}},{key:`handleUp`,value:function(e){var t=this;if(this.enabled&&this.isMouseDown){var n=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout==`number`&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var r=li(e,this.container),i=r.x,a=r.y,o=n.getState(),s=n.getPreviousState()||{x:0,y:0};this.isMoving?n.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:`quadraticOut`}):(this.lastMouseX!==i||this.lastMouseY!==a)&&n.setState({x:o.x,y:o.y}),this.isMoving=!1,setTimeout(function(){var e=t.draggedEvents>0;t.draggedEvents=0,e&&t.renderer.getSetting(`hideEdgesOnMove`)&&t.renderer.refresh()},0),this.emit(`mouseup`,ui(e,this.container))}}},{key:`handleMove`,value:function(e){var t=this;if(this.enabled){var n=ui(e,this.container);if(this.emit(`mousemovebody`,n),(e.target===this.container||e.composedPath()[0]===this.container)&&this.emit(`mousemove`,n),!n.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout==`number`&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){t.movingTimeout=null,t.isMoving=!1},this.settings.dragTimeout);var r=this.renderer.getCamera(),i=li(e,this.container),a=i.x,o=i.y,s=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),c=this.renderer.viewportToFramedGraph({x:a,y:o}),l=s.x-c.x,u=s.y-c.y,d=r.getState(),f=d.x+l,p=d.y+u;r.setState({x:f,y:p}),this.lastMouseX=a,this.lastMouseY=o,e.preventDefault(),e.stopPropagation()}}}},{key:`handleLeave`,value:function(e){this.emit(`mouseleave`,ui(e,this.container))}},{key:`handleEnter`,value:function(e){this.emit(`mouseenter`,ui(e,this.container))}},{key:`handleWheel`,value:function(e){var t=this,n=this.renderer.getCamera();if(this.enabled&&n.enabledZooming){var r=gi(e);if(r){var i=fi(e,this.container);if(this.emit(`wheel`,i),i.sigmaDefaultPrevented)e.preventDefault(),e.stopPropagation();else{var a=n.getState().ratio,o=r>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,s=n.getBoundedRatio(a*o),c=r>0?1:-1,l=Date.now();a!==s&&(e.preventDefault(),e.stopPropagation(),this.currentWheelDirection===c&&this.lastWheelTriggerTime&&l-this.lastWheelTriggerTime<this.settings.zoomDuration/5||(n.animate(this.renderer.getViewportZoomedState(li(e,this.container),s),{easing:`quadraticOut`,duration:this.settings.zoomDuration},function(){t.currentWheelDirection=0}),this.currentWheelDirection=c,this.lastWheelTriggerTime=l))}}}}},{key:`setSettings`,value:function(e){this.settings=e}}])}(_i),bi=[`dragTimeout`,`inertiaDuration`,`inertiaRatio`,`doubleClickTimeout`,`doubleClickZoomingRatio`,`doubleClickZoomingDuration`,`tapMoveTolerance`].reduce(function(e,t){return j(j({},e),{},A({},t,ni[t]))},{}),xi=function(e){function t(e,n){var r;return an(this,t),r=fn(this,t,[e,n]),A(r,`enabled`,!0),A(r,`isMoving`,!1),A(r,`hasMoved`,!1),A(r,`touchMode`,0),A(r,`startTouchesPositions`,[]),A(r,`lastTouches`,[]),A(r,`lastTap`,null),A(r,`settings`,bi),r.handleStart=r.handleStart.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleMove=r.handleMove.bind(r),e.addEventListener(`touchstart`,r.handleStart,{capture:!1}),e.addEventListener(`touchcancel`,r.handleLeave,{capture:!1}),document.addEventListener(`touchend`,r.handleLeave,{capture:!1,passive:!1}),document.addEventListener(`touchmove`,r.handleMove,{capture:!1,passive:!1}),r}return mn(t,e),sn(t,[{key:`kill`,value:function(){var e=this.container;e.removeEventListener(`touchstart`,this.handleStart),e.removeEventListener(`touchcancel`,this.handleLeave),document.removeEventListener(`touchend`,this.handleLeave),document.removeEventListener(`touchmove`,this.handleMove)}},{key:`getDimensions`,value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:`handleStart`,value:function(e){var t=this;if(this.enabled){e.preventDefault();var n=mi(e.touches);if(this.touchMode=n.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=n.map(function(e){return li(e,t.container)}),this.touchMode===2){var r=bn(this.startTouchesPositions,2),i=r[0],a=i.x,o=i.y,s=r[1],c=s.x,l=s.y;this.startTouchesAngle=Math.atan2(l-o,c-a),this.startTouchesDistance=Math.sqrt((c-a)**2+(l-o)**2)}this.emit(`touchdown`,hi(e,this.lastTouches,this.container)),this.lastTouches=n,this.lastTouchesPositions=this.startTouchesPositions}}},{key:`handleLeave`,value:function(e){if(this.enabled&&this.startTouchesPositions.length){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){var t=this.renderer.getCamera(),n=t.getState(),r=t.getPreviousState()||{x:0,y:0};t.animate({x:n.x+this.settings.inertiaRatio*(n.x-r.x),y:n.y+this.settings.inertiaRatio*(n.y-r.y)},{duration:this.settings.inertiaDuration,easing:`quadraticOut`})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0}if(this.emit(`touchup`,hi(e,this.lastTouches,this.container)),!e.touches.length){var i=li(this.lastTouches[0],this.container),a=this.startTouchesPositions[0],o=(i.x-a.x)**2+(i.y-a.y)**2;if(!e.touches.length&&o<this.settings.tapMoveTolerance**2){if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var s=hi(e,this.lastTouches,this.container);if(this.emit(`doubletap`,s),this.lastTap=null,!s.sigmaDefaultPrevented){var c=this.renderer.getCamera(),l=c.getBoundedRatio(c.getState().ratio/this.settings.doubleClickZoomingRatio);c.animate(this.renderer.getViewportZoomedState(i,l),{easing:`quadraticInOut`,duration:this.settings.doubleClickZoomingDuration})}}else{var u=hi(e,this.lastTouches,this.container);this.emit(`tap`,u),this.lastTap={time:Date.now(),position:u.touches[0]||u.previousTouches[0]}}}}this.lastTouches=mi(e.touches),this.startTouchesPositions=[]}}},{key:`handleMove`,value:function(e){var t=this;if(this.enabled&&this.startTouchesPositions.length){e.preventDefault();var n=mi(e.touches),r=n.map(function(e){return li(e,t.container)}),i=this.lastTouches;this.lastTouches=n,this.lastTouchesPositions=r;var a=hi(e,i,this.container);if(this.emit(`touchmove`,a),!a.sigmaDefaultPrevented&&(this.hasMoved||=r.some(function(e,n){var r=t.startTouchesPositions[n];return r&&(e.x!==r.x||e.y!==r.y)}),this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){t.isMoving=!1},this.settings.dragTimeout);var o=this.renderer.getCamera(),s=this.startCameraState,c=this.renderer.getSetting(`stagePadding`);switch(this.touchMode){case 1:var l=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),u=l.x,d=l.y,f=this.renderer.viewportToFramedGraph(r[0]),p=f.x,m=f.y;o.setState({x:s.x+u-p,y:s.y+d-m});break;case 2:var h={x:.5,y:.5,angle:0,ratio:1},g=r[0],_=g.x,v=g.y,y=r[1],b=y.x,x=y.y,S=Math.atan2(x-v,b-_)-this.startTouchesAngle,C=Math.hypot(x-v,b-_)/this.startTouchesDistance,w=o.getBoundedRatio(s.ratio/C);h.ratio=w,h.angle=s.angle+S;var ee=this.getDimensions(),te=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:s}),ne=Math.min(ee.width,ee.height)-2*c,re=ne/ee.width,ie=ne/ee.height,ae=w/ne,oe=_-ne/2/re,se=v-ne/2/ie,ce=[oe*Math.cos(-h.angle)-se*Math.sin(-h.angle),se*Math.cos(-h.angle)+oe*Math.sin(-h.angle)];oe=ce[0],se=ce[1],h.x=te.x-oe*ae,h.y=te.y+se*ae,o.setState(h)}}}}},{key:`setSettings`,value:function(e){this.settings=e}}])}(_i);function Si(e){if(Array.isArray(e))return _n(e)}function Ci(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function M(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
313
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function N(e){return Si(e)||Ci(e)||vn(e)||M()}function wi(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Ti(e,t){if(e==null)return{};var n,r,i=wi(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Ei=function(){function e(t,n){an(this,e),this.key=t,this.size=n}return sn(e,null,[{key:`compare`,value:function(e,t){return e.size>t.size?-1:e.size<t.size||e.key>t.key?1:-1}}])}(),P=function(){function e(){an(this,e),A(this,`width`,0),A(this,`height`,0),A(this,`cellSize`,0),A(this,`columns`,0),A(this,`rows`,0),A(this,`cells`,{})}return sn(e,[{key:`resizeAndClear`,value:function(e,t){this.width=e.width,this.height=e.height,this.cellSize=t,this.columns=Math.ceil(e.width/t),this.rows=Math.ceil(e.height/t),this.cells={}}},{key:`getIndex`,value:function(e){var t=Math.floor(e.x/this.cellSize);return Math.floor(e.y/this.cellSize)*this.columns+t}},{key:`add`,value:function(e,t,n){var r=new Ei(e,t),i=this.getIndex(n),a=this.cells[i];a||(a=[],this.cells[i]=a),a.push(r)}},{key:`organize`,value:function(){for(var e in this.cells)this.cells[e].sort(Ei.compare)}},{key:`getLabelsToDisplay`,value:function(e,t){var n=this.cellSize*this.cellSize,r=n/e/e*t/n,i=Math.ceil(r),a=[];for(var o in this.cells)for(var s=this.cells[o],c=0;c<Math.min(i,s.length);c++)a.push(s[c].key);return a}}])}();function F(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,a=[];return t.forEachEdge(function(e,t,o,s){(o===n||s===n||r.has(o)||r.has(s)||i.has(o)&&i.has(s))&&a.push(e)}),a}var Di=150,Oi=50,ki=Object.prototype.hasOwnProperty;function Ai(e,t,n){if(!ki.call(n,`x`)||!ki.call(n,`y`))throw Error(`Sigma: could not find a valid position (x, y) for node "${t}". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?`);return n.color||=e.defaultNodeColor,!n.label&&n.label!==``&&(n.label=null),n.label=n.label!==void 0&&n.label!==null?``+n.label:null,n.size||=2,ki.call(n,`hidden`)||(n.hidden=!1),ki.call(n,`highlighted`)||(n.highlighted=!1),ki.call(n,`forceLabel`)||(n.forceLabel=!1),n.type&&n.type!==``||(n.type=e.defaultNodeType),n.zIndex||=0,n}function I(e,t,n){return n.color||=e.defaultEdgeColor,n.label||=``,n.size||=.5,ki.call(n,`hidden`)||(n.hidden=!1),ki.call(n,`forceLabel`)||(n.forceLabel=!1),n.type&&n.type!==``||(n.type=e.defaultEdgeType),n.zIndex||=0,n}var ji=function(e){function t(e,n){var r,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(an(this,t),r=fn(this,t),A(r,`elements`,{}),A(r,`canvasContexts`,{}),A(r,`webGLContexts`,{}),A(r,`pickingLayers`,new Set),A(r,`textures`,{}),A(r,`frameBuffers`,{}),A(r,`activeListeners`,{}),A(r,`labelGrid`,new P),A(r,`nodeDataCache`,{}),A(r,`edgeDataCache`,{}),A(r,`nodeProgramIndex`,{}),A(r,`edgeProgramIndex`,{}),A(r,`nodesWithForcedLabels`,new Set),A(r,`edgesWithForcedLabels`,new Set),A(r,`nodeExtent`,{x:[0,1],y:[0,1]}),A(r,`nodeZExtent`,[1/0,-1/0]),A(r,`edgeZExtent`,[1/0,-1/0]),A(r,`matrix`,Rr()),A(r,`invMatrix`,Rr()),A(r,`correctionRatio`,1),A(r,`customBBox`,null),A(r,`normalizationFunction`,Qr({x:[0,1],y:[0,1]})),A(r,`graphToViewportRatio`,1),A(r,`itemIDsIndex`,{}),A(r,`nodeIndices`,{}),A(r,`edgeIndices`,{}),A(r,`width`,0),A(r,`height`,0),A(r,`pixelRatio`,Xr()),A(r,`pickingDownSizingRatio`,2*r.pixelRatio),A(r,`displayedNodeLabels`,new Set),A(r,`displayedEdgeLabels`,new Set),A(r,`highlightedNodes`,new Set),A(r,`hoveredNode`,null),A(r,`hoveredEdge`,null),A(r,`renderFrame`,null),A(r,`renderHighlightedNodesFrame`,null),A(r,`needToProcess`,!1),A(r,`checkEdgesEventsFrame`,null),A(r,`nodePrograms`,{}),A(r,`nodeHoverPrograms`,{}),A(r,`edgePrograms`,{}),r.settings=oi(i),ai(r.settings),Jr(e),!(n instanceof HTMLElement))throw Error(`Sigma: container should be an html element.`);for(var a in r.graph=e,r.container=n,r.createWebGLContext(`edges`,{picking:i.enableEdgeEvents}),r.createCanvasContext(`edgeLabels`),r.createWebGLContext(`nodes`,{picking:!0}),r.createCanvasContext(`labels`),r.createCanvasContext(`hovers`),r.createWebGLContext(`hoverNodes`),r.createCanvasContext(`mouse`,{style:{touchAction:`none`,userSelect:`none`}}),r.resize(),r.settings.nodeProgramClasses)r.registerNodeProgram(a,r.settings.nodeProgramClasses[a],r.settings.nodeHoverProgramClasses[a]);for(var o in r.settings.edgeProgramClasses)r.registerEdgeProgram(o,r.settings.edgeProgramClasses[o]);return r.camera=new ci,r.bindCameraHandlers(),r.mouseCaptor=new yi(r.elements.mouse,r),r.mouseCaptor.setSettings(r.settings),r.touchCaptor=new xi(r.elements.mouse,r),r.touchCaptor.setSettings(r.settings),r.bindEventHandlers(),r.bindGraphHandlers(),r.handleSettingsUpdate(),r.refresh(),r}return mn(t,e),sn(t,[{key:`registerNodeProgram`,value:function(e,t,n){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new t(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(n||t)(this.webGLContexts.hoverNodes,null,this),this}},{key:`registerEdgeProgram`,value:function(e,t){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new t(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:`unregisterNodeProgram`,value:function(e){if(this.nodePrograms[e]){var t=this.nodePrograms,n=t[e],r=Ti(t,[e].map(rn));n.kill(),this.nodePrograms=r}if(this.nodeHoverPrograms[e]){var i=this.nodeHoverPrograms,a=i[e],o=Ti(i,[e].map(rn));a.kill(),this.nodePrograms=o}return this}},{key:`unregisterEdgeProgram`,value:function(e){if(this.edgePrograms[e]){var t=this.edgePrograms,n=t[e],r=Ti(t,[e].map(rn));n.kill(),this.edgePrograms=r}return this}},{key:`resetWebGLTexture`,value:function(e){var t=this.webGLContexts[e],n=this.frameBuffers[e],r=this.textures[e];r&&t.deleteTexture(r);var i=t.createTexture();return t.bindFramebuffer(t.FRAMEBUFFER,n),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.width,this.height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),this.textures[e]=i,this}},{key:`bindCameraHandlers`,value:function(){var e=this;return this.activeListeners.camera=function(){e.scheduleRender()},this.camera.on(`updated`,this.activeListeners.camera),this}},{key:`unbindCameraHandlers`,value:function(){return this.camera.removeListener(`updated`,this.activeListeners.camera),this}},{key:`getNodeAtPosition`,value:function(e){var t=e.x,n=e.y,r=Fn(this.webGLContexts.nodes,this.frameBuffers.nodes,t,n,this.pixelRatio,this.pickingDownSizingRatio),i=Pn.apply(void 0,N(r)),a=this.itemIDsIndex[i];return a&&a.type===`node`?a.id:null}},{key:`bindEventHandlers`,value:function(){var e=this;this.activeListeners.handleResize=function(){e.scheduleRefresh()},window.addEventListener(`resize`,this.activeListeners.handleResize),this.activeListeners.handleMove=function(t){var n=di(t),r={event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}},i=e.getNodeAtPosition(n);if(i&&e.hoveredNode!==i&&!e.nodeDataCache[i].hidden)e.hoveredNode&&e.emit(`leaveNode`,j(j({},r),{},{node:e.hoveredNode})),e.hoveredNode=i,e.emit(`enterNode`,j(j({},r),{},{node:i})),e.scheduleHighlightedNodesRender();else if(e.hoveredNode&&e.getNodeAtPosition(n)!==e.hoveredNode){var a=e.hoveredNode;e.hoveredNode=null,e.emit(`leaveNode`,j(j({},r),{},{node:a})),e.scheduleHighlightedNodesRender()}else if(e.settings.enableEdgeEvents){var o=e.hoveredNode?null:e.getEdgeAtPoint(r.event.x,r.event.y);o!==e.hoveredEdge&&(e.hoveredEdge&&e.emit(`leaveEdge`,j(j({},r),{},{edge:e.hoveredEdge})),o&&e.emit(`enterEdge`,j(j({},r),{},{edge:o})),e.hoveredEdge=o)}},this.activeListeners.handleMoveBody=function(t){var n=di(t);e.emit(`moveBody`,{event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(t){var n=di(t),r={event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}};e.hoveredNode&&(e.emit(`leaveNode`,j(j({},r),{},{node:e.hoveredNode})),e.scheduleHighlightedNodesRender()),e.settings.enableEdgeEvents&&e.hoveredEdge&&(e.emit(`leaveEdge`,j(j({},r),{},{edge:e.hoveredEdge})),e.scheduleHighlightedNodesRender()),e.emit(`leaveStage`,j({},r))},this.activeListeners.handleEnter=function(t){var n=di(t),r={event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}};e.emit(`enterStage`,j({},r))};var t=function(t){return function(n){var r=di(n),i={event:r,preventSigmaDefault:function(){r.preventSigmaDefault()}},a=e.getNodeAtPosition(r);if(a)return e.emit(`${t}Node`,j(j({},i),{},{node:a}));if(e.settings.enableEdgeEvents){var o=e.getEdgeAtPoint(r.x,r.y);if(o)return e.emit(`${t}Edge`,j(j({},i),{},{edge:o}))}return e.emit(`${t}Stage`,i)}};return this.activeListeners.handleClick=t(`click`),this.activeListeners.handleRightClick=t(`rightClick`),this.activeListeners.handleDoubleClick=t(`doubleClick`),this.activeListeners.handleWheel=t(`wheel`),this.activeListeners.handleDown=t(`down`),this.activeListeners.handleUp=t(`up`),this.mouseCaptor.on(`mousemove`,this.activeListeners.handleMove),this.mouseCaptor.on(`mousemovebody`,this.activeListeners.handleMoveBody),this.mouseCaptor.on(`click`,this.activeListeners.handleClick),this.mouseCaptor.on(`rightClick`,this.activeListeners.handleRightClick),this.mouseCaptor.on(`doubleClick`,this.activeListeners.handleDoubleClick),this.mouseCaptor.on(`wheel`,this.activeListeners.handleWheel),this.mouseCaptor.on(`mousedown`,this.activeListeners.handleDown),this.mouseCaptor.on(`mouseup`,this.activeListeners.handleUp),this.mouseCaptor.on(`mouseleave`,this.activeListeners.handleLeave),this.mouseCaptor.on(`mouseenter`,this.activeListeners.handleEnter),this.touchCaptor.on(`touchdown`,this.activeListeners.handleDown),this.touchCaptor.on(`touchdown`,this.activeListeners.handleMove),this.touchCaptor.on(`touchup`,this.activeListeners.handleUp),this.touchCaptor.on(`touchmove`,this.activeListeners.handleMove),this.touchCaptor.on(`tap`,this.activeListeners.handleClick),this.touchCaptor.on(`doubletap`,this.activeListeners.handleDoubleClick),this.touchCaptor.on(`touchmove`,this.activeListeners.handleMoveBody),this}},{key:`bindGraphHandlers`,value:function(){var e=this,t=this.graph,n=new Set([`x`,`y`,`zIndex`,`type`]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(r){var i=r.hints?.attributes;e.graph.forEachNode(function(t){return e.updateNode(t)});var a=!i||i.some(function(e){return n.has(e)});e.refresh({partialGraph:{nodes:t.nodes()},skipIndexation:!a,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(n){var r=n.hints?.attributes;e.graph.forEachEdge(function(t){return e.updateEdge(t)});var i=r&&[`zIndex`,`type`].some(function(e){return r?.includes(e)});e.refresh({partialGraph:{edges:t.edges()},skipIndexation:!i,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(t){var n=t.key;e.addNode(n),e.refresh({partialGraph:{nodes:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(t){var n=t.key;e.refresh({partialGraph:{nodes:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(t){var n=t.key;e.removeNode(n),e.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(t){var n=t.key;e.addEdge(n),e.refresh({partialGraph:{edges:[n]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(t){var n=t.key;e.refresh({partialGraph:{edges:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(t){var n=t.key;e.removeEdge(n),e.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){e.clearEdgeState(),e.clearEdgeIndices(),e.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){e.clearEdgeState(),e.clearNodeState(),e.clearEdgeIndices(),e.clearNodeIndices(),e.refresh({schedule:!0})},t.on(`nodeAdded`,this.activeListeners.addNodeGraphUpdate),t.on(`nodeDropped`,this.activeListeners.dropNodeGraphUpdate),t.on(`nodeAttributesUpdated`,this.activeListeners.updateNodeGraphUpdate),t.on(`eachNodeAttributesUpdated`,this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),t.on(`edgeAdded`,this.activeListeners.addEdgeGraphUpdate),t.on(`edgeDropped`,this.activeListeners.dropEdgeGraphUpdate),t.on(`edgeAttributesUpdated`,this.activeListeners.updateEdgeGraphUpdate),t.on(`eachEdgeAttributesUpdated`,this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),t.on(`edgesCleared`,this.activeListeners.clearEdgesGraphUpdate),t.on(`cleared`,this.activeListeners.clearGraphUpdate),this}},{key:`unbindGraphHandlers`,value:function(){var e=this.graph;e.removeListener(`nodeAdded`,this.activeListeners.addNodeGraphUpdate),e.removeListener(`nodeDropped`,this.activeListeners.dropNodeGraphUpdate),e.removeListener(`nodeAttributesUpdated`,this.activeListeners.updateNodeGraphUpdate),e.removeListener(`eachNodeAttributesUpdated`,this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener(`edgeAdded`,this.activeListeners.addEdgeGraphUpdate),e.removeListener(`edgeDropped`,this.activeListeners.dropEdgeGraphUpdate),e.removeListener(`edgeAttributesUpdated`,this.activeListeners.updateEdgeGraphUpdate),e.removeListener(`eachEdgeAttributesUpdated`,this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener(`edgesCleared`,this.activeListeners.clearEdgesGraphUpdate),e.removeListener(`cleared`,this.activeListeners.clearGraphUpdate)}},{key:`getEdgeAtPoint`,value:function(e,t){var n=Fn(this.webGLContexts.edges,this.frameBuffers.edges,e,t,this.pixelRatio,this.pickingDownSizingRatio),r=Pn.apply(void 0,N(n)),i=this.itemIDsIndex[r];return i&&i.type===`edge`?i.id:null}},{key:`process`,value:function(){var e=this;this.emit(`beforeProcess`);var t=this.graph,n=this.settings,r=this.getDimensions();if(this.nodeExtent=qr(this.graph),!this.settings.autoRescale){var i=r.width,a=r.height,o=this.nodeExtent,s=o.x,c=o.y;this.nodeExtent={x:[(s[0]+s[1])/2-i/2,(s[0]+s[1])/2+i/2],y:[(c[0]+c[1])/2-a/2,(c[0]+c[1])/2+a/2]}}this.normalizationFunction=Qr(this.customBBox||this.nodeExtent);var l=Gr(new ci().getState(),r,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(r,n.labelGridCellSize);for(var u={},d={},f={},p={},m=1,h=t.nodes(),g=0,_=h.length;g<_;g++){var v=h[g],y=this.nodeDataCache[v],b=t.getNodeAttributes(v);y.x=b.x,y.y=b.y,this.normalizationFunction.applyTo(y),typeof y.label==`string`&&!y.hidden&&this.labelGrid.add(v,y.size,this.framedGraphToViewport(y,{matrix:l})),u[y.type]=(u[y.type]||0)+1}for(var x in this.labelGrid.organize(),this.nodePrograms){if(!ki.call(this.nodePrograms,x))throw Error(`Sigma: could not find a suitable program for node type "${x}"!`);this.nodePrograms[x].reallocate(u[x]||0),u[x]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(h=Zr(this.nodeZExtent,function(t){return e.nodeDataCache[t].zIndex},h));for(var S=0,C=h.length;S<C;S++){var w=h[S];d[w]=m,p[d[w]]={type:`node`,id:w},m++;var ee=this.nodeDataCache[w];this.addNodeToProgram(w,d[w],u[ee.type]++)}for(var te={},ne=t.edges(),re=0,ie=ne.length;re<ie;re++){var ae=ne[re],oe=this.edgeDataCache[ae];te[oe.type]=(te[oe.type]||0)+1}for(var se in this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ne=Zr(this.edgeZExtent,function(t){return e.edgeDataCache[t].zIndex},ne)),this.edgePrograms){if(!ki.call(this.edgePrograms,se))throw Error(`Sigma: could not find a suitable program for edge type "${se}"!`);this.edgePrograms[se].reallocate(te[se]||0),te[se]=0}for(var ce=0,le=ne.length;ce<le;ce++){var ue=ne[ce];f[ue]=m,p[f[ue]]={type:`edge`,id:ue},m++;var de=this.edgeDataCache[ue];this.addEdgeToProgram(ue,f[ue],te[de.type]++)}return this.itemIDsIndex=p,this.nodeIndices=d,this.edgeIndices=f,this.emit(`afterProcess`),this}},{key:`handleSettingsUpdate`,value:function(e){var t=this,n=this.settings;if(this.camera.minRatio=n.minCameraRatio,this.camera.maxRatio=n.maxCameraRatio,this.camera.enabledZooming=n.enableCameraZooming,this.camera.enabledPanning=n.enableCameraPanning,this.camera.enabledRotation=n.enableCameraRotation,n.cameraPanBoundaries?this.camera.clean=function(e){return t.cleanCameraState(e,n.cameraPanBoundaries&&$r(n.cameraPanBoundaries)===`object`?n.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==n.edgeProgramClasses){for(var r in n.edgeProgramClasses)n.edgeProgramClasses[r]!==e.edgeProgramClasses[r]&&this.registerEdgeProgram(r,n.edgeProgramClasses[r]);for(var i in e.edgeProgramClasses)n.edgeProgramClasses[i]||this.unregisterEdgeProgram(i)}if(e.nodeProgramClasses!==n.nodeProgramClasses||e.nodeHoverProgramClasses!==n.nodeHoverProgramClasses){for(var a in n.nodeProgramClasses)(n.nodeProgramClasses[a]!==e.nodeProgramClasses[a]||n.nodeHoverProgramClasses[a]!==e.nodeHoverProgramClasses[a])&&this.registerNodeProgram(a,n.nodeProgramClasses[a],n.nodeHoverProgramClasses[a]);for(var o in e.nodeProgramClasses)n.nodeProgramClasses[o]||this.unregisterNodeProgram(o)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:`cleanCameraState`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.tolerance,r=n===void 0?0:n,i=t.boundaries,a=j({},e),o=i||this.nodeExtent,s=bn(o.x,2),c=s[0],l=s[1],u=bn(o.y,2),d=u[0],f=u[1],p=[this.graphToViewport({x:c,y:d},{cameraState:e}),this.graphToViewport({x:l,y:d},{cameraState:e}),this.graphToViewport({x:c,y:f},{cameraState:e}),this.graphToViewport({x:l,y:f},{cameraState:e})],m=1/0,h=-1/0,g=1/0,_=-1/0;p.forEach(function(e){var t=e.x,n=e.y;m=Math.min(m,t),h=Math.max(h,t),g=Math.min(g,n),_=Math.max(_,n)});var v=h-m,y=_-g,b=this.getDimensions(),x=b.width,S=b.height,C=0,w=0;if(v>=x?h<x-r?C=h-(x-r):m>r&&(C=m-r):h>x+r?C=h-(x+r):m<-r&&(C=m+r),y>=S?_<S-r?w=_-(S-r):g>r&&(w=g-r):_>S+r?w=_-(S+r):g<-r&&(w=g+r),C||w){var ee=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),te=this.viewportToFramedGraph({x:C,y:w},{cameraState:e});C=te.x-ee.x,w=te.y-ee.y,a.x+=C,a.y+=w}return a}},{key:`renderLabels`,value:function(){if(!this.settings.renderLabels)return this;var e=this.camera.getState(),t=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);ei(t,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var n=this.canvasContexts.labels,r=0,i=t.length;r<i;r++){var a=t[r],o=this.nodeDataCache[a];if(!this.displayedNodeLabels.has(a)&&!o.hidden){var s=this.framedGraphToViewport(o),c=s.x,l=s.y,u=this.scaleSize(o.size);if(!(!o.forceLabel&&u<this.settings.labelRenderedSizeThreshold)&&!(c<-Di||c>this.width+Di||l<-Oi||l>this.height+Oi)){this.displayedNodeLabels.add(a);var d=this.settings.defaultDrawNodeLabel;(this.nodePrograms[o.type]?.drawLabel||d)(n,j(j({key:a},o),{},{size:u,x:c,y:l}),this.settings)}}}return this}},{key:`renderEdgeLabels`,value:function(){if(!this.settings.renderEdgeLabels)return this;var e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);var t=F({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});ei(t,this.edgesWithForcedLabels);for(var n=new Set,r=0,i=t.length;r<i;r++){var a=t[r],o=this.graph.extremities(a),s=this.nodeDataCache[o[0]],c=this.nodeDataCache[o[1]],l=this.edgeDataCache[a];if(!n.has(a)&&!(l.hidden||s.hidden||c.hidden)){var u=this.settings.defaultDrawEdgeLabel;(this.edgePrograms[l.type]?.drawLabel||u)(e,j(j({key:a},l),{},{size:this.scaleSize(l.size)}),j(j(j({key:o[0]},s),this.framedGraphToViewport(s)),{},{size:this.scaleSize(s.size)}),j(j(j({key:o[1]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),this.settings),n.add(a)}}return this.displayedEdgeLabels=n,this}},{key:`renderHighlightedNodes`,value:function(){var e=this,t=this.canvasContexts.hovers;t.clearRect(0,0,this.width,this.height);var n=function(n){var r=e.nodeDataCache[n],i=e.framedGraphToViewport(r),a=i.x,o=i.y,s=e.scaleSize(r.size),c=e.settings.defaultDrawNodeHover;(e.nodePrograms[r.type]?.drawHover||c)(t,j(j({key:n},r),{},{size:s,x:a,y:o}),e.settings)},r=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&r.push(this.hoveredNode),this.highlightedNodes.forEach(function(t){t!==e.hoveredNode&&r.push(t)}),r.forEach(function(e){return n(e)});var i={};for(var a in r.forEach(function(t){var n=e.nodeDataCache[t].type;i[n]=(i[n]||0)+1}),this.nodeHoverPrograms)this.nodeHoverPrograms[a].reallocate(i[a]||0),i[a]=0;r.forEach(function(t){var n=e.nodeDataCache[t];e.nodeHoverPrograms[n.type].process(0,i[n.type]++,n)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var o=this.getRenderParams();for(var s in this.nodeHoverPrograms)this.nodeHoverPrograms[s].render(o)}},{key:`scheduleHighlightedNodesRender`,value:function(){var e=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes(),e.renderEdgeLabels()}))}},{key:`render`,value:function(){var e=this;this.emit(`beforeRender`);var t=function(){return e.emit(`afterRender`),e};if(this.renderFrame&&=(cancelAnimationFrame(this.renderFrame),null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(t){return e.resetWebGLTexture(t)}),!this.graph.order)return t();var n=this.mouseCaptor,r=this.camera.isAnimated()||n.isMoving||n.draggedEvents||n.currentWheelDirection,i=this.camera.getState(),a=this.getDimensions(),o=this.getGraphDimensions(),s=this.getStagePadding();this.matrix=Gr(i,a,o,s),this.invMatrix=Gr(i,a,o,s,!0),this.correctionRatio=Kr(this.matrix,i,a),this.graphToViewportRatio=this.getGraphToViewportRatio();var c=this.getRenderParams();for(var l in this.nodePrograms)this.nodePrograms[l].render(c);if(!this.settings.hideEdgesOnMove||!r)for(var u in this.edgePrograms)this.edgePrograms[u].render(c);return this.settings.hideLabelsOnMove&&r||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),t()}},{key:`addNode`,value:function(e){var t=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(t=this.settings.nodeReducer(e,t));var n=Ai(this.settings,e,t);this.nodeDataCache[e]=n,this.nodesWithForcedLabels.delete(e),n.forceLabel&&!n.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),n.highlighted&&!n.hidden&&this.highlightedNodes.add(e),this.settings.zIndex&&(n.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=n.zIndex),n.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=n.zIndex))}},{key:`updateNode`,value:function(e){this.addNode(e);var t=this.nodeDataCache[e];this.normalizationFunction.applyTo(t)}},{key:`removeNode`,value:function(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}},{key:`addEdge`,value:function(e){var t=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(t=this.settings.edgeReducer(e,t));var n=I(this.settings,e,t);this.edgeDataCache[e]=n,this.edgesWithForcedLabels.delete(e),n.forceLabel&&!n.hidden&&this.edgesWithForcedLabels.add(e),this.settings.zIndex&&(n.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=n.zIndex),n.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=n.zIndex))}},{key:`updateEdge`,value:function(e){this.addEdge(e)}},{key:`removeEdge`,value:function(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}},{key:`clearNodeIndices`,value:function(){this.labelGrid=new P,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:`clearEdgeIndices`,value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:`clearIndices`,value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:`clearNodeState`,value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:`clearEdgeState`,value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:`clearState`,value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:`addNodeToProgram`,value:function(e,t,n){var r=this.nodeDataCache[e],i=this.nodePrograms[r.type];if(!i)throw Error(`Sigma: could not find a suitable program for node type "${r.type}"!`);i.process(t,n,r),this.nodeProgramIndex[e]=n}},{key:`addEdgeToProgram`,value:function(e,t,n){var r=this.edgeDataCache[e],i=this.edgePrograms[r.type];if(!i)throw Error(`Sigma: could not find a suitable program for edge type "${r.type}"!`);var a=this.graph.extremities(e),o=this.nodeDataCache[a[0]],s=this.nodeDataCache[a[1]];i.process(t,n,o,s,r),this.edgeProgramIndex[e]=n}},{key:`getRenderParams`,value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:`getStagePadding`,value:function(){var e=this.settings,t=e.stagePadding;return e.autoRescale&&t||0}},{key:`createLayer`,value:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[e])throw Error(`Sigma: a layer named "${e}" already exists`);var r=Yr(t,{position:`absolute`},{class:`sigma-${e}`});return n.style&&Object.assign(r.style,n.style),this.elements[e]=r,`beforeLayer`in n&&n.beforeLayer?this.elements[n.beforeLayer].before(r):`afterLayer`in n&&n.afterLayer?this.elements[n.afterLayer].after(r):this.container.appendChild(r),r}},{key:`createCanvas`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(e,`canvas`,t)}},{key:`createCanvasContext`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.createCanvas(e,t),r={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=n.getContext(`2d`,r),this}},{key:`createWebGLContext`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t?.canvas||this.createCanvas(e,t);t.hidden&&n.remove();var r=j({preserveDrawingBuffer:!1,antialias:!1},t),i=n.getContext(`webgl2`,r);i||=n.getContext(`webgl`,r),i||=n.getContext(`experimental-webgl`,r);var a=i;if(this.webGLContexts[e]=a,a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),t.picking){this.pickingLayers.add(e);var o=a.createFramebuffer();if(!o)throw Error(`Sigma: cannot create a new frame buffer for layer ${e}`);this.frameBuffers[e]=o}return a}},{key:`killLayer`,value:function(e){var t=this.elements[e];if(!t)throw Error(`Sigma: cannot kill layer ${e}, which does not exist`);if(this.webGLContexts[e]){var n;(n=this.webGLContexts[e].getExtension(`WEBGL_lose_context`))==null||n.loseContext(),delete this.webGLContexts[e]}else this.canvasContexts[e]&&delete this.canvasContexts[e];return t.remove(),delete this.elements[e],this}},{key:`getCamera`,value:function(){return this.camera}},{key:`setCamera`,value:function(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}},{key:`getContainer`,value:function(){return this.container}},{key:`getGraph`,value:function(){return this.graph}},{key:`setGraph`,value:function(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}},{key:`getMouseCaptor`,value:function(){return this.mouseCaptor}},{key:`getTouchCaptor`,value:function(){return this.touchCaptor}},{key:`getDimensions`,value:function(){return{width:this.width,height:this.height}}},{key:`getGraphDimensions`,value:function(){var e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}},{key:`getNodeDisplayData`,value:function(e){var t=this.nodeDataCache[e];return t?Object.assign({},t):void 0}},{key:`getEdgeDisplayData`,value:function(e){var t=this.edgeDataCache[e];return t?Object.assign({},t):void 0}},{key:`getNodeDisplayedLabels`,value:function(){return new Set(this.displayedNodeLabels)}},{key:`getEdgeDisplayedLabels`,value:function(){return new Set(this.displayedEdgeLabels)}},{key:`getSettings`,value:function(){return j({},this.settings)}},{key:`getSetting`,value:function(e){return this.settings[e]}},{key:`setSetting`,value:function(e,t){var n=j({},this.settings);return this.settings[e]=t,ai(this.settings),this.handleSettingsUpdate(n),this.scheduleRefresh(),this}},{key:`updateSetting`,value:function(e,t){return this.setSetting(e,t(this.settings[e])),this}},{key:`setSettings`,value:function(e){var t=j({},this.settings);return this.settings=j(j({},this.settings),e),ai(this.settings),this.handleSettingsUpdate(t),this.scheduleRefresh(),this}},{key:`resize`,value:function(e){var t=this.width,n=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Xr(),this.width===0){if(this.settings.allowInvalidContainer)this.width=1;else throw Error(`Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.`)}if(this.height===0){if(this.settings.allowInvalidContainer)this.height=1;else throw Error(`Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.`)}if(!e&&t===this.width&&n===this.height)return this;for(var r in this.elements){var i=this.elements[r];i.style.width=this.width+`px`,i.style.height=this.height+`px`}for(var a in this.canvasContexts)this.elements[a].setAttribute(`width`,this.width*this.pixelRatio+`px`),this.elements[a].setAttribute(`height`,this.height*this.pixelRatio+`px`),this.pixelRatio!==1&&this.canvasContexts[a].scale(this.pixelRatio,this.pixelRatio);for(var o in this.webGLContexts){this.elements[o].setAttribute(`width`,this.width*this.pixelRatio+`px`),this.elements[o].setAttribute(`height`,this.height*this.pixelRatio+`px`);var s=this.webGLContexts[o];if(s.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(o)){var c=this.textures[o];c&&s.deleteTexture(c)}}return this.emit(`resize`),this}},{key:`clear`,value:function(){return this.emit(`beforeClear`),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit(`afterClear`),this}},{key:`refresh`,value:function(e){var t=this,n=e?.skipIndexation!==void 0&&e?.skipIndexation,r=e?.schedule!==void 0&&e.schedule,i=!e||!e.partialGraph;if(i)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(e){return t.addNode(e)}),this.graph.forEachEdge(function(e){return t.addEdge(e)});else{for(var a,o=e.partialGraph?.nodes||[],s=0,c=o?.length||0;s<c;s++){var l=o[s];if(this.updateNode(l),n){var u=this.nodeProgramIndex[l];if(u===void 0)throw Error(`Sigma: node "${l}" can't be repaint`);this.addNodeToProgram(l,this.nodeIndices[l],u)}}for(var d=(e==null||(a=e.partialGraph)==null?void 0:a.edges)||[],f=0,p=d.length;f<p;f++){var m=d[f];if(this.updateEdge(m),n){var h=this.edgeProgramIndex[m];if(h===void 0)throw Error(`Sigma: edge "${m}" can't be repaint`);this.addEdgeToProgram(m,this.edgeIndices[m],h)}}}return(i||!n)&&(this.needToProcess=!0),r?this.scheduleRender():this.render(),this}},{key:`scheduleRender`,value:function(){var e=this;return this.renderFrame||=requestAnimationFrame(function(){e.render()}),this}},{key:`scheduleRefresh`,value:function(e){return this.refresh(j(j({},e),{},{schedule:!0}))}},{key:`getViewportZoomedState`,value:function(e,t){var n=this.camera.getState(),r=n.ratio,i=n.angle,a=n.x,o=n.y,s=this.settings,c=s.minCameraRatio,l=s.maxCameraRatio;typeof l==`number`&&(t=Math.min(t,l)),typeof c==`number`&&(t=Math.max(t,c));var u=t/r,d={x:this.width/2,y:this.height/2},f=this.viewportToFramedGraph(e),p=this.viewportToFramedGraph(d);return{angle:i,x:(f.x-p.x)*(1-u)+a,y:(f.y-p.y)*(1-u)+o,ratio:t}}},{key:`viewRectangle`,value:function(){var e=this.viewportToFramedGraph({x:0,y:0}),t=this.viewportToFramedGraph({x:this.width,y:0}),n=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:t.x,y2:t.y,height:t.y-n.y}}},{key:`framedGraphToViewport`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=!!t.cameraState||!!t.viewportDimensions||!!t.graphDimensions,r=Ur(t.matrix?t.matrix:n?Gr(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding()):this.matrix,e);return{x:(1+r.x)*this.width/2,y:(1-r.y)*this.height/2}}},{key:`viewportToFramedGraph`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=!!t.cameraState||!!t.viewportDimensions||!t.graphDimensions,r=Ur(t.matrix?t.matrix:n?Gr(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding(),!0):this.invMatrix,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(r.x)&&(r.x=0),isNaN(r.y)&&(r.y=0),r}},{key:`viewportToGraph`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,t))}},{key:`graphToViewport`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(e),t)}},{key:`getGraphToViewportRatio`,value:function(){var e={x:0,y:0},t={x:1,y:1},n=Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),r=this.graphToViewport(e),i=this.graphToViewport(t);return Math.sqrt((r.x-i.x)**2+(r.y-i.y)**2)/n}},{key:`getBBox`,value:function(){return this.nodeExtent}},{key:`getCustomBBox`,value:function(){return this.customBBox}},{key:`setCustomBBox`,value:function(e){return this.customBBox=e,this.scheduleRender(),this}},{key:`kill`,value:function(){this.emit(`kill`),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener(`resize`,this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&=(cancelAnimationFrame(this.renderFrame),null),this.renderHighlightedNodesFrame&&=(cancelAnimationFrame(this.renderHighlightedNodesFrame),null);for(var e=this.container;e.firstChild;)e.removeChild(e.firstChild);for(var t in this.nodePrograms)this.nodePrograms[t].kill();for(var n in this.nodeHoverPrograms)this.nodeHoverPrograms[n].kill();for(var r in this.edgePrograms)this.edgePrograms[r].kill();for(var i in this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={},this.elements)this.killLayer(i);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:`scaleSize`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return e/this.settings.zoomToSizeRatioFunction(t)*(this.getSetting(`itemSizesReference`)===`positions`?t*this.graphToViewportRatio:1)}},{key:`getCanvases`,value:function(){var e={};for(var t in this.elements)this.elements[t]instanceof HTMLCanvasElement&&(e[t]=this.elements[t]);return e}}])}(Nr),Mi=(0,T.createContext)(null),Ni=Mi.Provider;function Pi(){let e=(0,T.useContext)(Mi);if(e==null)throw Error(`No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>`);return e}function Fi(){return Pi().sigma}function L(){let{sigma:e}=Pi();return(0,T.useCallback)((t=>{e&&Object.keys(t).forEach((n=>{e.setSetting(n,t[n])}))}),[e])}function Ii(e){return new Set(Object.keys(e))}var Li=Ii({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),Ri=Ii({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),zi=Ii({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Bi=Ii({updated:!0});function Vi(){let e=Fi(),t=L(),[n,r]=(0,T.useState)({});return(0,T.useEffect)((()=>{if(!e||!n)return;let t=n,r=Object.keys(t);return r.forEach((n=>{let r=t[n];Li.has(n)&&e.on(n,r),Ri.has(n)&&e.getMouseCaptor().on(n,r),zi.has(n)&&e.getTouchCaptor().on(n,r),Bi.has(n)&&e.getCamera().on(n,r)})),()=>{e&&r.forEach((n=>{let r=t[n];Li.has(n)&&e.off(n,r),Ri.has(n)&&e.getMouseCaptor().off(n,r),zi.has(n)&&e.getTouchCaptor().off(n,r),Bi.has(n)&&e.getCamera().off(n,r)}))}}),[e,n,t]),r}function Hi(e,t){if(e===t)return!0;if(typeof e==`object`&&e&&typeof t==`object`&&t){if(Object.keys(e).length!=Object.keys(t).length)return!1;for(let n in e)if(!Object.hasOwn(t,n)||!Hi(e[n],t[n]))return!1;return!0}return!1}function Ui(e){let t=Fi(),[n,r]=(0,T.useState)(e||{});return(0,T.useEffect)((()=>{r((t=>Hi(t,e||{})?t:e||{}))}),[e]),{zoomIn:(0,T.useCallback)((e=>{t.getCamera().animatedZoom(Object.assign(Object.assign({},n),e))}),[t,n]),zoomOut:(0,T.useCallback)((e=>{t.getCamera().animatedUnzoom(Object.assign(Object.assign({},n),e))}),[t,n]),reset:(0,T.useCallback)((e=>{t.getCamera().animatedReset(Object.assign(Object.assign({},n),e))}),[t,n]),goto:(0,T.useCallback)(((e,r)=>{t.getCamera().animate(e,Object.assign(Object.assign({},n),r))}),[t,n]),gotoNode:(0,T.useCallback)(((e,r)=>{let i=t.getNodeDisplayData(e);i?t.getCamera().animate(i,Object.assign(Object.assign({},n),r)):console.warn(`Node ${e} not found`)}),[t,n])}}var Wi=(0,T.forwardRef)((({graph:e,id:t,className:n,style:r,settings:i={},children:a},o)=>{let s=(0,T.useRef)(null),c=(0,T.useRef)(null),l={className:`react-sigma ${n||``}`,id:t,style:r},[u,d]=(0,T.useState)(null),[f,p]=(0,T.useState)(i);(0,T.useEffect)((()=>{p((e=>Hi(e,i)?e:i))}),[i]),(0,T.useEffect)((()=>{let t=null;if(c.current!==null){let n=new k;e&&(n=typeof e==`function`?new e:e),t=new ji(n,c.current,f),d((e=>{let n=null;return e&&(n=e.getCamera().getState()),n&&t.getCamera().setState(n),t}))}return()=>{t&&t.kill()}}),[c,e,f]),(0,T.useImperativeHandle)(o,(()=>u),[u]);let m=(0,T.useMemo)((()=>u&&s.current?{sigma:u,container:s.current}:null),[u,s]),h=m===null?null:T.createElement(Ni,{value:m},a);return T.createElement(`div`,Object.assign({},l,{ref:s}),T.createElement(`div`,{className:`sigma-container`,ref:c}),h)}));async function Gi(e,t=fetch){return y(w(e.vault,`graph/visualization`,{centerId:e.centerId,depth:e.depth,limit:e.limit}),t)}var Ki=new Map([[`bold`,T.createElement(T.Fragment,null,T.createElement(`path`,{d:`M220,48V96a12,12,0,0,1-24,0V77l-35.51,35.52a12,12,0,0,1-17-17L179,60H160a12,12,0,0,1,0-24h48A12,12,0,0,1,220,48ZM95.51,143.51,60,179V160a12,12,0,0,0-24,0v48a12,12,0,0,0,12,12H96a12,12,0,0,0,0-24H77l35.52-35.51a12,12,0,0,0-17-17ZM208,148a12,12,0,0,0-12,12v19l-35.51-35.52a12,12,0,0,0-17,17L179,196H160a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,208,148ZM77,60H96a12,12,0,0,0,0-24H48A12,12,0,0,0,36,48V96a12,12,0,0,0,24,0V77l35.51,35.52a12,12,0,0,0,17-17Z`}))],[`duotone`,T.createElement(T.Fragment,null,T.createElement(`path`,{d:`M208,48V208H48V48Z`,opacity:`0.2`}),T.createElement(`path`,{d:`M216,48V96a8,8,0,0,1-16,0V67.31l-42.34,42.35a8,8,0,0,1-11.32-11.32L188.69,56H160a8,8,0,0,1,0-16h48A8,8,0,0,1,216,48ZM98.34,146.34,56,188.69V160a8,8,0,0,0-16,0v48a8,8,0,0,0,8,8H96a8,8,0,0,0,0-16H67.31l42.35-42.34a8,8,0,0,0-11.32-11.32ZM208,152a8,8,0,0,0-8,8v28.69l-42.34-42.35a8,8,0,0,0-11.32,11.32L188.69,200H160a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,208,152ZM67.31,56H96a8,8,0,0,0,0-16H48a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31l42.34,42.35a8,8,0,0,0,11.32-11.32Z`}))],[`fill`,T.createElement(T.Fragment,null,T.createElement(`path`,{d:`M109.66,146.34a8,8,0,0,1,0,11.32L83.31,184l18.35,18.34A8,8,0,0,1,96,216H48a8,8,0,0,1-8-8V160a8,8,0,0,1,13.66-5.66L72,172.69l26.34-26.35A8,8,0,0,1,109.66,146.34ZM83.31,72l18.35-18.34A8,8,0,0,0,96,40H48a8,8,0,0,0-8,8V96a8,8,0,0,0,13.66,5.66L72,83.31l26.34,26.35a8,8,0,0,0,11.32-11.32ZM208,40H160a8,8,0,0,0-5.66,13.66L172.69,72,146.34,98.34a8,8,0,0,0,11.32,11.32L184,83.31l18.34,18.35A8,8,0,0,0,216,96V48A8,8,0,0,0,208,40Zm3.06,112.61a8,8,0,0,0-8.72,1.73L184,172.69l-26.34-26.35a8,8,0,0,0-11.32,11.32L172.69,184l-18.35,18.34A8,8,0,0,0,160,216h48a8,8,0,0,0,8-8V160A8,8,0,0,0,211.06,152.61Z`}))],[`light`,T.createElement(T.Fragment,null,T.createElement(`path`,{d:`M214,48V96a6,6,0,0,1-12,0V62.48l-45.76,45.76a6,6,0,0,1-8.48-8.48L193.52,54H160a6,6,0,0,1,0-12h48A6,6,0,0,1,214,48ZM99.76,147.76,54,193.52V160a6,6,0,0,0-12,0v48a6,6,0,0,0,6,6H96a6,6,0,0,0,0-12H62.48l45.76-45.76a6,6,0,0,0-8.48-8.48ZM208,154a6,6,0,0,0-6,6v33.52l-45.76-45.76a6,6,0,0,0-8.48,8.48L193.52,202H160a6,6,0,0,0,0,12h48a6,6,0,0,0,6-6V160A6,6,0,0,0,208,154ZM62.48,54H96a6,6,0,0,0,0-12H48a6,6,0,0,0-6,6V96a6,6,0,0,0,12,0V62.48l45.76,45.76a6,6,0,0,0,8.48-8.48Z`}))],[`regular`,T.createElement(T.Fragment,null,T.createElement(`path`,{d:`M216,48V96a8,8,0,0,1-16,0V67.31l-42.34,42.35a8,8,0,0,1-11.32-11.32L188.69,56H160a8,8,0,0,1,0-16h48A8,8,0,0,1,216,48ZM98.34,146.34,56,188.69V160a8,8,0,0,0-16,0v48a8,8,0,0,0,8,8H96a8,8,0,0,0,0-16H67.31l42.35-42.34a8,8,0,0,0-11.32-11.32ZM208,152a8,8,0,0,0-8,8v28.69l-42.34-42.35a8,8,0,0,0-11.32,11.32L188.69,200H160a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,208,152ZM67.31,56H96a8,8,0,0,0,0-16H48a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31l42.34,42.35a8,8,0,0,0,11.32-11.32Z`}))],[`thin`,T.createElement(T.Fragment,null,T.createElement(`path`,{d:`M212,48V96a4,4,0,0,1-8,0V57.66l-49.17,49.17a4,4,0,0,1-5.66-5.66L198.34,52H160a4,4,0,0,1,0-8h48A4,4,0,0,1,212,48ZM101.17,149.17,52,198.34V160a4,4,0,0,0-8,0v48a4,4,0,0,0,4,4H96a4,4,0,0,0,0-8H57.66l49.17-49.17a4,4,0,0,0-5.66-5.66ZM208,156a4,4,0,0,0-4,4v38.34l-49.17-49.17a4,4,0,0,0-5.66,5.66L198.34,204H160a4,4,0,0,0,0,8h48a4,4,0,0,0,4-4V160A4,4,0,0,0,208,156ZM57.66,52H96a4,4,0,0,0,0-8H48a4,4,0,0,0-4,4V96a4,4,0,0,0,8,0V57.66l49.17,49.17a4,4,0,0,0,5.66-5.66Z`}))]]),qi=T.forwardRef((e,t)=>T.createElement(te,{ref:t,...e,weights:Ki}));qi.displayName=`ArrowsOutIcon`;var R=i();function Ji(e){let{zoomIn:t,zoomOut:n,reset:r}=Ui({duration:180}),[i,a]=(0,T.useState)(!1),[o,s]=(0,T.useState)(!1),[c,u]=(0,T.useState)(``),[g,_]=(0,T.useState)(0),v=(0,T.useRef)(null),y=e.selectedNode,b=(0,T.useMemo)(()=>{let t=c.trim().toLocaleLowerCase();return t?e.data.nodes.filter(e=>`${e.label}\n${e.id}`.toLocaleLowerCase().includes(t)).slice(0,20):e.data.nodes.slice(0,20)},[e.data.nodes,c]);function x(t){e.onLocate(t),a(!1)}function S(e){!e.nativeEvent.isComposing&&b.length&&(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),_(t=>(t+(e.key===`ArrowDown`?1:-1)+b.length)%b.length)):e.key===`Enter`&&(e.preventDefault(),x(b[Math.min(g,b.length-1)].id)))}return(0,R.jsxs)(`div`,{className:`graph-control-dock`,"aria-label":`Graph controls`,children:[(0,R.jsxs)(m,{open:i,onOpenChange:e=>{a(e),e&&(_(0),requestAnimationFrame(()=>v.current?.focus()))},label:`Find a graph node`,placement:`top-start`,mobileMode:`sheet`,className:`graph-search-popover`,trigger:(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Search graph`,"data-keyboard-item":`true`,children:(0,R.jsx)(ae,{"aria-hidden":`true`})}),children:[(0,R.jsx)(d,{ref:v,"data-popover-autofocus":`true`,type:`search`,value:c,"aria-label":`Search notes and graph objects`,placeholder:`Search the graph`,onChange:e=>{u(e.target.value),_(0)},onKeyDown:S}),(0,R.jsxs)(`div`,{className:`graph-search-results`,role:`listbox`,"aria-label":`Graph search results`,children:[b.map((e,t)=>(0,R.jsxs)(l,{variant:`ghost`,size:`small`,role:`option`,"aria-selected":t===g,className:t===g?`active`:``,onPointerMove:()=>_(t),onClick:()=>x(e.id),children:[(0,R.jsx)(`strong`,{children:e.label}),(0,R.jsx)(`span`,{className:`graph-result-id`,children:e.id})]},e.id)),!b.length&&(0,R.jsx)(f,{as:`div`,tone:`muted`,children:`No matching nodes.`})]})]}),(0,R.jsx)(h,{ref:e.queryToggleRef,variant:`ghost`,size:`small`,"aria-label":`Cypher query`,"aria-pressed":e.queryOpen,"data-keyboard-item":`true`,className:e.queryActive?`graph-query-toggle-active`:``,onClick:e.onToggleQuery,children:(0,R.jsx)(re,{"aria-hidden":`true`})}),(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Zoom in`,"data-keyboard-item":`true`,onClick:()=>t(),children:`+`}),(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Zoom out`,"data-keyboard-item":`true`,onClick:()=>n(),children:`−`}),(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Fit graph`,"data-keyboard-item":`true`,onClick:()=>r(),children:(0,R.jsx)(ee,{"aria-hidden":`true`})}),y&&y.id!==e.data.scope.centerId&&(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Local graph around ${y.label}`,"data-keyboard-item":`true`,onClick:()=>e.onShowLocalGraph(y.id),children:(0,R.jsx)(ie,{"aria-hidden":`true`})}),(0,R.jsxs)(m,{open:o,onOpenChange:s,label:`Graph display settings`,placement:`top-start`,mobileMode:`sheet`,className:`graph-settings-popover`,trigger:(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Graph display settings`,"data-keyboard-item":`true`,children:(0,R.jsx)(oe,{"aria-hidden":`true`})}),children:[(0,R.jsxs)(`header`,{children:[(0,R.jsx)(`strong`,{children:`Display`}),(0,R.jsxs)(`span`,{children:[e.data.meta.returnedNodes.toLocaleString(),` loaded nodes`]})]}),(0,R.jsx)(p,{checked:e.showIsolated,onCheckedChange:e.onShowIsolatedChange,children:`Show unconnected notes`}),(0,R.jsx)(p,{checked:e.showLabels,onCheckedChange:e.onShowLabelsChange,children:`Show labels while exploring`}),(0,R.jsxs)(`div`,{className:`graph-settings-actions`,children:[(0,R.jsx)(l,{size:`small`,onClick:e.onShowAllCategories,children:`Show all`}),(0,R.jsx)(l,{size:`small`,onClick:e.onShowNotesOnly,children:`Notes only`})]}),(0,R.jsx)(`div`,{className:`graph-category-list`,children:e.categories.map(t=>(0,R.jsxs)(p,{checked:!e.hiddenCategories.has(t.id),onCheckedChange:()=>e.onToggleCategory(t.id),children:[(0,R.jsx)(`i`,{style:{background:t.color}}),` `,(0,R.jsx)(`span`,{children:t.label}),(0,R.jsx)(`span`,{className:`graph-category-count`,children:t.count.toLocaleString()})]},t.id))})]}),e.localMode&&(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Return to full graph`,"data-keyboard-item":`true`,onClick:e.onShowFull,children:(0,R.jsx)(qi,{"aria-hidden":`true`})})]})}var Yi=class{original;value;constructor(e,t){this.original=e,this.value=t}accept(e,t){return e.visitLiteral(this,t)}},Xi=class{lang;id;operands;constructor(e,t,n){this.lang=e,this.id=t,this.operands=n}accept(e,t){return e.visitOperator(this,t)}},Zi=class{lang;id;args;constructor(e,t,n){this.lang=e,this.id=t,this.args=n}accept(e,t){return e.visitFunction(this,t)}},Qi=Symbol(`all attrs`),$i=Symbol(`bound param`),z=class e{aggregate;parts=[];[Symbol.iterator](){return this.parts[Symbol.iterator]()}accept(e,t){return e.visitIdentifier(this,t)}static fromParts(t){let n=new e;return n.parts=t,n}equals(e){if(this.parts.length!==e.parts.length)return!1;for(let t=0;t<this.parts.length;t++)if(this.parts[t]!==e.parts[t])return!1;return!0}},ea=class{lang;node;constructor(e,t){if(this.lang=e,t.length!==1)throw Error(`LangSwitch must contain exactly one statement`);this.node=t[0]}accept(e,t){return e.visitLangSwitch(this,t)}};function ta(e){return e}function na(e,t){return t}function ra(e){return e[0]}function ia(e){return e[1]}function aa(e){return[e,e]}function oa(e){return e instanceof G}function sa(e){return e instanceof z}function ca(e){return e!==null}function la(e){return e.clone()}function ua(e){return e&&(Array.isArray(e)?[ua(e[0]),e[1]]:e instanceof z?e:e.clone())}function da(e,t){return e&&(Array.isArray(e)?[da(e[0],t),e[1]]:e instanceof z?e:_o in e||e instanceof go?e.clone(t):e.clone())}function fa(e){return Array.isArray(e)?e:Array.from(e)}function B(e){if(e.length===0)return null;if(e.length>1)throw Error(`More than one element in sequence`);return e[0]}function pa(e,t){for(let n of t)e=e?.[n];return e}function ma(e,...t){let n={};for(let r=0;r<t.length;r++)n[e[r]]=t[r];return n}function ha(e,t){let n=[];for(let r of t)n.push(e[r]);return n}var ga=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window||typeof self==`object`&&self||typeof global==`object`&&global||(function(){return this})();function _a(){}function va(e){return e==null||typeof e!=`object`&&typeof e!=`function`}function ya(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ba(e){return ga.Buffer!==void 0&&ga.Buffer.isBuffer(e)}function xa(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function Sa(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var Ca=`[object RegExp]`,wa=`[object String]`,Ta=`[object Number]`,Ea=`[object Boolean]`,Da=`[object Arguments]`,Oa=`[object Symbol]`,ka=`[object Date]`,Aa=`[object Map]`,ja=`[object Set]`,Ma=`[object Array]`,Na=`[object Function]`,V=`[object ArrayBuffer]`,Pa=`[object Object]`,Fa=`[object Error]`,Ia=`[object DataView]`,La=`[object Uint8Array]`,Ra=`[object Uint8ClampedArray]`,za=`[object Uint16Array]`,Ba=`[object Uint32Array]`,Va=`[object BigUint64Array]`,Ha=`[object Int8Array]`,Ua=`[object Int16Array]`,Wa=`[object Int32Array]`,Ga=`[object BigInt64Array]`,Ka=`[object Float32Array]`,qa=`[object Float64Array]`;function Ja(e,t,n,r=new Map,i=void 0){let a=i?.(e,t,n,r);if(a!==void 0)return a;if(va(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=Ja(e[a],a,n,r,i);return Object.hasOwn(e,`index`)&&(t.index=e.index),Object.hasOwn(e,`input`)&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){let t=new Map;r.set(e,t);for(let[a,o]of e)t.set(a,Ja(o,a,n,r,i));return t}if(e instanceof Set){let t=new Set;r.set(e,t);for(let a of e)t.add(Ja(a,void 0,n,r,i));return t}if(ba(e))return e.subarray();if(ya(e)){let t=new(Object.getPrototypeOf(e)).constructor(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=Ja(e[a],a,n,r,i);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return r.set(e,t),Ya(t,e,n,r,i),t}if(typeof File<`u`&&e instanceof File){let t=new File([e],e.name,{type:e.type});return r.set(e,t),Ya(t,e,n,r,i),t}if(typeof Blob<`u`&&e instanceof Blob){let t=new Blob([e],{type:e.type});return r.set(e,t),Ya(t,e,n,r,i),t}if(e instanceof Error){let t=structuredClone(e);return r.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,t.constructor=e.constructor,Ya(t,e,n,r,i),t}if(e instanceof Boolean){let t=new Boolean(e.valueOf());return r.set(e,t),Ya(t,e,n,r,i),t}if(e instanceof Number){let t=new Number(e.valueOf());return r.set(e,t),Ya(t,e,n,r,i),t}if(e instanceof String){let t=new String(e.valueOf());return r.set(e,t),Ya(t,e,n,r,i),t}if(typeof e==`object`&&Xa(e)){let t=Object.create(Object.getPrototypeOf(e));return r.set(e,t),Ya(t,e,n,r,i),t}return e}function Ya(e,t,n=e,r,i){let a=[...Object.keys(t),...xa(t)];for(let o=0;o<a.length;o++){let s=a[o],c=Object.getOwnPropertyDescriptor(e,s);(c==null||c.writable)&&(e[s]=Ja(t[s],s,n,r,i))}}function Xa(e){switch(Sa(e)){case Da:case Ma:case V:case Ia:case Ea:case ka:case Ka:case qa:case Ha:case Ua:case Wa:case Aa:case Ta:case Pa:case Ca:case ja:case wa:case Oa:case La:case Ra:case za:case Ba:return!0;default:return!1}}function Za(e){return Ja(e,void 0,e,new Map,void 0)}function Qa(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function $a(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function eo(e,t,n){return to(e,t,void 0,void 0,void 0,void 0,n)}function to(e,t,n,r,i,a,o){let s=o(e,t,n,r,i,a);if(s!==void 0)return s;if(typeof e==typeof t)switch(typeof e){case`bigint`:case`string`:case`boolean`:case`symbol`:case`undefined`:return e===t;case`number`:return e===t||Object.is(e,t);case`function`:return e===t;case`object`:return no(e,t,a,o)}return no(e,t,a,o)}function no(e,t,n,r){if(Object.is(e,t))return!0;let i=Sa(e),a=Sa(t);if(i===`[object Arguments]`&&(i=Pa),a===`[object Arguments]`&&(a=Pa),i!==a)return!1;switch(i){case wa:return e.toString()===t.toString();case Ta:return $a(e.valueOf(),t.valueOf());case Ea:case ka:case Oa:return Object.is(e.valueOf(),t.valueOf());case Ca:return e.source===t.source&&e.flags===t.flags;case Na:return e===t}n??=new Map;let o=n.get(e),s=n.get(t);if(o!=null&&s!=null)return o===t;n.set(e,t),n.set(t,e);try{switch(i){case Aa:if(e.size!==t.size)return!1;for(let[i,a]of e.entries())if(!t.has(i)||!to(a,t.get(i),i,e,t,n,r))return!1;return!0;case ja:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),a=Array.from(t.values());for(let o=0;o<i.length;o++){let s=i[o],c=a.findIndex(i=>to(s,i,void 0,e,t,n,r));if(c===-1)return!1;a.splice(c,1)}return!0}case Ma:case La:case Ra:case za:case Ba:case Va:case Ha:case Ua:case Wa:case Ga:case Ka:case qa:if(ba(e)!==ba(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!to(e[i],t[i],i,e,t,n,r))return!1;return!0;case V:return e.byteLength===t.byteLength&&no(new Uint8Array(e),new Uint8Array(t),n,r);case Ia:return e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset?!1:no(new Uint8Array(e),new Uint8Array(t),n,r);case Fa:return e.name===t.name&&e.message===t.message;case Pa:{if(!(no(e.constructor,t.constructor,n,r)||Qa(e)&&Qa(t)))return!1;let i=[...Object.keys(e),...xa(e)],a=[...Object.keys(t),...xa(t)];if(i.length!==a.length)return!1;for(let a=0;a<i.length;a++){let o=i[a],s=e[o];if(!Object.hasOwn(t,o))return!1;let c=t[o];if(!to(s,c,o,e,t,n,r))return!1}return!0}default:return!1}}finally{n.delete(e),n.delete(t)}}function ro(e,t){return eo(e,t,_a)}var io=Symbol(`SENTINEL`),H=class e{root=new Map;get size(){return this._size}_size=0;constructor(e){if(e){if(Symbol.iterator in e)for(let t of e)this.add(t);else{for(let t in e)this.set([t],e[t]);for(let t of Object.getOwnPropertySymbols(e))this.set([t],e[t])}}}add(e){this.set(e,!0)}set(e,t){let n=this.root;for(let t of e)n.has(t)||n.set(t,new Map),n=n.get(t);n.has(io)||this._size++,n.set(io,t)}has(e){let t=this.root;for(let n of e){if(!t.has(n))return!1;t=t.get(n)}return t.has(io)}get(e,t){let n=this.root;for(let r of e){if(!n.has(r)){if(t!==void 0)n.set(r,new Map);else return}n=n.get(r)}return t!==void 0&&!n.has(io)?(n.set(io,t),this._size++,t):n.get(io)}delete(e){let t=this.deleteRecursive(this.root,e);return t&&this._size--,t}deleteRecursive(e,t){if(t.length===0)return e.delete(io);let[n,...r]=t,i=e.get(n);if(i){let t=this.deleteRecursive(i,r);return i.size===0&&e.delete(n),t}return!1}clear(){this.root.clear(),this._size=0}prefixAll(e){if(e.length===0||!this.size)return;let t=this.root;this.root=new Map;let n=this.root;for(let t=0;t<e.length-1;t++)n.set(e[t],n=new Map);n.set(e.at(-1),t)}[Symbol.iterator](){return this.keys()}*keys(e=[]){let t=this.root;for(let n of e){if(!t.has(n))return;t=t.get(n)}yield*this.iterTrieInner(t,e)}*entries(e=[]){let t=this.root;for(let n of e){if(!t.has(n))return;t=t.get(n)}yield*this.iterTrieInnerEntries(t,e)}*iterTrieInner(e,t){for(let[n,r]of e)n===io?yield t:r&&(yield*this.iterTrieInner(r,t.concat(n)))}*iterTrieInnerEntries(e,t){for(let[n,r]of e)n===io?yield[t,e.get(io)]:r&&(yield*this.iterTrieInnerEntries(r,t.concat(n)))}clone(t=!1){let n=t?Za(this.root):this.shallowClone(this.root),r=new e;return r.root=n,r._size=this._size,r}shallowClone(e){let t=new Map;for(let[n,r]of e)n===io?t.set(n,r):t.set(n,this.shallowClone(r));return t}};function ao(e){let t=new H;for(let n of e)t.add(n.parts);return t}function U(...e){let t=new H;for(let n of e)if(Array.isArray(n))for(let e of n)t.add(e.parts);else for(let e of n)t.add(e);return t}function oo(e,...t){let n=new H;for(let t of e)n.add(t);for(let e of t)for(let t of e)n.delete(t);return n}function so(e,t){let n=new H;if(Array.isArray(t))for(let r of t)e.has(r.parts)&&n.add(r.parts);else for(let r of t)e.has(r)&&n.add(r);return n}function co(e,t){if(Array.isArray(t)){for(let n of t)if(!e.has(n.parts))return!1}else for(let n of t)if(!e.has(n))return!1;return!0}function lo(e,t){if(Array.isArray(t)){for(let n of t)if(e.has(n.parts))return!0}else for(let n of t)if(e.has(n))return!0;return!1}function uo(e){let t=new H;for(let[n,r]of e.entries())t.set(r,n);return t}var W=class{schema;schemaSet;lang;parent;addToSchema(e){if(Array.isArray(e))for(let t of e)this.schemaSet.has(t.parts)||(this.schema.push(t),this.schemaSet.add(t.parts));else if(e instanceof H)for(let t of e)this.schemaSet.has(t)||(this.schema.push(z.fromParts(t)),this.schemaSet.add(t));else this.schemaSet.has(e.parts)||(this.schema.push(e),this.schemaSet.add(e.parts))}removeFromSchema(e){let t=!1;if(Array.isArray(e))for(let n of e)t=this.schemaSet.delete(n.parts)||t;else if(e instanceof H)for(let n of e)t=this.schemaSet.delete(n)||t;else t=this.schemaSet.delete(e.parts);if(t){let e=this.schema.filter(e=>this.schemaSet.has(e.parts));this.schema.length=0,this.schema.push(...e)}return t}clearSchema(){this.schema.length=0,this.schemaSet.clear()}getDependencies(){return new H}};function fo(e,t){for(let n of e)n instanceof z||(n.parent=t)}var po=class e extends W{name;constructor(e,t){super(),this.name=t,this.lang=e,this.schema=[],this.schemaSet=new H}accept(e,t){return e[this.lang].visitTupleSource(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(){let t=new e(this.lang,this.name);return t.schema=this.schema.slice(),t.schemaSet=this.schemaSet.clone(),t}},mo=class e extends W{args;impl;name;constructor(e,t,n,r){super(),this.args=t,this.impl=n,this.name=r,this.lang=e,this.schema=[],this.schemaSet=new H,fo(this.args,this)}accept(e,t){return e[this.lang].visitTupleFnSource(this,t)}replaceChild(e,t){t.parent=this;let n=this.args.indexOf(e);this.args[n]=t}getChildren(){return this.args.filter(oa)}clone(){let t=new e(this.lang,this.args.map(ua),this.impl,this.name);return t.schema=this.schema.slice(),t.schemaSet=this.schemaSet.clone(),t}getDependencies(){return ao(this.args.filter(sa))}},ho=class e extends po{index;access;fromItemKey;constructor(e,t,n,r,i){super(e,t),this.index=n,this.access=r,this.fromItemKey=i,this.access.parent=this}accept(e,t){return e[this.lang].visitIndexScan(this,t)}replaceChild(e,t){t.parent=this,this.access=t}getChildren(){return[this.access]}clone(){let t=new e(this.lang,this.name,this.index,this.access.clone(),this.fromItemKey);return t.schema=this.schema.slice(),t.schemaSet=this.schemaSet.clone(),t}},go=class e{lang;args;impl;fieldName;postGroupOp;get postGroupSource(){return this._postGSource}_postGSource;parent;constructor(e,t,n,r){this.lang=e,this.args=t,this.impl=n,this.fieldName=r,fo(this.args,this),this._postGSource=new po(e,z.fromParts([`<partition>`])),this.postGroupOp=this._postGSource,this.fieldName.aggregate=this}accept(e,t){return e[this.lang].visitAggregate(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.args.length;n++)if(this.args[n]===e){this.args[n]=t;return}}getChildren(){return this.args.filter(oa)}clone(t){let n=this.args.map(ua),r=new e(this.lang,n,this.impl,z.fromParts(this.fieldName.parts)),i=[],a=this._postGSource;for(;a!==this.postGroupOp;){let e=a.parent.getChildren();i.push(e.indexOf(a)),a=a.parent}r.postGroupOp=this.postGroupOp.clone();let o=r.postGroupOp;for(let e=i.length-1;e>=0;e--)o=o.getChildren()[i[e]];r._postGSource=o;for(let e of t??[])e.aggregate===this&&(e.aggregate=r);return r}getDependencies(){return ao(this.args.filter(sa))}},_o=Symbol(`CalcIntermediate`),G=class e{lang;impl;args;argMeta;original;aggregates;literal;parent;constructor(e,t,n,r,i,a=[],o=!1){this.lang=e,this.impl=t,this.args=n,this.argMeta=r,this.original=i,this.aggregates=a,this.literal=o,fo(n,this),fo(a,this)}accept(e,t){return e[this.lang].visitCalculation(this,t)}replaceChild(e,t){t.parent=this;let n;if(e instanceof go?(n=this.aggregates.indexOf(e),this.aggregates[n]=t,n=this.argMeta.findIndex(t=>t.aggregate===e),this.argMeta[n].aggregate=t):(n=this.args.indexOf(e),this.args[n]=t),e===this.original)this.original=t;else{let e=this.argMeta[n].originalLocations;if(!e.length)return;e[0].obj[e[0].key]=t;for(let n=1;n<e.length;n++)e[n].obj[e[n].key]=t.clone()}}getChildren(){let e=[];for(let t of this.args)t instanceof z||e.push(t);return e}clone(){let t=this.argMeta.map(e=>({...e,originalLocations:e.originalLocations.map(e=>({...e}))}));if(this.original&&(_o in this.original||this.original instanceof go)){let n=this.original.clone(t),r=t.filter(e=>e.aggregate).map(e=>e.aggregate),i=t.map(e=>{let t=e.originalLocations[0];return t.obj[t.key]});return new e(this.lang,this.impl,i,t,n,r,this.literal)}let n=this.original?.clone();return new e(this.lang,this.impl,this.args[0]===this.original&&this.args.length===1?[n]:this.args.map(ua),t,n,this.aggregates.map(la),this.literal)}getDependencies(){return ao(this.args.filter(sa))}},K=class e{lang;args;impl;pure;[_o]=!0;constructor(e,t,n,r=!1){this.lang=e,this.args=t,this.impl=n,this.pure=r;for(let e of t)`op`in e&&(e.op.parent=this)}accept(e,t){return e[this.lang].visitFnCall(this,t)}replaceChild(e,t){for(let n of this.args)if(`op`in n&&n.op===e){n.op=t,t.parent=this;return}}getChildren(){let e=[];for(let t of this.args)`op`in t&&e.push(t.op);return e}clone(t){let n=new e(this.lang,this.args.map(e=>`op`in e?{...e,op:_o in e.op||e.op instanceof go?e.op.clone(t):e.op.clone()}:e),this.impl,this.pure);for(let e of t??[])for(let t of e.originalLocations){if(t.op===this)t.op=n;else continue;if(t.obj===this.args)t.obj=n.args;else{let e=this.args.indexOf(t.obj);e!==-1&&(t.obj=n.args[e])}}return n}getDependencies(){return ao(this.args.filter(sa))}},vo=class e{lang;name;parent;constructor(e,t){this.lang=e,this.name=t}accept(e,t){return e[this.lang].visitItemSource(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(){return new e(this.lang,this.name)}getDependencies(){return new H}},yo=class e{lang;args;impl;name;parent;constructor(e,t,n,r){this.lang=e,this.args=t,this.impl=n,this.name=r,fo(this.args,this)}accept(e,t){return e[this.lang].visitItemFnSource(this,t)}replaceChild(e,t){t.parent=this;let n=this.args.indexOf(e);this.args[n]=t}getChildren(){return this.args.filter(oa)}clone(){return new e(this.lang,this.args.map(ua),this.impl,this.name)}getDependencies(){return ao(this.args.filter(sa))}},bo=class e{lang;value;[_o]=!0;constructor(e,t){this.lang=e,this.value=t}accept(e,t){return e[this.lang].visitLiteral(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(t){return new e(this.lang,this.value)}getDependencies(){return new H}},q=class e extends W{attrs;source;renames=new H;renamesInv=new H;constructor(e,t,n){super(),this.attrs=t,this.source=n,this.lang=e,this.schema=t.map(ia),this.schemaSet=ao(this.schema),n.parent=this;for(let[e,t]of this.attrs)e instanceof z?(this.renames.set(e.parts,t.parts),this.renamesInv.set(t.parts,e.parts)):e.parent=this}accept(e,t){return e[this.lang].visitProjection(this,t)}replaceChild(e,t){let n=t instanceof z;if(n||(t.parent=this),e===this.source){if(n)throw Error(`cannot replace source with identifier`);this.source=t}else this.attrs.find(t=>t[0]===e)[0]=t}getChildren(){let e=this.attrs.map(ra).filter(oa);return e.push(this.source),e}clone(){return new e(this.lang,this.attrs.map(ua),this.source.clone())}getDependencies(){return ao(this.attrs.map(ra).filter(sa))}},xo=class e extends W{mapping;outer;source;emptyVal=new H;validateSingleValue=!1;constructor(e,t,n,r){super(),this.mapping=t,this.outer=n,this.source=r,this.lang=e,this.schema=r.schema.filter(e=>!t.schemaSet.has(e.parts)).concat(t.schema),this.schemaSet=ao(this.schema),t.parent=this,r.parent=this}accept(e,t){return e[this.lang].visitProjectionConcat(this,t)}replaceChild(e,t){t.parent=this,e===this.mapping?this.mapping=t:this.source=t,this.clearSchema(),this.addToSchema(this.source.schema),this.removeFromSchema(this.mapping.schema),this.addToSchema(this.mapping.schema)}getChildren(){return[this.source,this.mapping]}clone(){let t=new e(this.lang,this.mapping.clone(),this.outer,this.source.clone());return t.emptyVal=this.emptyVal.clone(),t.validateSingleValue=this.validateSingleValue,t}},So=class e extends W{indexCol;source;constructor(e,t,n){super(),this.indexCol=t,this.source=n,this.lang=e,this.schema=[...n.schema.filter(e=>!e.equals(t)),t],this.schemaSet=ao(this.schema),n.parent=this}accept(e,t){return e[this.lang].visitProjectionIndex(this,t)}replaceChild(e,t){t.parent=this,this.source=t,this.clearSchema(),this.addToSchema(t.schema.filter(e=>!e.equals(this.indexCol))),this.addToSchema(this.indexCol)}getChildren(){return[this.source]}clone(){return new e(this.lang,this.indexCol,this.source.clone())}};function Co(e,t){let n=new K(t,[e],ta);return new G(t,ta,[e],[{originalLocations:[{obj:n.args,key:0,idAsFnArg:!0,op:n}]}],n,[],!1)}function wo(e,t,n){if(e.args.length===0)return e;let r=[e.args[0]],i=[e.argMeta[0]],a=[0];outer:for(let o=1;o<e.args.length;o++){let s=t[e.args[o]instanceof z?n:e.args[o].lang];for(let t=0;t<o;t++)if(r[t]&&s.areEqual(e.args[o],r[t])){a.push(t),i[t].usedMultipleTimes=!0,i[t].originalLocations.push(...e.argMeta[o].originalLocations),i[t].maybeSkipped&&=e.argMeta[o]?.maybeSkipped;continue outer}r.push(e.args[o]),a.push(r.length-1),i.push(e.argMeta[o])}if(r.length===e.args.length)return e;let o={args:r,impl:(...t)=>{let n=[];for(let e of a)n.push(t[e]);return e.impl.apply(null,n)},argMeta:i,literal:e.literal};return e.aggregates?.length&&(o.aggregates=i.filter(e=>e?.aggregate instanceof go).map(e=>e.aggregate)),o}function To(e,t,n){let r=e.accept(t);return r=wo(r,n,e.lang),new G(e.lang,r.impl,r.args,r.argMeta,e,r.aggregates,r.literal)}var J=class e extends W{source;condition;constructor(e,t,n){super(),this.source=n,this.lang=e,this.schema=n.schema,this.schemaSet=n.schemaSet,this.condition=t instanceof G?t:Co(t,e),this.condition.parent=this,n.parent=this}accept(e,t){return e[this.lang].visitSelection(this,t)}replaceChild(e,t){t instanceof z&&(t=Co(t,this.lang)),t.parent=this,e===this.condition?this.condition=t:this.source=t}getChildren(){return[this.source,this.condition]}clone(){return new e(this.lang,this.condition.clone(),this.source.clone())}},Eo=class e{lang;condition;whenThens;defaultCase;[_o]=!0;constructor(e,t,n,r){this.lang=e,this.condition=t,this.whenThens=n,this.defaultCase=r;let i=n.flat();t&&i.push(t),r&&i.push(r);for(let e of i)e instanceof z||(e.parent=this)}accept(e,t){return e[this.lang].visitConditional(this,t)}replaceChild(e,t){if(t.parent=this,this.condition===e)this.condition=t;else if(this.defaultCase===e)this.defaultCase=t;else for(let n of this.whenThens){if(n[0]===e){n[0]=t;return}if(n[1]===e){n[1]=t;return}}}getChildren(){return[this.condition,...this.whenThens.flat(),this.defaultCase].filter(e=>e&&!(e instanceof z))}clone(t){let n=new e(this.lang,da(this.condition,t),this.whenThens.map(e=>[da(e[0],t),da(e[1],t)]),da(this.defaultCase,t));for(let e of t??[])for(let t of e.originalLocations){if(t.op===this)t.op=n;else continue;if(t.obj===this)t.obj=n;else{let e=this.whenThens.indexOf(t.obj);e!==-1&&(t.obj=n.whenThens[e])}}return n}getDependencies(){let e=new H,t=this.whenThens.flat();this.condition&&t.push(this.condition),this.defaultCase&&t.push(this.defaultCase);for(let n of t)n instanceof z&&e.add(n.parts);return e}},Do=class e extends W{left;right;validateSingleValue=!1;constructor(e,t,n){super(),this.left=t,this.right=n,this.lang=e,this.schema=t.schema&&n.schema?t.schema.filter(e=>!n.schemaSet.has(e.parts)).concat(n.schema):t.schema||n.schema||[],this.schemaSet=ao(this.schema),t.parent=this,n.parent=this}accept(e,t){return e[this.lang].visitCartesianProduct(this,t)}replaceChild(e,t){t.parent=this,e===this.left?this.left=t:this.right=t,this.clearSchema(),this.addToSchema(this.left.schema),this.addToSchema(this.right.schema)}getChildren(){return[this.left,this.right]}clone(){let t=new e(this.lang,this.left.clone(),this.right.clone());return t.validateSingleValue=this.validateSingleValue,t}},Oo=class e extends Do{conditions;leftOuter=!1;rightOuter=!1;constructor(e,t,n,r){super(e,t,n),this.conditions=r,fo(this.conditions,this)}accept(e,t){return e[this.lang].visitJoin(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.conditions.length;n++)if(this.conditions[n]===e){this.conditions[n]=t;return}super.replaceChild(e,t)}getChildren(){return[this.left,this.right,...this.conditions]}clone(){let t=new e(this.lang,this.left.clone(),this.right.clone(),this.conditions.map(la));return t.leftOuter=this.leftOuter,t.rightOuter=this.rightOuter,t}},ko=class e{lang;key;source;parent;constructor(e,t,n){this.lang=e,this.key=t,this.source=n,t||(this.key=n.schema?.length===1?n.schema[0]:z.fromParts([Qi])),n.parent=this}accept(e,t){return e[this.lang].visitMapToItem(this,t)}replaceChild(e,t){t.parent=this,this.source=t}getChildren(){return[this.source]}clone(){return new e(this.lang,this.key,this.source.clone())}getDependencies(){return new H([this.key.parts])}},Ao=class e extends W{key;source;constructor(e,t,n){super(),this.key=t,this.source=n,this.lang=e,this.schema=[t],this.schemaSet=ao(this.schema),n.parent=this}accept(e,t){return e[this.lang].visitMapFromItem(this,t)}replaceChild(e,t){t.parent=this,this.source=t}getChildren(){return[this.source]}clone(){return new e(this.lang,this.key,this.source.clone())}};function jo(e){return e.key}var Mo=class e extends W{orders;source;constructor(e,t,n){super(),this.orders=t,this.source=n,this.lang=e,this.schema=n.schema,this.schemaSet=n.schemaSet,n.parent=this,fo(t.map(jo),this)}accept(e,t){return e[this.lang].visitOrderBy(this,t)}replaceChild(e,t){let n=t instanceof z;if(n||(t.parent=this),e===this.source){if(n)throw Error(`cannot replace source with an identifier`);this.source=t}else this.orders.find(t=>t.key===e).key=t}getChildren(){let e=this.orders.map(jo).filter(oa);return e.push(this.source),e}clone(){return new e(this.lang,this.orders.map(e=>({key:ua(e.key),ascending:e.ascending,nullsFirst:e.nullsFirst})),this.source.clone())}getDependencies(){return ao(this.orders.map(jo).filter(sa))}},No=class e extends W{keys;aggs;source;constructor(e,t,n,r){super(),this.keys=t,this.aggs=n,this.source=r,this.lang=e,this.schemaSet=ao(r.schema.concat(n.map(e=>e.fieldName)).concat(t.map(ia))),this.schema=Array.from(this.schemaSet.keys(),e=>z.fromParts(e)),r.parent=this,fo(t.map(ra),this),fo(n,this);for(let e of this.aggs)e.postGroupSource.clearSchema(),e.postGroupSource.addToSchema(this.source.schema.concat(this.keys.map(ia)))}accept(e,t){return e[this.lang].visitGroupBy(this,t)}replaceChild(e,t){let n=t instanceof z;if(n||(t.parent=this),e===this.source){if(n)throw Error(`Cannot replace source with an identifier`);this.source=t}else if(e instanceof go){if(n)throw Error(`Cannot replace aggregate with an identifier`);let r=this.aggs.indexOf(e);this.aggs[r]=t}else this.keys.find(t=>t[0]===e)[0]=t}getChildren(){let e=[this.source];for(let t of this.keys)t[0]instanceof G&&e.push(t[0]);return e.push(...this.aggs),e}clone(){return new e(this.lang,this.keys.map(ua),this.aggs.map(la),this.source.clone())}getDependencies(){return ao(this.keys.map(ra).filter(sa))}},Po=class e extends W{skip;limit;source;constructor(e,t,n,r){super(),this.skip=t,this.limit=n,this.source=r,this.lang=e,this.schema=r.schema,this.schemaSet=r.schemaSet,r.parent=this}accept(e,t){return e[this.lang].visitLimit(this,t)}replaceChild(e,t){t.parent=this,this.source=t}getChildren(){return[this.source]}clone(){return new e(this.lang,this.skip,this.limit,this.source.clone())}},Fo=class extends W{left;right;constructor(e,t,n){if(super(),this.left=t,this.right=n,this.lang=e,t instanceof W!=n instanceof W)throw Error(`Both sides of a set operator must be either tuple or non-tuple operators`);t instanceof W&&(this.schema=t.schema,this.schemaSet=t.schemaSet),t.parent=this,n.parent=this}replaceChild(e,t){t.parent=this,this.left===e?this.left=t:this.right=t}getChildren(){return[this.left,this.right]}},Io=class e extends Fo{accept(e,t){return e[this.lang].visitUnion(this,t)}clone(){return new e(this.lang,this.left.clone(),this.right.clone())}},Lo=class e extends Fo{accept(e,t){return e[this.lang].visitIntersection(this,t)}clone(){return new e(this.lang,this.left.clone(),this.right.clone())}},Ro=class e extends Fo{accept(e,t){return e[this.lang].visitDifference(this,t)}clone(){return new e(this.lang,this.left.clone(),this.right.clone())}},zo=class e extends W{attrs;source;constructor(e,t,n){super(),this.attrs=t,this.source=n,this.lang=e,this.schema=n.schema,this.schemaSet=n.schemaSet,n.parent=this}accept(e,t){return e[this.lang].visitDistinct(this,t)}replaceChild(e,t){let n=t instanceof z;if(n||(t.parent=this),this.source===e){if(n)throw Error(`Cannot replace source with an identifier`);this.source=t}else{let n=this.attrs.indexOf(e);this.attrs[n]=t}}getChildren(){let e=[this.source];return this.attrs!==Qi&&e.push(...this.attrs.filter(oa)),e}clone(){return new e(this.lang,this.attrs===Qi?this.attrs:this.attrs.map(ua),this.source.clone())}getDependencies(){return this.attrs===Qi?new H([[Qi]]):ao(this.attrs.filter(sa))}},Y=class e extends W{constructor(e){super(),this.lang=e,this.schema=[],this.schemaSet=new H}accept(e,t){return e[this.lang].visitNullSource(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(){return new e(this.lang)}},Bo=function(e){return e.ALL=`all`,e.ANY=`any`,e}({}),Vo=class e{lang;type;query;[_o]=!0;constructor(e,t,n){this.lang=e,this.type=t,this.query=n,this.query.parent=this}accept(e,t){return e[this.lang].visitQuantifier(this,t)}replaceChild(e,t){t.parent=this,this.query=t}getChildren(){return[this.query]}clone(t){let n=new e(this.lang,this.type,this.query.clone());for(let e of t??[])for(let t of e.originalLocations){if(t.op===this)t.op=n;else continue;t.obj===this&&(t.obj=n)}return n}getDependencies(){return new H}},Ho=class e extends W{min;max;condition;source;distinctKeys;constructor(e,t,n,r,i,a=[]){super(),this.min=t,this.max=n,this.condition=r,this.source=i,this.distinctKeys=a,this.lang=e,this.schema=i.schema,this.schemaSet=i.schemaSet,r&&(r.parent=this),i.parent=this,fo(this.distinctKeys,this)}accept(e,t){return e[this.lang].visitRecursion(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.distinctKeys.length;n++)if(this.distinctKeys[n]===e){this.distinctKeys[n]=t;return}e===this.condition?this.condition=t:this.source=t}getChildren(){return[this.source,this.condition,...this.distinctKeys.filter(oa)]}clone(){return new e(this.lang,this.min,this.max,this.condition.clone(),this.source.clone(),this.distinctKeys.map(ua))}getDependencies(){return ao(this.distinctKeys.filter(sa))}},Uo=class e extends W{min;max;mapping;source;distinctKeys;constructor(e,t,n,r,i,a=[]){super(),this.min=t,this.max=n,this.mapping=r,this.source=i,this.distinctKeys=a,this.lang=e,this.schema=i.schema,this.schemaSet=i.schemaSet,r.parent=this,i.parent=this,fo(this.distinctKeys,this)}accept(e,t){return e[this.lang].visitIndexedRecursion(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.distinctKeys.length;n++)if(this.distinctKeys[n]===e){this.distinctKeys[n]=t;return}e===this.mapping?this.mapping=t:this.source=t}getChildren(){return[this.source,this.mapping,...this.distinctKeys.filter(oa)]}clone(){return new e(this.lang,this.min,this.max,this.mapping.clone(),this.source.clone(),this.distinctKeys.map(ua))}getDependencies(){return ao(this.distinctKeys.filter(sa))}},X=class e extends W{min;max;mappingFwd;mappingRev;target;source;constructor(e,t,n,r,i,a,o){super(),this.min=t,this.max=n,this.mappingFwd=r,this.mappingRev=i,this.target=a,this.source=o,this.lang=e,this.schema=o.schema.concat(a.schema.filter(e=>!o.schemaSet.has(e.parts))),this.schemaSet=ao(this.schema),r.parent=this,i.parent=this,o.parent=this,a.parent=this}accept(e,t){return e[this.lang].visitBidirectionalRecursion(this,t)}replaceChild(e,t){t.parent=this,e===this.mappingFwd?this.mappingFwd=t:e===this.mappingRev?this.mappingRev=t:e===this.target?this.target=t:this.source=t}getChildren(){return[this.source,this.target,this.mappingFwd,this.mappingRev]}clone(){return new e(this.lang,this.min,this.max,this.mappingFwd.clone(),this.mappingRev.clone(),this.target.clone(),this.source.clone())}},Wo=class{vmap;db;tdepsVmap;constructor(e,t){this.vmap=e,this.db=t,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`)}canRename(e,t){let n=uo(t);return e.accept(this.vmap,{renames:n,renamesInv:t})}checkHorizontal(e,t,n){let r=oo(e.accept(this.tdepsVmap),t);return lo(r,n.renamesInv)||lo(r,n.renames)&&lo(t,n.renamesInv)?!1:e.accept(this.vmap,n)}checkHorizontalArray(e,t,n){for(let r of e)if(!(r instanceof z)&&!this.checkHorizontal(r,t,n))return!1;return!0}checkAttrs(e,t,n){return!e.some(e=>n.renamesInv.has(e[1].parts)&&(!(e[0]instanceof z)||!e[0].equals(e[1])))&&this.checkHorizontalArray(e.map(ra),t,n)}checkVerticalArray(e,t){for(let n of e)if(!(n instanceof z)&&!n.accept(this.vmap,t))return!1;return!0}visitRecursion(e,t){return this.checkHorizontal(e.condition,e.source.schemaSet,t)&&this.checkHorizontalArray(e.distinctKeys,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitProjection(e,t){return this.checkAttrs(e.attrs,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitSelection(e,t){return this.checkHorizontal(e.condition,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitTupleSource(e,t){return!0}visitItemSource(e,t){return!0}visitFnCall(e,t){return this.checkVerticalArray(e.args.map(e=>`op`in e?e.op:e),t)}visitLiteral(e,t){return!0}visitCalculation(e,t){return this.checkVerticalArray(e.args,t)}visitConditional(e,t){return this.checkVerticalArray(e.whenThens.flat(),t)&&this.checkVerticalArray([e.condition,e.defaultCase].filter(e=>!!e),t)}visitCartesianProduct(e,t){return e.left.accept(this.vmap,t)&&e.right.accept(this.vmap,t)}visitJoin(e,t){return this.checkHorizontalArray(e.conditions,U(e.left.schemaSet,e.right.schemaSet),t)&&this.visitCartesianProduct(e,t)}visitProjectionConcat(e,t){return this.checkHorizontal(e.mapping,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitMapToItem(e,t){return e.source.accept(this.vmap,t)}visitMapFromItem(e,t){return!t.renamesInv.has(e.key.parts)&&e.source.accept(this.vmap,t)}visitProjectionIndex(e,t){return!t.renamesInv.has(e.indexCol.parts)&&e.source.accept(this.vmap,t)}visitOrderBy(e,t){return this.checkHorizontalArray(e.orders.map(jo),e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitGroupBy(e,t){return this.checkAttrs(e.keys,e.source.schemaSet,t)&&this.checkHorizontalArray(e.aggs,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitLimit(e,t){return e.source.accept(this.vmap,t)}visitSetOp(e,t){return e.left.accept(this.vmap,t)&&e.right.accept(this.vmap,t)}visitUnion(e,t){return this.visitSetOp(e,t)}visitIntersection(e,t){return this.visitSetOp(e,t)}visitDifference(e,t){return this.visitSetOp(e,t)}visitDistinct(e,t){return Array.isArray(e.attrs)&&!this.checkHorizontalArray(e.attrs,e.source.schemaSet,t)?!1:e.source.accept(this.vmap,t)}visitNullSource(e,t){return!0}visitAggregate(e,t){return!t.renamesInv.has(e.fieldName.parts)&&this.checkVerticalArray(e.args,t)&&e.postGroupOp.accept(this.vmap,t)}visitItemFnSource(e,t){return this.checkVerticalArray(e.args,t)}visitTupleFnSource(e,t){return this.checkVerticalArray(e.args,t)}visitQuantifier(e,t){return e.query.accept(this.vmap,t)}visitIndexScan(e,t){return this.checkHorizontal(e.access,e.schemaSet,t)}visitIndexedRecursion(e,t){return this.checkHorizontal(e.mapping,e.source.schemaSet,t)&&this.checkHorizontalArray(e.distinctKeys,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitBidirectionalRecursion(e,t){return this.checkHorizontal(e.mappingFwd,e.source.schemaSet,t)&&this.checkHorizontal(e.mappingRev,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)&&e.target.accept(this.vmap,t)}},Go=class{vmap;db;tdepsVmap;varMappers;constructor(e,t){this.vmap=e,this.db=t,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.varMappers=this.db.langMgr.getVisitorMap(`variableMapper`)}rename(e,t){let n=this.prepareVarMapCtx(t);e.accept(this.varMappers,n);let r=this.prepareTranslations(n,t);e.accept(this.vmap,r),this.tdepsVmap[e.lang].invalidateCacheUpstream(e)}prepareVarMapCtx(e){let t=new H,n=0;for(let r of e.keys())t.set(r,z.fromParts([n++]));return{scopeStack:[new H,t],currentIndex:n,variableNames:[],translations:new Map,calcIntermediates:!0}}prepareTranslations(e,t){let n=new Map;for(let[r,{scope:i,external:a}]of e.translations.entries()){let e=new H;for(let[t,n]of a.entries())e.set(n.parts,z.fromParts(t));for(let[t,n]of i.entries())e.set(n.parts,z.fromParts(t));let o=0;for(let n of t.keys())e.set([o++],z.fromParts(t.get(n)));n.set(r,e)}return n}renameIdentifier(e,t){let n=t.get(e.parts);if(!n)throw Error(`No translation found for ${e.parts.join(`.`)}`);return e.aggregate&&(n=z.fromParts([...n.parts]),n.aggregate=e.aggregate),n}processArray(e,t,n,r){let i=t.get(n);for(let n=0;n<e.length;n++){let a=e[n];if(a instanceof z){let t=this.renameIdentifier(a,i);r?r(t,n):e[n]=t}else a.accept(this.vmap,t)}}processItem(e,t,n,r){let i=e[t];if(i instanceof z){let a=n.get(r);e[t]=this.renameIdentifier(i,a)}else i.accept(this.vmap,n)}visitRecursion(e,t){e.source.accept(this.vmap,t),this.processArray(e.distinctKeys,t,e),e.condition.accept(this.vmap,t)}visitProjection(e,t){let n=t.get(e);e.source.accept(this.vmap,t),e.renames=new H,e.renamesInv=new H;for(let r of e.attrs)r[1]=this.renameIdentifier(r[1],n),r[0]instanceof z?(r[0]=this.renameIdentifier(r[0],n),e.renames.set(r[0].parts,r[1].parts),e.renamesInv.set(r[1].parts,r[0].parts)):r[0].accept(this.vmap,t)}visitSelection(e,t){e.source.accept(this.vmap,t),e.condition.accept(this.vmap,t)}visitTupleSource(e,t){}visitItemSource(e,t){}visitFnCall(e,t){let n=t.get(e);for(let r=0;r<e.args.length;r++){let i=e.args[r];if(i instanceof z){let t=this.renameIdentifier(i,n);e.args[r]=t}else _o in i.op&&i.op.accept(this.vmap,t)}}visitLiteral(e,t){}visitCalculation(e,t){this.processArray(e.args,t,e),e.original&&e.original.accept(this.vmap,t)}visitConditional(e,t){let n=t.get(e);for(let r of[`condition`,`defaultCase`]){let i=e[r];if(i instanceof z){let t=this.renameIdentifier(i,n);t&&(e[r]=t)}else _o in i&&i.accept(this.vmap,t)}for(let r of e.whenThens)for(let e of[0,1]){let i=r[e];if(i instanceof z){let t=this.renameIdentifier(i,n);t&&(r[e]=t)}else _o in i&&i.accept(this.vmap,t)}}visitCartesianProduct(e,t){e.left.accept(this.vmap,t),e.right.accept(this.vmap,t)}visitJoin(e,t){this.visitCartesianProduct(e,t),this.processArray(e.conditions,t,e)}visitProjectionConcat(e,t){e.source.accept(this.vmap,t),this.processItem(e,`mapping`,t,e)}visitMapToItem(e,t){e.key=t.get(e).get(e.key.parts),e.source.accept(this.vmap,t)}visitMapFromItem(e,t){e.key=t.get(e).get(e.key.parts),e.source.accept(this.vmap,t)}visitProjectionIndex(e,t){e.indexCol=t.get(e).get(e.indexCol.parts),e.source.accept(this.vmap,t)}visitOrderBy(e,t){e.source.accept(this.vmap,t),this.processArray(e.orders.map(jo),t,e,(t,n)=>e.orders[n].key=t)}visitGroupBy(e,t){e.source.accept(this.vmap,t),this.processArray(e.keys.map(ra),t,e,(t,n)=>e.keys[n][0]=t),this.processArray(e.keys.map(ia),t,e,(t,n)=>e.keys[n][1]=t),this.processArray(e.aggs,t,e)}visitLimit(e,t){e.source.accept(this.vmap,t)}visitSetOp(e,t){e.left.accept(this.vmap,t),e.right.accept(this.vmap,t)}visitUnion(e,t){this.visitSetOp(e,t)}visitIntersection(e,t){this.visitSetOp(e,t)}visitDifference(e,t){this.visitSetOp(e,t)}visitDistinct(e,t){Array.isArray(e.attrs)&&this.processArray(e.attrs,t,e),e.source.accept(this.vmap,t)}visitNullSource(e,t){}visitAggregate(e,t){e.postGroupOp.accept(this.vmap,t),e.fieldName=t.get(e).get(e.fieldName.parts),this.processArray(e.args,t,e)}visitItemFnSource(e,t){this.processArray(e.args,t,e)}visitTupleFnSource(e,t){this.processArray(e.args,t,e)}visitQuantifier(e,t){}visitIndexScan(e,t){e.fromItemKey&&=t.get(e).get(e.fromItemKey.parts),e.access.accept(this.vmap,t)}visitIndexedRecursion(e,t){e.source.accept(this.vmap,t),this.processArray(e.distinctKeys,t,e),this.processItem(e,`mapping`,t,e)}visitBidirectionalRecursion(e,t){e.source.accept(this.vmap,t),e.target.accept(this.vmap,t),this.processItem(e,`mappingFwd`,t,e),this.processItem(e,`mappingRev`,t,e)}};function Ko(e,t){let n=0,r=[];for(let i of t)i instanceof z?r.push(e[n++]):r.push(i.impl(...e.slice(n,n+=i.args.length)));return r}function qo(e,t){if(!e||!(e instanceof G)||!e.literal)return!1;let n=e.impl();return!t||typeof t==`string`?typeof n===t:n instanceof t}var Jo=function(e){return e[e.modified=0]=`modified`,e[e.renamed=1]=`renamed`,e[e.unchanged=2]=`unchanged`,e}({});function Z(e,t){let n=!0;for(let r of e)if(t.schemaSet.has(r)){if(!t.renamesInv.has(r))return 0;n&&!Yo(t.renamesInv.get(r),r)&&(n=!1)}return n?2:1}function Yo(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Xo(e,t,n,r,i){let a=[];e instanceof z?a.push(new K(i,[e],ta)):Zo(e,ts,a);for(let e of a){let a=e.accept(n);a=wo(a,r,i),t=new J(i,new G(i,a.impl,a.args,a.argMeta,e,a.aggregates,a.literal),t)}return t}function Zo(e,t,n=[]){return!(e instanceof K)||e.impl!==t.impl?(n.push(e),n):(Zo(e.args[0]instanceof z?new K(e.lang,[e.args[0]],ta):e.args[0].op,t,n),Zo(e.args[1]instanceof z?new K(e.lang,[e.args[1]],ta):e.args[1].op,t,n),n)}function Qo(e=`.`){return function(t,n,r){if(!(r instanceof W))return{data:t};let i=r.schema.map(t=>t.parts.map(e=>e.toString()).join(e)),a=r.schema.map(e=>e.parts.at(-1)===Qi),o=n.getKeys(r);return{schema:i,data:Iterator.from(t).map(e=>{let t={};for(let n=0;n<o.length;n++){let r=e[o[n]];a[n]?Object.assign(t,r):t[i[n]]=r}return t})}}}function $o(e){let t=[];for(let n of e)n instanceof go?t.push(n):n instanceof G?t.push(...n.aggregates):n instanceof z&&n.aggregate&&t.push(n.aggregate);return t.map(la)}function Q(e,t=null){return(...n)=>{for(let e of n)if(e==null)return t;return e(...n)}}var es={name:`or`,impl:(e,t)=>e||t||(e===null?e:t)},ts={name:`and`,impl:(e,t)=>e&&t||(t===!1?t:e)},ns={name:`not`,impl:Q(e=>!e)},rs={name:`neg`,impl:e=>!e};function is(e){return e.literal}function as(e){return e.impl()}function os(e){return e instanceof z?e:e.args}function ss(e){return(e instanceof z?null:e.aggregates)??[]}function cs(e,t,n,r,i){if(e instanceof z)return[{originalLocations:[{obj:t,key:n,op:r,idAsFnArg:i}]}];for(let i of e.argMeta)i.originalLocations.length===0&&i.originalLocations.push(`op`in t[n]?{obj:t[n],key:`op`,op:r}:{obj:t,key:n,op:r});return e.argMeta}function ls(e){return[os(e[0]),os(e[1])]}function us(e){return[ss(e[0]),ss(e[1])]}function ds(e,t,n){return[cs(e[0],t,0,n),cs(e[1],t,1,n)]}function*fs(e){if(e.length===0)return[];for(let t of e[0])if(e.length===1)yield[t];else for(let n of fs(e.slice(1)))yield[t,...n]}function ps(e){return e.op instanceof Vo}function ms(e,t){return e.map(na).filter(n=>!(e[n]instanceof z)&&e[n].op instanceof Vo&&e[n].op.type===t)}var hs=class{vmap;db;constructor(e,t){this.vmap=e,this.db=t,this.processItem=this.processItem.bind(this),this.processFnArg=this.processFnArg.bind(this),this.processWhenThen=this.processWhenThen.bind(this)}toItem(e){let t=e.parent,n=new ko(e.lang,null,e);return t&&t.replaceChild(e,n),n}visitProjection(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitSelection(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitTupleSource(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitItemSource(e){return{args:[e],impl:B,argMeta:[{originalLocations:[]}]}}processItem(e){return e instanceof z?e:e instanceof K&&e.impl===ta?this.processItem(e.args[0]instanceof z?e.args[0]:e.args[0].op):e.accept(this.vmap)}processQuantifiedFn(e,t){return(...n)=>{let r=Ko(n,t),i=ms(e.args,Bo.ANY),a=ms(e.args,Bo.ALL),o=i.map(e=>r[e]),s=a.map(e=>r[e]);anyLoop:for(let t of o.length?fs(o):[[]]){for(let n of s.length?fs(s):[[]]){for(let e=0;e<i.length;e++)r[i[e]]=t[e];for(let e=0;e<a.length;e++)r[a[e]]=n[e];if(!e.impl(...r))continue anyLoop}return!0}return!o.length}}processFnArg(e){if(e instanceof z)return e;let t=e.op.accept(this.vmap);return(e.acceptSequence||ps(e))&&t.impl===B&&(t.impl=ta),t}visitFnCall(e){e.args.forEach((t,n)=>{let r=t.op;r instanceof K&&r.impl===ta&&(e.args[n]=r.args[0])});let t=e.args.map(this.processFnArg);if(e.pure&&t.every(is)){let n=t.map(as),r=e.impl(...n);return{args:[],impl:()=>r,literal:!0,argMeta:[]}}let n=t.map((t,n)=>cs(t,e.args,n,e,!0));for(let t=0;t<n.length;t++)!(e.args[t]instanceof z)&&!(_o in e.args[t].op)&&(n[t][0].acceptSequence=e.args[t].acceptSequence??!1);let r=n.flat();if(e.impl===es.impl)for(let e=n[0].length;e<r.length;e++)r[e].maybeSkipped=!0;return{args:t.flatMap(os),impl:e.args.some(ps)?this.processQuantifiedFn(e,t):(...n)=>{let r=Ko(n,t);return e.impl(...r)},argMeta:r,aggregates:t.flatMap(ss)}}visitLiteral(e){return{args:[],impl:()=>e.value,literal:!0,argMeta:[]}}visitCalculation(e){return{args:[e],impl:ta,argMeta:[{originalLocations:[]}]}}processWhenThen(e){return[this.processItem(e[0]),this.processItem(e[1])]}visitConditional(e){let t=e.whenThens.map(this.processWhenThen),n=e.condition&&this.processItem(e.condition),r=e.defaultCase&&this.processItem(e.defaultCase),i=t.map(ls),a=t.map(us),o=t.map((t,n)=>ds(t,e.whenThens[n],e)).flat(2);r&&(i.push(os(r)),a.push(ss(r)),o.push(...cs(r,e,`defaultCase`,e)));for(let e of o)e&&(e.maybeSkipped=!0);if(n&&(i.unshift(os(n)),a.push(ss(n)),o.unshift(...cs(n,e,`condition`,e))),n?.literal){let e=this.processLiteralConditional(n,t,r);if(e)return e}return{args:i.flat(2),argMeta:o,impl:(...e)=>{let i=0,a=t=>t instanceof z?e[i++]:t.impl(...e.slice(i,i+=t.args.length)),o=!n||a(n),s=t.findIndex(([e,t])=>{let n=a(e)===o;return i+=t instanceof z?1:t.args.length,n});if(s===-1)return r?a(r):null;let c=t[s][1];return i-=c instanceof z?1:c.args.length,a(c)},aggregates:a.flat(2)}}processLiteralConditional(e,t,n){let r=e.impl(),i=!1;for(let[e,n]of t)if(e.literal){if(r===e.impl()){if(n.literal){let e=n.impl();return{args:[],impl:()=>e,literal:!0,argMeta:[]}}i=!0;break}}else{i=!0;break}if(!i&&n&&n.literal){let e=n.impl();return{args:[],impl:()=>e,literal:!0,argMeta:[]}}return null}visitCartesianProduct(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitJoin(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitProjectionConcat(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitMapToItem(e){return{args:[e],impl:B,argMeta:[{originalLocations:[]}]}}visitMapFromItem(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitProjectionIndex(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitOrderBy(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitGroupBy(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitLimit(e){return{args:[e.source instanceof W?this.toItem(e):e],impl:B,argMeta:[{originalLocations:[]}]}}visitUnion(e){return{args:[e.left instanceof W?this.toItem(e):e],impl:B,argMeta:[{originalLocations:[]}]}}visitIntersection(e){return{args:[e.left instanceof W?this.toItem(e):e],impl:B,argMeta:[{originalLocations:[]}]}}visitDifference(e){return{args:[e.left instanceof W?this.toItem(e):e],impl:B,argMeta:[{originalLocations:[]}]}}visitDistinct(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitNullSource(e){return{args:[e],impl:B,argMeta:[{originalLocations:[]}]}}visitAggregate(e){return{args:[e.fieldName],impl:ta,aggregates:[e],argMeta:[{aggregate:e,originalLocations:[]}]}}visitItemFnSource(e){return{args:[e],impl:B,argMeta:[{originalLocations:[]}]}}visitTupleFnSource(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitQuantifier(e){let t=e.query.accept(this.vmap);return t.argMeta[0].acceptSequence=!0,t.argMeta[0].originalLocations=[{obj:e,key:`query`,op:e}],t}visitRecursion(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitIndexScan(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitIndexedRecursion(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}visitBidirectionalRecursion(e){return{args:[this.toItem(e)],impl:B,argMeta:[{originalLocations:[]}]}}},gs=class{vmap;constructor(e){this.vmap=e}maybeRename(e,t){let n=t?.get(e.parts);return n?z.fromParts(n):e}processItem(e,{other:t,ignoreLang:n,renameMap:r}){return e instanceof z&&t instanceof z?e.equals(this.maybeRename(t,r)):e.constructor===t.constructor?!n&&e.lang!==t.lang?!1:e.accept(this.vmap,{other:t,ignoreLang:n,renameMap:r}):!!(e instanceof z&&t instanceof K&&t.impl===ta&&t.args.length===1&&t.args[0]instanceof z&&this.maybeRename(t.args[0],r).equals(e)||t instanceof z&&e instanceof K&&e.impl===ta&&e.args.length===1&&e.args[0]instanceof z&&e.args[0].equals(this.maybeRename(t,r)))}processArray(e,t,n){return e.length===t.length&&e.every((e,r)=>this.processItem(e,{...n,other:t[r]}))}areEqual(e,t,n){let r=n?.ignoreLang??!1,i=n?.renameMap;return this.processItem(e,{other:t,ignoreLang:r,renameMap:i})}visitRecursion(e,t){let n=t.other;return e.min===n.min&&e.max===n.max&&this.processItem(e.condition,{...t,other:n.condition})&&this.processArray(e.distinctKeys,n.distinctKeys,t)&&this.processItem(e.source,{...t,other:n.source})}visitProjection(e,t){let n=t.other;return e.attrs.length===n.attrs.length&&e.attrs.every((e,r)=>{let i=n.attrs[r];return e[1].equals(i[1])&&this.processItem(e[0],{...t,other:i[0]})})&&this.processItem(e.source,{...t,other:n.source})}visitSelection(e,t){let n=t.other;return this.processItem(e.condition,{...t,other:n.condition})&&this.processItem(e.source,{...t,other:n.source})}visitTupleSource(e,t){return this.visitItemSource(e,t)}visitItemSource(e,t){let n=t.other;return Array.isArray(e.name)?Array.isArray(n.name)&&e.name[0].equals(n.name[0])&&e.name[1].equals(n.name[1]):!Array.isArray(n.name)&&e.name.equals(n.name)}visitFnCall(e,t){let n=t.other;return e.impl===n.impl&&e.args.length===n.args.length&&e.args.every((e,r)=>{let i=n.args[r];return this.processItem(`op`in e?e.op:e,{...t,other:`op`in i?i.op:i})})}visitLiteral(e,t){let n=t.other;return ro(e.value,n.value)}visitCalculation(e,t){let n=t.other;return this.processArray(e.args,n.args,t)&&!!e.original==!!n.original&&(e.original?this.processItem(e.original,{...t,other:n.original}):e.impl===n.impl)}visitConditional(e,t){let n=t.other;return this.processArray(e.whenThens.map(ra),n.whenThens.map(ra),t)&&this.processArray(e.whenThens.map(ia),n.whenThens.map(ia),t)&&(e.condition?!!n.condition&&this.processItem(e.condition,{...t,other:n.condition}):!n.condition)&&(e.defaultCase?!!n.defaultCase&&this.processItem(e.defaultCase,{...t,other:n.defaultCase}):!n.defaultCase)}visitCartesianProduct(e,t){let n=t.other;return this.processItem(e.left,{...t,other:n.left})&&this.processItem(e.right,{...t,other:n.right})}visitJoin(e,t){let n=t.other;return e.leftOuter===n.leftOuter&&e.rightOuter===n.rightOuter&&this.processArray(e.conditions,n.conditions,t)&&this.visitCartesianProduct(e,t)}visitProjectionConcat(e,t){let n=t.other;return e.outer===n.outer&&e.emptyVal.size===n.emptyVal.size&&co(e.emptyVal,n.emptyVal)&&this.processItem(e.mapping,{...t,other:n.mapping})&&this.processItem(e.source,{...t,other:n.source})}visitMapToItem(e,t){let n=t.other;return e.key.equals(n.key)&&this.processItem(e.source,{...t,other:n.source})}visitMapFromItem(e,t){let n=t.other;return e.key.equals(n.key)&&this.processItem(e.source,{...t,other:n.source})}visitProjectionIndex(e,t){let n=t.other;return e.indexCol.equals(n.indexCol)&&this.processItem(e.source,{...t,other:n.source})}visitOrderBy(e,t){let n=t.other;return e.orders.length===n.orders.length&&e.orders.every((e,r)=>{let i=n.orders[r];return e.ascending===i.ascending&&e.nullsFirst===i.nullsFirst&&this.processItem(e.key,{...t,other:i.key})})&&this.processItem(e.source,{...t,other:n.source})}visitGroupBy(e,t){let n=t.other;return e.keys.length===n.keys.length&&e.keys.every((e,r)=>{let i=n.keys[r];return e[1].equals(i[1])&&this.processItem(e[0],{...t,other:i[0]})})&&this.processArray(e.aggs,n.aggs,t)&&this.processItem(e.source,{...t,other:n.source})}visitLimit(e,t){let n=t.other;return e.limit===n.limit&&e.skip===n.skip&&this.processItem(e.source,{...t,other:n.source})}visitSetOp(e,t){let n=t.other;return this.processItem(e.left,{...t,other:n.left})&&this.processItem(e.right,{...t,other:n.right})}visitUnion(e,t){return this.visitSetOp(e,t)}visitIntersection(e,t){return this.visitSetOp(e,t)}visitDifference(e,t){return this.visitSetOp(e,t)}visitDistinct(e,t){let n=t.other;for(let[t,r]of[[e,n],[n,e]])if(t.attrs===Qi&&r.attrs!==Qi){let e=r.attrs.filter(sa);if(e.length!==r.attrs.length||e.length!==t.schema.length||!co(t.schemaSet,e))return!1}return e.attrs!==Qi&&!this.processArray(e.attrs,n.attrs,t)?!1:this.processItem(e.source,{...t,other:n.source})}visitNullSource(e,t){return!0}visitAggregate(e,t){let n=t.other;return e.impl===n.impl&&e.fieldName.equals(n.fieldName)&&this.processItem(e.postGroupOp,{...t,other:n.postGroupOp})&&this.processArray(e.args,n.args,t)}visitItemFnSource(e,t){let n=t.other;return e.impl===n.impl&&this.processArray(e.args,n.args,t)}visitTupleFnSource(e,t){let n=t.other;return e.impl===n.impl&&this.processArray(e.args,n.args,t)}visitQuantifier(e,t){let n=t.other;return e.type===n.type&&this.processItem(e.query,{...t,other:n.query})}visitIndexScan(e,t){let n=t.other;return this.visitTupleSource(e,t)&&this.processItem(e.access,{...t,other:n.access})}visitIndexedRecursion(e,t){let n=t.other;return e.min===n.min&&e.max===n.max&&this.processArray(e.distinctKeys,n.distinctKeys,t)&&this.processItem(e.mapping,{...t,other:n.mapping})&&this.processItem(e.source,{...t,other:n.source})}visitBidirectionalRecursion(e,t){let n=t.other;return e.min===n.min&&e.max===n.max&&this.processItem(e.mappingFwd,{...t,other:n.mappingFwd})&&this.processItem(e.mappingRev,{...t,other:n.mappingRev})&&this.processItem(e.source,{...t,other:n.source})&&this.processItem(e.target,{...t,other:n.target})}},$=new WeakMap,_s=class{vmap;constructor(e){this.vmap=e,this.processNode=this.processNode.bind(this)}onlyExternal(e,t){let n=e.clone();for(let e of t.schema)n.delete(e.parts);return n}processNode(e){return e.accept(this.vmap)}getCache(){return $}visitRecursion(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(U(this.visitCalculation(e.condition),...e.distinctKeys.filter(oa).map(this.processNode)??[]),e),e.source.accept(this.vmap));return $.set(e,t),t}visitProjection(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(U(...e.attrs.map(ra).filter(oa).map(this.processNode),e.getDependencies()),e.source),e.source.accept(this.vmap));return $.set(e,t),t}visitSelection(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(this.visitCalculation(e.condition),e),e.source.accept(this.vmap));return $.set(e,t),t}visitTupleSource(e){return e.getDependencies()}visitItemSource(e){return e.getDependencies()}visitFnCall(e){if($.has(e))return $.get(e);let t=U(...e.args.filter(e=>`op`in e).map(e=>this.processNode(e.op)),e.getDependencies());return $.set(e,t),t}visitLiteral(e){return e.getDependencies()}visitCalculation(e){if($.has(e))return $.get(e);let t=U(...e.args.filter(e=>!sa(e)).map(this.processNode),e.getDependencies());return $.set(e,t),t}visitConditional(e){if($.has(e))return $.get(e);let t=U(...e.getChildren().map(this.processNode),e.getDependencies());return $.set(e,t),t}visitCartesianProduct(e){if($.has(e))return $.get(e);let t=U(e.left.accept(this.vmap),e.right.accept(this.vmap));return $.set(e,t),t}visitJoin(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(U(...e.conditions.map(this.processNode)),e),e.left.accept(this.vmap),e.right.accept(this.vmap));return $.set(e,t),t}visitProjectionConcat(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(e.mapping.accept(this.vmap),e),e.source.accept(this.vmap));return $.set(e,t),t}visitMapToItem(e){if($.has(e))return $.get(e);let t=e.source.accept(this.vmap);return $.set(e,t),t}visitMapFromItem(e){if($.has(e))return $.get(e);let t=e.source.accept(this.vmap);return $.set(e,t),t}visitProjectionIndex(e){if($.has(e))return $.get(e);let t=e.source.accept(this.vmap);return $.set(e,t),t}visitOrderBy(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(U(...e.orders.map(jo).filter(oa).map(this.processNode),e.getDependencies()),e),e.source.accept(this.vmap));return $.set(e,t),t}visitGroupBy(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(U(...e.keys.map(ra).filter(oa).map(this.processNode),...e.aggs.map(this.processNode),e.getDependencies()),e),e.source.accept(this.vmap));return $.set(e,t),t}visitLimit(e){return $.has(e)?$.get(e):e.source.accept(this.vmap)}visitSetOp(e){if($.has(e))return $.get(e);let t=U(e.left.accept(this.vmap),e.right.accept(this.vmap));return $.set(e,t),t}visitUnion(e){return this.visitSetOp(e)}visitIntersection(e){return this.visitSetOp(e)}visitDifference(e){return this.visitSetOp(e)}visitDistinct(e){if($.has(e))return $.get(e);let t=U(e.attrs===Qi?e.getDependencies():this.onlyExternal(U(...e.attrs.filter(oa).map(this.processNode),e.getDependencies()),e),e.source.accept(this.vmap));return $.set(e,t),t}visitNullSource(e){return e.getDependencies()}visitAggregate(e){if($.has(e))return $.get(e);let t=U(...e.args.filter(oa).map(this.processNode),e.getDependencies(),e.postGroupOp.accept(this.vmap));return $.set(e,t),t}visitItemFnSource(e){if($.has(e))return $.get(e);let t=U(...e.args.filter(oa).map(this.processNode),e.getDependencies());return $.set(e,t),t}visitTupleFnSource(e){if($.has(e))return $.get(e);let t=U(...e.args.filter(oa).map(this.processNode),e.getDependencies());return $.set(e,t),t}visitQuantifier(e){if($.has(e))return $.get(e);let t=e.query.accept(this.vmap);return $.set(e,t),t}visitIndexScan(e){if($.has(e))return $.get(e);let t=this.onlyExternal(this.visitCalculation(e.access),e);return $.set(e,t),t}visitIndexedRecursion(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(U(e.mapping.accept(this.vmap),...e.distinctKeys.filter(oa).map(this.processNode)??[]),e),e.source.accept(this.vmap));return $.set(e,t),t}visitBidirectionalRecursion(e){if($.has(e))return $.get(e);let t=U(this.onlyExternal(U(e.mappingFwd.accept(this.vmap),e.mappingRev.accept(this.vmap)),e),e.source.accept(this.vmap),e.target.accept(this.vmap));return $.set(e,t),t}clearCache(){$=new WeakMap}invalidateCacheDownstream(e){for(;e;)$.delete(e),e=e.parent}invalidateCacheUpstream(e){$.delete(e);for(let t of e.getChildren())this.invalidateCacheUpstream(t)}invalidateCacheElement(e){$.delete(e)}},vs=class{vmap;constructor(e){this.vmap=e}mapVariables(e){let t={scopeStack:[new H],currentIndex:0,variableNames:[],translations:new Map};return e.accept(this.vmap,t),t}translate(e,t,n=t.scopeStack.length){let r=e.parts[0]===$i,i=Math.max(0,t.scopeStack.length-n),a;for(let n=r?0:t.scopeStack.length-1;n>=i&&(a=t.scopeStack[n].get(e.parts),a===void 0);n--);return a||(a=z.fromParts([t.currentIndex]),t.scopeStack.at(r?0:-1).set(e.parts,a),t.variableNames[t.currentIndex++]=e),e.aggregate&&(a=z.fromParts([...a.parts]),a.aggregate=e.aggregate),a}removeFromCurrScope(e,t){t.scopeStack.at(-1).delete(e.parts)}translateArray(e,t){for(let n=0;n<e.length;n++){let r=e[n];r instanceof z?e[n]=this.translate(r,t):r.accept(this.vmap,t)}}union(e,...t){let n=new H;for(let[t,r]of e.entries())n.set(t,r);for(let e of t)for(let[t,r]of e.entries())n.set(t,r);return n}setTranslations(e,t){t.translations.set(e,{external:this.union(...t.scopeStack),scope:t.scopeStack.at(-1)})}visitRecursion(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),this.translateArray(e.distinctKeys,t),this.visitCalculation(e.condition,t);for(let n of e.schema)this.translate(n,t,0)}visitProjection(e,t){e.source.accept(this.vmap,t);for(let n of e.attrs)n[0]instanceof z?(e.renames.delete(n[0].parts),e.renamesInv.delete(n[1].parts),n[0]=this.translate(n[0],t)):this.visitCalculation(n[0],t);let n=t.scopeStack.pop();t.scopeStack.push(n.clone());for(let n of e.source.schema)e.schemaSet.has(n.parts)||this.removeFromCurrScope(n,t);t.scopeStack.push(new H);for(let n of e.attrs)n[1]=this.translate(n[1],t,n[0]instanceof z&&n[0].equals(n[1])?2:1),n[0]instanceof z&&(e.renames.set(n[0].parts,n[1].parts),e.renamesInv.set(n[1].parts,n[0].parts));let r=t.scopeStack.pop(),i=this.union(t.scopeStack.pop(),r);t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1,t.scopeStack.push(i),this.setTranslations(e,t);let a=t.translations.get(e);a.external=this.union(a.external,n)}visitSelection(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),this.visitCalculation(e.condition,t)}visitTupleSource(e,t){let n=new H;t.scopeStack.push(n),this.setTranslations(e,t);for(let r of e.schema)t.variableNames[t.currentIndex]=r,n.set(r.parts,z.fromParts([t.currentIndex++]))}visitItemSource(e,t){this.setTranslations(e,t)}visitFnCall(e,t){for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof z?e.args[n]=this.translate(r,t):_o in r.op&&r.op.accept(this.vmap,t)}this.setTranslations(e,t)}visitLiteral(e,t){this.setTranslations(e,t)}visitCalculation(e,t){this.setTranslations(e,t),this.translateArray(e.args,t),e.original&&t.calcIntermediates&&e.original.accept(this.vmap,t)}visitConditional(e,t){for(let n of[`condition`,`defaultCase`]){let r=e[n];r&&(r instanceof z?e[n]=this.translate(r,t):_o in r&&r.accept(this.vmap,t))}for(let n of e.whenThens)for(let e of[0,1])n[e]instanceof z?n[e]=this.translate(n[e],t):_o in n[e]&&n[e].accept(this.vmap,t);this.setTranslations(e,t)}visitCartesianProduct(e,t){e.left.accept(this.vmap,t);let n=t.scopeStack.pop();e.right.accept(this.vmap,t);let r=t.scopeStack.pop(),i=this.union(r,n);t.scopeStack.push(i),this.setTranslations(e,t),t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1}visitJoin(e,t){this.visitCartesianProduct(e,t);for(let n of e.conditions)this.visitCalculation(n,t)}visitProjectionConcat(e,t){e.source.accept(this.vmap,t),e.mapping.accept(this.vmap,t);let n=t.scopeStack.pop(),r=t.scopeStack.pop(),i=this.union(n,r);if(e.outer){let n=e.emptyVal;e.emptyVal=new H;for(let[r,i]of n.entries())e.emptyVal.set(t.scopeStack.at(-1).get(r).parts,i)}t.scopeStack.push(i),this.setTranslations(e,t),t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1}visitMapToItem(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),e.key=this.translate(e.key,t),t.currentIndex-=t.scopeStack.pop().size}visitMapFromItem(e,t){e.source.accept(this.vmap,t),t.scopeStack.push(new H),this.setTranslations(e,t),e.key=this.translate(e.key,t,1)}visitProjectionIndex(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),e.indexCol=this.translate(e.indexCol,t,1)}visitOrderBy(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t);for(let n of e.orders)n.key instanceof z?n.key=this.translate(n.key,t):this.visitCalculation(n.key,t)}visitAggregate(e,t){e.postGroupOp.accept(this.vmap,t),this.setTranslations(e,t);for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof z?e.args[n]=this.translate(r,t):this.visitCalculation(r,t)}t.currentIndex-=t.scopeStack.pop().size}visitGroupBy(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t);for(let n of e.keys)n[0]instanceof z?n[0]=this.translate(n[0],t):this.visitCalculation(n[0],t);for(let n of e.keys)n[1]=this.translate(n[1],t,1);for(let n of e.aggs)n.fieldName=this.translate(n.fieldName,t,1);for(let n of e.aggs)this.visitAggregate(n,t)}visitLimit(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t)}visitSetOp(e,t){e.left.accept(this.vmap,t),this.setTranslations(e,t);let n;e.left instanceof W&&e.left.schema&&(n=t.scopeStack.pop(),t.currentIndex-=n.size),e.right.accept(this.vmap,t),e.right instanceof W&&e.right.schema&&(t.currentIndex-=t.scopeStack.pop().size-n.size,t.scopeStack.push(n))}visitUnion(e,t){this.visitSetOp(e,t)}visitIntersection(e,t){this.visitSetOp(e,t)}visitDifference(e,t){this.visitSetOp(e,t)}visitDistinct(e,t){if(e.source.accept(this.vmap,t),this.setTranslations(e,t),e.attrs!==Qi)for(let n=0;n<e.attrs.length;n++){let r=e.attrs[n];r instanceof z?e.attrs[n]=this.translate(r,t):this.visitCalculation(r,t)}}visitNullSource(e,t){t.scopeStack.push(new H),this.setTranslations(e,t)}visitItemFnSource(e,t){this.setTranslations(e,t);for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof z?e.args[n]=this.translate(r,t):this.visitCalculation(r,t)}}visitTupleFnSource(e,t){let n=new H;t.scopeStack.push(n),this.setTranslations(e,t);for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof z?e.args[n]=this.translate(r,t):this.visitCalculation(r,t)}for(let r of e.schema)t.variableNames[t.currentIndex]=r,n.set(r.parts,z.fromParts([t.currentIndex++]))}visitQuantifier(e,t){this.setTranslations(e,t)}visitIndexScan(e,t){this.visitTupleSource(e,t),e.fromItemKey&&=this.translate(e.fromItemKey,t,1),this.visitCalculation(e.access,t)}visitIndexedRecursion(e,t){e.source.accept(this.vmap,t),e.mapping.accept(this.vmap,t),t.currentIndex-=t.scopeStack.pop().size,t.scopeStack.push(new H);for(let n of e.schema)this.translate(n,t,1);this.translateArray(e.distinctKeys,t);let n=t.scopeStack.pop(),r=this.union(t.scopeStack.pop(),n);t.currentIndex=Math.max(...Array.from(r.entries(),e=>e[1].parts[0]))+1,t.scopeStack.push(r),this.setTranslations(e,t)}visitBidirectionalRecursion(e,t){e.source.accept(this.vmap,t),e.target.accept(this.vmap,t);let n=t.scopeStack.pop(),r=t.scopeStack.pop(),i=this.union(r,n);t.scopeStack.push(i),this.setTranslations(e,t),t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1;for(let n of[`mappingFwd`,`mappingRev`])e[n].accept(this.vmap,t),t.currentIndex-=t.scopeStack.pop().size}},ys=class{variableValues=[];variableNames=[];translations=new Map;get(e){return this.variableValues[e.parts[0]]}set(e,t){this.variableValues[e.parts[0]]=t}setTuple(e,t){for(let n of t)this.variableValues[n]=e[n];return e}getKeys(e){let t=this.translations.get(e);return e.schema.map(e=>t.scope.get(e.parts)?.parts[0]??t.external.get(e.parts).parts[0])}getTranslation(e,t){let n=this.translations.get(e);return(n.scope.get(t)??n.external.get(t)).parts[0]}getRenames(e,t){let n=this.translations.get(e),r=this.translations.get(t);return e.schema.map(e=>(r.scope.get(e.parts)??n.scope.get(e.parts)??n.external.get(e.parts)).parts[0])}},bs=n((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),xs=n(((e,t)=>{var n=bs(),r=n.ARRAY_BUFFER_SUPPORT,i=n.SYMBOL_SUPPORT;t.exports=function(e,t){var n,a,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||r&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`)for(o=0,s=e.length;o<s;o++)t(e[o],o);else if(typeof e.forEach==`function`)e.forEach(t);else if(i&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`)for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;else for(a in e)e.hasOwnProperty(a)&&t(e[a],a)}})),Ss=n(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}typeof Symbol<`u`&&(n.prototype[Symbol.iterator]=function(){return this}),n.of=function(){var e=arguments,t=e.length,r=0;return new n(function(){return r>=t?{done:!0}:{done:!1,value:e[r++]}})},n.empty=function(){return new n(function(){return{done:!0}})},n.fromSequence=function(e){var t=0,r=e.length;return new n(function(){return t>=r?{done:!0}:{done:!1,value:e[t++]}})},n.is=function(e){return e instanceof n||typeof e==`object`&&!!e&&typeof e.next==`function`},t.exports=n})),Cs=e(n(((e,t)=>{var n=Ss(),r=xs();function i(){this.clear()}i.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},i.prototype.enqueue=function(e){return this.items.push(e),++this.size},i.prototype.dequeue=function(){if(this.size){var e=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,e}},i.prototype.peek=function(){if(this.size)return this.items[this.offset]},i.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.offset,r=0,i=this.items.length;n<i;n++,r++)e.call(t,this.items[n],r,this)},i.prototype.toArray=function(){return this.items.slice(this.offset)},i.prototype.values=function(){var e=this.items,t=this.offset;return new n(function(){if(t>=e.length)return{done:!0};var n=e[t];return t++,{value:n,done:!1}})},i.prototype.entries=function(){var e=this.items,t=this.offset,r=0;return new n(function(){if(t>=e.length)return{done:!0};var n=e[t];return t++,{value:[r++,n],done:!1}})},typeof Symbol<`u`&&(i.prototype[Symbol.iterator]=i.prototype.values),i.prototype.toString=function(){return this.toArray().join(`,`)},i.prototype.toJSON=function(){return this.toArray()},i.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),i.from=function(e){var t=new i;return r(e,function(e){t.enqueue(e)}),t},i.of=function(){return i.from(arguments)},t.exports=i}))(),1),ws=class{value;next;constructor(e,t=null){this.value=e,this.next=t}};function Ts(e,t,n){let r=[];for(let e of t)r[e]=[];for(;e.next;){for(let n of t)r[n].push(e.value[n]);e=e.next}if(n)for(let t of n)r[t]=e.value[t];for(let n of t)r[n].push(e.value[n]),r[n].reverse();return r}function Es(e,t){return n=>{let r=[];for(let i=0;i<e.length;i++)r[t[i]]=n[e[i]];return r}}var Ds=class{lang;vmap;db;serialize;tdeps={};calcBuilders;eqCheckers;indexCache=new Map;constructor(e,t,n){this.lang=e,this.vmap=t,this.db=n,this.serialize=this.db.langMgr.getLang(this.lang).serialize,this.tdeps=n.langMgr.getVisitorMap(`transitiveDependencies`),this.calcBuilders=n.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=n.langMgr.getVisitorMap(`equalityChecker`)}execute(e,t,n){let r=new ys;if(n){let e=t.scopeStack[0];for(let[t,i]of Object.entries(n)){let n=e.get([$i,t]);if(!n)throw Error(`Bound parameter ${t} not found`);r.set(n,i)}}r.translations=t.translations,r.variableNames=t.variableNames;let i=e.accept(this.vmap,r);return this.indexCache.clear(),{result:i,ctx:r}}processItem(e,t){return e instanceof z?t.get(e):this.visitCalculation(e,t)[0]}renameKeys(e,t,n){let r=[];for(let i=0;i<t.length;i++)r[n[i]]=e[t[i]];return r}*visitRecursion(e,t){if(e.min>e.max||e.max===0)return;let n=new Cs.default,r=[],i=t.getKeys(e),a=t.getKeys(e.source),o=Es(a,t.getRenames(e.source,e)),s=new H,c=e.distinctKeys.length>0;for(let l of e.source.accept(this.vmap,t)){r.push(l);let u=new ws([]);for(let e of a)u.value[e]=l[e];if(e.min<=1||c){let n=t.setTuple(Ts(u,a),a);if(c&&!this.distinctCheck(e.distinctKeys,s,t))continue;e.min<=1&&(yield t.setTuple(o(n),i))}e.max>1&&n.enqueue(u)}let l=1;for(;n.size>0;){l++;let u=n.size;for(let d=0;d<u;d++){let u=n.dequeue();for(let d of r){let r=Ts(u,a);for(let e of a)t.variableValues[e]=[r[e],d[e]];if(this.visitCalculation(e.condition,t)[0]){if(l>=e.min||c){for(let e of a)r[e].push(d[e]);if(t.setTuple(r,a),c&&!this.distinctCheck(e.distinctKeys,s,t))continue;l>=e.min&&(yield t.setTuple(o(r),i))}if(l<e.max){let e=new ws([],u);for(let t of a)e.value[t]=d[t];n.enqueue(e)}}}}}}*visitIndexedRecursion(e,t){if(e.min>e.max||e.max===0)return;let n=new Cs.default,r=t.getKeys(e),i=t.getKeys(e.source),a=t.getRenames(e.source,e.mapping),o=Es(i,t.getRenames(e.source,e)),s=e.distinctKeys.length>0,c=new H;for(let a of e.source.accept(this.vmap,t)){let l=new ws([]);for(let e of i)l.value[e]=a[e];if(e.min<=1||s){let n=t.setTuple(o(Ts(l,i)),r);if(s&&!this.distinctCheck(e.distinctKeys,c,t))continue;e.min<=1&&(yield n)}e.max>1&&n.enqueue(l)}let l=1;for(;n.size>0;){l++;let u=n.size;for(let d=0;d<u;d++){let u=n.dequeue();t.setTuple(Ts(u,i),i);for(let d of e.mapping.accept(this.vmap,t)){if(l>=e.min||s){let n=Ts(u,i);for(let e=0;e<i.length;e++)n[i[e]].push(d[a[e]]);if(n=t.setTuple(o(n),r),s&&!this.distinctCheck(e.distinctKeys,c,t))continue;l>=e.min&&(yield n)}if(l<e.max){let e=new ws([],u);for(let t=0;t<i.length;t++)e.value[i[t]]=d[a[t]];n.enqueue(e)}}}}}*expandBidiFrontier(e,t,n,r,i,a,o,s,c,l,u,d){let f=e.size;for(let p=0;p<f;p++){let f=e.dequeue(),p=Ts(f,c,l);a.setTuple(p,c),a.setTuple(p,l);for(let p of i(a)){let i=new ws(p,f),m=ha(p,c);if(!d||d.has(m)){if(r>=o){let e=t.get(m);e&&(yield*this.joinBidiPaths(u?[i]:e,u?e:[i],a,c,l))}r<=s&&(e.enqueue(i),n.get(m,[]).push(i))}}}}*joinBidiPaths(e,t,n,r,i){let a=r.concat(i);for(let o of e){let e=Ts(o,r,i);for(let t of r)e[t].pop();for(let o of t){for(;o.next;){for(let t of r)e[t].push(o.value[t]);o=o.next}for(let t of r)e[t].push(o.value[t]);for(let t of i)e[t]??=o.value[t];yield n.setTuple(e,a)}}}getBidiKeys(e,t){let n=Array.from(oo(e.schemaSet,e.mappingFwd.schemaSet)).map(n=>t.getTranslation(e,n)),r=e.mappingFwd.schema.map(n=>t.getTranslation(e,n.parts)),i=t.getRenames(e.mappingFwd,e),a=t.getRenames(e.mappingRev,e),o=t.getRenames(e.target,e),s=t.getRenames(e.source,e),c=t.getKeys(e.mappingFwd),l=t.getKeys(e.mappingRev),u=t.getKeys(e.target),d=t.getKeys(e.source);return{keys:r,initialKeys:n,fwdRenamer:Es(c,i),revRenamer:Es(l,a),tgtRenamer:Es(u,o),srcRenamer:Es(d,s)}}getBidiGroups(e,t,n){let r=e.target.accept(this.tdeps),i=Array.from(r).map(n=>t.getTranslation(e,n));if(r.size===0){let r=new Cs.default;for(let i of e.source.accept(this.vmap,t)){let e=new ws(n(i));r.enqueue(e)}return r.size?[r]:[]}let a=new H;for(let r of e.source.accept(this.vmap,t)){let e=new ws(n(r)),t=ha(e.value,i),o=a.get(t);o?o.enqueue(e):(o=Cs.default.of(e),a.set(t,o))}return Array.from(a.entries()).map(([e,t])=>t)}*initBidiFrontiers(e,t,n,r,i,a,o,s,c){let l=n.peek();t.setTuple(l.value,s),t.setTuple(l.value,o);for(let e of n){let t=ha(e.value,o);i.get(t,[]).push(e)}for(let n of e.target.accept(this.vmap,t)){let l=new ws(c(n));r.enqueue(l);let u=ha(l.value,o);a.get(u,[]).push(l);let d=i.get(u);e.min<=1&&d&&(yield*this.joinBidiPaths(d,[l],t,o,s))}}bfsCheckSide(e,t,n,r,i,a,o){let s=new H;for(let t of e){let e=ha(t.value,r);(!o||o.has(e))&&s.add(e)}let c=0;for(;e.size>0;){let l=e.size;c++;for(let u=0;u<l;u++){let l=e.dequeue(),u=Ts(l,r,i);n.setTuple(u,r),n.setTuple(u,i);for(let i of t(n)){let t=new ws(i,l),n=ha(i,r);s.has(n)||o&&!o.has(n)||c<=a&&(e.enqueue(t),s.add(n))}}}return s}bfsCheck(e,t,n,r,i,a,o,s){let c=this.bfsCheckSide(e,n,i,a,o,s);return this.bfsCheckSide(t,r,i,a,o,s,c)}*visitBidirectionalRecursion(e,t){if(e.min>e.max||e.max===0)return;let{keys:n,initialKeys:r,fwdRenamer:i,revRenamer:a,tgtRenamer:o,srcRenamer:s}=this.getBidiKeys(e,t),c=new Cs.default,l=new H,u=new H,d=this.getBidiGroups(e,t,s);for(let s of d){if(yield*this.initBidiFrontiers(e,t,s,c,l,u,n,r,o),e.max===1)return;let d=t=>Iterator.from(e.mappingFwd.accept(this.vmap,t)).map(i),f=t=>Iterator.from(e.mappingRev.accept(this.vmap,t)).map(a),p=null,m=1;for(;(s.size&&(c.size||u.size)||c.size&&(s.size||l.size))&&m<e.max;){if(m>=4&&!p&&(p=this.bfsCheck(Cs.default.from(s),Cs.default.from(c),d,f,t,n,r,e.max),p.size===0))return;s.size>0&&(c.size===0||s.size<=c.size)?(m++,l=new H,yield*this.expandBidiFrontier(s,u,l,m,d,t,e.min,e.max,n,r,!0,p)):c.size>0&&(s.size===0||c.size<=s.size)&&(m++,u=new H,yield*this.expandBidiFrontier(c,l,u,m,f,t,e.min,e.max,n,r,!1,p))}}}*visitProjection(e,t){let n=e.attrs.map(e=>e[1].parts[0]);for(let r of e.source.accept(this.vmap,t)){let r=[];for(let n of e.attrs)r[n[1].parts[0]]=this.processItem(n[0],t);yield t.setTuple(r,n)}}*visitSelection(e,t){for(let n of e.source.accept(this.vmap,t))this.visitCalculation(e.condition,t)[0]&&(yield n)}visitTupleSource(e,t){let n=this.db.getSource(e.name.parts);return this.generateTuplesFromValues(n,e,t)}visitItemSource(e,t){throw Error(`Method not implemented.`)}visitFnCall(e,t){throw Error(`Method not implemented.`)}visitLiteral(e,t){throw Error(`Method not implemented.`)}visitCalculation(e,t){return[e.impl(...e.args.map(e=>e instanceof z?t.get(e):fa(e.accept(this.vmap,t))))]}visitConditional(e,t){throw Error(`Method not implemented.`)}*visitCartesianProduct(e,t){let n=fa(e.right.accept(this.vmap,t));if(n.length===0)return;let r=t.getKeys(e.right),i=e.left.accept(this.vmap,t),a=t.getKeys(e.left),o=t.getKeys(e),s=t.getRenames(e.right,e);for(let c of i)for(let i of this.validateSingleValue(e,n)){let e=[];for(let t of a)e[t]=c[t];for(let t=0;t<r.length;t++)e[s[t]]=i[r[t]];yield t.setTuple(e,o)}}*visitJoin(e,t){!e.leftOuter&&!e.rightOuter?yield*this.visitInnerJoin(e,t):e.leftOuter&&!e.rightOuter?yield*this.visitLeftJoin(e.left,e.right,e,t):!e.leftOuter&&e.rightOuter?yield*this.visitLeftJoin(e.right,e.left,e,t):yield*this.visitFullJoin(e,t)}*visitInnerJoin(e,t){let n=t.getKeys(e.right),r=t.getKeys(e.left),i=t.getRenames(e.right,e),a=t.getKeys(e),[o,s]=this.joinValues(e.left,e.right,e,t);for(let[c,l]of s)yield*this.validateSingleValue(e,Iterator.from(l).map(e=>{let o=[];for(let e of r)o[e]=c[e];for(let t=0;t<n.length;t++)o[i[t]]=e[n[t]];return t.setTuple(o,a)}).filter(()=>o.every(e=>this.visitCalculation(e,t)[0])))}*visitLeftJoin(e,t,n,r){let i=r.getKeys(t),a=r.getKeys(e),o=r.getRenames(t,n),s=r.getKeys(n),[c,l]=this.joinValues(e,t,n,r);for(let[e,t]of l){let l=!1;if(yield*this.validateSingleValue(n,Iterator.from(t).map(t=>{let n=[];for(let t of a)n[t]=e[t];for(let e=0;e<i.length;e++)n[o[e]]=t[i[e]];if(r.setTuple(n,s),c.every(e=>this.visitCalculation(e,r)[0]))return l=!0,n}).filter(e=>e)),!l){let t=[];for(let n of a)t[n]=e[n];for(let e of o)t[e]=null;yield r.setTuple(t,s)}}}*visitFullJoin(e,t){let n=t.getKeys(e.right),r=t.getKeys(e.left),i=t.getRenames(e.right,e),a=t.getKeys(e),[o,s,c]=this.joinValues(e.left,e.right,e,t),l=new Set(c);for(let[c,u]of s){let s=!1;if(yield*this.validateSingleValue(e,Iterator.from(u).map(e=>{let u=[];for(let e of r)u[e]=c[e];for(let t=0;t<n.length;t++)u[i[t]]=e[n[t]];if(t.setTuple(u,a),o.every(e=>this.visitCalculation(e,t)[0]))return s=!0,l.delete(e),u}).filter(e=>e)),!s){let e=[];for(let t of r)e[t]=c[t];for(let t of i)e[t]=null;yield t.setTuple(e,a)}}for(let e of l){let o=[];for(let e of r)o[e]=null;for(let t=0;t<n.length;t++)o[i[t]]=e[n[t]];yield t.setTuple(o,a)}}joinValues(e,t,n,r){let i=this.getBestJoinIndex(e,t,n,r);return i?this.hashJoinValues(e,t,n,r,...i):[n.conditions,...this.nestedLoopJoinValues(e,t,r)]}hashJoinValues(e,t,n,r,i,a,o){let s=new o(i,this.db),c=s.createAccessor(a);c.args.forEach((e,t)=>{e instanceof z&&(c.args[t]=z.fromParts([r.getTranslation(n,e.parts)]))});let l=n.conditions.filter(e=>!a.some(t=>t.containingFn===e.original)),u=Iterator.from(t.accept(this.vmap,r));return s.reindex(u.map(e=>({value:e,keys:i.map(e=>this.visitCalculation(e,r)[0])}))),[l,Iterator.from(e.accept(this.vmap,r)).map(e=>[e,this.visitCalculation(c,r)[0]]),s.allValues()]}getIndexMatchInputs(e,t){return t.conditions.filter(e=>e.original instanceof K).flatMap(e=>e.original.args.map((t,n)=>({expr:t instanceof z?t:t.op,containingFn:e.original,i:n}))).filter(({expr:t})=>t instanceof z?!e.schemaSet.has(t.parts):!lo(e.schemaSet,t.accept(this.tdeps)))}findIndexableExpressions(e,t){return this.db.config.executor?.hashJoinIndices.map(n=>{let r=n.canIndex(e);return r=r?.filter(n=>{let i=e[n].containingFn;for(let n=0;n<i.args.length;n++){if(r.some(t=>e[t].i===n&&e[t].containingFn===i))continue;let a=i.args[n];if(a instanceof z){if(t.schemaSet.has(a.parts))return!1}else if(lo(t.schemaSet,a.op.accept(this.tdeps)))return!1}return!0}),[r??[],n]}).filter(([e])=>e.length>0)}getBestJoinIndex(e,t,n,r){if(this.indexCache.has(n))return this.indexCache.get(n);if(this.db.config.executor?.hashJoinIndices===void 0)return null;let i=this.getIndexMatchInputs(e,n),a=this.findIndexableExpressions(i,t);if(!a?.length)return null;let o=a[0];for(let e=1;e<a.length;e++)a[e][0].length>o[0].length&&(o=a[e]);let s=o[0].map(e=>{let t=i[e].expr;return To(t instanceof z?new K(n.lang,[t],ta):t,this.calcBuilders,this.eqCheckers)});for(let e of s)e.args.forEach((t,i)=>{t instanceof z&&(e.args[i]=z.fromParts([r.getTranslation(n,t.parts)]))});let c=[s,o[0].map(e=>i[e]),o[1]];return this.indexCache.set(n,c),c}nestedLoopJoinValues(e,t,n){let r=fa(t.accept(this.vmap,n));return[Iterator.from(e.accept(this.vmap,n)).map(e=>[e,r]),r]}*visitProjectionConcat(e,t){let n=t.getKeys(e.mapping),r=[];for(let t of n)r[t]=e.emptyVal.get([t],null);let i=e.source.accept(this.vmap,t),a=t.getKeys(e.source),o=t.getKeys(e),s=t.getRenames(e.mapping,e),c=(e,r)=>{let i=[];for(let t of a)i[t]=e[t];for(let e=0;e<n.length;e++)i[s[e]]=r[n[e]];return t.setTuple(i,o)};for(let n of i){let i=e.mapping.accept(this.vmap,t)[Symbol.iterator](),a=i.next();if(a.done)e.outer&&(yield c(n,r));else{if(yield c(n,a.value),a=i.next(),e.validateSingleValue&&!a.done)throw Error(`Mapping returned more than one value`);if(!a.done)do yield c(n,a.value);while(!(a=i.next()).done)}}}validateSingleValue(e,t){if(e.validateSingleValue){let e=t[Symbol.iterator](),n=e.next();if(n.done)return[];let r=n.value;if(!e.next().done)throw Error(`Operator returned more than one value`);return[r]}return t}*visitMapToItem(e,t){let n=e.source.accept(this.vmap,t),r=e.key.parts[0];if(t.translations.get(e).scope.get([Qi])?.parts[0]===r)yield*this.serialize(n,t,e.source).data;else for(let e of n)yield e[r]}*visitMapFromItem(e,t){let n=e.source.accept(this.vmap,t),r=e.key.parts[0];for(let e of n){let n=[];n[r]=t.variableValues[r]=e,yield n}}*visitProjectionIndex(e,t){let n=1,r=t.getKeys(e.source),i=e.indexCol.parts[0];for(let a of e.source.accept(this.vmap,t)){let e=[];for(let t of r)e[t]=a[t];t.variableValues[i]=n,e[i]=n++,yield e}}*visitOrderBy(e,t){let n=[],r=Symbol(`indexCol`),i=[],a=t.getKeys(e),o=0;for(let a of e.source.accept(this.vmap,t)){n.push(a);let s=e.orders.map(e=>this.processItem(e.key,t));s[r]=o++,i.push(s)}i.sort((t,n)=>{for(let r=0;r<e.orders.length;r++){let i=e.orders[r],a=t[r],o=n[r];if(a!==o)return a===null?i.nullsFirst?-1:1:o===null?i.nullsFirst?1:-1:a<o?i.ascending?-1:1:i.ascending?1:-1}return 0});for(let e of i)yield t.setTuple(n[e[r]],a)}*visitGroupBy(e,t){let n=new H,r=t.getKeys(e.source),i=e.aggs.map(n=>Es(r,t.getRenames(e.source,n.postGroupSource))),a=e.aggs.map(e=>t.getKeys(e.postGroupSource)),o=t.getKeys(e),s=e.keys.map(e=>e[1].parts[0]);for(let r of e.source.accept(this.vmap,t)){let i=e.keys.map(e=>this.processItem(e[0],t)),a=n.get(i);a||(a=[],n.set(i,a)),a.push(r)}let c=e.aggs.map(e=>e.postGroupSource.accept),l=this.prepareAggNullChecks(e,t);for(let[c,u]of n.size===0&&e.keys.length===0?[[[],[]]]:n.entries()){let n=[];for(let e=0;e<s.length;e++)n[s[e]]=c[e];if(u.length>0)for(let e of r)n[e]=u[0][e];for(let r=0;r<e.aggs.length;r++){let o=e.aggs[r];o.postGroupSource.accept=()=>Iterator.from(u).map(e=>t.setTuple(i[r](e),a[r]));let s=o.impl.init(),c=!o.impl.includeNulls;for(let e of o.postGroupOp.accept(this.vmap,t)){let e=o.args.map(e=>this.processItem(e,t));c&&e.some(l[r])||(s=o.impl.step(s,...e))}n[o.fieldName.parts[0]]=o.impl.result(s)}yield t.setTuple(n,o)}for(let t=0;t<e.aggs.length;t++)e.aggs[t].postGroupSource.accept=c[t]}prepareAggNullChecks(e,t){let n=e.aggs.map(e=>{let n=[];for(let[r,i]of t.translations.get(e.postGroupSource).scope.entries())n[i.parts[0]]=r.at(-1);return e.args.map(e=>e instanceof z&&n[e.parts[0]]===Qi)});return e.aggs.map((e,t)=>(e,r)=>e==null&&!n[t][r])}*visitLimit(e,t){let n=e.source.accept(this.vmap,t),r=0;if(Array.isArray(n))yield*n.slice(e.skip,e.limit+e.skip);else for(let t of n){if(r++,r>e.limit+e.skip)break;r>e.skip&&(yield t)}}*visitUnion(e,t){if(yield*e.left.accept(this.vmap,t),!(e.right instanceof W)){yield*e.right.accept(this.vmap,t);return}let n=t.getKeys(e),r=t.getKeys(e.right);for(let i of e.right.accept(this.vmap,t))yield t.setTuple(this.renameKeys(i,r,n),n)}*visitIntersection(e,t){if(!(e.left instanceof W)){yield*this.visitIntersectionItems(e.left.accept(this.vmap,t),e.right.accept(this.vmap,t));return}let n=t.getKeys(e.left),r=t.getKeys(e.right),i=e.left.accept(this.vmap,t),a=new H;for(let e of i)a.add(n.map(t=>e[t]));for(let i of e.right.accept(this.vmap,t)){let e=r.map(e=>i[e]);a.has(e)&&(yield t.setTuple(this.renameKeys(i,r,n),n))}}*visitIntersectionItems(e,t){let n=new Set(e);for(let e of t)n.has(e)&&(yield e)}*visitDifference(e,t){if(!(e.left instanceof W)){yield*this.visitDifferenceItems(e.left.accept(this.vmap,t),e.right.accept(this.vmap,t));return}let n=t.getKeys(e.left),r=t.getKeys(e.right),i=e.right.accept(this.vmap,t),a=new H;for(let e of i)a.add(r.map(t=>e[t]));for(let r of e.left.accept(this.vmap,t)){let e=n.map(e=>r[e]);a.has(e)||(yield r)}}*visitDifferenceItems(e,t){let n=new Set(t);for(let t of e)n.has(t)||(yield t)}*distinctStream(e,t,n,r){for(let i of e)this.distinctCheck(t,n,r)&&(yield i)}distinctCheck(e,t,n){let r=e.map(e=>this.processItem(e,n));return!t.has(r)&&(t.add(r),!0)}visitDistinct(e,t){let n=new H,r=e.source.accept(this.vmap,t),i=e.attrs===Qi?t.getKeys(e).map(e=>z.fromParts([e])):e.attrs;return this.distinctStream(r,i,n,t)}visitNullSource(e,t){return[null]}visitAggregate(e,t){throw Error(`Method not implemented.`)}visitItemFnSource(e,t){return e.impl(...e.args.map(e=>this.processItem(e,t)))}visitTupleFnSource(e,t){let n=e.impl(...e.args.map(e=>this.processItem(e,t)));return this.generateTuplesFromValues(n,e,t)}visitQuantifier(e,t){throw Error(`Method not implemented.`)}*visitIndexScan(e,t){let n=this.visitCalculation(e.access,t)[0];if(e.fromItemKey){let r=e.fromItemKey.parts[0];for(let e of n){let n=[];n[r]=t.variableValues[r]=e,yield n}}else yield*this.generateTuplesFromValues(n,e,t)}generateTuplesFromValues(e,t,n){throw Error(`Method not implemented.`)}},Os=Symbol(`toInfer`),ks={logicalPlan:{calculationBuilder:hs,transitiveDependencies:_s,attributeRenamer:Go,attributeRenameChecker:Wo,equalityChecker:gs,variableMapper:vs,executor:null}},As=class e{db;langs={};static allLangs=Symbol(`allLangs`);operators=new H;functions=new H;aggregates=new H;castables=new H;constructor(e){this.db=e}registerExtension(t){let n=t.scope??[e.allLangs],r=[`operators`,`functions`,`aggregates`,`castables`];for(let e of n)for(let n of r)for(let r of t[n]??[])this[n].set([e,r.schema??t.schema,r.name],r)}registerLang(e){this.langs[e.name.toLowerCase()]=e,this.registerExtension({...e,scope:[e.name]})}getLang(e){return this.langs[e.toLowerCase()]}getVisitorMap(e){let t={};for(let n in this.langs)t[n]=new(this.langs[n].visitors[e]??ks.logicalPlan[e])(t,this.db);return t}getOp(e,t,n){return this.getImplementation(`operators`,e,t,n)}getFn(e,t,n){return this.getImplementation(`functions`,e,t,n)}getAggr(e,t,n){return this.getImplementation(`aggregates`,e,t,n)}getCast(e,t,n){return this.getImplementation(`castables`,e,t,n)}getFnOrAggr(e,t,n){let r=this.getImplementation(`functions`,e,t,n,!1)??this.getImplementation(`aggregates`,e,t,n,!1);if(!r)throw Error(`Function or aggregate not found: [${e}] ${n?n.toString():`<default>`}.${t}`);return r}getImplementation(t,n,r,i,a=!0){let o=this[t].get([n,i,r])??this[t].get([n,i,r.toLowerCase()]);if(o??=this[t].get([e.allLangs,i,r])??this[t].get([e.allLangs,i,r.toLowerCase()]),!o&&a)throw Error(`${t.slice(0,-1)} not found: [${n}] ${i?i.toString():`<default>`}.${r}`);return o}},js={name:`count`,init:()=>0,step:e=>e+1,stepInverse:e=>e-1,result:e=>e},Ms={name:`sum`,init:()=>null,step:(e,t)=>e===null?t:e+t,stepInverse:(e,t)=>e-t,result:e=>e},Ns={name:`avg`,init:()=>({sum:0,count:0}),step:(e,t)=>(e.sum+=t,e.count++,e),stepInverse:(e,t)=>(e.sum-=t,e.count--,e),result:e=>e.count===0?null:e.sum/e.count},Ps={name:`min`,init:()=>null,step:(e,t)=>e===null||t<e?t:e,result:e=>e},Fs={name:`max`,init:()=>null,step:(e,t)=>e===null||t>e?t:e,result:e=>e},Is={name:`collect`,init:()=>[],step:(e,t)=>(e.push(t),e),stepInverse:(e,t)=>(e.shift(),e),result:e=>e,includeNulls:!0},Ls=t({avg:()=>Ns,collect:()=>Is,count:()=>js,max:()=>Fs,min:()=>Ps,sum:()=>Ms}),Rs={name:`string`,pure:!0,convert:Q(e=>String(e))},zs={name:`number`,pure:!0,convert(e){let t=+e;return isNaN(t)?null:t}},Bs={name:`boolean`,pure:!0,convert(e){return!!e}},Vs={name:`date`,pure:!0,convert:Q(e=>{let t=new Date(e);return isNaN(t.getTime())?null:t})},Hs={name:`json`,convert:Q(e=>{try{return JSON.parse(e)}catch{return null}})},Us=t({toBool:()=>Bs,toDate:()=>Vs,toJson:()=>Hs,toNumber:()=>zs,toStr:()=>Rs}),Ws={name:`+`,impl:Q((e,t)=>t===void 0?+e:e+t)},Gs={name:`-`,impl:Q((e,t)=>t===void 0?-e:e-t)},Ks={name:`*`,impl:Q((e,t)=>e*t)},qs={name:`/`,impl:Q((e,t)=>e/t)},Js={name:`//`,impl:Q((e,t)=>Math.floor(e/t))},Ys={name:`%`,impl:Q((e,t)=>e%t)},Xs={name:`^`,impl:Q((e,t)=>e**+t)},Zs={name:`=`,impl:Q((e,t)=>e==t)},Qs={name:`!=`,impl:Q((e,t)=>e!=t)},$s={name:`<>`,impl:Qs.impl},ec={name:`>`,impl:Q((e,t)=>e>t)},tc={name:`<`,impl:Q((e,t)=>e<t)},nc={name:`>=`,impl:Q((e,t)=>e>=t)},rc={name:`<=`,impl:Q((e,t)=>e<=t)},ic={name:`is`,impl:(e,t)=>e===t},ac=t({add:()=>Ws,and:()=>ts,divide:()=>qs,eq:()=>Zs,ge:()=>nc,gt:()=>ec,idivide:()=>Js,isOp:()=>ic,le:()=>rc,lt:()=>tc,mod:()=>Ys,multiply:()=>Ks,neg:()=>rs,neq:()=>Qs,neq2:()=>$s,not:()=>ns,or:()=>es,pow:()=>Xs,subtract:()=>Gs}),oc={name:`unwind`,impl:e=>Array.isArray(e)?e:e==null?[]:[e]},sc={name:`substr`,impl:Q((e,t,n)=>n===void 0?e.slice(t):e.slice(t,t+n)),pure:!0},cc={name:`slice`,impl:Q((e,t,n)=>e.slice(t,n)),pure:!0},lc=t({slice:()=>cc,substr:()=>sc,unwind:()=>oc}),uc={operators:Object.values(ac),functions:Object.values(lc),aggregates:Object.values(Ls),castables:Object.values(Us)},dc=class{db;rules;config;constructor(e,t){this.db=t,this.reconfigure(e)}reconfigure(e){this.config=e,this.rules=e.rules.map(e=>typeof e==`function`?new e(this.db):e)}optimize(e){this.breakReferences(e);let t=new Po(`dummy`,0,1,e);for(let e of this.rules)this.visitOperator(t.source,e);let n=t.source;return n.parent=null,n}visitOperator(e,t){if(t.operator===null||e.constructor===t.operator||Array.isArray(t.operator)&&t.operator.includes(e.constructor)){let n=t.match(e);if(n!==null){let r=e.parent,i=t.transform(e,n.bindings);i!==e&&(r.replaceChild(e,i),e=i)}}for(let n of e.getChildren()){if(n.parent!==e)throw console.log(`Parent mismatch (op, child)`,e,n),Error(`Parent mismatch`);this.visitOperator(n,t)}}breakReferences(e){e instanceof W&&e.parent instanceof W&&e.schema===e.parent.schema&&(e.parent.schema=e.schema.slice(),e.parent.schemaSet=e.schemaSet.clone());for(let t of e.getChildren())this.breakReferences(t)}},fc=Symbol(`fromItemIndexKey`),pc=class{config;langMgr=null;registeredSources=new H;optimizer;indices=new H;friendInterface={langMgr:null,optimizer:null,getSource:e=>this.registeredSources.get(e),indices:this.indices,config:null};constructor(e){this.config=e,this.langMgr=this.friendInterface.langMgr=new As(this.friendInterface),this.friendInterface.langMgr=this.langMgr,this.langMgr.registerExtension(uc),this.langMgr.registerLang(e.mainLang),this.config.additionalLangs?.forEach(e=>this.langMgr.registerLang(e)),this.optimizer=new dc(e.optimizer,this.friendInterface),this.friendInterface.optimizer=this.optimizer,this.config.extensions?.forEach(e=>this.langMgr.registerExtension(e)),this.friendInterface.config=e}parse(e,t){return this.langMgr.getLang(t?.mainLang??this.config.mainLang.name).createParser(this.langMgr).parse(e).value}buildPlan(e,t){let n=this.langMgr.getLang(t?.mainLang??this.config.mainLang.name).visitors.logicalPlanBuilder,r=new n(this.friendInterface).buildPlan(e,new H,{});return this.optimizer.optimize(r.plan)}query(e,t){let n=this.parse(e,t),r=this.buildPlan(n.at(-1),t),i=this.executePlan(r,t?.boundParams);return{data:fa(i.data),schema:i.schema}}executePlan(e,t){let n=this.langMgr.getVisitorMap(`variableMapper`),r=this.langMgr.getVisitorMap(`executor`),i=this.langMgr.getVisitorMap(`transitiveDependencies`),a=this.langMgr.getLang(e.lang).serialize;e.accept(i);let o=n[e.lang].mapVariables(e),{result:s,ctx:c}=r[e.lang].execute(e,o,t);return a(s,c,e)}registerSource(e,t){this.registeredSources.set(e,t)}createIndex(e,t,n,r){let i=r?.mainLang??this.config.mainLang.name,a=this.langMgr.getLang(i).createParser(this.langMgr),o=new n(t.map(e=>{let t=a.parseExpr(e),n=this.langMgr.getLang(r?.mainLang??this.config.mainLang.name).visitors.logicalPlanBuilder,o=new n(this.friendInterface).buildPlan(t.value[0],new H(r?.fromItemKey?[r.fromItemKey]:[]),{}),s=this.optimizer.optimize(o.plan),c=s instanceof q?s.attrs[0][0]:s;if(c instanceof G){if(c.getChildren().length)throw Error(`Expression cannot contain subqueries`);return r?.fromItemKey&&this.renameItemIndexExpr(c,r.fromItemKey),c}return Co(r?.fromItemKey?z.fromParts([fc]):c,i)}),this.friendInterface),s=this.indices.get(e);s?s.push(o):this.indices.set(e,[o]),this.fillIndex(o,e,!!r?.fromItemKey)}renameItemIndexExpr(e,t){if(e.getDependencies().size===0)return;if(e.original){let n=this.langMgr.getVisitorMap(`attributeRenamer`),r=new H;r.set(t,[fc]),n[e.lang].rename(e.original,r)}let n=z.fromParts([fc]);e.args=e.args.map(()=>n)}fillIndex(e,t,n=!1){if(e.expressions.length===0)return;let r=e.expressions[0].lang,i=this.langMgr.getVisitorMap(`variableMapper`),a=this.langMgr.getVisitorMap(`executor`),o=e.expressions.map((e,t)=>[e.clone(),z.fromParts([t])]),s=n?z.fromParts([fc]):z.fromParts([Qi]);o.unshift([s,s]);let c=new q(r,o,n?new Ao(r,s,new vo(r,z.fromParts(t))):new po(r,z.fromParts(t)));if(!n){for(let t of e.expressions)c.source.addToSchema(t.getDependencies());c.source.addToSchema(s)}let l=i[r].mapVariables(c),{result:u,ctx:d}=a[r].execute(c,l),[f,...p]=d.getKeys(c);e.reindex(Iterator.from(u).map(e=>({value:e[f],keys:p.map(t=>e[t])})))}},mc=class extends Error{constructor(e){super(e),this.name=`UnsupportedError`}};function hc(e){let t=e.filter(e=>e.containingFn.impl!==es.impl),n=new Set(e.filter(e=>e.containingFn.impl===es.impl).map(e=>e.containingFn));if(!n.size)return{nonOr:e,alternatives:new Map};let r=Array.from(n).map(e=>[e,Zo(e,es)]).filter(([,e])=>e.every(e=>e instanceof K)).map(([e,t])=>[e,t.map(e=>e.args.map(t=>({expr:`op`in t?t.op:t,containingFn:e})))]);return{nonOr:t,alternatives:new Map(r)}}var gc=class{db;calcBuilders;eqCheckers;constructor(e){this.db=e,this.calcBuilders=e.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=e.langMgr.getVisitorMap(`equalityChecker`)}match(e){if(e.parent.constructor===J)return null;let t={selections:e.condition.original instanceof K?[e]:[],source:null,index:null,accessor:null};for(;e.source.constructor===J;)e.source.condition.original instanceof K&&t.selections.push(e.source),e=e.source;if(e.source.constructor!==po&&(e.source.constructor!==Ao||e.source.source.constructor!==vo))return null;t.source=e.source.constructor===po?e.source:e.source.source;let n=this.db.indices.get((Array.isArray(t.source.name)?t.source.name[0]:t.source.name).parts)??[],r=this.getExprCandidates(t.selections),i;e.source instanceof Ao&&(i=new H,i.set(e.source.key.parts,[fc]));for(let e of n){let n=this.matchIndex(e,r,i);if(n)return r=n.candidates,t.selections=t.selections.filter((e,t)=>r.some(e=>e.sIndex===t)),t.index=e,t.accessor=n.accessor,{bindings:t}}return null}matchIndex(e,t,n){let r=e.match(t,n);if(r)return t=t.filter((e,t)=>r.includes(t)),{candidates:t,accessor:e.createAccessor(t)};let{alternatives:i}=hc(t);for(let[r,a]of i){let i=a.map(t=>e.match(t,n));if(!i.every(ta))continue;let o=i.map((t,n)=>e.createAccessor(t.map(e=>a[n][e])));return{accessor:To(new K(o[0].lang,o.map(e=>({op:e.original??e})),function*(...e){let t=new H;for(let n of e)for(let e of n)t.has([e])||(t.add([e]),yield e)}),this.calcBuilders,this.eqCheckers),candidates:t.filter(e=>e.containingFn===r)}}return null}getExprCandidates(e){return e.flatMap((e,t)=>e.condition.original.args.map(n=>({sIndex:t,containingFn:e.condition.original,expr:n instanceof z?n:n.op})))}transform(e,t){let{selections:n,source:r,index:i,accessor:a}=t,o=n[0]===e;for(let e=+!!o;e<n.length;e++){let t=n[e];t.parent.replaceChild(t,t.source)}if(r instanceof po){let t=new ho(r.lang,r.name,i,a);return t.schemaSet=r.schemaSet,t.schema=r.schema,r.parent.replaceChild(r,t),o?e.source:e}let s=new ho(r.lang,r.name,i,a,r.parent.key);return s.addToSchema(r.parent.key),r.parent.parent.replaceChild(r.parent,s),o?e.source:e}operator=J},_c=class{db;operator=Oo;tdepsVmap;renamerVmap;renameCheckerVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.renamerVmap=this.db.langMgr.getVisitorMap(`attributeRenamer`),this.renameCheckerVmap=this.db.langMgr.getVisitorMap(`attributeRenameChecker`)}match(e){for(let t of[`right`,`left`]){if(t===`left`&&e.leftOuter||t===`right`&&e.rightOuter)continue;let n=this.traverseSide(e[t]);if(!n)continue;let r=n.projections.length?this.findValidAttrs(n.projections):e[t].schemaSet,i=this.getExprCandidates(e.conditions,r);if(!i.length)continue;let a=this.db.indices.get((Array.isArray(n.source.name)?n.source.name[0]:n.source.name).parts)??[],o=this.prepareRenameMap(n.projections),s;n.source instanceof vo?(s=o?o.clone():new H,s.set(n.source.parent.key.parts,[fc])):s=o;for(let r of a){let a=this.matchIndex(r,i,e.conditions,s);if(a)return{bindings:{side:t,renameMap:o,indexMatch:a.map(e=>i[e][0]),source:n.source}}}}return null}prepareRenameMap(e){if(!e.length)return null;let t=e[0].renamesInv.clone();for(let n=1;n<e.length;n++)for(let[r,i]of t.entries())t.set(r,e[n].renamesInv.get(i)??i);return t}matchIndex(e,t,n,r){let i=t.map(([e,t])=>{let r=n[e].original;return{containingFn:r,expr:r.args[t]instanceof z?r.args[t]:r.args[t].op}}),a=e.match(i,r);if(a)return a;let{alternatives:o}=hc(i);for(let[t,n]of o)if(n.every(t=>e.match(t,r))){let e=i.findIndex(e=>e.containingFn===t);return[e,e+1]}return a}findValidAttrs(e){let t=e.at(-1).source.schemaSet.clone();for(let n=e.length-1;n>=0;n--)t=new H([...e[n].renames.entries()].filter(([e,n])=>t.has(e)).map(([e,t])=>t));return t}getExprCandidates(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.original instanceof K){let e=i.original.args;for(let i=0;i<e.length;i++)e[i]instanceof z?t.has(e[i].parts)&&n.push([r,i]):n.push([r,i])}}return n}traverseSide(e){let t=[];for(;[q,J,Mo,Ho,Uo].includes(e.constructor);)e.constructor===q&&t.push(e),e=e.source;if(e.constructor===Ao){if(e.source.constructor===vo)return{projections:t,source:e.source}}else if(e.constructor===po)return{projections:t,source:e};return null}transform(e,t){let n=t.side===`left`?`right`:`left`,r=Symbol(`external`),i=new q(e.lang,e[n].schema.map(e=>[e,z.fromParts([r,...e.parts])]),e[n]);for(let t of e.conditions)this.renamerVmap[t.lang].rename(t,i.renames);let a=t.source instanceof po?t.source:t.source.parent;for(let n of new Set(t.indexMatch)){let r=e.conditions[n];t.renameMap&&this.renamerVmap[r.lang].rename(r,t.renameMap),a.parent.replaceChild(a,new J(r.lang,r,a))}for(let n=0;n<e.conditions.length;n++){let r=e.conditions[n];t.indexMatch.includes(n)||e.replaceChild(e[t.side],new J(r.lang,r,e[t.side]))}let o=new xo(e.lang,e[t.side],e[`${t.side===`left`?`right`:`left`}Outer`],i);return new q(e.lang,o.schema.map(e=>e.parts[0]===r?[e,z.fromParts(e.parts.slice(1))]:[e,e]),o)}},vc=class{db;operator=q;tdepsVmap;calcBuilderVmap;eqCheckersVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.calcBuilderVmap=this.db.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckersVmap=this.db.langMgr.getVisitorMap(`equalityChecker`)}match(e){if(e.parent.constructor===q)return null;let t=[e];for(;e.source.constructor===q;)t.push(e.source),e=e.source;return t.length>1?{bindings:t}:null}transform(e,t){let n=e;for(let e=1;e<t.length;e++)n=this.mergeProjections(n,t[e]);return this.tdepsVmap[e.lang].clearCache(),e}mergeProjections(e,t){let n=new H,r=new Map(e.attrs.filter(e=>e[0]instanceof G).map(e=>[e[0],this.getCalcInputDeps(e[0])])),[i,a]=this.canMergeIntoOne(e,t,n,r);if(!i)return t=new q(t.lang,a,t.source),t.parent=e,e.source=t,t;e.source=t.source,t.source.parent=e;for(let t of e.attrs)t[0]=t[0]instanceof G?this.getNewCalc(t[0],n):n.get(t[0].parts)??t[0],t[0]instanceof G&&(t[0].parent=e);return e}calcToFnCall(e,t){return new K(e.lang,t.map((t,n)=>{let r=e.argMeta[n];return r?.aggregate?{op:r.aggregate,acceptSequence:r.acceptSequence}:t instanceof z?t:{op:t,acceptSequence:r.acceptSequence}}),e.impl,e.literal)}getNewCalc(e,t){for(let n=0;n<e.args.length;n++){let r=e.args[n];if(r instanceof z){let i=t.get(r.parts);if(i)for(let t of e.argMeta[n].originalLocations){let{obj:e,key:n,idAsFnArg:r,op:a}=t;i instanceof G?(e[n]=r?{op:i.original}:i.original,i.original.parent=a):e[n]=i}}}return To(e.original,this.calcBuilderVmap,this.eqCheckersVmap)}canMergeIntoOne(e,t,n,r){let i=!0,a=t.attrs.filter(([t,a])=>{let o=0;for(let[s,c]of e.attrs)if(s instanceof G){if(s.original||(i=!1),r.get(s).has(a.parts))return i=!1,!0;if(s.getDependencies().has(a.parts)){let e=s.args.findIndex(e=>e instanceof z&&e.equals(a));if(o+=s.argMeta[e]?.usedMultipleTimes?2:1,t instanceof G&&(t.original||(i=!1),o>1))return i=!1,!0;n.set(a.parts,t)}}else if(s.equals(a)){if(o++,t instanceof G&&(t.original||(i=!1),o>1))return i=!1,!0;n.set(a.parts,t)}return o>0});return[i,a]}getCalcInputDeps(e){return U(...e.args.filter(e=>!sa(e)).map(e=>e.accept(this.tdepsVmap)))}},yc={operator:J,match:function(e){let t={selections:[e],product:null};for(;e.source.constructor===J;)t.selections.push(e.source),e=e.source;if(e.source.constructor===Do)t.product=e.source;else return null;return{bindings:t}},transform:function(e,t){return new Oo(t.product.lang,t.product.left,t.product.right,t.selections.map(e=>e.condition))}},bc=class{db;operator=xo;tdepsVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`)}match(e){return lo(e.mapping.accept(this.tdepsVmap),e.source.schema)?null:{bindings:{}}}transform(e,t){let n;return e.outer?(n=new Oo(e.lang,e.source,e.mapping,[]),n.leftOuter=!0):n=new Do(e.lang,e.source,e.mapping),n.validateSingleValue=e.validateSingleValue,n}},xc=class{db;operator=J;alwaysSwap=[Mo,zo];setOps=[Io,Lo,Ro];tdepsVmap;renamerVmap;renameCheckerVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.renamerVmap=this.db.langMgr.getVisitorMap(`attributeRenamer`),this.renameCheckerVmap=this.db.langMgr.getVisitorMap(`attributeRenameChecker`),this.cloneSelection=this.cloneSelection.bind(this)}match(e){if(e.parent.constructor===J)return null;let t={selections:[e],source:null};for(;e.source.constructor===J;)t.selections.push(e.source),e=e.source;return t.source=e.source,this.alwaysSwap.includes(t.source.constructor)?{bindings:t}:this.setOps.includes(t.source.constructor)&&t.source.schema?this.matchSetOp(t):t.source.constructor===q?this.matchProjection(t):t.source.constructor===Oo||t.source.constructor===Do?this.matchJoins(t):t.source.constructor===xo?this.matchProjectionConcat(t):t.source.constructor===No?this.matchGroupBy(t):null}matchGroupBy(e){let t=e.source,n=ao(t.keys.map(ia));for(let r of e.selections)if(co(n,so(this.getSelectionDeps(r),t.schemaSet)))return{bindings:e};return null}matchJoins(e){let t=e.source;for(let n of e.selections){let r=so(this.getSelectionDeps(n),t.schemaSet);if(!t.rightOuter&&co(t.left.schemaSet,r)||!t.leftOuter&&co(t.right.schemaSet,r))return{bindings:e}}return null}matchProjectionConcat(e){let t=e.source;for(let n of e.selections){let r=so(this.getSelectionDeps(n),t.schemaSet);if(co(t.source.schemaSet,r)||!t.outer&&co(t.mapping.schemaSet,r))return{bindings:e}}return null}matchProjection(e){for(let t of e.selections)if(this.checkProjection(t,e.source))return{bindings:e};return null}matchSetOp(e){let t=e.source;if(t.right.schema.every((e,n)=>e.equals(t.left.schema[n])))return{bindings:e};let n=new H;for(let e=0;e<t.right.schema.length;e++)n.set(t.right.schema[e].parts,t.left.schema[e].parts);for(let t of e.selections)if(this.renameCheckerVmap[t.lang].canRename(t.condition,n))return{bindings:e};return null}getSelectionDeps(e){return this.tdepsVmap[e.lang].visitCalculation(e.condition)}transform(e,t){let{selections:n,source:r}=t,i=n.at(-1),a;a=this.alwaysSwap.includes(r.constructor)?this.transformBasic(r,e,i):this.setOps.includes(r.constructor)?this.tranformSetOp(r,n):r.constructor===q?this.transformProjection(r,n):r.constructor===Do||r.constructor===Oo?this.transformJoin(r,n):r.constructor===xo?this.transformProjectionConcat(r,n):r.constructor===No?this.transformGroupBy(r,n):e;for(let e of n)this.tdepsVmap[e.lang].invalidateCacheElement(e);return this.tdepsVmap[e.lang].invalidateCacheElement(r),a}transformBasic(e,t,n){return n.source=e.source,e.source.parent=n,e.source=t,t.parent=e,e}transformGroupBy(e,t){let n=[],r=[],i=new Set,a=ao(e.keys.map(ia)),o=new H;for(let[t,n]of e.keys)t instanceof z&&!t.equals(n)&&o.set(n.parts,t.parts);for(let s of t){let t=so(this.getSelectionDeps(s),e.schemaSet);co(a,t)?(n.push(s),o.size&&lo(o,t)&&i.add(s)):r.push(s)}for(let e=0;e<r.length-1;e++)r[e].source=r[e+1],r[e+1].parent=r[e];for(let e=0;e<n.length-1;e++){let t=n[e];t.source=n[e+1],n[e+1].parent=t,i.has(t)&&this.renamerVmap[t.lang].rename(t.condition,o)}for(let t of n)t.schema=e.source.schema.slice(),t.schemaSet=e.source.schemaSet.clone();let s=n.at(-1);return s.source=e.source,e.source.parent=s,e.source=n[0],n[0].parent=e,i.has(s)&&this.renamerVmap[s.lang].rename(s.condition,o),r.length?(r.at(-1).source=e,e.parent=r.at(-1),r[0]):e}tranformSetOp(e,t){let n=[],r=[],i=new Set,a=new H;if(e.left.schema.every((t,n)=>t.equals(e.right.schema[n])))n=t;else{for(let t=0;t<e.right.schema.length;t++)a.set(e.right.schema[t].parts,e.left.schema[t].parts);for(let e of t)this.renameCheckerVmap[e.lang].canRename(e.condition,a)?(n.push(e),i.add(e)):r.push(e)}let o=uo(a),s=n.map(this.cloneSelection);for(let e=0;e<r.length-1;e++)r[e].source=r[e+1],r[e+1].parent=r[e];for(let e=0;e<n.length-1;e++){let t=n[e];t.source=n[e+1],n[e+1].parent=t,i.has(t)&&this.renamerVmap[t.lang].rename(t.condition,o),s[e].source=s[e+1],s[e+1].parent=s[e]}for(let t of n)t.schema=e.right.schema.slice(),t.schemaSet=e.right.schemaSet.clone();for(let t of s)t.schema=e.left.schema.slice(),t.schemaSet=e.left.schemaSet.clone();let c=n.at(-1);c.source=e.right,e.right.parent=c,e.right=n[0],n[0].parent=e,i.has(c)&&this.renamerVmap[c.lang].rename(c.condition,o);let l=s.at(-1);return l.source=e.left,e.left.parent=l,e.left=s[0],s[0].parent=e,r.length?(r.at(-1).source=e,e.parent=r.at(-1),r[0]):e}transformProjection(e,t){let n=[],r=[],i=new Set;for(let a of t)this.checkProjection(a,e,i)?n.push(a):r.push(a);for(let e=0;e<r.length-1;e++)r[e].source=r[e+1],r[e+1].parent=r[e];for(let t=0;t<n.length-1;t++){let r=n[t];r.source=n[t+1],n[t+1].parent=r,i.has(r)&&this.renamerVmap[r.lang].rename(r.condition,e.renamesInv)}for(let t of n)t.schema=e.source.schema.slice(),t.schemaSet=e.source.schemaSet.clone();let a=n.at(-1);return a.source=e.source,e.source.parent=a,e.source=n[0],n[0].parent=e,i.has(a)&&this.renamerVmap[a.lang].rename(a.condition,e.renamesInv),r.length?(r.at(-1).source=e,e.parent=r.at(-1),r[0]):e}transformJoin(e,t){let n=[],r=[],i=[];for(let a of t){let t=so(this.getSelectionDeps(a),e.schemaSet),o=!1;!e.rightOuter&&co(e.left.schemaSet,t)&&(n.push(a),o=!0),!e.leftOuter&&co(e.right.schemaSet,t)?o?r.push(this.cloneSelection(a)):r.push(a):o||i.push(a)}for(let e of[n,r,i])for(let t=0;t<e.length-1;t++)e[t].source=e[t+1],e[t+1].parent=e[t];return this.pushSelectionsUnder(n,`left`,e),this.pushSelectionsUnder(r,`right`,e),i.length?(i.at(-1).source=e,e.parent=i.at(-1),i[0]):e}transformProjectionConcat(e,t){let n=[],r=[],i=[];for(let a of t){let t=!1,o=so(this.getSelectionDeps(a),e.schemaSet);!e.outer&&co(e.mapping.schemaSet,o)&&(n.push(a),t=!0),co(e.source.schemaSet,o)?t?r.push(this.cloneSelection(a)):r.push(a):t||i.push(a)}for(let e of[n,r,i])for(let t=0;t<e.length-1;t++)e[t].source=e[t+1],e[t+1].parent=e[t];return this.pushSelectionsUnder(n,`mapping`,e),this.pushSelectionsUnder(r,`source`,e),i.length?(i.at(-1).source=e,e.parent=i.at(-1),i[0]):e}cloneSelection(e){let t=new J(e.lang,e.condition.clone(),e.source);return t.schema=t.schema.slice(),t.schemaSet=t.schemaSet.clone(),t}checkProjection(e,t,n){let r=this.getSelectionDeps(e),i=Z(r,t);return i===Jo.modified?!1:i===Jo.unchanged?!0:this.renameCheckerVmap[e.condition.lang].canRename(e.condition,t.renames)?!lo(oo(r,t.schemaSet),t.renames)&&(n&&n.add(e),!0):!1}pushSelectionsUnder(e,t,n){if(e.length){for(let r of e)r.schema=n[t].schema.slice(),r.schemaSet=n[t].schemaSet.clone();e.at(-1).source=n[t],n[t].parent=e.at(-1),n[t]=e[0],e[0].parent=n}}},Sc={operator:ko,match:e=>e.source.constructor===Ao&&e.key.equals(e.source.key)?{bindings:{}}:null,transform:e=>e.source.source},Cc={operator:Ao,match:e=>e.source.constructor===ko&&e.source.key.parts.at(-1)!==Qi?{bindings:{}}:null,transform:e=>{let t=e.source;return new q(e.lang,[[t.key,e.key]],t.source)}},wc=Symbol(`unnested`),Tc=[class{db;operator=[q,J,No,zo,Mo];tdepsVmap;calcBuilders;eqCheckers;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.calcBuilders=this.db.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=this.db.langMgr.getVisitorMap(`equalityChecker`)}match(e){let t=e.getChildren().map(e=>{if(!(e instanceof G&&e.original))return null;let t=e.args.map((t,n)=>{if(t instanceof z)return null;let r=e.argMeta[n];return!r.acceptSequence&&!r.maybeSkipped?n:null}).filter(ca);return t.length?[e,t]:null}).filter(ca);return t.length?{bindings:{subqueries:t}}:null}transform(e,t){let n=0,r=this.tdepsVmap[e.lang];r.invalidateCacheElement(e);let i=e.schema.map(aa);for(let[i,a]of t.subqueries){r.invalidateCacheElement(i);for(let t of a){let r=z.fromParts([wc,n+++``]),a=i.args[t];this.removeSubq(i,t,r);let o=new xo(e.lang,new Ao(e.lang,r,a),!this.isGuaranteedValue(a),e.source);o.parent=e,e.source=o,o.validateSingleValue=!0,e instanceof q||e.addToSchema(r)}}return r.clearCache(),new q(e.lang,i,e)}removeSubq(e,t,n){if(this.tdepsVmap[e.lang].invalidateCacheUpstream(e.args[t]),e.impl===B)e.parent.replaceChild(e,n);else{e.replaceChild(e.args[t],new K(e.lang,[n],ta));let r=e.original.accept(this.calcBuilders);r=wo(r,this.eqCheckers,e.lang),e.impl=r.impl,e.aggregates=r.aggregates,e.argMeta=r.argMeta,e.literal=r.literal,e.args=r.args}}isGuaranteedValue(e){switch(e.constructor){case ko:case Ao:case q:case So:case Mo:return this.isGuaranteedValue(e.source);case Io:return this.isGuaranteedValue(e.left)||this.isGuaranteedValue(e.right);case Do:return this.isGuaranteedValue(e.left)&&this.isGuaranteedValue(e.right);case xo:return e.outer?this.isGuaranteedValue(e.source):!1;case Oo:{let t=e;if(!t.leftOuter&&!t.rightOuter)return!1;if(t.leftOuter&&t.rightOuter)return!0;let n=t.leftOuter?t.left:t.right;return this.isGuaranteedValue(n)}case Po:return!e.skip&&(e.limit??1/0)>0&&this.isGuaranteedValue(e.source);case Y:return!0;case No:return!e.keys.length||this.isGuaranteedValue(e.source);default:return!1}}},Sc,Cc,xc,bc,yc,_c,gc,vc],Ec=class{fn;distinct;yieldItems;where;procedure=!1;constructor(e,t){this.fn=e,this.distinct=t}accept(e,t){return e.visitFnCallWrapper(this,t)}},Dc=class{query;pattern;where;constructor(e,t,n){this.query=e,this.pattern=t,this.where=n}accept(e,t){return e.visitExistsSubquery(this,t)}},Oc=function(e){return e.ANY=`any`,e.ALL=`all`,e.SINGLE=`single`,e.NONE=`none`,e}({}),kc=class{variable;expr;where;quantifier;constructor(e,t,n,r=null){this.variable=t,this.expr=n,this.where=r,this.quantifier=e.toLowerCase()}accept(e,t){return e.visitQuantifiedExpr(this,t)}},Ac=class{pattern;where;expr;constructor(e,t,n){this.pattern=e,this.where=t,this.expr=n}accept(e,t){return e.visitPatternComprehension(this,t)}},jc=class{variable;source;where;expr;constructor(e,t,n=null,r=null){this.variable=e,this.source=t,this.where=n,this.expr=r}accept(e,t){return e.visitListComprehension(this,t)}},Mc=class{expr;whenThens;elseExpr;constructor(e,t,n){this.expr=e,this.whenThens=t,this.elseExpr=n}accept(e,t){return e.visitCaseExpr(this,t)}},Nc=class{constructor(){}accept(e,t){return e.visitCountAll(this,t)}},Pc=class{expr;labels;constructor(e,t){this.expr=e,this.labels=t}accept(e,t){return e.visitLabelFilterExpr(this,t)}},Fc=class{expr;subscript;constructor(e,t){this.expr=e,this.subscript=t}accept(e,t){return e.visitSubscriptExpr(this,t)}},Ic=class{expr;prop;constructor(e,t){this.expr=e,this.prop=t}accept(e,t){return e.visitPropLookup(this,t)}};function Lc(e){let t=``,n=/^([bfnrt\\'"]|x[0-9a-f]{2}|u[0-9a-f]{4}|u[0-9a-f]{8}|[0-7]{1,3})/i;for(let r=1;r<e.length-1;r++){let i=e[r],a;i===`\\`&&(a=e.slice(r+1).match(n))?(r+=a[0].length,t+=Rc(a[0])):t+=i}return t}function Rc(e){let t;switch(e=e.toLowerCase(),e[0]){case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
|
|
314
|
+
`;case`r`:return`\r`;case`t`:return` `;case`\\`:return`\\`;case`x`:return t=parseInt(e.slice(1),16),String.fromCharCode(t);case`u`:return t=parseInt(e.slice(1),16),String.fromCodePoint(t);default:return t=parseInt(e,8),isNaN(t)?e:String.fromCharCode(t)}}var zc=class extends z{idOriginal;constructor(e){super(),this.idOriginal=e;let t=this.splitId(e);this.parts=t.map(e=>this.parseId(e))}accept(e,t){return e.visitCypherIdentifier(this,t)}parseId(e){return e.startsWith("`")&&e.endsWith("`")?e.replaceAll("`",``):e}splitId(e){if(e[0]!=="`"){let t=e.indexOf(`.`);return t===-1?[e]:[e.slice(0,t),...this.splitId(e.slice(t+1))]}for(let t=1;t<e.length-1;t++)if(e[t]==="`"){if(e[t+1]==="`")t++;else return[e.slice(0,t),...this.splitId(e.slice(t+2))]}return[e]}},Bc=class extends Yi{constructor(e){super(e,null),this.value=Lc(e)}accept(e,t){return e.visitStringLiteral(this,t)}},Vc=class extends Yi{constructor(e){super(e,+e)}accept(e,t){return e.visitNumberLiteral(this,t)}},Hc=class{items;constructor(e){this.items=e}accept(e,t){return e.visitListLiteral(this,t)}},Uc=class{items;constructor(e){this.items=e}accept(e,t){return e.visitMapLiteral(this,t)}},Wc=class extends Yi{constructor(e){super(e,null),this.value=this.parse(e)}accept(e,t){return e.visitBooleanLiteral(this,t)}parse(e){let t=e.toLowerCase();return t===`true`||t!==`false`&&null}},Gc=class{chain;variable=null;constructor(e){this.chain=Array.isArray(e)?e:[e]}accept(e,t){return e.visitPatternElChain(this,t)}},Kc=class{variable;labels;props;constructor(e,t=[],n=null){this.variable=e,this.labels=t,this.props=n}accept(e,t){return e.visitNodePattern(this,t)}},qc=class{pointsLeft;pointsRight;variable;types;range;props;constructor(e=!1,t=!1,n=null,r=[],i=null,a=null){this.pointsLeft=e,this.pointsRight=t,this.variable=n,this.types=r,this.range=i,this.props=a}accept(e,t){return e.visitRelPattern(this,t)}},Jc=function(e){return e.UNION=`union`,e.UNIONALL=`unionall`,e}({}),Yc=class{type;next;constructor(e,t){this.type=e,this.next=t}accept(e,t){return e.visitSetOp(this,t)}},Xc=class{statements;setOp;from;constructor(e){this.statements=e}accept(e,t){return e.visitQuery(this,t)}},Zc=class{pattern;where;optional=!1;constructor(e,t){this.pattern=e,this.where=t}accept(e,t){return e.visitMatchClause(this,t)}},Qc=class{expr;variable;constructor(e,t){this.expr=e,this.variable=t}accept(e,t){return e.visitUnwindClause(this,t)}},$c=class{pattern;constructor(e){this.pattern=e}accept(e,t){return e.visitCreateClause(this,t)}},el=class{pattern;onCreate=[];onMatch=[];constructor(e,t){this.pattern=e;for(let e of t)e.trigger===`create`?this.onCreate.push(...e.set.items):this.onMatch.push(...e.set.items)}accept(e,t){return e.visitMergeClause(this,t)}},tl=class{trigger;set;constructor(e,t){this.trigger=e,this.set=t}},nl=class{items;constructor(e){this.items=e}accept(e,t){return e.visitSetClause(this,t)}},rl=class{key;value;add=!1;constructor(e,t){this.key=e,this.value=t}accept(e,t){return e.visitSetItem(this,t)}},il=class{items;constructor(e){this.items=e}accept(e,t){return e.visitRemoveClause(this,t)}},al=class{key;labels;constructor(e,t){this.key=e,this.labels=t}accept(e,t){return e.visitRemoveItem(this,t)}},ol=class{exprs;detach;constructor(e,t=!1){this.exprs=e,this.detach=t}accept(e,t){return e.visitDeleteClause(this,t)}},sl=class{items;order;skip;limit;distinct;constructor(e,t=null,n=null,r=null,i=!1){this.items=e,this.order=t,this.skip=n,this.limit=r,this.distinct=i}accept(e,t){return e.visitProjectionBody(this,t)}},cl=class{expr;ascending;constructor(e,t=!0){this.expr=e,this.ascending=t}accept(e,t){return e.visitOrderItem(this,t)}},ll=class{body;constructor(e){this.body=e}accept(e,t){return e.visitReturnClause(this,t)}},ul=class{body;where;constructor(e,t){this.body=e,this.where=t}accept(e,t){return e.visitWithClause(this,t)}},dl=t({ASTBooleanLiteral:()=>Wc,ASTListLiteral:()=>Hc,ASTMapLiteral:()=>Uc,ASTNumberLiteral:()=>Vc,ASTStringLiteral:()=>Bc,CaseExpr:()=>Mc,CountAll:()=>Nc,CreateClause:()=>$c,CypherIdentifier:()=>zc,DeleteClause:()=>ol,ExistsSubquery:()=>Dc,FnCallWrapper:()=>Ec,LabelFilterExpr:()=>Pc,ListComprehension:()=>jc,MatchClause:()=>Zc,MergeAction:()=>tl,MergeClause:()=>el,NodePattern:()=>Kc,OrderItem:()=>cl,PatternComprehension:()=>Ac,PatternElChain:()=>Gc,ProjectionBody:()=>sl,PropLookup:()=>Ic,QuantifiedExpr:()=>kc,Quantifier:()=>Oc,Query:()=>Xc,RelPattern:()=>qc,RemoveClause:()=>il,RemoveItem:()=>al,ReturnClause:()=>ll,SetClause:()=>nl,SetItem:()=>rl,SetOp:()=>Yc,SetOpType:()=>Jc,SubscriptExpr:()=>Fc,UnwindClause:()=>Qc,WithClause:()=>ul}),fl=class{uniqueId=0;constructor(){this.processNode=this.processNode.bind(this),this.visitSchemaPart=this.visitSchemaPart.bind(this),this.processAttr=this.processAttr.bind(this),this.processNodeOrAttr=this.processNodeOrAttr.bind(this)}processNode(e){return e.accept(this)}processNodeOrAttr(e){return e===`*`?e:e instanceof Array?this.processAttr(e):this.processNode(e)}processAttr(e){return`${e[0].accept(this)} AS ${e[1].accept(this)}`}visitSchemaPart(e){return typeof e==`symbol`||typeof e==`number`?e===Qi?`*`:e.toString():this.addQuotes(e,"`")}visitIdentifier(e){return e.parts.map(this.visitSchemaPart).join(`.`)}visitCypherIdentifier(e){return this.visitIdentifier(e)}addQuotes(e,t){return t+e.replaceAll(t,t+t)+t}visitStringLiteral(e){return this.addQuotes(e.value,`'`)}visitNumberLiteral(e){return e.value.toString()}visitListLiteral(e){return`[${e.items.map(this.processNode)}]`}visitMapLiteral(e){return`{${e.items.map(([e,t])=>`${t.accept(this)}: ${e.accept(this)}`)}}`}visitBooleanLiteral(e){return e?.toString()??`null`}visitFnCallWrapper(e){let t=e.fn.id.accept(this)+`(`;return e.distinct&&(t+=`DISTINCT `),t+=e.fn.args.map(this.processNode),t+=`)`,e.yieldItems&&(t+=`YIELD `,e.yieldItems===`*`?t+=`*`:t+=e.yieldItems.map(this.processNodeOrAttr)),e.where&&(t+=` WHERE `+e.where.accept(this)),t}visitExistsSubquery(e){return`EXISTS {${e.query.accept(this)}}`}visitQuantifiedExpr(e){let t=`${e.quantifier} (${e.variable.accept(this)} IN ${e.expr.accept(this)}`;return e.where&&(t+=` WHERE `+e.where.accept(this)),t+`)`}visitPatternElChain(e){let t=e.chain.map(this.processNode).join(``);return e.variable&&(t=e.variable.accept(this)+`=`+t),t}visitNodePattern(e){let t=`(`;return e.variable&&(t+=e.variable.accept(this)),e.labels.length&&(t+=`:`+e.labels.map(this.processNode).join(`:`)),e.props&&(t+=` `+e.props.accept(this)),t+`)`}visitRange(e){let[t,n]=e,r=t?t.accept(this):``;return e.length===2?r+`..`+(n?n.accept(this):``):r}visitRelPattern(e){let t=`-[`;return e.pointsLeft&&(t=`<`+t),e.variable&&(t+=e.variable.accept(this)),e.types.length&&(t+=`:`+e.types.map(this.processNode).join(`:`)),e.range&&(t+=`*`+this.visitRange(e.range)),t+=e.range.map(e=>e?this.processNode(e):``).join(`..`),e.props&&(t+=` `+e.props.accept(this)),t+(e.pointsRight?`]->`:`]-`)}visitPatternComprehension(e){let t=`[`+e.pattern.accept(this);return e.where&&(t+=` WHERE `+e.where.accept(this)),t+=` | `+e.expr.accept(this)+`]`,t}visitListComprehension(e){let t=`[`+e.expr.accept(this)+` IN `+e.source.accept(this);return e.where&&(t+=` WHERE `+e.where.accept(this)),e.expr&&(t+=` | `+e.expr.accept(this)),t+`]`}visitCaseExpr(e){return`CASE ${e.expr?.accept(this)??``} ${e.whenThens.map(([e,t])=>`WHEN ${e.accept(this)} THEN ${t.accept(this)}`).join(` `)} ${e.elseExpr?` ELSE `+e.elseExpr.accept(this):``} END`}visitCountAll(e){return`COUNT(*)`}visitLabelFilterExpr(e){return`${e.expr.accept(this)}:${e.labels.map(this.processNode).join(`:`)}`}visitSubscriptExpr(e){return e.expr.accept(this)+`[`+this.visitRange(e.subscript)+`]`}visitPropLookup(e){return e.expr.accept(this)+`.`+e.prop.accept(this)}visitSetOp(e){return e.type+` `+e.next.accept(this)}visitQuery(e){let t=e.from?`FROM `+e.from.accept(this):``;for(let n of e.statements)t+=` `+n.accept(this);return e.setOp&&(t+=` `+e.setOp.accept(this)),t}visitMatchClause(e){let t=`MATCH `+e.pattern.map(this.processNode);return e.where&&(t+=` WHERE `+e.where.accept(this)),e.optional&&(t=`OPTIONAL `+t),t}visitUnwindClause(e){return`UNWIND ${e.expr.accept(this)} AS ${e.variable.accept(this)}`}visitCreateClause(e){return`CREATE ${e.pattern.map(this.processNode)}`}visitMergeClause(e){let t=`MERGE `+this.visitPatternElChain(e.pattern);return e.onMatch&&(t+=` ON MATCH SET `+e.onMatch.map(this.processNode)),e.onCreate&&(t+=` ON CREATE SET `+e.onCreate.map(this.processNode)),t}visitSetClause(e){return`SET `+e.items.map(this.processNode)}visitSetItem(e){let t=e.key.accept(this);return Array.isArray(e.value)?t+`:`+e.value.map(this.processNode).join(`:`):(t+=e.add?`+=`:`=`,t+e.value.accept(this))}visitRemoveClause(e){return`REMOVE `+e.items.map(this.processNode)}visitRemoveItem(e){let t=e.key.accept(this);return e.labels?.length&&(t+=`:`+e.labels.map(this.processNode).join(`:`)),t}visitDeleteClause(e){let t=`DELETE `+e.exprs.map(this.processNode);return e.detach?` DETACH `+t:t}visitProjectionBody(e){let t=e.items.map(e=>e===`*`?`*`:this.processNodeOrAttr(e)).join(`,`);return e.distinct&&(t=`DISTINCT `+t),e.order&&(t+=` ORDER BY `+e.order.map(this.processNode)),e.skip&&(t+=` SKIP `+e.skip.accept(this)),e.limit&&(t+=` LIMIT `+e.limit.accept(this)),t}visitOrderItem(e){return e.expr.accept(this)+(e.ascending?``:` DESC`)}visitWithClause(e){let t=`WITH ${this.visitProjectionBody(e.body)}`;return e.where?t+` WHERE `+e.where.accept(this):t}visitReturnClause(e){return`RETURN `+this.visitProjectionBody(e.body)}visitLiteral(e){throw Error(`Method not implemented.`)}visitOperator(e){return`${e.id.accept(this)}(${e.operands.map(this.processNode)})`}visitFunction(e){throw Error(`Method not implemented.`)}visitLangSwitch(e){return`lang_${e.lang}_${this.uniqueId++}`}};function pl(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function ml(e,t,n){return typeof n==`function`?hl(e,t,function e(t,r,i,a,o,s){let c=n(t,r,i,a,o,s);return c===void 0?hl(t,r,e,s,!1):!!c},new Map,!0):ml(e,t,()=>void 0)}function hl(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case`object`:return gl(e,t,n,r,i);case`function`:return Object.keys(t).length>0?hl(e,{...t},n,r,i):$a(e,t);default:return pl(e)&&i?typeof t!=`string`||t===``:$a(e,t)}}function gl(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return vl(e,t,n,r);if(t instanceof Map)return _l(e,t,n,r);if(t instanceof Set)return yl(e,t,n,r);let a=Object.keys(t);if(e==null)return i&&a.length===0;if(i)va(e)&&(e=Object(e));else{let t=Sa(e);if(t!==`[object Object]`&&t!==`[object Arguments]`)return!1}if(a.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let i=0;i<a.length;i++){let o=a[i];if(!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!n(e[o],t[o],o,e,t,r))return!1}return!0}finally{r?.delete(t)}}function _l(e,t,n,r){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[i,a]of t.entries())if(n(e.get(i),a,i,e,t,r)===!1)return!1;return!0}function vl(e,t,n,r){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let i=new Set;for(let a=0;a<t.length;a++){let o=t[a],s=!1;for(let c=0;c<e.length;c++){if(i.has(c))continue;let l=e[c],u=!1;if(n(l,o,a,e,t,r)&&(u=!0),u){i.add(c),s=!0;break}}if(!s)return!1}return!0}function yl(e,t,n,r){return t.size===0||e instanceof Set&&vl([...e],[...t],n,r)}function bl(e,t){return ml(e,t,()=>void 0)}function xl(e){return[e.parts.at(-1),e.parts.at(-2)]}function Sl(e){return z.fromParts([e])}function Cl(e,t){return e.parts[0]!==$i&&!t.ctx.has(e.parts)&&e.parts.length>1&&t.ctx.has([e.parts[0],Os])&&t.inferred.add(e.parts),e}function wl(){}function Tl(e){return e.parts[0]}var El=class{db;calcBuilders;eqCheckers;stringifier=new fl;dataAdapter;langCtx;constructor(e){this.db=e,this.calcBuilders=e.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=e.langMgr.getVisitorMap(`equalityChecker`);let t=e.langMgr.getLang(`cypher`);this.dataAdapter=t.dataAdapter}maybeId(e,t){if(!(e instanceof Ic))return e;let n=[e.prop.parts[0]],r=e.expr;for(;r instanceof Ic;)n.push(r.prop.parts[0]),r=r.expr;return r instanceof z&&r.parts[0]!==$i&&!t.ctx.has(r.parts)?(n.push(r.parts[0]),n.reverse(),z.fromParts(n)):e}toCalc(e,t){if(e=this.maybeId(e,t),e instanceof z)return Cl(e,t);let n=e.accept(this,t);return n instanceof go?n.fieldName:To(n,this.calcBuilders,this.eqCheckers)}processFnArg(e,t){return e=this.maybeId(e,t),e instanceof z?Cl(e,t):{op:e.accept(this,t)}}processAttr(e,t){if(Array.isArray(e)?e[0]=this.maybeId(e[0],t):e=this.maybeId(e,t),e instanceof z)return[Cl(e,t),e];if(Array.isArray(e))return[this.toCalc(e[0],t),e[1]];let n=Sl(e.accept(this.stringifier));return[this.toCalc(e,t),n]}processNode(e,t){return e=this.maybeId(e,t),e instanceof z?Cl(e,t):e.accept(this,t)}buildPlan(e,t,n){this.langCtx=n;let r=new H,i=e.accept(this,{ctx:t,inferred:r,graphName:this.db.langMgr.getLang(`cypher`).defaultGraph});return e instanceof ea&&i instanceof ko&&i.lang===`cypher`&&(i=i.source),{plan:i,inferred:r}}visitCypherIdentifier(e,t){return this.visitIdentifier(e,t)}visitStringLiteral(e){return new bo(`cypher`,e.value)}visitNumberLiteral(e){return new bo(`cypher`,e.value)}visitListLiteral(e,t){return new K(`cypher`,e.items.map(e=>this.processFnArg(e,t)),Array.of)}visitMapLiteral(e,t){let n=e.items.map(e=>e[1].parts[0]),r=e.items.map(e=>this.processFnArg(e[0],t));return r.unshift({op:new bo(`cypher`,n)}),new K(`cypher`,r,ma)}visitBooleanLiteral(e){return new bo(`cypher`,e.value)}visitFnCallWrapper(e,t){if(e.procedure)return this.visitProcedure(e,t);let[n,r]=xl(e.fn.id),i;try{i=this.db.langMgr.getFnOrAggr(`cypher`,n,r)}catch(e){let t=this.db.langMgr.getCast(`cypher`,n,r);if(t)i={name:t.name,impl:t.convert,pure:t.pure};else throw e}if(`init`in i){let n=new go(`cypher`,e.fn.args.map(e=>this.toCalc(e,t)),i,z.fromParts([this.stringifier.visitFnCallWrapper(e)]));return e.distinct&&(n.postGroupOp=new zo(`cypher`,n.args,n.postGroupOp)),n}let a=e.fn.args.map(e=>this.processFnArg(e,t));if(i.addAdapterCtx){let e=this.db.getSource(t.graphName.parts);a.unshift({op:new bo(`cypher`,{adapter:this.dataAdapter,graph:e})})}return new K(`cypher`,a,i.impl,i.pure)}visitProcedure(e,t){let[n,r]=xl(e.fn.id),i=this.db.langMgr.getFn(`cypher`,n,r),a=e.fn.args.map(e=>this.toCalc(e,t));if(i.addAdapterCtx){let e=this.db.getSource(t.graphName.parts),n={adapter:this.dataAdapter,graph:e};a.unshift(new G(`cypher`,()=>n,[],[],new bo(`cypher`,n)))}let o=new mo(`cypher`,a,i.impl,e.fn.id);return i.outputSchema&&o.addToSchema(i.outputSchema),e.yieldItems&&e.yieldItems!==`*`&&(o=new q(`cypher`,e.yieldItems.map(e=>this.processAttr(e,t)),o)),e.where&&(o=Xo(this.processNode(e.where,t),o,this.calcBuilders,this.eqCheckers,`cypher`)),o}visitExistsSubquery(e,t){let n;e.query?(n=e.query.accept(this,t),n instanceof W||(n=new Ao(`cypher`,Sl(`exists`),n))):n=this.visitMatchClause(e,t),n=new Po(`cypher`,0,1,n);let r=Sl(`count`);return n=new No(`cypher`,[],[new go(`cypher`,[Sl(Qi)],this.db.langMgr.getAggr(`cypher`,`count`),r)],n),n=new ko(`cypher`,r,n),new K(`cypher`,[{op:n}],e=>e>0)}visitQuantifiedExpr(e,t){let n=new Ao(`cypher`,e.variable,new yo(`cypher`,[this.toCalc(e.expr,t)],oc.impl,Sl(`unwind`))),r=e.quantifier===Oc.ALL,i=e.quantifier===Oc.ANY,a=this.toCalc(e.where??e.variable,t);if(r){if(a instanceof z)a=new G(`cypher`,e=>!e,[a],[void 0]);else{let e=a.impl;a.impl=(...t)=>!e(...t)}}return n=new J(`cypher`,a,n),e.quantifier===Oc.SINGLE?(n=new No(`cypher`,[],[new go(`cypher`,[e.variable],this.db.langMgr.getAggr(`cypher`,`count`),e.variable)],n),new K(`cypher`,[{op:new ko(`cypher`,e.variable,n)}],e=>e===1)):(n=new Po(`cypher`,0,1,n),n=new q(`cypher`,[[new G(`cypher`,()=>i,[],[]),e.variable]],n),new K(`cypher`,[{op:n}],t=>t===null?e.quantifier===Oc.ALL||e.quantifier===Oc.NONE:t))}preparePatternRefs(e,t,n,r){if(e.length){let i=r.src??new q(`cypher`,e.map(aa),new Y(`cypher`));for(let a=0,o=0;a<t.length;a++)n[a]&&(i=this.patternToSelection(i,e[o++],t[a],r));return i}return r.src}patternToSelection(e,t,n,r){if(!n.props)return e;if(n.props instanceof z)return new J(`cypher`,To(new K(`cypher`,[t,this.processFnArg(n.props,r)],bl),this.calcBuilders,this.eqCheckers),e);for(let i of n.props.items)e=new J(`cypher`,To(new K(`cypher`,[{op:new K(`cypher`,[t,{op:new bo(`cypher`,[i[1].parts[0]])}],pa,!0)},this.processFnArg(i[0],r)],Zs.impl),this.calcBuilders,this.eqCheckers),e);return e}setupChainSelections(e,t,n,r,i,a){for(let o=i;o<=a;o+=2){let i=e[o];if(i.range)continue;let a=i.pointsLeft?`in`:i.pointsRight?`out`:`any`,s=i.pointsLeft?`out`:i.pointsRight?`in`:`any`;n=this.isEdgeConnected(n,a,t[o-1],t[o],r),n=this.isEdgeConnected(n,s,t[o+1],t[o],r),a===`any`&&(n=this.checkCorrectAnyEdge(t[o-1],t[o],t[o+1],r,n))}let o=t.filter((e,t)=>t%2==1);for(let t=i;t<=a;t+=2){let r=!!e[t].range;t===1||r||(n=new J(`cypher`,To(new K(`cypher`,o.slice(0,t/2+1),(...t)=>{let n=t.pop();return t.every((t,r)=>e[r*2+1].range?!t.includes(n):t!==n)}),this.calcBuilders,this.eqCheckers),n))}return n}checkAnyRecEdge(e,t,n){return(e[n]!==e[n-1]&&e[n]!==t[n-1]||e[n]!==e[n+1]&&e[n]!==t[n+1]||e[n]===t[n])&&(t[n]!==e[n-1]&&t[n]!==t[n-1]||t[n]!==e[n+1]&&t[n]!==t[n+1]||e[n]===t[n])}checkCorrectAnyRecursion(e,t,n,r){let i=this.db.getSource(t.parts);return new J(`cypher`,To(new K(`cypher`,[e[n-1],e[n],e[n+1]],(e,t,n)=>{let r=t.map(e=>this.dataAdapter.getEdgeNode(i,e,`source`)),a=t.map(e=>this.dataAdapter.getEdgeNode(i,e,`target`));if(t.length===1)return r[0]===e!=(r[0]===n)||r[0]===a[0];if(r[0]!==e&&r[0]!==r[1]&&r[0]!==a[1]||a[0]!==e&&a[0]!==r[1]&&a[0]!==a[1]||r.at(-1)!==n&&r.at(-1)!==r.at(-2)&&r.at(-1)!==a.at(-2)||a.at(-1)!==n&&a.at(-1)!==r.at(-2)&&a.at(-1)!==a.at(-2))return!1;for(let e=1;e<t.length-1;e++)if(!this.checkAnyRecEdge(r,a,e))return!1;return!0}),this.calcBuilders,this.eqCheckers),r)}checkCorrectAnyEdge(e,t,n,r,i){let a=this.db.getSource(r.parts);return new J(`cypher`,To(new K(`cypher`,[e,t,n],(e,t,n)=>{let r=this.dataAdapter.getEdgeNode(a,t,`source`),i=this.dataAdapter.getEdgeNode(a,t,`target`);return r===e!=(r===n)||r===i}),this.calcBuilders,this.eqCheckers),i)}isEdgeConnected(e,t,n,r,i){return new J(`cypher`,To(new K(`cypher`,[{op:new bo(`cypher`,this.db.getSource(i.parts))},n,r,{op:new bo(`cypher`,t)}],this.dataAdapter.isConnected),this.calcBuilders,this.eqCheckers),e)}setupVarsAndRefs(e,t){let n=Symbol(`unnamed`),r=e.chain.map((e,t)=>e.variable??z.fromParts([n,t+``])),i=e.chain.map(e=>e.variable?(Cl(e.variable,t),e.variable.parts[0]===$i||t.ctx.has(e.variable.parts)||t.src?.schemaSet.has(e.variable.parts)||e.variable.parts.at(-1)===Os):!1),a=t.src?U(t.ctx,t.src.schema):t.ctx;return{variables:r,isRef:i,ctx:a,res:this.preparePatternRefs(r.filter((e,t)=>i[t]),e.chain,i,{...t,ctx:a,src:t.optional?null:t.src}),varPrefix:n}}processChainPart(e,t,n,r,i){return e.chain[t].accept(this,{...r,variable:n[t],ctx:i})}joinNodesEdges(e,t,n,r,i,a){let o=-1,s=e.findIndex(e=>!e);if(s>-1){r||(r=t.chain[s].accept(this,{...i,variable:n[s],ctx:a}),s++);for(let c=s;c<t.chain.length;c++){if(e[c])continue;let s=t.chain[c];if(s instanceof qc&&s.range){r=this.setupChainSelections(t.chain,n,r,i.graphName,o+2,c),o=c;let e=this.processChainPart(t,c+1,n,i,a);r=this.addRecursion(r,e,t.chain,n,c,{...i,ctx:a}),c++}else r=new xo(`cypher`,this.processChainPart(t,c,n,i,a),!1,r)}}return r=this.setupChainSelections(t.chain,n,r,i.graphName,o+2,t.chain.length-1),r}visitPatternElChain(e,t){let n=this.setupVarsAndRefs(e,t),{variables:r,isRef:i,ctx:a,varPrefix:o}=n,s=n.res;s=this.joinNodesEdges(i,e,r,s,t,a);let c=s.schema.filter(e=>e.parts[0]!==o).map(e=>[e,e]);if(!e.variable&&c.length===s.schema.length)return s;if(e.variable&&c.push([new G(`cypher`,(...e)=>e,r,r.map(wl)),e.variable]),s=new q(`cypher`,c,s),t.optional){let e=t.src??new Y(`cypher`);s=new q(`cypher`,s.schema.filter(t=>!e.schemaSet.has(t.parts)).map(aa),s),s=new xo(`cypher`,s,!0,e)}return s}visitNodePattern(e,t){let n=t.graphName.parts,r=new vo(`cypher`,z.fromParts(n.concat(`nodes`))),i=new Ao(`cypher`,t.variable,r);return i=this.addNodeSelections(i,e,t),i}addNodeSelections(e,t,n){let r=n.graphName.parts,i=this.db.getSource(r);return t.labels.length&&(e=new J(`cypher`,To(new K(`cypher`,[{op:new bo(`cypher`,i)},n.variable,{op:new bo(`cypher`,t.labels.map(Tl))}],this.dataAdapter.hasLabels),this.calcBuilders,this.eqCheckers),e)),t.props&&(e=this.patternToSelection(e,n.variable,t,n)),e}visitRelPattern(e,t){let n=t.graphName.parts,r=this.db.getSource(n),i=new vo(`cypher`,z.fromParts(n.concat(`edges`))),a=new Ao(`cypher`,t.variable,i);return e.types.length&&(a=new J(`cypher`,To(new K(`cypher`,[{op:new bo(`cypher`,r)},t.variable,{op:new bo(`cypher`,e.types.map(Tl))}],this.dataAdapter.hasAnyType),this.calcBuilders,this.eqCheckers),a)),e.props&&(a=this.patternToSelection(a,t.variable,e,t)),a}prepareBidiRecInput(e,t,n,r,i,a,o,s){let c=this.db.getSource(s.graphName.parts),l=this.createRecursionMapping(i,c,n,e.clone(),a,o),u=new xo(`cypher`,e.clone(),!1,t);return u=this.isEdgeConnected(u,n,i[o],i[a],s.graphName),a>1&&(u=new J(`cypher`,To(new K(`cypher`,i.filter((e,t)=>t%2==1).slice(0,a/2+1),(...e)=>{let t=e.pop();return e.every((e,n)=>r[n*2+1].range?!e.includes(t):e!==t)}),this.calcBuilders,this.eqCheckers),u)),[u,l]}addRecursion(e,t,n,r,i,a){let o=n[i],s=o.range[0]?.value??0,c=o.range[1]?.value??1/0,l=o.pointsLeft?`in`:o.pointsRight?`out`:`any`,u=l===`in`?`out`:l===`out`?`in`:`any`,d=this.visitRelPattern(o,{...a,variable:r[i]}),f,p,m=e;[e,f]=this.prepareBidiRecInput(d,e,l,n,r,i,i-1,a),[t,p]=this.prepareBidiRecInput(d,t,u,n,r,i,i+1,a);let h=new X(`cypher`,s||1,c,f,p,t,e);return h=new J(`cypher`,To(new K(`cypher`,[r[i]],e=>{for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(e[t]===e[n])return!1;return!0}),this.calcBuilders,this.eqCheckers),h),l===`any`&&(h=this.checkCorrectAnyRecursion(r,a.graphName,i,h)),s===0&&(h=this.handleRecursionZeroCase(m,n,r,i,h,a)),h}handleRecursionZeroCase(e,t,n,r,i,a){let o=new Y(`cypher`);o=new q(`cypher`,e.schema.map(aa),o);let s=o.clone(),c=new bo(`cypher`,[]);return o=new q(`cypher`,[...o.attrs.map(e=>e.slice()),[To(c,this.calcBuilders,this.eqCheckers),n[r]],[n[r-1],n[r+1]]],o),o=this.addNodeSelections(o,t[r+1],{...a,variable:n[r+1]}),e.parent.replaceChild(e,s),new xo(`cypher`,new Io(`cypher`,o,i),!1,e)}createRecursionMapping(e,t,n,r,i,a){let o=new yo(`cypher`,[e[i],e[a]],(e,r)=>{let i=[];if(n===`any`){let n=this.dataAdapter.getEdgeNode(t,e.at(-1),`source`),a=this.dataAdapter.getEdgeNode(t,e.at(-1),`target`);e.length===1?i.push(n===r?a:n):this.dataAdapter.isConnected(t,n,e.at(-2),`any`)?i.push(a):i.push(n)}else n===`in`?i.push(this.dataAdapter.getEdgeNode(t,e.at(-1),`source`)):i.push(this.dataAdapter.getEdgeNode(t,e.at(-1),`target`));return Iterator.from(i).flatMap(r=>this.dataAdapter.filterNodeEdges(t,r,n,(t,n,r)=>!e.includes(r)))},Sl(`connectedEdges`)),s=r.source;for(;!(s instanceof vo);)s=s.source;return s.parent.replaceChild(s,o),r}visitPatternComprehension(e,t){let n=e.pattern.accept(this,{...t,src:void 0}),r=Sl(`pattern`);return e.where&&(n=Xo(this.processNode(e.where,{...t,ctx:U(t.ctx,n.schema)}),n,this.calcBuilders,this.eqCheckers,`cypher`)),n=new q(`cypher`,[[this.toCalc(e.expr,{...t,ctx:U(t.ctx,n.schema)}),r]],n),n=new No(`cypher`,[],[new go(`cypher`,[r],Is,r)],n),new ko(`cypher`,r,n)}visitListComprehension(e,t){let n=new Ao(`cypher`,e.variable,new yo(`cypher`,[this.toCalc(e.source,t)],oc.impl,Sl(`unwind`)));return e.where&&(n=Xo(this.processNode(e.where,{...t,ctx:U(t.ctx,[e.variable])}),n,this.calcBuilders,this.eqCheckers,`cypher`)),e.expr&&(n=new q(`cypher`,[[this.toCalc(e.expr,{...t,ctx:U(t.ctx,[e.variable])}),e.variable]],n)),n=new No(`cypher`,[],[new go(`cypher`,[e.variable],Is,e.variable)],n),new ko(`cypher`,e.variable,n)}visitCaseExpr(e,t){return new Eo(`cypher`,e.expr&&this.processNode(e.expr,t),e.whenThens.map(([e,n])=>[this.processNode(e,t),this.processNode(n,t)]),e.elseExpr&&this.processNode(e.elseExpr,t))}visitCountAll(e,t){throw Error(`Method not implemented.`)}visitLabelFilterExpr(e,t){return new K(`cypher`,[{op:new bo(`cypher`,this.db.getSource(t.graphName.parts))},this.processFnArg(e.expr,t),{op:new bo(`cypher`,e.labels.map(Tl))}],Q(this.dataAdapter.hasLabels))}visitSubscriptExpr(e,t){let n=e.subscript.filter(ta).map(e=>this.processFnArg(e,t));return n.unshift(this.processFnArg(e.expr,t)),new K(`cypher`,n,Q(e.subscript.length===2?(e,t,n)=>e.slice(t??0,n??e.length):(e,t)=>`at`in e?e.at(t):e[t]))}visitPropLookup(e,t){return new K(`cypher`,[this.processFnArg(e.expr,t),{op:new bo(`cypher`,e.prop.parts)}],pa)}visitSetOp(e,t){let n=e.next.accept(this,{...t,src:null});return n=new Io(`cypher`,t.src,n),e.type===Jc.UNION&&(n=new zo(`cypher`,Qi,n)),n}visitQuery(e,t){if(e.from)t={...t,graphName:e.from};else if(!t.graphName)throw Error(`No graph specified`);let n=e.statements[0].accept(this,t);for(let r=1;r<e.statements.length;r++)n=e.statements[r].accept(this,{...t,src:n});return e.setOp&&(n=this.visitSetOp(e.setOp,{...t,src:n})),n}visitMatchClause(e,t){let n=this.visitPatternElChain(e.pattern[0],{...t,optional:e.optional});for(let r=1;r<e.pattern.length;r++)n=this.visitPatternElChain(e.pattern[r],{...t,src:n,optional:e.optional});return e.where&&(n=Xo(this.processNode(e.where,{...t,ctx:U(t.ctx,n.schema)}),n,this.calcBuilders,this.eqCheckers,`cypher`)),n}visitUnwindClause(e,t){let n=this.processNode(e.expr,{...t,ctx:U(t.ctx,t.src?.schema??[])});_o in n&&(n=To(n,this.calcBuilders,this.eqCheckers));let r;r=n instanceof z||n instanceof G?new yo(`cypher`,[n],oc.impl,Sl(`unwind`)):n instanceof W?new ko(`cypher`,z.fromParts([Qi]),n):n;let i=new Ao(`cypher`,e.variable,r);return t.src?new xo(`cypher`,i,!1,t.src):i}visitCreateClause(e,t){throw new mc(`Only read operations are supported`)}visitMergeClause(e,t){throw new mc(`Only read operations are supported`)}visitSetClause(e,t){throw new mc(`Only read operations are supported`)}visitSetItem(e,t){throw Error(`Method not implemented.`)}visitRemoveClause(e,t){throw new mc(`Only read operations are supported`)}visitRemoveItem(e,t){throw Error(`Method not implemented.`)}visitDeleteClause(e,t){throw new mc(`Only read operations are supported`)}visitProjectionBody(e,t){let n=t.src??new Y(`cypher`),r=n.schema,i=U(t.ctx,n.schema),a=[];for(let n of e.items)n===`*`?a.push(...r.map(aa)):a.push(this.processAttr(n,{...t,ctx:i}));let o=$o(a.map(ra)),s=e.distinct||o.length>0;if(e.order?.length&&(n=this.processOrderBy(e,n,{...t,ctx:i,bodyChangesCardinality:s,bodyAttrs:a})),!e.order?.length&&o.length&&(n=this.processGroupBy(n,o,a)),!s||!e.order?.length){if(e.order?.length)for(let e of a)e[0]instanceof G&&n.schemaSet.has(e[1].parts)&&(e[0]=e[1]);n=new q(`cypher`,a,n)}return e.distinct&&(n=new zo(`cypher`,Qi,n)),(e.limit||e.skip)&&(n=this.buildLimit(e,n,t)),n}processOrderBy(e,t,n){let r=n.bodyChangesCardinality?[]:t.schema.map(aa);r.push(...n.bodyAttrs.map(ua));let i=[];for(let t of e.order){let e=this.toCalc(t.expr,n);if(e instanceof G){let n=Sl(t.expr.accept(this.stringifier));r.push([e,n]),i.push({ascending:t.ascending,key:n,nullsFirst:!1})}else i.push({ascending:t.ascending,key:e,nullsFirst:!1})}let a=$o(r.map(ra));return a.length?t=this.processGroupBy(t,a,r):n.bodyChangesCardinality||(t=new q(`cypher`,r,t)),n.bodyChangesCardinality&&(t=new q(`cypher`,n.bodyAttrs,t)),new Mo(`cypher`,i,t)}processGroupBy(e,t,n){let r=ao(t.map(e=>e.fieldName)),i=[];for(let e of n)e[0]instanceof z?r.has(e[0].parts)||i.push(e.slice()):e[0].aggregates.length||i.push([e[0].clone(),e[1]]);for(let n of t)n.postGroupSource.addToSchema(e.schema);return new No(`cypher`,i,t,e)}buildLimit(e,t,n){let r=e.limit!==null&&this.toCalc(e.limit,n),i=e.skip!==null&&this.toCalc(e.skip,n);if(r&&!qo(r,`number`))throw Error(`Limit must be a number constant`);if(i&&!qo(i,`number`))throw Error(`Offset must be a number constant`);return new Po(`cypher`,i?i.impl():0,r?r.impl():1/0,t)}visitOrderItem(e,t){throw Error(`Method not implemented.`)}visitWithClause(e,t){let n=this.visitProjectionBody(e.body,{...t});return e.where&&(n=Xo(this.processNode(e.where,{...t,ctx:U(t.ctx,n.schemaSet)}),n,this.calcBuilders,this.eqCheckers,`cypher`)),n}visitReturnClause(e,t){return this.visitProjectionBody(e.body,{...t})}visitLiteral(e,t){return new bo(`cypher`,e.value)}visitOperator(e,t){let n=this.db.langMgr.getOp(e.lang,...xl(e.id));return new K(e.lang,e.operands.map(e=>({op:e.accept(this,t)})),n.impl,!0)}visitFunction(e,t){throw Error(`Method not implemented.`)}visitLangSwitch(e,t){let n=new(this.db.langMgr.getLang(e.lang)).visitors.logicalPlanBuilder(this.db).buildPlan(e.node,t.ctx,this.langCtx);for(let e of n.inferred)t.inferred.add(e);return n.plan instanceof W?new ko(`cypher`,null,n.plan):n.plan}visitIdentifier(e,t){return Cl(e,t),new K(`cypher`,[e],ta)}},Dl=class extends SyntaxError{constructor(e,t,n,r){super(e),this.expected=t,this.found=n,this.location=r,this.name=`SyntaxError`}format(e){let t=`Error: `+this.message;if(this.location){let n=null,r=e.find(e=>e.source===this.location.source);r&&(n=r.text.split(/\r\n|\n|\r/g));let i=this.location.start,a=this.location.source&&typeof this.location.source.offset==`function`?this.location.source.offset(i):i,o=this.location.source+`:`+a.line+`:`+a.column;if(n){let e=this.location.end,r=``.padEnd(a.line.toString().length,` `),s=n[i.line-1],c=(i.line===e.line?e.column:s.length+1)-i.column||1;t+=`
|
|
315
|
+
--> `+o+`
|
|
316
|
+
`+r+` |
|
|
317
|
+
`+a.line+` | `+s+`
|
|
318
|
+
`+r+` | `+``.padEnd(i.column-1,` `)+``.padEnd(c,`^`)}else t+=`
|
|
319
|
+
at `+o}return t}static buildMessage(e,t){function n(e){return e.codePointAt(0).toString(16).toUpperCase()}let r=Object.prototype.hasOwnProperty.call(RegExp.prototype,`unicode`)?RegExp(`[\\p{C}\\p{Mn}\\p{Mc}]`,`gu`):null;function i(e){return r?e.replace(r,e=>`\\u{`+n(e)+`}`):e}function a(e){return i(e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\0/g,`\\0`).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/[\x00-\x0F]/g,e=>`\\x0`+n(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>`\\x`+n(e)))}function o(e){return i(e.replace(/\\/g,`\\\\`).replace(/\]/g,`\\]`).replace(/\^/g,`\\^`).replace(/-/g,`\\-`).replace(/\0/g,`\\0`).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/[\x00-\x0F]/g,e=>`\\x0`+n(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>`\\x`+n(e)))}let s={literal(e){return`"`+a(e.text)+`"`},class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+`-`+o(e[1]):o(e));return`[`+(e.inverted?`^`:``)+t.join(``)+`]`+(e.unicode?`u`:``)},any(){return`any character`},end(){return`end of input`},other(e){return e.description}};function c(e){return s[e.type](e)}function l(e){let t=e.map(c);if(t.sort(),t.length>0){let e=1;for(let n=1;n<t.length;n++)t[n-1]!==t[n]&&(t[e]=t[n],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+` or `+t[1];default:return t.slice(0,-1).join(`, `)+`, or `+t[t.length-1]}}function u(e){return e?`"`+a(e)+`"`:`end of input`}return`Expected `+l(e)+` but `+u(t)+` found.`}};function Ol(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Cypher:Li},a=Li,o=`lang`,s=`union`,c=`optional`,l=`match`,u=`unwind`,d=`merge`,f=`create`,p=`detach`,m=`delete`,h=`remove`,g=`call`,_=`yield`,v=`with`,y=`return`,b=`distinct`,x=`order`,S=`skip`,C=`limit`,w=`ascending`,ee=`descending`,te=`desc`,ne=`where`,re=`starts`,ie=`ends`,ae=`contains`,oe=`null`,se=`count`,ce=`case`,le=`else`,ue=`when`,de=`then`,T=`none`,fe=`single`,pe=`exists`,me=`true`,he=`false`,ge=/^[)\]}]/,_e=/^[<>]/,ve=/^[+\-]/,ye=/^[%*\/]/,be=/^[0-9a-z_$]/i,xe=/^[01]/,Se=/^[a-f]/i,Ce=/^[0-9]/,we=/^[1-9]/,E=/^[0-7]/,D=/^[^"\\]/,O=/^[^'\\]/,Te=/^[\p{ID_Start}\p{Pc}]/u,Ee=/^[\p{ID_Continue}\p{Sc}]/u,De=/^[^`]/,Oe=/^[\p{White_Space}]/u,ke=/^[^*]/,Ae=/^[^\/]/,je=/^[^\r\n]/,Me=/^[<\u27E8\u3008\uFE64\uFF1C]/,Ne=/^[>\u27E9\u3009\uFE65\uFF1E]/,Pe=/^[\-\xAD\u2010\u2011\u2012\u2013\u2014\u2015\u2212\uFE58\uFE63\uFF0D]/,Fe=I(`;`,!1),Ie=Mi(),Le=I(`lang`,!0),Re=I(`exit`,!0),ze=ji([`)`,`]`,`}`],!1,!1,!1),Be=I(`FROM`,!0),Ve=I(`UNION`,!0),He=I(`ALL`,!0),Ue=I(`OPTIONAL`,!0),We=I(`MATCH`,!0),Ge=I(`UNWIND`,!0),Ke=I(`AS`,!0),qe=I(`MERGE`,!0),Je=I(`ON`,!0),Ye=I(`CREATE`,!0),Xe=I(`SET`,!0),Ze=I(`,`,!1),Qe=I(`=`,!1),$e=I(`+=`,!1),et=I(`DETACH`,!0),tt=I(`DELETE`,!0),nt=I(`REMOVE`,!0),rt=I(`CALL`,!0),it=I(`YIELD`,!0),at=I(`*`,!1),ot=I(`WITH`,!0),st=I(`RETURN`,!0),ct=I(`DISTINCT`,!0),lt=I(`ORDER`,!0),ut=I(`BY`,!0),dt=I(`SKIP`,!0),ft=I(`LIMIT`,!0),pt=I(`ASCENDING`,!0),mt=I(`ASC`,!0),ht=I(`DESCENDING`,!0),gt=I(`DESC`,!0),_t=I(`WHERE`,!0),vt=I(`(`,!1),yt=I(`)`,!1),bt=I(`[`,!1),xt=I(`]`,!1),St=I(`:`,!1),Ct=I(`|`,!1),wt=I(`..`,!1),Tt=I(`OR`,!0),Et=I(`XOR`,!0),Dt=I(`AND`,!0),Ot=I(`NOT`,!0),kt=I(`<>`,!1),At=I(`<=`,!1),jt=I(`>=`,!1),Mt=ji([`<`,`>`],!1,!1,!1),Nt=I(`STARTS`,!0),Pt=I(`ENDS`,!0),Ft=I(`CONTAINS`,!0),It=I(`IN`,!0),Lt=I(`IS`,!0),Rt=I(`NULL`,!0),zt=ji([`+`,`-`],!1,!1,!1),Bt=ji([`%`,`*`,`/`],!1,!1,!1),Vt=I(`^`,!1),Ht=I(`.`,!1),Ut=I(`COUNT`,!0),Wt=I(`LANG`,!0),Gt=ji([[`0`,`9`],[`a`,`z`],`_`,`$`],!1,!0,!1),Kt=I(`CASE`,!0),qt=I(`ELSE`,!0),Jt=I(`END`,!0),Yt=I(`WHEN`,!0),k=I(`THEN`,!0),Xt=I(`ANY`,!0),Zt=I(`NONE`,!0),Qt=I(`SINGLE`,!0),$t=I(`EXISTS`,!0),en=I(`{`,!1),tn=I(`}`,!1),nn=I(`TRUE`,!0),rn=I(`FALSE`,!0),an=I(`0x`,!1),on=I(`0o`,!1),sn=I(`0b`,!1),cn=ji([`0`,`1`],!1,!1,!1),ln=ji([[`a`,`f`]],!1,!0,!1),un=ji([[`0`,`9`]],!1,!1,!1),dn=ji([[`1`,`9`]],!1,!1,!1),fn=ji([[`0`,`7`]],!1,!1,!1),pn=I(`0`,!1),mn=I(`E`,!0),hn=I(`-`,!1),gn=I(`"`,!1),_n=ji([`"`,`\\`],!0,!1,!1),vn=I(`'`,!1),yn=ji([`'`,`\\`],!0,!1,!1),bn=I(`\\`,!1),xn=I(`$`,!1),Sn=I(`CONSTRAINT`,!0),Cn=I(`DO`,!0),wn=I(`FOR`,!0),Tn=I(`REQUIRE`,!0),En=I(`UNIQUE`,!0),Dn=I(`MANDATORY`,!0),On=I(`SCALAR`,!0),kn=I(`OF`,!0),An=I(`ADD`,!0),jn=I(`DROP`,!0),Mn=I(`FILTER`,!0),Nn=I(`EXTRACT`,!0),Pn=ji([`\\p{ID_Start}`,`\\p{Pc}`],!1,!1,!0),Fn=ji([`\\p{ID_Continue}`,`\\p{Sc}`],!1,!1,!0),A=I("`",!1),In=ji(["`"],!0,!1,!1),j=ji([`\\p{White_Space}`],!1,!1,!0),Ln=I(`/*`,!1),Rn=ji([`*`],!0,!1,!1),zn=ji([`/`],!0,!1,!1),Bn=I(`*/`,!1),Vn=I(`//`,!1),Hn=ji([`\r`,`
|
|
320
|
+
`],!0,!1,!1),Un=I(`\r`,!1),Wn=I(`
|
|
321
|
+
`,!1),Gn=ji([`<`,`⟨`,`〈`,`﹤`,`<`],!1,!1,!1),Kn=ji([`>`,`⟩`,`〉`,`﹥`,`>`],!1,!1,!1),qn=ji([`-`,``,`‐`,`‑`,`‒`,`–`,`—`,`―`,`−`,`﹘`,`﹣`,`-`],!1,!1,!1);function Jn(t){return{value:t,remainingInput:e.slice(ki().end.offset)}}function Yn(t){return{value:t,remainingInput:e.slice(ki().end.offset)}}function Xn(t){return{value:t,remainingInput:e.slice(ki().end.offset)}}function Zn(e,t,n){t.from=e;let r=t;for(let[e,t]of n)r.setOp=new Z.SetOp(e,t),r=t;return t}function Qn(){return`unionall`}function $n(){return`union`}function er(e,t){return e.push(t),new Z.Query(e)}function tr(e,t,n){return new Z.Query([...e,...t,n])}function nr(e,t){return t.statements=[e,t.statements].flat(1/0),t}function rr(e,t,n){return[e,t,n]}function ir(e,t,n){let r=new Z.MatchClause(t,n);return r.optional=!!e,r}function ar(e,t){return new Z.UnwindClause(e,t)}function or(e,t){return new Z.MergeClause(e,t)}function sr(e){return new yy.ast.MergeAction(`match`,e.items)}function cr(e){return new yy.ast.MergeAction(`create`,e.items)}function lr(e){return new Z.CreateClause(e)}function ur(e){return new Z.SetClause(e)}function dr(e,t){return new Z.SetItem(e,t)}function fr(e,t){return new Z.SetItem(e,t)}function pr(e,t){let n=new Z.SetItem(e,t);return n.add=!0,n}function mr(e,t){return new Z.SetItem(e,t)}function hr(e,t){return new Z.DeleteClause(t,!!e)}function gr(e){return new Z.RemoveClause(e)}function _r(e,t){return new Z.RemoveItem(e,t)}function vr(e){return new Z.RemoveItem(e)}function yr(e,t){let n=e;return e.where=t[0],e.yieldItems=t[1],n}function br(e,t){let n=e;return e.where=t[0],e.yieldItems=t[1],n}function xr(e,t){return new Z.WithClause(e,t)}function Sr(e){return new Z.ReturnClause(e)}function Cr(e,t,n,r,i){return new Z.ProjectionBody(t,n,r,i,!!e)}function wr(e){return[`*`,...e]}function Tr(e,t){let n=!t||t[0]===`a`||t[0]===`A`;return new Z.OrderItem(e,n)}function Er(e,t){return t.variable=e,t}function Dr(e,t){return new Z.PatternElChain([e,t].flat(1/0))}function Or(e,t,n){return new Z.NodePattern(e,t??[],n)}function kr(e){return e??=new Z.RelPattern,e.pointsLeft=!0,e}function Ar(e){return e??=new Z.RelPattern,e.pointsRight=!0,e}function jr(e){return e??new Z.RelPattern}function Mr(e,t,n,r){return new Z.RelPattern(!1,!1,e,t??[],n,r)}function Nr(e,t){e=e===null?void 0:new Z.ASTNumberLiteral(e);let n=t?t[1]===null?void 0:new Z.ASTNumberLiteral(t[1]):e;return[e,n]}function Pr(e,t){for(let n of t)e=new Z.PropLookup(e,n);return e}function Fr(e,t){return Yo(e,`or`,t)}function Ir(e,t){return Yo(e,`xor`,t)}function Lr(e,t){return Yo(e,`and`,t)}function Rr(e,n){for(let r=0;r<e.length;r++)n=t.makeOp(`not`,[n]);return n}function zr(e,n){if(!n.length)return e;let[r,...i]=n;e=t.makeOp(r[0],[e,r[1]]);for(let[n,r]of i)e=t.makeOp(`and`,[e,t.makeOp(n,[e.operands[1],r])]);return e}function Br(e,n){for(let[r,i]of n)e=t.makeOp(r,i?[e,i]:[e]);return e}function Vr(){return`startswith`}function Hr(){return`endswith`}function Ur(){return`isnull`}function Wr(){return`isnotnull`}function Gr(e,n){for(let[r,i]of n)e=t.makeOp(r,[e,i]);return e}function Kr(e,n){for(let[r,i]of n)e=t.makeOp(r,[e,i]);return e}function qr(e,t){return Yo(e,`^`,t)}function Jr(e,n){return t.makeOp(e,[n])}function Yr(e,t){return t?new Z.LabelFilterExpr(e,t):e}function Xr(e,t){for(let n of t)e=Array.isArray(n)?new Z.SubscriptExpr(e,n):new Z.PropLookup(e,n);return e}function Zr(e){return[e]}function Qr(){return t.wrapFn(Z.ASTIdentifier.fromParts([`count`]),[Z.ASTIdentifier.fromParts([Z.allAttrs])])}function $r(n){n=n.toLowerCase();let r=t.langMgr.getLang(n);if(!r)throw Error(`Unknown language: ${n}`);let i=ki().end.offset,a=r.createParser(t.langMgr),o=`
|
|
322
|
+
`.repeat(ki().end.line-1)+` `.repeat(ki().end.column-1),s=a.parse(o+e.slice(i));return e=e.slice(0,i)+e.slice(i,e.length-s.remainingInput.length).replace(/[^\n]/g,` `)+s.remainingInput,new Z.LangSwitch(n,s.value)}function ei(e,t){return new Z.CaseExpr(void 0,e,t)}function ti(e,t,n){return new Z.CaseExpr(e,t,n)}function ni(e,t){return new Z.ListComprehension(e.v,e.expr,e.where,t)}function ri(e,t,n,r){return t=new Z.PatternElChain(t.flat(1/0)),t.variable=e,new Z.PatternComprehension(t,n,r)}function ii(e,t){return new Z.QuantifiedExpr(e.toLowerCase(),t.v,t.expr,t.where)}function ai(e,t){return{where:t,v:e[0],expr:e[1]}}function oi(e){let t=new Z.PatternElChain(e.flat(1/0));return new Z.ExistsSubquery(null,[t])}function si(e,n,r){return t.wrapFn(e,r??[],!!n)}function ci(){return new Z.CypherIdentifier(Oi())}function li(e){return new Z.ExistsSubquery(e)}function ui(e,t){return new Z.ExistsSubquery(null,e,t)}function di(e){return new Z.ExistsSubquery(e)}function fi(e,n){let r=new t.wrapFn(e,n??[]);return r.procedure=!0,r}function pi(e){let n=new t.wrapFn(e);return n.procedure=!0,n}function mi(){return new Z.CypherIdentifier(Oi())}function hi(e){return new Z.ASTBooleanLiteral(e)}function gi(e){return new Z.ASTBooleanLiteral(e)}function _i(e){return new Z.ASTNumberLiteral(e)}function vi(e){return new Z.ASTStringLiteral(e)}function yi(e){return new Z.ASTListLiteral(e??[])}function bi(e){return e??=[],new Z.ASTMapLiteral(e.map(([e,t])=>[t,e]))}function xi(e){let t=new Z.CypherIdentifier(e);return t.parts.unshift(Z.boundParam),t}function Si(e){return new Z.CypherIdentifier(e)}function Ci(){return new Z.CypherIdentifier(Oi())}let M=t.peg$currPos|0,N=M,wi=[{line:1,column:1}],Ti=M,Ei=t.peg$maxFailExpected||[],P=t.peg$silentFails|0,F={},Di;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule "`+t.startRule+`".`);a=i[t.startRule]}function Oi(){return e.substring(N,M)}function ki(){return Fi(N,M)}function Ai(t=M){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function I(e,t){return{type:`literal`,text:e,ignoreCase:t}}function ji(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function Mi(){return{type:`any`}}function Ni(){return{type:`end`}}function Pi(t){let n=wi[t],r;if(n)return n;if(t>=wi.length)r=wi.length-1;else for(r=t;!wi[--r];);for(n=wi[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return wi[t]=n,n}function Fi(e,t,n){let i=Pi(e),a=Pi(t),o={source:r,start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:a.line,column:a.column}};return n&&r&&typeof r.offset==`function`&&(o.start=r.offset(o.start),o.end=r.offset(o.end)),o}function L(e){M<Ti||(M>Ti&&(Ti=M,Ei=[]),Ei.push(e))}function Ii(e,t,n){return new Dl(Dl.buildMessage(e,t),e,t,n)}function Li(){let t,r,i,a,s,c,l,u,d=M*132+0,f=F[d];return f?(M=f.nextPos,f.result):(t=M,r=X(),r===n&&(r=null),i=Ri(),i===n?(M=t,t=n):(a=M,s=X(),s===n&&(s=null),e.charCodeAt(M)===59?(c=`;`,M++):(c=n,P===0&&L(Fe)),c===n?(M=a,a=n):(s=[s,c],a=s),a===n&&(a=null),s=X(),s===n&&(s=null),c=M,P++,e.length>M?(l=e.charAt(M),M++):(l=n,P===0&&L(Ie)),P--,l===n?c=void 0:(M=c,c=n),c===n?(M=t,t=n):(N=t,t=Jn(i))),t===n&&(t=M,r=X(),r===n&&(r=null),i=Ri(),i===n?(M=t,t=n):(a=M,s=X(),s===n&&(s=null),e.charCodeAt(M)===59?(c=`;`,M++):(c=n,P===0&&L(Fe)),c===n?(M=a,a=n):(s=[s,c],a=s),a===n&&(a=null),s=X(),s===n&&(s=null),c=M,P++,l=zi(),P--,l===n?c=n:(M=c,c=void 0),c===n?(M=t,t=n):(N=t,t=Yn(i))),t===n&&(t=M,r=X(),r===n&&(r=null),i=Ri(),i===n?(M=t,t=n):(a=M,s=X(),s===n&&(s=null),e.charCodeAt(M)===59?(c=`;`,M++):(c=n,P===0&&L(Fe)),c===n?(M=a,a=n):(s=[s,c],a=s),a===n&&(a=null),s=X(),s===n&&(s=null),c=e.substr(M,4),c.toLowerCase()===o?M+=4:(c=n,P===0&&L(Le)),c===n?(M=t,t=n):(l=X(),l===n?(M=t,t=n):(u=e.substr(M,4),u.toLowerCase()===`exit`?M+=4:(u=n,P===0&&L(Re)),u===n?(M=t,t=n):(N=t,t=Xn(i))))))),F[d]={nextPos:M,result:t},t)}function Ri(){let e,t=M*132+1,r=F[t];return r?(M=r.nextPos,r.result):(e=io(),e===n&&(e=Bi()),F[t]={nextPos:M,result:e},e)}function zi(){let t,r=M*132+2,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),ge.test(t)?M++:(t=n,P===0&&L(ze)),F[r]={nextPos:M,result:t},t)}function Bi(){let e,t=M*132+3,r=F[t];return r?(M=r.nextPos,r.result):(e=Vi(),e===n&&(e=oa()),F[t]={nextPos:M,result:e},e)}function Vi(){let e,t,r,i,a,o,s,c=M*132+4,l=F[c];if(l)return M=l.nextPos,l.result;if(e=M,t=M,r=Hi(),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):t=r),t===n&&(t=null),r=Gi(),r!==n){for(i=[],a=M,o=X(),o===n&&(o=null),s=Ui(),s===n?(M=a,a=n):a=s;a!==n;)i.push(a),a=M,o=X(),o===n&&(o=null),s=Ui(),s===n?(M=a,a=n):a=s;N=e,e=Zn(t,r,i)}else M=e,e=n;return F[c]={nextPos:M,result:e},e}function Hi(){let t,r,i,a,o=M*132+5,s=F[o];return s?(M=s.nextPos,s.result):(t=M,r=e.substr(M,4),r.toLowerCase()===`from`?M+=4:(r=n,P===0&&L(Be)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=Y(),a===n?(M=t,t=n):t=a)),F[o]={nextPos:M,result:t},t)}function Ui(){let e,t,r,i=M*132+6,a=F[i];return a?(M=a.nextPos,a.result):(e=M,t=Wi(),t===n?(M=e,e=n):(r=Gi(),r===n?(M=e,e=n):(t=[t,r],e=t)),F[i]={nextPos:M,result:e},e)}function Wi(){let t,r,i,a,o,c=M*132+7,l=F[c];return l?(M=l.nextPos,l.result):(t=M,r=e.substr(M,5),r.toLowerCase()===s?M+=5:(r=n,P===0&&L(Ve)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=e.substr(M,3),a.toLowerCase()===`all`?M+=3:(a=n,P===0&&L(He)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),N=t,t=Qn()))),t===n&&(t=M,r=e.substr(M,5),r.toLowerCase()===s?M+=5:(r=n,P===0&&L(Ve)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),N=t,t=$n())),F[c]={nextPos:M,result:t},t)}function Gi(){let e,t=M*132+8,r=F[t];return r?(M=r.nextPos,r.result):(e=Ki(),e===n&&(e=qi()),F[t]={nextPos:M,result:e},e)}function Ki(){let e,t,r,i,a,o,s,c,l=M*132+9,u=F[l];if(u)return M=u.nextPos,u.result;for(e=M,t=[],r=Yi();r!==n;)t.push(r),r=M,i=X(),i===n&&(i=null),i=Yi(),i===n?(M=r,r=n):r=i;if(r=X(),r===n&&(r=null),i=fa(),i===n?(M=e,e=n):(N=e,e=er(t,i)),e===n){for(e=M,t=[],r=Yi();r!==n;)t.push(r),r=M,i=X(),i===n&&(i=null),i=Yi(),i===n?(M=r,r=n):r=i;for(r=X(),r===n&&(r=null),i=M,a=[],o=Ji();o!==n;)a.push(o),o=M,s=X(),s===n&&(s=null),s=Ji(),s===n?(M=o,o=n):o=s;a.length<1?(M=i,i=n):i=a,i===n?(M=e,e=n):(a=X(),a===n&&(a=null),o=M,s=X(),s===n&&(s=null),c=fa(),c===n?(M=o,o=n):o=c,o===n&&(o=null),N=e,e=tr(t,i,o))}return F[l]={nextPos:M,result:e},e}function qi(){let e,t,r,i=M*132+10,a=F[i];if(a)return M=a.nextPos,a.result;if(e=M,t=[],r=R(),r!==n)for(;r!==n;)t.push(r),r=R();else t=n;return t===n?(M=e,e=n):(r=Ki(),r===n?(M=e,e=n):(N=e,e=nr(t,r))),F[i]={nextPos:M,result:e},e}function R(){let e,t,r,i,a,o,s,c=M*132+11,l=F[c];if(l)return M=l.nextPos,l.result;for(e=M,t=[],r=Yi();r!==n;)t.push(r),r=M,i=X(),i===n&&(i=null),i=Yi(),i===n?(M=r,r=n):r=i;for(r=X(),r===n&&(r=null),i=[],a=Ji();a!==n;)i.push(a),a=M,o=X(),o===n&&(o=null),o=Ji(),o===n?(M=a,a=n):a=o;return a=X(),a===n&&(a=null),o=da(),o===n?(M=e,e=n):(s=X(),s===n&&(s=null),N=e,e=rr(t,i,o)),F[c]={nextPos:M,result:e},e}function Ji(){let e,t=M*132+12,r=F[t];return r?(M=r.nextPos,r.result):(e=z(),e===n&&(e=Qi(),e===n&&(e=na(),e===n&&(e=ea(),e===n&&(e=ra())))),F[t]={nextPos:M,result:e},e)}function Yi(){let e,t=M*132+13,r=F[t];return r?(M=r.nextPos,r.result):(e=Xi(),e===n&&(e=Zi(),e===n&&(e=aa())),F[t]={nextPos:M,result:e},e)}function Xi(){let t,r,i,a,o,s,u,d,f=M*132+14,p=F[f];return p?(M=p.nextPos,p.result):(t=M,r=M,i=e.substr(M,8),i.toLowerCase()===c?M+=8:(i=n,P===0&&L(Ue)),i===n?(M=r,r=n):(a=X(),a===n?(M=r,r=n):r=i),r===n&&(r=null),i=e.substr(M,5),i.toLowerCase()===l?M+=5:(i=n,P===0&&L(We)),i===n?(M=t,t=n):(a=X(),a===n&&(a=null),o=ba(),o===n?(M=t,t=n):(s=M,u=X(),u===n&&(u=null),d=ya(),d===n?(M=s,s=n):s=d,s===n&&(s=null),N=t,t=ir(r,o,s))),F[f]={nextPos:M,result:t},t)}function Zi(){let t,r,i,a,o,s,c,l,d=M*132+15,f=F[d];return f?(M=f.nextPos,f.result):(t=M,r=e.substr(M,6),r.toLowerCase()===u?M+=6:(r=n,P===0&&L(Ge)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=V(),a===n?(M=t,t=n):(o=X(),o===n?(M=t,t=n):(s=e.substr(M,2),s.toLowerCase()===`as`?M+=2:(s=n,P===0&&L(Ke)),s===n?(M=t,t=n):(c=X(),c===n?(M=t,t=n):(l=Y(),l===n?(M=t,t=n):(N=t,t=ar(a,l)))))))),F[d]={nextPos:M,result:t},t)}function Qi(){let t,r,i,a,o,s,c,l,u=M*132+16,f=F[u];if(f)return M=f.nextPos,f.result;if(t=M,r=e.substr(M,5),r.toLowerCase()===d?M+=5:(r=n,P===0&&L(qe)),r!==n){if(i=X(),i===n&&(i=null),a=xa(),a!==n){for(o=[],s=M,c=X(),c===n?(M=s,s=n):(l=$i(),l===n?(M=s,s=n):s=l);s!==n;)o.push(s),s=M,c=X(),c===n?(M=s,s=n):(l=$i(),l===n?(M=s,s=n):s=l);N=t,t=or(a,o)}else M=t,t=n}else M=t,t=n;return F[u]={nextPos:M,result:t},t}function $i(){let t,r,i,a,o,s,c=M*132+17,u=F[c];return u?(M=u.nextPos,u.result):(t=M,r=e.substr(M,2),r.toLowerCase()===`on`?M+=2:(r=n,P===0&&L(Je)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=e.substr(M,5),a.toLowerCase()===l?M+=5:(a=n,P===0&&L(We)),a===n?(M=t,t=n):(o=X(),o===n?(M=t,t=n):(s=ea(),s===n?(M=t,t=n):(N=t,t=sr(s)))))),t===n&&(t=M,r=e.substr(M,2),r.toLowerCase()===`on`?M+=2:(r=n,P===0&&L(Je)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=e.substr(M,6),a.toLowerCase()===f?M+=6:(a=n,P===0&&L(Ye)),a===n?(M=t,t=n):(o=X(),o===n?(M=t,t=n):(s=ea(),s===n?(M=t,t=n):(N=t,t=cr(s))))))),F[c]={nextPos:M,result:t},t)}function z(){let t,r,i,a,o=M*132+18,s=F[o];return s?(M=s.nextPos,s.result):(t=M,r=e.substr(M,6),r.toLowerCase()===f?M+=6:(r=n,P===0&&L(Ye)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=ba(),a===n?(M=t,t=n):(N=t,t=lr(a))),F[o]={nextPos:M,result:t},t)}function ea(){let t,r,i,a,o,s,c,l,u,d,f=M*132+19,p=F[f];if(p)return M=p.nextPos,p.result;if(t=M,r=e.substr(M,3),r.toLowerCase()===`set`?M+=3:(r=n,P===0&&L(Xe)),r!==n){for(i=X(),i===n&&(i=null),a=M,o=[],s=ta();s!==n;)o.push(s),s=M,c=M,l=X(),l===n&&(l=null),e.charCodeAt(M)===44?(u=`,`,M++):(u=n,P===0&&L(Ze)),u===n?(M=c,c=n):(d=X(),d===n&&(d=null),l=[l,u,d],c=l),c===n?s=c:(c=ta(),c===n?(M=s,s=n):s=c);o.length<1?(M=a,a=n):a=o,a===n?(M=t,t=n):(N=t,t=ur(a))}else M=t,t=n;return F[f]={nextPos:M,result:t},t}function ta(){let t,r,i,a,o,s,c=M*132+20,l=F[c];return l?(M=l.nextPos,l.result):(t=M,r=Na(),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===61?(a=`=`,M++):(a=n,P===0&&L(Qe)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=V(),s===n?(M=t,t=n):(N=t,t=dr(r,s)))),t===n&&(t=M,r=Y(),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===61?(a=`=`,M++):(a=n,P===0&&L(Qe)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=V(),s===n?(M=t,t=n):(N=t,t=fr(r,s)))),t===n&&(t=M,r=Y(),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.substr(M,2)===`+=`?(a=`+=`,M+=2):(a=n,P===0&&L($e)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=V(),s===n?(M=t,t=n):(N=t,t=pr(r,s)))),t===n&&(t=M,r=Y(),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=Aa(),a===n?(M=t,t=n):(N=t,t=mr(r,a)))))),F[c]={nextPos:M,result:t},t)}function na(){let t,r,i,a,o,s,c,l,u,d,f,h=M*132+21,g=F[h];if(g)return M=g.nextPos,g.result;if(t=M,r=M,i=e.substr(M,6),i.toLowerCase()===p?M+=6:(i=n,P===0&&L(et)),i===n?(M=r,r=n):(a=X(),a===n?(M=r,r=n):r=i),r===n&&(r=null),i=e.substr(M,6),i.toLowerCase()===m?M+=6:(i=n,P===0&&L(tt)),i!==n){for(a=X(),a===n&&(a=null),o=M,s=[],c=V();c!==n;)s.push(c),c=M,l=M,u=X(),u===n&&(u=null),e.charCodeAt(M)===44?(d=`,`,M++):(d=n,P===0&&L(Ze)),d===n?(M=l,l=n):(f=X(),f===n&&(f=null),u=[u,d,f],l=u),l===n?c=l:(l=V(),l===n?(M=c,c=n):c=l);s.length<1?(M=o,o=n):o=s,o===n?(M=t,t=n):(N=t,t=hr(r,o))}else M=t,t=n;return F[h]={nextPos:M,result:t},t}function ra(){let t,r,i,a,o,s,c,l,u,d,f=M*132+22,p=F[f];if(p)return M=p.nextPos,p.result;if(t=M,r=e.substr(M,6),r.toLowerCase()===h?M+=6:(r=n,P===0&&L(nt)),r!==n){if(i=X(),i!==n){for(a=M,o=[],s=ia();s!==n;)o.push(s),s=M,c=M,l=X(),l===n&&(l=null),e.charCodeAt(M)===44?(u=`,`,M++):(u=n,P===0&&L(Ze)),u===n?(M=c,c=n):(d=X(),d===n&&(d=null),l=[l,u,d],c=l),c===n?s=c:(c=ia(),c===n?(M=s,s=n):s=c);o.length<1?(M=a,a=n):a=o,a===n?(M=t,t=n):(N=t,t=gr(a))}else M=t,t=n}else M=t,t=n;return F[f]={nextPos:M,result:t},t}function ia(){let e,t,r,i=M*132+23,a=F[i];return a?(M=a.nextPos,a.result):(e=M,t=Y(),t===n?(M=e,e=n):(r=Aa(),r===n?(M=e,e=n):(N=e,e=_r(t,r))),e===n&&(e=M,t=Na(),t!==n&&(N=e,t=vr(t)),e=t),F[i]={nextPos:M,result:e},e)}function aa(){let t,r,i,a,o,s,c,l,u,d=M*132+24,f=F[d];return f?(M=f.nextPos,f.result):(t=M,r=e.substr(M,4),r.toLowerCase()===g?M+=4:(r=n,P===0&&L(rt)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=go(),a===n?(M=t,t=n):(o=M,s=X(),s===n&&(s=null),c=e.substr(M,5),c.toLowerCase()===_?M+=5:(c=n,P===0&&L(it)),c===n?(M=o,o=n):(l=X(),l===n?(M=o,o=n):(u=la(),u===n?(M=o,o=n):o=u)),o===n&&(o=null),N=t,t=yr(a,o)))),F[d]={nextPos:M,result:t},t)}function oa(){let t,r,i,a,o,s,c,l,u,d=M*132+25,f=F[d];return f?(M=f.nextPos,f.result):(t=M,r=e.substr(M,4),r.toLowerCase()===g?M+=4:(r=n,P===0&&L(rt)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=sa(),a===n?(M=t,t=n):(o=M,s=X(),s===n&&(s=null),c=e.substr(M,5),c.toLowerCase()===_?M+=5:(c=n,P===0&&L(it)),c===n?(M=o,o=n):(l=X(),l===n?(M=o,o=n):(u=ca(),u===n?(M=o,o=n):(s=[s,c,l,u],o=s))),o===n&&(o=null),N=t,t=br(a,o)))),F[d]={nextPos:M,result:t},t)}function sa(){let e,t=M*132+26,r=F[t];return r?(M=r.nextPos,r.result):(e=go(),e===n&&(e=_o()),F[t]={nextPos:M,result:e},e)}function ca(){let t,r=M*132+27,i=F[r];return i?(M=i.nextPos,i.result):(e.charCodeAt(M)===42?(t=`*`,M++):(t=n,P===0&&L(at)),t===n&&(t=la()),F[r]={nextPos:M,result:t},t)}function la(){let t,r,i,a,o,s,c,l,u=M*132+28,d=F[u];if(d)return M=d.nextPos,d.result;for(t=M,r=M,i=[],a=ua();a!==n;)i.push(a),a=M,o=M,s=X(),s===n&&(s=null),e.charCodeAt(M)===44?(c=`,`,M++):(c=n,P===0&&L(Ze)),c===n?(M=o,o=n):(l=X(),l===n&&(l=null),s=[s,c,l],o=s),o===n?a=o:(o=ua(),o===n?(M=a,a=n):a=o);return i.length<1?(M=r,r=n):r=i,r===n?(M=t,t=n):(i=M,a=X(),a===n&&(a=null),o=ya(),o===n?(M=i,i=n):i=o,i===n&&(i=null),r=[r,i],t=r),F[u]={nextPos:M,result:t},t}function ua(){let t,r,i,a,o,s,c=M*132+29,l=F[c];return l?(M=l.nextPos,l.result):(t=M,r=M,i=Y(),i===n?(M=r,r=n):(a=X(),a===n?(M=r,r=n):(o=e.substr(M,2),o.toLowerCase()===`as`?M+=2:(o=n,P===0&&L(Ke)),o===n?(M=r,r=n):(s=X(),s===n?(M=r,r=n):r=i))),r===n&&(r=null),i=Y(),i===n?(M=t,t=n):(r=[r,i],t=r),F[c]={nextPos:M,result:t},t)}function da(){let t,r,i,a,o,s,c=M*132+30,l=F[c];return l?(M=l.nextPos,l.result):(t=M,r=e.substr(M,4),r.toLowerCase()===v?M+=4:(r=n,P===0&&L(ot)),r===n?(M=t,t=n):(i=B(),i===n?(M=t,t=n):(a=M,o=X(),o===n&&(o=null),s=ya(),s===n?(M=a,a=n):a=s,a===n&&(a=null),N=t,t=xr(i,a))),F[c]={nextPos:M,result:t},t)}function fa(){let t,r,i,a=M*132+31,o=F[a];return o?(M=o.nextPos,o.result):(t=M,r=e.substr(M,6),r.toLowerCase()===y?M+=6:(r=n,P===0&&L(st)),r===n?(M=t,t=n):(i=B(),i===n?(M=t,t=n):(N=t,t=Sr(i))),F[a]={nextPos:M,result:t},t)}function B(){let t,r,i,a,o,s,c,l,u,d=M*132+32,f=F[d];return f?(M=f.nextPos,f.result):(t=M,r=M,i=X(),i===n&&(i=null),a=e.substr(M,8),a.toLowerCase()===b?M+=8:(a=n,P===0&&L(ct)),a===n?(M=r,r=n):r=a,r===n&&(r=null),i=X(),i===n?(M=t,t=n):(a=pa(),a===n?(M=t,t=n):(o=M,s=X(),s===n?(M=o,o=n):(c=ha(),c===n?(M=o,o=n):o=c),o===n&&(o=null),s=M,c=X(),c===n?(M=s,s=n):(l=ga(),l===n?(M=s,s=n):s=l),s===n&&(s=null),c=M,l=X(),l===n?(M=c,c=n):(u=_a(),u===n?(M=c,c=n):c=u),c===n&&(c=null),N=t,t=Cr(r,a,o,s,c))),F[d]={nextPos:M,result:t},t)}function pa(){let t,r,i,a,o,s,c,l,u=M*132+33,d=F[u];if(d)return M=d.nextPos,d.result;if(t=M,e.charCodeAt(M)===42?(r=`*`,M++):(r=n,P===0&&L(at)),r!==n){for(i=[],a=M,o=X(),o===n&&(o=null),e.charCodeAt(M)===44?(s=`,`,M++):(s=n,P===0&&L(Ze)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),l=ma(),l===n?(M=a,a=n):a=l);a!==n;)i.push(a),a=M,o=X(),o===n&&(o=null),e.charCodeAt(M)===44?(s=`,`,M++):(s=n,P===0&&L(Ze)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),l=ma(),l===n?(M=a,a=n):a=l);N=t,t=wr(i)}else M=t,t=n;if(t===n){for(t=M,r=[],i=ma();i!==n;)r.push(i),i=M,a=M,o=X(),o===n&&(o=null),e.charCodeAt(M)===44?(s=`,`,M++):(s=n,P===0&&L(Ze)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),o=[o,s,c],a=o),a===n?i=a:(a=ma(),a===n?(M=i,i=n):i=a);r.length<1?(M=t,t=n):t=r}return F[u]={nextPos:M,result:t},t}function ma(){let t,r,i,a,o,s,c=M*132+34,l=F[c];return l?(M=l.nextPos,l.result):(t=M,r=V(),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=e.substr(M,2),a.toLowerCase()===`as`?M+=2:(a=n,P===0&&L(Ke)),a===n?(M=t,t=n):(o=X(),o===n?(M=t,t=n):(s=Y(),s===n?(M=t,t=n):t=[r,s])))),t===n&&(t=V()),F[c]={nextPos:M,result:t},t)}function ha(){let t,r,i,a,o,s,c,l,u,d,f,p,m=M*132+35,h=F[m];if(h)return M=h.nextPos,h.result;if(t=M,r=e.substr(M,5),r.toLowerCase()===x?M+=5:(r=n,P===0&&L(lt)),r!==n){if(i=X(),i!==n){if(a=e.substr(M,2),a.toLowerCase()===`by`?M+=2:(a=n,P===0&&L(ut)),a!==n){if(o=X(),o!==n){for(s=M,c=[],l=va();l!==n;)c.push(l),l=M,u=M,d=X(),d===n&&(d=null),e.charCodeAt(M)===44?(f=`,`,M++):(f=n,P===0&&L(Ze)),f===n?(M=u,u=n):(p=X(),p===n&&(p=null),d=[d,f,p],u=d),u===n?l=u:(u=va(),u===n?(M=l,l=n):l=u);c.length<1?(M=s,s=n):s=c,s===n?(M=t,t=n):t=s}else M=t,t=n}else M=t,t=n}else M=t,t=n}else M=t,t=n;return F[m]={nextPos:M,result:t},t}function ga(){let t,r,i,a,o=M*132+36,s=F[o];return s?(M=s.nextPos,s.result):(t=M,r=e.substr(M,4),r.toLowerCase()===S?M+=4:(r=n,P===0&&L(dt)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=V(),a===n?(M=t,t=n):t=a)),F[o]={nextPos:M,result:t},t)}function _a(){let t,r,i,a,o=M*132+37,s=F[o];return s?(M=s.nextPos,s.result):(t=M,r=e.substr(M,5),r.toLowerCase()===C?M+=5:(r=n,P===0&&L(ft)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=V(),a===n?(M=t,t=n):t=a)),F[o]={nextPos:M,result:t},t)}function va(){let t,r,i,a,o,s=M*132+38,c=F[s];return c?(M=c.nextPos,c.result):(t=M,r=V(),r===n?(M=t,t=n):(i=M,a=X(),a===n&&(a=null),o=e.substr(M,9),o.toLowerCase()===w?M+=9:(o=n,P===0&&L(pt)),o===n&&(o=e.substr(M,3),o.toLowerCase()===`asc`?M+=3:(o=n,P===0&&L(mt)),o===n&&(o=e.substr(M,10),o.toLowerCase()===ee?M+=10:(o=n,P===0&&L(ht)),o===n&&(o=e.substr(M,4),o.toLowerCase()===te?M+=4:(o=n,P===0&&L(gt))))),o===n?(M=i,i=n):i=o,i===n&&(i=null),N=t,t=Tr(r,i)),F[s]={nextPos:M,result:t},t)}function ya(){let t,r,i,a,o=M*132+39,s=F[o];return s?(M=s.nextPos,s.result):(t=M,r=e.substr(M,5),r.toLowerCase()===ne?M+=5:(r=n,P===0&&L(_t)),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=V(),a===n?(M=t,t=n):t=a)),F[o]={nextPos:M,result:t},t)}function ba(){let t,r,i,a,o,s,c,l=M*132+40,u=F[l];if(u)return M=u.nextPos,u.result;for(t=M,r=[],i=xa();i!==n;)r.push(i),i=M,a=M,o=X(),o===n&&(o=null),e.charCodeAt(M)===44?(s=`,`,M++):(s=n,P===0&&L(Ze)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),o=[o,s,c],a=o),a===n?i=a:(a=xa(),a===n?(M=i,i=n):i=a);return r.length<1?(M=t,t=n):t=r,F[l]={nextPos:M,result:t},t}function xa(){let t,r,i,a,o,s,c=M*132+41,l=F[c];return l?(M=l.nextPos,l.result):(t=M,r=Y(),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===61?(a=`=`,M++):(a=n,P===0&&L(Qe)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=Sa(),s===n?(M=t,t=n):(N=t,t=Er(r,s)))),t===n&&(t=Sa()),F[c]={nextPos:M,result:t},t)}function Sa(){let t,r,i,a,o,s,c=M*132+42,l=F[c];if(l)return M=l.nextPos,l.result;if(t=M,r=wa(),r!==n){for(i=[],a=M,o=X(),o===n&&(o=null),s=Ta(),s===n?(M=a,a=n):a=s;a!==n;)i.push(a),a=M,o=X(),o===n&&(o=null),s=Ta(),s===n?(M=a,a=n):a=s;N=t,t=Dr(r,i)}else M=t,t=n;return t===n&&(t=M,e.charCodeAt(M)===40?(r=`(`,M++):(r=n,P===0&&L(vt)),r===n?(M=t,t=n):(i=Sa(),i===n?(M=t,t=n):(e.charCodeAt(M)===41?(a=`)`,M++):(a=n,P===0&&L(yt)),a===n?(M=t,t=n):t=i))),F[c]={nextPos:M,result:t},t}function Ca(){let e,t,r,i,a,o,s=M*132+43,c=F[s];if(c)return M=c.nextPos,c.result;if(e=M,t=wa(),t!==n){if(r=[],i=M,a=X(),a===n&&(a=null),o=Ta(),o===n?(M=i,i=n):i=o,i!==n)for(;i!==n;)r.push(i),i=M,a=X(),a===n&&(a=null),o=Ta(),o===n?(M=i,i=n):i=o;else r=n;r===n?(M=e,e=n):e=[t,r]}else M=e,e=n;return F[s]={nextPos:M,result:e},e}function wa(){let t,r,i,a,o,s,c,l,u=M*132+44,d=F[u];return d?(M=d.nextPos,d.result):(t=M,e.charCodeAt(M)===40?(r=`(`,M++):(r=n,P===0&&L(vt)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=M,o=Y(),o===n?(M=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),o=M,s=Aa(),s===n?(M=o,o=n):(c=X(),c===n&&(c=null),o=s),o===n&&(o=null),s=M,c=Oa(),c===n?(M=s,s=n):(l=X(),l===n&&(l=null),s=c),s===n&&(s=null),e.charCodeAt(M)===41?(c=`)`,M++):(c=n,P===0&&L(yt)),c===n?(M=t,t=n):(N=t,t=Or(a,o,s))),F[u]={nextPos:M,result:t},t)}function Ta(){let e,t,r,i,a=M*132+45,o=F[a];return o?(M=o.nextPos,o.result):(e=M,t=Ea(),t===n?(M=e,e=n):(r=X(),r===n&&(r=null),i=wa(),i===n?(M=e,e=n):e=[t,i]),F[a]={nextPos:M,result:e},e)}function Ea(){let e,t,r,i,a,o,s,c,l=M*132+46,u=F[l];return u?(M=u.nextPos,u.result):(e=M,t=Ko(),t===n?(M=e,e=n):(r=X(),r===n&&(r=null),i=Jo(),i===n?(M=e,e=n):(a=X(),a===n&&(a=null),o=Da(),o===n&&(o=null),s=X(),s===n&&(s=null),c=Jo(),c===n?(M=e,e=n):(N=e,e=kr(o)))),e===n&&(e=M,t=Jo(),t===n?(M=e,e=n):(r=X(),r===n&&(r=null),i=Da(),i===n&&(i=null),a=X(),a===n&&(a=null),o=Jo(),o===n?(M=e,e=n):(s=X(),s===n&&(s=null),c=qo(),c===n?(M=e,e=n):(N=e,e=Ar(i)))),e===n&&(e=M,t=Jo(),t===n?(M=e,e=n):(r=X(),r===n&&(r=null),i=Da(),i===n&&(i=null),a=X(),a===n&&(a=null),o=Jo(),o===n?(M=e,e=n):(N=e,e=jr(i))))),F[l]={nextPos:M,result:e},e)}function Da(){let t,r,i,a,o,s,c,l,u,d=M*132+47,f=F[d];return f?(M=f.nextPos,f.result):(t=M,e.charCodeAt(M)===91?(r=`[`,M++):(r=n,P===0&&L(bt)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=M,o=Y(),o===n?(M=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),o=M,s=ka(),s===n?(M=o,o=n):(c=X(),c===n&&(c=null),o=s),o===n&&(o=null),s=Ma(),s===n&&(s=null),c=M,l=Oa(),l===n?(M=c,c=n):(u=X(),u===n&&(u=null),c=l),c===n&&(c=null),e.charCodeAt(M)===93?(l=`]`,M++):(l=n,P===0&&L(xt)),l===n?(M=t,t=n):(N=t,t=Mr(a,o,s,c))),F[d]={nextPos:M,result:t},t)}function Oa(){let e,t=M*132+48,r=F[t];return r?(M=r.nextPos,r.result):(e=Io(),e===n&&(e=Lo()),F[t]={nextPos:M,result:e},e)}function ka(){let t,r,i,a,o,s,c,l=M*132+49,u=F[l];if(u)return M=u.nextPos,u.result;for(t=M,r=[],i=M,e.charCodeAt(M)===58?(a=`:`,M++):(a=n,P===0&&L(St)),a===n?(M=i,i=n):(o=X(),o===n&&(o=null),s=Ro(),s===n?(M=i,i=n):i=s);i!==n;)r.push(i),i=M,a=M,o=X(),o===n&&(o=null),e.charCodeAt(M)===124?(s=`|`,M++):(s=n,P===0&&L(Ct)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),o=[o,s,c],a=o),a===n?i=a:(a=M,e.charCodeAt(M)===58?(o=`:`,M++):(o=n,P===0&&L(St)),o===n?(M=a,a=n):(s=X(),s===n&&(s=null),c=Ro(),c===n?(M=a,a=n):a=c),a===n?(M=i,i=n):i=a);return r.length<1?(M=t,t=n):t=r,F[l]={nextPos:M,result:t},t}function Aa(){let e,t,r,i,a=M*132+50,o=F[a];if(o)return M=o.nextPos,o.result;for(e=M,t=[],r=ja();r!==n;)t.push(r),r=M,i=X(),i===n&&(i=null),i=ja(),i===n?(M=r,r=n):r=i;return t.length<1?(M=e,e=n):e=t,F[a]={nextPos:M,result:e},e}function ja(){let t,r,i,a,o=M*132+51,s=F[o];return s?(M=s.nextPos,s.result):(t=M,e.charCodeAt(M)===58?(r=`:`,M++):(r=n,P===0&&L(St)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=Ro(),a===n?(M=t,t=n):t=a),F[o]={nextPos:M,result:t},t)}function Ma(){let t,r,i,a,o,s,c,l,u,d,f=M*132+52,p=F[f];return p?(M=p.nextPos,p.result):(t=M,e.charCodeAt(M)===42?(r=`*`,M++):(r=n,P===0&&L(at)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=M,o=M,s=q(),o=s===n?s:e.substring(o,M),o===n?(M=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),o=M,e.substr(M,2)===`..`?(s=`..`,M+=2):(s=n,P===0&&L(wt)),s===n?(M=o,o=n):(c=X(),c===n&&(c=null),l=M,u=M,d=q(),u=d===n?d:e.substring(u,M),u===n?(M=l,l=n):(d=X(),d===n&&(d=null),l=u),l===n&&(l=null),o=[s,l]),o===n&&(o=null),N=t,t=Nr(a,o)),F[f]={nextPos:M,result:t},t)}function Na(){let e,t,r,i,a,o,s=M*132+53,c=F[s];if(c)return M=c.nextPos,c.result;if(e=M,t=ro(),t!==n){if(r=[],i=M,a=X(),a===n&&(a=null),o=no(),o===n?(M=i,i=n):i=o,i!==n)for(;i!==n;)r.push(i),i=M,a=X(),a===n&&(a=null),o=no(),o===n?(M=i,i=n):i=o;else r=n;r===n?(M=e,e=n):(N=e,e=Pr(t,r))}else M=e,e=n;return F[s]={nextPos:M,result:e},e}function V(){let t,r,i,a,o,s,c,l,u=M*132+54,d=F[u];if(d)return M=d.nextPos,d.result;if(t=M,r=Pa(),r!==n){for(i=[],a=M,o=X(),o===n?(M=a,a=n):(s=e.substr(M,2),s.toLowerCase()===`or`?M+=2:(s=n,P===0&&L(Tt)),s===n?(M=a,a=n):(c=X(),c===n?(M=a,a=n):(l=Pa(),l===n?(M=a,a=n):a=l)));a!==n;)i.push(a),a=M,o=X(),o===n?(M=a,a=n):(s=e.substr(M,2),s.toLowerCase()===`or`?M+=2:(s=n,P===0&&L(Tt)),s===n?(M=a,a=n):(c=X(),c===n?(M=a,a=n):(l=Pa(),l===n?(M=a,a=n):a=l)));N=t,t=Fr(r,i)}else M=t,t=n;return F[u]={nextPos:M,result:t},t}function Pa(){let t,r,i,a,o,s,c,l,u=M*132+55,d=F[u];if(d)return M=d.nextPos,d.result;if(t=M,r=Fa(),r!==n){for(i=[],a=M,o=X(),o===n?(M=a,a=n):(s=e.substr(M,3),s.toLowerCase()===`xor`?M+=3:(s=n,P===0&&L(Et)),s===n?(M=a,a=n):(c=X(),c===n?(M=a,a=n):(l=Fa(),l===n?(M=a,a=n):a=l)));a!==n;)i.push(a),a=M,o=X(),o===n?(M=a,a=n):(s=e.substr(M,3),s.toLowerCase()===`xor`?M+=3:(s=n,P===0&&L(Et)),s===n?(M=a,a=n):(c=X(),c===n?(M=a,a=n):(l=Fa(),l===n?(M=a,a=n):a=l)));N=t,t=Ir(r,i)}else M=t,t=n;return F[u]={nextPos:M,result:t},t}function Fa(){let t,r,i,a,o,s,c,l,u=M*132+56,d=F[u];if(d)return M=d.nextPos,d.result;if(t=M,r=Ia(),r!==n){for(i=[],a=M,o=X(),o===n?(M=a,a=n):(s=e.substr(M,3),s.toLowerCase()===`and`?M+=3:(s=n,P===0&&L(Dt)),s===n?(M=a,a=n):(c=X(),c===n?(M=a,a=n):(l=Ia(),l===n?(M=a,a=n):a=l)));a!==n;)i.push(a),a=M,o=X(),o===n?(M=a,a=n):(s=e.substr(M,3),s.toLowerCase()===`and`?M+=3:(s=n,P===0&&L(Dt)),s===n?(M=a,a=n):(c=X(),c===n?(M=a,a=n):(l=Ia(),l===n?(M=a,a=n):a=l)));N=t,t=Lr(r,i)}else M=t,t=n;return F[u]={nextPos:M,result:t},t}function Ia(){let t,r,i,a,o,s=M*132+57,c=F[s];if(c)return M=c.nextPos,c.result;for(t=M,r=[],i=M,a=e.substr(M,3),a.toLowerCase()===`not`?M+=3:(a=n,P===0&&L(Ot)),a===n?(M=i,i=n):(o=X(),o===n&&(o=null),i=a);i!==n;)r.push(i),i=M,a=e.substr(M,3),a.toLowerCase()===`not`?M+=3:(a=n,P===0&&L(Ot)),a===n?(M=i,i=n):(o=X(),o===n&&(o=null),i=a);return i=La(),i===n?(M=t,t=n):(N=t,t=Rr(r,i)),F[s]={nextPos:M,result:t},t}function La(){let e,t,r,i,a,o,s=M*132+58,c=F[s];if(c)return M=c.nextPos,c.result;if(e=M,t=Ba(),t!==n){for(r=[],i=M,a=X(),a===n&&(a=null),o=Ra(),o===n?(M=i,i=n):i=o;i!==n;)r.push(i),i=M,a=X(),a===n&&(a=null),o=Ra(),o===n?(M=i,i=n):i=o;N=e,e=zr(t,r)}else M=e,e=n;return F[s]={nextPos:M,result:e},e}function Ra(){let e,t,r,i,a=M*132+59,o=F[a];return o?(M=o.nextPos,o.result):(e=M,t=za(),t===n?(M=e,e=n):(r=X(),r===n&&(r=null),i=Ba(),i===n?(M=e,e=n):e=[t,i]),F[a]={nextPos:M,result:e},e)}function za(){let t,r=M*132+60,i=F[r];return i?(M=i.nextPos,i.result):(e.charCodeAt(M)===61?(t=`=`,M++):(t=n,P===0&&L(Qe)),t===n&&(e.substr(M,2)===`<>`?(t=`<>`,M+=2):(t=n,P===0&&L(kt)),t===n&&(e.substr(M,2)===`<=`?(t=`<=`,M+=2):(t=n,P===0&&L(At)),t===n&&(e.substr(M,2)===`>=`?(t=`>=`,M+=2):(t=n,P===0&&L(jt)),t===n&&(t=e.charAt(M),_e.test(t)?M++:(t=n,P===0&&L(Mt)))))),F[r]={nextPos:M,result:t},t)}function Ba(){let e,t,r,i,a=M*132+61,o=F[a];if(o)return M=o.nextPos,o.result;if(e=M,t=Ka(),t!==n){for(r=[],i=Va();i!==n;)r.push(i),i=Va();N=e,e=Br(t,r)}else M=e,e=n;return F[a]={nextPos:M,result:e},e}function Va(){let e,t=M*132+62,r=F[t];return r?(M=r.nextPos,r.result):(e=Ha(),e===n&&(e=Wa(),e===n&&(e=Ga())),F[t]={nextPos:M,result:e},e)}function Ha(){let e,t,r,i,a=M*132+63,o=F[a];return o?(M=o.nextPos,o.result):(e=M,t=Ua(),t===n?(M=e,e=n):(r=X(),r===n&&(r=null),i=Ka(),i===n?(M=e,e=n):e=[t,i]),F[a]={nextPos:M,result:e},e)}function Ua(){let t,r,i,a,o,s=M*132+64,c=F[s];return c?(M=c.nextPos,c.result):(t=M,r=X(),r===n?(M=t,t=n):(i=e.substr(M,6),i.toLowerCase()===re?M+=6:(i=n,P===0&&L(Nt)),i===n?(M=t,t=n):(a=X(),a===n?(M=t,t=n):(o=e.substr(M,4),o.toLowerCase()===v?M+=4:(o=n,P===0&&L(ot)),o===n?(M=t,t=n):(N=t,t=Vr())))),t===n&&(t=M,r=X(),r===n?(M=t,t=n):(i=e.substr(M,4),i.toLowerCase()===ie?M+=4:(i=n,P===0&&L(Pt)),i===n?(M=t,t=n):(a=X(),a===n?(M=t,t=n):(o=e.substr(M,4),o.toLowerCase()===v?M+=4:(o=n,P===0&&L(ot)),o===n?(M=t,t=n):(N=t,t=Hr())))),t===n&&(t=M,r=X(),r===n?(M=t,t=n):(i=e.substr(M,8),i.toLowerCase()===ae?M+=8:(i=n,P===0&&L(Ft)),i===n?(M=t,t=n):t=i))),F[s]={nextPos:M,result:t},t)}function Wa(){let t,r,i,a,o,s=M*132+65,c=F[s];return c?(M=c.nextPos,c.result):(t=M,r=X(),r===n?(M=t,t=n):(i=e.substr(M,2),i.toLowerCase()===`in`?M+=2:(i=n,P===0&&L(It)),i===n?(M=t,t=n):(a=X(),a===n&&(a=null),o=Ka(),o===n?(M=t,t=n):t=[i,o])),F[s]={nextPos:M,result:t},t)}function Ga(){let t,r,i,a,o,s,c,l=M*132+66,u=F[l];return u?(M=u.nextPos,u.result):(t=M,r=X(),r===n?(M=t,t=n):(i=e.substr(M,2),i.toLowerCase()===`is`?M+=2:(i=n,P===0&&L(Lt)),i===n?(M=t,t=n):(a=X(),a===n?(M=t,t=n):(o=e.substr(M,4),o.toLowerCase()===oe?M+=4:(o=n,P===0&&L(Rt)),o===n?(M=t,t=n):(N=t,t=Ur())))),t===n&&(t=M,r=X(),r===n?(M=t,t=n):(i=e.substr(M,2),i.toLowerCase()===`is`?M+=2:(i=n,P===0&&L(Lt)),i===n?(M=t,t=n):(a=X(),a===n?(M=t,t=n):(o=e.substr(M,3),o.toLowerCase()===`not`?M+=3:(o=n,P===0&&L(Ot)),o===n?(M=t,t=n):(s=X(),s===n?(M=t,t=n):(c=e.substr(M,4),c.toLowerCase()===oe?M+=4:(c=n,P===0&&L(Rt)),c===n?(M=t,t=n):(N=t,t=Wr()))))))),F[l]={nextPos:M,result:t},t)}function Ka(){let e,t,r,i,a,o,s,c,l=M*132+67,u=F[l];if(u)return M=u.nextPos,u.result;if(e=M,t=Ja(),t!==n){for(r=[],i=M,a=X(),a===n&&(a=null),o=qa(),o===n?(M=i,i=n):(s=X(),s===n&&(s=null),c=Ja(),c===n?(M=i,i=n):i=[o,c]);i!==n;)r.push(i),i=M,a=X(),a===n&&(a=null),o=qa(),o===n?(M=i,i=n):(s=X(),s===n&&(s=null),c=Ja(),c===n?(M=i,i=n):i=[o,c]);N=e,e=Gr(t,r)}else M=e,e=n;return F[l]={nextPos:M,result:e},e}function qa(){let t,r=M*132+68,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),ve.test(t)?M++:(t=n,P===0&&L(zt)),F[r]={nextPos:M,result:t},t)}function Ja(){let e,t,r,i,a,o,s,c,l=M*132+69,u=F[l];if(u)return M=u.nextPos,u.result;if(e=M,t=Xa(),t!==n){for(r=[],i=M,a=X(),a===n&&(a=null),o=Ya(),o===n?(M=i,i=n):(s=X(),s===n&&(s=null),c=Xa(),c===n?(M=i,i=n):i=[o,c]);i!==n;)r.push(i),i=M,a=X(),a===n&&(a=null),o=Ya(),o===n?(M=i,i=n):(s=X(),s===n&&(s=null),c=Xa(),c===n?(M=i,i=n):i=[o,c]);N=e,e=Kr(t,r)}else M=e,e=n;return F[l]={nextPos:M,result:e},e}function Ya(){let t,r=M*132+70,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),ye.test(t)?M++:(t=n,P===0&&L(Bt)),F[r]={nextPos:M,result:t},t)}function Xa(){let t,r,i,a,o,s,c,l,u=M*132+71,d=F[u];if(d)return M=d.nextPos,d.result;if(t=M,r=Za(),r!==n){for(i=[],a=M,o=X(),o===n&&(o=null),e.charCodeAt(M)===94?(s=`^`,M++):(s=n,P===0&&L(Vt)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),l=Za(),l===n?(M=a,a=n):a=l);a!==n;)i.push(a),a=M,o=X(),o===n&&(o=null),e.charCodeAt(M)===94?(s=`^`,M++):(s=n,P===0&&L(Vt)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),l=Za(),l===n?(M=a,a=n):a=l);N=t,t=qr(r,i)}else M=t,t=n;return F[u]={nextPos:M,result:t},t}function Za(){let e,t,r,i,a=M*132+72,o=F[a];return o?(M=o.nextPos,o.result):(e=Qa(),e===n&&(e=M,t=qa(),t===n?(M=e,e=n):(r=X(),r===n&&(r=null),i=Qa(),i===n?(M=e,e=n):(N=e,e=Jr(t,i)))),F[a]={nextPos:M,result:e},e)}function Qa(){let e,t,r,i,a,o=M*132+73,s=F[o];return s?(M=s.nextPos,s.result):(e=M,t=eo(),t===n?(M=e,e=n):(r=M,i=X(),i===n&&(i=null),a=Aa(),a===n?(M=r,r=n):r=a,r===n&&(r=null),N=e,e=Yr(t,r)),F[o]={nextPos:M,result:e},e)}function $a(){let e,t=M*132+74,r=F[t];return r?(M=r.nextPos,r.result):(e=to(),e===n&&(e=no()),F[t]={nextPos:M,result:e},e)}function eo(){let e,t,r,i,a,o,s=M*132+75,c=F[s];if(c)return M=c.nextPos,c.result;if(e=M,t=ro(),t!==n){for(r=[],i=M,a=X(),a===n&&(a=null),o=$a(),o===n?(M=i,i=n):i=o;i!==n;)r.push(i),i=M,a=X(),a===n&&(a=null),o=$a(),o===n?(M=i,i=n):i=o;N=e,e=Xr(t,r)}else M=e,e=n;return F[s]={nextPos:M,result:e},e}function to(){let t,r,i,a,o,s,c=M*132+76,l=F[c];return l?(M=l.nextPos,l.result):(t=M,e.charCodeAt(M)===91?(r=`[`,M++):(r=n,P===0&&L(bt)),r===n?(M=t,t=n):(i=V(),i===n?(M=t,t=n):(e.charCodeAt(M)===93?(a=`]`,M++):(a=n,P===0&&L(xt)),a===n?(M=t,t=n):(N=t,t=Zr(i)))),t===n&&(t=M,e.charCodeAt(M)===91?(r=`[`,M++):(r=n,P===0&&L(bt)),r===n?(M=t,t=n):(i=V(),i===n&&(i=null),e.substr(M,2)===`..`?(a=`..`,M+=2):(a=n,P===0&&L(wt)),a===n?(M=t,t=n):(o=V(),o===n&&(o=null),e.charCodeAt(M)===93?(s=`]`,M++):(s=n,P===0&&L(xt)),s===n?(M=t,t=n):t=[i,o]))),F[c]={nextPos:M,result:t},t)}function no(){let t,r,i,a,o=M*132+77,s=F[o];return s?(M=s.nextPos,s.result):(t=M,e.charCodeAt(M)===46?(r=`.`,M++):(r=n,P===0&&L(Ht)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=Ro(),a===n?(M=t,t=n):t=a),F[o]={nextPos:M,result:t},t)}function ro(){let t,r,i,a,o,s,c,l,u=M*132+78,d=F[u];return d?(M=d.nextPos,d.result):(t=vo(),t===n&&(t=io(),t===n&&(t=Lo(),t===n&&(t=H(),t===n&&(t=M,r=e.substr(M,5),r.toLowerCase()===se?M+=5:(r=n,P===0&&L(Ut)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===40?(a=`(`,M++):(a=n,P===0&&L(vt)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),e.charCodeAt(M)===42?(s=`*`,M++):(s=n,P===0&&L(at)),s===n?(M=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(M)===41?(l=`)`,M++):(l=n,P===0&&L(yt)),l===n?(M=t,t=n):(N=t,t=Qr())))),t===n&&(t=U(),t===n&&(t=oo(),t===n&&(t=so(),t===n&&(t=uo(),t===n&&(t=W(),t===n&&(t=po(),t===n&&(t=ho(),t===n&&(t=Y())))))))))))),F[u]={nextPos:M,result:t},t)}function io(){let t,r,i,a,s,c,l=M*132+79,u=F[l];if(u)return M=u.nextPos,u.result;if(t=M,r=e.substr(M,4),r.toLowerCase()===o?M+=4:(r=n,P===0&&L(Wt)),r!==n){if(i=X(),i!==n){if(a=M,s=[],c=e.charAt(M),be.test(c)?M++:(c=n,P===0&&L(Gt)),c!==n)for(;c!==n;)s.push(c),c=e.charAt(M),be.test(c)?M++:(c=n,P===0&&L(Gt));else s=n;a=s===n?s:e.substring(a,M),a===n?(M=t,t=n):(N=t,t=$r(a))}else M=t,t=n}else M=t,t=n;return F[l]={nextPos:M,result:t},t}function H(){let t,r,i,a,o,s,c,l,u,d,f=M*132+80,p=F[f];if(p)return M=p.nextPos,p.result;if(t=M,r=e.substr(M,4),r.toLowerCase()===ce?M+=4:(r=n,P===0&&L(Kt)),r!==n){if(i=[],a=M,o=X(),o===n&&(o=null),s=ao(),s===n?(M=a,a=n):a=s,a!==n)for(;a!==n;)i.push(a),a=M,o=X(),o===n&&(o=null),s=ao(),s===n?(M=a,a=n):a=s;else i=n;i===n?(M=t,t=n):(a=M,o=X(),o===n&&(o=null),s=e.substr(M,4),s.toLowerCase()===le?M+=4:(s=n,P===0&&L(qt)),s===n?(M=a,a=n):(c=X(),c===n&&(c=null),l=V(),l===n?(M=a,a=n):a=l),a===n&&(a=null),o=X(),o===n&&(o=null),s=e.substr(M,3),s.toLowerCase()===`end`?M+=3:(s=n,P===0&&L(Jt)),s===n?(M=t,t=n):(N=t,t=ei(i,a)))}else M=t,t=n;if(t===n){if(t=M,r=e.substr(M,4),r.toLowerCase()===ce?M+=4:(r=n,P===0&&L(Kt)),r!==n){if(i=X(),i===n&&(i=null),a=V(),a!==n){if(o=[],s=M,c=X(),c===n&&(c=null),l=ao(),l===n?(M=s,s=n):s=l,s!==n)for(;s!==n;)o.push(s),s=M,c=X(),c===n&&(c=null),l=ao(),l===n?(M=s,s=n):s=l;else o=n;o===n?(M=t,t=n):(s=M,c=X(),c===n&&(c=null),l=e.substr(M,4),l.toLowerCase()===le?M+=4:(l=n,P===0&&L(qt)),l===n?(M=s,s=n):(u=X(),u===n&&(u=null),d=V(),d===n?(M=s,s=n):s=d),s===n&&(s=null),c=X(),c===n&&(c=null),l=e.substr(M,3),l.toLowerCase()===`end`?M+=3:(l=n,P===0&&L(Jt)),l===n?(M=t,t=n):(N=t,t=ti(a,o,s)))}else M=t,t=n}else M=t,t=n}return F[f]={nextPos:M,result:t},t}function ao(){let t,r,i,a,o,s,c,l,u=M*132+81,d=F[u];return d?(M=d.nextPos,d.result):(t=M,r=e.substr(M,4),r.toLowerCase()===ue?M+=4:(r=n,P===0&&L(Yt)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=V(),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=e.substr(M,4),s.toLowerCase()===de?M+=4:(s=n,P===0&&L(k)),s===n?(M=t,t=n):(c=X(),c===n&&(c=null),l=V(),l===n?(M=t,t=n):t=[a,l]))),F[u]={nextPos:M,result:t},t)}function U(){let t,r,i,a,o,s,c,l,u,d=M*132+82,f=F[d];return f?(M=f.nextPos,f.result):(t=M,e.charCodeAt(M)===91?(r=`[`,M++):(r=n,P===0&&L(bt)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=lo(),a===n?(M=t,t=n):(o=M,s=X(),s===n&&(s=null),e.charCodeAt(M)===124?(c=`|`,M++):(c=n,P===0&&L(Ct)),c===n?(M=o,o=n):(l=X(),l===n&&(l=null),u=V(),u===n?(M=o,o=n):o=u),o===n&&(o=null),s=X(),s===n&&(s=null),e.charCodeAt(M)===93?(c=`]`,M++):(c=n,P===0&&L(xt)),c===n?(M=t,t=n):(N=t,t=ni(a,o)))),F[d]={nextPos:M,result:t},t)}function oo(){let t,r,i,a,o,s,c,l,u,d,f,p,m=M*132+83,h=F[m];return h?(M=h.nextPos,h.result):(t=M,e.charCodeAt(M)===91?(r=`[`,M++):(r=n,P===0&&L(bt)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=M,o=Y(),o===n?(M=a,a=n):(s=X(),s===n&&(s=null),e.charCodeAt(M)===61?(c=`=`,M++):(c=n,P===0&&L(Qe)),c===n?(M=a,a=n):(l=X(),l===n&&(l=null),a=o)),a===n&&(a=null),o=Ca(),o===n?(M=t,t=n):(s=X(),s===n&&(s=null),c=M,l=ya(),l===n?(M=c,c=n):(u=X(),u===n&&(u=null),c=l),c===n&&(c=null),e.charCodeAt(M)===124?(l=`|`,M++):(l=n,P===0&&L(Ct)),l===n?(M=t,t=n):(u=X(),u===n&&(u=null),d=V(),d===n?(M=t,t=n):(f=X(),f===n&&(f=null),e.charCodeAt(M)===93?(p=`]`,M++):(p=n,P===0&&L(xt)),p===n?(M=t,t=n):(N=t,t=ri(a,o,c,d)))))),F[m]={nextPos:M,result:t},t)}function so(){let t,r,i,a,o,s,c,l,u=M*132+84,d=F[u];return d?(M=d.nextPos,d.result):(t=M,r=co(),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===40?(a=`(`,M++):(a=n,P===0&&L(vt)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=lo(),s===n?(M=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(M)===41?(l=`)`,M++):(l=n,P===0&&L(yt)),l===n?(M=t,t=n):(N=t,t=ii(r,s))))),F[u]={nextPos:M,result:t},t)}function co(){let t,r=M*132+85,i=F[r];return i?(M=i.nextPos,i.result):(t=e.substr(M,3),t.toLowerCase()===`all`?M+=3:(t=n,P===0&&L(He)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`any`?M+=3:(t=n,P===0&&L(Xt)),t===n&&(t=e.substr(M,4),t.toLowerCase()===T?M+=4:(t=n,P===0&&L(Zt)),t===n&&(t=e.substr(M,6),t.toLowerCase()===fe?M+=6:(t=n,P===0&&L(Qt))))),F[r]={nextPos:M,result:t},t)}function lo(){let e,t,r,i,a,o=M*132+86,s=F[o];return s?(M=s.nextPos,s.result):(e=M,t=fo(),t===n?(M=e,e=n):(r=M,i=X(),i===n&&(i=null),a=ya(),a===n?(M=r,r=n):r=a,r===n&&(r=null),N=e,e=ai(t,r)),F[o]={nextPos:M,result:e},e)}function uo(){let e,t,r=M*132+87,i=F[r];return i?(M=i.nextPos,i.result):(e=M,t=Ca(),t!==n&&(N=e,t=oi(t)),e=t,F[r]={nextPos:M,result:e},e)}function W(){let t,r,i,a,o,s,c=M*132+88,l=F[c];return l?(M=l.nextPos,l.result):(t=M,e.charCodeAt(M)===40?(r=`(`,M++):(r=n,P===0&&L(vt)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),a=V(),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),e.charCodeAt(M)===41?(s=`)`,M++):(s=n,P===0&&L(yt)),s===n?(M=t,t=n):t=a)),F[c]={nextPos:M,result:t},t)}function fo(){let t,r,i,a,o,s,c=M*132+89,l=F[c];return l?(M=l.nextPos,l.result):(t=M,r=Y(),r===n?(M=t,t=n):(i=X(),i===n?(M=t,t=n):(a=e.substr(M,2),a.toLowerCase()===`in`?M+=2:(a=n,P===0&&L(It)),a===n?(M=t,t=n):(o=X(),o===n?(M=t,t=n):(s=V(),s===n?(M=t,t=n):t=[r,s])))),F[c]={nextPos:M,result:t},t)}function po(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h,g=M*132+90,_=F[g];if(_)return M=_.nextPos,_.result;if(t=M,r=mo(),r!==n){if(i=X(),i===n&&(i=null),e.charCodeAt(M)===40?(a=`(`,M++):(a=n,P===0&&L(vt)),a!==n){for(o=X(),o===n&&(o=null),s=M,c=e.substr(M,8),c.toLowerCase()===b?M+=8:(c=n,P===0&&L(ct)),c===n?(M=s,s=n):(l=X(),l===n&&(l=null),s=c),s===n&&(s=null),c=M,l=M,u=[],d=V();d!==n;)u.push(d),d=M,f=M,p=X(),p===n&&(p=null),e.charCodeAt(M)===44?(m=`,`,M++):(m=n,P===0&&L(Ze)),m===n?(M=f,f=n):(h=X(),h===n&&(h=null),p=[p,m,h],f=p),f===n?d=f:(f=V(),f===n?(M=d,d=n):d=f);u.length<1?(M=l,l=n):l=u,l===n?(M=c,c=n):(u=X(),u===n&&(u=null),c=l),c===n&&(c=null),e.charCodeAt(M)===41?(l=`)`,M++):(l=n,P===0&&L(yt)),l===n?(M=t,t=n):(N=t,t=si(r,s,c))}else M=t,t=n}else M=t,t=n;return F[g]={nextPos:M,result:t},t}function mo(){let e,t,r=M*132+91,i=F[r];return i?(M=i.nextPos,i.result):(e=M,K(),t=Y(),t===n?(M=e,e=n):(N=e,e=ci()),F[r]={nextPos:M,result:e},e)}function ho(){let t,r,i,a,o,s,c,l,u,d=M*132+92,f=F[d];return f?(M=f.nextPos,f.result):(t=M,r=e.substr(M,6),r.toLowerCase()===pe?M+=6:(r=n,P===0&&L($t)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===123?(a=`{`,M++):(a=n,P===0&&L(en)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=Vi(),s===n?(M=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(M)===125?(l=`}`,M++):(l=n,P===0&&L(tn)),l===n?(M=t,t=n):(N=t,t=li(s))))),t===n&&(t=M,r=e.substr(M,6),r.toLowerCase()===pe?M+=6:(r=n,P===0&&L($t)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===123?(a=`{`,M++):(a=n,P===0&&L(en)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=ba(),s===n?(M=t,t=n):(c=M,l=X(),l===n&&(l=null),u=ya(),u===n?(M=c,c=n):c=u,c===n&&(c=null),l=X(),l===n&&(l=null),e.charCodeAt(M)===125?(u=`}`,M++):(u=n,P===0&&L(tn)),u===n?(M=t,t=n):(N=t,t=ui(s,c))))),t===n&&(t=M,r=e.substr(M,6),r.toLowerCase()===pe?M+=6:(r=n,P===0&&L($t)),r===n?(M=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(M)===123?(a=`{`,M++):(a=n,P===0&&L(en)),a===n?(M=t,t=n):(o=X(),o===n&&(o=null),s=io(),s===n?(M=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(M)===125?(l=`}`,M++):(l=n,P===0&&L(tn)),l===n?(M=t,t=n):(N=t,t=di(s))))))),F[d]={nextPos:M,result:t},t)}function go(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h=M*132+93,g=F[h];if(g)return M=g.nextPos,g.result;if(t=M,r=G(),r!==n){if(i=X(),i===n&&(i=null),e.charCodeAt(M)===40?(a=`(`,M++):(a=n,P===0&&L(vt)),a!==n){for(o=X(),o===n&&(o=null),s=M,c=M,l=[],u=V();u!==n;)l.push(u),u=M,d=M,f=X(),f===n&&(f=null),e.charCodeAt(M)===44?(p=`,`,M++):(p=n,P===0&&L(Ze)),p===n?(M=d,d=n):(m=X(),m===n&&(m=null),f=[f,p,m],d=f),d===n?u=d:(d=V(),d===n?(M=u,u=n):u=d);l.length<1?(M=c,c=n):c=l,c===n?(M=s,s=n):(l=X(),l===n&&(l=null),s=c),s===n&&(s=null),e.charCodeAt(M)===41?(c=`)`,M++):(c=n,P===0&&L(yt)),c===n?(M=t,t=n):(N=t,t=fi(r,s))}else M=t,t=n}else M=t,t=n;return F[h]={nextPos:M,result:t},t}function _o(){let e,t,r=M*132+94,i=F[r];return i?(M=i.nextPos,i.result):(e=M,t=G(),t!==n&&(N=e,t=pi(t)),e=t,F[r]={nextPos:M,result:e},e)}function G(){let e,t,r=M*132+95,i=F[r];return i?(M=i.nextPos,i.result):(e=M,K(),t=Y(),t===n?(M=e,e=n):(N=e,e=mi()),F[r]={nextPos:M,result:e},e)}function K(){let t,r,i,a,o=M*132+96,s=F[o];if(s)return M=s.nextPos,s.result;for(t=[],r=M,i=Y(),i===n?(M=r,r=n):(e.charCodeAt(M)===46?(a=`.`,M++):(a=n,P===0&&L(Ht)),a===n?(M=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=M,i=Y(),i===n?(M=r,r=n):(e.charCodeAt(M)===46?(a=`.`,M++):(a=n,P===0&&L(Ht)),a===n?(M=r,r=n):(i=[i,a],r=i));return F[o]={nextPos:M,result:t},t}function vo(){let t,r,i,a=M*132+97,o=F[a];return o?(M=o.nextPos,o.result):(t=M,r=yo(),r!==n&&(N=t,r=hi(r)),t=r,t===n&&(t=M,r=e.substr(M,4),r.toLowerCase()===oe?M+=4:(r=n,P===0&&L(Rt)),r!==n&&(N=t,r=gi(r)),t=r,t===n&&(t=M,r=M,i=bo(),r=i===n?i:e.substring(r,M),r!==n&&(N=t,r=_i(r)),t=r,t===n&&(t=M,r=M,i=No(),r=i===n?i:e.substring(r,M),r!==n&&(N=t,r=vi(r)),t=r,t===n&&(t=Fo(),t===n&&(t=Io()))))),F[a]={nextPos:M,result:t},t)}function yo(){let t,r=M*132+98,i=F[r];return i?(M=i.nextPos,i.result):(t=e.substr(M,4),t.toLowerCase()===me?M+=4:(t=n,P===0&&L(nn)),t===n&&(t=e.substr(M,5),t.toLowerCase()===he?M+=5:(t=n,P===0&&L(rn))),F[r]={nextPos:M,result:t},t)}function bo(){let e,t=M*132+99,r=F[t];return r?(M=r.nextPos,r.result):(e=Ao(),e===n&&(e=q()),F[t]={nextPos:M,result:e},e)}function q(){let e,t=M*132+100,r=F[t];return r?(M=r.nextPos,r.result):(e=xo(),e===n&&(e=Co(),e===n&&(e=wo(),e===n&&(e=So()))),F[t]={nextPos:M,result:e},e)}function xo(){let t,r,i,a,o=M*132+101,s=F[o];if(s)return M=s.nextPos,s.result;if(t=M,e.substr(M,2)===`0x`?(r=`0x`,M+=2):(r=n,P===0&&L(an)),r!==n){if(i=[],a=J(),a!==n)for(;a!==n;)i.push(a),a=J();else i=n;i===n?(M=t,t=n):(r=[r,i],t=r)}else M=t,t=n;return F[o]={nextPos:M,result:t},t}function So(){let e,t,r,i,a=M*132+102,o=F[a];if(o)return M=o.nextPos,o.result;if(e=ko(),e===n){if(e=M,t=Do(),t!==n){for(r=[],i=Eo();i!==n;)r.push(i),i=Eo();t=[t,r],e=t}else M=e,e=n}return F[a]={nextPos:M,result:e},e}function Co(){let t,r,i,a,o=M*132+103,s=F[o];if(s)return M=s.nextPos,s.result;if(t=M,e.substr(M,2)===`0o`?(r=`0o`,M+=2):(r=n,P===0&&L(on)),r!==n){if(i=[],a=Oo(),a!==n)for(;a!==n;)i.push(a),a=Oo();else i=n;i===n?(M=t,t=n):(r=[r,i],t=r)}else M=t,t=n;return F[o]={nextPos:M,result:t},t}function wo(){let t,r,i,a,o=M*132+104,s=F[o];if(s)return M=s.nextPos,s.result;if(t=M,e.substr(M,2)===`0b`?(r=`0b`,M+=2):(r=n,P===0&&L(sn)),r!==n){if(i=[],a=e.charAt(M),xe.test(a)?M++:(a=n,P===0&&L(cn)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(M),xe.test(a)?M++:(a=n,P===0&&L(cn));else i=n;i===n?(M=t,t=n):(r=[r,i],t=r)}else M=t,t=n;return F[o]={nextPos:M,result:t},t}function To(){let t,r=M*132+105,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),Se.test(t)?M++:(t=n,P===0&&L(ln)),F[r]={nextPos:M,result:t},t)}function J(){let e,t=M*132+106,r=F[t];return r?(M=r.nextPos,r.result):(e=Eo(),e===n&&(e=To()),F[t]={nextPos:M,result:e},e)}function Eo(){let t,r=M*132+107,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),Ce.test(t)?M++:(t=n,P===0&&L(un)),F[r]={nextPos:M,result:t},t)}function Do(){let t,r=M*132+108,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),we.test(t)?M++:(t=n,P===0&&L(dn)),F[r]={nextPos:M,result:t},t)}function Oo(){let t,r=M*132+109,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),E.test(t)?M++:(t=n,P===0&&L(fn)),F[r]={nextPos:M,result:t},t)}function ko(){let t,r=M*132+110,i=F[r];return i?(M=i.nextPos,i.result):(e.charCodeAt(M)===48?(t=`0`,M++):(t=n,P===0&&L(pn)),F[r]={nextPos:M,result:t},t)}function Ao(){let e,t=M*132+111,r=F[t];return r?(M=r.nextPos,r.result):(e=jo(),e===n&&(e=Mo()),F[t]={nextPos:M,result:e},e)}function jo(){let t,r,i,a,o,s,c,l,u=M*132+112,d=F[u];if(d)return M=d.nextPos,d.result;if(t=M,r=[],i=Eo(),i!==n)for(;i!==n;)r.push(i),i=Eo();else r=n;if(r!==n){if(i=e.charAt(M),i.toLowerCase()===`e`?M++:(i=n,P===0&&L(mn)),i!==n){if(e.charCodeAt(M)===45?(a=`-`,M++):(a=n,P===0&&L(hn)),a===n&&(a=null),o=[],s=Eo(),s!==n)for(;s!==n;)o.push(s),s=Eo();else o=n;o===n?(M=t,t=n):(r=[r,i,a,o],t=r)}else M=t,t=n}else M=t,t=n;if(t===n){for(t=M,r=[],i=Eo();i!==n;)r.push(i),i=Eo();if(e.charCodeAt(M)===46?(i=`.`,M++):(i=n,P===0&&L(Ht)),i!==n){if(a=[],o=Eo(),o!==n)for(;o!==n;)a.push(o),o=Eo();else a=n;if(a!==n){if(o=e.charAt(M),o.toLowerCase()===`e`?M++:(o=n,P===0&&L(mn)),o!==n){if(e.charCodeAt(M)===45?(s=`-`,M++):(s=n,P===0&&L(hn)),s===n&&(s=null),c=[],l=Eo(),l!==n)for(;l!==n;)c.push(l),l=Eo();else c=n;c===n?(M=t,t=n):(r=[r,i,a,o,s,c],t=r)}else M=t,t=n}else M=t,t=n}else M=t,t=n}return F[u]={nextPos:M,result:t},t}function Mo(){let t,r,i,a,o,s=M*132+113,c=F[s];if(c)return M=c.nextPos,c.result;for(t=M,r=[],i=Eo();i!==n;)r.push(i),i=Eo();if(e.charCodeAt(M)===46?(i=`.`,M++):(i=n,P===0&&L(Ht)),i!==n){if(a=[],o=Eo(),o!==n)for(;o!==n;)a.push(o),o=Eo();else a=n;a===n?(M=t,t=n):(r=[r,i,a],t=r)}else M=t,t=n;return F[s]={nextPos:M,result:t},t}function No(){let t,r,i,a,o=M*132+114,s=F[o];if(s)return M=s.nextPos,s.result;if(t=M,e.charCodeAt(M)===34?(r=`"`,M++):(r=n,P===0&&L(gn)),r!==n){for(i=[],a=e.charAt(M),D.test(a)?M++:(a=n,P===0&&L(_n)),a===n&&(a=Po());a!==n;)i.push(a),a=e.charAt(M),D.test(a)?M++:(a=n,P===0&&L(_n)),a===n&&(a=Po());e.charCodeAt(M)===34?(a=`"`,M++):(a=n,P===0&&L(gn)),a===n?(M=t,t=n):(r=[r,i,a],t=r)}else M=t,t=n;if(t===n){if(t=M,e.charCodeAt(M)===39?(r=`'`,M++):(r=n,P===0&&L(vn)),r!==n){for(i=[],a=e.charAt(M),O.test(a)?M++:(a=n,P===0&&L(yn)),a===n&&(a=Po());a!==n;)i.push(a),a=e.charAt(M),O.test(a)?M++:(a=n,P===0&&L(yn)),a===n&&(a=Po());e.charCodeAt(M)===39?(a=`'`,M++):(a=n,P===0&&L(vn)),a===n?(M=t,t=n):(r=[r,i,a],t=r)}else M=t,t=n}return F[o]={nextPos:M,result:t},t}function Po(){let t,r,i,a=M*132+115,o=F[a];return o?(M=o.nextPos,o.result):(t=M,e.charCodeAt(M)===92?(r=`\\`,M++):(r=n,P===0&&L(bn)),r===n?(M=t,t=n):(e.length>M?(i=e.charAt(M),M++):(i=n,P===0&&L(Ie)),i===n?(M=t,t=n):(r=[r,i],t=r)),F[a]={nextPos:M,result:t},t)}function Fo(){let t,r,i,a,o,s,c,l,u,d,f,p=M*132+116,m=F[p];if(m)return M=m.nextPos,m.result;if(t=M,e.charCodeAt(M)===91?(r=`[`,M++):(r=n,P===0&&L(bt)),r!==n){for(i=X(),i===n&&(i=null),a=M,o=M,s=[],c=V();c!==n;)s.push(c),c=M,l=M,u=X(),u===n&&(u=null),e.charCodeAt(M)===44?(d=`,`,M++):(d=n,P===0&&L(Ze)),d===n?(M=l,l=n):(f=X(),f===n&&(f=null),u=[u,d,f],l=u),l===n?c=l:(l=V(),l===n?(M=c,c=n):c=l);s.length<1?(M=o,o=n):o=s,o===n?(M=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),e.charCodeAt(M)===93?(o=`]`,M++):(o=n,P===0&&L(xt)),o===n?(M=t,t=n):(N=t,t=yi(a))}else M=t,t=n;return F[p]={nextPos:M,result:t},t}function Io(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h=M*132+117,g=F[h];if(g)return M=g.nextPos,g.result;if(t=M,e.charCodeAt(M)===123?(r=`{`,M++):(r=n,P===0&&L(en)),r!==n){for(i=X(),i===n&&(i=null),a=M,o=M,s=[],c=M,l=Ro(),l===n?(M=c,c=n):(u=X(),u===n&&(u=null),e.charCodeAt(M)===58?(d=`:`,M++):(d=n,P===0&&L(St)),d===n?(M=c,c=n):(f=X(),f===n&&(f=null),p=V(),p===n?(M=c,c=n):c=[l,p]));c!==n;)s.push(c),c=M,l=M,u=X(),u===n&&(u=null),e.charCodeAt(M)===44?(d=`,`,M++):(d=n,P===0&&L(Ze)),d===n?(M=l,l=n):(f=X(),f===n&&(f=null),u=[u,d,f],l=u),l===n?c=l:(l=M,u=Ro(),u===n?(M=l,l=n):(d=X(),d===n&&(d=null),e.charCodeAt(M)===58?(f=`:`,M++):(f=n,P===0&&L(St)),f===n?(M=l,l=n):(p=X(),p===n&&(p=null),m=V(),m===n?(M=l,l=n):l=[u,m])),l===n?(M=c,c=n):c=l);s.length<1?(M=o,o=n):o=s,o===n?(M=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),e.charCodeAt(M)===125?(o=`}`,M++):(o=n,P===0&&L(tn)),o===n?(M=t,t=n):(N=t,t=bi(a))}else M=t,t=n;return F[h]={nextPos:M,result:t},t}function Lo(){let t,r,i,a,o=M*132+118,s=F[o];return s?(M=s.nextPos,s.result):(t=M,e.charCodeAt(M)===36?(r=`$`,M++):(r=n,P===0&&L(xn)),r===n?(M=t,t=n):(i=M,a=Y(),a===n&&(a=So()),i=a===n?a:e.substring(i,M),i===n?(M=t,t=n):(N=t,t=xi(i))),F[o]={nextPos:M,result:t},t)}function Ro(){let e,t,r=M*132+119,i=F[r];return i?(M=i.nextPos,i.result):(e=Y(),e===n&&(e=M,t=zo(),t!==n&&(N=e,t=Si(t)),e=t),F[r]={nextPos:M,result:e},e)}function zo(){let t,r=M*132+120,i=F[r];return i?(M=i.nextPos,i.result):(t=e.substr(M,3),t.toLowerCase()===`all`?M+=3:(t=n,P===0&&L(He)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`asc`?M+=3:(t=n,P===0&&L(mt)),t===n&&(t=e.substr(M,9),t.toLowerCase()===w?M+=9:(t=n,P===0&&L(pt)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`by`?M+=2:(t=n,P===0&&L(ut)),t===n&&(t=e.substr(M,6),t.toLowerCase()===f?M+=6:(t=n,P===0&&L(Ye)),t===n&&(t=e.substr(M,6),t.toLowerCase()===m?M+=6:(t=n,P===0&&L(tt)),t===n&&(t=e.substr(M,4),t.toLowerCase()===te?M+=4:(t=n,P===0&&L(gt)),t===n&&(t=e.substr(M,10),t.toLowerCase()===ee?M+=10:(t=n,P===0&&L(ht)),t===n&&(t=e.substr(M,6),t.toLowerCase()===p?M+=6:(t=n,P===0&&L(et)),t===n&&(t=e.substr(M,6),t.toLowerCase()===pe?M+=6:(t=n,P===0&&L($t)),t===n&&(t=e.substr(M,5),t.toLowerCase()===C?M+=5:(t=n,P===0&&L(ft)),t===n&&(t=e.substr(M,5),t.toLowerCase()===l?M+=5:(t=n,P===0&&L(We)),t===n&&(t=e.substr(M,5),t.toLowerCase()===d?M+=5:(t=n,P===0&&L(qe)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`on`?M+=2:(t=n,P===0&&L(Je)),t===n&&(t=e.substr(M,8),t.toLowerCase()===c?M+=8:(t=n,P===0&&L(Ue)),t===n&&(t=e.substr(M,5),t.toLowerCase()===x?M+=5:(t=n,P===0&&L(lt)),t===n&&(t=e.substr(M,6),t.toLowerCase()===h?M+=6:(t=n,P===0&&L(nt)),t===n&&(t=e.substr(M,6),t.toLowerCase()===y?M+=6:(t=n,P===0&&L(st)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`set`?M+=3:(t=n,P===0&&L(Xe)),t===n&&(t=e.substr(M,4),t.toLowerCase()===S?M+=4:(t=n,P===0&&L(dt)),t===n&&(t=e.substr(M,5),t.toLowerCase()===ne?M+=5:(t=n,P===0&&L(_t)),t===n&&(t=e.substr(M,4),t.toLowerCase()===v?M+=4:(t=n,P===0&&L(ot)),t===n&&(t=e.substr(M,5),t.toLowerCase()===s?M+=5:(t=n,P===0&&L(Ve)),t===n&&(t=e.substr(M,6),t.toLowerCase()===u?M+=6:(t=n,P===0&&L(Ge)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`and`?M+=3:(t=n,P===0&&L(Dt)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`as`?M+=2:(t=n,P===0&&L(Ke)),t===n&&(t=e.substr(M,8),t.toLowerCase()===ae?M+=8:(t=n,P===0&&L(Ft)),t===n&&(t=e.substr(M,8),t.toLowerCase()===b?M+=8:(t=n,P===0&&L(ct)),t===n&&(t=e.substr(M,4),t.toLowerCase()===ie?M+=4:(t=n,P===0&&L(Pt)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`in`?M+=2:(t=n,P===0&&L(It)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`is`?M+=2:(t=n,P===0&&L(Lt)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`not`?M+=3:(t=n,P===0&&L(Ot)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`or`?M+=2:(t=n,P===0&&L(Tt)),t===n&&(t=e.substr(M,6),t.toLowerCase()===re?M+=6:(t=n,P===0&&L(Nt)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`xor`?M+=3:(t=n,P===0&&L(Et)),t===n&&(t=e.substr(M,5),t.toLowerCase()===he?M+=5:(t=n,P===0&&L(rn)),t===n&&(t=e.substr(M,4),t.toLowerCase()===me?M+=4:(t=n,P===0&&L(nn)),t===n&&(t=e.substr(M,4),t.toLowerCase()===oe?M+=4:(t=n,P===0&&L(Rt)),t===n&&(t=e.substr(M,10),t.toLowerCase()===`constraint`?M+=10:(t=n,P===0&&L(Sn)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`do`?M+=2:(t=n,P===0&&L(Cn)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`for`?M+=3:(t=n,P===0&&L(wn)),t===n&&(t=e.substr(M,7),t.toLowerCase()===`require`?M+=7:(t=n,P===0&&L(Tn)),t===n&&(t=e.substr(M,6),t.toLowerCase()===`unique`?M+=6:(t=n,P===0&&L(En)),t===n&&(t=e.substr(M,4),t.toLowerCase()===ce?M+=4:(t=n,P===0&&L(Kt)),t===n&&(t=e.substr(M,4),t.toLowerCase()===ue?M+=4:(t=n,P===0&&L(Yt)),t===n&&(t=e.substr(M,4),t.toLowerCase()===de?M+=4:(t=n,P===0&&L(k)),t===n&&(t=e.substr(M,4),t.toLowerCase()===le?M+=4:(t=n,P===0&&L(qt)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`end`?M+=3:(t=n,P===0&&L(Jt)),t===n&&(t=e.substr(M,9),t.toLowerCase()===`mandatory`?M+=9:(t=n,P===0&&L(Dn)),t===n&&(t=e.substr(M,6),t.toLowerCase()===`scalar`?M+=6:(t=n,P===0&&L(On)),t===n&&(t=e.substr(M,2),t.toLowerCase()===`of`?M+=2:(t=n,P===0&&L(kn)),t===n&&(t=e.substr(M,3),t.toLowerCase()===`add`?M+=3:(t=n,P===0&&L(An)),t===n&&(t=e.substr(M,4),t.toLowerCase()===`drop`?M+=4:(t=n,P===0&&L(jn)))))))))))))))))))))))))))))))))))))))))))))))))))))),F[r]={nextPos:M,result:t},t)}function Y(){let t,r,i=M*132+121,a=F[i];return a?(M=a.nextPos,a.result):(t=M,r=Bo(),r===n&&(r=Uo(),r===n&&(r=e.substr(M,5),r.toLowerCase()===se?M+=5:(r=n,P===0&&L(Ut)),r===n&&(r=e.substr(M,6),r.toLowerCase()===`filter`?M+=6:(r=n,P===0&&L(Mn)),r===n&&(r=e.substr(M,7),r.toLowerCase()===`extract`?M+=7:(r=n,P===0&&L(Nn)),r===n&&(r=e.substr(M,3),r.toLowerCase()===`any`?M+=3:(r=n,P===0&&L(Xt)),r===n&&(r=e.substr(M,4),r.toLowerCase()===T?M+=4:(r=n,P===0&&L(Zt)),r===n&&(r=e.substr(M,6),r.toLowerCase()===fe?M+=6:(r=n,P===0&&L(Qt))))))))),r!==n&&(N=t,r=Ci()),t=r,F[i]={nextPos:M,result:t},t)}function Bo(){let e,t,r,i,a=M*132+122,o=F[a];if(o)return M=o.nextPos,o.result;if(e=M,t=Vo(),t!==n){for(r=[],i=Ho();i!==n;)r.push(i),i=Ho();t=[t,r],e=t}else M=e,e=n;return F[a]={nextPos:M,result:e},e}function Vo(){let e,t=M*132+123,r=F[t];return r?(M=r.nextPos,r.result):(e=Ai(),Te.test(e)?M+=e.length:(e=n,P===0&&L(Pn)),F[t]={nextPos:M,result:e},e)}function Ho(){let e,t=M*132+124,r=F[t];return r?(M=r.nextPos,r.result):(e=Ai(),Ee.test(e)?M+=e.length:(e=n,P===0&&L(Fn)),F[t]={nextPos:M,result:e},e)}function Uo(){let t,r,i,a,o,s=M*132+125,c=F[s];if(c)return M=c.nextPos,c.result;if(t=[],r=M,e.charCodeAt(M)===96?(i="`",M++):(i=n,P===0&&L(A)),i!==n){for(a=[],o=e.charAt(M),De.test(o)?M++:(o=n,P===0&&L(In));o!==n;)a.push(o),o=e.charAt(M),De.test(o)?M++:(o=n,P===0&&L(In));e.charCodeAt(M)===96?(o="`",M++):(o=n,P===0&&L(A)),o===n?(M=r,r=n):(i=[i,a,o],r=i)}else M=r,r=n;if(r!==n)for(;r!==n;)if(t.push(r),r=M,e.charCodeAt(M)===96?(i="`",M++):(i=n,P===0&&L(A)),i!==n){for(a=[],o=e.charAt(M),De.test(o)?M++:(o=n,P===0&&L(In));o!==n;)a.push(o),o=e.charAt(M),De.test(o)?M++:(o=n,P===0&&L(In));e.charCodeAt(M)===96?(o="`",M++):(o=n,P===0&&L(A)),o===n?(M=r,r=n):(i=[i,a,o],r=i)}else M=r,r=n;else t=n;return F[s]={nextPos:M,result:t},t}function X(){let e,t,r=M*132+126,i=F[r];if(i)return M=i.nextPos,i.result;if(e=[],t=Wo(),t!==n)for(;t!==n;)e.push(t),t=Wo();else e=n;return F[r]={nextPos:M,result:e},e}function Wo(){let e,t=M*132+127,r=F[t];return r?(M=r.nextPos,r.result):(e=Ai(),Oe.test(e)?M+=e.length:(e=n,P===0&&L(j)),e===n&&(e=Go()),F[t]={nextPos:M,result:e},e)}function Go(){let t,r,i,a,o,s,c=M*132+128,l=F[c];if(l)return M=l.nextPos,l.result;if(t=M,e.substr(M,2)===`/*`?(r=`/*`,M+=2):(r=n,P===0&&L(Ln)),r!==n){for(i=[],a=e.charAt(M),ke.test(a)?M++:(a=n,P===0&&L(Rn)),a===n&&(a=M,e.charCodeAt(M)===42?(o=`*`,M++):(o=n,P===0&&L(at)),o===n?(M=a,a=n):(s=e.charAt(M),Ae.test(s)?M++:(s=n,P===0&&L(zn)),s===n?(M=a,a=n):(o=[o,s],a=o)));a!==n;)i.push(a),a=e.charAt(M),ke.test(a)?M++:(a=n,P===0&&L(Rn)),a===n&&(a=M,e.charCodeAt(M)===42?(o=`*`,M++):(o=n,P===0&&L(at)),o===n?(M=a,a=n):(s=e.charAt(M),Ae.test(s)?M++:(s=n,P===0&&L(zn)),s===n?(M=a,a=n):(o=[o,s],a=o)));e.substr(M,2)===`*/`?(a=`*/`,M+=2):(a=n,P===0&&L(Bn)),a===n?(M=t,t=n):(r=[r,i,a],t=r)}else M=t,t=n;if(t===n){if(t=M,e.substr(M,2)===`//`?(r=`//`,M+=2):(r=n,P===0&&L(Vn)),r!==n){for(i=[],a=e.charAt(M),je.test(a)?M++:(a=n,P===0&&L(Hn));a!==n;)i.push(a),a=e.charAt(M),je.test(a)?M++:(a=n,P===0&&L(Hn));e.charCodeAt(M)===13?(a=`\r`,M++):(a=n,P===0&&L(Un)),a===n&&(a=null),e.charCodeAt(M)===10?(o=`
|
|
323
|
+
`,M++):(o=n,P===0&&L(Wn)),o===n&&(o=M,P++,e.length>M?(s=e.charAt(M),M++):(s=n,P===0&&L(Ie)),P--,s===n?o=void 0:(M=o,o=n)),o===n?(M=t,t=n):(r=[r,i,a,o],t=r)}else M=t,t=n}return F[c]={nextPos:M,result:t},t}function Ko(){let t,r=M*132+129,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),Me.test(t)?M++:(t=n,P===0&&L(Gn)),F[r]={nextPos:M,result:t},t)}function qo(){let t,r=M*132+130,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),Ne.test(t)?M++:(t=n,P===0&&L(Kn)),F[r]={nextPos:M,result:t},t)}function Jo(){let t,r=M*132+131,i=F[r];return i?(M=i.nextPos,i.result):(t=e.charAt(M),Pe.test(t)?M++:(t=n,P===0&&L(qn)),F[r]={nextPos:M,result:t},t)}let Z=t.ast;function Yo(e,t,n){let r=e,i=typeof t==`string`?new Z.CypherIdentifier(t.toLowerCase()):t;for(let e of n)r=new Z.ASTOperator(`cypher`,i,[r,e]);return r}Di=a();let Xo=Di!==n&&M===e.length;function Zo(){throw Di!==n&&M<e.length&&L(Ni()),Ii(Ei,Ti<e.length?Ai(Ti):null,Ti<e.length?Fi(Ti,Ti+1):Fi(Ti,Ti))}if(t.peg$library)return{peg$result:Di,peg$currPos:M,peg$FAILED:n,peg$maxFailExpected:Ei,peg$maxFailPos:Ti,peg$success:Xo,peg$throw:Xo?void 0:Zo};if(Xo)return Di;Zo()}function kl(e){let t={langMgr:e,makeOp:(e,t)=>typeof e==`string`?new Xi(`cypher`,new zc(e.toLowerCase()),t):new Xi(`cypher`,e,t),wrapFn:(e,t=[],n=!1)=>new Ec(new Zi(`cypher`,e,t),n),ast:{...dl,ASTLiteral:Yi,ASTOperator:Xi,ASTFunction:Zi,ASTIdentifier:z,LangSwitch:ea,allAttrs:Qi,boundParam:$i}};return{parse(e){let n=Ol(e,{peg$library:!0,...t});return n.peg$result===n.peg$FAILED&&n.peg$throw(),{value:[n.peg$result.value],remainingInput:n.peg$result.remainingInput}},parseExpr(e){return this.parse(`RETURN ${e}`)}}}var Al=class extends Ds{adapter=this.db.langMgr.getLang(`cypher`).dataAdapter;constructor(e,t){super(`cypher`,e,t)}visitItemSource(e,t){let n=e.name,r=this.db.getSource(n.parts.slice(0,-1));return n.parts.at(-1)===`nodes`?this.adapter.filterNodes(r):this.adapter.filterEdges(r)}},jl={name:`startNode`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getEdgeNode(e.graph,t,`source`))},Ml={name:`endNode`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getEdgeNode(e.graph,t,`target`))},Nl={name:`labels`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getLabels(e.graph,t))},Pl={name:`type`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getType(e.graph,t))},Fl=t({endNode:()=>Ml,labels:()=>Nl,startNode:()=>jl,type:()=>Pl}),Il={name:`+`,impl:Q((e,t)=>Array.isArray(e)&&Array.isArray(t)?[...e,...t]:e+t)},Ll=t({add:()=>Il}),Rl=Symbol(`nodeOrEdgeId`),zl=Symbol(`labelsOrType`),Bl=`__symbol__labelsOrType`,Vl=(e,t)=>{for(let n of e)if(!t.includes(n))return!1;return!0},Hl=class{convertNode(e,t){return t[Rl]=e,t}convertEdge(e,t){return t[Rl]=e,t}*getNodesByLabels(e,...t){for(let{node:n,attributes:r}of e.nodeEntries())Vl(t,r[zl]??[])&&(yield this.convertNode(n,r))}*filterNodes(e,t){if(!t)yield*e.mapNodes(this.convertNode);else for(let{node:n,attributes:r}of e.nodeEntries()){let e=this.convertNode(n,r);t(e)&&(yield e)}}*getEdgesByType(e,t){for(let{edge:n,attributes:r}of e.edgeEntries())r[zl]===t&&(yield this.convertEdge(n,r))}*filterEdges(e,t){if(t)for(let n of e.edgeEntries()){let e=this.convertEdge(n.edge,n.attributes);t(this.convertNode(n.source,n.sourceAttributes),this.convertNode(n.target,n.targetAttributes),e)&&(yield e)}else for(let{edge:t,attributes:n}of e.edgeEntries())yield this.convertEdge(t,n)}*getNodeEdgesByType(e,t,n,r){for(let{edge:i,attributes:a}of e[r===`in`?`inEdgeEntries`:r===`out`?`outEdgeEntries`:`edgeEntries`](t[Rl]))a[zl]===n&&(yield this.convertEdge(i,a))}*filterNodeEdges(e,t,n,r){for(let i of e[n===`in`?`inEdgeEntries`:n===`out`?`outEdgeEntries`:`edgeEntries`](t[Rl])){let e=this.convertEdge(i.edge,i.attributes);r?r(this.convertNode(i.source,i.sourceAttributes),this.convertNode(i.target,i.targetAttributes),e)&&(yield e):yield e}}isConnected(e,t,n,r){let i=n[Rl];return e[r===`in`?`someInboundEdge`:r===`out`?`someOutboundEdge`:`someEdge`](t[Rl],e=>e===i)}hasLabels(e,t,n){return Vl(n,t[zl]??[])}getLabels(e,t){return t==null?null:t[zl]??[]}hasAnyType(e,t,n){return n.includes(t[zl])}getType(e,t){return t==null?null:t[zl]}getEdgeNode(e,t,n){let r=e[n](t[Rl]);return this.convertNode(r,e.getNodeAttributes(r))}static import(e){for(let t of e.nodes)t.attributes[zl]=t.attributes[Bl],delete t.attributes[Bl];for(let t of e.edges)t.attributes[zl]=t.attributes[Bl],delete t.attributes[Bl];return new $t().import(e)}static export(e){let t=e.export();for(let n of t.nodes)n.attributes??={},n.attributes[Bl]=e.getNodeAttributes(n.key)[zl];for(let n of t.edges)n.attributes??={},n.attributes[Bl]=e.getEdgeAttributes(n.key)[zl];return t}};function Ul(e){return{name:`cypher`,operators:[...Object.values(Ll)],aggregates:[],functions:[...Object.values(Fl)],castables:[],visitors:{logicalPlanBuilder:El,executor:Al},createParser:kl,dataAdapter:e?.adapter??new Hl,defaultGraph:e?.defaultGraph&&z.fromParts([e.defaultGraph]),serialize:e?.serialize??Qo()}}var Wl=class{expressions;eqCheckers;calcBuilders;adapter;constructor(e,t){this.expressions=e,this.eqCheckers=t.langMgr.getVisitorMap(`equalityChecker`),this.calcBuilders=t.langMgr.getVisitorMap(`calculationBuilder`),this.adapter=t.langMgr.getLang(`cypher`).dataAdapter}reindex(e){}match(e,t){for(let n=0;n<e.length;n++)if(e[n].containingFn.impl===this.adapter.isConnected){let r=e[n].expr;if(this.matchesFromItemKey(r,t))return[n]}return null}matchesFromItemKey(e,t){for(let n of e instanceof z?[e.parts]:e.getDependencies())if(t?.get(n)?.[0]===fc)return!0;return!1}createAccessor(e){let t=e[0],n=t.expr instanceof z?t.containingFn.args[2]instanceof z&&t.expr.equals(t.containingFn.args[2]):t.expr===t.containingFn.args[2].op;return To(new K(t.containingFn.lang,[t.containingFn.args[0],t.containingFn.args[n?1:2],t.containingFn.args[3]],n?(e,t,n)=>this.adapter.filterNodeEdges(e,t,n):(e,t,n)=>{let r=[];return(n===`any`||n===`in`)&&r.push(this.adapter.getEdgeNode(e,t,`target`)),(n===`any`||n===`out`)&&r.push(this.adapter.getEdgeNode(e,t,`source`)),r}),this.calcBuilders,this.eqCheckers)}},Gl=`vault`,Kl=200,ql={operators:[{name:`in`,impl:(e,t)=>Array.isArray(t)&&e!=null?t.includes(e):null},{name:`contains`,impl:(e,t)=>typeof e==`string`&&typeof t==`string`?e.includes(t):null},{name:`startswith`,impl:(e,t)=>typeof e==`string`&&typeof t==`string`?e.startsWith(t):null},{name:`endswith`,impl:(e,t)=>typeof e==`string`&&typeof t==`string`?e.endsWith(t):null}],functions:[{name:`toLower`,pure:!0,impl:e=>typeof e==`string`?e.toLowerCase():null},{name:`toUpper`,pure:!0,impl:e=>typeof e==`string`?e.toUpperCase():null},{name:`trim`,pure:!0,impl:e=>typeof e==`string`?e.trim():null},{name:`size`,pure:!0,impl:e=>typeof e==`string`||Array.isArray(e)?e.length:null}]},Jl=[`avg`,`collect`,`count`,`endNode`,`labels`,`max`,`min`,`size`,`startNode`,`sum`,`toLower`,`toUpper`,`trim`,`type`];function Yl(e){let t=new pc({mainLang:Ul({defaultGraph:Gl}),extensions:[ql],optimizer:{rules:Tc}});return t.registerSource([Gl],e.graph),t.createIndex([Gl,`nodes`],[],Wl),{run(n){if(!n.trim())return{status:`error`,message:`Write a query to run.`};let r=performance.now();try{let i=t.query(n),a=i.schema??Object.keys(i.data[0]??{}),o=Xl(i.data,e);return{status:`ok`,columns:a.map(Ql),rows:i.data.slice(0,Kl).map(e=>a.map(t=>e[t])),totalRows:i.data.length,nodeIds:[...o.nodes],edgeIds:[...o.edges],elapsedMs:performance.now()-r}}catch(e){return $l(e)}}}}function Xl(e,t){let n=new Set,r=new Set,i=new WeakSet,a=e=>{if(!e||typeof e!=`object`||i.has(e))return;i.add(e);let o=t.nodeIds.get(e);if(o){n.add(o);return}let s=t.edgeIds.get(e);s?r.add(s):Object.values(e).forEach(a)};return e.forEach(a),{nodes:n,edges:r}}function Zl(e,t){return e==null?`null`:typeof e==`object`?t.nodeIds.has(e)?String(e.title??t.nodeIds.get(e)):t.edgeIds.has(e)?`:${String(e[zl])}`:Array.isArray(e)?`[${e.map(e=>Zl(e,t)).join(`, `)}]`:e instanceof Date?e.toISOString():`{${Object.entries(e).map(([e,n])=>`${e}: ${Zl(n,t)}`).join(`, `)}}`:typeof e==`string`?e:String(e)}function Ql(e){return e.replace(/`/g,``)}function $l(e){let t=e instanceof Error?e.message:String(e),n=e?.location;if(n?.start){let e=n.end??n.start;return{status:`error`,message:`Syntax error: ${t}`,location:{line:n.start.line,column:n.start.column,endLine:e.line,endColumn:Math.max(e.column,n.start.column+1)}}}return/only read operations/i.test(t)?{status:`error`,message:`Only read queries run here: CREATE, MERGE, SET, REMOVE and DELETE are not supported.`}:{status:`error`,message:t}}function eu({result:e,source:t}){return(0,R.jsxs)(`div`,{className:`graph-query-rows`,children:[(0,R.jsxs)(`table`,{children:[(0,R.jsx)(`thead`,{children:(0,R.jsx)(`tr`,{children:e.columns.map(e=>(0,R.jsx)(`th`,{scope:`col`,children:e},e))})}),(0,R.jsx)(`tbody`,{children:e.rows.map((e,n)=>(0,R.jsx)(`tr`,{children:e.map((e,n)=>(0,R.jsx)(`td`,{children:Zl(e,t)},n))},n))})]}),e.totalRows>e.rows.length&&(0,R.jsxs)(f,{as:`p`,size:`small`,tone:`muted`,children:[`Showing `,e.rows.length.toLocaleString(),` of `,e.totalRows.toLocaleString(),` rows.`]})]})}var tu=(e,t,n=`${t}s`)=>`${e.toLocaleString()} ${e===1?t:n}`;function nu(e,t){if(!t)return{tone:`muted`,text:`Loading note properties…`};if(!e)return{tone:`muted`,text:`Run a query to show only the notes it returns. ⌘↵ runs, esc closes.`};if(e.status===`error`){let t=e.location?` (line ${e.location.line}, column ${e.location.column})`:``;return{tone:`error`,text:`${e.message}${t}`}}let n=[tu(e.nodeIds.length,`node`),tu(e.edgeIds.length,`relationship`),tu(e.totalRows,`row`)],r=e.nodeIds.length===0?` · no nodes returned, so the graph is empty`:``;return{tone:`ok`,text:`${n.join(` · `)} · ${Math.max(1,Math.round(e.elapsedMs))} ms${r}`}}var ru=(0,T.lazy)(async()=>({default:(await x(async()=>{let{CypherEditor:e}=await import(`./cypher-editor-M9g--02t.js`);return{CypherEditor:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))).CypherEditor}));function iu({draft:e,result:t,schema:n,source:r,ready:i,examples:a,onDraftChange:o,onRun:u,onClear:d,onClose:p}){let[m,g]=(0,T.useState)(!1),_=nu(t,i),v=t?.status===`ok`&&t.rows.length>0&&t.nodeIds.length===0;return(0,R.jsxs)(`section`,{className:`graph-query-bar`,"aria-label":`Cypher query`,children:[(0,R.jsx)(`div`,{className:`graph-query-editor`,children:(0,R.jsx)(T.Suspense,{fallback:(0,R.jsx)(f,{as:`div`,tone:`muted`,className:`graph-query-editor-fallback`,children:`Loading editor…`}),children:(0,R.jsx)(ru,{value:e,schema:n,functions:Jl,autoFocus:!0,error:t?.status===`error`?t:void 0,onChange:o,onRun:()=>u(),onEscape:p})})}),(0,R.jsxs)(`footer`,{className:`graph-query-footer`,children:[(0,R.jsx)(f,{as:`p`,size:`small`,tone:_.tone===`error`?`danger`:`muted`,className:`graph-query-status graph-query-status-${_.tone}`,role:`status`,children:_.text}),(0,R.jsxs)(`div`,{className:`graph-query-actions`,children:[(0,R.jsx)(c,{open:m,onOpenChange:g,label:`Example queries`,placement:`bottom-end`,trigger:(0,R.jsxs)(l,{variant:`ghost`,size:`small`,children:[(0,R.jsx)(se,{"aria-hidden":`true`}),` Examples`]}),children:a.map(e=>(0,R.jsx)(s,{label:e.title,description:e.query.replace(/\s*\n\s*/g,` `),onClick:()=>{g(!1),u(e.query)}},e.title))}),t&&(0,R.jsx)(l,{variant:`ghost`,size:`small`,onClick:d,children:`Clear`}),(0,R.jsxs)(l,{variant:`primary`,size:`small`,hint:`⌘↵`,disabled:!i||!e.trim(),onClick:()=>u(),children:[(0,R.jsx)(ce,{"aria-hidden":`true`,weight:`fill`}),` Run`]}),(0,R.jsx)(h,{variant:`ghost`,size:`small`,"aria-label":`Close query bar`,onClick:p,children:(0,R.jsx)(ne,{"aria-hidden":`true`})})]})]}),v&&r&&(0,R.jsx)(eu,{result:t,source:r})]})}var au={note:`Note`,board:`Board`,"board-column":`BoardColumn`,"board-card":`Card`,calendar:`Calendar`,"calendar-entry":`CalendarEntry`,"calendar-occurrence":`CalendarOccurrence`,matrix:`Matrix`,"matrix-card":`MatrixCard`},ou=40;function su(e){let t=au[e.kind]??`Node`;return e.entityType&&e.entityType!==t?[e.entityType,t]:[t]}function cu(e,t){return{...t,id:e.id,title:e.label,kind:e.kind,...e.entityType?{type:e.entityType}:{},exists:e.exists,degree:e.degree}}function lu(e){let t=new $t,n=new WeakMap,r=new WeakMap;for(let r of e.nodes){let i={...cu(r,e.frontmatter.get(r.id)),[zl]:su(r)};t.addNode(r.id,i),n.set(i,r.id)}return e.edges.forEach((e,n)=>{if(!t.hasNode(e.source)||!t.hasNode(e.target))return;let i=uu(e),a=String(n);t.addDirectedEdgeWithKey(a,e.source,e.target,i),r.set(i,a)}),{graph:t,nodeIds:n,edgeIds:r}}function uu(e){return{[zl]:e.relation,...e.provider?{provider:e.provider}:{}}}function du(e){let t=new Set,n=new Map;for(let r of e.nodes){su(r).forEach(e=>t.add(e));for(let[t,i]of Object.entries(cu(r,e.frontmatter.get(r.id)))){let e=n.get(t)??new Set;n.set(t,e),(typeof i==`string`&&i.length<=80||typeof i==`number`||typeof i==`boolean`)&&e.size<ou&&e.add(typeof i==`string`?JSON.stringify(i):String(i))}}let r=(e,t)=>e.localeCompare(t);return{labels:[...t].sort(r),relationshipTypes:[...new Set(e.edges.map(e=>e.relation))].sort(r),propertyKeys:[...n.keys()].sort(r),propertyValues:Object.fromEntries([...n].map(([e,t])=>[e,[...t].sort(r)]))}}var fu=b({scope:`vault`,name:`graphQuery`,fallback:``,parse:e=>e.length<=2e4?e:void 0});function pu(e){return _(fu,{vaultId:e})}function mu(e,t){S(fu,t,{vaultId:e})}var hu={labels:[],relationshipTypes:[],propertyKeys:[],propertyValues:{}};function gu(e,t,n){let[r,i]=(0,T.useState)(!1),[a,o]=(0,T.useState)(()=>pu(e)),[s,c]=(0,T.useState)(),[l,u]=(0,T.useState)();(0,T.useEffect)(()=>{o(pu(e)),c(void 0),u(void 0)},[e]);let d=r||s!==void 0;(0,T.useEffect)(()=>{if(!d)return;let t=new AbortController;return v(e,void 0,(e,n)=>C(e,{...n,signal:t.signal})).then(e=>u(new Map(e.map(e=>[e.id,e.frontmatter])))).catch(()=>{t.signal.aborted||u(new Map)}),()=>t.abort()},[d,n,e]);let f=(0,T.useMemo)(()=>t&&l?{nodes:t.nodes,edges:t.edges,frontmatter:l}:void 0,[t,l]),p=(0,T.useMemo)(()=>f?lu(f):void 0,[f]),m=(0,T.useMemo)(()=>p?Yl(p):void 0,[p]),h=(0,T.useMemo)(()=>f?du(f):hu,[f]),g=(0,T.useMemo)(()=>s!==void 0&&m?m.run(s):void 0,[s,m]);function _(t){o(t),mu(e,t)}return{open:r,draft:a,result:g,appliedQuery:s,schema:h,source:p,ready:!!m,setOpen:i,setDraft:_,run:(e=a)=>{e!==a&&_(e),c(e)},clear:()=>c(void 0)}}var _u=/^[A-Z]/;function vu(e){let t=e.labels.filter(e=>!_u.test(e))[0]??`Note`,n=e.relationshipTypes.find(e=>e!==`bodyLink`)??e.relationshipTypes[0],r=Object.entries(e.propertyValues).find(([e,t])=>![`id`,`title`,`kind`,`type`,`exists`,`degree`].includes(e)&&!e.startsWith(`_`)&&t.length>1&&t.length<12&&t[0].startsWith(`"`));return[{title:`Every ${t}`,query:`MATCH (n:${t})\nRETURN n`},...n?[{title:`Notes joined by ${n}`,query:`MATCH (a)-[r:${n}]->(b)\nRETURN a, r, b`}]:[],...r?[{title:`Filter on ${r[0]}`,query:`MATCH (n:Note)\nWHERE n.${r[0]} = ${r[1][0]}\nRETURN n`}]:[],{title:`Title contains a word`,query:`MATCH (n:Note)
|
|
324
|
+
WHERE toLower(n.title) CONTAINS "plan"
|
|
325
|
+
RETURN n`},{title:`Two steps around a ${t}`,query:`MATCH p = (n:${t})-[*1..2]-(m)\nRETURN p\nLIMIT 200`},{title:`Unconnected notes`,query:`MATCH (n:Note)
|
|
326
|
+
WHERE n.degree = 0
|
|
327
|
+
RETURN n`},{title:`Notes per type (table)`,query:`MATCH (n:Note)
|
|
328
|
+
RETURN n.type AS type, count(n) AS notes
|
|
329
|
+
ORDER BY notes DESC, type`}]}function yu(e,t){let n=new Set(t);return{...e,nodes:e.nodes.filter(e=>n.has(e.id)),edges:e.edges.filter(e=>n.has(e.source)&&n.has(e.target))}}var bu=n((e=>{function t(e){return typeof e!=`number`||isNaN(e)?1:e}function n(e,t){var n={},r=function(e){return e===void 0?t:e};typeof t==`function`&&(r=t);var i=function(t){return r(t[e])},a=function(){return r(void 0)};return typeof e==`string`?(n.fromAttributes=i,n.fromGraph=function(e,t){return i(e.getNodeAttributes(t))},n.fromEntry=function(e,t){return i(t)}):typeof e==`function`?(n.fromAttributes=function(){throw Error(`graphology-utils/getters/createNodeValueGetter: irrelevant usage.`)},n.fromGraph=function(t,n){return r(e(n,t.getNodeAttributes(n)))},n.fromEntry=function(t,n){return r(e(t,n))}):(n.fromAttributes=a,n.fromGraph=a,n.fromEntry=a),n}function r(e,t){var n={},r=function(e){return e===void 0?t:e};typeof t==`function`&&(r=t);var i=function(t){return r(t[e])},a=function(){return r(void 0)};return typeof e==`string`?(n.fromAttributes=i,n.fromGraph=function(e,t){return i(e.getEdgeAttributes(t))},n.fromEntry=function(e,t){return i(t)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):typeof e==`function`?(n.fromAttributes=function(){throw Error(`graphology-utils/getters/createEdgeValueGetter: irrelevant usage.`)},n.fromGraph=function(t,n){var i=t.extremities(n);return r(e(n,t.getEdgeAttributes(n),i[0],i[1],t.getNodeAttributes(i[0]),t.getNodeAttributes(i[1]),t.isUndirected(n)))},n.fromEntry=function(t,n,i,a,o,s,c){return r(e(t,n,i,a,o,s,c))},n.fromPartialEntry=function(t,n,i,a){return r(e(t,n,i,a))},n.fromMinimalEntry=function(t,n){return r(e(t,n))}):(n.fromAttributes=a,n.fromGraph=a,n.fromEntry=a,n.fromMinimalEntry=a),n}e.createNodeValueGetter=n,e.createEdgeValueGetter=r,e.createEdgeWeightGetter=function(e){return r(e,t)}})),xu=n(((e,t)=>{t.exports=function(e,t,n){var r,i,a,o,s,c,l,u,d,f,p=t.length,m=n.length,h=e.adjustSizes,g=e.barnesHutTheta*e.barnesHutTheta,_,v,y,b,x,S,C,w=[];for(a=0;a<p;a+=10)t[a+4]=t[a+2],t[a+5]=t[a+3],t[a+2]=0,t[a+3]=0;if(e.outboundAttractionDistribution){for(_=0,a=0;a<p;a+=10)_+=t[a+6];_/=p/10}if(e.barnesHutOptimize){var ee=1/0,te=-1/0,ne=1/0,re=-1/0,ie,ae,oe;for(a=0;a<p;a+=10)ee=Math.min(ee,t[a+0]),te=Math.max(te,t[a+0]),ne=Math.min(ne,t[a+1]),re=Math.max(re,t[a+1]);var se=te-ee,ce=re-ne;for(se>ce?(ne-=(se-ce)/2,re=ne+se):(ee-=(ce-se)/2,te=ee+ce),w[0]=-1,w[1]=(ee+te)/2,w[2]=(ne+re)/2,w[3]=Math.max(te-ee,re-ne),w[4]=-1,w[5]=-1,w[6]=0,w[7]=0,w[8]=0,r=1,a=0;a<p;a+=10)for(i=0,oe=3;;)if(w[i+5]>=0){ie=t[a+0]<w[i+1]?t[a+1]<w[i+2]?w[i+5]:w[i+5]+9:t[a+1]<w[i+2]?w[i+5]+18:w[i+5]+27,w[i+7]=(w[i+7]*w[i+6]+t[a+0]*t[a+6])/(w[i+6]+t[a+6]),w[i+8]=(w[i+8]*w[i+6]+t[a+1]*t[a+6])/(w[i+6]+t[a+6]),w[i+6]+=t[a+6],i=ie;continue}else if(w[i+0]<0){w[i+0]=a;break}else{if(w[i+5]=r*9,u=w[i+3]/2,d=w[i+5],w[d+0]=-1,w[d+1]=w[i+1]-u,w[d+2]=w[i+2]-u,w[d+3]=u,w[d+4]=d+9,w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,d+=9,w[d+0]=-1,w[d+1]=w[i+1]-u,w[d+2]=w[i+2]+u,w[d+3]=u,w[d+4]=d+9,w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,d+=9,w[d+0]=-1,w[d+1]=w[i+1]+u,w[d+2]=w[i+2]-u,w[d+3]=u,w[d+4]=d+9,w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,d+=9,w[d+0]=-1,w[d+1]=w[i+1]+u,w[d+2]=w[i+2]+u,w[d+3]=u,w[d+4]=w[i+4],w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,r+=4,ie=t[w[i+0]+0]<w[i+1]?t[w[i+0]+1]<w[i+2]?w[i+5]:w[i+5]+9:t[w[i+0]+1]<w[i+2]?w[i+5]+18:w[i+5]+27,w[i+6]=t[w[i+0]+6],w[i+7]=t[w[i+0]+0],w[i+8]=t[w[i+0]+1],w[ie+0]=w[i+0],w[i+0]=-1,ae=t[a+0]<w[i+1]?t[a+1]<w[i+2]?w[i+5]:w[i+5]+9:t[a+1]<w[i+2]?w[i+5]+18:w[i+5]+27,ie===ae){if(oe--){i=ie;continue}oe=3;break}w[ae+0]=a;break}}if(e.barnesHutOptimize)for(v=e.scalingRatio,a=0;a<p;a+=10)for(i=0;;)if(w[i+5]>=0){if(S=(t[a+0]-w[i+7])**2+(t[a+1]-w[i+8])**2,f=w[i+3],4*f*f/S<g){if(y=t[a+0]-w[i+7],b=t[a+1]-w[i+8],h===!0?S>0?(C=v*t[a+6]*w[i+6]/S,t[a+2]+=y*C,t[a+3]+=b*C):S<0&&(C=-v*t[a+6]*w[i+6]/Math.sqrt(S),t[a+2]+=y*C,t[a+3]+=b*C):S>0&&(C=v*t[a+6]*w[i+6]/S,t[a+2]+=y*C,t[a+3]+=b*C),i=w[i+4],i<0)break;continue}i=w[i+5];continue}else{if(c=w[i+0],c>=0&&c!==a&&(y=t[a+0]-t[c+0],b=t[a+1]-t[c+1],S=y*y+b*b,h===!0?S>0?(C=v*t[a+6]*t[c+6]/S,t[a+2]+=y*C,t[a+3]+=b*C):S<0&&(C=-v*t[a+6]*t[c+6]/Math.sqrt(S),t[a+2]+=y*C,t[a+3]+=b*C):S>0&&(C=v*t[a+6]*t[c+6]/S,t[a+2]+=y*C,t[a+3]+=b*C)),i=w[i+4],i<0)break;continue}else for(v=e.scalingRatio,o=0;o<p;o+=10)for(s=0;s<o;s+=10)y=t[o+0]-t[s+0],b=t[o+1]-t[s+1],h===!0?(S=Math.sqrt(y*y+b*b)-t[o+8]-t[s+8],S>0?(C=v*t[o+6]*t[s+6]/S/S,t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C):S<0&&(C=100*v*t[o+6]*t[s+6],t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C)):(S=Math.sqrt(y*y+b*b),S>0&&(C=v*t[o+6]*t[s+6]/S/S,t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C));for(d=e.gravity/e.scalingRatio,v=e.scalingRatio,a=0;a<p;a+=10)C=0,y=t[a+0],b=t[a+1],S=Math.sqrt(y**2+b**2),e.strongGravityMode?S>0&&(C=v*t[a+6]*d):S>0&&(C=v*t[a+6]*d/S),t[a+2]-=y*C,t[a+3]-=b*C;for(v=1*(e.outboundAttractionDistribution?_:1),l=0;l<m;l+=3)o=n[l+0],s=n[l+1],u=n[l+2],x=u**+e.edgeWeightInfluence,y=t[o+0]-t[s+0],b=t[o+1]-t[s+1],h===!0?(S=Math.sqrt(y*y+b*b)-t[o+8]-t[s+8],e.linLogMode?e.outboundAttractionDistribution?S>0&&(C=-v*x*Math.log(1+S)/S/t[o+6]):S>0&&(C=-v*x*Math.log(1+S)/S):e.outboundAttractionDistribution?S>0&&(C=-v*x/t[o+6]):S>0&&(C=-v*x)):(S=Math.sqrt(y**2+b**2),e.linLogMode?e.outboundAttractionDistribution?S>0&&(C=-v*x*Math.log(1+S)/S/t[o+6]):S>0&&(C=-v*x*Math.log(1+S)/S):e.outboundAttractionDistribution?(S=1,C=-v*x/t[o+6]):(S=1,C=-v*x)),S>0&&(t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C);var le,ue,de,T,fe,pe;if(h===!0)for(a=0;a<p;a+=10)t[a+9]!==1&&(le=Math.sqrt(t[a+2]**2+t[a+3]**2),le>10&&(t[a+2]=t[a+2]*10/le,t[a+3]=t[a+3]*10/le),ue=t[a+6]*Math.sqrt((t[a+4]-t[a+2])*(t[a+4]-t[a+2])+(t[a+5]-t[a+3])*(t[a+5]-t[a+3])),de=Math.sqrt((t[a+4]+t[a+2])*(t[a+4]+t[a+2])+(t[a+5]+t[a+3])*(t[a+5]+t[a+3]))/2,T=.1*Math.log(1+de)/(1+Math.sqrt(ue)),fe=t[a+0]+t[a+2]*(T/e.slowDown),t[a+0]=fe,pe=t[a+1]+t[a+3]*(T/e.slowDown),t[a+1]=pe);else for(a=0;a<p;a+=10)t[a+9]!==1&&(ue=t[a+6]*Math.sqrt((t[a+4]-t[a+2])*(t[a+4]-t[a+2])+(t[a+5]-t[a+3])*(t[a+5]-t[a+3])),de=Math.sqrt((t[a+4]+t[a+2])*(t[a+4]+t[a+2])+(t[a+5]+t[a+3])*(t[a+5]+t[a+3]))/2,T=t[a+7]*Math.log(1+de)/(1+Math.sqrt(ue)),t[a+7]=Math.min(1,Math.sqrt(T*(t[a+2]**2+t[a+3]**2)/(1+Math.sqrt(ue)))),fe=t[a+0]+t[a+2]*(T/e.slowDown),t[a+0]=fe,pe=t[a+1]+t[a+3]*(T/e.slowDown),t[a+1]=pe);return{}}})),Su=n((e=>{e.assign=function(e){e||={};for(var t=Array.prototype.slice.call(arguments).slice(1),n=0,r,i=t.length;n<i;n++)if(t[n])for(r in t[n])e[r]=t[n][r];return e},e.validateSettings=function(e){return`linLogMode`in e&&typeof e.linLogMode!=`boolean`?{message:"the `linLogMode` setting should be a boolean."}:`outboundAttractionDistribution`in e&&typeof e.outboundAttractionDistribution!=`boolean`?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:`adjustSizes`in e&&typeof e.adjustSizes!=`boolean`?{message:"the `adjustSizes` setting should be a boolean."}:`edgeWeightInfluence`in e&&typeof e.edgeWeightInfluence!=`number`?{message:"the `edgeWeightInfluence` setting should be a number."}:`scalingRatio`in e&&!(typeof e.scalingRatio==`number`&&e.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:`strongGravityMode`in e&&typeof e.strongGravityMode!=`boolean`?{message:"the `strongGravityMode` setting should be a boolean."}:`gravity`in e&&!(typeof e.gravity==`number`&&e.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:`slowDown`in e&&!(typeof e.slowDown==`number`||e.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:`barnesHutOptimize`in e&&typeof e.barnesHutOptimize!=`boolean`?{message:"the `barnesHutOptimize` setting should be a boolean."}:`barnesHutTheta`in e&&!(typeof e.barnesHutTheta==`number`&&e.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},e.graphToByteArrays=function(e,t){var n=e.order,r=e.size,i={},a,o=new Float32Array(n*10),s=new Float32Array(r*3);return a=0,e.forEachNode(function(e,t){i[e]=a,o[a]=t.x,o[a+1]=t.y,o[a+2]=0,o[a+3]=0,o[a+4]=0,o[a+5]=0,o[a+6]=1,o[a+7]=1,o[a+8]=t.size||1,o[a+9]=+!!t.fixed,a+=10}),a=0,e.forEachEdge(function(e,n,r,c,l,u,d){var f=i[r],p=i[c],m=t(e,n,r,c,l,u,d);o[f+6]+=m,o[p+6]+=m,s[a]=f,s[a+1]=p,s[a+2]=m,a+=3}),{nodes:o,edges:s}},e.assignLayoutChanges=function(e,t,n){var r=0;e.updateEachNodeAttributes(function(e,i){return i.x=t[r],i.y=t[r+1],r+=10,n?n(e,i):i})},e.readGraphPositions=function(e,t){var n=0;e.forEachNode(function(e,r){t[n]=r.x,t[n+1]=r.y,n+=10})},e.collectLayoutChanges=function(e,t,n){for(var r=e.nodes(),i={},a=0,o=0,s=t.length;a<s;a+=10){if(n){var c=Object.assign({},e.getNodeAttributes(r[o]));c.x=t[a],c.y=t[a+1],c=n(r[o],c),i[r[o]]={x:c.x,y:c.y}}else i[r[o]]={x:t[a],y:t[a+1]};o++}return i},e.createWorker=function(e){var t=window.URL||window.webkitURL,n=e.toString(),r=t.createObjectURL(new Blob([`(`+n+`).call(this);`],{type:`text/javascript`})),i=new Worker(r);return t.revokeObjectURL(r),i}})),Cu=n(((e,t)=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}})),wu=n(((e,t)=>{var n=Pr(),r=bu().createEdgeWeightGetter,i=xu(),a=Su(),o=Cu();function s(e,t,s){if(!n(t))throw Error(`graphology-layout-forceatlas2: the given graph is not a valid graphology instance.`);typeof s==`number`&&(s={iterations:s});var c=s.iterations;if(typeof c!=`number`)throw Error(`graphology-layout-forceatlas2: invalid number of iterations.`);if(c<=0)throw Error(`graphology-layout-forceatlas2: you should provide a positive number of iterations.`);var l=r(`getEdgeWeight`in s?s.getEdgeWeight:`weight`).fromEntry,u=typeof s.outputReducer==`function`?s.outputReducer:null,d=a.assign({},o,s.settings),f=a.validateSettings(d);if(f)throw Error(`graphology-layout-forceatlas2: `+f.message);for(var p=a.graphToByteArrays(t,l),m=0;m<c;m++)i(d,p.nodes,p.edges);if(e)a.assignLayoutChanges(t,p.nodes,u);else return a.collectLayoutChanges(t,p.nodes)}function c(e){var t=typeof e==`number`?e:e.order;return{barnesHutOptimize:t>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(t)}}var l=s.bind(null,!1);l.assign=s.bind(null,!0),l.inferSettings=c,t.exports=l})),Tu=n(((e,t)=>{function n(e){return!e||typeof e!=`object`||typeof e==`function`||Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof RegExp||e instanceof Date}function r(e,t){e||={};var i={};for(var a in t){var o=e[a],s=t[a];i[a]=n(s)?o===void 0?s:o:r(o,s)}return i}t.exports=r})),Eu=n(((e,t)=>{var n=Tu(),r=Pr(),i={dimensions:[`x`,`y`],center:.5,rng:Math.random,scale:1};function a(e,t,a){if(!r(t))throw Error(`graphology-layout/random: the given graph is not a valid graphology instance.`);a=n(a,i);var o=a.dimensions;if(!Array.isArray(o)||o.length<1)throw Error(`graphology-layout/random: given dimensions are invalid.`);var s=o.length,c=a.center,l=a.rng,u=a.scale,d=(c-.5)*u;function f(e){for(var t=0;t<s;t++)e[o[t]]=l()*u+d;return e}if(!e){var p={};return t.forEachNode(function(e){p[e]=f({})}),p}t.updateEachNodeAttributes(function(e,t){return f(t),t},{attributes:o})}var o=a.bind(null,!1);o.assign=a.bind(null,!0),t.exports=o})),Du=e(wu(),1),Ou=e(Eu(),1),ku=[`#34d058`,`#58a6ff`,`#d29922`,`#bc8cff`,`#39c5bb`,`#f0883e`,`#db61a2`,`#7ee787`],Au={note:`#87929d`,board:`#39c5bb`,"board-column":`#bc8cff`,"board-card":`#d29922`,calendar:`#58a6ff`,"calendar-entry":`#f0883e`,"calendar-occurrence":`#d6a15a`,matrix:`#db61a2`,"matrix-card":`#7ee787`},ju={missing:`#59616a`,label:`#aeb7c0`,edge:`#2e3942`};function Mu(e){return e.kind===`note`&&e.entityType?`entity:${e.entityType}`:`kind:${e.kind}`}function Nu(e){let t=new Map;for(let n of e.nodes){let e=Mu(n),r=t.get(e);if(r){r.count+=1;continue}let i=e.startsWith(`entity:`),a=i?e.slice(7):n.kind;t.set(e,{id:e,label:i?Zu(a):n.kind===`note`?`Untyped notes`:Zu(a),color:i?Yu(a):Au[n.kind],count:1})}return[...t.values()].sort((e,t)=>e.label.localeCompare(t.label))}function Pu(e,t){let n=new Map;for(let r of e){if(r.source===r.target||!t.has(r.source)||!t.has(r.target))continue;let[e,i]=r.source<r.target?[r.source,r.target]:[r.target,r.source],a=`${e}\u0000${i}`,o=n.get(a)??{id:`visual:${n.size}`,source:e,target:i,relations:[],providers:[],count:0};o.count+=1,o.relations.includes(r.relation)||o.relations.push(r.relation),r.provider&&!o.providers.includes(r.provider)&&o.providers.push(r.provider),n.set(a,o)}return[...n.values()]}function Fu(e,t){let n=Nu(e),r=new Map(n.map(e=>[e.id,e])),i=e.nodes.filter(e=>!t.hiddenCategories.has(Mu(e))),a=new Set(i.map(e=>e.id)),o=Pu(e.edges,a),s=new Set(o.flatMap(e=>[e.source,e.target])),c=t.showIsolated?i:i.filter(e=>s.has(e.id)),l=new Set(c.map(e=>e.id));return o=o.filter(e=>l.has(e.source)&&l.has(e.target)),{visible:c,edges:o,categories:n,categoryById:r}}function Iu(e){return{...ju,...Object.fromEntries(Object.entries(e.neutrals??{}).filter(([,e])=>e))}}function Lu(e,t,n){let r=Mu(e);return{label:e.label,fullLabel:e.id,kind:e.kind,entityType:e.entityType,category:r,color:e.exists?t.get(r)?.color??Au.note:n.missing,labelColor:n.label,exists:e.exists,provider:e.provider,reference:e.reference}}function Ru(e,t){return{label:e.relations.join(`, `),relations:e.relations,providers:e.providers,count:e.count,color:t.edge,size:Math.min(.32,.1+Math.log2(e.count+1)*.06)}}function zu(e,t){e.forEachNode(n=>{let r=e.degree(n);e.mergeNodeAttributes(n,{size:r?Math.min(10,1.8+Math.log2(r+1)*1.25):t??1.35})})}function Bu(e,t){return{graph:e,categories:t,visibleNodes:e.order,isolatedNodes:e.filterNodes(t=>e.degree(t)===0).length}}function Vu(e,t){let n=Iu(t),{visible:r,edges:i,categories:a,categoryById:o}=Fu(e,t),s=new Zt;for(let e of r)s.addNode(e.id,{...Lu(e,o,n),size:1.6});for(let e of i)s.addUndirectedEdgeWithKey(e.id,e.source,e.target,Ru(e,n));return zu(s,t.isolatedNodeSize),Wu(s,e.vaultId),Bu(s,a)}function Hu(e,t,n){let{visible:r,edges:i}=Fu(t,n),{graph:a}=e;return a.order!==r.length||a.size!==i.length?!1:r.every(e=>a.hasNode(e.id))&&i.every(e=>a.hasEdge(e.source,e.target))}function Uu(e,t,n){let r=Iu(n),{visible:i,edges:a,categories:o,categoryById:s}=Fu(t,n),{graph:c}=e;for(let e of i)c.mergeNodeAttributes(e.id,Lu(e,s,r));for(let e of a){let t=c.edge(e.source,e.target);t!==void 0&&c.mergeEdgeAttributes(t,Ru(e,r))}return zu(c,n.isolatedNodeSize),Bu(c,o)}function Wu(e,t){if(!e.order)return;let n=Gu(e),r=n.filter(e=>e.length>1),i=n.filter(e=>e.length===1).flat(),a=[];r.forEach((n,r)=>{let i=Ku(e,n);Ou.default.assign(i,{rng:Qu(`${t}:${n[0]}`),scale:Math.max(4,Math.sqrt(n.length))}),i.size&&Du.default.assign(i,{iterations:n.length<=30?180:n.length<=150?220:260,settings:{...Du.default.inferSettings(i),adjustSizes:!0,barnesHutOptimize:n.length>50,gravity:.08,linLogMode:n.length>8,scalingRatio:18,slowDown:6}});let o=Math.max(7,Math.sqrt(n.length)*3.2),s=r===0?{x:0,y:0}:Ju(o,a);qu(i,e,s.x,s.y,o),a.push({...s,radius:o})});let o=a.reduce((e,t)=>Math.max(e,Math.hypot(t.x,t.y)+t.radius),0),s=o?o+10:0,c=Math.PI*(3-Math.sqrt(5));i.forEach((t,n)=>{let r=s+Math.sqrt(n)*3.4,i=n*c;e.mergeNodeAttributes(t,{x:Math.cos(i)*r,y:Math.sin(i)*r})})}function Gu(e){let t=new Set(e.nodes()),n=[];for(;t.size;){let r=t.values().next().value,i=[],a=[r];t.delete(r);for(let n=0;n<a.length;n+=1){let r=a[n];i.push(r);for(let n of e.neighbors(r))t.delete(n)&&a.push(n)}n.push(i)}return n.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}function Ku(e,t){let n=new Zt,r=new Set(t);return t.forEach(t=>n.addNode(t,e.getNodeAttributes(t))),e.forEachEdge((e,t,i,a)=>{r.has(i)&&r.has(a)&&n.addUndirectedEdgeWithKey(e,i,a,t)}),n}function qu(e,t,n,r,i){let a=e.mapNodes((e,t)=>({node:e,x:Number(t.x)||0,y:Number(t.y)||0})),o=Math.min(...a.map(({x:e})=>e)),s=Math.max(...a.map(({x:e})=>e)),c=Math.min(...a.map(({y:e})=>e)),l=Math.max(...a.map(({y:e})=>e)),u=(o+s)/2,d=(c+l)/2,f=Math.max(s-o,l-c,1),p=i*2/f;a.forEach(({node:e,x:i,y:a})=>t.mergeNodeAttributes(e,{x:n+(i-u)*p,y:r+(a-d)*p}))}function Ju(e,t){let n=Math.PI*(3-Math.sqrt(5));for(let r=1;r<2e4;r+=1){let i=Math.sqrt(r)*4.5,a={x:Math.cos(r*n)*i,y:Math.sin(r*n)*i};if(t.every(t=>Math.hypot(a.x-t.x,a.y-t.y)>=e+t.radius+6))return a}return{x:t.reduce((e,t)=>Math.max(e,t.x+t.radius),0)+e+6,y:0}}function Yu(e){return ku[Xu(e)%ku.length]}function Xu(e){return[...e].reduce((e,t)=>Math.imul(e^t.charCodeAt(0),16777619)>>>0,2166136261)}function Zu(e){return e.replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Qu(e){let t=Xu(e);return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function $u(e,t){let[n,r]=(0,T.useState)(e);return(0,T.useEffect)(()=>{if(Object.is(n,e))return;let i=setTimeout(()=>r(e),t);return()=>clearTimeout(i)},[t,n,e]),n}var ed=Object.freeze({hiddenCategories:[],showIsolated:!1,showLabels:!0}),td=b({scope:`vault`,name:`graphPreferences`,fallback:{...ed},parse:e=>{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return;let n=t;return{hiddenCategories:Array.isArray(n.hiddenCategories)?n.hiddenCategories.filter(e=>typeof e==`string`):[],showIsolated:n.showIsolated===!0,showLabels:n.showLabels!==!1}}});function nd(e){return{..._(td,{vaultId:e})}}function rd(e,t){S(td,t,{vaultId:e})}var id=[`--ui-text-muted`,`--border-strong`,`--text-soft`,`--surface-active`,`--text-faint`,`--surface`,`--accent`,`--accent-border-soft`,`--ui-text-strong`,`--text-disabled`];function ad(e){return e.enabled===!1?(0,R.jsx)(`main`,{className:`main-content content-full-size graph-view`,children:(0,R.jsx)(u,{feature:g,vaultId:e.vaultId,children:`Enable Graph for this vault to explore its notes and links as a graph.`})}):(0,R.jsx)(od,{...e})}function od({vaultId:e,entityRevision:t,onSummaryChange:n,onOpenNote:r}){let i=a(),[s,c]=(0,T.useState)(),[u,d]=(0,T.useState)(()=>nd(e)),[f,p]=(0,T.useState)(!0),[m,h]=(0,T.useState)(),[g,_]=(0,T.useState)(),[v,y]=(0,T.useState)();(0,T.useEffect)(()=>{d(nd(e)),y(void 0),_(void 0),ae.current=void 0},[e]);let b=$u(t,1500);(0,T.useEffect)(()=>{let t=new AbortController;return p(!0),h(void 0),Gi({vault:e,centerId:v,depth:2,limit:v?1500:4e3},(e,n)=>C(e,{...n,signal:t.signal})).then(e=>{c(e),n(`${e.scope.mode===`neighborhood`?`Local graph · `:``}${e.meta.returnedNodes.toLocaleString()} nodes · ${e.meta.returnedEdges.toLocaleString()} relationships`)}).catch(e=>{t.signal.aborted||h(e instanceof Error?e.message:String(e))}).finally(()=>{t.signal.aborted||p(!1)}),()=>t.abort()},[v,b,n,e]);let x=gu(e,s,b),S=(0,T.useRef)(null),w=(0,T.useMemo)(()=>vu(x.schema),[x.schema]),ee=x.result?.status===`ok`?x.result:void 0,te=(0,T.useMemo)(()=>s&&ee?yu(s,ee.nodeIds):s,[s,ee]),ne=(0,T.useMemo)(()=>new Set(u.hiddenCategories),[u.hiddenCategories]),re=le(id),ie=(0,T.useMemo)(()=>({missing:re[`--text-disabled`],label:re[`--text-soft`],edge:re[`--border-strong`]}),[re]),ae=(0,T.useRef)(void 0),oe=(0,T.useMemo)(()=>{if(!te)return;let e={hiddenCategories:ne,showIsolated:!!ee||u.showIsolated,neutrals:ie,...ee?{isolatedNodeSize:5}:{}},t=ae.current,n=t&&Hu(t,te,e)?Uu(t,te,e):Vu(te,e);return ae.current=n,n},[te,ne,u.showIsolated,ee,ie]),se=s?.nodes.find(e=>e.id===g),ce=[...s?.meta.truncated?[`Limited to ${s.scope.limit.toLocaleString()} nodes.`]:[],...s?.providerErrors?.map(e=>`${e.provider}: ${e.message}`)??[]];function ue(t){d(n=>{let r={...n,...t};return rd(e,r),r})}function de(e){let t=new Set(ne);t.has(e)?t.delete(e):t.add(e),ue({hiddenCategories:[...t]})}function fe(e,t){_(e);let n=s?.nodes.find(t=>t.id===e);n?.exists&&n.provider===`notes`&&n.kind===`note`?r(e,t):i.warning(n?.exists?`The ${n.kind} node '${n.label}' has no note to edit.`:`The unresolved node '${e}' has no note to edit.`)}function pe(e){_(e),y(e)}function me(e){let t=s?.nodes.find(t=>t.id===e);if(t){let e=t.kind===`note`&&t.entityType?`entity:${t.entityType}`:`kind:${t.kind}`,n=u.hiddenCategories.filter(t=>t!==e),r=t.degree===0&&!u.showIsolated;(n.length!==u.hiddenCategories.length||r)&&ue({hiddenCategories:n,showIsolated:u.showIsolated||r})}_(e)}function he(){x.setOpen(!1),requestAnimationFrame(()=>S.current?.focus())}return(0,R.jsx)(`main`,{className:`main-content content-full-size graph-view`,children:(0,R.jsxs)(`section`,{className:`graph-stage`,"aria-label":`Knowledge graph visualization`,children:[s&&te&&oe&&oe.graph.order>0&&(0,R.jsxs)(Wi,{graph:oe.graph,className:`sigma-container`,settings:{defaultNodeColor:re[`--ui-text-muted`],defaultEdgeColor:re[`--border-strong`],labelColor:{attribute:`labelColor`,color:re[`--text-soft`]},labelFont:`Inter, ui-sans-serif, system-ui, sans-serif`,labelSize:10,labelDensity:.3,labelGridCellSize:110,labelRenderedSizeThreshold:u.showLabels?4:2**53-1,hideLabelsOnMove:!0,itemSizesReference:`screen`,defaultDrawNodeHover:(e,t,n)=>cd(e,t,n,re),renderEdgeLabels:!1,zIndex:!0,minCameraRatio:.04,maxCameraRatio:12},children:[(0,R.jsx)(sd,{focusedNodeId:g,colors:re,onActivate:fe,onClear:()=>_(void 0)}),(0,R.jsx)(Ji,{data:te,categories:oe.categories,hiddenCategories:ne,showIsolated:u.showIsolated,showLabels:u.showLabels,localMode:s.scope.mode===`neighborhood`,selectedNode:se,onLocate:me,onShowLocalGraph:pe,onShowFull:()=>y(void 0),onShowIsolatedChange:e=>ue({showIsolated:e}),onShowLabelsChange:e=>ue({showLabels:e}),onToggleCategory:de,onShowAllCategories:()=>ue({hiddenCategories:[]}),onShowNotesOnly:()=>ue({hiddenCategories:oe.categories.filter(e=>!e.id.startsWith(`entity:`)&&e.id!==`kind:note`).map(e=>e.id)}),queryOpen:x.open,queryActive:!!x.result,queryToggleRef:S,onToggleQuery:()=>x.open?he():x.setOpen(!0)})]},`${e}:${s.scope.mode}:${s.scope.centerId??`full`}:${ee?x.appliedQuery:``}`),f&&!s?(0,R.jsxs)(o,{status:`loading`,className:`graph-state`,children:[(0,R.jsx)(`span`,{className:`graph-loader`}),`Laying out graph…`]}):m?(0,R.jsx)(o,{status:`error`,className:`graph-state`,children:m}):s&&oe?.graph.order===0?ee?(0,R.jsx)(o,{status:`empty`,className:`graph-state`,action:!x.open&&(0,R.jsx)(l,{size:`small`,onClick:()=>x.setOpen(!0),children:`Edit query`}),children:`The query returned no nodes to show.`}):(0,R.jsx)(o,{status:`empty`,className:`graph-state`,children:`No nodes match the current graph filters.`}):null,(0,R.jsxs)(`div`,{className:`graph-overlay-stack`,children:[x.open&&s&&(0,R.jsx)(iu,{draft:x.draft,result:x.result,schema:x.schema,source:x.source,ready:x.ready,examples:w,onDraftChange:x.setDraft,onRun:x.run,onClear:x.clear,onClose:he}),s&&oe&&!f&&!x.open&&(0,R.jsxs)(`p`,{className:`graph-layout-summary`,children:[oe.visibleNodes.toLocaleString(),` shown`,ee?` · filtered by a query`:!u.showIsolated&&s.meta.isolatedNodes?` · ${s.meta.isolatedNodes.toLocaleString()} unconnected hidden`:``]}),ce.length>0&&(0,R.jsx)(`div`,{className:`graph-warning-stack`,role:`status`,"aria-label":`Graph warnings`,children:ce.map(e=>(0,R.jsx)(`p`,{className:`graph-warning`,children:e},e))})]})]})})}function sd({focusedNodeId:e,colors:t,onActivate:n,onClear:r}){let i=Vi(),a=L(),o=Fi(),{gotoNode:s}=Ui({duration:220}),[c,l]=(0,T.useState)();return(0,T.useEffect)(()=>{if(!e||!o.getGraph().hasNode(e))return;let t=0,n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>s(e))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[e,s,o]),(0,T.useEffect)(()=>{let n=c??e;if(!n||!o.getGraph().hasNode(n)){a({nodeReducer:null,edgeReducer:null});return}let r=o.getGraph(),i=new Set(r.neighbors(n)),s=new Set([...i].sort((e,t)=>r.degree(t)-r.degree(e)||e.localeCompare(t)).slice(0,20));a({nodeReducer:(e,r)=>{let a=r;return e===n?{...a,size:Math.max(5,a.size*1.5),highlighted:!0,forceLabel:!0,zIndex:2}:i.has(e)?{...a,size:a.size*1.2,forceLabel:s.has(e),zIndex:1}:{...a,size:a.size*.78,color:t[`--surface-active`],labelColor:t[`--text-faint`]}},edgeReducer:(e,i)=>{let a=i,[o,s]=r.extremities(e);return o===n||s===n?{...a,color:`${t[`--accent`]}cc`,size:Math.max(1.25,a.size*3),zIndex:1}:{...a,color:`${t[`--border-strong`]}40`,size:Math.max(.12,a.size*.6)}}})},[t,e,c,a,o]),(0,T.useEffect)(()=>i({clickNode:({node:e,event:t})=>n(e,ue(t.original)),clickStage:r,enterNode:({node:e})=>l(e),leaveNode:()=>l(void 0)}),[n,r,i]),null}function cd(e,t,n,r){let i=typeof t.label==`string`?t.label:``,a=Math.max(11,n.labelSize+1),o=n.labelColor.color??r[`--ui-text-strong`];e.save(),e.font=`${n.labelWeight} ${a}px ${n.labelFont}`;let s=i?e.measureText(i).width:0,c=t.x+t.size+7,l=t.y-(a+8)/2;e.beginPath(),e.arc(t.x,t.y,t.size+2,0,Math.PI*2),e.fillStyle=`${r[`--surface`]}e8`,e.fill(),e.lineWidth=1.5,e.strokeStyle=t.color??r[`--accent`],e.stroke(),i&&(e.beginPath(),e.roundRect(c,l,s+14,a+8,5),e.fillStyle=`${r[`--surface`]}f2`,e.fill(),e.lineWidth=1,e.strokeStyle=`${r[`--accent-border-soft`]}33`,e.stroke(),e.fillStyle=o,e.fillText(i,c+7,t.y+a*.35)),e.restore()}export{ad as GraphExplorer};
|