@lobu/runtime-server 24.8.0 → 24.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalogs/automations.json +2 -2
- package/dist/catalogs/connectors.json +99 -10
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +6 -2
- package/dist/connectors/github.ts +16 -3
- package/dist/connectors/market_quotes.ts +388 -91
- package/dist/connectors/postgres.ts +60 -38
- package/dist/connectors/whatsapp-web-adapter.js +41 -10
- package/dist/connectors/whatsapp-web-helpers.ts +12 -2
- package/dist/connectors/whatsapp_web.ts +18 -2
- package/dist/connectors/x-dm-adapter.js +55 -21
- package/dist/connectors/x.ts +1 -1
- package/dist/db/migrations/20261109010000_workspace_navigation.sql +14 -0
- package/dist/db/migrations/20261110010000_view_resources.sql +11 -0
- package/dist/db/migrations/20261112210000_instance_identity.sql +18 -0
- package/dist/dependencies.bun.lock +88 -86
- package/dist/embeddings-server.mjs +38 -5
- package/dist/owletto/dist/assets/_-CYvj1y65.js +3 -0
- package/dist/owletto/dist/assets/_-CeLTSYYY.js +2 -0
- package/dist/owletto/dist/assets/_agentId-BB5E-L6T.js +2 -0
- package/dist/owletto/dist/assets/_agentId-DN0EwMAC.js +2 -0
- package/dist/owletto/dist/assets/_automationId-DvUl9CSd.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-CVKfL9AG.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-Cv6FzK1v.js +2 -0
- package/dist/owletto/dist/assets/{_conversationId-OJrZjd0o.js → _conversationId-CPpNySjO.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-DZKicuq6.js +2 -0
- package/dist/owletto/dist/assets/_owner-Dauk3YuD.js +3 -0
- package/dist/owletto/dist/assets/_shape-cKrEID3T.js +2 -0
- package/dist/owletto/dist/assets/_slug-DJx_8fsV.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CPVzVKEf.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CW8gexOQ.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-Dwq1GAnG.js +2 -0
- package/dist/owletto/dist/assets/activity-route-location-C1jcXC7v.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-D78Wj0RH.js +2 -0
- package/dist/owletto/dist/assets/agent-connect-pages-DoI9UR0a.js +4 -0
- package/dist/owletto/dist/assets/{agent-editor-form-CDAHRNWl.js → agent-editor-form-DlavYg2q.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-BupiSjR-.js → agent-loading-shells-DYqQphN7.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-C1L8IcYR.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-B0ZYVE3n.js → agent-skill-context-D1nMrVod.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-ByU0xhXn.js → agent-subpage-shell-2w7vTeXw.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-DiVKn1WX.js → agent-thread-BopD-2k1.js} +2 -2
- package/dist/owletto/dist/assets/{app._appId-BQWElSoP.js → app._appId-BXeFXW1w.js} +2 -2
- package/dist/owletto/dist/assets/{assist-composer-igTXq3DL.js → assist-composer-CL5x8pNt.js} +2 -2
- package/dist/owletto/dist/assets/automation-run-now-MtxUTfzd.js +2 -0
- package/dist/owletto/dist/assets/{callback-Dmaio9CX.js → callback-BgfwP1Eo.js} +2 -2
- package/dist/owletto/dist/assets/{card-rE4Ctuy6.js → card-DtLIFq7D.js} +2 -2
- package/dist/owletto/dist/assets/{claim-BN17CPYh.js → claim-CT3hYVMF.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-B7xVaUA-.js → client-activity-scopes-BPbRX-Pe.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-B3LULJxW.js → client-rows-vrNA6FLs.js} +2 -2
- package/dist/owletto/dist/assets/clients-xnzZeEdZ.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-UppEMWpt.js → code-editor-mrKkAfcE.js} +2 -2
- package/dist/owletto/dist/assets/connect-NUCSay8X.js +2 -0
- package/dist/owletto/dist/assets/{connect-menu-B9u86bb2.js → connect-menu-C6iVtuSo.js} +2 -2
- package/dist/owletto/dist/assets/connect._clientId-Cp-d9Q5b.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId-CaF-ZWlZ.js → connected._clientId-ROfVgp9h.js} +2 -2
- package/dist/owletto/dist/assets/connection-BMz740Wi.js +2 -0
- package/dist/owletto/dist/assets/{connection-feed-detail-CJYqryAV.js → connection-feed-detail-0VAJiZTP.js} +2 -2
- package/dist/owletto/dist/assets/connector-page-shell-BFv21yuv.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-CW4CXtCz.js → connector-provenance-b59RfBtk.js} +2 -2
- package/dist/owletto/dist/assets/connectors-nYS31lO2.js +2 -0
- package/dist/owletto/dist/assets/consent-cPRF9JQv.js +2 -0
- package/dist/owletto/dist/assets/{copy-button-1ALlvZU1.js → copy-button-C3wMMv63.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-6koO33th.js → core.esm-C9QlSrgK.js} +3 -3
- package/dist/owletto/dist/assets/{create-kUevP9Xx.js → create-ASRN3Obq.js} +2 -2
- package/dist/owletto/dist/assets/create-CBcodaSO.js +2 -0
- package/dist/owletto/dist/assets/create-CGOWfMk4.js +2 -0
- package/dist/owletto/dist/assets/{create-automation-form-BhujNbRr.js → create-automation-form-CLicoPH5.js} +3 -3
- package/dist/owletto/dist/assets/create._connectorKey-s4xkktTC.js +2 -0
- package/dist/owletto/dist/assets/{custom-guardrail-edits-B_aCgvoZ.js → custom-guardrail-edits-BUL7nmuO.js} +2 -2
- package/dist/owletto/dist/assets/{definition-comparison-3zKUSTt8.js → definition-comparison-4UYMI6BK.js} +2 -2
- package/dist/owletto/dist/assets/{detail-page-skeleton-BmxqqIsH.js → detail-page-skeleton-C8v3rJXK.js} +2 -2
- package/dist/owletto/dist/assets/device-BBwsOi7q.js +2 -0
- package/dist/owletto/dist/assets/device-pin-tombstone-Bcpe7nAA.js +2 -0
- package/dist/owletto/dist/assets/{device._deviceId-Dqtmb1Xp.js → device._deviceId-DLT4jh0Z.js} +2 -2
- package/dist/owletto/dist/assets/{dynamic-schema-form-D3KnzCsW.js → dynamic-schema-form-BDT8x0Vg.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-B9hm9V87.js +2 -0
- package/dist/owletto/dist/assets/entity-page-DZjzQ2V4.js +2 -0
- package/dist/owletto/dist/assets/entity-pages-BWBpttz3.js +2 -0
- package/dist/owletto/dist/assets/entity-schema-graph-lMMx3HhR.js +2 -0
- package/dist/owletto/dist/assets/{entity-type-page-CouHZbc9.js → entity-type-page-CkQm0yEu.js} +2 -2
- package/dist/owletto/dist/assets/event-detail-CkzfakTK.js +2 -0
- package/dist/owletto/dist/assets/events-feed-DmRzikZW.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-CQoSj-20.js +3 -0
- package/dist/owletto/dist/assets/{full-page-spinner-B7A6Ycyi.js → full-page-spinner-CYyCnKve.js} +2 -2
- package/dist/owletto/dist/assets/index-BE7eb2kE.js +2 -0
- package/dist/owletto/dist/assets/index-BFR0uiKY.js +2 -0
- package/dist/owletto/dist/assets/{index-DXfYVs5m.js → index-BS5Ty3tf.js} +2 -2
- package/dist/owletto/dist/assets/index-C38OzBpB.js +2 -0
- package/dist/owletto/dist/assets/{index-BztXeLBN.js → index-C3hz9tzx.js} +2 -2
- package/dist/owletto/dist/assets/index-CDyFQ32o.js +2 -0
- package/dist/owletto/dist/assets/{index-B-dZruj6.js → index-CUndAH6o.js} +2 -2
- package/dist/owletto/dist/assets/index-CiKysEhV.js +2 -0
- package/dist/owletto/dist/assets/index-DByaMzsG.js +7906 -0
- package/dist/owletto/dist/assets/index-DfdinB7B.js +2 -0
- package/dist/owletto/dist/assets/index-DgMM4Zt5.css +1 -0
- package/dist/owletto/dist/assets/index-Xk711gVC.js +2 -0
- package/dist/owletto/dist/assets/index-ittfA0k8.js +2 -0
- package/dist/owletto/dist/assets/{json-diff-CJK-gzCt.js → json-diff-mcDgyct_.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-bQAZ0hQp.js → list-skeleton-DsYGUHxi.js} +2 -2
- package/dist/owletto/dist/assets/login-EoLq136v.js +2 -0
- package/dist/owletto/dist/assets/{logout-H0F3IfiO.js → logout-gLgEQOiX.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-Doic_6qX.js → member-scope-gate-vvkgSAb2.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-DvDtwrEI.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-BrfaDwIg.js → model-selector-D3vSMLO2.js} +2 -2
- package/dist/owletto/dist/assets/needs-you-list-B5Bgd05M.js +2 -0
- package/dist/owletto/dist/assets/new-BPW3V0Y1.js +2 -0
- package/dist/owletto/dist/assets/new-Bk_flKQO.js +2 -0
- package/dist/owletto/dist/assets/new-C5HtQdM_.js +2 -0
- package/dist/owletto/dist/assets/new-dLXsCHBd.js +2 -0
- package/dist/owletto/dist/assets/organization-DBfgBkzq.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-c2PG3TEX.js +2 -0
- package/dist/owletto/dist/assets/{pending-seed-DYYOoCvj.js → pending-seed-CBhx2Ql-.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-BVwOMoq9.js → proposal-review-shell-B-jYcKfB.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-D8TijlRY.js +2 -0
- package/dist/owletto/dist/assets/record-activity-DnRVOrG2.js +2 -0
- package/dist/owletto/dist/assets/{record-session-KuEDuF3S.js → record-session-CAmGHMyM.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-ucwCQmBk.js → renderer-olRv_HMI.js} +3 -3
- package/dist/owletto/dist/assets/reset-password-B9_xi8Pq.js +2 -0
- package/dist/owletto/dist/assets/{run-initiator-8vdkq-3o.js → run-initiator-DhE5v4z0.js} +2 -2
- package/dist/owletto/dist/assets/runs-C8sZQr4o.js +2 -0
- package/dist/owletto/dist/assets/runs-list-CwtH-wmk.js +2 -0
- package/dist/owletto/dist/assets/{schema-value-CefbtPIY.js → schema-value-zTJGE4eh.js} +3 -3
- package/dist/owletto/dist/assets/scoped-feed-bar-BKyJSa3_.js +2 -0
- package/dist/owletto/dist/assets/{settings-DvzkRYQy.js → settings-z02cvVS3.js} +2 -2
- package/dist/owletto/dist/assets/source-record-panels-CGmKIJdN.js +2 -0
- package/dist/owletto/dist/assets/{status-variants-BxHtpMOj.js → status-variants-DyRCXBzM.js} +2 -2
- package/dist/owletto/dist/assets/subDays-D8nHthaS.js +2 -0
- package/dist/owletto/dist/assets/{table-1O-ik4_O.js → table-C637cQxG.js} +2 -2
- package/dist/owletto/dist/assets/use-automations-CgWNoYio.js +2 -0
- package/dist/owletto/dist/assets/use-login-redirect-tDdhXTpt.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-CA-evCDf.js → use-mention-search-D-kIKchD.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-CUCj9Df-.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-C35Dyt91.js +2 -0
- package/dist/owletto/dist/index.html +19 -12
- package/dist/server-main.bundle.mjs +6964 -4213
- package/npm-shrinkwrap.json +423 -406
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +29 -2
- package/vendor/connector-sdk/dist/index.d.ts +1 -0
- package/vendor/connector-sdk/dist/index.js +1 -0
- package/vendor/connector-sdk/dist/ip-reachability.d.ts +1 -1
- package/vendor/connector-sdk/dist/ip-reachability.js +1 -1
- package/vendor/connector-sdk/dist/logger.d.ts +1 -1
- package/vendor/connector-sdk/dist/logger.js +1 -1
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +3 -1
- package/vendor/connector-sdk/dist/retry.d.ts +1 -1
- package/vendor/connector-sdk/dist/retry.js +1 -1
- package/vendor/connector-sdk/dist/source-withheld-error.d.ts +16 -0
- package/vendor/connector-sdk/dist/source-withheld-error.js +19 -0
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/classify-error.d.ts +4 -5
- package/vendor/core/dist/classify-error.js +10 -10
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
- package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +67 -3
- package/vendor/core/dist/contracts/tools/manage-automations.js +38 -9
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +8 -0
- package/vendor/core/dist/contracts/tools/manage-entity.js +11 -3
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
- package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
- package/vendor/core/dist/contracts/tools/navigation.js +284 -0
- package/vendor/core/dist/contracts/tools/save-memory.d.ts +11 -1
- package/vendor/core/dist/contracts/tools/save-memory.js +25 -3
- package/vendor/core/dist/contracts/tools/search-memory.js +1 -1
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
- package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
- package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
- package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
- package/vendor/core/dist/contracts/tools/view-host.js +28 -1
- package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
- package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
- package/vendor/core/dist/credentials.d.ts +12 -0
- package/vendor/core/dist/credentials.js +1 -0
- package/vendor/core/dist/errors.d.ts +17 -24
- package/vendor/core/dist/errors.js +19 -26
- package/vendor/core/dist/types.d.ts +0 -6
- package/vendor/core/dist/worker/auth.d.ts +5 -0
- package/vendor/core/dist/worker/auth.js +15 -4
- package/vendor/core/package.json +11 -1
- package/vendor/postgres/cf/src/connection.js +7 -2
- package/vendor/postgres/cjs/src/connection.js +7 -2
- package/vendor/postgres/src/connection.js +7 -2
- package/vendor/views/dist/api.d.ts +30 -5
- package/vendor/views/dist/api.js +22 -8
- package/vendor/views/dist/bridge.d.ts +17 -0
- package/vendor/views/dist/bridge.js +49 -1
- package/vendor/views/dist/components.d.ts +27 -5
- package/vendor/views/dist/components.js +57 -7
- package/vendor/views/dist/embed.d.ts +98 -0
- package/vendor/views/dist/embed.js +418 -0
- package/vendor/views/dist/index.d.ts +3 -1
- package/vendor/views/dist/index.js +1 -0
- package/vendor/views/dist/native.d.ts +33 -1
- package/vendor/views/dist/native.js +3 -0
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-B0tmXZ86.js +0 -2
- package/dist/owletto/dist/assets/_-DwXULq4r.js +0 -3
- package/dist/owletto/dist/assets/_agentId-B1dNkhnr.js +0 -2
- package/dist/owletto/dist/assets/_agentId-sYjvnBaB.js +0 -2
- package/dist/owletto/dist/assets/_automationId-Bnw_CnT_.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-D7Z8DQ-B.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-DM5MTO8c.js +0 -2
- package/dist/owletto/dist/assets/_eventId-CfB0_2zK.js +0 -2
- package/dist/owletto/dist/assets/_owner-BDvTUY0a.js +0 -3
- package/dist/owletto/dist/assets/_shape-BZidoJMB.js +0 -2
- package/dist/owletto/dist/assets/_slug-R989vOiM.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BDUSrpe5.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BnFqh5-t.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-BC-ZIsrf.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-CN2dOiCD.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-CdDjrHjn.js +0 -4
- package/dist/owletto/dist/assets/agent-permissions-matrix-ju7L2M0l.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-BJwRU6qT.js +0 -2
- package/dist/owletto/dist/assets/clients-CydgUHrc.js +0 -2
- package/dist/owletto/dist/assets/connect-OdHpIVV9.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-EI1tcdSE.js +0 -2
- package/dist/owletto/dist/assets/connection-D8ZAMHBT.js +0 -2
- package/dist/owletto/dist/assets/connector-boxes-BWPXijAk.js +0 -2
- package/dist/owletto/dist/assets/connector-page-shell-C23dWdKz.js +0 -2
- package/dist/owletto/dist/assets/connectors-Bp08_KPq.js +0 -2
- package/dist/owletto/dist/assets/consent-_PpYI1cT.js +0 -2
- package/dist/owletto/dist/assets/create-DULVO0HS.js +0 -2
- package/dist/owletto/dist/assets/create-Drx9tcnG.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-N6fhcIPy.js +0 -2
- package/dist/owletto/dist/assets/device-D2eUt_nr.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-BFPbTM_o.js +0 -2
- package/dist/owletto/dist/assets/entity-options-IUdQ-64R.js +0 -2
- package/dist/owletto/dist/assets/entity-page-B3Im65EI.js +0 -2
- package/dist/owletto/dist/assets/entity-pages-DJNSQrfB.js +0 -2
- package/dist/owletto/dist/assets/event-detail-CvaRN1qB.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DwOkLk6A.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-DQ5V4Cvh.js +0 -2
- package/dist/owletto/dist/assets/home-stream-Bg97PUBJ.js +0 -2
- package/dist/owletto/dist/assets/home-toolbar-CpCcHA6z.js +0 -2
- package/dist/owletto/dist/assets/index-9PGnv4-5.js +0 -2
- package/dist/owletto/dist/assets/index-C2TCKJDP.js +0 -7901
- package/dist/owletto/dist/assets/index-C7QM3aqU.js +0 -2
- package/dist/owletto/dist/assets/index-CWn46a4y.js +0 -2
- package/dist/owletto/dist/assets/index-CxJONizf.js +0 -2
- package/dist/owletto/dist/assets/index-DJhb3li3.js +0 -2
- package/dist/owletto/dist/assets/index-DY-YGnCe.js +0 -2
- package/dist/owletto/dist/assets/index-j3v7ITPb.js +0 -2
- package/dist/owletto/dist/assets/index-oiy6ygaI.js +0 -2
- package/dist/owletto/dist/assets/index-pEgtAY1t.js +0 -2
- package/dist/owletto/dist/assets/index-xAvK3IyQ.css +0 -1
- package/dist/owletto/dist/assets/login-DLqL54Rk.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-CUea2Llz.js +0 -74
- package/dist/owletto/dist/assets/new-5GkxlOuQ.js +0 -2
- package/dist/owletto/dist/assets/new-BiA4DGoN.js +0 -2
- package/dist/owletto/dist/assets/new-M-MX_T5C.js +0 -2
- package/dist/owletto/dist/assets/organization-CLrcmgNK.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-B29OcHwm.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-BbjPgh3k.js +0 -2
- package/dist/owletto/dist/assets/record-activity-BCpNKaUo.js +0 -2
- package/dist/owletto/dist/assets/reset-password-BkiAmXZW.js +0 -2
- package/dist/owletto/dist/assets/runs-B_iywKWb.js +0 -2
- package/dist/owletto/dist/assets/runs-list-CJJFRhTl.js +0 -2
- package/dist/owletto/dist/assets/schema-type-editor-panel-C4e8pq1A.js +0 -2
- package/dist/owletto/dist/assets/scoped-feed-bar-CapleZvS.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-LJIWGtHb.js +0 -2
- package/dist/owletto/dist/assets/subDays-DwIOMzYC.js +0 -2
- package/dist/owletto/dist/assets/use-automations-lV8PuE8L.js +0 -2
- package/dist/owletto/dist/assets/use-login-redirect-CfCbEeJR.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-Bp84PUMd.js +0 -2
- package/dist/owletto/dist/assets/views-access-required-BerT4Z1d.js +0 -2
- /package/vendor/postgres/{.bun-tag-c81dacd34e959a7a → .bun-tag-652f2580b8090d71} +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import{r as v,j as n,B as U,dh as it,fE as Es,fF as Cs,bV as _s,i as ae,dE as Et,m as We,bn as Ms,cs as $n,q as Ts,fG as Rs,dC as Is,fH as Ls,G as Oe,fI as Kt,fJ as $s,fK as Os,fL as As,T as $e,bg as Lt,bh as $t,bi as Ot,bj as At,bk as ut,fM as Ps,U as et,fN as Ds,bI as On,fO as An,fP as Pn,fQ as Fs,x as Ct,fR as zs,c as tt,u as Jt,eH as Dn,ct as Ws,d4 as Bs,d5 as Hs,fS as Vs,aH as Us,fT as Fn,b2 as Gs,b9 as qs,bT as zn,a6 as Ys,L as He,X as Ks,el as Wn,bX as Js,bY as Xs,fU as Qs,fV as Zs,cz as er,c0 as tr,bo as Bn,fW as Hn,fX as Qe,fY as yt,fZ as nr,f_ as sr,f$ as Xt,g0 as rr,g1 as Bt,g2 as Ht,g3 as or,g4 as ar,cC as Vn,cP as xt,e5 as ir,da as cr,bG as lr,ei as dr,fr as ur,eV as mr,b0 as Un,g5 as Gn,fi as fr,fC as pr,eE as hr,a2 as Vt,dm as qn,g6 as gr,dN as yr,du as xr,e3 as Yn,e4 as Kn,e6 as Jn,e7 as Xn,e8 as br,e9 as vr,ea as wr,eb as kr,dp as un,g7 as Nr,cV as Sr,dq as jr,a4 as Er,g8 as Qn,g9 as Zn,ax as Cr,ga as _r,M as es,gb as Mr,c9 as Be,w as ts,gc as Pt,gd as Tr,ge as Rr,dx as mn,gf as Dt,gg as Ir,gh as Lr,gi as $r,cL as Or,gj as Ar,gk as Pr,be as Dr,gl as Fr,a as zr,gm as Wr,gn as Br,ar as Hr,aF as Vr}from"./index-C2TCKJDP.js";import{P as Ur}from"./public-shell-ready-BbjPgh3k.js";import{A as Gr}from"./connector-boxes-BWPXijAk.js";import{u as qr}from"./use-automations-lV8PuE8L.js";import{f as Yr}from"./feed-event-kinds-BYuZCoU4.js";import{S as Kr}from"./schema-type-editor-panel-C4e8pq1A.js";import{D as Jr,c as Xr}from"./dynamic-schema-form-D3KnzCsW.js";import{S as Qr,E as ns,a as Zr,e as eo,b as to,c as no}from"./entity-pages-DJNSQrfB.js";import{a as so}from"./filter-editors-DQ5V4Cvh.js";import{l as ro,p as _t,e as ss,a as oo,S as ao,J as io}from"./renderer-ucwCQmBk.js";import{u as co,a as lo,D as uo,P as mo,b as rs,c as fo,C as po}from"./core.esm-6koO33th.js";import{v as ho,V as os,M as as,a as is,w as go,b as yo}from"./view-param-filters-Bp84PUMd.js";import{E as xo}from"./entity-type-page-CouHZbc9.js";import{M as bo}from"./member-scope-gate-Doic_6qX.js";function fn(e){let t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)t=Math.min(t,i.x-i.w/2),o=Math.max(o,i.x+i.w/2),s=Math.min(s,i.y-i.h/2),r=Math.max(r,i.y+i.h/2);return Number.isFinite(t)?{x0:t,y0:s,x1:o,y1:r}:null}const bt=(e,t,s)=>e<t?t:e>s?s:e;function vo(e,t,s,{padding:o=.12,minZoom:r=.2,maxZoom:i=1.2}={}){const a=Math.max(1,e.x1-e.x0),l=Math.max(1,e.y1-e.y0),m=bt(Math.min(t/(a*(1+o)),s/(l*(1+o))),r,i);return{z:m,x:t/2-(e.x0+e.x1)/2*m,y:s/2-(e.y0+e.y1)/2*m}}function wo(e,t,s=0){if(e===t){const x=e.x+e.w/2,d=e.y-e.h/2;return[{x:x-30,y:d},{x:x-30,y:d-26},{x:x+22,y:d-26},{x:x+22,y:e.y-6},{x,y:e.y-6}]}const o=s*8,r=e.x+e.w/2,i=e.y+bt(o,-e.h/2+6,e.h/2-6),a=t.x-t.w/2,l=t.y+bt(o,-t.h/2+6,t.h/2-6);if(a-r>=40){const x=(r+a)/2+o;return[{x:r,y:i},{x,y:i},{x,y:l},{x:a,y:l}]}const m=Math.max(e.y+e.h/2,t.y+t.h/2)+24+Math.abs(o),c=Math.min(e.y-e.h/2,t.y-t.h/2)-24-Math.abs(o),y=(i+l)/2,p=Math.abs(m-y)<=Math.abs(c-y)?m:c,f=r+24+Math.abs(o),h=a-24-Math.abs(o);return[{x:r,y:i},{x:f,y:i},{x:f,y:p},{x:h,y:p},{x:h,y:l},{x:a,y:l}]}function ko(e,t,s){const o=s.x-t.x,r=s.y-t.y,i=o*o+r*r,a=i?bt(((e.x-t.x)*o+(e.y-t.y)*r)/i,0,1):0;return Math.hypot(e.x-(t.x+a*o),e.y-(t.y+a*r))}function No(e,t){let s=Number.POSITIVE_INFINITY;for(let o=0;o<t.length-1;o++)s=Math.min(s,ko(e,t[o],t[o+1]));return s}function So(e,t){return Math.abs(t.x-e.x)<=e.w/2&&Math.abs(t.y-e.y)<=e.h/2}class Xe{cells=new Set;static CELL_W=12;static CELL_H=16;keys(t){const s=[],o=Math.floor(t.x0/Xe.CELL_W),r=Math.floor(t.x1/Xe.CELL_W),i=Math.floor(t.y0/Xe.CELL_H),a=Math.floor(t.y1/Xe.CELL_H);for(let l=o;l<=r;l++)for(let m=i;m<=a;m++)s.push(l*1e5+m);return s}isFree(t){return this.keys(t).every(s=>!this.cells.has(s))}reserve(t){for(const s of this.keys(t))this.cells.add(s)}}function jo(e,t,s,o,r){const i=e.slice(0,-1).map((p,f)=>({i:f,length:Math.hypot(e[f+1].x-p.x,e[f+1].y-p.y)})).sort((p,f)=>f.length-p.length);if(i.length===0)return null;const a=p=>({x0:p.x-t/2,x1:p.x+t/2,y0:p.y-s/2,y1:p.y+s/2}),l=p=>({x:(e[p].x+e[p+1].x)/2,y:(e[p].y+e[p+1].y)/2});for(const{i:p,length:f}of i){if(!r&&f<t*.7)break;const h=l(p);if(o.isFree(a(h)))return o.reserve(a(h)),h}if(!r)return null;const m=l(i[0].i),y=[-1,1,-1.6,1.6].map(p=>({x:m.x,y:m.y+p*(s+12)})).find(p=>o.isFree(a(p)))??m;return o.reserve(a(y)),y}const Eo=e=>n.jsx(Et,{icon:e||null,className:"h-4 w-4"}),Co='600 14px "DM Sans", system-ui, sans-serif',_o='400 11px "DM Sans", system-ui, sans-serif',Mo='500 9px "DM Sans", system-ui, sans-serif',To='500 11px "DM Sans", system-ui, sans-serif',at=18,pn=8;function hn(e){const t=getComputedStyle(e),s=(o,r)=>t.getPropertyValue(o).trim()||r;return{foreground:s("--foreground","#141414"),muted:s("--muted-foreground","#545454"),card:s("--card","#ffffff"),background:s("--background","#fcfcfb"),border:s("--border","#e7e4dc"),primary:s("--primary","#2f63e8"),mutedSurface:s("--muted","#f3f1ea")}}function mt(e,t,s){if(e.measureText(t).width<=s)return t;let o=0,r=t.length;for(;o<r;){const i=Math.ceil((o+r)/2);e.measureText(`${t.slice(0,i)}…`).width<=s?o=i:r=i-1}return`${t.slice(0,o)}…`}function Ro(e,t,s,o){const r=Math.hypot(s.x-t.x,s.y-t.y);if(r<1)return;const i=(s.x-t.x)/r,a=(s.y-t.y)/r;e.moveTo(s.x-i*o-a*o*.55,s.y-a*o+i*o*.55),e.lineTo(s.x,s.y),e.lineTo(s.x-i*o+a*o*.55,s.y-a*o-i*o*.55)}function cs({boxes:e,edges:t,label:s,onOpenBox:o,openLabel:r,onConnect:i,renderIcon:a=Eo,className:l}){const m=v.useRef(null),c=v.useRef(null),y=v.useRef(null),p=v.useRef({z:1,x:0,y:0}),f=v.useRef({w:0,h:0,dpr:1}),h=v.useRef(!0),x=v.useRef(new Map),d=v.useRef(null),N=v.useRef(null),_=v.useRef(new Map),j=v.useRef(null),E=v.useRef(""),k=v.useRef(!1),[b,w]=v.useState(()=>new Map),[M,P]=v.useState(null),[A,I]=v.useState(null),[F,B]=v.useState(null),[J,W]=v.useState(null),[se,me]=v.useState(0),{placed:X,movedIds:Ee}=v.useMemo(()=>{const C=new Map,u=new Set;for(const g of e){const S=b.get(g.id);S&&S.from.x===g.x&&S.from.y===g.y?(C.set(g.id,{...g,x:S.at.x,y:S.at.y}),u.add(g.id)):C.set(g.id,g)}return{placed:C,movedIds:u}},[e,b]),ue=v.useMemo(()=>{const C=new Map;for(const g of t){const S=[g.source,g.target].sort().join("|");C.set(S,[...C.get(S)??[],g])}const u=new Map;for(const g of t){const S=X.get(g.source),T=X.get(g.target);if(!S||!T)continue;if(g.route&&!Ee.has(S.id)&&!Ee.has(T.id)){u.set(g.id,g.route);continue}const R=C.get([g.source,g.target].sort().join("|"))??[g];u.set(g.id,wo(S,T,R.indexOf(g)-(R.length-1)/2))}return u},[t,X,Ee]),G=v.useCallback(()=>{h.current=!0},[]),te=v.useCallback(()=>{const C=fn([...X.values()]),{w:u,h:g}=f.current;!C||!u||!g||(p.current=vo(C,u,g),k.current=!0,G())},[X,G]),xe=C=>{p.current=C,k.current=!1,G()},Ce=C=>{const u=fn(C),{w:g,h:S}=f.current;if(!u||!g||!S)return;const T=p.current,R=24;u.x0*T.z+T.x>=R&&u.y0*T.z+T.y>=R&&u.x1*T.z+T.x<=g-R&&u.y1*T.z+T.y<=S-R||xe({...T,x:g/2-(u.x0+u.x1)/2*T.z,y:S/2-(u.y0+u.y1)/2*T.z})},Ve=C=>{W(C);const u=X.get(C);u&&Ce([u])},ie=e.map(C=>`${C.id}@${Math.round(C.x)},${Math.round(C.y)}`).join(";");v.useEffect(()=>{!ie||E.current===ie||f.current.w&&(E.current=ie,te())},[ie,te]);const ke=v.useRef(te);ke.current=te;const Ae=v.useRef(ie);Ae.current=ie,v.useEffect(()=>{const C=m.current,u=c.current;if(!C||!u||typeof ResizeObserver>"u")return;const g=()=>{const T=window.devicePixelRatio||1,R=C.clientWidth,O=C.clientHeight;f.current={w:R,h:O,dpr:T},u.width=Math.round(R*T),u.height=Math.round(O*T);const H=Ae.current;H&&R&&O&&(E.current!==H||k.current)&&(E.current=H,ke.current()),G()};g();const S=new ResizeObserver(g);return S.observe(C),()=>S.disconnect()},[G]);const[be,Ue]=v.useState(0);v.useEffect(()=>{const C=y.current,u=c.current;if(!C||!u)return;const g=hn(u).muted;for(const S of C.querySelectorAll("[data-icon-key]")){const T=S.dataset.iconKey??"";if(x.current.has(T))continue;const R=S.querySelector("svg"),O=R?null:S.querySelector("img")?.src;if(!R&&!O){x.current.set(T,S.textContent??"");continue}const H=new Image;if(H.onload=G,H.onerror=()=>{x.current.delete(T),Ue(z=>z+1)},R){const z=R.cloneNode(!0);z.getAttribute("width")||z.setAttribute("width","24"),z.getAttribute("height")||z.setAttribute("height","24");const D=new XMLSerializer().serializeToString(z).replaceAll("currentColor",g);H.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(D)}`}else O&&(H.src=O);x.current.set(T,H)}},[e,se,be,G]);const Ne=(C,u)=>{const g=p.current;return{x:(C-g.x)/g.z,y:(u-g.y)/g.z}},Pe=(C,u)=>{const g=p.current,S=Ne(C,u),T=M&&M.kind!=="edge"?X.get(M.box.id):void 0;if(T&&i){const z=gn(T);if(Math.hypot(z.x*g.z+g.x-C,z.y*g.z+g.y-u)<=pn+3)return{kind:"handle",box:T}}const R=[...X.values()];for(let z=R.length-1;z>=0;z--)if(So(R[z],S))return{kind:"box",box:R[z]};let O=null,H=7/g.z;for(const z of t){const D=ue.get(z.id);if(!D)continue;const ce=No(S,D);ce<H&&(H=ce,O=z)}return O?{kind:"edge",edge:O}:null},fe=v.useMemo(()=>{const C=new Set;for(const g of[A,F])g&&C.add(g);M?.kind==="edge"&&C.add(M.edge.id);const u=M&&M.kind!=="edge"?M.box.id:J;if(u)for(const g of t)(g.source===u||g.target===u)&&C.add(g.id);for(const g of t)g.dimmed&&C.delete(g.id);return C},[t,M,A,F,J]);v.useEffect(G,[X,ue,fe,M,J,G]);const _e=v.useCallback(()=>{const C=c.current,u=C?.getContext("2d");if(!C||!u)return;const{w:g,h:S,dpr:T}=f.current,R=hn(C),O=getComputedStyle(C),H=new Map,z=$=>{let Y=H.get($);return Y===void 0&&(Y=O.getPropertyValue($).trim(),H.set($,Y)),Y},{z:D,x:ce,y:oe}=p.current,ve=$=>({x:$.x*D+ce,y:$.y*D+oe});u.setTransform(T,0,0,T,0,0),u.clearRect(0,0,g,S);const Re=M&&M.kind!=="edge"?M.box.id:null;u.lineJoin="round";for(const $ of t){const Y=ue.get($.id);if(!Y)continue;const Q=Y.map(ve),V=fe.has($.id);u.globalAlpha=$.dimmed?.15:V?.95:.55,u.strokeStyle=V?R.foreground:R.muted,u.lineWidth=V?1.75:1.25,u.beginPath(),u.moveTo(Q[0].x,Q[0].y);for(const Z of Q.slice(1))u.lineTo(Z.x,Z.y);$.directed&&Ro(u,Q[Q.length-2],Q[Q.length-1],8),u.stroke()}const Ge=new Xe;for(const $ of X.values()){const Y=ve($),Q=$.w*D,V=$.h*D,Z=Y.x-Q/2,q=Y.y-V/2;if(Ge.reserve({x0:Z,y0:q,x1:Z+Q,y1:q+V}),Z>g||q>S||Z+Q<0||q+V<0)continue;const Le=Re===$.id||j.current?.over?.id===$.id;u.globalAlpha=$.dimmed?.25:1,u.beginPath(),u.roundRect(Z,q,Q,V,8*D),u.fillStyle=$.muted?R.mutedSurface:R.card,u.fill(),u.lineWidth=Le||J===$.id?1.5:1,u.strokeStyle=Le||J===$.id?R.primary:R.border,u.stroke();const ne=$.accent&&z($.accent);if(ne&&(u.save(),u.clip(),u.fillStyle=ne,u.fillRect(Z,q,3*D,V),u.restore()),14*D<5)continue;const de=12*D,ee=16*D,le=$.meta?q+V/2-8*D:q+V/2,Se=x.current.get($.icon??"");Se instanceof HTMLImageElement&&Se.complete&&Se.naturalWidth>0?u.drawImage(Se,Z+de,le-ee/2,ee,ee):typeof Se=="string"&&Se&&(u.font=`${14*D}px system-ui, sans-serif`,u.textBaseline="middle",u.textAlign="left",u.fillText(Se,Z+de,le));const ze=Z+de+ee+8*D,st=12*D;u.textBaseline="middle",u.textAlign="left";let Ke=Z+Q-st-ze;if($.badge){u.font=Mo.replace("9px",`${9*D}px`);const rt=mt(u,$.badge.toUpperCase(),Ke*.35),Je=u.measureText(rt).width+8*D,ot=Z+Q-st-Je;u.strokeStyle=R.border,u.lineWidth=1,u.beginPath(),u.roundRect(ot,le-7*D,Je,14*D,3*D),u.stroke(),u.fillStyle=R.muted,u.fillText(rt,ot+4*D,le+.5),Ke-=Je+6*D}u.font=Co.replace("14px",`${14*D}px`),u.fillStyle=R.foreground,u.fillText(mt(u,$.title,Ke),ze,le+.5),$.meta&&(u.font=_o.replace("11px",`${11*D}px`),u.fillStyle=R.muted,u.fillText(mt(u,$.meta,Z+Q-de-ze),ze,q+V/2+10*D))}const Ie=j.current,qe=Ie?.from??(Re?X.get(Re):void 0);if(i&&qe&&qe.w*D>=60){const $=ve(gn(qe));if(u.globalAlpha=1,Ie){const Y=ve(Ie.to);u.strokeStyle=R.primary,u.lineWidth=2,u.setLineDash([6,4]),u.beginPath(),u.moveTo($.x,$.y),u.lineTo(Y.x,Y.y),u.stroke(),u.setLineDash([])}u.fillStyle=R.card,u.strokeStyle=R.primary,u.lineWidth=1.5,u.beginPath(),u.arc($.x,$.y,pn,0,Math.PI*2),u.fill(),u.stroke(),u.beginPath(),u.moveTo($.x-4,$.y),u.lineTo($.x+4,$.y),u.moveTo($.x,$.y-4),u.lineTo($.x,$.y+4),u.stroke()}u.font=To,u.textAlign="center",u.textBaseline="middle";const Ye=($,Y,Q,V)=>{u.globalAlpha=1,u.fillStyle=R.background,u.strokeStyle=Q?R.foreground:R.border,u.lineWidth=1,u.beginPath(),u.roundRect($.x-V/2,$.y-at/2,V,at,5),u.fill(),u.stroke(),u.fillStyle=Q?R.foreground:R.muted,u.fillText(Y,$.x,$.y+.5)},Mt=[...t].sort(($,Y)=>Number(fe.has(Y.id))-Number(fe.has($.id)));for(const $ of Mt){const Y=ue.get($.id);if(!Y||$.dimmed&&!fe.has($.id))continue;const Q=Y.map(ve),V=fe.has($.id),q=(V?$.details:[$.summary]).map(ee=>mt(u,ee,200)),Le=Math.max(...q.map(ee=>u.measureText(ee).width))+14,ne=q.length*(at+2);if(!V&&D<.45)continue;const de=jo(Q,Le,ne,Ge,V);de&&q.forEach((ee,le)=>{Ye({x:de.x,y:de.y-ne/2+(at+2)*le+at/2},ee,V,Le)})}u.globalAlpha=1},[t,ue,X,fe,M,J,i]);v.useEffect(()=>{let C=0;const u=()=>{C=requestAnimationFrame(u),h.current&&(h.current=!1,_e())};return C=requestAnimationFrame(u),document.addEventListener("visibilitychange",G),()=>{cancelAnimationFrame(C),document.removeEventListener("visibilitychange",G)}},[_e,G]),v.useEffect(()=>{const C=new MutationObserver(()=>{x.current.clear(),me(u=>u+1),G()});return C.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>C.disconnect()},[G]);const pe=(C,u,g)=>{const S=p.current,T=Math.min(3,Math.max(.15,S.z*C));xe({z:T,x:u-(u-S.x)*(T/S.z),y:g-(g-S.y)*(T/S.z)})},Me=C=>{const u=c.current?.getBoundingClientRect();return{x:C.clientX-(u?.left??0),y:C.clientY-(u?.top??0)}},re=C=>{if(C.button!==0&&C.pointerType==="mouse")return;C.currentTarget.setPointerCapture(C.pointerId);const u=Me(C);if(C.pointerType==="touch"&&(_.current.set(C.pointerId,u),_.current.size===2)){const[T,R]=[..._.current.values()];d.current=null,j.current=null,N.current={d:Math.hypot(T.x-R.x,T.y-R.y)||1,mid:{x:(T.x+R.x)/2,y:(T.y+R.y)/2}};return}const g=Pe(u.x,u.y),S={start:u,last:u,hit:g,moved:!1};if(g?.kind==="handle")j.current={from:g.box,to:Ne(u.x,u.y),over:null};else if(g?.kind==="box"){const T=Ne(u.x,u.y);S.grab={x:g.box.x-T.x,y:g.box.y-T.y}}d.current=S},nt=C=>{const u=Me(C);_.current.has(C.pointerId)&&_.current.set(C.pointerId,u);const g=N.current;if(g&&_.current.size===2){const[z,D]=[..._.current.values()],ce=Math.hypot(z.x-D.x,z.y-D.y)||1,oe={x:(z.x+D.x)/2,y:(z.y+D.y)/2};xe({...p.current,x:p.current.x+oe.x-g.mid.x,y:p.current.y+oe.y-g.mid.y}),pe(ce/g.d,oe.x,oe.y),N.current={d:ce,mid:oe};return}const S=d.current;if(!S){const z=Pe(u.x,u.y);P(ce=>Io(ce,z)?ce:z);const D=c.current;D&&(D.style.cursor=z?.kind==="handle"?"crosshair":z?"pointer":"grab");return}const T=u.x-S.last.x,R=u.y-S.last.y;if(S.last=u,!S.moved&&Math.hypot(u.x-S.start.x,u.y-S.start.y)>4&&(S.moved=!0),!S.moved)return;const O=j.current;if(O){O.to=Ne(u.x,u.y);const z=Pe(u.x,u.y);O.over=z?.kind==="box"?z.box:null,G();return}const H=S.hit;if(H?.kind==="box"&&S.grab){const z=Ne(u.x,u.y),D=e.find(oe=>oe.id===H.box.id);if(!D)return;const ce={x:z.x+S.grab.x,y:z.y+S.grab.y};w(oe=>new Map(oe).set(D.id,{at:ce,from:{x:D.x,y:D.y}}));return}xe({...p.current,x:p.current.x+T,y:p.current.y+R}),c.current&&(c.current.style.cursor="grabbing")},ge=C=>{if(_.current.delete(C.pointerId),N.current){_.current.size<2&&(N.current=null),d.current=null;return}const u=d.current;d.current=null;const g=j.current;if(j.current=null,!u)return;if(c.current&&(c.current.style.cursor="grab"),g){G(),g.over&&i&&i(g.from.id,g.over.id);return}if(u.moved)return;const S=u.hit;S?.kind==="box"?o(S.box.id):S?.kind==="edge"?I(T=>T===S.edge.id?null:S.edge.id):I(null)},Te=C=>{_.current.delete(C.pointerId),N.current=null,d.current=null,j.current=null,G()};v.useEffect(()=>{const C=c.current;if(!C)return;const u=g=>{g.preventDefault();const S=Me(g);g.ctrlKey||g.metaKey?pe(Math.exp(-g.deltaY*(g.ctrlKey?.01:.002)),S.x,S.y):xe({...p.current,x:p.current.x-g.deltaX,y:p.current.y-g.deltaY})};return C.addEventListener("wheel",u,{passive:!1}),()=>C.removeEventListener("wheel",u)});const De=C=>pe(C,f.current.w/2,f.current.h/2),Fe=[...new Set(e.map(C=>C.icon??""))];return n.jsxs("div",{ref:m,className:ae("relative h-full w-full overflow-hidden",l),children:[n.jsx("canvas",{ref:c,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:re,onPointerMove:nt,onPointerUp:ge,onPointerCancel:Te,onPointerLeave:()=>{d.current||P(null)}}),n.jsxs("ul",{ref:y,"aria-label":s,className:"sr-only",children:[Fe.map(C=>n.jsx("li",{"aria-hidden":"true","data-icon-key":C,children:a(C)},`icon:${C}`)),e.map(C=>n.jsx("li",{children:n.jsx("button",{type:"button",onClick:()=>o(C.id),onFocus:()=>Ve(C.id),onBlur:()=>W(null),children:r(C)})},C.id)),t.map(C=>n.jsx("li",{"data-revealed":fe.has(C.id)||void 0,children:n.jsx("button",{type:"button","aria-pressed":A===C.id,onClick:()=>I(u=>u===C.id?null:C.id),onFocus:()=>{B(C.id);const u=ue.get(C.id);u&&Ce(u.map(g=>({...g,w:0,h:0})))},onBlur:()=>B(null),children:C.ariaLabel})},C.id))]}),n.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>De(1.25),children:n.jsx(it,{className:"h-3.5 w-3.5"})}),n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>De(.8),children:n.jsx(Es,{className:"h-3.5 w-3.5"})}),n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:te,children:n.jsx(Cs,{className:"h-3.5 w-3.5"})}),Ee.size>0?n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>w(new Map),children:n.jsx(_s,{className:"h-3.5 w-3.5"})}):null]})]})}const gn=e=>({x:e.x+e.w/2,y:e.y});function Io(e,t){return!e||!t?e===t:e.kind==="edge"||t.kind==="edge"?e.kind==="edge"&&t.kind==="edge"&&e.edge.id===t.edge.id:e.kind===t.kind&&e.box.id===t.box.id}function Qt({label:e,fill:t=!1,schemaActions:s=!1}){return n.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:ae("flex min-w-0 flex-col gap-3",t&&"min-h-0 flex-1"),children:[n.jsx("div",{className:"flex min-w-0 items-center gap-3",children:n.jsx("div",{"aria-hidden":"true",className:"min-w-0 flex-1",children:n.jsx(We,{className:"h-5 w-3/4 max-w-xl rounded-none"})})}),n.jsxs("div",{className:ae("relative flex min-h-0 flex-col",t&&"flex-1"),"aria-hidden":"true",children:[s?n.jsxs("div",{className:"z-10 flex flex-wrap justify-end gap-2 lg:absolute lg:top-0 lg:right-0",children:[n.jsx(We,{className:"h-8 w-40 rounded-none"}),n.jsx(We,{className:"h-8 w-36 rounded-none"})]}):null,n.jsxs("div",{className:ae("relative min-h-[420px]",t?"flex-1":"h-[70vh]"),children:[n.jsxs("div",{className:"absolute top-1/2 left-1/2 flex h-16 w-52 -translate-x-1/2 -translate-y-1/2 items-center gap-3 rounded-xl border border-border bg-card px-4",children:[n.jsx(We,{className:"h-4 w-4 shrink-0 rounded-none"}),n.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[n.jsx(We,{className:"h-3.5 w-24 rounded-none"}),n.jsx(We,{className:"h-2.5 w-32 rounded-none"})]})]}),n.jsx("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:["in","out","fit"].map(o=>n.jsx("div",{className:"flex h-7 w-7 items-center justify-center border border-input bg-background",children:n.jsx(We,{className:"h-3 w-3 rounded-none"})},o))})]})]})]})}const yn={trigger:"runs on arrival",delivery:"delivers here"};function Lo(e){const t=new Map,s=(o,r,i,a)=>{const l=Number(o);if(!Number.isInteger(l)||l<=0)return;const m=t.get(l)??[],c=m.find(y=>y.automation.automation_id===r.automation_id);if(c){if(c.reason===i)for(const y of a)c.eventTypes.includes(y)||c.eventTypes.push(y);return}m.push({automation:r,reason:i,eventTypes:[...a]}),t.set(l,m)};for(const o of e){for(const r of o.triggers??[]){const i=Array.isArray(r.event_types)?r.event_types.map(String):[];s(r.connection_id,o,"trigger",i)}s(o.delivery_target?.connection_id,o,"delivery",[])}return t}function $o(e){const t=new Map;for(const s of e){const o=t.get(s.connection_id)??[];o.push(s),t.set(s.connection_id,o)}return t}function Oo(e){const t=(s,o,r)=>`${s} ${s===1?o:r}`;return[t(e.feeds,"feed","feeds"),e.actions>0?t(e.actions,"action","actions"):null,e.automations>0?t(e.automations,"Automation","Automations"):null].filter(Boolean).join(" · ")}function ft(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ft={exports:{}},xn;function Ao(){return xn||(xn=1,(function(e,t){(function(s){e.exports=s()})(function(){return(function(){function s(o,r,i){function a(c,y){if(!r[c]){if(!o[c]){var p=typeof ft=="function"&&ft;if(!y&&p)return p(c,!0);if(l)return l(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var h=r[c]={exports:{}};o[c][0].call(h.exports,function(x){var d=o[c][1][x];return a(d||x)},h,h.exports,s,o,r,i)}return r[c].exports}for(var l=typeof ft=="function"&&ft,m=0;m<i.length;m++)a(i[m]);return a}return s})()({1:[function(s,o,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;function i(f){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},i(f)}function a(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}function l(f,h){for(var x=0;x<h.length;x++){var d=h[x];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(f,c(d.key),d)}}function m(f,h,x){return h&&l(f.prototype,h),Object.defineProperty(f,"prototype",{writable:!1}),f}function c(f){var h=y(f,"string");return i(h)=="symbol"?h:h+""}function y(f,h){if(i(f)!="object"||!f)return f;var x=f[Symbol.toPrimitive];if(x!==void 0){var d=x.call(f,h);if(i(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}r.default=(function(){function f(){var h=this,x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},d=x.defaultLayoutOptions,N=d===void 0?{}:d,_=x.algorithms,j=_===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:_,E=x.workerFactory,k=x.workerUrl;if(a(this,f),this.defaultLayoutOptions=N,this.initialized=!1,typeof k>"u"&&typeof E>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var b=E;typeof k<"u"&&typeof E>"u"&&(b=function(P){return new Worker(P)});var w=b(k);if(typeof w.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new p(w),this.worker.postMessage({cmd:"register",algorithms:j}).then(function(M){return h.initialized=!0}).catch(console.err)}return m(f,[{key:"layout",value:function(x){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=d.layoutOptions,_=N===void 0?this.defaultLayoutOptions:N,j=d.logging,E=j===void 0?!1:j,k=d.measureExecutionTime,b=k===void 0?!1:k;return x?this.worker.postMessage({cmd:"layout",graph:x,layoutOptions:_,options:{logging:E,measureExecutionTime:b}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}])})();var p=(function(){function f(h){var x=this;if(a(this,f),h===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=h,this.worker.onmessage=function(d){setTimeout(function(){x.receive(x,d)},0)}}return m(f,[{key:"postMessage",value:function(x){var d=this.id||0;this.id=d+1,x.id=d;var N=this;return new Promise(function(_,j){N.resolvers[d]=function(E,k){E?(N.convertGwtStyleError(E),j(E)):_(k)},N.worker.postMessage(x)})}},{key:"receive",value:function(x,d){var N=d.data,_=x.resolvers[N.id];_&&(delete x.resolvers[N.id],N.error?_(N.error):_(null,N.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(x){if(x){var d=x.__java$exception;d&&(d.cause&&d.cause.backingJsObject&&(x.cause=d.cause.backingJsObject,this.convertGwtStyleError(x.cause)),delete x.__java$exception)}}}])})()},{}],2:[function(s,o,r){var i=s("./elk-api.js").default;Object.defineProperty(o.exports,"__esModule",{value:!0}),o.exports=i,i.default=i},{"./elk-api.js":1}]},{},[2])(2)})})(Ft)),Ft.exports}var Po=Ao();const Do=Ms(Po);function Fo(e){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:e?.name})}const zo=200,Wo=320,Ze=56,Bo=7.4,Ho=5.9,Vo=84,Uo=48;function ct(e,t){return Math.round(Math.min(Wo,Math.max(zo,Vo+e.length*Bo,Uo+t.length*Ho)))}function Go(e,t){const s=[];return e>0&&s.push(`${e} ${e===1?"field":"fields"}`),typeof t=="number"&&s.push(`${t.toLocaleString()} ${t===1?"record":"records"}`),s.join(" · ")}function bn(e,t){return e.slug<t.slug?-1:e.slug>t.slug?1:0}function ls(e,t){const s=new Set;return e.filter(o=>o.status!=="active"||o.organization_slug&&o.organization_slug!==t||s.has(o.slug)?!1:(s.add(o.slug),!0))}function qo(e){const t=e.metadata_schema;if(!t||typeof t!="object")return 0;const s=t.properties;return!s||typeof s!="object"?0:Object.keys(s).length}function ds(e){const{entityTypes:t,relationshipTypes:s,rulesBySlug:o}=e,r=e.ownerSlug??"",i=[...t].sort(bn),a=ls(s,r).sort(bn),l=b=>!b.organization_slug||b.organization_slug===r,m=b=>b.organization_slug||r,c=new Map;for(const b of i)c.set(b.slug,[...c.get(b.slug)??[],b]);const y=b=>(c.get(b.slug)?.length??0)>1?`${m(b)}:${b.slug}`:b.slug,p=new Set(i.filter(l).map(y)),f=b=>{const w=c.get(b)??[];return w.find(l)??(w.length===1?w[0]:void 0)},h=new Set(p),x=a.flatMap(b=>[...o[b.slug]??[]].sort((w,M)=>w.id-M.id).flatMap(w=>{const M=f(w.source_entity_type_slug),P=f(w.target_entity_type_slug);if(!M||!P)return[];const A=y(M),I=y(P);return!p.has(A)&&!p.has(I)?[]:(h.add(A),h.add(I),[{rt:b,source:A,target:I}])})),d=i.filter(b=>h.has(y(b))),N=[],_=new Map,j=new Map;for(const{rt:b,source:w,target:M}of x){const P=`${b.slug}|${w}|${M}`,A=j.get(P);if(A){A.ruleCount+=1;continue}const I={slug:b.slug,label:b.name||b.slug,ruleCount:1};j.set(P,I);const F=`${w}|${M}`,B=_.get(F);if(B){B.data.relationships.push(I),B.data.isSymmetric=B.data.isSymmetric&&b.is_symmetric;continue}const J={id:`pair:${w}|${M}`,source:w,target:M,data:{relationships:[I],isSymmetric:b.is_symmetric}};_.set(F,J),N.push(J)}const E=new Map;for(const{rt:b,source:w,target:M}of x){const P=E.get(b.slug)??new Set;P.add(`${w}|${M}`),E.set(b.slug,P)}for(const{rt:b}of x)if(E.get(b.slug)?.size===1&&typeof b.relationship_count=="number")for(const w of j.values())w.slug===b.slug&&(w.linkCount=b.relationship_count);return{nodes:d.map(b=>{const w=b.name||b.slug,M=qo(b),P=Go(M,b.entity_count);return{id:y(b),width:ct(w,P),height:Ze,data:{slug:b.slug,label:w,icon:b.icon,isSystem:$n(b),organizationSlug:l(b)?void 0:m(b),metaLabel:P}}}),edges:N}}const we=24,Yo=72,Ko=16,Jo=48,Xo=64,zt=16,Qo=720;function Zo(e,t){const s=new Map(e.map(i=>[i.id,i.id])),o=i=>{const a=s.get(i)??i;if(a===i)return i;const l=o(a);return s.set(i,l),l};for(const i of t)s.set(o(i.source),o(i.target));const r=new Map;for(const i of e){const a=o(i.id);r.set(a,[...r.get(a)??[],i])}return[...r.values()].sort((i,a)=>a.length-i.length)}function ea(e,t,s,o){const r=new Map(e.flatMap((y,p)=>y.map(f=>[f.id,p]))),i=e.map(()=>({top:1/0,bottom:-1/0})),a=(y,p,f)=>{const h=i[r.get(y)??0];h.top=Math.min(h.top,p),h.bottom=Math.max(h.bottom,f)};for(const y of t)a(y.id,y.position.y,y.position.y+y.height);for(const y of s)for(const p of o.get(y.id)??[])a(y.source,p.y,p.y);let l=we;const m=i.map(({top:y,bottom:p})=>{const f=l-y;return l=p+f+Jo,f}),c=y=>m[r.get(y)??0];for(const y of s){const p=o.get(y.id);p&&o.set(y.id,p.map(f=>({x:f.x,y:f.y+c(y.source)})))}return t.map(y=>({...y,position:{x:y.position.x,y:y.position.y+c(y.id)}}))}function ta(e,t){const s=we,o=Math.max(s+Qo,...t.map(l=>l.position.x+l.width));let r=t.length>0?Math.max(...t.map(l=>l.position.y+l.height))+Xo:we;const i=[...new Set(e.map(l=>l.lane??0))].sort((l,m)=>l-m),a=[];for(const l of i){let m=s,c=0;for(const y of e.filter(p=>(p.lane??0)===l))m>s&&m+y.width>o&&(m=s,r+=c+zt,c=0),a.push({...y,position:{x:m,y:r}}),m+=y.width+zt,c=Math.max(c,y.height);r+=c+zt*2}return a}let vn=null;function na(){return vn??=new Do({workerFactory:()=>new Fo}),vn}const Wt={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"48","elk.spacing.edgeEdge":"14","elk.spacing.edgeNode":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.crossingMinimization.semiInteractive":"true"};async function Zt(e,{elk:t=na(),targetAspect:s}={}){const o=new Set;for(const b of e.edges)o.add(b.source),o.add(b.target);const r=e.nodes.some(b=>b.lane!==void 0),i=e.nodes.filter(b=>o.has(b.id)),a=r?Zo(i,e.edges):[i],l=a.flat(),m=e.nodes.filter(b=>!o.has(b.id)),c=r?[]:m,y=r?m:[],p=c.reduce((b,w)=>Math.max(b,w.width),0),f=c.length>0?we+p+Yo:0,h=b=>({x:b.x+we+f,y:b.y+we});let x=[];const d=new Map;if(l.length>0){const b=e.edges.filter(I=>I.source!==I.target),w=I=>t.layout({id:"root",layoutOptions:r?{...I,"elk.partitioning.activate":"true","elk.separateConnectedComponents":"false"}:I,children:l.map(F=>({id:F.id,width:F.width,height:F.height,...r?{layoutOptions:{"elk.partitioning.partition":String(F.lane??1)}}:{}})),edges:b.map(F=>({id:F.id,sources:[F.layoutReversed?F.target:F.source],targets:[F.layoutReversed?F.source:F.target]}))});let M=await w(Wt);const P=s&&M.width&&M.height?s*M.width/M.height:1;if(P>1.08){const I=Number(Wt["elk.spacing.nodeNode"]),F=Math.min(P,2.2);M=await w({...Wt,"elk.spacing.nodeNode":String(Math.round(Math.min(180,I*F+Ze*(F-1))))})}const A=new Map((M.children??[]).map(I=>[I.id,I]));x=l.map(I=>{const F=A.get(I.id);return{...I,position:h({x:F?.x??0,y:F?.y??0})}});for(const I of M.edges??[]){const F=(I.sections??[]).flatMap(J=>[J.startPoint,...J.bendPoints??[],J.endPoint]);if(F.length<2)continue;const B=e.edges.find(J=>J.id===I.id)?.layoutReversed;d.set(I.id,(B?[...F].reverse():F).map(h))}}let N=we;const _=c.map(b=>{const w={x:we,y:N};return N+=b.height+Ko,{...b,position:w}});r&&(x=ea(a,x,e.edges,d));const j=ta(y,x),E=new Map([...x,..._,...j].map(b=>[b.id,b]));return{nodes:e.nodes.map(b=>E.get(b.id)??{...b,position:{x:we,y:we}}),edges:e.edges.map(b=>({...b,route:d.get(b.id)??null}))}}function sa(e,t){return Zt(ds(e),t)}const Ut="connector:",wn=e=>`${Ut}${e}`,ra={event:"Zap",schedule:"CalendarClock",manual:"Hand"},oa=0,aa=1,kn=2;function ia(e,t){const s=new Map;for(const{kind:o,targets:r}of Yr(e?.feeds_schema?.[t]))for(const{entityType:i,creates:a}of r){const l=s.get(i)??{creates:!1,eventKinds:new Set};l.creates||=a,l.eventKinds.add(o),s.set(i,l)}return s}function ca(e,t){const s=new Map(e.connectorDefs.map(d=>[d.key,d])),o=new Map(e.connectorDefs.map(d=>[d.key,d.name])),r=new Map(e.connections.map(d=>[d.id,d])),i=$o(e.feeds),a=d=>`connection:${d}`,l=d=>`automation:${d}`,m=[],c=(d,N,_,j,E=!1)=>{m.push({id:`flow:${d}->${N}`,source:d,target:N,layoutReversed:E,data:{relationships:[],isSymmetric:!1,flow:{summary:_,details:j}}})},y=new Set(e.connections.map(d=>d.id));for(const d of e.connections){const N=new Map;for(const _ of i.get(d.id)??[]){const j=ia(s.get(d.connector_key),_.feed_key);for(const[E,k]of j){const b=N.get(E)??{creates:!1,eventKinds:new Set};b.creates||=k.creates;for(const w of k.eventKinds)b.eventKinds.add(w);N.set(E,b)}}for(const[_,j]of N){const E=t.get(_);E&&c(a(d.id),E,j.creates?"creates records":"links records",[`From ${[...j.eventKinds].sort().join(", ")} events`])}}const p=Lo(e.automations);for(const[d,N]of p)if(y.has(d))for(const{automation:_,reason:j,eventTypes:E}of N){const k=l(_.automation_id);j==="trigger"?c(a(d),k,yn.trigger,E.length>0?[`On ${[...E].sort().join(", ")}`]:[]):c(k,a(d),yn.delivery,[],!0)}const f=[];for(const d of e.automations){const N=l(d.automation_id),_=d.entity_type?t.get(d.entity_type):void 0;_&&c(_,N,"anchored here",[d.entity_name?`On ${d.entity_name}`:""].filter(Boolean));const j=Ts(d,o,r),E=Rs(d),k=d.health==="degraded"?"Needs attention":void 0;f.push({id:N,lane:kn,width:ct(`${j.does} ${k??""}`,j.when),height:Ze,data:{slug:N,label:j.does,icon:E?wn(E):ra[j.kind],isSystem:!1,badge:k,metaLabel:j.when,ref:{kind:"automation",automationId:d.automation_id}}})}const h=[];for(const d of e.metrics){const N=t.get(d.typeSlug);if(!N)continue;const _=`metric:${d.typeSlug}:${d.name}`;c(N,_,"measures",[d.description].filter(Boolean)),h.push({id:_,lane:kn,width:ct(d.name,d.agg),height:Ze,data:{slug:_,label:d.name,icon:"ChartColumn",isSystem:!1,metaLabel:d.agg,ref:{kind:"metric",typeSlug:d.typeSlug,name:d.name}}})}return{nodes:[...e.connections.map(d=>{const N=Is(d),_=Ls(d,s.get(d.connector_key)),j=Oo({feeds:i.get(d.id)?.length||d.feed_count,actions:d.operations_summary?.total??0,automations:p.get(d.id)?.length??0}),E=_.needsAttention?"Needs attention":d.device_label??void 0;return{id:a(d.id),lane:oa,width:ct(`${N} ${E??""}`,j),height:Ze,data:{slug:a(d.id),label:N,icon:wn(d.connector_key),isSystem:!1,badge:E,metaLabel:j,ref:{kind:"connection",connectorKey:d.connector_key,connectionId:d.id}}}}),...f,...h],edges:m}}function us(e){switch(e.data.ref?.kind){case"connection":return"connections";case"automation":return"automations";case"metric":return"metrics";default:return"entities"}}function la(e,t){const s=new Map;for(const m of e.nodes)(!m.data.organizationSlug||!s.has(m.data.slug))&&s.set(m.data.slug,m.id);const o=ca(t,s),{layers:r}=t,i=[...o.nodes,...e.nodes.map(m=>({...m,lane:aa}))].filter(m=>r[us(m)]),a=new Set(i.map(m=>m.id)),l=[...e.edges,...o.edges].filter(m=>a.has(m.source)&&a.has(m.target));return{nodes:i,edges:l}}const Nn="__new__";function Sn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function da({entityTypes:e,initialSource:t="",initialTarget:s="",onDone:o}){const r=v.useId(),i=`${r}-relationship`,a=`${r}-name`,l=`${r}-symmetric`,m=`${r}-source`,c=`${r}-target`,{orgContext:y}=Oe(),{data:p=[]}=Kt(y),f=$s(),h=Os(),[x,d]=v.useState(""),[N,_]=v.useState(""),[j,E]=v.useState(!1),[k,b]=v.useState(t),[w,M]=v.useState(s),[P,A]=v.useState(null),I=x===Nn,F=p.filter(W=>W.status==="active"&&W.purpose!==As&&(!W.organization_slug||W.organization_slug===y?.slug)),B=f.isPending||h.isPending,J=async()=>{if(A(null),!x)return A("Pick a relationship");if(!k||!w)return A("Pick both ends");try{let W=x;if(I){const se=N.trim();if(!se)return A("Name the relationship");const me=Sn(se);if(!me)return A("Name must contain a letter or number");W=(await f.mutateAsync({slug:me,name:se,is_symmetric:j})).relationship_type.slug,d(W)}await h.mutateAsync({slug:W,source_entity_type_slug:k,target_entity_type_slug:w}),o()}catch(W){A(W instanceof Error?W.message:"Could not save")}};return n.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[n.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Relationships are defined once for the workspace, then paired with the types they connect."}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:i,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),n.jsxs(Lt,{value:x,onValueChange:d,children:[n.jsx($t,{id:i,className:"h-8 text-xs",children:n.jsx(Ot,{placeholder:"Pick or define one"})}),n.jsxs(At,{children:[F.map(W=>n.jsx(ut,{value:W.slug,children:W.name||W.slug},W.slug)),F.length>0?n.jsx(Ps,{}):null,n.jsx(ut,{value:Nn,children:"Define a new one…"})]})]})]}),I?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:a,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),n.jsx(et,{id:a,value:N,onChange:W=>_(W.target.value),placeholder:"works at",className:"h-8 text-xs"}),N.trim()?n.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",n.jsx("code",{children:Sn(N)||"—"})]}):null]}),n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs($e,{htmlFor:l,className:"text-xs font-normal",children:["Symmetric",n.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Both ends mean the same thing, like “connected with”."})]}),n.jsx(Ds,{id:l,checked:j,onCheckedChange:E})]})]}):null,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:m,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),n.jsxs(Lt,{value:k,onValueChange:b,children:[n.jsx($t,{id:m,className:"h-8 text-xs",children:n.jsx(Ot,{placeholder:"Type"})}),n.jsx(At,{children:e.map(W=>n.jsx(ut,{value:W.slug,children:W.label},W.slug))})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),n.jsxs(Lt,{value:w,onValueChange:M,children:[n.jsx($t,{id:c,className:"h-8 text-xs",children:n.jsx(Ot,{placeholder:"Type"})}),n.jsx(At,{children:e.map(W=>n.jsx(ut,{value:W.slug,children:W.label},W.slug))})]})]}),P?n.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P}):null,n.jsx(On,{onCancel:o,cancelDisabled:B,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:n.jsx(U,{type:"button",size:"sm",onClick:J,disabled:B,children:B?"Saving…":"Add relationship"})})]})}const ms=288,ua=440,vt=240,wt=720,ma=320,en="lobu.schema-panel-width:v1";function kt(e,t){if(!Number.isFinite(e))return ms;const s=Math.max(vt,Math.min(wt,t-ma));return Math.round(Math.min(s,Math.max(vt,e)))}function fa(){const e=An(en);if(e===null)return null;const t=Number.parseInt(e,10);return!Number.isFinite(t)||t<vt||t>wt?null:t}function pa(e){Pn(en,String(Math.round(e)))}function ha(){Fs(en)}const jn={nodes:[],edges:[]};function ga(e,t,s){const{orgContext:o}=Oe(),{data:r=[],isLoading:i,isError:a}=Ct(o),{data:l=[],isLoading:m,isError:c}=Kt(o),y=v.useMemo(()=>ls(l,e),[l,e]),{data:p,isLoading:f,isError:h}=zs(o),x=v.useMemo(()=>{const k=new Map(y.map(w=>[w.id,w.slug])),b={};for(const w of p??[]){const M=k.get(w.relationship_type_id);M&&(b[M]??=[]).push(w)}return b},[p,y]),d=v.useMemo(()=>({entityTypes:r,relationshipTypes:y,rulesBySlug:x,ownerSlug:e,targetAspect:t,flow:s}),[r,y,x,e,t,s]),[N,_]=v.useState(null),j=i||m||f,E=a||c||h;return v.useEffect(()=>{if(j||E)return;let k=!1;const b={targetAspect:d.targetAspect};let w;return d.flow?w=Zt(la(ds(d),d.flow),b):w=sa(d,b),w.then(M=>{k||_({graph:M,isError:!1})}).catch(()=>{k||_({graph:jn,isError:!0})}),()=>{k=!0}},[d,j,E]),{graph:N?.graph??jn,isLoading:!E&&!N,isError:E||N?.isError===!0}}function En(e){const t=e.ruleCount>1?` ×${e.ruleCount}`:"",s=typeof e.linkCount=="number"?` · ${e.linkCount.toLocaleString()}`:"";return`${e.label}${t}${s}`}const Gt={connections:"--chart-3",entities:"--chart-5",automations:"--chart-2",metrics:"--chart-4"};function ya(e,t){const s=e.nodes.some(a=>a.data.ref),o=new Map(e.nodes.map(a=>[a.id,a.data.label])),r=e.nodes.map(a=>({id:a.id,x:a.position.x+a.width/2,y:a.position.y+a.height/2,w:a.width,h:a.height,title:a.data.label,meta:a.data.metaLabel,icon:a.data.icon,badge:a.data.badge??a.data.organizationSlug,muted:a.data.isSystem,dimmed:t?!t.nodes.has(a.id):!1,accent:s?Gt[us(a)]:void 0})),i=e.edges.map(a=>{const{relationships:l,isSymmetric:m,flow:c}=a.data;if(c)return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:c.summary,details:[c.summary,...c.details],directed:!0,dimmed:t?!t.edges.has(a.id):!1,ariaLabel:`${o.get(a.source)??a.source} to ${o.get(a.target)??a.target}: ${c.summary}`};const y=l.map(p=>p.label).join(", ");return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:l.length===1?En(l[0]):`${l.length} relationships`,details:l.map(En),directed:!m,dimmed:t?!t.edges.has(a.id):!1,ariaLabel:`${o.get(a.source)??a.source} ${m?"and":"to"} ${o.get(a.target)??a.target}: ${y}`}});return{boxes:r,edges:i}}const Cn=[{key:"connections",label:"Connections"},{key:"entities",label:"Entities"},{key:"automations",label:"Automations"},{key:"metrics",label:"Metrics"}],xa={count:"Count",count_distinct:"Distinct count",sum:"Sum",min:"Minimum",max:"Maximum"};function ba({metric:e,ownerSlug:t}){const s=(o,r)=>r.length>0?n.jsxs("section",{className:"flex flex-col gap-1.5",children:[n.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),n.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:r.map(i=>n.jsxs("li",{children:[n.jsx("span",{className:"font-medium",children:i.name}),i.description?n.jsx("span",{className:"text-muted-foreground",children:` · ${i.description}`}):null]},i.name))})]}):null;return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"flex flex-col gap-1",children:[n.jsxs("p",{className:"text-sm",children:[xa[e.agg]??e.agg," of"," ",n.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:e.eventSet})," ","events, per ",e.typeLabel]}),e.description?n.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}):null]}),s("Data from",e.sources.map(o=>({name:o,description:""}))),s("Group by",e.dimensions),s("Segments",e.segments),n.jsx(U,{asChild:!0,variant:"outline",size:"sm",className:"self-start",children:n.jsxs(He,{to:"/$owner/$entityType",params:{owner:t,entityType:e.typeSlug},children:["Open ",e.typeLabel]})})]})}function va({ownerSlug:e,metric:t,endpointOptions:s,canAuthor:o,mode:r,onModeChange:i}){const a=()=>i({kind:"index"});return r.kind==="metric"?t?n.jsx(ba,{metric:t,ownerSlug:e}):null:o?r.kind==="create-type"?n.jsx(Kr,{slug:null,onClose:a}):r.kind==="new-relationship"?n.jsx(da,{entityTypes:s,initialSource:r.source,initialTarget:r.target,onDone:a},`${r.source??""}|${r.target??""}`):null:null}function wa(e){const{mode:t,canAuthor:s,onModeChange:o,isPeekOpen:r}=e,i=s&&t.kind==="create-type",a=t.kind==="metric"?t.name:s&&t.kind==="new-relationship"?"New relationship":i?"New entity type":"Data map",l=v.useRef(null),m=JSON.stringify(t),c=v.useRef(m);return v.useEffect(()=>{c.current!==m&&(c.current=m,l.current?.focus({preventScroll:!0}))},[m]),n.jsx("aside",{style:{"--schema-panel-width":`${e.width}px`},className:ae("order-first flex w-full shrink-0 flex-col lg:order-none lg:w-[var(--schema-panel-width)]",t.kind==="index"?"lg:absolute lg:top-0 lg:right-6 lg:z-10 lg:w-max lg:max-w-[calc(100%-3rem)] lg:max-h-[calc(100%-2rem)]":"bg-background lg:relative",r&&"lg:hidden"),children:n.jsxs("div",{className:ae("flex min-h-0 flex-1 flex-col",t.kind!=="index"&&"lg:absolute lg:inset-0"),children:[n.jsxs("div",{className:t.kind==="index"?"sr-only":"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[n.jsx("h2",{ref:l,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:a}),t.kind!=="index"?n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Close",onClick:()=>o({kind:"index"}),children:n.jsx(Ks,{className:"h-4 w-4"})}):null]}),n.jsx("div",{className:ae("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",t.kind==="index"?"pb-1":"p-4"),children:n.jsx(va,{...e})})]})})}function fs(e){const t=e.previousElementSibling,s=e.nextElementSibling;if(t instanceof HTMLElement&&s instanceof HTMLElement){const o=t.clientWidth+s.clientWidth;if(o>0)return o}return 0}function ka({width:e,maxWidth:t,onResize:s,onCommit:o,onReset:r,className:i}){const[a,l]=v.useState(!1),m=v.useRef(0),c=f=>{const h=fs(f);return h>0?h:f.parentElement?.clientWidth??0},y=f=>{if(f.button!==0)return;const h=f.currentTarget;if(!h.parentElement)return;f.preventDefault(),m.current=c(h);const d=f.clientX,N=e;l(!0),h.setPointerCapture(f.pointerId);const _=b=>kt(N-(b-d),m.current);let j=N;const E=b=>{j=_(b.clientX),s(j)},k=b=>{h.removeEventListener("pointermove",E),h.removeEventListener("pointerup",k),h.removeEventListener("pointercancel",k),l(!1),o(b.type==="pointercancel"?j:_(b.clientX))};h.addEventListener("pointermove",E),h.addEventListener("pointerup",k),h.addEventListener("pointercancel",k)},p=f=>{const h=c(f.currentTarget),x=d=>{f.preventDefault(),o(kt(e+d,h))};f.key==="ArrowLeft"?x(16):f.key==="ArrowRight"?x(-16):f.key==="Home"&&(f.preventDefault(),r())};return n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize map panel","aria-valuenow":e,"aria-valuemin":vt,"aria-valuemax":t,tabIndex:0,onPointerDown:y,onKeyDown:p,onDoubleClick:r,className:ae("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",a&&"cursor-col-resize",i),children:n.jsx("div",{className:ae("w-px rounded-full bg-border transition-[background-color,width] group-hover:w-0.5 group-hover:bg-primary/60 group-focus-visible:w-0.5 group-focus-visible:bg-primary",a&&"w-0.5 bg-primary")})})}function Na({ownerSlug:e}){const t=tt(),s=Jt(),o=s?.item!=null,{orgContext:r}=Oe(),{isAdmin:i}=Dn(r.organizationId),[a,l]=v.useState({connections:!0,entities:!0,automations:!0,metrics:!0}),[m,c]=v.useState({kind:"index"}),y=s?.close,p=v.useCallback(g=>{g.kind!=="index"&&o&&y?.(),c(g)},[o,y]),[f,h]=v.useState(),x=v.useRef(null),d=v.useCallback(g=>{if(x.current?.disconnect(),x.current=null,!g||typeof ResizeObserver>"u")return;const S=()=>{if(!g.clientWidth||!g.clientHeight)return;const R=Math.round(g.clientHeight/g.clientWidth*10)/10;h(O=>O===R?O:R)};S();const T=new ResizeObserver(S);T.observe(g),x.current=T},[]),N=r.organizationId,_=Ws(N),j=Bs(N),E=Hs(N),k=qr(N??void 0),{data:b}=Ct(r),w=v.useMemo(()=>b?.filter(g=>Vs(g,e)),[b,e]),M=v.useMemo(()=>(w??[]).flatMap(g=>Object.entries(g.metrics_config?.measures??{}).map(([S,T])=>({typeSlug:g.slug,name:S,agg:T.agg,description:T.description}))),[w]),P=_.isLoading||j.isLoading||E.isLoading||k.isLoading,A=v.useMemo(()=>P?null:{connections:_.data??[],feeds:j.data??[],connectorDefs:E.data??[],automations:k.data??[],metrics:M,layers:a},[P,_.data,j.data,E.data,k.data,M,a]),{graph:I,isLoading:F,isError:B}=ga(e,f,A),J=F||P,W={connections:!P&&(_.data??[]).length===0,entities:!1,automations:!P&&(k.data??[]).length===0,metrics:!P&&M.length===0},se=m.kind==="metric"?m:null,me=v.useMemo(()=>{if(!se)return null;const g=`metric:${se.typeSlug}:${se.name}`,S=I.edges.find(O=>O.target===g);if(!S)return null;const T=S.source,R=I.edges.filter(O=>O.target===T&&I.nodes.find(H=>H.id===O.source)?.data.ref?.kind==="connection");return{typeId:T,nodes:new Set([g,T,...R.map(O=>O.source)]),edges:new Set([S.id,...R.map(O=>O.id)]),sources:R.map(O=>I.nodes.find(H=>H.id===O.source)?.data.label??O.source)}},[se,I]),{boxes:X,edges:Ee}=v.useMemo(()=>ya(I,me),[I,me]),ue=v.useMemo(()=>{if(!se)return null;const g=w?.find(R=>R.slug===se.typeSlug),S=g?.metrics_config,T=S?.measures?.[se.name];return!g||!T?null:{name:se.name,typeSlug:g.slug,typeLabel:g.name||g.slug,agg:T.agg,eventSet:T.eventSet,description:T.description,dimensions:Object.entries(S?.dimensions??{}).map(([R,O])=>({name:R,description:O.description})),segments:Object.entries(S?.segments??{}).map(([R,O])=>({name:R,description:O.description})),sources:me?.sources??[]}},[se,w,me]),G=v.useMemo(()=>new Map(I.nodes.map(g=>[g.id,g.data.slug])),[I.nodes]),te=v.useMemo(()=>new Map(I.nodes.flatMap(g=>g.data.ref?[[g.id,g.data.ref]]:[])),[I.nodes]),{data:xe=[]}=Us(r.organizationId),Ce=v.useMemo(()=>{const g=new Map;for(const S of I.nodes)S.data.ref||(!S.data.organizationSlug||!g.has(S.data.slug))&&g.set(S.data.slug,{slug:S.data.slug,label:S.data.label});return[...g.values()]},[I.nodes]),Ve=v.useCallback(g=>{const S=te.get(g);if(S?.kind==="connection"){t({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:S.connectorKey,connectionId:String(S.connectionId)},search:{}});return}if(S?.kind==="metric"){p({kind:"metric",typeSlug:S.typeSlug,name:S.name});return}if(S?.kind==="automation"){t({to:"/$owner/automations/$automationId",params:{owner:e,automationId:S.automationId},search:{view:"activity",run_id:void 0}});return}t(Fn(e,G.get(g)??g))},[t,e,G,te,p]),ie=v.useCallback((g,S)=>{te.has(g)||te.has(S)||p({kind:"new-relationship",source:G.get(g)??g,target:G.get(S)??S})},[G,te,p]),ke=!!w?.some(g=>!$n(g)),Ae=I.nodes.some(g=>g.data.ref),be="size-6 text-muted-foreground hover:text-foreground",Ue={connections:n.jsx(Gr,{ownerSlug:e,catalog:xe,trigger:n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:be,"aria-label":"New connector",title:"New connector",children:n.jsx(it,{className:"size-3.5"})})}),entities:n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:be,"aria-label":"Create entity type",title:"Create entity type",onClick:()=>p({kind:"create-type"}),children:n.jsx(it,{className:"size-3.5"})}),automations:n.jsx(U,{asChild:!0,variant:"ghost",size:"icon",className:be,children:n.jsx(He,{to:"/$owner/automations/new",params:{owner:e},"aria-label":"New Automation",title:"New Automation",children:n.jsx(it,{className:"size-3.5"})})})},Ne=v.useCallback(g=>{const S=g.startsWith(Ut)?g.slice(Ut.length):null;if(!S)return n.jsx(Et,{icon:g||null,className:"h-4 w-4"});const T=Gs(S,E.data??[],{name:_.data?.find(R=>R.connector_key===S)?.connector_name??S});return n.jsx(qs,{plain:!0,icon:T.icon,iconUrl:T.iconUrl,name:T.name,faviconDomain:T.faviconDomain})},[E.data,_.data]),Pe=i&&m.kind==="create-type",fe=m.kind==="metric"||i&&m.kind!=="index",[_e,pe]=v.useState(()=>fa()),Me=_e??(Pe?ua:ms),[re,nt]=v.useState(null),ge=v.useRef(null),Te=v.useCallback(g=>{if(ge.current?.disconnect(),ge.current=null,!g||typeof ResizeObserver>"u")return;const S=g.children[1];if(!S)return;const T=()=>{const O=fs(S);O>0&&nt(H=>H===O?H:O)};T();const R=new ResizeObserver(T);R.observe(g),ge.current=R},[]),De=re===null?Me:kt(Me,re),Fe=re===null?wt:kt(wt,re),C=v.useCallback(g=>{pe(g),pa(g)},[]),u=v.useCallback(()=>{pe(null),ha()},[]);return J?n.jsx(Qt,{label:"Loading data map",fill:!0,schemaActions:i}):B?n.jsx("div",{className:"flex min-w-0 flex-col gap-3",children:n.jsx(zn,{label:"data map"})}):n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[n.jsxs("div",{className:ae("flex flex-wrap items-center justify-between gap-3",fe&&"hidden lg:flex"),children:[n.jsx("div",{className:"flex min-w-0 items-center gap-3",children:n.jsx("p",{className:"min-w-0 text-sm text-muted-foreground",children:Ae?"Where records come from and what uses them.":ke?I.edges.length>0?"Your record types and how they relate.":"Your record types.":i?"Add the types of record you track.":"No record types yet."})}),n.jsxs("fieldset",{className:"m-0 flex min-w-0 shrink-0 flex-wrap items-center gap-x-4 gap-y-1 border-0 p-0 text-sm",children:[n.jsx("legend",{className:"sr-only",children:"Show on the map"}),Cn.map(({key:g,label:S})=>{const T=`memory-map-show-${g}`,R=a[g]&&!W[g]&&Cn.filter(({key:O})=>a[O]&&!W[O]).length===1;return n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Ys,{id:T,checked:a[g],disabled:R,style:{borderColor:`var(${Gt[g]})`,backgroundColor:a[g]?`var(${Gt[g]})`:void 0},onCheckedChange:O=>l(H=>({...H,[g]:O===!0}))}),n.jsx("label",{htmlFor:T,className:"inline-flex cursor-pointer select-none items-center",children:S}),i?Ue[g]:null]},g)})]})]}),n.jsxs("div",{ref:Te,className:"relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 lg:-mr-6 lg:-mb-8 lg:flex-row lg:gap-0",children:[n.jsx("div",{className:ae("flex min-w-0 flex-1 flex-col lg:pb-8",fe&&"hidden lg:flex"),children:n.jsx("div",{ref:d,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:n.jsx(cs,{boxes:X,edges:Ee,label:"Data map",onOpenBox:Ve,openLabel:g=>`Open ${g.title}`,onConnect:i?ie:void 0,renderIcon:Ne})})}),n.jsx(ka,{width:De,maxWidth:Fe,onResize:pe,onCommit:C,onReset:u,className:o||m.kind==="index"?"lg:hidden":void 0}),n.jsx(wa,{width:De,metric:ue,ownerSlug:e,endpointOptions:Ce,canAuthor:i,mode:m,onModeChange:p,isPeekOpen:o})]})]})}function Sa({onClose:e,entityTypeSlug:t,orgContext:s,onSuccess:o}){const{data:r,isLoading:i}=Wn(t,s),a=`${s.organizationId??s.slug}:${t}`,l=Js(a,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},r?.metadata_schema),[m,c]=l.field("name"),[y,p]=l.field("customSlug"),[f,h]=l.field("useCustomSlug"),[x,d]=l.field("metadata"),[N,_]=Xs(a,null),j=Qs(),E=f?y:Zs(m),k=async A=>{if(A.preventDefault(),!l.canSubmit)return;if(_(null),!m.trim()){_("Name is required");return}const I=Xr(x),F={entityType:t,name:m.trim(),slug:f?y:void 0,metadata:Object.keys(I).length>0?I:void 0};try{const B=await j.mutateAsync(F);if(e(),B.approval_queued||!B.entity){Bn.info("Create queued for approval");return}typeof B.entity.id=="number"&&o?.(B.entity.id)}catch(B){_(B instanceof Error?B.message:"Failed to create entity")}},b=r?.name||t,w=l.revision,M=`Create ${b}`,P=`Add a new ${b.toLowerCase()} to your workspace.`;return i?n.jsx(er,{rows:6}):n.jsxs("form",{onSubmit:k,children:[n.jsx(tr,{visible:l.hasConflict,onReload:l.reset}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:M}),n.jsx("p",{className:"text-sm text-muted-foreground",children:P})]}),n.jsxs("div",{className:"grid gap-4 py-4",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsxs($e,{htmlFor:"name",children:["Name ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx(et,{id:"name",value:m,onChange:A=>c(A.target.value),placeholder:`Enter ${b.toLowerCase()} name`,autoFocus:!0})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx($e,{htmlFor:"slug",children:"URL Slug"}),n.jsx("button",{type:"button",onClick:()=>h(!f),className:"text-xs text-muted-foreground hover:text-foreground",children:f?"Auto-generate":"Customize"})]}),f?n.jsx(et,{id:"slug",value:y,onChange:A=>p(A.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):n.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:E||"slug-preview"})]}),w&&Object.keys(w).length>0?n.jsxs(n.Fragment,{children:[n.jsx(Qr,{className:"my-2"}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx($e,{className:"text-sm font-medium",children:"Additional Fields"}),n.jsx(Jr,{schema:l.revision,values:x,onValuesChange:d,orgContext:s})]})]}):null,N&&n.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:N})]}),n.jsx(On,{onCancel:e,cancelDisabled:j.isPending,className:"mt-2",children:n.jsx(U,{type:"submit",disabled:!l.canSubmit||j.isPending||!m.trim(),children:j.isPending?"Creating...":`Create ${b}`})})]})}function ja(e){const t=e?.properties??{},s=or(e);return Object.entries(t).flatMap(([o,r])=>{const i=s.find(p=>p.field===o);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)||!r||r.const!==void 0||r["x-table-column"]!==!0&&r["x-facet"]!==!0&&!i)return[];const a=[r,...Array.isArray(r.anyOf)?r.anyOf:[]],l=i?.options??[],m=l.find(p=>p.value!==null)?.value,c=a.find(p=>["string","number","integer","boolean"].includes(String(p.type)))??(m===void 0?void 0:{type:typeof m});if(!c)return[];const y=r.format==="date-time"||c.format==="date-time"?"datetime-local":r.format==="date"||c.format==="date"?"date":c.type==="number"||c.type==="integer"?"number":c.type==="boolean"?"boolean":"string";return[{field:o,label:String(r["x-table-label"]??r.title??o.replaceAll("_"," ")),type:y,options:y==="boolean"&&!l.some(p=>typeof p.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...l]:l}]})}function Ea(e){const t=e?.[Ht];return t===void 0?{}:Xt(t)}function Ca(e,t,s){try{const o=Ea(t),r=e[Hn],i=r===void 0?void 0:o.presets?.find(y=>y.key===r);if(r!==void 0&&!i)throw new Error("This saved filter is unavailable. Choose another filter.");if(i&&!s&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const a=i&&e[Qe]===void 0?{collection:yt(i)}:nr(e,s);if(a.error)throw a.error;const l=e[sr],m=l===void 0?i?.table??o.table??{}:Xt({table:typeof l=="string"?JSON.parse(l):l}).table??{},c=!!i&&(_n(a.collection)!==_n(yt(i))||Nt(m)!==Nt(i.table??o.table??{}));return{...a,presentation:o,preset:i,table:m,edited:c}}catch(o){return{collection:{},presentation:{},table:{},edited:!1,error:o instanceof Error?o:new Error("Invalid collection configuration")}}}function _n(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(ht)])}function ht(e){return JSON.stringify([e.field,e.op,e.value])}function Nt(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function _a(e,t){return t?{[Hn]:t,[Qe]:Bt(e)[Qe]??"{}"}:Bt(e)}function Ma(e,t,s,o,r=new Date){let i=t.filters??[],a=e.relativeDate;if(a){const l=(yt({...e,selection:{}},r).filters??[]).map(ht),m=i.map(ht);l.every(c=>m.includes(c))?i=i.filter(c=>!l.includes(ht(c))):a=void 0}return{key:e.key,label:e.label,selection:{...t.search?{search:t.search}:{},...i.length?{filters:i}:{},...t.segment?{segment:t.segment}:{}},...Nt(s)!==Nt(o.table??{})?{table:s}:{},...a?{relativeDate:a}:{}}}function Ta(e,t,s){const o=[...e.filters??[]],r=s??(t.length===1&&t[0].op==="eq"?o.findIndex(a=>a.field===t[0].field&&a.op==="eq"):-1),i=r>=0?[...o.slice(0,r),...t,...o.slice(r+1)]:[...o,...t];return{...e,filters:ar({filters:i}).filters}}function Ra(e,t){return{...e,filters:e.filters?.filter((s,o)=>o!==t)}}function Ia(e,t){return{...typeof e.$preset=="string"?e[Qe]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[Qe]:String(rr(e[Qe]))}:Bt(t),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const La=[{field:"name",label:"Name"},{field:"created_at",label:"Created"},{field:"total_content",label:"Activity count"},{field:"active_connections",label:"Connections"},{field:"automations_count",label:"Automations"},{field:"children_count",label:"Children"}];function $a(e){return e.sort&&La.some(t=>t.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Oa(e,t,s,o,r){const i={...o,filters:o.filters?.filter(a=>a.field!==s)};return Vn({queryKey:["collection-facets",e,t,s,i],enabled:!!t&&!!s,staleTime:3e4,retry:!1,queryFn:async({signal:a})=>{const l=await xt("query_sdk",{title:`Value counts query for ${s}`,script:`const input = ${JSON.stringify({field:s,collection:i})};
|
|
2
|
-
${t}`},e,{signal:a}),m=l.return_value;if(!l.success||typeof m?.connection!="string"||typeof m.sql!="string")throw new Error(l.error?.message??"Value distribution is unavailable");if(a.aborted)throw new DOMException("Aborted","AbortError");const c=await xt("query_sql",{title:`Value counts for ${s}`,connection:m.connection,sql:m.sql,limit:51},e,{signal:a});if(c.error)throw new Error(c.error);if(!Array.isArray(c.rows))throw new Error("Source did not return value counts");const y=c.rows.map(p=>{const f=p,h=typeof f.count=="string"&&/^\d+$/.test(f.count)?Number(f.count):f.count;if(!(f.value===null||["string","number","boolean"].includes(typeof f.value))||typeof h!="number"||!Number.isSafeInteger(h)||h<0)throw new Error("Source returned an invalid value distribution");return{value:f.value,count:h}});return{values:y.slice(0,50),truncated:y.length>50||c.truncated===!0}}})}const Aa=300;function Pa({label:e,search:t,onSearch:s,className:o}){const r=t??"",[i,a]=v.useState(r),l=v.useRef({search:t,onSearch:s});l.current={search:t,onSearch:s};const m=v.useRef(void 0);v.useEffect(()=>{const y=()=>{clearTimeout(m.current),a(l.current.search??"")};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[]);const c=v.useRef(r);return v.useEffect(()=>{r!==c.current&&(c.current=r,a(r))},[r]),v.useEffect(()=>{if(i===(l.current.search??""))return;const y=setTimeout(()=>{const p=l.current.onSearch;c.current=i,p(i||void 0,!0)},Aa);return m.current=y,()=>clearTimeout(y)},[i]),n.jsxs("div",{className:`relative${o?` ${o}`:""}`,children:[n.jsx(cr,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(et,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:i,onChange:y=>a(y.target.value),className:"pl-9"})]})}const Da={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Fa({field:e,initial:t,org:s,facetQuery:o,collection:r,onApply:i,close:a}){const[l,m]=v.useState(t?.op??"eq"),[c,y]=v.useState(t?.value==null?"":String(t.value)),[p,f]=v.useState(""),[h,x]=v.useState(!1),[d,N]=v.useState(),_=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",j=Oa(s,o,e.field,r),E=w=>{try{const M=h?[{field:e.field,op:"gte",value:e.type==="number"?Number(c):c},{field:e.field,op:"lte",value:e.type==="number"?Number(p):p}]:[{field:e.field,op:l,value:w}];if(e.type==="datetime-local")for(const I of M)typeof I.value=="string"&&(I.value=new Date(I.value).toISOString());if(M.some(I=>typeof I.value=="number"&&!Number.isFinite(I.value)))throw new Error("Enter a valid number.");const P=M[0].value,A=M[1]?.value;if(h&&P!=null&&A!=null&&P>A)throw new Error("The lower bound must be before the upper bound.");i(M),a()}catch(M){N(M instanceof Error?M.message:"Could not apply filter")}},k=[...e.options];for(const w of j.data?.values??[])k.some(M=>M.value===w.value)||k.push({value:w.value,label:w.value===null?"Not supplied":String(w.value)});const b=Math.max(1,...j.data?.values.map(w=>w.count)??[]);return n.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[n.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:h?"range":l,onChange:w=>{x(w.target.value==="range"),w.target.value!=="range"&&m(w.target.value)},children:[n.jsx("option",{value:"eq",children:"is"}),n.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"lt",children:"less than / before"}),n.jsx("option",{value:"lte",children:"at most / on or before"}),n.jsx("option",{value:"gt",children:"greater than / after"}),n.jsx("option",{value:"gte",children:"at least / on or after"}),t?null:n.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&n.jsxs("form",{className:"space-y-2",onSubmit:w=>{w.preventDefault(),E(e.type==="number"?Number(c):c)},children:[n.jsx(et,{required:!0,"aria-label":h?"From value":"Filter value",type:_,step:e.type==="number"?"any":void 0,value:c,onChange:w=>y(w.target.value),placeholder:"Enter a value…"}),h&&n.jsx(et,{required:!0,"aria-label":"To value",type:_,step:e.type==="number"?"any":void 0,value:p,onChange:w=>f(w.target.value)}),n.jsx(U,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!h&&(l==="eq"||l==="neq")&&n.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:k.filter(w=>!c||w.label.toLowerCase().includes(c.toLowerCase())).map(w=>{const M=j.data?.values.find(P=>P.value===w.value)?.count;return n.jsxs("button",{type:"button","aria-label":w.label,onClick:()=>E(w.value),className:"relative flex w-full items-center justify-between gap-3 overflow-hidden rounded px-2 py-1.5 text-left text-sm hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[M!==void 0&&n.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${M/b*100}%`}}),n.jsx("span",{className:"relative truncate",children:w.label}),n.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:M?.toLocaleString()})]},JSON.stringify(w.value))})}),o&&j.isFetching&&n.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),j.isError&&n.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),j.data?.truncated&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),d&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d})]})}function za({collection:e,schema:t,label:s,onChange:o,org:r,facetQuery:i,segmentChip:a,viewFilters:l,onClearAll:m}){const c=ja(t),y=(x,d)=>({kind:"custom",className:"w-80",render:N=>n.jsx(Fa,{field:x,initial:d==null?void 0:e.filters?.[d],org:r,facetQuery:i,collection:e,onApply:_=>o(Ta(e,_,d)),close:N})}),p=c.map(x=>({key:x.field,label:x.label,icon:n.jsx(ir,{className:"h-4 w-4"}),editor:y(x)})),f=new Map,h=(e.filters??[]).map((x,d)=>{const N=`${x.field}:${x.op}:${JSON.stringify(x.value)}`,_=f.get(N)??0;f.set(N,_+1);const j=c.find(k=>k.field===x.field),E=j?.options.find(k=>k.value===x.value)?.label??String(x.value??"Not supplied");return{id:`${N}:${_}`,label:j?.label??x.field,op:Da[x.op],value:E,editor:j?y(j,d):void 0,onRemove:()=>o(Ra(e,d))}});if(a&&h.unshift(a),l?.fields.length){for(const x of p)x.group=s;p.push(...l.fields),h.push(...l.chips)}return!p.length&&!h.length?null:n.jsx(so,{label:`${s} filters`,fields:p,chips:h,onClearAll:m??(()=>o({...e,filters:[],segment:void 0}))})}const St=120,je=12;function Mn(e,t){return typeof e.linkId=="number"&&typeof t.linkId=="number"?e.linkId-t.linkId:String(e.linkId).localeCompare(String(t.linkId))}function Wa(e){const t=e.records.slice(0,St),s=c=>e.types.get(c)??{label:c},o=new Map;for(const c of t)o.set(String(c.id),{source:c.source,entityType:e.typeSlug,slug:c.slug,name:c.name,isFocus:!0,hasMoreLinks:!1});const r=new Map;for(const c of e.links){if(!o.has(String(c.recordId)))continue;const y=r.get(c.recordId)??new Map;y.set(c.linkId,c),r.set(c.recordId,y)}const i=new Map;for(const[c,y]of r){const p=[...y.values()].sort(Mn),f=o.get(String(c));f&&p.length>je&&(f.hasMoreLinks=!0);for(const h of p.slice(0,je)){i.set(h.linkId,h);const x=String(h.peer.id);o.has(x)||o.set(x,{source:h.peer.source,...h.peer.remote?{remote:h.peer.remote}:{},entityType:h.peer.type,slug:h.peer.slug,name:h.peer.name,isFocus:!1,hasMoreLinks:!1})}}const a=[];for(const[c,y]of o){const p=y.remote?{label:y.entityType}:s(y.entityType),f=y.name||y.slug,h=y.hasMoreLinks?`${p.label} · ${je}+ links`:p.label;a.push({id:c,data:{slug:y.slug,label:f,icon:p.icon,isSystem:!1,metaLabel:h},width:ct(f,h),height:Ze})}const l=new Map;for(const c of[...i.values()].sort(Mn)){const y=String(c.fromId),p=String(c.toId),f=JSON.stringify([y,p]),h=l.get(f)??{source:y,target:p,rels:new Map,symmetric:!0};h.symmetric&&=c.isSymmetric,h.rels.has(c.relSlug)||h.rels.set(c.relSlug,{slug:c.relSlug,label:c.relName,ruleCount:1}),l.set(f,h)}const m=[...l.entries()].map(([c,y])=>({id:`link:${c}`,source:y.source,target:y.target,data:{relationships:[...y.rels.values()],isSymmetric:y.symmetric}}));return{nodes:a,edges:m,records:o,hasMoreRecords:e.hasMore===!0||e.records.length>St,listedCount:t.length,focusCount:t.length}}async function Ba(e,t){const s=Wa(e);return{...await Zt({nodes:s.nodes,edges:s.edges},t),records:s.records,hasMoreRecords:s.hasMoreRecords,listedCount:s.listedCount,focusCount:s.focusCount}}const Ha=8,Va=3,Ua=4;function gt(e){return`source:${JSON.stringify([e.type,e.key])}`}function Ga(e,t){return t.map(s=>{const o={type:e,key:s.slug};return{...s,id:gt(o),source:o}})}function Tn(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function qa(e,t,s){const o=e.slice(0,Ha),r=[];let i=0;return await Promise.all(Array.from({length:Math.min(Va,o.length)},async()=>{for(;i<o.length;){const a=i++,l=o[a];try{if(s?.aborted)throw s.reason;const m=await t(l),c=new Map(l.links.map(N=>[Tn(N),N]));for(const N of m.record_links){const _=Tn(N),j=c.get(_);(!j||j.occurred_at<N.occurred_at)&&c.set(_,N)}const y=new Map((l.relationships??[]).map(N=>[N.id,N]));for(const N of m.relationships??[])y.set(N.id,N);const p=[...y.values()].slice(0,je+1),f=[...c.values()].slice(0,je+1),h=(l.pagesRead??0)+1,x=!!m.next_cursor&&h>=Ua,d=m.record_failures.length>0||!!m.relationship_failures?.length||x;r[a]={read:{record:l.record,links:f,failed:d,entityId:l.entityId,relationships:p},...!x&&(d||m.next_cursor&&f.length+p.length<=je)?{next:{record:l.record,entityId:l.entityId,relationships:p,pagesRead:h,cursor:m.next_cursor??l.cursor,links:f}}:{}}}catch(m){if(s?.aborted)throw m;r[a]={read:{record:l.record,links:l.links,failed:!0,entityId:l.entityId,relationships:l.relationships},next:{...l,cursor:m instanceof lr&&m.status===400?null:l.cursor}}}}})),{reads:r.map(a=>a.read),pending:[...r.flatMap(a=>a.next?[a.next]:[]),...e.slice(o.length)]}}function Ya(e,t){const s=new Map;for(const i of e)for(const a of i.reads)s.set(String(a.entityId??gt(a.record)),a);const o=new Map(t.map(i=>[i.slug,i])),r=[];for(const[i,a]of s){for(const l of a.relationships??[]){const m=(N,_,j)=>j?`remote:${j}`:typeof N=="number"?N:gt({type:_,key:N}),c=m(l.from_entity_id,l.from_entity_type,l.from_entity_url),y=m(l.to_entity_id,l.to_entity_type,l.to_entity_url),p=String(c)===i,f=p?y:c,h=p?l.to_entity_id:l.from_entity_id,x=p?l.to_entity_url:l.from_entity_url,d=(p?l.to_entity_type:l.from_entity_type)??"";r.push({recordId:i,linkId:l.id,fromId:c,toId:y,relSlug:l.relationship_type_slug,relName:l.relationship_type_name,isSymmetric:l.is_symmetric,peer:{id:f,name:(p?l.to_entity_name:l.from_entity_name)??String(h),slug:(p?l.to_entity_slug:l.from_entity_slug)??String(h),type:d,...x?{remote:{url:dr(x)}}:typeof h=="string"?{source:{type:d,key:h}}:{}}})}for(const l of a.links){const m={type:l.entity_type,key:l.key},c=gt(m),y=o.get(l.relationship_type);let p=l.direction==="incoming"?c:i,f=l.direction==="incoming"?i:c;y?.is_symmetric&&p>f&&([p,f]=[f,p]),r.push({recordId:i,linkId:JSON.stringify([p,f,l.relationship_type]),fromId:p,toId:f,relSlug:l.relationship_type,relName:y?.name||l.relationship_type.replaceAll("_"," "),isSymmetric:y?.is_symmetric??!1,peer:{id:c,name:l.name||l.key,slug:l.key,type:l.entity_type,source:m}})}}return{links:r,checked:s.size,failed:[...s.values()].filter(i=>i.failed).length}}function Ka(e,t,s,o,r,i=!1){const{orgContext:a}=Oe(),l=Ct(a),m=Kt(a),c=v.useMemo(()=>i?Ga(t,s):s,[i,t,s]),y=v.useMemo(()=>c.slice(0,St).flatMap(k=>k.source?[{record:k.source,cursor:null,links:[]}]:typeof k.id=="number"?[{entityId:k.id,record:{type:t,key:k.slug},cursor:null,links:[]}]:[]),[c,t]),p=ur({queryKey:["source-records-graph",a.organizationId,e,t,y.map(k=>[k.record,k.entityId])],enabled:!0,initialPageParam:y,queryFn:({pageParam:k,signal:b})=>qa(k,async w=>{const M=await xt("manage_entity",{action:"list_links",...w.entityId===void 0?{record:w.record,cursor:w.cursor}:{entity_id:w.entityId,offset:Number(w.cursor??0)},limit:je+1},e,{signal:b});return{...M,record_links:M.record_links??[],record_failures:M.record_failures??[],next_cursor:w.entityId===void 0?M.next_cursor:M.metadata?.has_more?String(Number(w.cursor??0)+je+1):null}},b),getNextPageParam:k=>k.pending.length?k.pending:void 0,staleTime:3e4,retry:!1}),f=v.useMemo(()=>p.data?Ya(p.data.pages,m.data??[]):void 0,[p.data,m.data]),h=f?.links,x=p.isError,d=JSON.stringify([a.organizationId,e,t,i,c.map(k=>[k.id,k.name,k.slug]),o]),N=v.useMemo(()=>new Map((l.data??[]).map(k=>[k.slug,{label:k.name||k.slug,icon:k.icon}])),[l.data]),[_,j]=v.useState(null);v.useEffect(()=>{if(!h)return;let k=!1;return Ba({typeSlug:t,records:c,hasMore:o,links:h,types:N},{targetAspect:r}).then(b=>{k||j({graph:b,key:d,isError:!1})}).catch(()=>{k||j({graph:null,key:d,isError:!0})}),()=>{k=!0}},[h,t,c,o,N,r,d]);const E=_?.key===d?_:null;return{graph:E?.graph??null,isLoading:!x&&!E,isError:x||E?.isError===!0,sourceProgress:{checked:f?.checked??0,total:Math.min(s.length,St),failed:f?.failed??0,hasMore:!!p.hasNextPage,isFetching:p.isFetching,loadMore:()=>{p.isFetching||p.fetchNextPage()}}}}function Ja(e){const t=new Map(e.nodes.map(r=>[r.id,r.data.label])),s=e.nodes.map(r=>({id:r.id,x:r.position.x+r.width/2,y:r.position.y+r.height/2,w:r.width,h:r.height,title:r.data.label,meta:r.data.metaLabel,icon:r.data.icon,muted:e.records.get(r.id)?.isFocus===!1})),o=e.edges.map(r=>{const{relationships:i,isSymmetric:a}=r.data,l=i.map(m=>m.label);return{id:r.id,source:r.source,target:r.target,route:r.route??null,summary:l.length===1?l[0]:`${l.length} relationships`,details:l,directed:!a,ariaLabel:`${t.get(r.source)??r.source} ${a?"and":"to"} ${t.get(r.target)??r.target}: ${l.join(", ")}`}});return{boxes:s,edges:o}}function Xa({ownerSlug:e,typeSlug:t,records:s,hasMore:o,sourceBacked:r=!1}){const i=tt(),a=Jt(),{orgContext:l}=Oe(),{data:m=[]}=Ct(l),c=m.find(b=>b.slug===t)?.name??t,[y,p]=v.useState(),f=v.useRef(null),h=v.useCallback(b=>{if(f.current?.disconnect(),f.current=null,!b||typeof ResizeObserver>"u")return;const w=()=>{if(!b.clientWidth||!b.clientHeight)return;const P=Math.round(b.clientHeight/b.clientWidth*10)/10;p(A=>A===P?A:P)};w();const M=new ResizeObserver(w);M.observe(b),f.current=M},[]),{graph:x,isLoading:d,isError:N,sourceProgress:_}=Ka(e,t,s,o,y,r),j=v.useMemo(()=>x?Ja(x):null,[x]),E=v.useCallback(b=>{const w=x?.records.get(b);if(w){if(w.remote){w.remote.url&&window.open(w.remote.url,"_blank","noopener,noreferrer");return}if(a){a.open(ro({...w.source?{record:w.source}:{entityId:Number(b)},ownerSlug:e,orgContext:l,name:w.name||w.slug}));return}i({to:mr(e,[{entity_type:w.entityType,slug:w.slug}])})}},[x,e,l,a,i]);if(N)return n.jsx(zn,{label:`${c} graph`});if(d||!x||!j)return n.jsx(Qt,{label:`Loading ${c} graph`});const k=_?n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[n.jsxs("p",{children:["Checked ",_.checked," of ",_.total," records. Up to ",je," relationships per record."]}),_.failed>0?n.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),_.hasMore?n.jsx(U,{variant:"outline",size:"sm",disabled:_.isFetching,onClick:_.loadMore,children:_.isFetching?"Loading…":_.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return x.focusCount===0?n.jsxs("div",{className:"space-y-3",children:[k,n.jsx(Un,{icon:Gn,title:`No ${c} records match`,description:"Change the search or filters to see records here."})]}):n.jsxs("div",{className:"flex flex-col gap-2",children:[k,n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",x.hasMoreRecords?"the first ":"",x.focusCount," ",c," record",x.focusCount===1?"":"s",". Click a record to see it."]}),n.jsx("div",{ref:h,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:n.jsx(cs,{boxes:j.boxes,edges:j.edges,label:`${c} records`,onOpenBox:E,openLabel:b=>`Show ${b.title}`})})]})}function Qa(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function ps(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function tn(e){const t=e?.properties;if(!t)return null;const r=fr(t).find(([,c])=>ps(c)==="workflowState");if(!r)return null;const[i,a]=r,l=a["x-lobu"]?.states,m=Array.isArray(l)&&l.length>0?l:(a.enum??[]).map(c=>({value:c}));return m.length===0||m.some(c=>typeof c.value!="string")?null:{field:i,states:m.map(c=>({...c,label:c.label||pr(a,c.value)||Qa(c.value),terminal:c.terminal??["done","complete","completed","closed","archived"].includes(c.value.toLowerCase())}))}}function Za(e){const t=e?.properties;if(!t)return null;const s=Object.entries(t),o=s.find(([,a])=>ps(a)==="sortRank"),r=s.find(([a])=>["rank","sort_rank","order"].includes(a)),i=o??r;return i?{field:i[0]}:null}function ei(e,{isDerived:t}){const s=e?.["x-lobu"]?.defaultView;return(s==="table"||s==="board")&&!(t&&s!=="table")?s:t?"table":tn(e)?"board":"table"}const hs={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},ti={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function ni(e){const{canShowBoard:t,builtinData:s,builtInLabels:o}=e,r=["table",...t?["board"]:[]],i={table:hs,board:ti};return r.map(a=>({id:a,label:o[a],builtInMode:a,template:i[a],data:s}))}function qt(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function jt(e,t){if(!t)return e.created_at??String(e.id);const s=_t(e.metadata);return String(s[t.field]??e.created_at??e.id)}function si(e,t){const s=e?Number(e):Number.NaN,o=t?Number(t):Number.NaN;return Number.isFinite(s)&&Number.isFinite(o)&&s<o?String((s+o)/2):Number.isFinite(s)?String(s+1):Number.isFinite(o)?String(o-1):String(Date.now())}function Yt(e,t){const s=_t(e.metadata);return String(s[t]??"")}function gs(e,t){return[...e].sort((s,o)=>jt(s,t).localeCompare(jt(o,t)))}function ri(e,t,s,o,r){if(!t.startsWith("card:")||!s)return null;const i=Number(t.slice(5)),a=e.find(j=>j.id===i);if(!a)return null;const l=s.startsWith("column:")?s.slice(7):Yt(e.find(j=>`card:${j.id}`===s)??a,o.field);if(!l)return null;const m=gs(e.filter(j=>j.id!==i&&Yt(j,o.field)===l),r),c=s.startsWith("card:")?m.findIndex(j=>`card:${j.id}`===s):m.length,y=c>=0?c:m.length,p=y>0?m[y-1]:void 0,f=m[y],h=r?si(p?jt(p,r):void 0,f?jt(f,r):void 0):void 0,x=_t(a.metadata),d={[o.field]:l,...r&&h?{[r.field]:h}:{}};o.states.find(j=>j.value===l)?.terminal&&!x.completed_at&&(d.completed_at=new Date().toISOString());const _={...x,...d};return{entityId:i,changedMetadata:d,nextMetadata:_}}function Rn(e,t,s){return e.map(o=>o.id===t?{...o,metadata:s}:o)}function oi({id:e,children:t,className:s}){const{setNodeRef:o,isOver:r}=rs({id:`column:${e}`});return n.jsx("div",{ref:o,className:ae("min-h-[220px] rounded-lg bg-card p-2 transition-colors",r?"bg-accent/50":"",s),children:t})}function ai({entity:e,owner:t,statusField:s,entityTypeIcon:o,schema:r,didDragRef:i}){const a=_t(e.metadata),{attributes:l,listeners:m,setNodeRef:c,transform:y,isDragging:p}=fo({id:`card:${e.id}`}),{setNodeRef:f,isOver:h}=rs({id:`card:${e.id}`}),x=qn(t,ss(e)),d=N=>{i.current&&(N.preventDefault(),N.stopPropagation())};return n.jsx("div",{ref:N=>{c(N),f(N)},style:{transform:po.Translate.toString(y)},className:ae(yr,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",p?"opacity-60":"",h?"ring-1 ring-ring":""),children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("button",{type:"button",className:"mt-0.5 shrink-0 cursor-grab touch-none text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":`Drag ${e.name}`,...l,...m,children:n.jsx(gr,{className:"h-4 w-4"})}),n.jsx(ns,{metadata:a,metadataSchema:r,name:e.name,typeIcon:o,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx(He,{to:x,className:"font-medium text-foreground hover:underline",onClick:d,children:e.name}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof a.priority=="string"&&a.priority?n.jsx(Vt,{variant:"outline",className:"text-xs",children:qt(a.priority)}):null,typeof a[s]=="string"&&a[s]?n.jsx(Vt,{variant:"secondary",className:"text-xs",children:qt(String(a[s]))}):null]})]})]})})}function ii({owner:e,entities:t,totalCount:s,schema:o,entityTypeIcon:r,onUpdate:i}){const a=v.useMemo(()=>tn(o),[o]),l=v.useMemo(()=>Za(o),[o]),[m,c]=v.useState(t),[y,p]=v.useState(()=>new Set),f=v.useRef(!1),h=co(lo(mo,{activationConstraint:{distance:6}})),x=v.useCallback(()=>{window.setTimeout(()=>{f.current=!1},0)},[]);v.useEffect(()=>{c(t)},[t]);const d=v.useMemo(()=>{if(!a)return new Map;const E=new Map(a.states.map(k=>[k.value,[]]));for(const k of m){const b=Yt(k,a.field),w=E.has(b)?b:a.states[0]?.value;w&&E.get(w)?.push(k)}for(const[k,b]of E)E.set(k,gs(b,l));return E},[m,l,a]);if(!a)return null;const N=E=>{p(k=>{const b=new Set(k);return b.has(E)?b.delete(E):b.add(E),b})},_=()=>{f.current=!0},j=E=>{const k=String(E.active.id),b=E.over?String(E.over.id):null,w=ri(m,k,b,a,l);if(!w){x();return}const{entityId:M,changedMetadata:P,nextMetadata:A}=w,F=m.find(B=>B.id===M)?.metadata;c(B=>Rn(B,M,A)),i(M,P).catch(()=>{c(B=>Rn(B,M,F))}),x()};return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:"Board"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",qt(a.field),typeof s=="number"&&s>m.length?n.jsxs(n.Fragment,{children:[" · ",n.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",m.length," of ",s," — narrow with search"]})]}):null]})]}),n.jsx(uo,{sensors:h,onDragStart:_,onDragEnd:j,children:n.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:a.states.map(E=>{const k=d.get(E.value)??[],b=E.collapsed??E.terminal,w=b&&!y.has(E.value);return n.jsxs(oi,{id:E.value,children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[E.terminal?n.jsx(hr,{className:"h-4 w-4 text-muted-foreground"}):null,n.jsx("h3",{className:"text-sm font-medium",children:E.label})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(Vt,{variant:"secondary",className:"text-xs",children:k.length}),b?n.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>N(E.value),children:w?"Show":"Hide"}):null]})]}),w?n.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[k.length," hidden ",E.label?.toLowerCase()," item",k.length===1?"":"s"]}):n.jsx("div",{className:"space-y-2",children:k.length>0?k.map(M=>n.jsx(ai,{entity:M,owner:e,statusField:a.field,entityTypeIcon:r,schema:o,didDragRef:f},M.id)):n.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",E.label?.toLowerCase()," items"]})})]},E.value)})})})]})}const ci=v.memo(ii);function li(e){let t=0;for(let s=0;s<e.length;s++)t=(t<<5)-t+e.charCodeAt(s),t|=0;return t.toString(36)}function ys(e,t){return{queryKey:["metric_series",e,li(t)],queryFn:()=>xt("metric_series",{sql:t},{slug:e}),staleTime:6e4}}function xs(e,t){const s=!!e&&!!t,o=ys(e??"",t??"");return Vn({...o,enabled:s})}xs.queryOptions=(e,t)=>ys(e,t);function di(e,t){if(!e?.columns?.length||!e.rows)return[];const s=e.columns.indexOf(t);return s<0?[]:e.rows.map(o=>Number(o[s])||0)}const In=/^[a-z][a-z0-9_]*$/;function ui(e){const t=Object.entries(e);for(const[r,i]of t){if(!In.test(r))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${r}'`);if(!In.test(i))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${i}'`)}const s=t.flatMap(([r,i])=>[`COUNT(*) FILTER (
|
|
3
|
-
WHERE semantic_type = 'change'
|
|
4
|
-
AND metadata->>'category' = 'lifecycle'
|
|
5
|
-
AND metadata->>'entity_type' = '${i}'
|
|
6
|
-
AND metadata->>'op' = 'created'
|
|
7
|
-
) AS ${r}_added`,`COUNT(*) FILTER (
|
|
8
|
-
WHERE semantic_type = 'change'
|
|
9
|
-
AND metadata->>'category' = 'lifecycle'
|
|
10
|
-
AND metadata->>'entity_type' = '${i}'
|
|
11
|
-
AND metadata->>'op' = 'deleted'
|
|
12
|
-
) AS ${r}_removed`]).join(`,
|
|
13
|
-
`),o=t.map(([r])=>` SUM(COALESCE(b.${r}_added, 0) - COALESCE(b.${r}_removed, 0))
|
|
14
|
-
OVER (ORDER BY d.bucket) AS ${r}`).join(`,
|
|
15
|
-
`);return`
|
|
16
|
-
WITH days AS (
|
|
17
|
-
SELECT generate_series(
|
|
18
|
-
date_trunc('day', now() - interval '13 days'),
|
|
19
|
-
date_trunc('day', now()),
|
|
20
|
-
interval '1 day'
|
|
21
|
-
) AS bucket
|
|
22
|
-
),
|
|
23
|
-
buckets AS (
|
|
24
|
-
SELECT
|
|
25
|
-
date_trunc('day', created_at) AS bucket,
|
|
26
|
-
${s}
|
|
27
|
-
FROM events
|
|
28
|
-
WHERE created_at > now() - interval '14 days'
|
|
29
|
-
GROUP BY 1
|
|
30
|
-
)
|
|
31
|
-
SELECT d.bucket,
|
|
32
|
-
${o}
|
|
33
|
-
FROM days d
|
|
34
|
-
LEFT JOIN buckets b ON b.bucket = d.bucket
|
|
35
|
-
ORDER BY d.bucket
|
|
36
|
-
`}const mi={"memory-activity":`
|
|
37
|
-
WITH days AS (
|
|
38
|
-
SELECT generate_series(
|
|
39
|
-
date_trunc('day', now() - interval '13 days'),
|
|
40
|
-
date_trunc('day', now()),
|
|
41
|
-
interval '1 day'
|
|
42
|
-
) AS bucket
|
|
43
|
-
),
|
|
44
|
-
buckets AS (
|
|
45
|
-
SELECT
|
|
46
|
-
date_trunc('day', created_at) AS bucket,
|
|
47
|
-
COUNT(*) FILTER (
|
|
48
|
-
WHERE semantic_type NOT IN ('change', 'audit', 'operation')
|
|
49
|
-
) AS events_count,
|
|
50
|
-
COUNT(*) FILTER (
|
|
51
|
-
WHERE semantic_type = 'change'
|
|
52
|
-
AND metadata->>'category' = 'lifecycle'
|
|
53
|
-
AND metadata->>'entity_type' = 'connection'
|
|
54
|
-
AND metadata->>'op' = 'created'
|
|
55
|
-
) AS connections_added,
|
|
56
|
-
COUNT(*) FILTER (
|
|
57
|
-
WHERE semantic_type = 'change'
|
|
58
|
-
AND metadata->>'category' = 'lifecycle'
|
|
59
|
-
AND metadata->>'entity_type' = 'connection'
|
|
60
|
-
AND metadata->>'op' = 'deleted'
|
|
61
|
-
) AS connections_removed
|
|
62
|
-
FROM events
|
|
63
|
-
WHERE created_at > now() - interval '14 days'
|
|
64
|
-
GROUP BY 1
|
|
65
|
-
)
|
|
66
|
-
SELECT d.bucket,
|
|
67
|
-
COALESCE(b.events_count, 0)::int AS events,
|
|
68
|
-
SUM(COALESCE(b.connections_added, 0) - COALESCE(b.connections_removed, 0))
|
|
69
|
-
OVER (ORDER BY d.bucket) AS connections
|
|
70
|
-
FROM days d
|
|
71
|
-
LEFT JOIN buckets b ON b.bucket = d.bucket
|
|
72
|
-
ORDER BY d.bucket
|
|
73
|
-
`};function fi(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const t=Object.fromEntries(Object.entries(e.lifecycle).map(([s,o])=>[s,String(o)]));if(Object.keys(t).length>0)try{return ui(t)}catch{return null}}return typeof e.preset=="string"?mi[e.preset]??null:null}function pi({owner:e,sql:t,lifecycle:s,preset:o,column:r,chart:i,height:a,width:l,color:m,label:c,className:y}){const p=v.useMemo(()=>fi({sql:t,lifecycle:s,preset:o}),[t,s,o]),f=typeof e=="string"&&e?e:null,{data:h}=xs(f,p),x=String(r??""),d=v.useMemo(()=>di(h,x),[h,x]),N=v.useMemo(()=>!h?.columns?.length||!h.rows?[]:h.rows.map((j,E)=>({label:String(j[0]??"").slice(0,10),value:d[E]??0})),[h,d]);if(!f||!p||!x)return null;const _=i==="line"?n.jsx(oo,{data:N,height:typeof a=="number"?a:void 0}):n.jsx(ao,{data:d,height:typeof a=="number"?a:void 0,width:typeof l=="number"?l:void 0,color:typeof m=="string"?m:void 0});return c==null?n.jsx("div",{className:y,children:_}):n.jsxs("div",{className:y,children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:String(c)}),_]})}function hi({metadata:e,metadataSchema:t,name:s,typeIcon:o,initialsFallback:r,className:i}){return n.jsx(ns,{metadata:e,metadataSchema:t,name:String(s??""),typeIcon:o,initialsFallback:!!r,className:i})}function gi({entity:e,owner:t,className:s,onClick:o,children:r}){const i=e;if(!i)return n.jsx(n.Fragment,{children:r});const a=qn(String(t??""),ss(i));return n.jsx(He,{to:a,className:s,onClick:o,children:r})}function yi({state:e}){return e?n.jsx(Zr,{...e}):null}function xi({state:e,onUpdate:t}){return e?n.jsx(ci,{...e,onUpdate:t}):null}const bi={"entity-avatar":hi,"entity-link":gi,"entity-table":yi,"entity-board":xi,"metric-series":pi};function vi({ownerSlug:e,typeSlug:t,title:s,shape:o}){const[r,i]=v.useState(!1),a=tt(),{visible:l,system:m,isTypesLoading:c}=xr(e),y=f=>{i(!1);const h=`/${e}/${Qn(f)}`;a({to:o?`${h}/${Zn}/${o}`:h})},p=f=>n.jsxs(jr,{value:`${f.name} ${f.slug}`,onSelect:()=>y(f.slug),children:[n.jsx(Et,{icon:f.icon,className:"mr-2 h-4 w-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate",children:f.name||f.slug}),f.slug===t?n.jsx(Er,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,f.entity_count!=null?n.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:f.entity_count.toLocaleString()}):null]},f.slug);return n.jsxs(Yn,{open:r,onOpenChange:i,children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:n.jsx(Kn,{asChild:!0,children:n.jsxs(U,{type:"button",variant:"ghost",className:"-ml-2 h-auto gap-1.5 px-2 py-1 text-2xl font-semibold tracking-tight",children:[s,n.jsx(Jn,{className:"h-5 w-5 text-muted-foreground"})]})})}),n.jsx(Xn,{align:"start",className:"w-72 p-0",children:n.jsxs(br,{children:[n.jsx(vr,{autoFocus:!0,placeholder:"Find a type…"}),n.jsxs(wr,{children:[n.jsx(kr,{children:c?"Loading types…":"No type matches."}),l.length>0?n.jsx(un,{heading:"Types",children:l.map(p)}):null,m.length>0?n.jsx(un,{heading:"System",children:m.map(p)}):null]}),n.jsx(Nr,{}),n.jsxs(He,{to:"/$owner/data",params:{owner:e},onClick:()=>i(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[n.jsx(Sr,{className:"h-4 w-4"}),"Data map"]})]})})]})}function wi(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,t])=>t.on==="entity").map(([t,s])=>({name:t,description:s.description}))}const pt={table:{label:"Table",icon:$r},board:{label:"Board",icon:Lr},graph:{label:"Graph",icon:Gn}},bs=(e,t)=>`lobu.record-shape:v1:${e}/${t}`,ki=new Set(["table","board","graph"]);function Ni(e,t){const s=An(bs(e,t));return s&&ki.has(s)?s:void 0}function Si(e,t,s){Pn(bs(e,t),s)}const Ln=":records";function ji({ownerSlug:e,entityTypeSlug:t,create:s,onCreateChange:o,viewKey:r,shape:i}){const{orgContext:a,hasOrgContext:l}=Oe(),m=Wn(t,a),{data:c,isLoading:y,error:p}=m;Cr(`/${e}`,a);const f=_r(),[h,x]=v.useState({key:"",page:0}),d=es({strict:!1}),N=tt(),_=Jt(),j=`/${e}/${Qn(t)}`,E=!y&&c?.slug===t,{collection:k,error:b,presentation:w,preset:M,edited:P,table:A}=v.useMemo(()=>Ca(d,c?.metadata_schema,!!r),[d,c?.metadata_schema,r]),I=E?b:void 0,F=v.useMemo(()=>Ia(d,k),[d,k]),[B,J]=v.useState(!1),[W,se]=v.useState(0),me=k.search??"",X=k.segment,Ee=JSON.stringify(k),ue=X?wi(c).find(L=>L.name===X)??{name:X,description:""}:null,G=L=>void N({to:".",search:{...Be(L),...F},replace:!0}),te=Mr(m.data),xe=te?A.sort:$a(A),Ce=xe?.field,Ve=xe?.order,ie=v.useMemo(()=>Ce?[{id:Ce,desc:Ve==="desc"}]:[],[Ce,Ve]),ke=v.useCallback(L=>void N({to:".",search:{...r?Be(d):{},...F,$table:JSON.stringify(L)},replace:!0}),[N,r,d,F]),Ae=v.useCallback(L=>{const K=typeof L=="function"?L(ie):L;K[0]&&ke({...A,sort:{field:K[0].id,order:K[0].desc?"desc":"asc"}})},[ie,ke,A]),be=s===!0,Ue=()=>o(!0),Ne=()=>o(!1),Pe=ie[0]?.id,fe=ie[0]?ie[0].desc?"desc":"asc":void 0,_e=m.data?.metadata_schema,pe=!!tn(_e)&&!te,Me=ei(_e,{isDerived:te}),re=ts(a),nt=Pt(re.data??[],t,k),ge=(L,K=!1,ye=Be(d))=>{const he=!r||!re.data||Pt(re.data,t,L).some(lt=>lt.key===r);N({to:he?".":j,search:{...he&&r?ye:{},..._a(L,M?.key),$table:JSON.stringify(A)},replace:K})},Te=L=>{const K=L?yt(L):{},ye=!r||Pt(re.data??[],t,K).some(he=>he.key===r);J(!1),se(he=>he+1),N({to:ye?".":j,search:L?{$preset:L.key}:{}})},{isAdmin:De}=Dn(a.organizationId),Fe=Tr(a),C=De&&!!c&&!m.isPlaceholderData,u=v.useRef(d);u.current=d;const g=async()=>{if(!M)return;const L=JSON.stringify(d),{data:K}=await m.refetch(),ye=K?.metadata_schema,he=ye?Xt(ye[Ht]??{}):void 0,lt=he?.presets?.find(dt=>dt.key===M.key);if(!K||!ye||!he||!lt){Bn.error("This saved filter changed. Reload and try again.");return}const It=Ma(lt,k,A,he);await Fe.mutateAsync({slug:K.slug,metadata_schema:{...ye,[Ht]:{...he,presets:he.presets?.map(dt=>dt.key===It.key?It:dt)}}}).then(()=>!0,()=>!1)&&(await m.refetch(),JSON.stringify(u.current)===L&&Te(It))},S=v.useMemo(()=>Ni(e,t),[e,t]),T=Rr(re.data??[],t,{viewKey:r,shape:i??(r?void 0:S)},Me,k),R=T.kind==="builtin"?T.mode==="board"&&!pe?"table":T.mode:null,O=R==="graph";v.useEffect(()=>{i&&E&&R&&Si(e,t,R)},[i,E,R,e,t]);const H=["table",...pe?["board"]:[],"graph"],z=T.kind==="view"?T.view:null,D=T.kind==="missing"?T.key:null,ce=T.kind==="inapplicable"?T:null,oe=R==="table"?50:200,ve=`${t}?${Ee}&sort=${JSON.stringify(A.sort)}&size=${oe}`,Re=h.key===ve?h.page:0,Ge=v.useCallback(L=>x(K=>({key:ve,page:L(K.key===ve?K.page:0)})),[ve]),Ie=mn(t,a,{limit:oe,offset:Re*oe,search:me.trim()||void 0,sortBy:Pe,sortOrder:fe,segment:X,filters:k.filters,enabled:E&&!r&&!I}),qe=mn(t,a,{limit:1,offset:0,parentId:null,search:me.trim()||void 0,segment:X,filters:k.filters,enabled:E&&!r&&!I&&!te}),{data:Ye,error:Mt}=Ie,$=Ie.isLoading||Ie.isPending&&Ie.fetchStatus==="paused",Y=I||p||(r?null:Mt),Q=!!r&&re.data===void 0&&re.isError,V=Ye?.entities??[],Z=Ye?.metadata?.has_more??!1,q=Ye?.metadata?.total_count??0,Le=V.length>0||me.trim().length>0||Re>0||!!X||!!k.filters?.length,ne=c?.name?.trim()||Dt(t),de=c?.icon||void 0,ee=te,le=_e,Se=!I&&(!l||!E||(r?re.data===void 0&&!re.isError:$||!te&&qe.isLoading)),ze=Ye?.linked_entities??{},st=qe.data?.metadata?.total_count,Ke=q>0&&typeof st=="number"?st<q:!1,rt=v.useMemo(()=>c?.measure_columns??[],[c?.measure_columns]),Je=v.useCallback(L=>ke({...A,columns:L}),[ke,A]),ot=v.useMemo(()=>({entities:V,owner:e,schema:le,entityTypeIcon:de,isDerived:ee,measureColumns:rt,linkedEntityLookups:ze,hasAnyParents:Ke,sorting:ie,onSortingChange:Ae,visibleColumns:A.columns,columnChoices:eo(le,ee,V),onVisibleColumnsChange:Je,page:Re,pageSize:oe,totalCount:q,hasMore:Z,pageTitle:ne,onPrevPage:()=>Ge(L=>Math.max(0,L-1)),onNextPage:()=>Ge(L=>L+1)}),[V,e,le,de,ee,rt,ze,Ke,ie,A.columns,Je,Ae,Ge,Re,oe,q,Z,ne]),nn=q>V.length,sn=`showing first ${V.length} of ${q} — narrow with search`,rn=v.useMemo(()=>({owner:e,entityType:c,entities:V,totalCount:q,schema:le,entityTypeIcon:de}),[e,c,V,q,le,de]),Tt=v.useMemo(()=>({tableState:ot,boardState:rn,owner:e,schema:le,entityType:c,entityTypeIcon:de,totalCount:q,isTruncated:nn,truncationNotice:sn,canCreate:!ee,addLabel:`Add ${c?.name||Dt(t)}`}),[ot,rn,e,le,c,de,q,nn,sn,ee,t]),vs=v.useMemo(()=>ni({canShowBoard:pe,builtinData:Tt,builtInLabels:{table:pt.table.label,board:pt.board.label}}),[pe,Tt]),on=R?vs.find(L=>L.id===R)??null:null,ws=on?.template??hs,ks=on?.data??Tt,an=L=>void N({to:L===Ln?j:`${j}${Pr(L)}`,search:F}),Rt=Be(d),Ns=ho(z?.params,Rt,L=>void N({to:".",search:{...Be(L),...F}})),Ss=()=>ge({...k,filters:[],segment:void 0},!1,go(z?.params,Rt)),cn=`Moved on ${c?.name||c?.slug||t} board`,ln=v.useMemo(()=>(L,K)=>f.mutateAsync({entityId:L,metadata:K,field_note:cn}),[f,cn]),js=v.useMemo(()=>({updateEntity:ln,openCreate:()=>o(!0)}),[ln,o]),dn=L=>_?n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:ae("size-8 text-muted-foreground hover:text-foreground",L),"aria-label":"Edit type",title:"Edit type",onClick:()=>_.open({href:Ar(e,t),title:ne}),children:n.jsx(Or,{className:"h-4 w-4"})}):null;return n.jsx(to,{title:n.jsx(vi,{ownerSlug:e,typeSlug:t,title:ne,shape:r?null:R}),actions:dn(be||!E?"":"hidden @lg:inline-flex"),controls:n.jsxs(n.Fragment,{children:[be?n.jsx("div",{className:"max-w-3xl",children:n.jsx(Sa,{onClose:Ne,entityTypeSlug:t,orgContext:a})}):null,!be&&E&&n.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${ne} views`,children:[dn("-mr-1 @lg:hidden"),!r&&H.length>1&&n.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:H.map(L=>{const K=pt[L].icon,ye=R===L;return n.jsx(U,{type:"button",variant:"ghost",size:"sm","aria-pressed":ye,title:pt[L].label,"data-testid":`shape-${L}`,className:ae("h-7 px-2",ye&&"bg-accent text-accent-foreground"),onClick:()=>void N({to:`${j}/${Zn}/${L}`,search:F,replace:!0}),children:n.jsx(K,{className:"h-4 w-4"})},L)})}),r&&n.jsx(U,{variant:"ghost",onClick:()=>an(Ln),children:"Records"}),!!w.presets?.length&&n.jsxs(Yn,{open:B,onOpenChange:J,children:[n.jsx(Kn,{asChild:!0,children:n.jsxs(U,{variant:"outline",className:ae("gap-2",P&&"border-dashed border-primary"),"data-edited":P||void 0,title:"Choose saved filter",children:[M?.label??(k.filters?.length||k.search?"Custom filter":"All records"),P?n.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,n.jsx(Jn,{className:"h-4 w-4 text-muted-foreground"})]})}),n.jsxs(Xn,{align:"start",className:"w-60 p-1",children:[n.jsx(U,{variant:M?"ghost":"secondary",className:"w-full justify-start",onClick:()=>Te(),children:"All records"}),w.presets.map(L=>n.jsx(U,{variant:M?.key===L.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>Te(L),children:L.label},L.key))]})]}),M&&P?n.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[n.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Te(M),children:"Reset"}),C?n.jsx(U,{size:"sm",disabled:Fe.isPending,onClick:()=>void g(),children:Fe.isPending?"Saving…":"Save"}):null]}):null,!I&&n.jsx(za,{collection:k,schema:le,label:ne,org:a??"",facetQuery:w.facetQuery,onChange:ge,viewFilters:Ns,onClearAll:Ss,segmentChip:ue?{id:"segment",label:"Segment",op:"is",value:Dt(ue.name),title:ue.description||void 0,editor:ue.description?{kind:"custom",render:()=>n.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:ue.description})}:void 0,onRemove:()=>ge({...k,segment:void 0})}:void 0},`filters:${t}:${W}`),nt.map(L=>n.jsx(U,{"data-testid":`tab-${L.key}`,variant:r===L.key?"secondary":"ghost","aria-pressed":r===L.key,onClick:()=>an(L.key),children:L.name},L.key)),n.jsx(Pa,{label:ne,search:k.search,onSearch:(L,K)=>ge({...k,search:L},K),className:"ml-auto min-w-40 max-w-64 flex-1"},`search:${t}:${W}`),!ee&&!r?n.jsxs(U,{size:"sm","aria-label":`Add ${ne||"entity"}`,onClick:()=>Ue(),children:[n.jsx(it,{className:"mr-2 h-4 w-4"}),"Add"]}):null]})]}),children:be?null:Se?O?n.jsx(Qt,{label:`Loading ${ne} graph`}):n.jsx(no,{}):Y?n.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[Y.message||`Failed to load ${ne.toLowerCase()}.`,I&&n.jsx(U,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>ge({}),children:"Clear filters"})]}):Q?n.jsx(os,{onRetry:()=>void re.refetch()}):ce?n.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[n.jsxs("h2",{className:"text-lg font-semibold",children:["“",ce.view.name,"” doesn’t apply to the current filters"]}),n.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(ce.when).map(([L,K])=>`${L} is ${K===null?"not supplied":String(K)}`).join(" and "),"."]}),n.jsx(He,{to:j,search:F,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${ne}`})]}):D?n.jsx(as,{viewKey:D,backTo:j,backLabel:`Back to ${ne}`}):z?n.jsx(is,{orgSlug:e,viewKey:z.key,scope:{type:t,collection:k},params:Rt,onParamsChange:G,contentHash:z.content_hash,title:z.name,minHeight:320}):O&&Le?n.jsx(Xa,{ownerSlug:e,typeSlug:t,sourceBacked:te,records:V.map(L=>({...L,id:L.id??JSON.stringify([L.entity_type,L.slug])})),hasMore:Z}):Le?n.jsx(io,{template:ws,data:ks,actions:js,components:bi}):n.jsx(Un,{icon:Ir,iconElement:n.jsx(Et,{icon:c?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${ne.toLowerCase()} yet`,description:ee?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${c?.name?.toLowerCase()||"entity"}.`,actionLabel:ee?void 0:`Add ${c?.name||"Entity"}`,onAction:ee?void 0:()=>Ue()})})}function Ei(e,t){return ae("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",t,e?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground")}function Ci({ownerSlug:e,typeScope:t,create:s,createType:o=!1,viewKey:r,shape:i}){const a=tt(),{orgContext:l}=Oe(),m=es({strict:!1}),c=t?Dr(t):void 0,y=c==="$member",p=()=>{a({to:"/$owner/data",params:{owner:e},search:{}})},f=x=>{if(!c)return;const d=Fn(e,c);a({to:d.to,params:d.params,search:x?{create:!0}:{},replace:!0})},h=o?n.jsx("div",{className:"mx-auto w-full max-w-3xl",children:n.jsx(xo,{entityType:null,orgContext:l,onClose:p})}):c?n.jsx(ji,{ownerSlug:e,entityTypeSlug:c,create:s,onCreateChange:f,viewKey:r,shape:i}):n.jsx(_i,{ownerSlug:e,viewKey:r,search:m});return n.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:y?n.jsx(bo,{children:h}):h})}function _i({ownerSlug:e,viewKey:t,search:s}){const o=tt(),{orgContext:r}=Oe(),{data:i,isError:a,error:l,refetch:m}=ts(r),c=Fr(i??[],t),y=zr(),p=Wr(i??[]),f=a?Br(l,{subject:"Views"}):null;if(t&&i===void 0)return a?n.jsx(os,{error:l,onRetry:()=>void m()}):null;if(c.kind==="missing")return n.jsx(as,{viewKey:c.key,backTo:`/${e}/data`,backLabel:"Back to Memory"});const h=y?p:[];return n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[h.length>0?n.jsx("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-wrap items-center gap-1",children:h.map(x=>n.jsx(He,{to:"/$owner/data/-/views/$viewKey",params:{owner:e,viewKey:x.key},search:{},activeOptions:{exact:!0},"aria-current":t===x.key?"page":void 0,className:Mi(t===x.key),children:x.name},x.key))}):null,y&&f?n.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[f.title,"."," ",f.retryable?n.jsx("button",{type:"button",onClick:()=>void m(),className:"underline underline-offset-4",children:"Retry"}):null]}):null,c.kind==="view"?n.jsxs(n.Fragment,{children:[n.jsx(yo,{decls:c.view.params,params:Be(s),onParamsChange:x=>void o({to:".",search:x})}),n.jsx(is,{orgSlug:e,viewKey:c.view.key,scope:{},params:Be(s),onParamsChange:x=>void o({to:".",search:x,replace:!0}),contentHash:c.view.content_hash,title:c.view.name,minHeight:400})]}):n.jsx(Na,{ownerSlug:e})]})}const Mi=e=>Ei(e,"min-h-8 max-w-full gap-2 px-3 text-sm break-words");function Ui({ownerSlug:e,typeScope:t,create:s,createType:o=!1,viewKey:r,shape:i}){return n.jsxs(Hr,{inset:r?"flush":"page",className:r?"gap-0 pt-0 pb-0":"gap-6 pt-2.5 pb-8",children:[n.jsx(Ur,{}),n.jsx(Vr,{owner:e,children:a=>n.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:n.jsx(Ci,{ownerSlug:a.ownerSlug,typeScope:t,create:s,createType:o,viewKey:r,shape:i})})})]})}export{Ui as M};
|
|
74
|
-
//# sourceMappingURL=memory-browse-page-CUea2Llz.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as S,n as C,ct as k,aH as A,s as T,r as g,j as e,ar as L,as as B,cw as P,L as b,cx as R,cB as $,m as f,cF as p,aF as F}from"./index-C2TCKJDP.js";import{C as I,A as O}from"./create-automation-form-BhujNbRr.js";import"./entity-options-IUdQ-64R.js";import"./use-automations-lV8PuE8L.js";import"./device-automation-Dp3faMvp.js";import"./model-selector-BrfaDwIg.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-UppEMWpt.js";import"./index-Vcq4gwWv.js";import"./json-diff-CJK-gzCt.js";import"./use-mention-search-CA-evCDf.js";function D(n){return n.includes(":")?n.slice(n.indexOf(":")+1):n}function E({prefillAgentId:n,onCancel:t,initialTriggers:l,conversationSetup:h}){const{org:a}=C(),[i,x]=g.useState({ready:!1,triggers:[]}),[u,N]=g.useState(),o=g.useCallback(s=>{x(m=>JSON.stringify(m)===JSON.stringify(s)?m:s)},[]),r=u??l;return e.jsx(I,{startFromScratch:!!l,organizationId:a?.id??"",prefillAgentId:n,conversationSetup:h,onClose:t,onPrefillTriggers:s=>N(s.length>0?s:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!i.ready,createFields:{triggers:i.triggers},triggerFields:e.jsx(O,{organizationId:a?.id??null,initialTriggers:r,onChange:o},JSON.stringify(r??"new"))})}function J({owner:n,prefilled:t}){const l=S(),{org:h}=C(),a=k(h?.id??null,{status:"active",limit:500}),i=A(h?.id??null),{data:x=[]}=T(),u=!!(t?.platform&&(t.listen||t.resource)),N=u&&(a.isLoading||i.isLoading),o=g.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const d=a.data??[],j=t.connection?d.find(c=>c.slug===t.connection):(()=>{const c=d.filter(v=>v.connector_key!==t.platform?!1:t.resource?!0:v.facets.chat&&(v.external_tenant_id??"")===(t.team??""));return c.length===1?c[0]:void 0})();if(t.connection&&!j)return;const w=t.events?.split(",").map(c=>c.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...j?{connection_id:j.id}:{},event_types:w.length>0?w:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:D(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[a.data,t]),r=i.data?.find(d=>d.key===t?.platform)?.name,s=t?.label??t?.listen,m=g.useMemo(()=>t?.listen&&o&&s?{name:r?`${r}: ${s}`:s}:void 0,[s,r,o,t?.listen]),y=()=>void l({to:"/$owner",params:{owner:n},search:{section:"automation"}}),_=o?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:u&&!a.isLoading?"Choose the matching connection and event, then define the reaction.":"Start from a template, from scratch, or clone an existing Automation.";return e.jsx(L,{className:"gap-6 pt-2.5 pb-8",children:e.jsxs(B,{className:"flex min-w-0 flex-col gap-4",children:[e.jsx(P,{crumbs:[e.jsx(b,{to:"/$owner",params:{owner:n},search:{section:"automation"},className:R,children:"Automations"},"automations")],current:"New automation"}),e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:e.jsxs("h1",{className:"flex min-w-0 items-center gap-2 truncate font-display text-xl font-semibold",children:[e.jsx($,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"New automation"]})})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_}),m&&!t?.agent?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[x.length===0?"This workspace has no agents yet. ":"Choose the agent that answers here, or ",e.jsx(b,{to:"/$owner/agents/new",params:{owner:n},search:t,className:"underline underline-offset-4",children:x.length===0?"Create an agent":"create an agent"})," ","and come back to finish this setup."]}):null,N?e.jsxs("div",{className:"space-y-3",children:[e.jsx(f,{className:"h-10 w-full"}),e.jsx(f,{className:"h-32 w-full"})]}):u&&t?.connection&&!o?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(E,{prefillAgentId:t?.agent,onCancel:y,initialTriggers:o,conversationSetup:m})]})})}function Z(){const{owner:n}=p.useParams(),t=p.useSearch();return e.jsx(F,{owner:n,children:()=>e.jsx(J,{owner:n,prefilled:t})})}export{Z as component};
|
|
2
|
-
//# sourceMappingURL=new-5GkxlOuQ.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as R,z as U,Q as F,r,j as e,T as v,U as S,B as L,V as N,W as E}from"./index-C2TCKJDP.js";import{C as T,a as A,b as I,c as k}from"./card-rE4Ctuy6.js";import{F as B}from"./full-page-spinner-B7A6Ycyi.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function H(){const l=R(),{session:u,isReady:d}=U(),{slug:n,name:i}=F.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(B,{});const P=a=>{const s=E(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},z=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(T,{children:[e.jsx(A,{children:e.jsx(I,{children:"Create organization"})}),e.jsx(k,{children:e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{H as component};
|
|
2
|
-
//# sourceMappingURL=new-BiA4DGoN.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{hQ as o,c as l,ad as x,z as h,n as b,s as w,j as a,ar as j,as as A,cu as L,b1 as f,cw as C,L as N,cx as S,cz as k,b0 as y,b_ as E}from"./index-C2TCKJDP.js";import{A as O}from"./agent-editor-form-CDAHRNWl.js";import"./definition-comparison-3zKUSTt8.js";import"./json-diff-CJK-gzCt.js";import"./code-editor-UppEMWpt.js";import"./index-Vcq4gwWv.js";import"./schema-value-CefbtPIY.js";import"./model-selector-BrfaDwIg.js";function Q(){const{owner:e}=o.useParams(),t=o.useSearch(),r=l(),i=x(),{isAuthenticated:c}=h(),{isMember:m,isLoading:g}=b(),n=c&&m,{data:u=[],isLoading:d}=w({enabled:n});return a.jsx(j,{className:"gap-3 pt-2.5 pb-8",children:a.jsxs(A,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(L,{breadcrumb:a.jsx(C,{crumbs:[a.jsx(N,{to:"/$owner",params:{owner:e},search:{section:"agent"},className:S,children:"Agents"},"agents")]}),icon:a.jsx(f.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),g||n&&d?a.jsx(k,{rows:1}):n?a.jsx(O,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const p=["agents",e];if(await i.refetchQueries({queryKey:p,exact:!0}),t.platform&&t.listen){await r({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await r({to:"/$owner/agents/$agentId",params:{owner:e,agentId:s}})}}):a.jsx(y,{icon:E,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{Q as component};
|
|
2
|
-
//# sourceMappingURL=new-M-MX_T5C.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{ad as ge,r as v,bC as Ie,bD as Be,bE as Ke,bF as Me,bG as be,j as e,bH as Y,B as N,bI as Ve,b0 as Ge,bJ as Ue,bK as He,bL as Ye,bM as Je,bN as Ze,bO as Xe,bP as es,bQ as ve,bo as ie,bR as ss,bS as ts,bT as ns,bU as me,bV as is,bW as as,c as os,a8 as We,G as rs,bX as cs,bY as ne,bZ as ls,T as je,U as Ne,b_ as ds,b$ as us,c0 as ms,ai as Ce,c1 as hs,m as P,V as le,c2 as ps,c3 as _e,c4 as ke,c5 as gs,W as xs,c6 as Se,ar as fs,as as ys,S as bs,i as vs,c7 as js}from"./index-C2TCKJDP.js";import{P as he,a as De,A as Ns}from"./agent-permissions-matrix-ju7L2M0l.js";import{C as we,a as Ae,b as Oe,c as Pe}from"./card-rE4Ctuy6.js";const ze=["auto","approval","deny"],Cs={matched_rule:"Matching policy rules apply.",default_approval:"No rule matches; approval is required.",unresolved_principal:"The requesting agent or Automation could not be identified.",parent_approval:"Approval is inherited from the parent action.",unavailable_operation:"This action is unavailable on the connection."},Le={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function pe(s){return{operation_key:s.operation_key??null,connector_key:s.connector_key??null,connection_id:s.connection_id??null,operation_category:s.operation_category??null}}const de=s=>JSON.stringify(pe(s)),$e=s=>({...s,effect:s.effects.execute??"approval"});function F({label:s,value:n,onChange:a,children:c,disabled:h}){return e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),e.jsx("select",{"aria-label":s,value:n,onChange:r=>a(r.target.value),disabled:h,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:c})]})}function _s(s,n){const a=n.connections?.find(c=>c.id===s.connection_id);return s.connection_id?`Connection: ${a?.display_name||a?.connector_key||"Unavailable"} (#${s.connection_id})`:s.connector_key?`Connector: ${n.connectors?.find(c=>c.key===s.connector_key)?.name||s.connector_key}`:"All connectors"}function ks(s,n){return s.operation_key?n.connector_operations.find(a=>a.operation_key===s.operation_key)?.name||s.operation_key:s.operation_category?Le[s.operation_category]:"All actions"}function ue(s,n){return`${_s(s,n)} · ${ks(s,n)}`}function Ee(s){return s.connection_id?`connection:${s.connection_id}`:s.connector_key?`connector:${s.connector_key}`:"all"}function Te({catalog:s}){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"all",children:"All connectors"}),e.jsx("optgroup",{label:"Connectors",children:s.connectors?.map(n=>e.jsx("option",{value:`connector:${n.key}`,children:n.name},n.key))}),e.jsx("optgroup",{label:"Connections",children:s.connections?.map(n=>e.jsxs("option",{value:`connection:${n.id}`,children:[n.display_name||n.connector_key," (#",n.id,")"]},n.id))})]})}function Ss({label:s,ariaLabel:n,disabled:a,onRemove:c}){const[h,r]=v.useState(!1);return h?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:a,"aria-label":"Confirm removal",onClick:async()=>{await c()&&r(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,"aria-label":n,onClick:()=>r(!0),children:s})}function ws({owner:s,connector:n,connection:a,agent:c}){const h=ge(),[r,y]=v.useState(c??""),C=Ie(s),l=C.data,u=l?.agents.some(t=>t.id===r)?r:"",m=Be(s,u),i=Ke(s,!u),[z,_]=v.useState(a?`connection:${a}`:n?`connector:${n}`:"all"),[M,J]=v.useState(z),[I,W]=v.useState(!1),[k,D]=v.useState(""),[A,V]=v.useState("all"),[Z,E]=v.useState("approval"),[g,S]=v.useState(!1),[L,T]=v.useState(null),[G,X]=v.useState(a?String(a):""),[U,Q]=v.useState(""),R=l?.connections?.some(t=>String(t.id)===G)?G:"",w=Me(s,R?Number(R):void 0,U,u||void 0);async function H(t,f){S(!0),T(null);try{if(u){const d={resource_class:"connector_action",...pe(t)};f?await Ye(s,u,{...d,effects:{execute:f}}):await Je(s,u,d)||T("This rule was already removed. The list has been refreshed.")}else{const d=i.data;if(!d)return;const K=d.rules.filter(qe=>de(qe)!==de(t));f&&K.push({...pe(t),effect:f});const ce=await Ze(s,{revision:d.revision,rules:K});h.setQueryData(Xe(s),ce)}return await Promise.all(["write-permissions","agent-permissions","available-operations","connector-operations","policy-explanation"].map(d=>h.invalidateQueries({queryKey:[d]}))),t}catch(d){d instanceof be&&d.status===409?(T("Policies changed in another session. Review the refreshed rules before saving again."),await i.refetch()):T(d instanceof Error?d.message:"Could not save policy.")}finally{S(!1)}}const q=C.error||(u?m.error:i.error);if(q instanceof be&&q.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(q)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(q)]});if(!l||(u?!m.data:!i.data))return e.jsx(Y,{label:"policies",rows:2});const b=t=>t==="all"||l.connectors?.some(f=>`connector:${f.key}`===t)||l.connections?.some(f=>`connection:${f.id}`===t)?t:"all",o=b(z),p=b(M),j=l.connections?.find(t=>`connection:${t.id}`===p),$=j?.connector_key??(p.startsWith("connector:")?p.slice(10):void 0),x=t=>p==="all"||Ee(t)==="all"?!0:t.connection_id?j?t.connection_id===j.id:l.connections?.some(f=>f.id===t.connection_id&&f.connector_key===$):t.connector_key===$;function B(t){return u?t.principal_kind==="agent"&&t.principal_id===u:!t.principal_kind}const ee=o.startsWith("connector:")?o.slice(10):o.startsWith("connection:")?l.connections?.find(t=>t.id===Number(o.slice(11)))?.connector_key:void 0,O=l.connector_operations.filter(t=>!ee||t.connector_key===ee),se=l.connections?.find(t=>t.id===Number(R))?.connector_key,ae=l.connector_operations.filter(t=>t.connector_key===se),oe=u?(m.data?.agent??[]).filter(t=>t.resource_class==="connector_action").map($e):i.data?.rules??[],te=(m.data?.floor??[]).filter(t=>t.resource_class==="connector_action"&&x(t)).map($e),Qe={connector_key:o.startsWith("connector:")?o.slice(10):o==="all"&&A==="specific"?O.find(t=>t.operation_key===k)?.connector_key??null:null,connection_id:o.startsWith("connection:")?Number(o.slice(11)):null,operation_key:A==="specific"?k:null,operation_category:A.startsWith("category:")?A.slice(9):null},re=oe.filter(x);function fe(){_(p),V("all"),D(""),E("approval"),W(!0)}const ye=(t,f=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:t.map(d=>{const K=!f&&B(d);return e.jsxs(De,{controls:e.jsxs(e.Fragment,{children:[e.jsx(he,{options:ze,value:d.effect,floor:"auto",compact:!0,disabled:g||!K,ariaLabel:`Policy for ${ue(d,l)}`,onChange:ce=>void H(d,ce)}),K&&e.jsx(Ss,{label:"Remove",disabled:g,ariaLabel:`Remove rule: ${ue(d,l)}`,onRemove:()=>H(d)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:ue(d,l)}),!K&&e.jsx("p",{className:"text-xs text-muted-foreground",children:d.principal_kind==="agent"&&!d.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([d.principal_kind,d.principal_id,de(d)]))})});return e.jsxs("div",{className:"space-y-4",children:[(p!==M||u!==r)&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"The requested scope is unavailable. Showing organization rules; install the connector or choose an available scope."}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Auto runs immediately. Ask waits for human approval. Block prevents execution and hides the action from agents. Authentication and guardrails still apply."}),e.jsxs("details",{className:"space-y-2",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-foreground",children:"How rules combine"}),e.jsx("p",{children:"A rule overrides another when it is narrower in target or actions and at least as narrow in the other. When rules are narrower in different ways, or use different categories, the stricter choice wins: Block, then Ask, then Auto. With no matching rule, the result is Ask. Impact categories apply only to writes."}),e.jsx("p",{children:"A connection-wide Auto does not override an organization-wide destructive Block. Add a destructive rule for that connection to make an exception."}),e.jsx("p",{children:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(F,{label:"Policy owner",value:u,onChange:y,disabled:g,children:[e.jsx("option",{value:"",children:"Organization"}),l.agents.map(t=>e.jsxs("option",{value:t.id,children:["Agent: ",t.name]},t.id))]}),u&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Auto adds no restriction for this agent. It inherits organization policy and cannot bypass Ask or Block."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Without a matching restriction, this agent inherits organization policy.":"Without a matching rule, actions require approval (Ask)."}),e.jsx(F,{label:"Show rules for",value:p,onChange:J,disabled:g,children:e.jsx(Te,{catalog:l})}),u&&te.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),ye(te,!0)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:u?"Saved restrictions":"Saved rules"}),!I&&re.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:g,onClick:fe,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:t=>{t.preventDefault(),!g&&(A!=="specific"||k)&&H(Qe,Z).then(f=>{f&&(W(!1),J(Ee(f)))})},children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add rule"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(F,{label:"Applies to",value:o,onChange:t=>{_(t),V("all"),D("")},disabled:g,children:e.jsx(Te,{catalog:l})}),e.jsxs(F,{label:"Actions",value:A,onChange:V,disabled:g,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:l.operation_categories?.map(t=>e.jsx("option",{value:`category:${t}`,children:Le[t]},t))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),A==="specific"&&e.jsxs(F,{label:"Specific action",value:k,onChange:D,disabled:g,children:[e.jsx("option",{value:"",children:"Choose action"}),O.map(t=>e.jsxs("option",{value:t.operation_key,children:[t.connector_name,": ",t.name]},t.operation_key))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(he,{options:ze,value:Z,floor:"auto",compact:!0,disabled:g,ariaLabel:"New rule decision",onChange:E}),e.jsx(Ve,{onCancel:()=>W(!1),cancelDisabled:g,children:e.jsx(N,{type:"submit",disabled:g||A==="specific"&&!k,children:g?"Saving…":"Save rule"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving an existing scope replaces its decision. Removing a rule reveals the next matching rule."})]}),re.length?ye(re):!I&&e.jsx(Ge,{icon:Ue,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:fe})]}),L&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:L}),e.jsxs("details",{className:"space-y-3 border-t pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Check an action"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(F,{label:"Check connection",value:R,onChange:t=>{X(t),Q("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),l.connections?.map(t=>e.jsxs("option",{value:String(t.id),children:[t.display_name||t.connector_key," (#",t.id,")"]},t.id))]}),e.jsxs(F,{label:"Check action",value:U,onChange:Q,disabled:!R,children:[e.jsx("option",{value:"",children:"Choose action"}),ae.map(t=>e.jsx("option",{value:t.operation_key.slice(t.connector_key.length+2),children:t.name},t.operation_key))]})]}),w.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(w.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:U?w.isPending?"Checking…":w.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:He[w.data.effect]})," ·"," ",Cs[w.data.reason]??"The server evaluated this action.",w.data.rule_ids.length>0?` · Rules ${w.data.rule_ids.map(t=>`#${t}`).join(", ")}`:""]}):"":""})]})]})}const As=[{action:"create_type",label:"Create entity types",description:"Add a new type and its initial fields."},{action:"update_type",label:"Edit entity types",description:"Change fields, write rules, event kinds, or type metadata."},{action:"delete_type",label:"Delete entity types",description:"Remove an entity-type definition."}],Os=[{action:"create_relationship_type",label:"Create relationship types",description:"Add a new kind of link between entity types."},{action:"update_relationship_type",label:"Edit relationship types",description:"Change a definition, or which types it may connect."},{action:"delete_relationship_type",label:"Delete relationship types",description:"Remove a relationship-type definition."}];function xe(s){return s.resource_class==="entity_schema"&&s.principal_kind===null&&s.entity_type_slug===null&&s.operation_key===null&&s.target_agent_id===null}function Ps(s){return s.agent.find(xe)}function zs(s,n){return{...s,agent:[...s.agent.filter(a=>!xe(a)),n]}}function $s(s){return{...s,agent:s.agent.filter(n=>!xe(n))}}function Es({label:s,description:n,action:a,value:c,pending:h,onChange:r}){return e.jsxs(De,{controls:e.jsx(he,{options:as("entity_schema",a),value:c,floor:"auto",disabled:h,compact:!0,ariaLabel:s,onChange:r}),children:[e.jsx("p",{children:s}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:n})]})}function Re({title:s,actions:n,effects:a,pending:c,onChange:h}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:s}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:n.map(({action:r,label:y,description:C})=>e.jsx(Es,{action:r,label:y,description:C,value:a[r]??me.entity_schema[r]??"deny",pending:c,onChange:l=>h(r,l)},r))})]})}function Ts({owner:s}){const n=ge(),a=es(s),c=Ie(s),h=ve({mutationFn:m=>ss(s,{resource_class:"entity_schema",effects:m}),onSuccess:m=>{n.setQueryData(a,i=>i&&zs(i,m)),n.invalidateQueries({queryKey:a})},onError:m=>{ie.error(m instanceof Error?m.message:"Failed to save schema policy")}}),r=ve({mutationFn:()=>ts(s,{resource_class:"entity_schema"}),onSuccess:()=>{n.setQueryData(a,m=>m&&$s(m)),n.invalidateQueries({queryKey:a})},onError:m=>{ie.error(m instanceof Error?m.message:"Failed to reset schema policy")}});if(c.isLoading)return e.jsx(Y,{label:"schema policy",variant:"cards",cards:1});if(c.isError||!c.data)return e.jsx(ns,{label:"schema policy"});const y=Ps(c.data),C=y?.effects??me.entity_schema,l=h.isPending||r.isPending,u=(m,i)=>{h.mutate({...y?.effects??me.entity_schema,[m]:i})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:y?"Custom policy":"Workspace defaults"}),y?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:l,onClick:()=>r.mutate(),children:[e.jsx(is,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{title:"Entity types",actions:As,effects:C,pending:l,onChange:u}),e.jsx(Re,{title:"Relationship types",actions:Os,effects:C,pending:l,onChange:u})]})]})}function Fe(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Rs(s,n,a){const c=s.split("/");return c[1]===n?(c[1]=a,c.join("/")||"/"):`/${a}`}function Fs({section:s}){return s==="policies"?e.jsx(Y,{label:"policies",rows:2}):s==="governance"?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx(Y,{label:"agent write defaults",variant:"table",rows:3})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx(Y,{label:"schema governance",rows:3})]})]}):e.jsxs("div",{role:"status","aria-label":"Loading general settings","aria-busy":"true",className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{"aria-hidden":"true",className:"space-y-4",children:[["name","slug"].map(n=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{className:"h-3.5 w-12 rounded-none"}),e.jsx("div",{className:"flex h-9 items-center border border-input bg-background px-3",children:e.jsx(P,{className:"h-4 w-32 rounded-none"})})]},n)),e.jsx(P,{className:"h-3 w-4/5 rounded-none"})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsx("div",{"aria-hidden":"true",className:"grid gap-2 sm:grid-cols-2",children:["private","public"].map(n=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-3",children:[e.jsx(P,{className:"mt-0.5 h-4 w-4 shrink-0 rounded-none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(P,{className:"h-4 w-16 rounded-none"}),e.jsx(P,{className:"h-3 w-full rounded-none"}),e.jsx(P,{className:"h-3 w-2/3 rounded-none"})]})]},n))})]}),e.jsxs("div",{"aria-hidden":"true",className:"flex justify-end gap-2",children:[e.jsx(P,{className:"h-9 w-20 rounded-none"}),e.jsx(P,{className:"h-9 w-28 rounded-none"})]})]})}function Is({owner:s,section:n="general",connector:a,connection:c,agent:h}){const r=os(),y=ge(),{data:C,error:l}=We(),{activeOrg:u,urlOrgSlug:m}=rs(),i=(C??[]).find(o=>o.slug===s&&o.is_member)??null,z=i?.id??s,_=cs(z,{name:i?.name??"",slug:i?.slug??"",visibility:i?.visibility??"private"}),[M,J]=_.field("name"),[I,W]=_.field("slug"),[k,D]=_.field("visibility"),[A,V]=ne(z,!!i),[Z,E]=ne(z,!1),[g,S]=ne(z,null),[L,T]=v.useState(!1),[G,X]=v.useState(!1),[U,Q]=ne(z,!1);if(ls(l)&&C===void 0)return e.jsxs(we,{role:"alert",children:[e.jsx(Ae,{children:e.jsx(Oe,{children:"Couldn't load organizations"})}),e.jsx(Pe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(C===void 0)return e.jsx(Fs,{section:n});if(!i)return e.jsxs(we,{children:[e.jsx(Ae,{children:e.jsx(Oe,{children:"Organization not found"})}),e.jsx(Pe,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You aren't a member of an organization at"," ",e.jsx("span",{className:"font-mono",children:s}),", or it has been deleted."]})})]});if(n==="policies")return e.jsx("div",{className:"space-y-6",children:e.jsxs("section",{id:"policies",className:"scroll-mt-6 space-y-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control connector actions across the organization. Changes to existing rules save automatically."})}),e.jsx(ws,{owner:s,connector:a,connection:c,agent:h},`${s}:${h??""}:${a??""}:${c??""}`)]})});if(n==="governance")return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the defaults agents inherit for entities and agents. Changes save automatically; agents can only tighten them."})]}),e.jsx(Ns,{owner:s,variant:"org-floor"})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control structural changes by agents and connected AI clients. Changes save automatically."})]}),e.jsx(Ts,{owner:s})]})]});const R=o=>{const p=xs(o);if(p.kind==="cross-host"){window.location.assign(p.href);return}r({to:p.to})},w=o=>{if(o==="public"&&i.visibility!=="public"){E(!0);return}D(o),E(!1)},H=async()=>{if(!_.canSubmit)return;const o=M.trim();if(!o){S("Name is required");return}const p=I.trim()||Fe(o);if(!p){S("Slug is required");return}T(!0),S(null);try{const j=o!==i.name||p!==i.slug,$=k!==i.visibility;let x=i.slug;if(j){const O=await le.update({organizationId:i.id,data:{name:o,slug:p}});if(O.error){S(O.error.message||"Failed to update organization");return}x=O.data?.slug??p}$&&(x=(await ps(x,k)).slug),(j||$)&&(_.accept(_.values,{name:o,slug:x,visibility:k}),await y.invalidateQueries({queryKey:["organizations"]}),ie.success("Organization updated"));const B=u?.id===i.id||m===i.slug,ee=x!==i.slug;if(B&&ee){const O=_e(),se=ke();if(O===i.slug&&se){const oe=gs(window.location.pathname,i.slug)||"/",te=`${window.location.protocol}//${x}.${se}${oe}${window.location.search}${window.location.hash}`;window.location.assign(te);return}const ae=Rs(window.location.pathname,i.slug,x);r({to:`${ae}${window.location.search}${window.location.hash}`});return}}catch(j){S(j instanceof Error?j.message:"Failed to update organization")}finally{T(!1)}},q=async()=>{X(!0),S(null);try{const o=await le.delete({organizationId:i.id});if(o.error){S(o.error.message||"Failed to delete organization");return}await y.invalidateQueries({queryKey:["organizations"]}),ie.success("Organization deleted");const j=(C??[]).filter(x=>x.is_member).find(x=>x.id!==i.id)??null,$=u?.id===i.id||m===i.slug;if($&&j){await le.setActive({organizationId:j.id}),R(j.slug);return}if($){const x=_e(),B=ke();if(x===i.slug&&B){window.location.assign(`${window.location.protocol}//app.${B}/`);return}r({to:"/"});return}r({to:"/"})}catch(o){S(o instanceof Error?o.message:"Failed to delete organization")}finally{X(!1),Q(!1)}},b=L||G;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"org-name",children:"Name"}),e.jsx(Ne,{id:"org-name",value:M,onChange:o=>{J(o.target.value),A||W(Fe(o.target.value))},placeholder:"e.g. My Team",disabled:b})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"org-slug",children:"Slug"}),e.jsx(Ne,{id:"org-slug",value:I,onChange:o=>{V(!0),W(o.target.value)},placeholder:"e.g. my-team",disabled:b}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Changing the slug rewrites this workspace's URL. Existing links to"," ",e.jsxs("span",{className:"font-mono",children:["/",i.slug]})," redirect for a grace period."]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>w("private"),disabled:b,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${k==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(ds,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Private"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only members can access this workspace."})]})]}),e.jsxs("button",{type:"button",onClick:()=>w("public"),disabled:b,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${k==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(us,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone can browse public pages for this workspace."})]})]})]}),Z&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:[e.jsx("p",{className:"text-foreground",children:"Make this workspace public? Catalog-style content may become visible outside the membership."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(N,{type:"button",size:"sm",onClick:()=>{D("public"),E(!1)},disabled:b,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>E(!1),disabled:b,children:"Cancel"})]})]})]}),g&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:g}),e.jsx(ms,{visible:_.hasConflict,onReload:_.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void r({to:`/${s}`}),disabled:b,children:"Cancel"}),e.jsxs(N,{onClick:H,disabled:b||!_.canSubmit,children:[L?e.jsx(Ce,{size:"lg",className:"mr-1.5"}):null,L?"Saving...":"Save changes"]})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:i.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i.is_personal?"Your personal workspace can't be deleted — your devices and personal connections are bound to it.":"Permanently removes the organization and all members' workspace access. This cannot be undone."}),!i.is_personal&&e.jsx("div",{className:"mt-3",children:U?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:q,disabled:b,children:[G?e.jsx(Ce,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>Q(!1),disabled:b,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>Q(!0),disabled:b,children:[e.jsx(hs,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Qs(){const{owner:s}=Se.useParams(),n=Se.useSearch(),a=n.section??"general",c={general:"General",policies:"Policies",governance:"Governance"}[a],{data:h}=We(),r=(h??[]).find(y=>y.slug===s&&y.is_member)?.name;return e.jsx(fs,{className:"pt-2.5 pb-8",children:e.jsxs(ys,{className:vs("flex flex-1 flex-col gap-6",js(a)),children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bs,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:c})]}),r?e.jsx("p",{className:"text-base font-medium text-foreground",children:r}):null]}),e.jsx(Is,{owner:s,...n,section:a})]})})}export{Qs as component};
|
|
2
|
-
//# sourceMappingURL=organization-CLrcmgNK.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,d_ as ae,jG as z,jH as oe,jI as X,jJ as ce,jK as le,r as g,jL as de,u as D,aH as ue,ct as me,m as $,ii as pe,ja as xe,B as k,jM as he,jN as K,jO as fe,dA as ge,jP as je,y as L,ai as P,ax as ee,cg as te,eH as ye,G as ve,x as Ne,g8 as we,H as ke,L as H,jQ as be,fT as Ae,gb as Ce,g5 as Se,jR as Ie,gj as G,e$ as $e,aF as Le,jS as Pe,n as Re,w as _e,jT as Te,cC as Oe,eA as Ee,cP as ze,eZ as De,f0 as Me,f6 as O,p as Fe,jU as Be,jV as Ke,d3 as He,jW as Ue,eG as Ve,a7 as We,jX as qe,A as Ge,jY as Qe}from"./index-C2TCKJDP.js";import{u as Ye,A as Ze}from"./automation-detail-content-BJwRU6qT.js";import{A as Je}from"./agent-loading-shells-BupiSjR-.js";import{s as Xe,h as et,R as tt,A as st}from"./agent-thread-DiVKn1WX.js";import{C as nt,a as rt,c as it,A as at}from"./connection-feed-detail-CJYqryAV.js";import{O as ot}from"./connect-menu-B9u86bb2.js";import{E as R,R as ct,b as lt,s as Q,p as Y,e as dt,f as ut}from"./events-feed-DwOkLk6A.js";import{S as mt}from"./source-record-panels-LJIWGtHb.js";import{S as pt}from"./schema-type-editor-panel-C4e8pq1A.js";import{c as xt,s as ht,k as ft}from"./renderer-ucwCQmBk.js";import{E as gt}from"./event-detail-CvaRN1qB.js";import{V as jt,R as yt}from"./views-access-required-BerT4Z1d.js";import{V as vt,a as Nt}from"./view-param-filters-Bp84PUMd.js";import{S as wt,g as kt}from"./status-variants-BxHtpMOj.js";import{a as bt}from"./use-automations-lV8PuE8L.js";import"./home-stream-Bg97PUBJ.js";import"./filter-editors-DQ5V4Cvh.js";import"./subDays-DwIOMzYC.js";import"./list-skeleton-bQAZ0hQp.js";import"./clients-CydgUHrc.js";import"./client-activity-scopes-B7xVaUA-.js";import"./client-rows-B3LULJxW.js";import"./home-toolbar-CpCcHA6z.js";import"./scoped-feed-bar-CapleZvS.js";import"./event-kind-options-fHAIXu24.js";import"./create-automation-form-BhujNbRr.js";import"./entity-options-IUdQ-64R.js";import"./device-automation-Dp3faMvp.js";import"./model-selector-BrfaDwIg.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-UppEMWpt.js";import"./index-Vcq4gwWv.js";import"./json-diff-CJK-gzCt.js";import"./use-mention-search-CA-evCDf.js";import"./proposal-review-shell-BVwOMoq9.js";import"./runs-B_iywKWb.js";import"./definition-comparison-3zKUSTt8.js";import"./schema-value-CefbtPIY.js";import"./runs-list-CJJFRhTl.js";import"./run-initiator-8vdkq-3o.js";import"./app-bridge-C4nPtae3.js";import"./pending-seed-DYYOoCvj.js";import"./feed-event-kinds-BYuZCoU4.js";import"./copy-button-1ALlvZU1.js";import"./entity-type-page-CouHZbc9.js";import"./card-rE4Ctuy6.js";import"./table-1O-ik4_O.js";import"./dynamic-schema-form-D3KnzCsW.js";import"./record-session-KuEDuF3S.js";function At(t){if(!t||typeof t!="object")return[];const s=t.properties;if(!s)return[];const r=Array.isArray(t.required)?new Set(t.required.map(String)):new Set;return Object.entries(s).map(([n,i])=>({name:n,type:String(i.type??"any"),required:r.has(n),description:typeof i.description=="string"?i.description:void 0}))}function Ct({fields:t}){return t.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>e.jsxs("li",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[e.jsx("code",{className:"text-xs font-medium text-foreground",children:s.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:s.type}),s.required?e.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),s.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]},s.name))})}function M({item:t,hideHeading:s=!1}){const r=t.schemaSections;return r?e.jsxs("article",{className:s?"space-y-4":"space-y-4 px-5 py-5",children:[!s&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ae,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h2",{className:"text-base font-medium text-foreground",children:t.title}),r.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:r.description}):null]})]}),r.sections.map(n=>{const i=At(n.schema);return e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n.title}),n.description?e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.description}):null]}),e.jsx(Ct,{fields:i})]},n.title)})]}):null}function St({actions:t}){const s=Object.entries(t).map(([r,n])=>{const i=n;return{id:r,name:i.name??r,description:i.description,action:i}});return e.jsx(z,{entries:s,label:"actions",renderDetail:({name:r,action:n})=>e.jsx(M,{hideHeading:!0,item:{href:"",title:r,schemaSections:X(n)}})})}function It({feeds:t}){const s=Object.entries(t).map(([r,n])=>{const i=n;return{id:r,name:i.name??r,description:i.description,feed:i}});return e.jsx(z,{entries:s,label:"feed types",renderDetail:({name:r,feed:n})=>e.jsx(M,{hideHeading:!0,item:{href:"",title:r,schemaSections:oe(n)}})})}function $t(t){const s=[];return t.forEach((r,n)=>{s.push({id:`sep:${r.runId}`,role:"system",parts:[{type:"text",text:Lt(r,n)}],createdAt:r.completedAt?new Date(r.completedAt).getTime():void 0});for(const i of r.messages)s.push({...i,id:`r${r.runId}:${i.id}`})}),s}function Lt(t,s){const r=(t.pendingActionCount??0)>0?`Waiting for you (${t.pendingActionCount})`:t.status==="completed"?"Completed":t.status??"Completed",n=(t.autoAppliedCount??0)>0?` · ${t.autoAppliedCount} applied automatically`:"",i=t.completedAt?new Date(t.completedAt).toLocaleString():null;return i?`Run ${s+1} · ${r}${n} · ${i}`:`Run ${s+1} · ${r}${n}`}const se=Symbol("trusted-automation-interaction");function Pt(t){return Object.defineProperty(t,se,{value:!0}),t}function Rt(t){return{title:`${t} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${t} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${t} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${t} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${t} proposals.`}]}}const _t=new Set(["automation-approval-batch"]);function Tt(t){return new Promise(s=>{t({onSettled:(r,n)=>s(!!n)})})}function Ot(){const t=ce(),s=le();return g.useMemo(()=>({toolNames:_t,resolve:(r,n)=>{if(!n||typeof n!="object"||n[se]!==!0)return null;const i=n;if(r==="automation-approval-batch"){const o=typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0?i.runId:null,l=typeof i.count=="number"&&Number.isSafeInteger(i.count)&&i.count>1?i.count:null,a=Array.isArray(i.runIds)?i.runIds.filter(d=>typeof d=="number"&&Number.isSafeInteger(d)&&d>0):[];return o===null||l===null||a.length!==l||new Set(a).size!==l?null:{view:Rt(l),handlers:{manage_operations:d=>d.action!=="approve"&&d.action!=="reject"?Promise.resolve(!0):Tt(p=>d.action==="approve"?t.mutate({run_id:o,run_ids:a},p):s.mutate({run_id:o,run_ids:a},p))}}}return null}}),[t,s])}const Et=/(?:^|\n)Run this Automation now/;function zt(t){return t.role==="user"&&t.parts.some(s=>s.type==="text"&&Et.test(s.text))}function Dt(t){return`history-interaction:${t.runId}:${t.eventId??"error"}`}function Mt({agentId:t,automationId:s,ownerSlug:r,runId:n}){const{data:i,isLoading:o}=de(t,s,{orgSlug:r,...n!=null?{runId:n}:{}}),l=Ot(),a=D(),d=g.useCallback(m=>{a?.open({href:`/${r}/automations/${s}?view=activity&run_id=${m}`,title:`Automation run #${m}`,runId:m})},[a,r,s]),p=g.useMemo(()=>{const m=i?.runs??[],b=(n!=null?m.filter(x=>x.runId===n):m).slice().reverse();return $t(b.map(x=>{const j=x.messages.map(u=>Xe(u,{showToolCalls:!0})).filter(u=>u!==null&&!zt(u));x.task?.trim()&&j.unshift({id:"task",role:"user",parts:[{type:"text",text:x.task.trim()}]});const N=x.actions??[],y=N.filter(u=>u.status==="pending");if(y.length>1){const u=y.map(h=>h.runId).sort((h,C)=>h-C);j.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${x.runId}`,toolName:"automation-approval-batch",args:Pt({runId:x.runId,count:y.length,runIds:u})}]})}for(const u of N){const h=et([u],{workspaceSlug:r,agentId:t,webOrigin:typeof window>"u"?null:window.location.origin});h&&j.push({...h,id:Dt(u)})}return{runId:x.runId,completedAt:x.completedAt,status:x.status,pendingActionCount:x.pendingActionCount,autoAppliedCount:x.autoAppliedCount,messages:j}}))},[t,i,r,n]);return o?e.jsx(Je,{readOnly:!0}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):e.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:e.jsx(tt,{messages:p,workspaceSlug:r,children:e.jsx(st,{readOnly:!0,readerPositionMode:"runs",interactionExtension:l,onRunSelect:n==null&&a?d:void 0})})})}function Ft({panel:t}){const s=ue(t.organizationId),r=t.section==="connections"||!!t.connectionId,n=me(t.organizationId,{connectorKey:t.connectorKey,connectionIds:t.connectionId?[t.connectionId]:void 0,enabled:r}),i=s.data?.find(l=>l.key===t.connectorKey),o=n.data?.find(l=>l.id===t.connectionId&&l.connector_key===t.connectorKey);return s.isLoading||r&&n.isLoading?e.jsx("div",{className:"p-5",children:e.jsx($,{className:"h-28 w-full"})}):s.isError||r&&n.isError?e.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):t.connectionId&&!o||!i&&!o&&t.section!=="connections"?e.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):e.jsx("div",{className:"p-5",children:t.section==="connections"?e.jsx(pe,{connections:n.data??[],connector:i,connectorKey:t.connectorKey,ownerSlug:t.ownerSlug}):o&&t.section==="data"?e.jsx(nt,{connection:o,ownerSlug:t.ownerSlug}):o?e.jsx(Ht,{connection:o,connector:i,panel:t}):i?t.section==="oauth-apps"?e.jsx(ot,{connector:i,organizationId:t.organizationId,newApp:!!t.newApp}):t.section==="feeds"?e.jsx(Bt,{connector:i}):i.installed===!1?e.jsx(Kt,{connector:i,ownerSlug:t.ownerSlug}):e.jsx(Vt,{connector:i,ownerSlug:t.ownerSlug}):null},`${t.connectorKey}:${t.connectionId??"connector"}:${t.section}`)}function Bt({connector:t}){return e.jsx(It,{feeds:t.feeds_schema??{}})}function Kt({connector:t,ownerSlug:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",e.jsx(K,{ownerSlug:s,connectorKey:t.key})]}),e.jsx(St,{actions:t.actions_schema??{}})]})}function Ht({connection:t,connector:s,panel:r}){const[n,i]=g.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:n,children:r.section==="feeds"?e.jsx(Ut,{connection:t,connector:s,ownerSlug:r.ownerSlug}):e.jsx(xe,{connection:t,ownerSlug:r.ownerSlug,inPeek:!0,onReviewPermissions:s?()=>i(!0):void 0})}),n&&s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>i(!1),children:"Back to actions"}),e.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),e.jsx(he,{connection:t,connectorDef:s})]})]})}function Ut({connection:t,connector:s,ownerSlug:r}){const{data:n=[],isLoading:i,isError:o}=ge(t.id),[l,a]=g.useState(!1),d=t.facets?.chat??!1;if(i)return e.jsx($,{className:"h-28 w-full"});if(o)return e.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=n.map(m=>({id:String(m.id),name:m.display_name||m.feed_key,status:je(m)??(m.operations.includes("sync")?"Sync enabled":"Live access"),feed:m}));return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:l,children:e.jsx(z,{entries:p,label:d?"channels":"feeds",action:Object.keys(s?.feeds_schema??{}).length>0?e.jsx(k,{size:"sm",variant:"outline",onClick:()=>a(!0),children:d?"Add channel":"Add feed"}):void 0,renderDetail:({feed:m})=>m.store==="channel_messages"?e.jsx(rt,{feed:m,hideHeader:!0}):e.jsx(it,{feed:m,connectorDef:s,ownerSlug:r})})}),l&&s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold",children:d?"Add channel":"Add feed"}),e.jsx(at,{organizationId:t.organization_id,connections:[t],connectorDefinitions:[s],onClose:()=>a(!1)})]})]})}function Vt({connector:t,ownerSlug:s}){const{data:r=[],isLoading:n,isError:i}=fe(t.key);if(n)return e.jsx($,{className:"h-28 w-full"});if(i)return e.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const o=t.actions_schema??{},l=r.map(a=>({id:a.operation_key,name:a.name??a.operation_key,description:a.description,operation:a}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",e.jsx(K,{ownerSlug:s,connectorKey:t.key})]}),e.jsx(z,{entries:l,label:"actions",renderControl:()=>e.jsx(K,{ownerSlug:s,connectorKey:t.key}),renderDetail:({operation:a,name:d})=>o[a.operation_key]?e.jsx(M,{hideHeading:!0,item:{href:"",title:d,schemaSections:X(o[a.operation_key])}}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function Wt({owner:t,name:s,agentId:r,clientIds:n}){const{data:i,isLoading:o}=L(t==="me"?null:t,{slug:t}),l=i?.workspace,a=t!=="me"&&l?.type==="organization"?l.id:null,d=n?.join(",")??"",p=g.useMemo(()=>({sortBy:"date",sortOrder:"desc",...r?{agentId:r}:{clientIds:d.split(",").filter(Boolean)}}),[r,d]);return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):e.jsx("div",{className:"space-y-3 px-4 py-4",children:e.jsx(R,{organizationId:a,ownerSlug:t,filters:p,hideOriginator:!0,groupStretches:!0,emptyState:e.jsxs("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:["No activity from ",s," yet."]})})})}function qt({owner:t,path:s}){const{data:r,isLoading:n}=L(t,{slug:t}),i=r?.workspace,o=i?.type==="organization"?i.id:null,l=o?{slug:t}:void 0,{data:a,isLoading:d}=ee(`/${t}/${te(s)}`,l),p=a?.entity,m=p?.id;return n||d?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):o?m==null?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?e.jsx(mt,{record:{type:p.entity_type,key:p.slug},orgContext:l}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{organizationId:o,ownerSlug:t,entityId:typeof m=="number"?m:void 0,filters:{sortBy:"date",sortOrder:"desc"},emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function Gt(t){if(Array.isArray(t.enum))return`One of ${t.enum.length}`;if(t.format==="date"||t.format==="date-time")return"Date";if(t.format==="uri")return"Link";if(t.format==="email")return"Email";const s=Array.isArray(t.type)?t.type[0]:t.type;return s==="array"?"List":s==="object"?"Group":s==="integer"||s==="number"?"Number":s==="boolean"?"Yes / no":"Text"}function Qt({owner:t,typeSlug:s,view:r}){const{data:n,isLoading:i}=L(t,{slug:t}),o=n?.workspace,l=o?.type==="organization"?o.id:null,{isAdmin:a}=ye(l??void 0),{orgContext:d}=ve(),{data:p,isSuccess:m}=Ne(d),v=(p??[]).find(A=>A.slug===s),b=m&&!v,x=`/${t}/${we(s)}`,{pathname:j}=ke(),N=j===x||j===`${x}/`||j.startsWith(`${x}/-/`),y=g.useMemo(()=>xt(v?.metadata_schema),[v?.metadata_schema]),u=D(),h=u?.close;g.useEffect(()=>{b&&h?.()},[b,h]);const C=g.useMemo(()=>({entityTypes:[s],sortBy:"date",sortOrder:"desc"}),[s]);if(i)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]});if(b)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This entity type no longer exists."});if(!l)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."});const _=v?.name??s;return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-4 py-2.5",children:[N?null:e.jsx(k,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs(H,{...Ae(t,s),children:[e.jsx(be,{className:"mr-1.5 h-3.5 w-3.5"}),"Browse records"]})}),v&&!N&&!Ce(v)&&v.entity_count!==0?e.jsx(k,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs(H,{to:"/$owner/$entityType/-/$shape",params:{owner:t,entityType:s,shape:"graph"},search:Ie(G(t,s)),children:[e.jsx(Se,{className:"mr-1.5 h-3.5 w-3.5"}),"Graph"]})}):null,r!=="activity"&&u?e.jsxs(k,{type:"button",variant:"ghost",size:"sm",className:"ml-auto h-8 gap-1.5 text-xs text-muted-foreground hover:text-foreground",onClick:()=>u.open({href:G(t,s,"activity"),title:`${_} activity`}),children:[e.jsx($e,{className:"h-3.5 w-3.5"}),"Activity"]}):null]}),r==="activity"?e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{organizationId:l,ownerSlug:t,filters:C,showEntityLinks:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to these records yet."})})}):a?e.jsx("div",{className:"p-4",children:e.jsx(pt,{slug:s,onClose:()=>h?.()})}):y.length>0?e.jsxs("section",{"aria-labelledby":"entity-type-peek-fields",className:"px-4 py-4",children:[e.jsx("h3",{id:"entity-type-peek-fields",className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Fields"}),e.jsx("dl",{className:"divide-y divide-border/60 text-sm",children:y.map(A=>e.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",title:A.prop.description,children:[e.jsx("dt",{className:"min-w-0 truncate",children:ht(A)}),e.jsx("dd",{className:"shrink-0 text-xs text-muted-foreground",children:Gt(A.prop)})]},A.key))})]}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This type has no fields yet."})]})}function Yt({owner:t,eventId:s,viewKey:r}){const n=D(),i=(o,l)=>e.jsx(gt,{owner:l,organizationId:o,eventId:s,viewKey:r,dense:!0,onSelectView:n?a=>n.retarget(a):void 0},`${l}/${s}/${r??""}`);return e.jsx("div",{className:"px-4 py-4",children:t==="me"?i(null,t):e.jsx(Le,{owner:t,children:({organizationId:o,ownerSlug:l})=>o?i(o,l):e.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function Zt({owner:t,feedId:s,semanticTypes:r}){const{data:n,isLoading:i}=L(t==="me"?null:t,{slug:t}),o=n?.workspace,l=t!=="me"&&o?.type==="organization"?o.id:null,a=g.useMemo(()=>({feedIds:[s],...r?.length?{semanticTypes:r}:{},sortBy:"date",sortOrder:"desc"}),[s,r]);return t!=="me"&&i?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):l==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{organizationId:l,ownerSlug:t,filters:a,showEntityLinks:!0,hideOriginator:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:r?.length===1?`No ${r[0]} events from this feed yet.`:"No matching events from this feed yet."})})})}function E({owner:t,runId:s,runIds:r,contentIds:n}){const{data:i,isLoading:o}=L(t==="me"?null:t,{slug:t}),l=i?.workspace,a=t!=="me"&&l?.type==="organization"?l.id:null,d=g.useMemo(()=>{if(t==="me")return n?.length?{contentIds:n,sortBy:"date",sortOrder:"desc"}:void 0;const m=r??(s!=null?[s]:void 0);if(!(!m?.length&&!n?.length))return{...m?.length?{runIds:m}:{},...n?.length?{contentIds:n}:{}}},[t,n,s,r]),p=d!=null;return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):t!=="me"&&a==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{presentation:"detail",organizationId:a,ownerSlug:t,filters:d,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:s!=null||r?.length?"No matching events from this run yet.":"No matching events yet."})})}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const F=25;function Jt({target:t}){const[s,r]=g.useState(0),{data:n,isLoading:i,isError:o,refetch:l}=Pe(t.entityId,t.orgContext,{relationshipType:t.relationshipType,limit:F,offset:s}),a=n?.total;return e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.label," · ",t.entityName,a!==void 0?` · ${a} current ${a===1?"link":"links"}`:n?` · ${n.rows.length} shown`:""]}),e.jsx(ct,{count:n?.failures?.length??0,onRetry:()=>void l()}),i?e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{className:"h-6 w-full"}),e.jsx($,{className:"h-6 w-full"})]}):o||!n?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void l(),children:"Retry"})]}):n.rows.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):e.jsx("ul",{className:"divide-y divide-border",children:n.rows.map(d=>e.jsx("li",{className:"flex items-center justify-between gap-3 py-1.5",children:e.jsx(lt,{row:d,entityId:t.entityId,ownerSlug:t.ownerSlug,orgContext:t.orgContext})},d.id))}),n&&(s>0||n.hasMore)?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{type:"button",variant:"outline",size:"sm",disabled:s===0,onClick:()=>r(Math.max(0,s-F)),children:"Previous"}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[n.rows.length," shown",a===void 0?"":` of ${a}`]}),e.jsx(k,{type:"button",variant:"outline",size:"sm",disabled:!n.hasMore,onClick:()=>r(s+F),children:"Next"})]}):null]})}function Xt({owner:t,path:s,viewKey:r}){const[n,i]=g.useState({}),{data:o,isLoading:l}=L(t,{slug:t}),a=o?.workspace,d=a?.type==="organization"?a.id:null,p=d?{slug:t,organizationId:d}:void 0,{data:m,isLoading:v}=ee(`/${t}/${te(s)}`,p),{isMember:b,isPublic:x,isLoading:j}=Re(t),N=b||x,y=_e({slug:t,organizationId:b?d:null}),u=m?.entity;if(l||v||j||N&&y.isLoading)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]});if(!N)return e.jsx(jt,{});if(y.isError)return e.jsx(vt,{onRetry:()=>void y.refetch()});const h=u?Te(y.data??[],{type:u.entity_type,id:u.id??u.slug}).find(C=>C.key===r):void 0;return!d||!u||!h?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(Nt,{orgSlug:t,viewKey:h.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id??u.slug},params:n,onParamsChange:i,contentHash:h.content_hash,title:h.name,minHeight:320})})}function ne({owner:t,runId:s}){const r=Oe({queryKey:["run-outcome",t,s],queryFn:async()=>{const i=await ze("manage_operations",{action:"get_run",run_id:s},{slug:t});if(!i.run)throw new Error(i.error||"Run not found");return i.run},enabled:t!=="me",staleTime:15e3,refetchInterval:i=>["pending","claimed","running"].includes(i.state.data?.status??"")?5e3:!1});if(t==="me")return null;if(r.isLoading)return e.jsx("p",{role:"status",className:"px-4 pt-4 text-xs text-muted-foreground",children:"Loading run…"});if(!r.data)return e.jsx("p",{role:"alert",className:"px-4 pt-4 text-sm text-destructive",children:"Could not load this run."});const n=r.data;return e.jsxs("section",{"aria-label":"Run outcome",className:"space-y-2 border-b px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(wt,{status:kt(n.status),children:n.status}),e.jsx("time",{dateTime:n.created_at,className:"text-xs text-muted-foreground",children:Ee(n.created_at)})]}),n.connection_display_name?e.jsx("p",{className:"text-sm",children:n.connection_display_name}):null,n.error_message?e.jsx("p",{className:"whitespace-pre-wrap break-words text-sm text-destructive",children:n.error_message}):null,r.isError?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Could not refresh this run. Showing its last known outcome."}):null]})}const Z=30;function I({label:t,children:s}){return e.jsxs("section",{className:"border-t px-4 py-3 first:border-t-0",children:[e.jsx("h3",{className:"mb-1.5 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),s]})}function B({label:t,detail:s}){return e.jsxs("div",{className:"flex items-baseline gap-3 py-0.5 text-sm",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),e.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:s})]})}function es({stretch:t,ownerSlug:s,connectorDefinitions:r,connectionName:n,sourceConnection:i,showEntity:o}){const l=D(),a=g.useMemo(()=>De(t),[t]),d=g.useMemo(()=>Me(t),[t]),[p,m]=g.useState(!1),[v,b]=g.useState(new Set),x=c=>e.jsx("li",{children:e.jsx(ut,{content:c,ownerSlug:s,connectorDefinitions:r,connectionName:n,showEntity:o})},c.id),j=c=>e.jsx("ul",{className:"-mx-1 divide-y overflow-hidden rounded-lg border",children:c.map(x)}),N=[...a.failedCalls.map(c=>c.content),...a.failedOperations.flatMap(c=>O(c)??[])],y=t.changes.flatMap(c=>O(c)??[]),u=[...t.calls.map(c=>c.content),...t.operations.flatMap(c=>O(c)??[])].sort((c,f)=>new Date(f.occurred_at).getTime()-new Date(c.occurred_at).getTime()),h=p?u:u.slice(0,Z),C=(c,f)=>e.jsxs(k,{variant:"ghost",size:"sm",className:"mt-2",onClick:f,children:["Show all ",c]});if(t.source){const{source:c}=t,f=t.flagged.flatMap(w=>O(w)??[]),ie=d.reduce((w,W)=>w+W.items.length,0),T=i?.(c.connectionId)??null;return e.jsxs("div",{className:"pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-4 pt-3 pb-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:c.name}),e.jsxs("span",{children:["· ",Q(t)]}),e.jsxs("span",{children:["· ",Y(ie,"item")]}),f.length>0?e.jsxs("span",{children:["· ",f.length," failed"]}):null,T&&l?e.jsxs(k,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>l.open({href:`/${s}/connectors/${encodeURIComponent(T.connectorKey)}/${c.connectionId}`,key:`connection:${c.connectionId}`,title:c.name,connectorPanel:{section:"data",connectorKey:T.connectorKey,connectionId:c.connectionId,organizationId:T.organizationId,ownerSlug:s}}),children:["All data from ",c.name]}):null]}),f.length>0?e.jsx(I,{label:`Failed · ${f.length}`,children:j(f)}):null,d.map(w=>{const q=v.has(w.type)?w.items:w.items.slice(0,Z);return e.jsxs(I,{label:w.label,children:[j(q),w.items.length>q.length?C(w.items.length,()=>b(new Set([...v,w.type]))):null]},w.type)})]})}const _=a.did.reduce((c,f)=>c+f.count,0),A=a.lookedAt.reduce((c,f)=>c+f.count,0),S=t.apps.length===1?t.apps[0]:null,V=S?.key.startsWith("client:")?`/${s}/events?client_ids=${encodeURIComponent(S.key.slice(7))}`:S?.key.startsWith("agent:")?`/${s}/events?agent=${encodeURIComponent(S.key.slice(6))}`:null;return e.jsxs("div",{className:"pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-4 pt-3 pb-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:dt(t)}),e.jsxs("span",{children:["· ",Q(t)]}),e.jsxs("span",{children:["· ",Y(t.calls.length,"call")]}),e.jsxs("span",{children:["· ",N.length," failed"]}),V&&S&&l?e.jsxs(k,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>l.open({href:V,title:S.name}),children:["All activity from ",S.name]}):null]}),N.length>0?e.jsx(I,{label:`Failed · ${N.length}`,children:j(N)}):null,t.kind==="background"?null:e.jsxs(I,{label:`Changed · ${y.length||a.changeSteps.reduce((c,f)=>c+f.count,0)}`,children:[y.length>0?j(y):null,a.changeSteps.map(c=>e.jsx(B,{label:c.title,detail:`${c.methods.join(" · ")} · ${c.count}`},c.title)),y.length===0&&a.changeSteps.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing changed."}):null]}),_>0?e.jsx(I,{label:`Did · ${_}`,children:a.did.map(c=>e.jsx(B,{label:c.group,detail:c.items.length>0?c.items.slice(0,5).map(f=>`${f.item} ${f.count}`).join(" · ")+(c.items.length>5?` · ${c.items.length-5} more`:""):String(c.count)},c.group))}):null,A>0?e.jsx(I,{label:`Looked at · ${A}`,children:a.lookedAt.map(c=>e.jsx(B,{label:c.title,detail:`${c.methods.join(" · ")} · ${c.count}`},c.title))}):null,e.jsxs(I,{label:`Raw calls · ${u.length}`,children:[j(h),u.length>h.length?C(u.length,()=>m(!0)):null]})]})}function Js({item:t}){if(t.connectorPanel)return e.jsx(Ft,{panel:t.connectorPanel});if(t.schemaSections)return e.jsx(M,{item:t});if(t.recordField)return e.jsx(yt,{target:t.recordField});if(t.recordPeer)return e.jsx(ft,{target:t.recordPeer});if(t.recordLinks)return e.jsx(Jt,{target:t.recordLinks});if(t.workStretch)return e.jsx(es,{...t.workStretch});if(typeof t.browserUrl=="string"&&t.browserUrl.length>0)return e.jsx(J,{item:t});const s=t.href?Fe(t.href):null;return s?s.kind==="memory"?"runId"in s?e.jsxs(e.Fragment,{children:[e.jsx(ne,{owner:s.owner,runId:s.runId}),e.jsx(U,{title:"What it produced",children:e.jsx(E,{owner:s.owner,runId:s.runId})}),e.jsx(re,{owner:s.owner,runId:s.runId})]}):"runIds"in s?e.jsx(E,{owner:s.owner,runIds:s.runIds}):e.jsx(E,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?e.jsx(qt,{owner:s.owner,path:s.path}):s.kind==="entity-type"?e.jsx(Qt,{owner:s.owner,typeSlug:s.typeSlug,view:s.view}):s.kind==="record-view"?e.jsx(Xt,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?e.jsx(Yt,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):s.kind==="feed"?e.jsx(Zt,{owner:s.owner,feedId:s.feedId,semanticTypes:s.semanticTypes}):s.kind==="agent"?e.jsx(Wt,{owner:s.owner,name:t.title,agentId:s.agentId,clientIds:s.clientIds}):t.runId?e.jsx(ts,{owner:s.owner,automationId:s.automationId,runId:t.runId}):e.jsx(ss,{owner:s.owner,automationId:s.automationId}):e.jsx(J,{item:t})}function J({item:t}){const s=t.body,r=t.notificationType??"generic",n=t.createdAt,i=t.browserUrl??null,o=t.browserHandoff??null;return e.jsxs("article",{className:"space-y-4 px-5 py-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Be,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ke(r)}),n?e.jsx("span",{children:He(n)}):null]})]}),s?e.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:e.jsx(Ue,{text:s,linkPolicy:r==="action_approval_needed"?"app-links":"strip"})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),t.owner&&t.sourceAttribution?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),e.jsx(Ve,{owner:t.owner,source:t.sourceAttribution,className:"text-xs"})]}):null,i?e.jsx("div",{className:"space-y-2",children:o?.state==="expired"?e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o.error_message??"This draft expired before the page was opened."}):o?.state==="completed"||o?.state==="preparing"?e.jsx("p",{className:"text-sm text-muted-foreground",children:o.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):e.jsxs(k,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{qe(i)},children:[e.jsx(We,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function U({title:t,children:s}){return e.jsxs("section",{"aria-label":t,className:"border-b",children:[e.jsx("h2",{className:"px-4 pt-4 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),s]})}function re({owner:t,runId:s}){return t==="me"?null:e.jsx("div",{className:"px-4 py-3",children:e.jsxs(H,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(s)},className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Open in Activity",e.jsx(Ge,{"aria-hidden":"true",className:"h-3.5 w-3.5"})]})})}function ts({owner:t,automationId:s,runId:r}){const{organizationId:n}=Ye(t),i=bt(s,void 0,n),o=Qe(i.data?.automation);return e.jsxs(e.Fragment,{children:[e.jsx(ne,{owner:t,runId:r}),e.jsx(U,{title:"What it produced",children:e.jsx(E,{owner:t,runId:r})}),o?e.jsx(U,{title:"How it ran",children:e.jsx(Mt,{agentId:o,automationId:s,ownerSlug:t,runId:r})}):i.isLoading?e.jsx($,{className:"m-4 h-24 rounded-lg"}):null,e.jsx(re,{owner:t,runId:r})]})}function ss({owner:t,automationId:s}){return e.jsx("div",{className:"px-4 py-4",children:e.jsx(Ze,{owner:t,agentId:null,automationId:s,view:"activity",onDone:()=>{}})})}export{Js as PeekPaneContent};
|
|
2
|
-
//# sourceMappingURL=peek-pane-content-B29OcHwm.js.map
|