@lobu/runtime-server 24.1.1 → 24.3.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/connectors.json +175 -39
- package/dist/catalogs/skills.json +2 -2
- package/dist/component.json +1 -1
- package/dist/connectors/gchat.ts +31 -1
- package/dist/connectors/google_gmail.ts +70 -41
- package/dist/connectors/google_gmail_references.ts +406 -0
- package/dist/connectors/linkedin-inbox-adapter.js +107 -36
- package/dist/connectors/linkedin-inbox.ts +13 -0
- package/dist/connectors/linkedin.ts +1 -1
- package/dist/connectors/postgres.ts +14 -8
- package/dist/connectors/reddit.ts +171 -5
- package/dist/connectors/whatsapp-web-adapter.js +147 -61
- package/dist/connectors/whatsapp-web-helpers.ts +6 -2
- package/dist/connectors/whatsapp_web.ts +48 -17
- package/dist/connectors/x-dm-adapter.js +252 -35
- package/dist/connectors/x.ts +189 -13
- package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +3 -1
- package/dist/db/migrations/20261024050000_events_source_reference_arrival.sql +27 -0
- package/dist/db/migrations/20261026000000_turn_write_receipts.sql +36 -0
- package/dist/db/migrations/20261026190000_federated_relationship_endpoints.sql +143 -0
- package/dist/dependencies.bun.lock +137 -202
- package/dist/embeddings-server.mjs +81 -11
- package/dist/guest.bundle.js +62 -25
- package/dist/owletto/dist/assets/_-XKF0m81R.js +3 -0
- package/dist/owletto/dist/assets/_-e8MbEBtw.js +2 -0
- package/dist/owletto/dist/assets/_agentId-Cv9goIFf.js +2 -0
- package/dist/owletto/dist/assets/_agentId-emObu67X.js +2 -0
- package/dist/owletto/dist/assets/_automationId-CfFFAYK1.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-D6NKXSOE.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-DFrkLLTU.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-D3vuAQPe.js +2 -0
- package/dist/owletto/dist/assets/_eventId-BV5SQaUA.js +2 -0
- package/dist/owletto/dist/assets/_name-DjtJMop4.js +2 -0
- package/dist/owletto/dist/assets/_owner-oBX68rb9.js +3 -0
- package/dist/owletto/dist/assets/_shape-C4lLPAwI.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-Cw-7q6hI.js +2 -0
- package/dist/owletto/dist/assets/_slug-B2g5qzn3.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CIKGCtdK.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-Dx4kJo7o.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-38lHBvjO.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-voRYSM3a.js +2 -0
- package/dist/owletto/dist/assets/agent-card-controls-DiU7Un5w.js +2 -0
- package/dist/owletto/dist/assets/{agent-client-setup-list-BlXB4SE5.js → agent-client-setup-list-Bkyw22GW.js} +4 -4
- package/dist/owletto/dist/assets/agent-connect-pages-CpBxQCpx.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-DsSoeQeF.js → agent-editor-form-QrIDroFL.js} +2 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-CyoGSxcZ.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-B7v6Cffw.js → agent-loading-shells-CamDtzHY.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-CgsQ8BK_.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-DFucg4c4.js → agent-skill-context-lWbXKEm1.js} +2 -2
- package/dist/owletto/dist/assets/agent-skills-route-D-w3tY_2.js +2 -0
- package/dist/owletto/dist/assets/agent-subpage-shell-CLqpn5Tb.js +2 -0
- package/dist/owletto/dist/assets/{agent-thread-D38STyeu.js → agent-thread-CsRexwTv.js} +4 -4
- package/dist/owletto/dist/assets/agents-DzH_FFKU.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-CmGrMvPC.js +2 -0
- package/dist/owletto/dist/assets/app-bridge-C4nPtae3.js +121 -0
- package/dist/owletto/dist/assets/app._appId-BO7G38fL.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-DMYxs6F6.js +2 -0
- package/dist/owletto/dist/assets/automations-DzH_FFKU.js +2 -0
- package/dist/owletto/dist/assets/calendar-DDCCSPW6.js +2 -0
- package/dist/owletto/dist/assets/callback-DFciMR8u.js +2 -0
- package/dist/owletto/dist/assets/{card-jzhQrMDP.js → card-BCsbrdGs.js} +2 -2
- package/dist/owletto/dist/assets/{claim-B-wq745Q.js → claim-BRua2b_7.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-BLIy1Zc3.js +2 -0
- package/dist/owletto/dist/assets/client-rows-DiJQ5D1z.js +2 -0
- package/dist/owletto/dist/assets/clients-8-EpRjsm.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-CEqoCky-.js → code-editor-BFZa4EIt.js} +3 -3
- package/dist/owletto/dist/assets/connect-C0cHE9Xl.js +2 -0
- package/dist/owletto/dist/assets/connect-menu-D2K4tmvW.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-D4EG5a0v.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-DhoCT6sT.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-Dn4qw2Us.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-BTI5JXA3.js +2 -0
- package/dist/owletto/dist/assets/connection-X9VU9Ijm.js +2 -0
- package/dist/owletto/dist/assets/connection-feed-detail-B6ydKasK.js +2 -0
- package/dist/owletto/dist/assets/connections-browser-BMV8bf54.js +2 -0
- package/dist/owletto/dist/assets/connector-boxes-DqZA-FdG.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-D-ECOlMJ.js → connector-provenance-BIg8P8WY.js} +2 -2
- package/dist/owletto/dist/assets/connector-scope-lists-CJYz53YF.js +2 -0
- package/dist/owletto/dist/assets/{connectors-CH4KBZyT.js → connectors-BroKpwhB.js} +2 -2
- package/dist/owletto/dist/assets/{consent-C9ZpHb7V.js → consent-fzLN-Qy7.js} +2 -2
- package/dist/owletto/dist/assets/copy-button-Df7QXE0w.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-BupT3V0i.js → core.esm-A1UnFbGs.js} +2 -2
- package/dist/owletto/dist/assets/create-BjwsYarn.js +2 -0
- package/dist/owletto/dist/assets/create-Dzr4mlr0.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-DHW6OUoS.js +3 -0
- package/dist/owletto/dist/assets/create-c94SPL21.js +2 -0
- package/dist/owletto/dist/assets/create._connectorKey-DLLn2nej.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-CWImw-kf.js → cronstrue-xxpD1P2-.js} +2 -2
- package/dist/owletto/dist/assets/{device-D-7WBe9E.js → device-C3AEoL5c.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-2U0UMu3_.js → device-pin-tombstone-B_te59GE.js} +2 -2
- package/dist/owletto/dist/assets/device._deviceId-ZU09qrot.js +2 -0
- package/dist/owletto/dist/assets/elk-worker.min-BENGc9gn.js +23 -0
- package/dist/owletto/dist/assets/{entity-avatar-mdh7Kq5D.js → entity-avatar-CEV4ttUQ.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-DJv2EhVV.js +2 -0
- package/dist/owletto/dist/assets/entity-page-BUghWZ1s.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-Lf6ONdpf.js +2 -0
- package/dist/owletto/dist/assets/event-card-CBlsG32u.js +2 -0
- package/dist/owletto/dist/assets/event-detail-BKSGEOdW.js +2 -0
- package/dist/owletto/dist/assets/events-feed-VfU4csn2.js +2 -0
- package/dist/owletto/dist/assets/feed-event-kinds-BYuZCoU4.js +2 -0
- package/dist/owletto/dist/assets/filter-bar-COU0sBFQ.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-C1Q_jEzD.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-6ZJv1uzM.js +2 -0
- package/dist/owletto/dist/assets/identity-BaFLmbSo.js +2 -0
- package/dist/owletto/dist/assets/index-008wj-Pz.js +7950 -0
- package/dist/owletto/dist/assets/index-BaetvYLa.js +2 -0
- package/dist/owletto/dist/assets/index-BiEf5xOE.css +1 -0
- package/dist/owletto/dist/assets/{index-CxF2XXzl.js → index-BrDP4PCs.js} +2 -2
- package/dist/owletto/dist/assets/index-BuXIeK7D.js +2 -0
- package/dist/owletto/dist/assets/index-CAVcR9za.js +2 -0
- package/dist/owletto/dist/assets/index-CMLfWGPU.js +2 -0
- package/dist/owletto/dist/assets/index-D0YEYP7N.js +2 -0
- package/dist/owletto/dist/assets/index-DFyBbp7b.js +2 -0
- package/dist/owletto/dist/assets/{index-D7gHOpfg.js → index-DNtYqkiA.js} +2 -2
- package/dist/owletto/dist/assets/index-DQxzeM37.js +2 -0
- package/dist/owletto/dist/assets/index-DkO0nPex.js +2 -0
- package/dist/owletto/dist/assets/index-KlRId0g6.js +2 -0
- package/dist/owletto/dist/assets/index-Ywnqi4A6.js +2 -0
- package/dist/owletto/dist/assets/index-wHFQv1aT.js +12 -0
- package/dist/owletto/dist/assets/index-xnxhf3Op.js +2 -0
- package/dist/owletto/dist/assets/{index-BTlx9K_t.js → index-yIub2xUM.js} +2 -2
- package/dist/owletto/dist/assets/json-diff-LE_vNZrM.js +4 -0
- package/dist/owletto/dist/assets/{list-skeleton-CepswBka.js → list-skeleton-Kzxi2OXB.js} +2 -2
- package/dist/owletto/dist/assets/login-DWOT6jtS.js +2 -0
- package/dist/owletto/dist/assets/logout-Dt_VDilG.js +2 -0
- package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-De75CR7W.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-p2vIbfkC.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-CDrAjH31.js → model-selector-3l9lY50C.js} +2 -2
- package/dist/owletto/dist/assets/model-udnQ_S43.js +2 -0
- package/dist/owletto/dist/assets/models-CQj7GIOp.js +2 -0
- package/dist/owletto/dist/assets/new-BOwIHkre.js +2 -0
- package/dist/owletto/dist/assets/{new-ktz9Cs_P.js → new-BbdwuJPm.js} +2 -2
- package/dist/owletto/dist/assets/new-DTuFCQhV.js +2 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-lZNZ9gul.js → oauth-workspace-access-QPo4YwRX.js} +2 -2
- package/dist/owletto/dist/assets/organization-BDzjnqPf.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-D7yt0PrA.js +2 -0
- package/dist/owletto/dist/assets/permissions-CfoY4WFY.js +2 -0
- package/dist/owletto/dist/assets/proposal-review-shell-CVkLnnKo.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-DXUTTGGp.js +2 -0
- package/dist/owletto/dist/assets/record-activity-BXhvJbd9.js +2 -0
- package/dist/owletto/dist/assets/{record-session-Pbr5czGw.js → record-session-D07szzqN.js} +2 -2
- package/dist/owletto/dist/assets/renderer-AJxSmE3-.js +97 -0
- package/dist/owletto/dist/assets/reset-password-kRYyQuTY.js +2 -0
- package/dist/owletto/dist/assets/runs-lG2ChtOt.js +2 -0
- package/dist/owletto/dist/assets/runs-panel-LnGpHCAQ.js +2 -0
- package/dist/owletto/dist/assets/schema-type-editor-panel-C_Es0qDf.js +2 -0
- package/dist/owletto/dist/assets/settings-CEAOg7fr.js +2 -0
- package/dist/owletto/dist/assets/settings-gGYXbFfd.js +2 -0
- package/dist/owletto/dist/assets/skills-BOL5c_Tk.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-CjFPgKKJ.js +2 -0
- package/dist/owletto/dist/assets/status-dot-CSBtKT4g.js +2 -0
- package/dist/owletto/dist/assets/table-DHM-vCxP.js +2 -0
- package/dist/owletto/dist/assets/use-automations-C4TSie1i.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-Dcunv4L0.js → use-mention-search-PfZrNbu_.js} +4 -4
- package/dist/owletto/dist/assets/use-scroll-sentinel-D-fJx_Md.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-DkX4YdDT.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-2ubIf_3N.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +137007 -132255
- package/npm-shrinkwrap.json +723 -1095
- package/package.json +7 -10
- package/vendor/@better-auth-kysely-adapter/LICENSE.md +20 -0
- package/vendor/@better-auth-kysely-adapter/README.md +17 -0
- package/vendor/@better-auth-kysely-adapter/dist/bun-sqlite-dialect-DoOVo4ja.mjs +123 -0
- package/vendor/@better-auth-kysely-adapter/dist/d1-sqlite-dialect-Cru74LbR.mjs +133 -0
- package/vendor/@better-auth-kysely-adapter/dist/index.d.mts +116 -0
- package/vendor/@better-auth-kysely-adapter/dist/index.mjs +719 -0
- package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.d.mts +27 -0
- package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.mjs +123 -0
- package/vendor/@better-auth-kysely-adapter/dist/sqlite-introspector-DSCAP82F.mjs +90 -0
- package/vendor/@better-auth-kysely-adapter/package.json +52 -0
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +34 -1
- package/vendor/connector-sdk/dist/index.d.ts +3 -1
- package/vendor/connector-sdk/dist/index.js +4 -0
- package/vendor/connector-sdk/dist/redact.d.ts +10 -0
- package/vendor/connector-sdk/dist/redact.js +130 -0
- package/vendor/connector-sdk/dist/types.d.ts +2 -1
- package/vendor/connector-sdk/package.json +6 -1
- package/vendor/core/dist/agent-tooling.d.ts +8 -0
- package/vendor/core/dist/agent-tooling.js +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +5 -0
- package/vendor/core/dist/connector-query-errors.d.ts +6 -0
- package/vendor/core/dist/connector-query-errors.js +4 -0
- package/vendor/core/dist/contracts/entity-reference.d.ts +3 -0
- package/vendor/core/dist/contracts/entity-reference.js +31 -0
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +3 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +4 -1
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +117 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +47 -14
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +13 -4
- package/vendor/core/dist/contracts/tools/manage-operations.js +19 -7
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +6 -1
- package/vendor/core/dist/contracts/tools/read-knowledge.js +20 -1
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +3 -1
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +4 -9
- package/vendor/core/dist/contracts/worker/device-automation.js +10 -15
- package/vendor/core/dist/contracts/worker/protocol.d.ts +20 -0
- package/vendor/core/dist/contracts/worker/protocol.js +20 -0
- package/vendor/core/dist/errors.d.ts +0 -20
- package/vendor/core/dist/errors.js +1 -25
- package/vendor/core/dist/otel.js +38 -10
- package/vendor/core/dist/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/utils/ajv.js +3 -1
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +31 -5
- package/vendor/postgres/.bun-tag-22d644c2873790db +0 -0
- package/vendor/postgres/cf/src/query.js +3 -1
- package/vendor/postgres/cjs/src/query.js +3 -1
- package/vendor/postgres/src/query.js +3 -1
- package/vendor/views/dist/api.js +31 -7
- package/vendor/views/dist/bridge.d.ts +2 -1
- package/vendor/views/dist/bridge.js +10 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-BorucF19.js +0 -3
- package/dist/owletto/dist/assets/_-CkGyNi0G.js +0 -2
- package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +0 -2
- package/dist/owletto/dist/assets/_agentId-DgRrCE2B.js +0 -2
- package/dist/owletto/dist/assets/_automationId-DSrZIYcs.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DWxv1uoi.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-BTP5ijdT.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-98Y3RuRO.js +0 -2
- package/dist/owletto/dist/assets/_deploymentId-B1UWPY0i.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BAnr8g8z.js +0 -2
- package/dist/owletto/dist/assets/_name-BUfFO_A0.js +0 -2
- package/dist/owletto/dist/assets/_owner-C79BwQ0I.js +0 -3
- package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +0 -2
- package/dist/owletto/dist/assets/_slug-DbPdDc-5.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-UXU5Fx2G.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-D7ORHntE.js +0 -2
- package/dist/owletto/dist/assets/agent-card-controls-CplnPhbv.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BmknviTI.js +0 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-TdvvIc_J.js +0 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-BkZu1LYE.js +0 -2
- package/dist/owletto/dist/assets/agent-skills-route-B3vvvZZe.js +0 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-CZJvnjNC.js +0 -2
- package/dist/owletto/dist/assets/agents-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-DJ67GZ93.js +0 -2
- package/dist/owletto/dist/assets/app-bridge-BCm4muqj.js +0 -128
- package/dist/owletto/dist/assets/app._appId-Cp78oEZ9.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-DSwbRpbx.js +0 -2
- package/dist/owletto/dist/assets/automations-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/callback-CBexCo3F.js +0 -2
- package/dist/owletto/dist/assets/client-rows-BYbsXGy9.js +0 -2
- package/dist/owletto/dist/assets/clients-BhNl1tVq.js +0 -2
- package/dist/owletto/dist/assets/connect-wx-qqLir.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-BqprYeOX.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-DhRoSzBr.js +0 -2
- package/dist/owletto/dist/assets/connection-CNm2ukrI.js +0 -2
- package/dist/owletto/dist/assets/connection-feed-detail-WcGCA6qY.js +0 -2
- package/dist/owletto/dist/assets/connections-browser-CrtnAs0Q.js +0 -2
- package/dist/owletto/dist/assets/connector-scope-lists-CRFEpSvk.js +0 -2
- package/dist/owletto/dist/assets/conversations-table-D_HOe1jN.js +0 -2
- package/dist/owletto/dist/assets/create-C4lptGWj.js +0 -2
- package/dist/owletto/dist/assets/create-CCjZxIkK.js +0 -2
- package/dist/owletto/dist/assets/create-DkgUQAbB.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-Bpy92SM5.js +0 -3
- package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +0 -2
- package/dist/owletto/dist/assets/deployments-C5hvipQh.js +0 -2
- package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +0 -2
- package/dist/owletto/dist/assets/deployments-body-DGII20dQ.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-Bn37UpWH.js +0 -2
- package/dist/owletto/dist/assets/entity-options-Clz_WXK-.js +0 -2
- package/dist/owletto/dist/assets/entity-page-D3e4iPle.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-DebN1vCM.js +0 -2
- package/dist/owletto/dist/assets/event-detail-DV_zfWnC.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-Bwhqj7lY.js +0 -2
- package/dist/owletto/dist/assets/guardrails-BiJollCA.js +0 -2
- package/dist/owletto/dist/assets/identity-HCFWtdaI.js +0 -2
- package/dist/owletto/dist/assets/index-8wxsyxqt.js +0 -2
- package/dist/owletto/dist/assets/index-9YuSRymd.js +0 -7950
- package/dist/owletto/dist/assets/index-B3c-0eZG.js +0 -2
- package/dist/owletto/dist/assets/index-B64PGxQm.js +0 -2
- package/dist/owletto/dist/assets/index-BSH07yVD.css +0 -1
- package/dist/owletto/dist/assets/index-BX0EA_oB.js +0 -2
- package/dist/owletto/dist/assets/index-CDz3-ieP.js +0 -12
- package/dist/owletto/dist/assets/index-CdJJaQDX.js +0 -2
- package/dist/owletto/dist/assets/index-CfT_W8Vo.js +0 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.js +0 -2
- package/dist/owletto/dist/assets/index-DB1iWI_a.js +0 -2
- package/dist/owletto/dist/assets/index-DMNzF8Lf.js +0 -2
- package/dist/owletto/dist/assets/index-DyB3IzOA.js +0 -2
- package/dist/owletto/dist/assets/index-Vcq4gwWv.js +0 -2
- package/dist/owletto/dist/assets/index-fgAJydgX.js +0 -2
- package/dist/owletto/dist/assets/json-diff-DIN5Jhfx.js +0 -4
- package/dist/owletto/dist/assets/login-DxGYyE4n.js +0 -2
- package/dist/owletto/dist/assets/logout-Bkzc7J44.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-BnuhLJ6X.css +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-D_UlBa27.js +0 -103
- package/dist/owletto/dist/assets/models-BAVeysNq.js +0 -2
- package/dist/owletto/dist/assets/new-C2av0diq.js +0 -2
- package/dist/owletto/dist/assets/new-snm1ctHn.js +0 -2
- package/dist/owletto/dist/assets/organization-Cb0W823y.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-BNR9ImQY.js +0 -2
- package/dist/owletto/dist/assets/permissions-Dv39zWKt.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-CFhOqCLf.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +0 -2
- package/dist/owletto/dist/assets/recent-QhnLDU1_.js +0 -2
- package/dist/owletto/dist/assets/record-activity-ZJntBfN_.js +0 -2
- package/dist/owletto/dist/assets/record-field-peek-Brh1IQGy.js +0 -2
- package/dist/owletto/dist/assets/reset-password-CzZw6RcC.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-C0_DNTcq.js +0 -2
- package/dist/owletto/dist/assets/runs-table-B1APZv7d.js +0 -2
- package/dist/owletto/dist/assets/schema-value-normalization-CKdPjdPC.js +0 -97
- package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +0 -2
- package/dist/owletto/dist/assets/settings-VDNiffKU.js +0 -2
- package/dist/owletto/dist/assets/skills-DgDGscm5.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-BdfOVPWn.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-B0quibBi.js +0 -2
- /package/vendor/{postgres/.bun-tag-2f292c6554a8475e → @better-auth-kysely-adapter/.bun-tag-abf95749a412716} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ia as e,j as o,av as n}from"./index-008wj-Pz.js";import{A as a}from"./agent-connect-pages-CpBxQCpx.js";import"./agent-client-setup-list-Bkyw22GW.js";import"./copy-button-Df7QXE0w.js";import"./clients-8-EpRjsm.js";import"./client-rows-DiJQ5D1z.js";function u(){const{owner:t}=e.useParams();return o.jsx(n,{owner:t,children:({ownerSlug:r})=>o.jsx(a,{owner:r})})}export{u as component};
|
|
2
|
+
//# sourceMappingURL=index-xnxhf3Op.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=index-
|
|
1
|
+
import{t as I,v as C,w as U,r as R,x as S,y as L,j as y}from"./index-008wj-Pz.js";import{F as P}from"./full-page-spinner-C1Q_jEzD.js";function f(t){return t?.trim().toLowerCase()||null}function _(t){return t?.methods??[]}function x(t,s){const e=f(s);if(!e)return null;for(const i of t){const o=_(i.auth_schema);if(!o.some(n=>n.type==="oauth"&&f(n.provider)===e&&Array.isArray(n.loginScopes)&&n.loginScopes.length>0))continue;const r=o.find(n=>n.type==="app_installation"&&f(n.provider)===e);if(r)return{connectorKey:i.key,provider:e,installShape:r.installShape??null}}return null}function z(){const{isAuthenticated:t,authReady:s,currentOwner:e,orgsReady:i}=I(),o=C(),p=U(),r=R.useRef(!1),n=new URLSearchParams(window.location.search).get("onboard_provider"),d=new URLSearchParams(window.location.search).get("connector"),l=d&&/^[a-z0-9][a-z0-9._-]{0,127}$/.test(d)&&!["create","deployments"].includes(d)?d:null;return R.useEffect(()=>{if(s&&p.pathname==="/"){if(t&&e){const a=new URLSearchParams(window.location.hash.replace(/^#/,"")),m=a.get("agent")?.trim(),h=a.get("thread")?.trim(),$=a.get("message")?.trim()||a.get("message_id")?.trim(),c=a.get("run")?.trim(),g=a.get("worker")?.trim();if(!!m&&!!h||!!c&&/^\d+$/.test(c)||!!g){if(r.current)return;if(r.current=!0,window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}`),m&&h){const u=$?`?message_id=${encodeURIComponent($)}`:"";window.location.replace(`/${encodeURIComponent(e)}/chat/${encodeURIComponent(m)}/c/${encodeURIComponent(h)}${u}`);return}if(c&&/^\d+$/.test(c)){const u=new URLSearchParams({run_ids:c,peek:"1",peek_run_id:c});window.location.replace(`/${encodeURIComponent(e)}/events?${u.toString()}`);return}if(g){window.location.replace(`/${encodeURIComponent(e)}/connectors/device/${encodeURIComponent(g)}`);return}}if(r.current)return;if(r.current=!0,l){o({to:"/$owner/connectors/$connectorKey",params:{owner:e,connectorKey:l},replace:!0});return}const w=()=>void o({to:"/$owner",params:{owner:e},replace:!0});if(n){S(e).then(u=>{const v=x(u,n);if(v){window.location.assign(`/${encodeURIComponent(e)}/connectors/${encodeURIComponent(v.connectorKey)}`);return}w()}).catch(w);return}w();return}if(t){i&&o({to:"/account/settings",replace:!0});return}o({to:"/auth/login",search:L({callbackUrl:l?`/?connector=${encodeURIComponent(l)}`:void 0}),replace:!0})}},[s,e,t,i,o,p.pathname,n,l]),y.jsx("div",{"data-public-loading":"true",children:y.jsx(P,{delayMs:0,className:"min-h-0 py-16"})})}export{z as component};
|
|
2
|
+
//# sourceMappingURL=index-yIub2xUM.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{j as x,bk as Je,V as W,r as P,cL as ze,C as _e,h as qe,dk as Ke}from"./index-008wj-Pz.js";import{T as be,P as Be,E as S,S as J,g as $e,V as Qe,F as Le,a as Q,R as U,D as M,G as Z,W as Y,l as Ze,h as Ye,b as Xe,C as et,c as tt,d as oe,s as nt,j as rt,e as it}from"./index-wHFQv1aT.js";function lt({operation:t}){switch(t){case"create":case"created":return x.jsx(W,{variant:"default",children:"Created"});case"update":case"updated":return x.jsx(W,{variant:"secondary",children:"Updated"});case"delete":case"deleted":return x.jsx(W,{variant:"destructive",children:"Deleted"});default:return x.jsx(W,{variant:"outline",children:t||"Change"})}}function Wt({operation:t,actor:e,createdAt:n,resource:l,changedFields:i,showAttribution:r=!0}){return x.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[x.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l?x.jsx("span",{className:"break-words text-sm font-medium",children:l}):null,x.jsx(lt,{operation:t}),r?x.jsx("time",{dateTime:n,title:n,className:"ml-auto text-xs text-muted-foreground",children:Je(n)}):null]}),r?x.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["by ",e||"unknown"]}):null,i?.length?x.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["Changed: ",i.join(", ")]}):null]})}class C{constructor(e,n,l,i){this.fromA=e,this.toA=n,this.fromB=l,this.toB=i}offset(e,n=e){return new C(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function j(t,e,n,l,i,r){if(t==l)return[];let o=ee(t,e,n,l,i,r),a=te(t,e+o,n,l,i+o,r);e+=o,n-=a,i+=o,r-=a;let f=n-e,c=r-i;if(!f||!c)return[new C(e,n,i,r)];if(f>c){let d=t.slice(e,n).indexOf(l.slice(i,r));if(d>-1)return[new C(e,e+d,i,i),new C(e+d+c,n,r,r)]}else if(c>f){let d=l.slice(i,r).indexOf(t.slice(e,n));if(d>-1)return[new C(e,e,i,i+d),new C(n,n,i+d+f,r)]}if(f==1||c==1)return[new C(e,n,i,r)];let s=Se(t,e,n,l,i,r);if(s){let[d,u,h]=s;return j(t,e,d,l,i,u).concat(j(t,d+h,n,l,u+h,r))}return ot(t,e,n,l,i,r)}let R=1e9,F=0,X=!1;function ot(t,e,n,l,i,r){let o=n-e,a=r-i;if(R<1e9&&Math.min(o,a)>R*16||F>0&&Date.now()>F)return Math.min(o,a)>R*64?[new C(e,n,i,r)]:ae(t,e,n,l,i,r);let f=Math.ceil((o+a)/2);_.reset(f),q.reset(f);let c=(h,m)=>t.charCodeAt(e+h)==l.charCodeAt(i+m),s=(h,m)=>t.charCodeAt(n-h-1)==l.charCodeAt(r-m-1),d=(o-a)%2!=0?q:null,u=d?null:_;for(let h=0;h<f;h++){if(h>R||F>0&&!(h&63)&&Date.now()>F)return ae(t,e,n,l,i,r);let m=_.advance(h,o,a,f,d,!1,c)||q.advance(h,o,a,f,u,!0,s);if(m)return at(t,e,n,e+m[0],l,i,r,i+m[1])}return[new C(e,n,i,r)]}class De{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,l,i,r,o,a){for(let f=-e+this.start;f<=e-this.end;f+=2){let c=i+f,s=f==-e||f!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,d=s-f;for(;s<n&&d<l&&a(s,d);)s++,d++;if(this.vec[c]=s,s>n)this.end+=2;else if(d>l)this.start+=2;else if(r){let u=i+(n-l)-f;if(u>=0&&u<this.len&&r.vec[u]!=-1)if(o){let h=r.vec[u];if(h>=n-s)return[h,i+h-u]}else{let h=n-r.vec[u];if(s>=h)return[s,d]}}}return null}}const _=new De,q=new De;function at(t,e,n,l,i,r,o,a){let f=!1;return!N(t,l)&&++l==n&&(f=!0),!N(i,a)&&++a==o&&(f=!0),f?[new C(e,n,r,o)]:j(t,e,l,i,r,a).concat(j(t,l,n,i,a,o))}function Me(t,e){let n=1,l=Math.min(t,e);for(;n<l;)n=n<<1;return n}function ee(t,e,n,l,i,r){if(e==n||e==r||t.charCodeAt(e)!=l.charCodeAt(i))return 0;let o=Me(n-e,r-i);for(let a=e,f=i;;){let c=a+o,s=f+o;if(c>n||s>r||t.slice(a,c)!=l.slice(f,s)){if(o==1)return a-e-(N(t,a)?0:1);o=o>>1}else{if(c==n||s==r)return c-e;a=c,f=s}}}function te(t,e,n,l,i,r){if(e==n||i==r||t.charCodeAt(n-1)!=l.charCodeAt(r-1))return 0;let o=Me(n-e,r-i);for(let a=n,f=r;;){let c=a-o,s=f-o;if(c<e||s<i||t.slice(c,a)!=l.slice(s,f)){if(o==1)return n-a-(N(t,a)?0:1);o=o>>1}else{if(c==e||s==i)return n-c;a=c,f=s}}}function K(t,e,n,l,i,r,o,a){let f=l.slice(i,r),c=null;for(;;){if(c||o<a)return c;for(let s=e+o;;){N(t,s)||s++;let d=s+o;if(N(t,d)||(d+=d==s+1?1:-1),d>=n)break;let u=t.slice(s,d),h=-1;for(;(h=f.indexOf(u,h+1))!=-1;){let m=ee(t,d,n,l,i+h+u.length,r),p=te(t,e,s,l,i,i+h),g=u.length+m+p;(!c||c[2]<g)&&(c=[s-p,i+h-p,g])}s=d}if(a<0)return c;o=o>>1}}function Se(t,e,n,l,i,r){let o=n-e,a=r-i;if(o<a){let f=Se(l,i,r,t,e,n);return f&&[f[1],f[0],f[2]]}return o<4||a*2<o?null:K(t,e,n,l,i,r,Math.floor(o/4),-1)}function ae(t,e,n,l,i,r){X=!0;let o=n-e,a=r-i,f;if(o<a){let u=K(l,i,r,t,e,n,Math.floor(o/6),50);f=u&&[u[1],u[0],u[2]]}else f=K(t,e,n,l,i,r,Math.floor(a/6),50);if(!f)return[new C(e,n,i,r)];let[c,s,d]=f;return j(t,e,c,l,i,s).concat(j(t,c+d,n,l,s+d,r))}function ye(t,e){for(let n=1;n<t.length;n++){let l=t[n-1],i=t[n];l.toA>i.fromA-e&&l.toB>i.fromB-e&&(t[n-1]=new C(l.fromA,i.toA,l.fromB,i.toB),t.splice(n--,1))}}function st(t,e,n){for(;;){ye(n,1);let l=!1;for(let i=0;i<n.length;i++){let r=n[i],o,a;(o=ee(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new C(r.fromA+o,r.toA,r.fromB+o,r.toB)),(a=te(t,r.fromA,r.toA,e,r.fromB,r.toB))&&(r=n[i]=new C(r.fromA,r.toA-a,r.fromB,r.toB-a));let f=r.toA-r.fromA,c=r.toB-r.fromB;if(f&&c)continue;let s=r.fromA-(i?n[i-1].toA:0),d=(i<n.length-1?n[i+1].fromA:t.length)-r.toA;if(!s||!d)continue;let u=f?t.slice(r.fromA,r.toA):e.slice(r.fromB,r.toB);s<=u.length&&t.slice(r.fromA-s,r.fromA)==u.slice(u.length-s)?(n[i]=new C(r.fromA-s,r.toA-s,r.fromB-s,r.toB-s),l=!0):d<=u.length&&t.slice(r.toA,r.toA+d)==u.slice(0,d)&&(n[i]=new C(r.fromA+d,r.toA+d,r.fromB+d,r.toB+d),l=!0)}if(!l)break}return n}function dt(t,e,n){for(let l=0,i=0;i<t.length;i++){let r=t[i],o=r.toA-r.fromA,a=r.toB-r.fromB;if(o&&a||o>3||a>3){let f=i==t.length-1?e.length:t[i+1].fromA,c=r.fromA-l,s=f-r.toA,d=de(e,r.fromA,c),u=se(e,r.toA,s),h=r.fromA-d,m=u-r.toA;if((!o||!a)&&h&&m){let p=Math.max(o,a),[g,k,T]=o?[e,r.fromA,r.toA]:[n,r.fromB,r.toB];p>h&&e.slice(d,r.fromA)==g.slice(T-h,T)?(r=t[i]=new C(d,d+o,r.fromB-h,r.toB-h),d=r.fromA,u=se(e,r.toA,f-r.toA)):p>m&&e.slice(r.toA,u)==g.slice(k,k+m)&&(r=t[i]=new C(u-o,u,r.fromB+m,r.toB+m),u=r.toA,d=de(e,r.fromA,r.fromA-l)),h=r.fromA-d,m=u-r.toA}if(h||m)r=t[i]=new C(r.fromA-h,r.toA+m,r.fromB-h,r.toB+m);else if(o){if(!a){let p=ce(e,r.fromA,r.toA),g,k=p<0?-1:fe(e,r.toA,r.fromA);p>-1&&(g=p-r.fromA)<=s&&e.slice(r.fromA,p)==e.slice(r.toA,r.toA+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toA-k)<=c&&e.slice(r.fromA-g,r.fromA)==e.slice(k,r.toA)&&(r=t[i]=r.offset(-g))}}else{let p=ce(n,r.fromB,r.toB),g,k=p<0?-1:fe(n,r.toB,r.fromB);p>-1&&(g=p-r.fromB)<=s&&n.slice(r.fromB,p)==n.slice(r.toB,r.toB+g)?r=t[i]=r.offset(g):k>-1&&(g=r.toB-k)<=c&&n.slice(r.fromB-g,r.fromB)==n.slice(k,r.toB)&&(r=t[i]=r.offset(-g))}}l=r.toA}return ye(t,3),t}let y;try{y=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function je(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Ee(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?je(n)?1:0:y?!Te(n)||e==t.length-1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e,e+2))?2:0:0}function Ne(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?je(n)?1:0:y?!Ge(n)||e==1?y.test(String.fromCharCode(n))?1:0:y.test(t.slice(e-2,e))?2:0:0}const Oe=8;function se(t,e,n){if(e==t.length||!Ne(t,e))return e;for(let l=e,i=e+n,r=0;r<Oe;r++){let o=Ee(t,l);if(!o||l+o>i)return l;l+=o}return e}function de(t,e,n){if(!e||!Ee(t,e))return e;for(let l=e,i=e-n,r=0;r<Oe;r++){let o=Ne(t,l);if(!o||l-o<i)return l;l-=o}return e}function fe(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function ce(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const Te=t=>t>=55296&&t<=56319,Ge=t=>t>=56320&&t<=57343;function N(t,e){return!e||e==t.length||!Te(t.charCodeAt(e-1))||!Ge(t.charCodeAt(e))}function ft(t,e,n){var l;let i=n?.override;return i?i(t,e):(R=((l=n?.scanLimit)!==null&&l!==void 0?l:1e9)>>1,F=n?.timeout?Date.now()+n.timeout:0,X=!1,st(t,e,j(t,0,t.length,e,0,e.length)))}function Re(){return!X}function Fe(t,e,n){return dt(ft(t,e,n),t,e)}const D=Le.define({combine:t=>t[0]}),ct=Q.define(),Ie=Le.define(),w=J.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(ct)&&(t=n.value);for(let n of e.state.facet(Ie))t=n(t,e);return t}});class E{constructor(e,n,l,i,r,o=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=i,this.toB=r,this.precise=o}offset(e,n){return e||n?new E(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let i=Fe(e.toString(),n.toString(),l);return We(i,e,n,0,0,Re())}static updateA(e,n,l,i,r){return pe(ge(e,i,!0,l.length),e,n,l,r)}static updateB(e,n,l,i,r){return pe(ge(e,i,!1,n.length),e,n,l,r)}}function ue(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.to==t&&r.to==e&&t<n.length&&e<l.length?[t+1,e+1]:[i.from,r.from]}function he(t,e,n,l){let i=n.lineAt(t),r=l.lineAt(e);return i.from==t&&r.from==e?[t,e]:[i.to+1,r.to+1]}function We(t,e,n,l,i,r){let o=[];for(let a=0;a<t.length;a++){let f=t[a],[c,s]=ue(f.fromA+l,f.fromB+i,e,n),[d,u]=he(f.toA+l,f.toB+i,e,n),h=[f.offset(-c+l,-s+i)];for(;a<t.length-1;){let m=t[a+1],[p,g]=ue(m.fromA+l,m.fromB+i,e,n);if(p>d+1&&g>u+1)break;h.push(m.offset(-c+l,-s+i)),[d,u]=he(m.toA+l,m.toB+i,e,n),a++}o.push(new E(h,c,Math.max(c,d),s,Math.max(s,u),r))}return o}const H=1e3;function me(t,e,n,l){let i=0,r=t.length;for(;;){if(i==r){let s=0,d=0;i&&({toA:s,toB:d}=t[i-1]);let u=e-(n?s:d);return[s+u,d+u]}let o=i+r>>1,a=t[o],[f,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(f>e)r=o;else if(c<=e)i=o+1;else return l?[a.fromA,a.fromB]:[a.toA,a.toB]}}function ge(t,e,n,l){let i=[];return e.iterChangedRanges((r,o,a,f)=>{let c=0,s=n?e.length:l,d=0,u=n?l:e.length;r>H&&([c,d]=me(t,r-H,n,!0)),o<e.length-H&&([s,u]=me(t,o+H,n,!1));let h=f-a-(o-r),m,[p,g]=n?[h,0]:[0,h];i.length&&(m=i[i.length-1]).toA>=c?i[i.length-1]={fromA:m.fromA,fromB:m.fromB,toA:s,toB:u,diffA:m.diffA+p,diffB:m.diffB+g}:i.push({fromA:c,toA:s,fromB:d,toB:u,diffA:p,diffB:g})}),i}function pe(t,e,n,l,i){if(!t.length)return e;let r=[];for(let o=0,a=0,f=0,c=0;;o++){let s=o==t.length?null:t[o],d=s?s.fromA+a:n.length,u=s?s.fromB+f:l.length;for(;c<e.length;){let g=e[c];if(s&&(g.toA+a>d||g.toB+f>u))break;r.push(g.offset(a,f)),c++}if(!s)break;let h=s.toA+a+s.diffA,m=s.toB+f+s.diffB,p=Fe(n.sliceString(d,h),l.sliceString(u,m),i);for(let g of We(p,n,l,d,u,Re()))r.push(g);for(a+=s.diffA,f+=s.diffB;c<e.length;){let g=e[c];if(g.fromA+a>h&&g.fromB+f>m)break;c++}}return r}const ut={scanLimit:500},He=Qe.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Ae(t))}update(t){(t.docChanged||t.viewportChanged||ht(t.startState,t.state)||mt(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Ae(t.view))}},{decorations:t=>t.deco});function ht(t,e){return t.field(w,!1)!=e.field(w,!1)}function mt(t,e){return t.facet(D)!=e.facet(D)}const xe=M.line({class:"cm-changedLine"}),Pe=M.mark({class:"cm-changedText"}),gt=M.mark({tagName:"ins",class:"cm-insertedLine"}),pt=M.mark({tagName:"del",class:"cm-deletedLine"}),Ce=new class extends Z{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function xt(t,e,n,l,i,r){let o=n?t.fromA:t.fromB,a=n?t.toA:t.toB,f=0;if(o!=a){i.add(o,o,xe),i.add(o,a,n?pt:gt),r&&r.add(o,o,Ce);for(let c=e.iterRange(o,a-1),s=o;!c.next().done;){if(c.lineBreak){s++,i.add(s,s,xe),r&&r.add(s,s,Ce);continue}let d=s+c.value.length;if(l)for(;f<t.changes.length;){let u=t.changes[f],h=o+(n?u.fromA:u.fromB),m=o+(n?u.toA:u.toB),p=Math.max(s,h),g=Math.min(d,m);if(p<g&&i.add(p,g,Pe),m<d)f++;else break}s=d}}}function Ae(t){let e=t.state.field(w),{side:n,highlightChanges:l,markGutter:i,overrideChunk:r}=t.state.facet(D),o=n=="a",a=new U,f=i?new U:null,{from:c,to:s}=t.viewport;for(let d of e){if((o?d.fromA:d.fromB)>=s)break;(o?d.toA:d.toB)>c&&(!r||!r(t.state,d,a,f))&&xt(d,t.state.doc,o,l,a,f)}return{deco:a.finish(),gutter:f&&f.finish()}}const $=Q.define({map:(t,e)=>e.mapPos(t)});class Ct extends Y{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let i=e.posAtDOM(l.target);e.dispatch({effects:$.of(i)});let{side:r,sibling:o}=e.state.facet(D);o&&o().dispatch({effects:$.of(At(i,e.state.field(w),r=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function At(t,e,n){let l=0,i=0;for(let r=0;;r++){let o=r<e.length?e[r]:null;if(!o||(n?o.fromA:o.fromB)>=t)return i+(t-l);[l,i]=n?[o.toA,o.toB]:[o.toB,o.toA]}}const kt=J.define({create(t){return M.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is($)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(w)!=e.startState.field(w,!1)){let n=e.state.facet(D).side=="a",l=[];for(let i of e.state.field(w))t.between(n?i.fromA:i.fromB,n?i.toA:i.toB,r=>{l.push(r)});l.length&&(t=t.update({filter:i=>l.indexOf(i)<0}))}return t},provide:t=>S.decorations.from(t)});function wt({margin:t=3,minSize:e=4}){return kt.init(n=>vt(n,t,e))}function vt(t,e,n){let l=new U,i=t.facet(D).side=="a",r=t.field(w),o=1;for(let a=0;;a++){let f=a<r.length?r[a]:null,c=a?o+e:1,s=f?t.doc.lineAt(i?f.fromA:f.fromB).number-1-e:t.doc.lines,d=s-c+1;if(d>=n&&l.add(t.doc.line(c).from,t.doc.line(s).to,M.replace({widget:new Ct(d),block:!0})),!f)break;o=t.doc.lineAt(Math.min(t.doc.length,i?f.toA:f.toB)).number}return l.finish()}const bt=S.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),Bt=new class extends Z{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Lt=Be.low($e({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(He))===null||e===void 0?void 0:e.gutter)||tt.empty},widgetMarker:(t,e)=>e instanceof Ue?Bt:null}));function Dt(t){var e;let n=typeof t.original=="string"?be.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||ut;return[Be.low(He),jt,bt,S.editorAttributes.of({class:"cm-merge-b"}),Ie.of((i,r)=>{let o=r.effects.find(a=>a.is(ne));return o&&(i=E.updateA(i,o.value.doc,r.startState.doc,o.value.changes,l)),r.docChanged&&(i=E.updateB(i,r.state.field(O),r.newDoc,r.changes,l)),i}),D.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:t.allowInlineDiffs?Tt:void 0,side:"b"}),O.init(()=>n),Lt,t.collapseUnchanged?wt(t.collapseUnchanged):[],w.init(i=>E.build(n,i.doc,l))]}const ne=Q.define(),O=J.define({create:()=>be.empty,update(t,e){for(let n of e.effects)n.is(ne)&&(t=n.value.doc);return t}}),ke=new WeakMap;class Ue extends Y{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Mt(t,e,n){let l=ke.get(e.changes);if(l)return l;let i=o=>{let{highlightChanges:a,syntaxHighlightDeletions:f,syntaxHighlightDeletionsMaxLength:c,mergeControls:s}=t.facet(D),d=document.createElement("div");if(d.className="cm-deletedChunk",s){let v=d.appendChild(document.createElement("div"));v.className="cm-chunkButtons";let B=A=>{A.preventDefault(),St(o,o.posAtDOM(d))},L=A=>{A.preventDefault(),yt(o,o.posAtDOM(d))};if(typeof s=="function")v.appendChild(s("accept",B)),v.appendChild(s("reject",L));else{let A=v.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=B;let b=v.appendChild(document.createElement("button"));b.name="reject",b.textContent=t.phrase("Reject"),b.onmousedown=L}}if(n||e.fromA>=e.toA)return d;let u=o.state.field(O).sliceString(e.fromA,e.endA),h=f&&t.facet(Ze),m=T(),p=e.changes,g=0,k=!1;function T(){let v=d.appendChild(document.createElement("div"));return v.className="cm-deletedLine",v.appendChild(document.createElement("del"))}function I(v,B,L){for(let A=v;A<B;){if(u.charAt(A)==`
|
|
2
|
+
`){m.firstChild||m.appendChild(document.createElement("br")),m=T(),A++;continue}let b=B,re=L+(k?" cm-deletedText":""),ie=!1,z=u.indexOf(`
|
|
3
|
+
`,A);if(z>-1&&z<B&&(b=z),a&&g<p.length){let G=Math.max(0,k?p[g].toA:p[g].fromA);G<=b&&(b=G,k&&g++,ie=!0)}if(b>A){let G=document.createTextNode(u.slice(A,b));if(re){let le=m.appendChild(document.createElement("span"));le.className=re,le.appendChild(G)}else m.appendChild(G);A=b}ie&&(k=!k)}}if(h&&e.toA-e.fromA<=c){let v=h.parser.parse(u),B=0;Ye(v,{style:L=>Xe(t,L)},(L,A,b)=>{L>B&&I(B,L,""),I(L,A,b),B=A}),I(B,u.length,"")}else I(0,u.length,"");return m.firstChild||m.appendChild(document.createElement("br")),d},r=M.widget({block:!0,side:-1,widget:new Ue(i)});return ke.set(e.changes,r),r}function St(t,e){let{state:n}=t,l=e??n.selection.main.head,i=t.state.field(w).find(f=>f.fromB<=l&&f.endB>=l);if(!i)return!1;let r=t.state.sliceDoc(i.fromB,Math.max(i.fromB,i.toB-1)),o=t.state.field(O);i.fromB!=i.toB&&i.toA<=o.length&&(r+=t.state.lineBreak);let a=et.of({from:i.fromA,to:Math.min(o.length,i.toA),insert:r},o.length);return t.dispatch({effects:ne.of({doc:a.apply(o),changes:a}),userEvent:"accept"}),!0}function yt(t,e){let{state:n}=t,l=e??n.selection.main.head,i=n.field(w).find(a=>a.fromB<=l&&a.endB>=l);if(!i)return!1;let o=n.field(O).sliceString(i.fromA,Math.max(i.fromA,i.toA-1));return i.fromA!=i.toA&&i.toB<=n.doc.length&&(o+=n.lineBreak),t.dispatch({changes:{from:i.fromB,to:Math.min(n.doc.length,i.toB),insert:o},userEvent:"revert"}),!0}function we(t){let e=new U;for(let n of t.field(w)){let l=t.facet(D).overrideChunk&&Ve(t,n);e.add(n.fromB,n.fromB,Mt(t,n,!!l))}return e.finish()}const jt=J.define({create:t=>we(t),update(t,e){return e.state.field(w,!1)!=e.startState.field(w,!1)?we(e.state):t},provide:t=>S.decorations.from(t)}),ve=new WeakMap;function Ve(t,e){let n=ve.get(e);if(n!==void 0)return n;n=null;let l=t.field(O),i=t.doc,r=l.lineAt(e.endA).number-l.lineAt(e.fromA).number+1,o=i.lineAt(e.endB).number-i.lineAt(e.fromB).number+1;e:if(r==o&&r<10){let a=[],f=0,c=e.fromA,s=e.fromB;for(let d of e.changes){if(d.fromA<d.toA){f+=d.toA-d.fromA;let u=l.sliceString(c+d.fromA,c+d.toA);if(/\n/.test(u))break e;a.push(M.widget({widget:new Et(u),side:-1}).range(s+d.fromB))}d.fromB<d.toB&&a.push(Pe.range(s+d.fromB,s+d.toB))}f<e.endA-e.fromA-r*2&&(n=a)}return ve.set(e,n),n}class Et extends Y{constructor(e){super(),this.text=e}eq(e){return this.text==e.text}toDOM(e){let n=document.createElement("del");return n.className="cm-deletedText",n.textContent=this.text,n}}const Nt=new class extends Z{constructor(){super(...arguments),this.elementClass="cm-inlineChangedLineGutter"}},Ot=M.line({class:"cm-inlineChangedLine"});function Tt(t,e,n,l){let i=Ve(t,e),r=0;if(!i)return!1;for(let o=t.doc.lineAt(e.fromB);;){for(l&&l.add(o.from,o.from,Nt),n.add(o.from,o.from,Ot);r<i.length&&i[r].to<=o.to;){let a=i[r++];n.add(a.from,a.to,a.value)}if(o.to>=e.endB)break;o=t.doc.lineAt(o.to+1)}return!0}const Gt=S.theme({"&":{backgroundColor:"var(--background)",color:"var(--foreground)",fontSize:"12px",border:"1px solid var(--border)",borderRadius:"0.5rem",overflow:"hidden",width:"100%"},"& .cm-scroller":{overflow:"auto",maxHeight:"20rem",fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace'},".cm-content":{padding:"6px 0"},".cm-gutters":{backgroundColor:"var(--muted)",color:"var(--muted-foreground)",border:"none",borderRight:"1px solid var(--border)"},".cm-changedLine":{backgroundColor:"color-mix(in oklch, var(--chart-2) 14%, transparent)"},".cm-changedText":{background:"color-mix(in oklch, var(--chart-2) 32%, transparent)"},".cm-deletedChunk":{backgroundColor:"color-mix(in oklch, var(--destructive) 10%, transparent)"},".cm-deletedText":{background:"color-mix(in oklch, var(--destructive) 28%, transparent)"},".cm-collapsedLines":{background:"var(--muted)",color:"var(--muted-foreground)",padding:"2px 8px"}});function V(t){if(Array.isArray(t))return t.map(V);if(t&&typeof t=="object"){const e={};for(const n of Object.keys(t).sort())e[n]=V(t[n]);return e}return t}function Rt({before:t,after:e}){const n=P.useRef(null);return P.useEffect(()=>{if(!n.current)return;const l=new S({state:oe.create({doc:e,extensions:[oe.readOnly.of(!0),S.editable.of(!1),S.lineWrapping,nt(it,{fallback:!0}),rt(),Dt({original:t,mergeControls:!1,gutter:!0,collapseUnchanged:{margin:3,minSize:4}}),Gt]}),parent:n.current});return()=>l.destroy()},[t,e]),x.jsx("div",{ref:n,className:"w-full"})}function Ht({before:t,after:e}){const[n,l]=P.useState(!1),i=P.useId();if(!t&&!e)return null;const r=!!(t&&e);return x.jsxs("div",{className:"mt-2",children:[x.jsxs("button",{type:"button",onClick:()=>l(o=>!o),"aria-expanded":n,"aria-controls":n?i:void 0,className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[n?x.jsx(ze,{className:"h-3 w-3"}):x.jsx(_e,{className:"h-3 w-3"}),r?n?"Hide diff":"Show diff":n?"Hide details":"Show details"]}),n&&(r?x.jsx("div",{id:i,className:"mt-2",children:x.jsx(Rt,{before:JSON.stringify(V(t),null,2),after:JSON.stringify(V(e),null,2)})}):x.jsxs("div",{id:i,className:"mt-2",children:[x.jsx("p",{className:"mb-1 text-[10px] font-medium uppercase text-muted-foreground",children:e?"After":"Before"}),x.jsx("pre",{className:qe(Ke,"max-h-48 overflow-auto p-2 text-xs"),children:JSON.stringify(e??t,null,2)})]}))]})}export{Wt as C,Ht as J};
|
|
4
|
+
//# sourceMappingURL=json-diff-LE_vNZrM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as s,S as e}from"./index-
|
|
2
|
-
//# sourceMappingURL=list-skeleton-
|
|
1
|
+
import{j as s,S as e}from"./index-008wj-Pz.js";function m({label:r,actions:l=!1}){return s.jsx("div",{className:"overflow-hidden rounded-lg border",role:"status","aria-label":r,children:Array.from({length:4},(d,a)=>s.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 ${a===3?"":"border-b"}`,children:[s.jsx(e,{className:"h-7 w-7 shrink-0 rounded-md"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsx(e,{className:"h-4 w-40"}),s.jsx(e,{className:"h-3 w-24"})]}),l?s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(e,{className:"h-8 w-8 rounded-md"}),s.jsx(e,{className:"h-8 w-8 rounded-md"})]}):null]},a))})}export{m as L};
|
|
2
|
+
//# sourceMappingURL=list-skeleton-Kzxi2OXB.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{v as ke,a2 as Ne,o as Se,a3 as Ce,E as Ee,r as s,a4 as ae,j as e,a5 as b,a6 as Le,a7 as ce,a8 as $,a9 as Fe,aa as Ue,ab as Pe,$ as Me,Q as Ie,a0 as ze,ac as oe}from"./index-008wj-Pz.js";import{C as Ae,c as Re}from"./card-BCsbrdGs.js";function q(o){if(!o||typeof o!="object")return null;const f=o.error;if(typeof f=="string")return f;if(f&&typeof f=="object"){const y=f.message;if(typeof y=="string"&&y.length>0)return y}const m=o.message;return typeof m=="string"&&m.length>0?m:null}async function le(o,f){if(typeof window>"u")return;const m=window.PasswordCredential;if(!(!m||!navigator.credentials?.store))try{const y=new m({id:o,password:f});await navigator.credentials.store(y)}catch{}}function $e({domain:o}){const[f,m]=s.useState(!1);return!(o.length>0&&o.length<=253&&/^[A-Za-z0-9.-]+$/.test(o))||f?e.jsx(ce,{className:"w-4 h-4"}):e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(o)}&sz=32`,alt:"",width:16,height:16,className:"h-4 w-4",onError:()=>m(!0)})}function E(o){return o?o.toLowerCase().replaceAll("_"," ").trim().includes("account not linked")?"This social account matches an existing Lobu user. Sign in with a magic link to verify ownership, then continue.":o:null}function Oe(){const o=ke(),f=Ne(),{session:m,isReady:y}=Se(),{data:i,isLoading:F,error:B}=Ce(),l=Ee({from:"/auth/login"}),O=l.invitationOrg,[p,j]=s.useState("social"),[d,P]=s.useState(l.intent??"sign-in"),[T,de]=s.useState(""),[a,W]=s.useState(()=>l.loginHint??""),[k,ue]=s.useState(""),[N,me]=s.useState(""),[M,V]=s.useState(""),[ge,Q]=s.useState(!1),[c,u]=s.useState(null),[I,r]=s.useState(null),[J,G]=s.useState(!1),[fe,K]=s.useState(!1),[Z,pe]=s.useState(!1),X=s.useRef(!1),L=l.callbackUrl,Y=l.mode==="extension",D=l.error==="account_not_linked",ee=E(l.errorDescription||l.error),z=Object.values(i?.social??{}).some(Boolean),w=!!i?.magicLink,A=!!i?.phone,h=!!i?.emailPassword,te=!!i?.passkey,x=!!i?.singleUserMode,ne=!!i?.hasUser,H=x,U=p==="magic-link"&&w&&J,v=s.useMemo(()=>{const t=[];return h&&t.push("email-password"),z&&t.push("social"),w&&t.push("magic-link"),A&&t.push("whatsapp"),t},[h,w,z,A]),he=s.useMemo(()=>h?v.filter(t=>t!=="magic-link"&&t!=="social"):v,[v,h]),_=B instanceof Error?B.message:B?"Unable to load sign-in options.":null;s.useEffect(()=>{if(m){const t=ae(L);L?window.location.href=t:o({to:"/"})}},[m,o,L]),s.useEffect(()=>{!i||v.length===0||v.includes(p)||j(v[0])},[i,p,v]),s.useEffect(()=>{!w||!D||(j("magic-link"),l.loginHint&&!a&&W(l.loginHint))},[w,D,l.loginHint,a]),s.useEffect(()=>{l.intent&&P(l.intent)},[l.intent]),s.useEffect(()=>{if(!x||!i)return;const t=ne?"sign-in":"sign-up";d!==t&&P(t)},[x,ne,i,d]);const S=()=>L?ae(L):"/",se=async(t,{quiet:n=!1}={})=>{u(t),r(null);try{const g=await $.social({provider:t,callbackURL:S(),newUserCallbackURL:L?S():`/?onboard_provider=${encodeURIComponent(t)}`}),C=q(g);if(C&&!n){const R=E(C);R?.toLowerCase().includes("magic link")&&j("magic-link"),r(R)}}catch(g){if(n)return;r(E(g instanceof Error?g.message:`Failed to sign in with ${t}`))}finally{u(null)}};s.useEffect(()=>{if(X.current||!y||m||F||!i||l.error)return;const t=l.provider;if(!t)return;X.current=!0;const n=Object.hasOwn(i.social??{},t)&&!!i.social?.[t];se(t,{quiet:!n})},[i,F,m,y,l.provider,l.error]);const re=async()=>{if(a){u("magic-link"),r(null);try{return await $.magicLink({email:a,callbackURL:S()}),G(!0),!0}catch(t){return r(t instanceof Error?t.message:"Failed to send magic link"),!1}finally{u(null)}}},xe=async t=>{t.preventDefault(),await re()},be=async t=>{if(t.preventDefault(),!(!a||!k)){u("email-password"),r(null);try{if(d==="sign-up"){const n=await Ue.email({email:a,password:k,name:T||a.split("@")[0]||"User",callbackURL:S()}),g=q(n);if(g){r(E(g));return}if(await le(a,k),await f.invalidateQueries({queryKey:["organizations"]}),x&&te)try{await Pe.passkey.addPasskey({name:T||`${navigator.platform||"This device"}`})}catch{}}else{const n=await $.email({email:a,password:k,callbackURL:S()}),g=q(n);if(g){r(E(g));return}if(!n?.data){r("Invalid email or password");return}await le(a,k)}}catch(n){const g=n instanceof Error?n.message:typeof n=="string"?n:q(n);r(g||"Authentication failed")}finally{u(null)}}},ie=async()=>{r(null),pe(!0),u("local");try{const t=await Fe();if(!t.ok){const n=await t.json().catch(()=>null);r(n?.error_description??"Could not sign in to your local install.");return}window.location.href=S()}catch(t){r(t instanceof Error?t.message:"Could not sign in to your local install.")}finally{u(null)}};s.useEffect(()=>{H&&i&&!m&&!Z&&ie()},[H,i,m,Z]);const ye=async()=>{if(!a){r("Enter your email address first to reset your password.");return}u("reset-password-request"),r(null);try{const t=`${window.location.origin}/auth/reset-password`,n=await Me(`${Ie}/api/auth/request-password-reset`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:a,redirectTo:t})});if(!n.ok)throw await ze(n);K(!0)}catch(t){r(t instanceof Error?t.message:"Failed to send password reset email")}finally{u(null)}},je=async t=>{if(t.preventDefault(),!!N){u("phone"),r(null);try{await oe.sendOtp({phoneNumber:N}),Q(!0)}catch(n){r(n instanceof Error?n.message:"Failed to send verification code")}finally{u(null)}}},we=async t=>{if(t.preventDefault(),!(!N||!M)){u("verify"),r(null);try{await oe.verify({phoneNumber:N,code:M})}catch(n){r(n instanceof Error?n.message:"Invalid verification code"),u(null)}}};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsx("h1",{className:"text-2xl font-bold",children:O?`Sign in to join ${O}`:x&&d==="sign-up"?"Set up your local install":x?"Welcome back":d==="sign-up"?"Create your account":"Sign in"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:O?"Sign in with the email your invitation was sent to.":x&&d==="sign-up"?"This account stays on this machine. Email is just an identifier — pick anything you’ll remember.":x?"Sign in to your local install.":Y?"Sign in to connect the browser extension":d==="sign-up"?"Choose a sign-up method":"Choose your preferred sign-in method"}),x&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-muted text-muted-foreground rounded-full text-xs",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Local install · nothing sent to lobu.ai"]}),Y&&e.jsxs("div",{className:"mt-3 inline-flex items-center gap-2 px-3 py-1.5 bg-primary/10 text-primary rounded-full text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),"Browser Extension"]})]}),e.jsx(Ae,{children:e.jsx(Re,{children:H?e.jsx("div",{className:"space-y-4",children:I?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:I}),e.jsx("button",{type:"button",disabled:c!==null,onClick:ie,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:"Try again"})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Signing you into your local install…"})]})}):e.jsxs(e.Fragment,{children:[F&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(b,{size:"lg"}),e.jsx("span",{children:"Loading sign-in options…"})]}),!F&&_&&e.jsxs("div",{className:"text-sm text-destructive",children:["Failed to load sign-in options. ",_]}),!F&&!_&&v.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"No sign-in methods are configured. Contact support for access."}),h&&!U&&e.jsxs("div",{className:"mb-4 flex rounded-lg border p-1",children:[e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-in"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-in"),children:"Sign In"}),e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${d==="sign-up"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>P("sign-up"),children:"Sign Up"})]}),!U&&he.length>1&&e.jsxs("div",{className:"mb-6 flex rounded-lg border p-1",children:[h&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="email-password"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("email-password"),children:"Email + Password"}),z&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="social"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("social"),children:"Social"}),!h&&w&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="magic-link"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("magic-link"),children:"Magic Link"}),A&&e.jsx("button",{type:"button",className:`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors ${p==="whatsapp"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>j("whatsapp"),children:"WhatsApp"})]}),D&&e.jsx("div",{className:"mb-4 rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900",children:"We found an existing account for this identity. To protect the account, verify with a magic link before linking social sign-in."}),ee&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:ee}),I&&e.jsx("div",{className:"mb-4 p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:I}),!U&&(h||p==="social")&&z&&e.jsxs("div",{className:"space-y-3",children:[Object.entries(i?.social??{}).filter(([,t])=>t).map(([t])=>{const n=Le.find(ve=>ve.provider===t),g=n?.icon,C=i?.socialMeta?.[t],R=n?.name??C?.name??t.charAt(0).toUpperCase()+t.slice(1);return e.jsxs("button",{type:"button",onClick:()=>se(t),disabled:c!==null,className:"w-full flex items-center justify-center gap-3 h-10 px-4 border border-input rounded-lg bg-background hover:bg-accent hover:text-accent-foreground transition-colors disabled:opacity-50",children:[c===t?e.jsx(b,{size:"lg"}):g?e.jsx(g,{className:"w-4 h-4"}):C?.faviconDomain?e.jsx($e,{domain:C.faviconDomain},C.faviconDomain):e.jsx(ce,{className:"w-4 h-4"}),"Continue with ",R]},t)}),h&&e.jsxs("div",{className:"relative my-2",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]})]}),!U&&h&&e.jsxs("form",{onSubmit:be,className:"space-y-4",children:[d==="sign-up"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"full-name",className:"block text-sm font-medium",children:"Full name"}),e.jsx("input",{id:"full-name",type:"text",value:T,onChange:t=>de(t.target.value),placeholder:"Jane Doe",className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email-password-email",type:"email",value:a,onChange:t=>{W(t.target.value),K(!1)},placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email-password-password",className:"block text-sm font-medium",children:"Password"}),e.jsx("input",{id:"email-password-password",type:"password",value:k,onChange:t=>ue(t.target.value),placeholder:"Enter a password",required:!0,minLength:8,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!a||!k,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="email-password"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:d==="sign-up"?"Creating account...":"Signing in..."})]}):d==="sign-up"?x?"Create local account":"Create Account":"Sign In"}),d==="sign-in"&&te&&e.jsx("button",{type:"button",disabled:c!==null,onClick:async()=>{r(null),u("passkey");try{const t=await $.passkey();if(t?.error){const n=t.error.message??"Passkey sign-in failed.";r(E(n)??n);return}window.location.href=S()}catch(t){const n=t instanceof Error?t.message:String(t);r(E(n)??n)}finally{u(null)}},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="passkey"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Waiting for passkey…"})]}):"Sign in with passkey"}),d==="sign-in"&&w&&e.jsx("button",{type:"button",disabled:c!==null||!a,onClick:async()=>{await re()&&j("magic-link")},className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending magic link..."})]}):"Send me a magic link instead"}),d==="sign-in"&&e.jsx("button",{type:"button",disabled:c!==null||!a,onClick:ye,className:"flex h-10 w-full items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50",children:c==="reset-password-request"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending reset email..."})]}):"Forgot password?"}),d==="sign-in"&&fe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"If this email exists, we sent a password reset link."})]}),p==="magic-link"&&w&&(J?e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsx("svg",{className:"h-12 w-12 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),e.jsx("h2",{className:"text-lg font-medium",children:"Check your email"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["We sent a magic link to ",e.jsx("strong",{children:a}),".",e.jsx("br",{}),"Click the link in the email to sign in."]}),e.jsx("button",{type:"button",className:"mt-4 text-sm text-primary hover:underline",onClick:()=>G(!1),children:"Use a different email"})]}):e.jsxs("form",{onSubmit:xe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium",children:"Email address"}),e.jsx("input",{id:"email",type:"email",value:a,onChange:t=>W(t.target.value),placeholder:"you@example.com",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!a,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="magic-link"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Magic Link"})]})),!U&&p==="whatsapp"&&A&&(ge?e.jsxs("form",{onSubmit:we,className:"space-y-4",children:[e.jsxs("div",{className:"text-center text-sm text-muted-foreground",children:["Enter the 6-digit code sent to ",e.jsx("strong",{children:N})]}),e.jsx("div",{children:e.jsx("input",{type:"text",value:M,onChange:t=>V(t.target.value),placeholder:"000000",maxLength:6,pattern:"[0-9]{6}",required:!0,className:"block h-12 w-full rounded-md border border-input bg-background px-3 py-2 text-center text-xl tracking-widest placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})}),e.jsx("button",{type:"submit",disabled:c!==null||M.length!==6,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="verify"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Verifying..."})]}):"Verify & Sign In"}),e.jsx("button",{type:"button",className:"w-full text-sm text-primary hover:underline",onClick:()=>{Q(!1),V("")},children:"Use a different number"})]}):e.jsxs("form",{onSubmit:je,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium",children:"WhatsApp Number"}),e.jsx("input",{id:"phone",type:"tel",value:N,onChange:t=>me(t.target.value),placeholder:"+1234567890",required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Include country code (e.g., +1 for US)"})]}),e.jsx("button",{type:"submit",disabled:c!==null||!N,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:c==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(b,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Sending..."})]}):"Send Code via WhatsApp"})]}))]})})})]})})}export{Oe as component};
|
|
2
|
+
//# sourceMappingURL=login-DWOT6jtS.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as n,a1 as o,j as e}from"./index-008wj-Pz.js";function s(){return n.useEffect(()=>{o().catch(t=>console.error("Sign out failed:",t)).finally(()=>{window.location.href="/"})},[]),e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Signing out..."})})}export{s as component};
|
|
2
|
+
//# sourceMappingURL=logout-Dt_VDilG.js.map
|
package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-De75CR7W.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,S as o,
|
|
2
|
-
//# sourceMappingURL=member-scope-gate-
|
|
1
|
+
import{j as e,S as o,o as c,ap as d,w as u,a$ as h,dE as b,B as p,L as x,y as g}from"./index-008wj-Pz.js";function j({rows:t=5}){return e.jsx("div",{className:"space-y-2",role:"status","aria-label":"Loading members",children:Array.from({length:t}).map((a,s)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2",children:[e.jsx(o,{className:"h-8 w-8 shrink-0 rounded-full"}),e.jsx(o,{className:"h-4 w-40"})]},s))})}function l({title:t,body:a,ctaLabel:s,showCta:n,callbackUrl:r}){return e.jsx(h,{icon:b,title:t,description:a,children:s&&n?e.jsx(p,{asChild:!0,className:"mt-4",children:e.jsx(x,{to:"/auth/login",search:g({callbackUrl:r,intent:"sign-in"}),children:s})}):null})}function y({children:t}){const{isAuthenticated:a,isReady:s}=c(),{isMember:n,isLoading:r}=d(),i=u({select:m=>m.href});return!s||r?e.jsx(j,{}):a?n?e.jsx(e.Fragment,{children:t}):e.jsx(l,{title:"Join to see members",body:"Emails and member details are only visible to members of this workspace. Use the banner above to join.",callbackUrl:i}):e.jsx(l,{title:"Sign in to see members",body:"The members of this workspace are only visible to people who have signed in.",ctaLabel:"Sign in",showCta:!0,callbackUrl:i})}export{y as M};
|
|
2
|
+
//# sourceMappingURL=member-scope-gate-De75CR7W.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import{r as b,j as t,B as Y,d9 as mt,f5 as Os,f6 as $s,bU as As,h as de,d8 as Rt,S as ve,f7 as Ps,f8 as Ds,t as De,f9 as en,fa as Fs,fb as zs,fc as Ws,H as Pe,bv as Ft,bw as zt,bx as Wt,by as Bt,bz as yt,fd as Bs,I as rt,fe as Hs,bG as qn,ff as Gn,fg as Kn,fh as Vs,k as It,ei as Us,fi as qs,v as at,u as tn,et as Yn,aD as Gs,aE as Ks,cn as Ys,fj as Js,ax as Qs,fk as Jn,b1 as Xs,b5 as Zs,bS as Qn,W as er,L as we,X as tr,em as Xn,bW as nr,bX as sr,fl as rr,fm as ar,fn as or,b_ as ir,bP as Zn,fo as es,fp as tt,fq as jt,fr as cr,fs as lr,ft as nn,fu as dr,fv as Kt,fw as Yt,fx as ur,fy as mr,co as ts,cT as Nt,dL as fr,dd as hr,dI as sn,dK as rn,fz as ns,dJ as an,bE as pr,f1 as gr,dR as ss,a$ as rs,fA as as,eG as os,fB as qe,eT as yr,cV as nt,V as ht,eH as xr,dW as br,fC as vr,dk as wr,d0 as kr,cL as is,dM as jr,dN as Nr,dO as Sr,dP as Er,cX as vn,fD as Cr,fE as _r,cY as Mr,dF as Tr,fF as cs,fG as ls,am as Lr,fH as Rr,E as ds,fI as Ir,c7 as Ue,i as us,fJ as Ht,fK as Or,fL as $r,d3 as wn,fM as Ar,fN as Pr,bg as Dr,fO as Fr,fP as zr,bt as Wr,fQ as Br,a as Hr,fR as Vr,av as Ur}from"./index-008wj-Pz.js";import{P as qr}from"./public-shell-ready-DXUTTGGp.js";import{f as Gr,a as Kr,c as kn,d as Yr,A as Jr}from"./connector-boxes-DqZA-FdG.js";import{u as Qr}from"./use-automations-C4TSie1i.js";import{c as Xr}from"./connections-browser-BMV8bf54.js";import{d as Zr,e as ea}from"./model-udnQ_S43.js";import{c as ta}from"./connection-label-BobuYiAG.js";import{f as na}from"./feed-event-kinds-BYuZCoU4.js";import{S as sa}from"./schema-type-editor-panel-C_Es0qDf.js";import{D as ra,c as aa,l as oa,p as Ee,S as jn,n as ia,e as Ot,a as ca,g as la,f as Nn,b as da,d as ua,J as ma}from"./renderer-AJxSmE3-.js";import{S as fa,E as on}from"./entity-avatar-CEV4ttUQ.js";import{F as ha}from"./filter-bar-COU0sBFQ.js";import{T as pa,a as ga,b as Vt,c as Sn,d as ya,e as Ut}from"./table-DHM-vCxP.js";import{u as xa,a as ba,D as va,P as wa,b as ms,c as ka,C as ja}from"./core.esm-A1UnFbGs.js";import{v as Na,V as fs,M as hs,a as ps,w as Sa,b as Ea}from"./view-param-filters-DkX4YdDT.js";import{E as Ca}from"./entity-type-page-Lf6ONdpf.js";import{M as _a}from"./member-scope-gate-De75CR7W.js";function En(e){let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)n=Math.min(n,i.x-i.w/2),a=Math.max(a,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(n)?{x0:n,y0:s,x1:a,y1:r}:null}const St=(e,n,s)=>e<n?n:e>s?s:e;function Ma(e,n,s,{padding:a=.12,minZoom:r=.2,maxZoom:i=1.2}={}){const o=Math.max(1,e.x1-e.x0),l=Math.max(1,e.y1-e.y0),y=St(Math.min(n/(o*(1+a)),s/(l*(1+a))),r,i);return{z:y,x:n/2-(e.x0+e.x1)/2*y,y:s/2-(e.y0+e.y1)/2*y}}function Ta(e,n,s=0){if(e===n){const v=e.x+e.w/2,j=e.y-e.h/2;return[{x:v-30,y:j},{x:v-30,y:j-26},{x:v+22,y:j-26},{x:v+22,y:e.y-6},{x:v,y:e.y-6}]}const a=s*8,r=e.x+e.w/2,i=e.y+St(a,-e.h/2+6,e.h/2-6),o=n.x-n.w/2,l=n.y+St(a,-n.h/2+6,n.h/2-6);if(o-r>=40){const v=(r+o)/2+a;return[{x:r,y:i},{x:v,y:i},{x:v,y:l},{x:o,y:l}]}const y=Math.max(e.y+e.h/2,n.y+n.h/2)+24+Math.abs(a),c=Math.min(e.y-e.h/2,n.y-n.h/2)-24-Math.abs(a),x=(i+l)/2,m=Math.abs(y-x)<=Math.abs(c-x)?y:c,h=r+24+Math.abs(a),p=o-24-Math.abs(a);return[{x:r,y:i},{x:h,y:i},{x:h,y:m},{x:p,y:m},{x:p,y:l},{x:o,y:l}]}function La(e,n,s){const a=s.x-n.x,r=s.y-n.y,i=a*a+r*r,o=i?St(((e.x-n.x)*a+(e.y-n.y)*r)/i,0,1):0;return Math.hypot(e.x-(n.x+o*a),e.y-(n.y+o*r))}function Ra(e,n){let s=Number.POSITIVE_INFINITY;for(let a=0;a<n.length-1;a++)s=Math.min(s,La(e,n[a],n[a+1]));return s}function Ia(e,n){return Math.abs(n.x-e.x)<=e.w/2&&Math.abs(n.y-e.y)<=e.h/2}class et{cells=new Set;static CELL_W=12;static CELL_H=16;keys(n){const s=[],a=Math.floor(n.x0/et.CELL_W),r=Math.floor(n.x1/et.CELL_W),i=Math.floor(n.y0/et.CELL_H),o=Math.floor(n.y1/et.CELL_H);for(let l=a;l<=r;l++)for(let y=i;y<=o;y++)s.push(l*1e5+y);return s}isFree(n){return this.keys(n).every(s=>!this.cells.has(s))}reserve(n){for(const s of this.keys(n))this.cells.add(s)}}function Oa(e,n,s,a,r){const i=e.slice(0,-1).map((m,h)=>({i:h,length:Math.hypot(e[h+1].x-m.x,e[h+1].y-m.y)})).sort((m,h)=>h.length-m.length);if(i.length===0)return null;const o=m=>({x0:m.x-n/2,x1:m.x+n/2,y0:m.y-s/2,y1:m.y+s/2}),l=m=>({x:(e[m].x+e[m+1].x)/2,y:(e[m].y+e[m+1].y)/2});for(const{i:m,length:h}of i){if(!r&&h<n*.7)break;const p=l(m);if(a.isFree(o(p)))return a.reserve(o(p)),p}if(!r)return null;const y=l(i[0].i),x=[-1,1,-1.6,1.6].map(m=>({x:y.x,y:y.y+m*(s+12)})).find(m=>a.isFree(o(m)))??y;return a.reserve(o(x)),x}const $a=e=>t.jsx(Rt,{icon:e||null,className:"h-4 w-4"}),Aa='600 14px "DM Sans", system-ui, sans-serif',Pa='400 11px "DM Sans", system-ui, sans-serif',Da='500 9px "DM Sans", system-ui, sans-serif',Fa='500 11px "DM Sans", system-ui, sans-serif',dt=18,Cn=8;function _n(e){const n=getComputedStyle(e),s=(a,r)=>n.getPropertyValue(a).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 xt(e,n,s){if(e.measureText(n).width<=s)return n;let a=0,r=n.length;for(;a<r;){const i=Math.ceil((a+r)/2);e.measureText(`${n.slice(0,i)}…`).width<=s?a=i:r=i-1}return`${n.slice(0,a)}…`}function za(e,n,s,a){const r=Math.hypot(s.x-n.x,s.y-n.y);if(r<1)return;const i=(s.x-n.x)/r,o=(s.y-n.y)/r;e.moveTo(s.x-i*a-o*a*.55,s.y-o*a+i*a*.55),e.lineTo(s.x,s.y),e.lineTo(s.x-i*a+o*a*.55,s.y-o*a-i*a*.55)}function gs({boxes:e,edges:n,label:s,onOpenBox:a,openLabel:r,onConnect:i,renderIcon:o=$a,className:l}){const y=b.useRef(null),c=b.useRef(null),x=b.useRef(null),m=b.useRef({z:1,x:0,y:0}),h=b.useRef({w:0,h:0,dpr:1}),p=b.useRef(!0),v=b.useRef(new Map),j=b.useRef(null),d=b.useRef(null),S=b.useRef(new Map),N=b.useRef(null),C=b.useRef(""),k=b.useRef(!1),[g,w]=b.useState(()=>new Map),[M,A]=b.useState(null),[P,D]=b.useState(null),[J,q]=b.useState(null),[se,V]=b.useState(null),[ne,he]=b.useState(0),{placed:O,movedIds:I}=b.useMemo(()=>{const _=new Map,u=new Set;for(const f of e){const E=g.get(f.id);E&&E.from.x===f.x&&E.from.y===f.y?(_.set(f.id,{...f,x:E.at.x,y:E.at.y}),u.add(f.id)):_.set(f.id,f)}return{placed:_,movedIds:u}},[e,g]),U=b.useMemo(()=>{const _=new Map;for(const f of n){const E=[f.source,f.target].sort().join("|");_.set(E,[..._.get(E)??[],f])}const u=new Map;for(const f of n){const E=O.get(f.source),T=O.get(f.target);if(!E||!T)continue;if(f.route&&!I.has(E.id)&&!I.has(T.id)){u.set(f.id,f.route);continue}const L=_.get([f.source,f.target].sort().join("|"))??[f];u.set(f.id,Ta(E,T,L.indexOf(f)-(L.length-1)/2))}return u},[n,O,I]),H=b.useCallback(()=>{p.current=!0},[]),W=b.useCallback(()=>{const _=En([...O.values()]),{w:u,h:f}=h.current;!_||!u||!f||(m.current=Ma(_,u,f),k.current=!0,H())},[O,H]),Q=_=>{m.current=_,k.current=!1,H()},re=_=>{const u=En(_),{w:f,h:E}=h.current;if(!u||!f||!E)return;const T=m.current,L=24;u.x0*T.z+T.x>=L&&u.y0*T.z+T.y>=L&&u.x1*T.z+T.x<=f-L&&u.y1*T.z+T.y<=E-L||Q({...T,x:f/2-(u.x0+u.x1)/2*T.z,y:E/2-(u.y0+u.y1)/2*T.z})},pe=_=>{V(_);const u=O.get(_);u&&re([u])},ue=e.map(_=>`${_.id}@${Math.round(_.x)},${Math.round(_.y)}`).join(";");b.useEffect(()=>{!ue||C.current===ue||h.current.w&&(C.current=ue,W())},[ue,W]);const Ce=b.useRef(W);Ce.current=W;const Fe=b.useRef(ue);Fe.current=ue,b.useEffect(()=>{const _=y.current,u=c.current;if(!_||!u||typeof ResizeObserver>"u")return;const f=()=>{const T=window.devicePixelRatio||1,L=_.clientWidth,z=_.clientHeight;h.current={w:L,h:z,dpr:T},u.width=Math.round(L*T),u.height=Math.round(z*T);const G=Fe.current;G&&L&&z&&(C.current!==G||k.current)&&(C.current=G,Ce.current()),H()};f();const E=new ResizeObserver(f);return E.observe(_),()=>E.disconnect()},[H]);const[Ne,Ge]=b.useState(0);b.useEffect(()=>{const _=x.current,u=c.current;if(!_||!u)return;const f=_n(u).muted;for(const E of _.querySelectorAll("[data-icon-key]")){const T=E.dataset.iconKey??"";if(v.current.has(T))continue;const L=E.querySelector("svg"),z=L?null:E.querySelector("img")?.src;if(!L&&!z){v.current.set(T,E.textContent??"");continue}const G=new Image;if(G.onload=H,G.onerror=()=>{v.current.delete(T),Ge(B=>B+1)},L){const B=L.cloneNode(!0);B.getAttribute("width")||B.setAttribute("width","24"),B.getAttribute("height")||B.setAttribute("height","24");const F=new XMLSerializer().serializeToString(B).replaceAll("currentColor",f);G.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(F)}`}else z&&(G.src=z);v.current.set(T,G)}},[e,ne,Ne,H]);const _e=(_,u)=>{const f=m.current;return{x:(_-f.x)/f.z,y:(u-f.y)/f.z}},ze=(_,u)=>{const f=m.current,E=_e(_,u),T=M&&M.kind!=="edge"?O.get(M.box.id):void 0;if(T&&i){const B=Mn(T);if(Math.hypot(B.x*f.z+f.x-_,B.y*f.z+f.y-u)<=Cn+3)return{kind:"handle",box:T}}const L=[...O.values()];for(let B=L.length-1;B>=0;B--)if(Ia(L[B],E))return{kind:"box",box:L[B]};let z=null,G=7/f.z;for(const B of n){const F=U.get(B.id);if(!F)continue;const me=Ra(E,F);me<G&&(G=me,z=B)}return z?{kind:"edge",edge:z}:null},ye=b.useMemo(()=>{const _=new Set;for(const f of[P,J])f&&_.add(f);M?.kind==="edge"&&_.add(M.edge.id);const u=M&&M.kind!=="edge"?M.box.id:se;if(u)for(const f of n)(f.source===u||f.target===u)&&_.add(f.id);for(const f of n)f.dimmed&&_.delete(f.id);return _},[n,M,P,J,se]);b.useEffect(H,[O,U,ye,M,se,H]);const Le=b.useCallback(()=>{const _=c.current,u=_?.getContext("2d");if(!_||!u)return;const{w:f,h:E,dpr:T}=h.current,L=_n(_),z=getComputedStyle(_),G=new Map,B=$=>{let Z=G.get($);return Z===void 0&&(Z=z.getPropertyValue($).trim(),G.set($,Z)),Z},{z:F,x:me,y:le}=m.current,Se=$=>({x:$.x*F+me,y:$.y*F+le});u.setTransform(T,0,0,T,0,0),u.clearRect(0,0,f,E);const Oe=M&&M.kind!=="edge"?M.box.id:null;u.lineJoin="round";for(const $ of n){const Z=U.get($.id);if(!Z)continue;const te=Z.map(Se),K=ye.has($.id);u.globalAlpha=$.dimmed?.15:K?.95:.55,u.strokeStyle=K?L.foreground:L.muted,u.lineWidth=K?1.75:1.25,u.beginPath(),u.moveTo(te[0].x,te[0].y);for(const ae of te.slice(1))u.lineTo(ae.x,ae.y);$.directed&&za(u,te[te.length-2],te[te.length-1],8),u.stroke()}const Ke=new et;for(const $ of O.values()){const Z=Se($),te=$.w*F,K=$.h*F,ae=Z.x-te/2,X=Z.y-K/2;if(Ke.reserve({x0:ae,y0:X,x1:ae+te,y1:X+K}),ae>f||X>E||ae+te<0||X+K<0)continue;const Ae=Oe===$.id||N.current?.over?.id===$.id;u.globalAlpha=$.dimmed?.25:1,u.beginPath(),u.roundRect(ae,X,te,K,8*F),u.fillStyle=$.muted?L.mutedSurface:L.card,u.fill(),u.lineWidth=Ae||se===$.id?1.5:1,u.strokeStyle=Ae||se===$.id?L.primary:L.border,u.stroke();const ie=$.accent&&B($.accent);if(ie&&(u.save(),u.clip(),u.fillStyle=ie,u.fillRect(ae,X,3*F,K),u.restore()),14*F<5)continue;const ge=12*F,oe=16*F,fe=$.meta?X+K/2-8*F:X+K/2,Me=v.current.get($.icon??"");Me instanceof HTMLImageElement&&Me.complete&&Me.naturalWidth>0?u.drawImage(Me,ae+ge,fe-oe/2,oe,oe):typeof Me=="string"&&Me&&(u.font=`${14*F}px system-ui, sans-serif`,u.textBaseline="middle",u.textAlign="left",u.fillText(Me,ae+ge,fe));const He=ae+ge+oe+8*F,it=12*F;u.textBaseline="middle",u.textAlign="left";let Qe=ae+te-it-He;if($.badge){u.font=Da.replace("9px",`${9*F}px`);const ct=xt(u,$.badge.toUpperCase(),Qe*.35),Xe=u.measureText(ct).width+8*F,lt=ae+te-it-Xe;u.strokeStyle=L.border,u.lineWidth=1,u.beginPath(),u.roundRect(lt,fe-7*F,Xe,14*F,3*F),u.stroke(),u.fillStyle=L.muted,u.fillText(ct,lt+4*F,fe+.5),Qe-=Xe+6*F}u.font=Aa.replace("14px",`${14*F}px`),u.fillStyle=L.foreground,u.fillText(xt(u,$.title,Qe),He,fe+.5),$.meta&&(u.font=Pa.replace("11px",`${11*F}px`),u.fillStyle=L.muted,u.fillText(xt(u,$.meta,ae+te-ge-He),He,X+K/2+10*F))}const $e=N.current,Ye=$e?.from??(Oe?O.get(Oe):void 0);if(i&&Ye&&Ye.w*F>=60){const $=Se(Mn(Ye));if(u.globalAlpha=1,$e){const Z=Se($e.to);u.strokeStyle=L.primary,u.lineWidth=2,u.setLineDash([6,4]),u.beginPath(),u.moveTo($.x,$.y),u.lineTo(Z.x,Z.y),u.stroke(),u.setLineDash([])}u.fillStyle=L.card,u.strokeStyle=L.primary,u.lineWidth=1.5,u.beginPath(),u.arc($.x,$.y,Cn,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=Fa,u.textAlign="center",u.textBaseline="middle";const Je=($,Z,te,K)=>{u.globalAlpha=1,u.fillStyle=L.background,u.strokeStyle=te?L.foreground:L.border,u.lineWidth=1,u.beginPath(),u.roundRect($.x-K/2,$.y-dt/2,K,dt,5),u.fill(),u.stroke(),u.fillStyle=te?L.foreground:L.muted,u.fillText(Z,$.x,$.y+.5)},$t=[...n].sort(($,Z)=>Number(ye.has(Z.id))-Number(ye.has($.id)));for(const $ of $t){const Z=U.get($.id);if(!Z||$.dimmed&&!ye.has($.id))continue;const te=Z.map(Se),K=ye.has($.id),X=(K?$.details:[$.summary]).map(oe=>xt(u,oe,200)),Ae=Math.max(...X.map(oe=>u.measureText(oe).width))+14,ie=X.length*(dt+2);if(!K&&F<.45)continue;const ge=Oa(te,Ae,ie,Ke,K);ge&&X.forEach((oe,fe)=>{Je({x:ge.x,y:ge.y-ie/2+(dt+2)*fe+dt/2},oe,K,Ae)})}u.globalAlpha=1},[n,U,O,ye,M,se,i]);b.useEffect(()=>{let _=0;const u=()=>{_=requestAnimationFrame(u),p.current&&(p.current=!1,Le())};return _=requestAnimationFrame(u),document.addEventListener("visibilitychange",H),()=>{cancelAnimationFrame(_),document.removeEventListener("visibilitychange",H)}},[Le,H]),b.useEffect(()=>{const _=new MutationObserver(()=>{v.current.clear(),he(u=>u+1),H()});return _.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>_.disconnect()},[H]);const xe=(_,u,f)=>{const E=m.current,T=Math.min(3,Math.max(.15,E.z*_));Q({z:T,x:u-(u-E.x)*(T/E.z),y:f-(f-E.y)*(T/E.z)})},Re=_=>{const u=c.current?.getBoundingClientRect();return{x:_.clientX-(u?.left??0),y:_.clientY-(u?.top??0)}},ce=_=>{if(_.button!==0&&_.pointerType==="mouse")return;_.currentTarget.setPointerCapture(_.pointerId);const u=Re(_);if(_.pointerType==="touch"&&(S.current.set(_.pointerId,u),S.current.size===2)){const[T,L]=[...S.current.values()];j.current=null,N.current=null,d.current={d:Math.hypot(T.x-L.x,T.y-L.y)||1,mid:{x:(T.x+L.x)/2,y:(T.y+L.y)/2}};return}const f=ze(u.x,u.y),E={start:u,last:u,hit:f,moved:!1};if(f?.kind==="handle")N.current={from:f.box,to:_e(u.x,u.y),over:null};else if(f?.kind==="box"){const T=_e(u.x,u.y);E.grab={x:f.box.x-T.x,y:f.box.y-T.y}}j.current=E},ot=_=>{const u=Re(_);S.current.has(_.pointerId)&&S.current.set(_.pointerId,u);const f=d.current;if(f&&S.current.size===2){const[B,F]=[...S.current.values()],me=Math.hypot(B.x-F.x,B.y-F.y)||1,le={x:(B.x+F.x)/2,y:(B.y+F.y)/2};Q({...m.current,x:m.current.x+le.x-f.mid.x,y:m.current.y+le.y-f.mid.y}),xe(me/f.d,le.x,le.y),d.current={d:me,mid:le};return}const E=j.current;if(!E){const B=ze(u.x,u.y);A(me=>Wa(me,B)?me:B);const F=c.current;F&&(F.style.cursor=B?.kind==="handle"?"crosshair":B?"pointer":"grab");return}const T=u.x-E.last.x,L=u.y-E.last.y;if(E.last=u,!E.moved&&Math.hypot(u.x-E.start.x,u.y-E.start.y)>4&&(E.moved=!0),!E.moved)return;const z=N.current;if(z){z.to=_e(u.x,u.y);const B=ze(u.x,u.y);z.over=B?.kind==="box"?B.box:null,H();return}const G=E.hit;if(G?.kind==="box"&&E.grab){const B=_e(u.x,u.y),F=e.find(le=>le.id===G.box.id);if(!F)return;const me={x:B.x+E.grab.x,y:B.y+E.grab.y};w(le=>new Map(le).set(F.id,{at:me,from:{x:F.x,y:F.y}}));return}Q({...m.current,x:m.current.x+T,y:m.current.y+L}),c.current&&(c.current.style.cursor="grabbing")},ke=_=>{if(S.current.delete(_.pointerId),d.current){S.current.size<2&&(d.current=null),j.current=null;return}const u=j.current;j.current=null;const f=N.current;if(N.current=null,!u)return;if(c.current&&(c.current.style.cursor="grab"),f){H(),f.over&&i&&i(f.from.id,f.over.id);return}if(u.moved)return;const E=u.hit;E?.kind==="box"?a(E.box.id):E?.kind==="edge"?D(T=>T===E.edge.id?null:E.edge.id):D(null)},Ie=_=>{S.current.delete(_.pointerId),d.current=null,j.current=null,N.current=null,H()};b.useEffect(()=>{const _=c.current;if(!_)return;const u=f=>{f.preventDefault();const E=Re(f);f.ctrlKey||f.metaKey?xe(Math.exp(-f.deltaY*(f.ctrlKey?.01:.002)),E.x,E.y):Q({...m.current,x:m.current.x-f.deltaX,y:m.current.y-f.deltaY})};return _.addEventListener("wheel",u,{passive:!1}),()=>_.removeEventListener("wheel",u)});const We=_=>xe(_,h.current.w/2,h.current.h/2),Be=[...new Set(e.map(_=>_.icon??""))];return t.jsxs("div",{ref:y,className:de("relative h-full w-full overflow-hidden",l),children:[t.jsx("canvas",{ref:c,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:ce,onPointerMove:ot,onPointerUp:ke,onPointerCancel:Ie,onPointerLeave:()=>{j.current||A(null)}}),t.jsxs("ul",{ref:x,"aria-label":s,className:"sr-only",children:[Be.map(_=>t.jsx("li",{"aria-hidden":"true","data-icon-key":_,children:o(_)},`icon:${_}`)),e.map(_=>t.jsx("li",{children:t.jsx("button",{type:"button",onClick:()=>a(_.id),onFocus:()=>pe(_.id),onBlur:()=>V(null),children:r(_)})},_.id)),n.map(_=>t.jsx("li",{"data-revealed":ye.has(_.id)||void 0,children:t.jsx("button",{type:"button","aria-pressed":P===_.id,onClick:()=>D(u=>u===_.id?null:_.id),onFocus:()=>{q(_.id);const u=U.get(_.id);u&&re(u.map(f=>({...f,w:0,h:0})))},onBlur:()=>q(null),children:_.ariaLabel})},_.id))]}),t.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>We(1.25),children:t.jsx(mt,{className:"h-3.5 w-3.5"})}),t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>We(.8),children:t.jsx(Os,{className:"h-3.5 w-3.5"})}),t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:W,children:t.jsx($s,{className:"h-3.5 w-3.5"})}),I.size>0?t.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>w(new Map),children:t.jsx(As,{className:"h-3.5 w-3.5"})}):null]})]})}const Mn=e=>({x:e.x+e.w/2,y:e.y});function Wa(e,n){return!e||!n?e===n:e.kind==="edge"||n.kind==="edge"?e.kind==="edge"&&n.kind==="edge"&&e.edge.id===n.edge.id:e.kind===n.kind&&e.box.id===n.box.id}function cn({label:e,fill:n=!1,schemaActions:s=!1}){return t.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:de("flex min-w-0 flex-col gap-3",n&&"min-h-0 flex-1"),children:[t.jsx("div",{"aria-hidden":"true",children:t.jsx(ve,{className:"h-5 w-3/4 max-w-xl rounded-none"})}),t.jsxs("div",{className:de("relative flex min-h-0 flex-col",n&&"flex-1"),"aria-hidden":"true",children:[s?t.jsxs("div",{className:"z-10 flex flex-wrap justify-end gap-2 lg:absolute lg:top-0 lg:right-0",children:[t.jsx(ve,{className:"h-8 w-40 rounded-none"}),t.jsx(ve,{className:"h-8 w-36 rounded-none"})]}):null,t.jsxs("div",{className:de("relative min-h-[420px]",n?"flex-1":"h-[70vh]"),children:[t.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:[t.jsx(ve,{className:"h-4 w-4 shrink-0 rounded-none"}),t.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[t.jsx(ve,{className:"h-3.5 w-24 rounded-none"}),t.jsx(ve,{className:"h-2.5 w-32 rounded-none"})]})]}),t.jsx("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:["in","out","fit"].map(a=>t.jsx("div",{className:"flex h-7 w-7 items-center justify-center border border-input bg-background",children:t.jsx(ve,{className:"h-3 w-3 rounded-none"})},a))})]})]})]})}function bt(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 qt={exports:{}},Tn;function Ba(){return Tn||(Tn=1,(function(e,n){(function(s){e.exports=s()})(function(){return(function(){function s(a,r,i){function o(c,x){if(!r[c]){if(!a[c]){var m=typeof bt=="function"&&bt;if(!x&&m)return m(c,!0);if(l)return l(c,!0);var h=new Error("Cannot find module '"+c+"'");throw h.code="MODULE_NOT_FOUND",h}var p=r[c]={exports:{}};a[c][0].call(p.exports,function(v){var j=a[c][1][v];return o(j||v)},p,p.exports,s,a,r,i)}return r[c].exports}for(var l=typeof bt=="function"&&bt,y=0;y<i.length;y++)o(i[y]);return o}return s})()({1:[function(s,a,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;function i(h){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},i(h)}function o(h,p){if(!(h instanceof p))throw new TypeError("Cannot call a class as a function")}function l(h,p){for(var v=0;v<p.length;v++){var j=p[v];j.enumerable=j.enumerable||!1,j.configurable=!0,"value"in j&&(j.writable=!0),Object.defineProperty(h,c(j.key),j)}}function y(h,p,v){return p&&l(h.prototype,p),Object.defineProperty(h,"prototype",{writable:!1}),h}function c(h){var p=x(h,"string");return i(p)=="symbol"?p:p+""}function x(h,p){if(i(h)!="object"||!h)return h;var v=h[Symbol.toPrimitive];if(v!==void 0){var j=v.call(h,p);if(i(j)!="object")return j;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(h)}r.default=(function(){function h(){var p=this,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},j=v.defaultLayoutOptions,d=j===void 0?{}:j,S=v.algorithms,N=S===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:S,C=v.workerFactory,k=v.workerUrl;if(o(this,h),this.defaultLayoutOptions=d,this.initialized=!1,typeof k>"u"&&typeof C>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var g=C;typeof k<"u"&&typeof C>"u"&&(g=function(A){return new Worker(A)});var w=g(k);if(typeof w.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new m(w),this.worker.postMessage({cmd:"register",algorithms:N}).then(function(M){return p.initialized=!0}).catch(console.err)}return y(h,[{key:"layout",value:function(v){var j=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d=j.layoutOptions,S=d===void 0?this.defaultLayoutOptions:d,N=j.logging,C=N===void 0?!1:N,k=j.measureExecutionTime,g=k===void 0?!1:k;return v?this.worker.postMessage({cmd:"layout",graph:v,layoutOptions:S,options:{logging:C,measureExecutionTime:g}}):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 m=(function(){function h(p){var v=this;if(o(this,h),p===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=p,this.worker.onmessage=function(j){setTimeout(function(){v.receive(v,j)},0)}}return y(h,[{key:"postMessage",value:function(v){var j=this.id||0;this.id=j+1,v.id=j;var d=this;return new Promise(function(S,N){d.resolvers[j]=function(C,k){C?(d.convertGwtStyleError(C),N(C)):S(k)},d.worker.postMessage(v)})}},{key:"receive",value:function(v,j){var d=j.data,S=v.resolvers[d.id];S&&(delete v.resolvers[d.id],d.error?S(d.error):S(null,d.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(v){if(v){var j=v.__java$exception;j&&(j.cause&&j.cause.backingJsObject&&(v.cause=j.cause.backingJsObject,this.convertGwtStyleError(v.cause)),delete v.__java$exception)}}}])})()},{}],2:[function(s,a,r){var i=s("./elk-api.js").default;Object.defineProperty(a.exports,"__esModule",{value:!0}),a.exports=i,i.default=i},{"./elk-api.js":1}]},{},[2])(2)})})(qt)),qt.exports}var Ha=Ba();const Va=Ps(Ha);function Ua(e){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:e?.name})}const qa=200,Ga=320,st=56,Ka=7.4,Ya=5.9,Ja=84,Qa=48;function ft(e,n){return Math.round(Math.min(Ga,Math.max(qa,Ja+e.length*Ka,Qa+n.length*Ya)))}function Xa(e,n){const s=[];return e>0&&s.push(`${e} ${e===1?"field":"fields"}`),typeof n=="number"&&s.push(`${n.toLocaleString()} ${n===1?"record":"records"}`),s.join(" · ")}function Ln(e,n){return e.slug<n.slug?-1:e.slug>n.slug?1:0}function ys(e,n){const s=new Set;return e.filter(a=>a.status!=="active"||a.organization_slug&&a.organization_slug!==n||s.has(a.slug)?!1:(s.add(a.slug),!0))}function Za(e){const n=e.metadata_schema;if(!n||typeof n!="object")return 0;const s=n.properties;return!s||typeof s!="object"?0:Object.keys(s).length}function xs(e){const{entityTypes:n,relationshipTypes:s,rulesBySlug:a}=e,r=e.ownerSlug??"",i=[...n].sort(Ln),o=ys(s,r).sort(Ln),l=g=>!g.organization_slug||g.organization_slug===r,y=g=>g.organization_slug||r,c=new Map;for(const g of i)c.set(g.slug,[...c.get(g.slug)??[],g]);const x=g=>(c.get(g.slug)?.length??0)>1?`${y(g)}:${g.slug}`:g.slug,m=new Set(i.filter(l).map(x)),h=g=>{const w=c.get(g)??[];return w.find(l)??(w.length===1?w[0]:void 0)},p=new Set(m),v=o.flatMap(g=>[...a[g.slug]??[]].sort((w,M)=>w.id-M.id).flatMap(w=>{const M=h(w.source_entity_type_slug),A=h(w.target_entity_type_slug);if(!M||!A)return[];const P=x(M),D=x(A);return!m.has(P)&&!m.has(D)?[]:(p.add(P),p.add(D),[{rt:g,source:P,target:D}])})),j=i.filter(g=>p.has(x(g))),d=[],S=new Map,N=new Map;for(const{rt:g,source:w,target:M}of v){const A=`${g.slug}|${w}|${M}`,P=N.get(A);if(P){P.ruleCount+=1;continue}const D={slug:g.slug,label:g.name||g.slug,ruleCount:1};N.set(A,D);const J=`${w}|${M}`,q=S.get(J);if(q){q.data.relationships.push(D),q.data.isSymmetric=q.data.isSymmetric&&g.is_symmetric;continue}const se={id:`pair:${w}|${M}`,source:w,target:M,data:{relationships:[D],isSymmetric:g.is_symmetric}};S.set(J,se),d.push(se)}const C=new Map;for(const{rt:g,source:w,target:M}of v){const A=C.get(g.slug)??new Set;A.add(`${w}|${M}`),C.set(g.slug,A)}for(const{rt:g}of v)if(C.get(g.slug)?.size===1&&typeof g.relationship_count=="number")for(const w of N.values())w.slug===g.slug&&(w.linkCount=g.relationship_count);return{nodes:j.map(g=>{const w=g.name||g.slug,M=Za(g),A=Xa(M,g.entity_count);return{id:x(g),width:ft(w,A),height:st,data:{slug:g.slug,label:w,icon:g.icon,isSystem:Ds(g),organizationSlug:l(g)?void 0:y(g),metaLabel:A}}}),edges:d}}const Ve=24,eo=72,to=16;let Rn=null;function no(){return Rn??=new Va({workerFactory:()=>new Ua}),Rn}const Gt={"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 ln(e,{elk:n=no(),targetAspect:s}={}){const a=new Set;for(const d of e.edges)a.add(d.source),a.add(d.target);const r=e.nodes.some(d=>d.lane!==void 0),i=e.nodes.filter(d=>r||a.has(d.id)),o=e.nodes.filter(d=>!r&&!a.has(d.id)),l=o.reduce((d,S)=>Math.max(d,S.width),0),y=o.length>0?Ve+l+eo:0,c=d=>({x:d.x+Ve+y,y:d.y+Ve});let x=[];const m=new Map;if(i.length>0){const d=e.edges.filter(g=>g.source!==g.target),S=g=>n.layout({id:"root",layoutOptions:r?{...g,"elk.partitioning.activate":"true"}:g,children:i.map(w=>({id:w.id,width:w.width,height:w.height,...r?{layoutOptions:{"elk.partitioning.partition":String(w.lane??1)}}:{}})),edges:d.map(w=>({id:w.id,sources:[w.layoutReversed?w.target:w.source],targets:[w.layoutReversed?w.source:w.target]}))});let N=await S(Gt);const C=s&&N.width&&N.height?s*N.width/N.height:1;if(C>1.08){const g=Number(Gt["elk.spacing.nodeNode"]),w=Math.min(C,2.2);N=await S({...Gt,"elk.spacing.nodeNode":String(Math.round(Math.min(180,g*w+st*(w-1))))})}const k=new Map((N.children??[]).map(g=>[g.id,g]));x=i.map(g=>{const w=k.get(g.id);return{...g,position:c({x:w?.x??0,y:w?.y??0})}});for(const g of N.edges??[]){const w=(g.sections??[]).flatMap(A=>[A.startPoint,...A.bendPoints??[],A.endPoint]);if(w.length<2)continue;const M=e.edges.find(A=>A.id===g.id)?.layoutReversed;m.set(g.id,(M?[...w].reverse():w).map(c))}}let h=Ve;const p=o.map(d=>{const S={x:Ve,y:h};return h+=d.height+to,{...d,position:S}}),v=new Map([...x,...p].map(d=>[d.id,d]));return{nodes:e.nodes.map(d=>v.get(d.id)??{...d,position:{x:Ve,y:Ve}}),edges:e.edges.map(d=>({...d,route:m.get(d.id)??null}))}}function so(e,n){return ln(xs(e),n)}const Jt="connector:",In=e=>`${Jt}${e}`,ro={event:"Zap",schedule:"CalendarClock",manual:"Hand"},ao=0,oo=1,On=2;function io(e,n){const s=new Map;for(const{kind:a,targets:r}of na(e?.feeds_schema?.[n]))for(const{entityType:i,creates:o}of r){const l=s.get(i)??{creates:!1,eventKinds:new Set};l.creates||=o,l.eventKinds.add(a),s.set(i,l)}return s}function co(e,n){const s=new Map(e.connectorDefs.map(d=>[d.key,d])),a=new Map(e.connectorDefs.map(d=>[d.key,d.name])),r=new Map(e.connections.map(d=>[d.id,d])),i=Gr(e.feeds),o=d=>`connection:${d}`,l=d=>`automation:${d}`,y=[],c=new Set,x=(d,S,N,C,k=!1)=>{y.push({id:`flow:${d}->${S}`,source:d,target:S,layoutReversed:k,data:{relationships:[],isSymmetric:!1,flow:{summary:N,details:C}}}),c.add(d),c.add(S)},m=new Set(e.connections.map(d=>d.id));for(const d of e.connections){const S=new Map;for(const N of i.get(d.id)??[]){const C=io(s.get(d.connector_key),N.feed_key);for(const[k,g]of C){const w=S.get(k)??{creates:!1,eventKinds:new Set};w.creates||=g.creates;for(const M of g.eventKinds)w.eventKinds.add(M);S.set(k,w)}}for(const[N,C]of S){const k=n.get(N);k&&x(o(d.id),k,C.creates?"creates records":"links records",[`From ${[...C.eventKinds].sort().join(", ")} events`])}}const h=Kr(e.automations);for(const[d,S]of h)if(m.has(d))for(const{automation:N,reason:C,eventTypes:k}of S){const g=l(N.automation_id);C==="trigger"?x(o(d),g,kn.trigger,k.length>0?[`On ${[...k].sort().join(", ")}`]:[]):x(g,o(d),kn.delivery,[],!0)}const p=[];for(const d of e.automations){const S=l(d.automation_id),N=d.entity_type?n.get(d.entity_type):void 0;N&&x(N,S,"anchored here",[d.entity_name?`On ${d.entity_name}`:""].filter(Boolean));const C=Zr(d,a,r),k=ea(d),g=d.health==="degraded"?"Needs attention":void 0;p.push({id:S,lane:On,width:ft(`${C.does} ${g??""}`,C.when),height:st,data:{slug:S,label:C.does,icon:k?In(k):ro[C.kind],isSystem:!1,badge:g,metaLabel:C.when,ref:{kind:"automation",automationId:d.automation_id}}})}const v=[];for(const d of e.metrics){const S=n.get(d.typeSlug);if(!S)continue;const N=`metric:${d.typeSlug}:${d.name}`;x(S,N,"measures",[d.description].filter(Boolean)),v.push({id:N,lane:On,width:ft(d.name,d.agg),height:st,data:{slug:N,label:d.name,icon:"ChartColumn",isSystem:!1,metaLabel:d.agg,ref:{kind:"metric",typeSlug:d.typeSlug,name:d.name}}})}return{nodes:[...e.connections.filter(d=>c.has(o(d.id))).map(d=>{const S=ta(d),N=Xr(d,s.get(d.connector_key)),C=Yr({feeds:i.get(d.id)?.length||d.feed_count,actions:d.operations_summary?.total??0,automations:h.get(d.id)?.length??0}),k=N.needsAttention?"Needs attention":d.device_label??void 0;return{id:o(d.id),lane:ao,width:ft(`${S} ${k??""}`,C),height:st,data:{slug:o(d.id),label:S,icon:In(d.connector_key),isSystem:!1,badge:k,metaLabel:C,ref:{kind:"connection",connectorKey:d.connector_key,connectionId:d.id}}}}),...p,...v],edges:y}}function ut(e){switch(e.data.ref?.kind){case"connection":return"connections";case"automation":return"automations";case"metric":return"metrics";default:return"entities"}}function lo(e,n){const s=new Map;for(const x of e.nodes)(!x.data.organizationSlug||!s.has(x.data.slug))&&s.set(x.data.slug,x.id);const a=co(n,s),{layers:r}=n,i=[...a.nodes,...e.nodes.map(x=>({...x,lane:oo}))],o=new Set(i.filter(x=>r[ut(x)]).map(x=>x.id)),l=[...e.edges,...a.edges].filter(x=>o.has(x.source)&&o.has(x.target)),y=new Set(l.flatMap(x=>[x.source,x.target]));return{graph:{nodes:i.filter(x=>o.has(x.id)&&(ut(x)==="entities"||ut(x)==="automations"||y.has(x.id))),edges:l},hidden:{connections:r.connections?n.connections.length-a.nodes.filter(x=>ut(x)==="connections").length:0}}}const $n="__new__";function An(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function uo({entityTypes:e,initialSource:n="",initialTarget:s="",onDone:a}){const r=b.useId(),i=`${r}-relationship`,o=`${r}-name`,l=`${r}-symmetric`,y=`${r}-source`,c=`${r}-target`,{orgContext:x}=De(),{data:m=[]}=en(x),h=Fs(),p=zs(),[v,j]=b.useState(""),[d,S]=b.useState(""),[N,C]=b.useState(!1),[k,g]=b.useState(n),[w,M]=b.useState(s),[A,P]=b.useState(null),D=v===$n,J=m.filter(V=>V.status==="active"&&V.purpose!==Ws&&(!V.organization_slug||V.organization_slug===x?.slug)),q=h.isPending||p.isPending,se=async()=>{if(P(null),!v)return P("Pick a relationship");if(!k||!w)return P("Pick both ends");try{let V=v;if(D){const ne=d.trim();if(!ne)return P("Name the relationship");const he=An(ne);if(!he)return P("Name must contain a letter or number");V=(await h.mutateAsync({slug:he,name:ne,is_symmetric:N})).relationship_type.slug,j(V)}await p.mutateAsync({slug:V,source_entity_type_slug:k,target_entity_type_slug:w}),a()}catch(V){P(V instanceof Error?V.message:"Could not save")}};return t.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[t.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."}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Pe,{htmlFor:i,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),t.jsxs(Ft,{value:v,onValueChange:j,children:[t.jsx(zt,{id:i,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Pick or define one"})}),t.jsxs(Bt,{children:[J.map(V=>t.jsx(yt,{value:V.slug,children:V.name||V.slug},V.slug)),J.length>0?t.jsx(Bs,{}):null,t.jsx(yt,{value:$n,children:"Define a new one…"})]})]})]}),D?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Pe,{htmlFor:o,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),t.jsx(rt,{id:o,value:d,onChange:V=>S(V.target.value),placeholder:"works at",className:"h-8 text-xs"}),d.trim()?t.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",t.jsx("code",{children:An(d)||"—"})]}):null]}),t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs(Pe,{htmlFor:l,className:"text-xs font-normal",children:["Symmetric",t.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Both ends mean the same thing, like “connected with”."})]}),t.jsx(Hs,{id:l,checked:N,onCheckedChange:C})]})]}):null,t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Pe,{htmlFor:y,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),t.jsxs(Ft,{value:k,onValueChange:g,children:[t.jsx(zt,{id:y,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Type"})}),t.jsx(Bt,{children:e.map(V=>t.jsx(yt,{value:V.slug,children:V.label},V.slug))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Pe,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),t.jsxs(Ft,{value:w,onValueChange:M,children:[t.jsx(zt,{id:c,className:"h-8 text-xs",children:t.jsx(Wt,{placeholder:"Type"})}),t.jsx(Bt,{children:e.map(V=>t.jsx(yt,{value:V.slug,children:V.label},V.slug))})]})]}),A?t.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:A}):null,t.jsx(qn,{onCancel:a,cancelDisabled:q,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:t.jsx(Y,{type:"button",size:"sm",onClick:se,disabled:q,children:q?"Saving…":"Add relationship"})})]})}const bs=288,mo=440,Et=240,Ct=720,fo=320,dn="lobu.schema-panel-width:v1";function _t(e,n){if(!Number.isFinite(e))return bs;const s=Math.max(Et,Math.min(Ct,n-fo));return Math.round(Math.min(s,Math.max(Et,e)))}function ho(){const e=Gn(dn);if(e===null)return null;const n=Number.parseInt(e,10);return!Number.isFinite(n)||n<Et||n>Ct?null:n}function po(e){Kn(dn,String(Math.round(e)))}function go(){Vs(dn)}const Pn={nodes:[],edges:[]};function yo(e,n,s){const{orgContext:a,hasOrgContext:r}=De(),{data:i=[],isLoading:o,isError:l}=It(a),{data:y=[],isLoading:c,isError:x}=en(a),m=b.useMemo(()=>ys(y,e),[y,e]),h=b.useCallback(g=>{const w={};return m.forEach((M,A)=>{const P=g[A]?.data;P?.length&&(w[M.slug]=P)}),{rulesBySlug:w,isRulesLoading:g.some(M=>M.isLoading),isRulesError:g.some(M=>M.isError)}},[m]),{rulesBySlug:p,isRulesLoading:v,isRulesError:j}=Us({queries:m.map(g=>({...qs.queryOptions(g.slug,a),enabled:r})),combine:h}),d=b.useMemo(()=>({entityTypes:i,relationshipTypes:m,rulesBySlug:p,ownerSlug:e,targetAspect:n,flow:s}),[i,m,p,e,n,s]),[S,N]=b.useState(null),C=o||c||v,k=l||x||j;return b.useEffect(()=>{if(C||k)return;let g=!1;const w={targetAspect:d.targetAspect};let M,A;if(d.flow){const P=lo(xs(d),d.flow);M=P.hidden,A=ln(P.graph,w)}else A=so(d,w);return A.then(P=>{g||N({graph:P,isError:!1,hidden:M})}).catch(()=>{g||N({graph:Pn,isError:!0})}),()=>{g=!0}},[d,C,k]),{graph:S?.graph??Pn,hidden:S?.hidden,isLoading:!k&&!S,isError:k||S?.isError===!0}}function Dn(e){const n=e.ruleCount>1?` ×${e.ruleCount}`:"",s=typeof e.linkCount=="number"?` · ${e.linkCount.toLocaleString()}`:"";return`${e.label}${n}${s}`}const vs={connections:"--chart-3",entities:"--chart-5",automations:"--chart-2",metrics:"--chart-4"};function xo(e,n){const s=e.nodes.some(o=>o.data.ref),a=new Map(e.nodes.map(o=>[o.id,o.data.label])),r=e.nodes.map(o=>({id:o.id,x:o.position.x+o.width/2,y:o.position.y+o.height/2,w:o.width,h:o.height,title:o.data.label,meta:o.data.metaLabel,icon:o.data.icon,badge:o.data.badge??o.data.organizationSlug,muted:o.data.isSystem,dimmed:n?!n.nodes.has(o.id):!1,accent:s?vs[ut(o)]:void 0})),i=e.edges.map(o=>{const{relationships:l,isSymmetric:y,flow:c}=o.data;if(c)return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:c.summary,details:[c.summary,...c.details],directed:!0,dimmed:n?!n.edges.has(o.id):!1,ariaLabel:`${a.get(o.source)??o.source} to ${a.get(o.target)??o.target}: ${c.summary}`};const x=l.map(m=>m.label).join(", ");return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:l.length===1?Dn(l[0]):`${l.length} relationships`,details:l.map(Dn),directed:!y,dimmed:n?!n.edges.has(o.id):!1,ariaLabel:`${a.get(o.source)??o.source} ${y?"and":"to"} ${a.get(o.target)??o.target}: ${x}`}});return{boxes:r,edges:i}}const bo=[{key:"connections",label:"Connections"},{key:"entities",label:"Entities"},{key:"automations",label:"Automations"},{key:"metrics",label:"Metrics"}],vo={count:"Count",count_distinct:"Distinct count",sum:"Sum",min:"Minimum",max:"Maximum"};function wo({metric:e,ownerSlug:n}){const s=(a,r)=>r.length>0?t.jsxs("section",{className:"flex flex-col gap-1.5",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a}),t.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:r.map(i=>t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:i.name}),i.description?t.jsx("span",{className:"text-muted-foreground",children:` · ${i.description}`}):null]},i.name))})]}):null;return t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm",children:[vo[e.agg]??e.agg," of"," ",t.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:e.eventSet})," ","events, per ",e.typeLabel]}),e.description?t.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}):null]}),s("Data from",e.sources.map(a=>({name:a,description:""}))),s("Group by",e.dimensions),s("Segments",e.segments),t.jsx(Y,{asChild:!0,variant:"outline",size:"sm",className:"self-start",children:t.jsxs(we,{to:"/$owner/$entityType",params:{owner:n,entityType:e.typeSlug},children:["Open ",e.typeLabel]})})]})}function ko({ownerSlug:e,metric:n,endpointOptions:s,canAuthor:a,mode:r,onModeChange:i}){const o=()=>i({kind:"index"});return r.kind==="metric"?n?t.jsx(wo,{metric:n,ownerSlug:e}):null:a?r.kind==="create-type"?t.jsx(sa,{slug:null,onClose:o}):r.kind==="new-relationship"?t.jsx(uo,{entityTypes:s,initialSource:r.source,initialTarget:r.target,onDone:o},`${r.source??""}|${r.target??""}`):null:null}function jo(e){const{mode:n,canAuthor:s,onModeChange:a,isPeekOpen:r}=e,i=s&&n.kind==="create-type",o=n.kind==="metric"?n.name:s&&n.kind==="new-relationship"?"New relationship":i?"New entity type":"Schema",l=b.useRef(null),y=JSON.stringify(n),c=b.useRef(y);return b.useEffect(()=>{c.current!==y&&(c.current=y,l.current?.focus({preventScroll:!0}))},[y]),t.jsx("aside",{style:{"--schema-panel-width":`${e.width}px`},className:de("order-first flex w-full shrink-0 flex-col lg:order-none lg:w-[var(--schema-panel-width)]",n.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:t.jsxs("div",{className:de("flex min-h-0 flex-1 flex-col",n.kind!=="index"&&"lg:absolute lg:inset-0"),children:[t.jsxs("div",{className:n.kind==="index"?"sr-only":"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[t.jsx("h2",{ref:l,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:o}),n.kind!=="index"?t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Close",onClick:()=>a({kind:"index"}),children:t.jsx(tr,{className:"h-4 w-4"})}):null]}),t.jsx("div",{className:de("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",n.kind==="index"?"pb-1":"p-4"),children:t.jsx(ko,{...e})})]})})}function ws(e){const n=e.previousElementSibling,s=e.nextElementSibling;if(n instanceof HTMLElement&&s instanceof HTMLElement){const a=n.clientWidth+s.clientWidth;if(a>0)return a}return 0}function No({width:e,maxWidth:n,onResize:s,onCommit:a,onReset:r,className:i}){const[o,l]=b.useState(!1),y=b.useRef(0),c=h=>{const p=ws(h);return p>0?p:h.parentElement?.clientWidth??0},x=h=>{if(h.button!==0)return;const p=h.currentTarget;if(!p.parentElement)return;h.preventDefault(),y.current=c(p);const j=h.clientX,d=e;l(!0),p.setPointerCapture(h.pointerId);const S=g=>_t(d-(g-j),y.current);let N=d;const C=g=>{N=S(g.clientX),s(N)},k=g=>{p.removeEventListener("pointermove",C),p.removeEventListener("pointerup",k),p.removeEventListener("pointercancel",k),l(!1),a(g.type==="pointercancel"?N:S(g.clientX))};p.addEventListener("pointermove",C),p.addEventListener("pointerup",k),p.addEventListener("pointercancel",k)},m=h=>{const p=c(h.currentTarget),v=j=>{h.preventDefault(),a(_t(e+j,p))};h.key==="ArrowLeft"?v(16):h.key==="ArrowRight"?v(-16):h.key==="Home"&&(h.preventDefault(),r())};return t.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize schema panel","aria-valuenow":e,"aria-valuemin":Et,"aria-valuemax":n,tabIndex:0,onPointerDown:x,onKeyDown:m,onDoubleClick:r,className:de("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",o&&"cursor-col-resize",i),children:t.jsx("div",{className:de("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",o&&"w-0.5 bg-primary")})})}function So({ownerSlug:e}){const n=at(),s=tn(),a=s?.item!=null,{orgContext:r}=De(),{isAdmin:i}=Yn(r.organizationId),[o,l]=b.useState({connections:!0,entities:!0,automations:!0,metrics:!0}),[y,c]=b.useState({kind:"index"}),x=s?.close,m=b.useCallback(f=>{f.kind!=="index"&&a&&x?.(),c(f)},[a,x]),[h,p]=b.useState(),v=b.useRef(null),j=b.useCallback(f=>{if(v.current?.disconnect(),v.current=null,!f||typeof ResizeObserver>"u")return;const E=()=>{if(!f.clientWidth||!f.clientHeight)return;const L=Math.round(f.clientHeight/f.clientWidth*10)/10;p(z=>z===L?z:L)};E();const T=new ResizeObserver(E);T.observe(f),v.current=T},[]),d=r.organizationId,S=Gs(d),N=Ks(d),C=Ys(d),k=Qr(d??void 0),{data:g}=It(r),w=b.useMemo(()=>g?.filter(f=>Js(f,e)),[g,e]),M=b.useMemo(()=>(w??[]).flatMap(f=>Object.entries(f.metrics_config?.measures??{}).map(([E,T])=>({typeSlug:f.slug,name:E,agg:T.agg,description:T.description}))),[w]),A=S.isLoading||N.isLoading||C.isLoading||k.isLoading,P=b.useMemo(()=>A?null:{connections:S.data??[],feeds:N.data??[],connectorDefs:C.data??[],automations:k.data??[],metrics:M,layers:o},[A,S.data,N.data,C.data,k.data,M,o]),{graph:D,isLoading:J,isError:q,hidden:se}=yo(e,h,P),V=J||A,ne=y.kind==="metric"?y:null,he=b.useMemo(()=>{if(!ne)return null;const f=`metric:${ne.typeSlug}:${ne.name}`,E=D.edges.find(z=>z.target===f);if(!E)return null;const T=E.source,L=D.edges.filter(z=>z.target===T&&D.nodes.find(G=>G.id===z.source)?.data.ref?.kind==="connection");return{typeId:T,nodes:new Set([f,T,...L.map(z=>z.source)]),edges:new Set([E.id,...L.map(z=>z.id)]),sources:L.map(z=>D.nodes.find(G=>G.id===z.source)?.data.label??z.source)}},[ne,D]),{boxes:O,edges:I}=b.useMemo(()=>xo(D,he),[D,he]),U=b.useMemo(()=>{if(!ne)return null;const f=w?.find(L=>L.slug===ne.typeSlug),E=f?.metrics_config,T=E?.measures?.[ne.name];return!f||!T?null:{name:ne.name,typeSlug:f.slug,typeLabel:f.name||f.slug,agg:T.agg,eventSet:T.eventSet,description:T.description,dimensions:Object.entries(E?.dimensions??{}).map(([L,z])=>({name:L,description:z.description})),segments:Object.entries(E?.segments??{}).map(([L,z])=>({name:L,description:z.description})),sources:he?.sources??[]}},[ne,w,he]),H=b.useMemo(()=>new Map(D.nodes.map(f=>[f.id,f.data.slug])),[D.nodes]),W=b.useMemo(()=>new Map(D.nodes.flatMap(f=>f.data.ref?[[f.id,f.data.ref]]:[])),[D.nodes]),{data:Q=[]}=Qs(r.organizationId),re=b.useMemo(()=>{const f=new Map;for(const E of D.nodes)E.data.ref||(!E.data.organizationSlug||!f.has(E.data.slug))&&f.set(E.data.slug,{slug:E.data.slug,label:E.data.label});return[...f.values()]},[D.nodes]),pe=b.useCallback(f=>{const E=W.get(f);if(E?.kind==="connection"){n({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:E.connectorKey,connectionId:String(E.connectionId)},search:{}});return}if(E?.kind==="metric"){m({kind:"metric",typeSlug:E.typeSlug,name:E.name});return}if(E?.kind==="automation"){n({to:"/$owner/automations/$automationId",params:{owner:e,automationId:E.automationId},search:{view:"activity",run_id:void 0}});return}n(Jn(e,H.get(f)??f))},[n,e,H,W,m]),ue=b.useCallback((f,E)=>{W.has(f)||W.has(E)||m({kind:"new-relationship",source:H.get(f)??f,target:H.get(E)??E})},[H,W,m]),Ce=D.nodes.some(f=>!f.data.ref&&!f.data.isSystem&&!f.data.organizationSlug),Fe=D.nodes.some(f=>f.data.ref),Ne="size-6 text-muted-foreground hover:text-foreground",Ge={connections:t.jsx(Jr,{ownerSlug:e,catalog:Q,trigger:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:Ne,"aria-label":"New connector",title:"New connector",children:t.jsx(mt,{className:"size-3.5"})})}),entities:t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:Ne,"aria-label":"Create entity type",title:"Create entity type",onClick:()=>m({kind:"create-type"}),children:t.jsx(mt,{className:"size-3.5"})}),automations:t.jsx(Y,{asChild:!0,variant:"ghost",size:"icon",className:Ne,children:t.jsx(we,{to:"/$owner/automations/new",params:{owner:e},"aria-label":"New Automation",title:"New Automation",children:t.jsx(mt,{className:"size-3.5"})})})},_e=b.useCallback(f=>{const E=f.startsWith(Jt)?f.slice(Jt.length):null;if(!E)return t.jsx(Rt,{icon:f||null,className:"h-4 w-4"});const T=Xs(E,C.data??[],{name:S.data?.find(L=>L.connector_key===E)?.connector_name??E});return t.jsx(Zs,{plain:!0,icon:T.icon,iconUrl:T.iconUrl,name:T.name,faviconDomain:T.faviconDomain})},[C.data,S.data]),ze=i&&y.kind==="create-type",ye=y.kind==="metric"||i&&y.kind!=="index",[Le,xe]=b.useState(()=>ho()),Re=Le??(ze?mo:bs),[ce,ot]=b.useState(null),ke=b.useRef(null),Ie=b.useCallback(f=>{if(ke.current?.disconnect(),ke.current=null,!f||typeof ResizeObserver>"u")return;const E=f.children[1];if(!E)return;const T=()=>{const z=ws(E);z>0&&ot(G=>G===z?G:z)};T();const L=new ResizeObserver(T);L.observe(f),ke.current=L},[]),We=ce===null?Re:_t(Re,ce),Be=ce===null?Ct:_t(Ct,ce),_=b.useCallback(f=>{xe(f),po(f)},[]),u=b.useCallback(()=>{xe(null),go()},[]);return V?t.jsx(cn,{label:"Loading workspace schema",fill:!0,schemaActions:i}):q?t.jsx(Qn,{label:"workspace schema"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[t.jsxs("div",{className:de("flex flex-wrap items-center justify-between gap-3",ye&&"hidden lg:flex"),children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:Fe?`Where records come from, the types they land in, and what uses them. Click a box to open it${i?", or drag a type's ⊕ onto another to relate them":""}. Only stored links are drawn${se?.connections?`; ${se.connections} connections have none yet`:""}.`:Ce?D.edges.length>0?`Your workspace schema. Hover a type or select a line to name its relationships, click a type to open it${i?", or drag its ⊕ to relate types.":"."}`:"Your workspace schema. Click a type to open it — relationships appear here once you add one to a type.":i?"Member is already here: everyone in this workspace. Create the first type of record you track — a company, a deal, a ticket — then drag its ⊕ onto Member to relate them.":"Member is already here: everyone in this workspace. An admin can add the types of record this workspace tracks."}),t.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:[t.jsx("legend",{className:"sr-only",children:"Show on the map"}),bo.map(({key:f,label:E})=>{const T=`memory-map-show-${f}`,L=o[f]&&Object.values(o).filter(Boolean).length===1;return t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(er,{id:T,checked:o[f],disabled:L,onCheckedChange:z=>l(G=>({...G,[f]:z===!0}))}),t.jsxs("label",{htmlFor:T,className:"inline-flex cursor-pointer select-none items-center gap-1.5",children:[t.jsx("span",{"aria-hidden":"true",className:"size-2 rounded-full",style:{background:`var(${vs[f]})`}}),E]}),i?Ge[f]:null]},f)})]})]}),t.jsxs("div",{ref:Ie,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:[t.jsx("div",{className:de("flex min-w-0 flex-1 flex-col lg:pb-8",ye&&"hidden lg:flex"),children:t.jsx("div",{ref:j,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:t.jsx(gs,{boxes:O,edges:I,label:"Workspace schema",onOpenBox:pe,openLabel:f=>`Open ${f.title}`,onConnect:i?ue:void 0,renderIcon:_e})})}),t.jsx(No,{width:We,maxWidth:Be,onResize:xe,onCommit:_,onReset:u,className:a||y.kind==="index"?"lg:hidden":void 0}),t.jsx(jo,{width:We,metric:U,ownerSlug:e,endpointOptions:re,canAuthor:i,mode:y,onModeChange:m,isPeekOpen:a})]})]})}function Eo({onClose:e,entityTypeSlug:n,orgContext:s,onSuccess:a}){const{data:r,isLoading:i}=Xn(n,s),o=`${s.organizationId??s.slug}:${n}`,l=nr(o,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},r?.metadata_schema),[y,c]=l.field("name"),[x,m]=l.field("customSlug"),[h,p]=l.field("useCustomSlug"),[v,j]=l.field("metadata"),[d,S]=sr(o,null),N=rr(),C=h?x:ar(y),k=async P=>{if(P.preventDefault(),!l.canSubmit)return;if(S(null),!y.trim()){S("Name is required");return}const D=aa(v),J={entityType:n,name:y.trim(),slug:h?x:void 0,metadata:Object.keys(D).length>0?D:void 0};try{const q=await N.mutateAsync(J);if(e(),q.approval_queued||!q.entity){Zn.info("Create queued for approval");return}typeof q.entity.id=="number"&&a?.(q.entity.id)}catch(q){S(q instanceof Error?q.message:"Failed to create entity")}},g=r?.name||n,w=l.revision,M=`Create ${g}`,A=`Add a new ${g.toLowerCase()} to your workspace.`;return i?t.jsx(or,{rows:6}):t.jsxs("form",{onSubmit:k,children:[t.jsx(ir,{visible:l.hasConflict,onReload:l.reset}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:A})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsxs(Pe,{htmlFor:"name",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(rt,{id:"name",value:y,onChange:P=>c(P.target.value),placeholder:`Enter ${g.toLowerCase()} name`,autoFocus:!0})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(Pe,{htmlFor:"slug",children:"URL Slug"}),t.jsx("button",{type:"button",onClick:()=>p(!h),className:"text-xs text-muted-foreground hover:text-foreground",children:h?"Auto-generate":"Customize"})]}),h?t.jsx(rt,{id:"slug",value:x,onChange:P=>m(P.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):t.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:C||"slug-preview"})]}),w&&Object.keys(w).length>0?t.jsxs(t.Fragment,{children:[t.jsx(fa,{className:"my-2"}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(Pe,{className:"text-sm font-medium",children:"Additional Fields"}),t.jsx(ra,{schema:l.revision,values:v,onValuesChange:j,orgContext:s})]})]}):null,d&&t.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:d})]}),t.jsx(qn,{onCancel:e,cancelDisabled:N.isPending,className:"mt-2",children:t.jsx(Y,{type:"submit",disabled:!l.canSubmit||N.isPending||!y.trim(),children:N.isPending?"Creating...":`Create ${g}`})})]})}function Co(e){const n=e?.properties??{},s=ur(e);return Object.entries(n).flatMap(([a,r])=>{const i=s.find(m=>m.field===a);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a)||!r||r.const!==void 0||r["x-table-column"]!==!0&&r["x-facet"]!==!0&&!i)return[];const o=[r,...Array.isArray(r.anyOf)?r.anyOf:[]],l=i?.options??[],y=l.find(m=>m.value!==null)?.value,c=o.find(m=>["string","number","integer","boolean"].includes(String(m.type)))??(y===void 0?void 0:{type:typeof y});if(!c)return[];const x=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:a,label:String(r["x-table-label"]??r.title??a.replaceAll("_"," ")),type:x,options:x==="boolean"&&!l.some(m=>typeof m.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...l]:l}]})}function _o(e){const n=e?.[Yt];return n===void 0?{}:nn(n)}function Mo(e,n,s){try{const a=_o(n),r=e[es],i=r===void 0?void 0:a.presets?.find(x=>x.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 o=i&&e[tt]===void 0?{collection:jt(i)}:cr(e,s);if(o.error)throw o.error;const l=e[lr],y=l===void 0?i?.table??a.table??{}:nn({table:typeof l=="string"?JSON.parse(l):l}).table??{},c=!!i&&(Fn(o.collection)!==Fn(jt(i))||Mt(y)!==Mt(i.table??a.table??{}));return{...o,presentation:a,preset:i,table:y,edited:c}}catch(a){return{collection:{},presentation:{},table:{},edited:!1,error:a instanceof Error?a:new Error("Invalid collection configuration")}}}function Fn(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(wt)])}function wt(e){return JSON.stringify([e.field,e.op,e.value])}function Mt(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function To(e,n){return n?{[es]:n,[tt]:Kt(e)[tt]??"{}"}:Kt(e)}function Lo(e,n,s,a,r=new Date){let i=n.filters??[],o=e.relativeDate;if(o){const l=(jt({...e,selection:{}},r).filters??[]).map(wt),y=i.map(wt);l.every(c=>y.includes(c))?i=i.filter(c=>!l.includes(wt(c))):o=void 0}return{key:e.key,label:e.label,selection:{...n.search?{search:n.search}:{},...i.length?{filters:i}:{},...n.segment?{segment:n.segment}:{}},...Mt(s)!==Mt(a.table??{})?{table:s}:{},...o?{relativeDate:o}:{}}}function Ro(e,n,s){const a=[...e.filters??[]],r=s??(n.length===1&&n[0].op==="eq"?a.findIndex(o=>o.field===n[0].field&&o.op==="eq"):-1),i=r>=0?[...a.slice(0,r),...n,...a.slice(r+1)]:[...a,...n];return{...e,filters:mr({filters:i}).filters}}function Io(e,n){return{...e,filters:e.filters?.filter((s,a)=>a!==n)}}function Oo(e,n){return{...typeof e.$preset=="string"?e[tt]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[tt]:String(dr(e[tt]))}:Kt(n),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const $o=[{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 Ao(e){return e.sort&&$o.some(n=>n.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Po(e,n,s,a,r){const i={...a,filters:a.filters?.filter(o=>o.field!==s)};return ts({queryKey:["collection-facets",e,n,s,i],enabled:!!n&&!!s,staleTime:3e4,retry:!1,queryFn:async({signal:o})=>{const l=await Nt("query_sdk",{title:`Value counts query for ${s}`,script:`const input = ${JSON.stringify({field:s,collection:i})};
|
|
2
|
+
${n}`},e,{signal:o}),y=l.return_value;if(!l.success||typeof y?.connection!="string"||typeof y.sql!="string")throw new Error(l.error?.message??"Value distribution is unavailable");if(o.aborted)throw new DOMException("Aborted","AbortError");const c=await Nt("query_sql",{title:`Value counts for ${s}`,connection:y.connection,sql:y.sql,limit:51},e,{signal:o});if(c.error)throw new Error(c.error);if(!Array.isArray(c.rows))throw new Error("Source did not return value counts");const x=c.rows.map(m=>{const h=m,p=typeof h.count=="string"&&/^\d+$/.test(h.count)?Number(h.count):h.count;if(!(h.value===null||["string","number","boolean"].includes(typeof h.value))||typeof p!="number"||!Number.isSafeInteger(p)||p<0)throw new Error("Source returned an invalid value distribution");return{value:h.value,count:p}});return{values:x.slice(0,50),truncated:x.length>50||c.truncated===!0}}})}const Do=300;function Fo({label:e,search:n,onSearch:s,className:a}){const r=n??"",[i,o]=b.useState(r),l=b.useRef({search:n,onSearch:s});l.current={search:n,onSearch:s};const y=b.useRef(void 0);b.useEffect(()=>{const x=()=>{clearTimeout(y.current),o(l.current.search??"")};return window.addEventListener("popstate",x),()=>window.removeEventListener("popstate",x)},[]);const c=b.useRef(r);return b.useEffect(()=>{r!==c.current&&(c.current=r,o(r))},[r]),b.useEffect(()=>{if(i===(l.current.search??""))return;const x=setTimeout(()=>{const m=l.current.onSearch;c.current=i,m(i||void 0,!0)},Do);return y.current=x,()=>clearTimeout(x)},[i]),t.jsxs("div",{className:`relative${a?` ${a}`:""}`,children:[t.jsx(hr,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(rt,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:i,onChange:x=>o(x.target.value),className:"pl-9"})]})}const zo={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Wo({field:e,initial:n,org:s,facetQuery:a,collection:r,onApply:i,close:o}){const[l,y]=b.useState(n?.op??"eq"),[c,x]=b.useState(n?.value==null?"":String(n.value)),[m,h]=b.useState(""),[p,v]=b.useState(!1),[j,d]=b.useState(),S=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",N=Po(s,a,e.field,r),C=w=>{try{const M=p?[{field:e.field,op:"gte",value:e.type==="number"?Number(c):c},{field:e.field,op:"lte",value:e.type==="number"?Number(m):m}]:[{field:e.field,op:l,value:w}];if(e.type==="datetime-local")for(const D of M)typeof D.value=="string"&&(D.value=new Date(D.value).toISOString());if(M.some(D=>typeof D.value=="number"&&!Number.isFinite(D.value)))throw new Error("Enter a valid number.");const A=M[0].value,P=M[1]?.value;if(p&&A!=null&&P!=null&&A>P)throw new Error("The lower bound must be before the upper bound.");i(M),o()}catch(M){d(M instanceof Error?M.message:"Could not apply filter")}},k=[...e.options];for(const w of N.data?.values??[])k.some(M=>M.value===w.value)||k.push({value:w.value,label:w.value===null?"Not supplied":String(w.value)});const g=Math.max(1,...N.data?.values.map(w=>w.count)??[]);return t.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[t.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:p?"range":l,onChange:w=>{v(w.target.value==="range"),w.target.value!=="range"&&y(w.target.value)},children:[t.jsx("option",{value:"eq",children:"is"}),t.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&t.jsxs(t.Fragment,{children:[t.jsx("option",{value:"lt",children:"less than / before"}),t.jsx("option",{value:"lte",children:"at most / on or before"}),t.jsx("option",{value:"gt",children:"greater than / after"}),t.jsx("option",{value:"gte",children:"at least / on or after"}),n?null:t.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&t.jsxs("form",{className:"space-y-2",onSubmit:w=>{w.preventDefault(),C(e.type==="number"?Number(c):c)},children:[t.jsx(rt,{required:!0,"aria-label":p?"From value":"Filter value",type:S,step:e.type==="number"?"any":void 0,value:c,onChange:w=>x(w.target.value),placeholder:"Enter a value…"}),p&&t.jsx(rt,{required:!0,"aria-label":"To value",type:S,step:e.type==="number"?"any":void 0,value:m,onChange:w=>h(w.target.value)}),t.jsx(Y,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!p&&(l==="eq"||l==="neq")&&t.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=N.data?.values.find(A=>A.value===w.value)?.count;return t.jsxs("button",{type:"button","aria-label":w.label,onClick:()=>C(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&&t.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${M/g*100}%`}}),t.jsx("span",{className:"relative truncate",children:w.label}),t.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:M?.toLocaleString()})]},JSON.stringify(w.value))})}),a&&N.isFetching&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),N.isError&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),N.data?.truncated&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),j&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:j})]})}function Bo({choices:e,visible:n,onChange:s}){return t.jsxs(sn,{children:[t.jsx(rn,{asChild:!0,children:t.jsx(Y,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground","aria-label":"Choose columns",title:"Choose columns",children:t.jsx(ns,{className:"h-4 w-4"})})}),t.jsxs(an,{align:"end",className:"max-h-80 overflow-y-auto p-3",children:[t.jsx("p",{className:"mb-2 text-sm font-medium",children:"Visible columns"}),e.map(a=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 py-1.5 text-sm",children:[t.jsx("input",{type:"checkbox",checked:!n||n.includes(a.field),onChange:r=>{const i=n??e.map(o=>o.field);s(r.target.checked?[...i,a.field]:i.filter(o=>o!==a.field))}}),a.label]},a.field))]})]})}function Ho({collection:e,schema:n,label:s,onChange:a,org:r,facetQuery:i,segmentChip:o,viewFilters:l,onClearAll:y}){const c=Co(n),x=(v,j)=>({kind:"custom",className:"w-80",render:d=>t.jsx(Wo,{field:v,initial:j==null?void 0:e.filters?.[j],org:r,facetQuery:i,collection:e,onApply:S=>a(Ro(e,S,j)),close:d})}),m=c.map(v=>({key:v.field,label:v.label,icon:t.jsx(fr,{className:"h-4 w-4"}),editor:x(v)})),h=new Map,p=(e.filters??[]).map((v,j)=>{const d=`${v.field}:${v.op}:${JSON.stringify(v.value)}`,S=h.get(d)??0;h.set(d,S+1);const N=c.find(k=>k.field===v.field),C=N?.options.find(k=>k.value===v.value)?.label??String(v.value??"Not supplied");return{id:`${d}:${S}`,label:N?.label??v.field,op:zo[v.op],value:C,editor:N?x(N,j):void 0,onRemove:()=>a(Io(e,j))}});if(o&&p.unshift(o),l?.fields.length){for(const v of m)v.group=s;m.push(...l.fields),p.push(...l.chips)}return!m.length&&!p.length?null:t.jsx(ha,{label:`${s} filters`,fields:m,chips:p,onClearAll:y??(()=>a({...e,filters:[],segment:void 0}))})}const Tt=120,Te=12;function zn(e,n){return typeof e.linkId=="number"&&typeof n.linkId=="number"?e.linkId-n.linkId:String(e.linkId).localeCompare(String(n.linkId))}function Vo(e){const n=e.records.slice(0,Tt),s=c=>e.types.get(c)??{label:c},a=new Map;for(const c of n)a.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(!a.has(String(c.recordId)))continue;const x=r.get(c.recordId)??new Map;x.set(c.linkId,c),r.set(c.recordId,x)}const i=new Map;for(const[c,x]of r){const m=[...x.values()].sort(zn),h=a.get(String(c));h&&m.length>Te&&(h.hasMoreLinks=!0);for(const p of m.slice(0,Te)){i.set(p.linkId,p);const v=String(p.peer.id);a.has(v)||a.set(v,{source:p.peer.source,entityType:p.peer.type,slug:p.peer.slug,name:p.peer.name,isFocus:!1,hasMoreLinks:!1})}}const o=[];for(const[c,x]of a){const m=s(x.entityType),h=x.name||x.slug,p=x.hasMoreLinks?`${m.label} · ${Te}+ links`:m.label;o.push({id:c,data:{slug:x.slug,label:h,icon:m.icon,isSystem:!1,metaLabel:p},width:ft(h,p),height:st})}const l=new Map;for(const c of[...i.values()].sort(zn)){const x=String(c.fromId),m=String(c.toId),h=JSON.stringify([x,m]),p=l.get(h)??{source:x,target:m,rels:new Map,symmetric:!0};p.symmetric&&=c.isSymmetric,p.rels.has(c.relSlug)||p.rels.set(c.relSlug,{slug:c.relSlug,label:c.relName,ruleCount:1}),l.set(h,p)}const y=[...l.entries()].map(([c,x])=>({id:`link:${c}`,source:x.source,target:x.target,data:{relationships:[...x.rels.values()],isSymmetric:x.symmetric}}));return{nodes:o,edges:y,records:a,hasMoreRecords:e.hasMore===!0||e.records.length>Tt,listedCount:n.length,focusCount:n.length}}async function Uo(e,n){const s=Vo(e);return{...await ln({nodes:s.nodes,edges:s.edges},n),records:s.records,hasMoreRecords:s.hasMoreRecords,listedCount:s.listedCount,focusCount:s.focusCount}}const qo=8,Go=3,Ko=4;function kt(e){return`source:${JSON.stringify([e.type,e.key])}`}function Yo(e,n){return n.map(s=>{const a={type:e,key:s.slug};return{...s,id:kt(a),source:a}})}function Wn(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Jo(e,n,s){const a=e.slice(0,qo),r=[];let i=0;return await Promise.all(Array.from({length:Math.min(Go,a.length)},async()=>{for(;i<a.length;){const o=i++,l=a[o];try{if(s?.aborted)throw s.reason;const y=await n(l),c=new Map(l.links.map(d=>[Wn(d),d]));for(const d of y.record_links){const S=Wn(d),N=c.get(S);(!N||N.occurred_at<d.occurred_at)&&c.set(S,d)}const x=new Map((l.relationships??[]).map(d=>[d.id,d]));for(const d of y.relationships??[])x.set(d.id,d);const m=[...x.values()].slice(0,Te+1),h=[...c.values()].slice(0,Te+1),p=(l.pagesRead??0)+1,v=!!y.next_cursor&&p>=Ko,j=y.record_failures.length>0||!!y.relationship_failures?.length||v;r[o]={read:{record:l.record,links:h,failed:j,entityId:l.entityId,relationships:m},...!v&&(j||y.next_cursor&&h.length+m.length<=Te)?{next:{record:l.record,entityId:l.entityId,relationships:m,pagesRead:p,cursor:y.next_cursor??l.cursor,links:h}}:{}}}catch(y){if(s?.aborted)throw y;r[o]={read:{record:l.record,links:l.links,failed:!0,entityId:l.entityId,relationships:l.relationships},next:{...l,cursor:y instanceof pr&&y.status===400?null:l.cursor}}}}})),{reads:r.map(o=>o.read),pending:[...r.flatMap(o=>o.next?[o.next]:[]),...e.slice(a.length)]}}function Qo(e,n){const s=new Map;for(const i of e)for(const o of i.reads)s.set(String(o.entityId??kt(o.record)),o);const a=new Map(n.map(i=>[i.slug,i])),r=[];for(const[i,o]of s){for(const l of o.relationships??[]){const y=(j,d)=>typeof j=="number"?j:kt({type:d,key:j}),c=y(l.from_entity_id,l.from_entity_type),x=y(l.to_entity_id,l.to_entity_type),m=String(c)===i,h=m?x:c,p=m?l.to_entity_id:l.from_entity_id,v=(m?l.to_entity_type:l.from_entity_type)??"";r.push({recordId:i,linkId:l.id,fromId:c,toId:x,relSlug:l.relationship_type_slug,relName:l.relationship_type_name,isSymmetric:l.is_symmetric,peer:{id:h,name:(m?l.to_entity_name:l.from_entity_name)??String(p),slug:(m?l.to_entity_slug:l.from_entity_slug)??String(p),type:v,...typeof p=="string"?{source:{type:v,key:p}}:{}}})}for(const l of o.links){const y={type:l.entity_type,key:l.key},c=kt(y),x=a.get(l.relationship_type);let m=l.direction==="incoming"?c:i,h=l.direction==="incoming"?i:c;x?.is_symmetric&&m>h&&([m,h]=[h,m]),r.push({recordId:i,linkId:JSON.stringify([m,h,l.relationship_type]),fromId:m,toId:h,relSlug:l.relationship_type,relName:x?.name||l.relationship_type.replaceAll("_"," "),isSymmetric:x?.is_symmetric??!1,peer:{id:c,name:l.name||l.key,slug:l.key,type:l.entity_type,source:y}})}}return{links:r,checked:s.size,failed:[...s.values()].filter(i=>i.failed).length}}function Xo(e,n,s,a,r,i=!1){const{orgContext:o}=De(),l=It(o),y=en(o),c=b.useMemo(()=>i?Yo(n,s):s,[i,n,s]),x=b.useMemo(()=>c.slice(0,Tt).flatMap(k=>k.source?[{record:k.source,cursor:null,links:[]}]:typeof k.id=="number"?[{entityId:k.id,record:{type:n,key:k.slug},cursor:null,links:[]}]:[]),[c,n]),m=gr({queryKey:["source-records-graph",o.organizationId,e,n,x.map(k=>[k.record,k.entityId])],enabled:!0,initialPageParam:x,queryFn:({pageParam:k,signal:g})=>Jo(k,async w=>{const M=await Nt("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:Te+1},e,{signal:g});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)+Te+1):null}},g),getNextPageParam:k=>k.pending.length?k.pending:void 0,staleTime:3e4,retry:!1}),h=b.useMemo(()=>m.data?Qo(m.data.pages,y.data??[]):void 0,[m.data,y.data]),p=h?.links,v=m.isError,j=JSON.stringify([o.organizationId,e,n,i,c.map(k=>[k.id,k.name,k.slug]),a]),d=b.useMemo(()=>new Map((l.data??[]).map(k=>[k.slug,{label:k.name||k.slug,icon:k.icon}])),[l.data]),[S,N]=b.useState(null);b.useEffect(()=>{if(!p)return;let k=!1;return Uo({typeSlug:n,records:c,hasMore:a,links:p,types:d},{targetAspect:r}).then(g=>{k||N({graph:g,key:j,isError:!1})}).catch(()=>{k||N({graph:null,key:j,isError:!0})}),()=>{k=!0}},[p,n,c,a,d,r,j]);const C=S?.key===j?S:null;return{graph:C?.graph??null,isLoading:!v&&!C,isError:v||C?.isError===!0,sourceProgress:{checked:h?.checked??0,total:Math.min(s.length,Tt),failed:h?.failed??0,hasMore:!!m.hasNextPage,isFetching:m.isFetching,loadMore:()=>{m.isFetching||m.fetchNextPage()}}}}function Zo(e){const n=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})),a=e.edges.map(r=>{const{relationships:i,isSymmetric:o}=r.data,l=i.map(y=>y.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:!o,ariaLabel:`${n.get(r.source)??r.source} ${o?"and":"to"} ${n.get(r.target)??r.target}: ${l.join(", ")}`}});return{boxes:s,edges:a}}function ei({ownerSlug:e,typeSlug:n,records:s,hasMore:a,sourceBacked:r=!1}){const i=at(),o=tn(),{orgContext:l}=De(),{data:y=[]}=It(l),c=y.find(g=>g.slug===n)?.name??n,[x,m]=b.useState(),h=b.useRef(null),p=b.useCallback(g=>{if(h.current?.disconnect(),h.current=null,!g||typeof ResizeObserver>"u")return;const w=()=>{if(!g.clientWidth||!g.clientHeight)return;const A=Math.round(g.clientHeight/g.clientWidth*10)/10;m(P=>P===A?P:A)};w();const M=new ResizeObserver(w);M.observe(g),h.current=M},[]),{graph:v,isLoading:j,isError:d,sourceProgress:S}=Xo(e,n,s,a,x,r),N=b.useMemo(()=>v?Zo(v):null,[v]),C=b.useCallback(g=>{const w=v?.records.get(g);if(w){if(o){o.open(oa({...w.source?{record:w.source}:{entityId:Number(g)},ownerSlug:e,orgContext:l,name:w.name||w.slug}));return}i({to:ss(e,[{entity_type:w.entityType,slug:w.slug}])})}},[v,e,l,o,i]);if(d)return t.jsx(Qn,{label:`${c} graph`});if(j||!v||!N)return t.jsx(cn,{label:`Loading ${c} graph`});const k=S?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[t.jsxs("p",{children:["Checked ",S.checked," of ",S.total," records. Up to ",Te," relationships per record."]}),S.failed>0?t.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),S.hasMore?t.jsx(Y,{variant:"outline",size:"sm",disabled:S.isFetching,onClick:S.loadMore,children:S.isFetching?"Loading…":S.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return v.focusCount===0?t.jsxs("div",{className:"space-y-3",children:[k,t.jsx(rs,{icon:as,title:`No ${c} records match`,description:"Change the search or filters to see records here."})]}):t.jsxs("div",{className:"flex flex-col gap-2",children:[k,t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",v.hasMoreRecords?"the first ":"",v.focusCount," ",c," record",v.focusCount===1?"":"s",". Click a record to see it."]}),t.jsx("div",{ref:p,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:t.jsx(gs,{boxes:N.boxes,edges:N.edges,label:`${c} records`,onOpenBox:C,openLabel:g=>`Show ${g.title}`})})]})}function ti({direction:e}){return e?t.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("title",{children:e==="asc"?"Sort ascending":"Sort descending"}),e==="asc"?t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}):t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})]}):t.jsxs("svg",{className:"h-4 w-4 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[t.jsx("title",{children:"Sort"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})]})}function Ze({column:e,children:n,alignRight:s=!1}){return t.jsxs("button",{type:"button",className:`flex items-center gap-1.5 whitespace-nowrap text-left transition-colors hover:text-foreground [&>svg]:shrink-0${s?" ml-auto":""}`,onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:[n,t.jsx(ti,{direction:e.getIsSorted()})]})}function Qt(e,n,s){const a=os(e?.properties).filter(([i,o])=>(!n||i!=="name")&&!o["x-image"]&&o["x-table-column"]===!0);if(a.length)return a.map(([i,o])=>({field:i,label:o["x-table-label"]??qe(i.replaceAll("_"," "))}));if(!n)return[];const r=s.find(i=>Object.keys(Ee(i.metadata)).length>0);return Object.keys(Ee(r?.metadata)).filter(i=>i!=="id"&&i!=="slug"&&i!=="name"&&!yr(e?.properties?.[i])).map(i=>({field:i,label:qe(i.replaceAll("_"," "))}))}function ni(e){return e.some(n=>Object.hasOwn(Ee(n.metadata),"name"))}function si(e,n){return nt(e,Ot(n))}function ri(e){return`${e.entityType}:${e.lookupField}`}const ai=new Set(["stage","category","round_type","investor_type"]);function oi(e,n){const s=e.toLowerCase();return s==="mrr"||s==="arr"||s==="revenue"||s==="valuation"||s==="funding_raised"||s==="fund_size"||s.endsWith("_usd")||n.description?.toLowerCase().includes("usd")===!0}function ii(e,n){if(oi(e,n))return"currency";if(ai.has(e)||e.endsWith("_slug"))return"enum"}function ci({entities:e,owner:n,schema:s,entityTypeIcon:a,isDerived:r,measureColumns:i,linkedEntityLookups:o,hasAnyParents:l,sorting:y,onSortingChange:c,visibleColumns:x,columnChoices:m,onVisibleColumnsChange:h,page:p,pageSize:v,totalCount:j,hasMore:d,pageTitle:S,onPrevPage:N,onNextPage:C}){const k=m?.length&&h?t.jsx(Bo,{choices:m,visible:x,onChange:h}):null,g=s?.properties,w=!r||ni(e),M=b.useMemo(()=>g?Object.fromEntries(Object.entries(g).flatMap(([O,I])=>I["x-link-entity-type"]?[[O,{entityType:I["x-link-entity-type"],lookupField:I["x-link-lookup-field"]||"slug"}]]:[])):{},[g]),A=b.useMemo(()=>g?Qt({properties:g},r,[]).map(({field:I})=>[I,g[I]]).map(([I,U])=>{const H=M[I],W=H?o[ri(H)]:void 0;return{id:r?I:`meta_${I}`,accessorFn:Q=>{const re=Ee(Q.metadata);return ia(re[I],U.enum)},header:({column:Q})=>{const re=U["x-table-label"]||U.title||U.description||qe(I.replace(/_/g," "));return r?t.jsx(Ze,{column:Q,children:re}):re},cell:({getValue:Q})=>t.jsx(jn,{value:Q(),prop:U,format:ii(I,U),className:"text-muted-foreground",resolveLink:W?re=>{const pe=W[re];return pe?{label:pe.name,to:nt(n,[{entity_type:pe.entity_type,slug:pe.slug}])}:void 0}:void 0})}}):[],[r,M,o,n,g]),P=b.useMemo(()=>new Set(i),[i]),D=b.useMemo(()=>!r||A.length>0?[]:Qt({properties:g},!0,e).map(({field:I})=>I).map(I=>{const U=P.has(I);return{id:I,accessorFn:H=>Ee(H.metadata)[I],header:({column:H})=>t.jsxs(Ze,{column:H,children:[U?I:qe(I.replace(/_/g," ")),U&&t.jsx(ht,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]}),cell:({getValue:H})=>t.jsx(jn,{value:H(),prop:g?.[I],className:U?"tabular-nums":"text-muted-foreground"}),meta:U?{align:"right"}:void 0}}),[r,A,e,P,g]),J=b.useMemo(()=>{const O=s?.["x-table-relationships"];return!O||O.length===0?[]:O.map(I=>({id:`rel_${I.relationship_type}`,accessorFn:U=>U.relationships?.[I.relationship_type]??[],header:I.label,cell:({getValue:U})=>{const H=U();return!H||H.length===0?t.jsx("span",{className:"text-muted-foreground",children:"-"}):t.jsx("div",{className:"flex flex-wrap gap-1",children:H.map((W,Q)=>{const re=nt(n,[{entity_type:W.entity_type,slug:W.slug}]);return t.jsxs("span",{children:[t.jsx(we,{to:re,className:"text-primary hover:underline",onClick:pe=>pe.stopPropagation(),children:W.name}),Q<H.length-1&&","]},W.id)})})}}))},[n,s]),q=b.useMemo(()=>l||e.some(I=>I.parent_name&&I.parent_slug&&I.parent_entity_type)?[{id:"parent",accessorFn:I=>I.parent_name,header:"Parent",cell:({row:I})=>{if(!I.original.parent_name||!I.original.parent_slug||!I.original.parent_entity_type)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const U=nt(n,[{entity_type:I.original.parent_entity_type,slug:I.original.parent_slug}]);return t.jsx(we,{to:U,className:"text-primary hover:underline",children:I.original.parent_name})}}]:[],[e,l,n]),se=b.useMemo(()=>{const O=[],I=e.some(W=>(W.total_content??0)>0),U=e.some(W=>(W.active_connections??0)>0),H=e.some(W=>(W.automations_count??0)>0);return I&&O.push({accessorKey:"total_content",header:({column:W})=>t.jsx(Ze,{column:W,alignRight:!0,children:"Activity"}),cell:({row:W,getValue:Q})=>{const re=Q()??0;if(re===0)return t.jsx("span",{className:"tabular-nums",children:"0"});const pe=Ot(W.original);return t.jsx(we,{to:ss(n,pe),className:"tabular-nums hover:underline",children:re})},meta:{align:"right"}}),U&&O.push({accessorKey:"active_connections",header:"Connectors",cell:({getValue:W})=>{const Q=W();return Q&&Q>0?t.jsxs(ht,{variant:"outline",className:"text-green-600 dark:text-green-400",children:[Q," active"]}):t.jsx("span",{className:"text-muted-foreground",children:"-"})},meta:{align:"right"}}),H&&O.push({accessorKey:"automations_count",header:({column:W})=>t.jsx(Ze,{column:W,alignRight:!0,children:"Automations"}),cell:({getValue:W})=>t.jsx("span",{className:"tabular-nums",children:W()??0}),meta:{align:"right"}}),O},[e,n]),V=b.useMemo(()=>[{accessorKey:"name",header:({column:O})=>w?t.jsx(Ze,{column:O,children:"Name"}):"Name",cell:({row:O})=>{const I=Ee(O.original.metadata);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(on,{metadata:I,metadataSchema:s,name:O.original.name,typeIcon:a,className:"h-6 w-6 shrink-0"}),t.jsx("div",{className:"min-w-0",children:(()=>{const U=si(n,O.original);return t.jsx(we,{to:U,className:"block max-w-56 truncate font-medium hover:underline",title:O.original.name,children:O.original.name})})()})]})}},...q,...A,...D,...J,...se,...r?[]:[{accessorKey:"created_at",header:({column:O})=>t.jsx(Ze,{column:O,children:"Created"}),cell:({getValue:O})=>t.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:new Date(O()).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})}]],[n,q,A,D,J,se,s,a,r,w]),ne=ca({data:e,columns:V,state:{sorting:y,columnVisibility:Object.fromEntries([...A,...D].flatMap(O=>O.id?[[O.id,!x||x.includes(r?O.id:O.id.replace(/^meta_/,""))]]:[]))},onSortingChange:c,getCoreRowModel:la(),manualSorting:!0,enableSortingRemoval:!1}),he=e.length>0||p>0;return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"rounded-lg border",children:t.jsxs(pa,{className:"min-w-[48rem]",children:[t.jsx(ga,{children:ne.getHeaderGroups().map(O=>t.jsxs(Vt,{children:[O.headers.map(I=>t.jsx(Sn,{"aria-sort":I.column.getIsSorted()==="asc"?"ascending":I.column.getIsSorted()==="desc"?"descending":void 0,className:I.column.columnDef.meta?.align==="right"?"text-right":"",children:I.isPlaceholder?null:Nn(I.column.columnDef.header,I.getContext())},I.id)),k?t.jsx(Sn,{className:"w-10 pr-2 text-right",children:k}):null]},O.id))}),t.jsx(ya,{children:ne.getRowModel().rows.length?ne.getRowModel().rows.map(O=>t.jsxs(Vt,{children:[O.getVisibleCells().map(I=>t.jsx(Ut,{className:I.column.columnDef.meta?.align==="right"?"whitespace-nowrap text-right":"",children:Nn(I.column.columnDef.cell,I.getContext())},I.id)),k?t.jsx(Ut,{}):null]},O.id)):t.jsx(Vt,{children:t.jsx(Ut,{colSpan:V.length+(k?1:0),className:"h-24 text-center",children:"No results found."})})})]})}),he&&t.jsxs("div",{className:"mt-4 flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:["Showing ",e.length," of ",j," ",S.toLowerCase()]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["Page ",p+1," of ",Math.max(1,Math.ceil(j/v))]}),t.jsx(Y,{variant:"outline",size:"sm",onClick:N,disabled:p===0,children:"Previous"}),t.jsx(Y,{variant:"outline",size:"sm",onClick:C,disabled:!d,children:"Next"})]})]})]})}function li(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function ks(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function un(e){const n=e?.properties;if(!n)return null;const r=os(n).find(([,c])=>ks(c)==="workflowState");if(!r)return null;const[i,o]=r,l=o["x-lobu"]?.states,y=Array.isArray(l)&&l.length>0?l:(o.enum??[]).map(c=>({value:c}));return y.length===0||y.some(c=>typeof c.value!="string")?null:{field:i,states:y.map(c=>({...c,label:c.label||xr(o,c.value)||li(c.value),terminal:c.terminal??["done","complete","completed","closed","archived"].includes(c.value.toLowerCase())}))}}function di(e){const n=e?.properties;if(!n)return null;const s=Object.entries(n),a=s.find(([,o])=>ks(o)==="sortRank"),r=s.find(([o])=>["rank","sort_rank","order"].includes(o)),i=a??r;return i?{field:i[0]}:null}function ui(e,{isDerived:n}){const s=e?.["x-lobu"]?.defaultView;return(s==="table"||s==="board")&&!(n&&s!=="table")?s:n?"table":un(e)?"board":"table"}const js={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},mi={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function fi(e){const{canShowBoard:n,builtinData:s,builtInLabels:a}=e,r=["table",...n?["board"]:[]],i={table:js,board:mi};return r.map(o=>({id:o,label:a[o],builtInMode:o,template:i[o],data:s}))}function Xt(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Lt(e,n){if(!n)return e.created_at??String(e.id);const s=Ee(e.metadata);return String(s[n.field]??e.created_at??e.id)}function hi(e,n){const s=e?Number(e):Number.NaN,a=n?Number(n):Number.NaN;return Number.isFinite(s)&&Number.isFinite(a)&&s<a?String((s+a)/2):Number.isFinite(s)?String(s+1):Number.isFinite(a)?String(a-1):String(Date.now())}function Zt(e,n){const s=Ee(e.metadata);return String(s[n]??"")}function Ns(e,n){return[...e].sort((s,a)=>Lt(s,n).localeCompare(Lt(a,n)))}function pi(e,n,s,a,r){if(!n.startsWith("card:")||!s)return null;const i=Number(n.slice(5)),o=e.find(N=>N.id===i);if(!o)return null;const l=s.startsWith("column:")?s.slice(7):Zt(e.find(N=>`card:${N.id}`===s)??o,a.field);if(!l)return null;const y=Ns(e.filter(N=>N.id!==i&&Zt(N,a.field)===l),r),c=s.startsWith("card:")?y.findIndex(N=>`card:${N.id}`===s):y.length,x=c>=0?c:y.length,m=x>0?y[x-1]:void 0,h=y[x],p=r?hi(m?Lt(m,r):void 0,h?Lt(h,r):void 0):void 0,v=Ee(o.metadata),j={[a.field]:l,...r&&p?{[r.field]:p}:{}};a.states.find(N=>N.value===l)?.terminal&&!v.completed_at&&(j.completed_at=new Date().toISOString());const S={...v,...j};return{entityId:i,changedMetadata:j,nextMetadata:S}}function Bn(e,n,s){return e.map(a=>a.id===n?{...a,metadata:s}:a)}function gi({id:e,children:n,className:s}){const{setNodeRef:a,isOver:r}=ms({id:`column:${e}`});return t.jsx("div",{ref:a,className:de("min-h-[220px] rounded-lg bg-card p-2 transition-colors",r?"bg-accent/50":"",s),children:n})}function yi({entity:e,owner:n,statusField:s,entityTypeIcon:a,schema:r,didDragRef:i}){const o=Ee(e.metadata),{attributes:l,listeners:y,setNodeRef:c,transform:x,isDragging:m}=ka({id:`card:${e.id}`}),{setNodeRef:h,isOver:p}=ms({id:`card:${e.id}`}),v=nt(n,Ot(e)),j=d=>{i.current&&(d.preventDefault(),d.stopPropagation())};return t.jsx("div",{ref:d=>{c(d),h(d)},style:{transform:ja.Translate.toString(x)},className:de(wr,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",m?"opacity-60":"",p?"ring-1 ring-ring":""),children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.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,...y,children:t.jsx(vr,{className:"h-4 w-4"})}),t.jsx(on,{metadata:o,metadataSchema:r,name:e.name,typeIcon:a,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(we,{to:v,className:"font-medium text-foreground hover:underline",onClick:j,children:e.name}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof o.priority=="string"&&o.priority?t.jsx(ht,{variant:"outline",className:"text-xs",children:Xt(o.priority)}):null,typeof o[s]=="string"&&o[s]?t.jsx(ht,{variant:"secondary",className:"text-xs",children:Xt(String(o[s]))}):null]})]})]})})}function xi({owner:e,entities:n,totalCount:s,schema:a,entityTypeIcon:r,onUpdate:i}){const o=b.useMemo(()=>un(a),[a]),l=b.useMemo(()=>di(a),[a]),[y,c]=b.useState(n),[x,m]=b.useState(()=>new Set),h=b.useRef(!1),p=xa(ba(wa,{activationConstraint:{distance:6}})),v=b.useCallback(()=>{window.setTimeout(()=>{h.current=!1},0)},[]);b.useEffect(()=>{c(n)},[n]);const j=b.useMemo(()=>{if(!o)return new Map;const C=new Map(o.states.map(k=>[k.value,[]]));for(const k of y){const g=Zt(k,o.field),w=C.has(g)?g:o.states[0]?.value;w&&C.get(w)?.push(k)}for(const[k,g]of C)C.set(k,Ns(g,l));return C},[y,l,o]);if(!o)return null;const d=C=>{m(k=>{const g=new Set(k);return g.has(C)?g.delete(C):g.add(C),g})},S=()=>{h.current=!0},N=C=>{const k=String(C.active.id),g=C.over?String(C.over.id):null,w=pi(y,k,g,o,l);if(!w){v();return}const{entityId:M,changedMetadata:A,nextMetadata:P}=w,J=y.find(q=>q.id===M)?.metadata;c(q=>Bn(q,M,P)),i(M,A).catch(()=>{c(q=>Bn(q,M,J))}),v()};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Board"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",Xt(o.field),typeof s=="number"&&s>y.length?t.jsxs(t.Fragment,{children:[" · ",t.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",y.length," of ",s," — narrow with search"]})]}):null]})]}),t.jsx(va,{sensors:p,onDragStart:S,onDragEnd:N,children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:o.states.map(C=>{const k=j.get(C.value)??[],g=C.collapsed??C.terminal,w=g&&!x.has(C.value);return t.jsxs(gi,{id:C.value,children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[C.terminal?t.jsx(br,{className:"h-4 w-4 text-muted-foreground"}):null,t.jsx("h3",{className:"text-sm font-medium",children:C.label})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(ht,{variant:"secondary",className:"text-xs",children:k.length}),g?t.jsx(Y,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>d(C.value),children:w?"Show":"Hide"}):null]})]}),w?t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[k.length," hidden ",C.label?.toLowerCase()," item",k.length===1?"":"s"]}):t.jsx("div",{className:"space-y-2",children:k.length>0?k.map(M=>t.jsx(yi,{entity:M,owner:e,statusField:o.field,entityTypeIcon:r,schema:a,didDragRef:h},M.id)):t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",C.label?.toLowerCase()," items"]})})]},C.value)})})})]})}const bi=b.memo(xi);function vi(e){let n=0;for(let s=0;s<e.length;s++)n=(n<<5)-n+e.charCodeAt(s),n|=0;return n.toString(36)}function Ss(e,n){return{queryKey:["metric_series",e,vi(n)],queryFn:()=>Nt("metric_series",{sql:n},{slug:e}),staleTime:6e4}}function Es(e,n){const s=!!e&&!!n,a=Ss(e??"",n??"");return ts({...a,enabled:s})}Es.queryOptions=(e,n)=>Ss(e,n);function wi(e,n){if(!e?.columns?.length||!e.rows)return[];const s=e.columns.indexOf(n);return s<0?[]:e.rows.map(a=>Number(a[s])||0)}const Hn=/^[a-z][a-z0-9_]*$/;function ki(e){const n=Object.entries(e);for(const[r,i]of n){if(!Hn.test(r))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${r}'`);if(!Hn.test(i))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${i}'`)}const s=n.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
|
+
`),a=n.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
|
+
${a}
|
|
33
|
+
FROM days d
|
|
34
|
+
LEFT JOIN buckets b ON b.bucket = d.bucket
|
|
35
|
+
ORDER BY d.bucket
|
|
36
|
+
`}const ji={"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 Ni(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const n=Object.fromEntries(Object.entries(e.lifecycle).map(([s,a])=>[s,String(a)]));if(Object.keys(n).length>0)try{return ki(n)}catch{return null}}return typeof e.preset=="string"?ji[e.preset]??null:null}function Si({owner:e,sql:n,lifecycle:s,preset:a,column:r,chart:i,height:o,width:l,color:y,label:c,className:x}){const m=b.useMemo(()=>Ni({sql:n,lifecycle:s,preset:a}),[n,s,a]),h=typeof e=="string"&&e?e:null,{data:p}=Es(h,m),v=String(r??""),j=b.useMemo(()=>wi(p,v),[p,v]),d=b.useMemo(()=>!p?.columns?.length||!p.rows?[]:p.rows.map((N,C)=>({label:String(N[0]??"").slice(0,10),value:j[C]??0})),[p,j]);if(!h||!m||!v)return null;const S=i==="line"?t.jsx(da,{data:d,height:typeof o=="number"?o:void 0}):t.jsx(ua,{data:j,height:typeof o=="number"?o:void 0,width:typeof l=="number"?l:void 0,color:typeof y=="string"?y:void 0});return c==null?t.jsx("div",{className:x,children:S}):t.jsxs("div",{className:x,children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:String(c)}),S]})}function Ei({metadata:e,metadataSchema:n,name:s,typeIcon:a,initialsFallback:r,className:i}){return t.jsx(on,{metadata:e,metadataSchema:n,name:String(s??""),typeIcon:a,initialsFallback:!!r,className:i})}function Ci({entity:e,owner:n,className:s,onClick:a,children:r}){const i=e;if(!i)return t.jsx(t.Fragment,{children:r});const o=nt(String(n??""),Ot(i));return t.jsx(we,{to:o,className:s,onClick:a,children:r})}function _i({state:e}){return e?t.jsx(ci,{...e}):null}function Mi({state:e,onUpdate:n}){return e?t.jsx(bi,{...e,onUpdate:n}):null}const Ti={"entity-avatar":Ei,"entity-link":Ci,"entity-table":_i,"entity-board":Mi,"metric-series":Si};function Li({ownerSlug:e,typeSlug:n,title:s,shape:a}){const[r,i]=b.useState(!1),o=at(),{visible:l,system:y,isTypesLoading:c}=kr(e),x=h=>{i(!1);const p=`/${e}/${cs(h)}`;o({to:a?`${p}/${ls}/${a}`:p})},m=h=>t.jsxs(Mr,{value:`${h.name} ${h.slug}`,onSelect:()=>x(h.slug),children:[t.jsx(Rt,{icon:h.icon,className:"mr-2 h-4 w-4 shrink-0"}),t.jsx("span",{className:"flex-1 truncate",children:h.name||h.slug}),h.slug===n?t.jsx(Tr,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,h.entity_count!=null?t.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:h.entity_count.toLocaleString()}):null]},h.slug);return t.jsxs(sn,{open:r,onOpenChange:i,children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t.jsx(rn,{asChild:!0,children:t.jsxs(Y,{type:"button",variant:"ghost",className:"-ml-2 h-auto gap-1.5 px-2 py-1 text-2xl font-semibold tracking-tight",children:[s,t.jsx(is,{className:"h-5 w-5 text-muted-foreground"})]})})}),t.jsx(an,{align:"start",className:"w-72 p-0",children:t.jsxs(jr,{children:[t.jsx(Nr,{autoFocus:!0,placeholder:"Find a type…"}),t.jsxs(Sr,{children:[t.jsx(Er,{children:c?"Loading types…":"No type matches."}),l.length>0?t.jsx(vn,{heading:"Types",children:l.map(m)}):null,y.length>0?t.jsx(vn,{heading:"System",children:y.map(m)}):null]}),t.jsx(Cr,{}),t.jsxs(we,{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:[t.jsx(_r,{className:"h-4 w-4"}),"Schema map"]})]})})]})}function Ri(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,n])=>n.on==="entity").map(([n,s])=>({name:n,description:s.description}))}const vt={table:{label:"Table",icon:Ar},board:{label:"Board",icon:ns},graph:{label:"Graph",icon:as}},Cs=(e,n)=>`lobu.record-shape:v1:${e}/${n}`,Ii=new Set(["table","board","graph"]);function Oi(e,n){const s=Gn(Cs(e,n));return s&&Ii.has(s)?s:void 0}function $i(e,n,s){Kn(Cs(e,n),s)}const Vn=":records";function Ai({ownerSlug:e,entityTypeSlug:n,create:s,onCreateChange:a,viewKey:r,shape:i}){const{orgContext:o,hasOrgContext:l}=De(),y=Xn(n,o),{data:c,isLoading:x,error:m}=y;Lr(`/${e}`,o);const h=Rr(),[p,v]=b.useState({key:"",page:0}),j=ds({strict:!1}),d=at(),S=tn(),N=`/${e}/${cs(n)}`,C=!x&&c?.slug===n,{collection:k,error:g,presentation:w,preset:M,edited:A,table:P}=b.useMemo(()=>Mo(j,c?.metadata_schema,!!r),[j,c?.metadata_schema,r]),D=C?g:void 0,J=b.useMemo(()=>Oo(j,k),[j,k]),[q,se]=b.useState(!1),[V,ne]=b.useState(0),he=k.search??"",O=k.segment,I=JSON.stringify(k),U=O?Ri(c).find(R=>R.name===O)??{name:O,description:""}:null,H=R=>void d({to:".",search:{...Ue(R),...J},replace:!0}),W=Ir(y.data),Q=W?P.sort:Ao(P),re=Q?.field,pe=Q?.order,ue=b.useMemo(()=>re?[{id:re,desc:pe==="desc"}]:[],[re,pe]),Ce=b.useCallback(R=>void d({to:".",search:{...r?Ue(j):{},...J,$table:JSON.stringify(R)},replace:!0}),[d,r,j,J]),Fe=b.useCallback(R=>{const ee=typeof R=="function"?R(ue):R;ee[0]&&Ce({...P,sort:{field:ee[0].id,order:ee[0].desc?"desc":"asc"}})},[ue,Ce,P]),Ne=s===!0,Ge=()=>a(!0),_e=()=>a(!1),ze=ue[0]?.id,ye=ue[0]?ue[0].desc?"desc":"asc":void 0,Le=y.data?.metadata_schema,xe=!!un(Le)&&!W,Re=ui(Le,{isDerived:W}),ce=us(o),ot=Ht(ce.data??[],n,k),ke=(R,ee=!1,je=Ue(j))=>{const be=!r||!ce.data||Ht(ce.data,n,R).some(pt=>pt.key===r);d({to:be?".":N,search:{...be&&r?je:{},...To(R,M?.key),$table:JSON.stringify(P)},replace:ee})},Ie=R=>{const ee=R?jt(R):{},je=!r||Ht(ce.data??[],n,ee).some(be=>be.key===r);se(!1),ne(be=>be+1),d({to:je?".":N,search:R?{$preset:R.key}:{}})},{isAdmin:We}=Yn(o.organizationId),Be=Or(o),_=We&&!!c&&!y.isPlaceholderData,u=b.useRef(j);u.current=j;const f=async()=>{if(!M)return;const R=JSON.stringify(j),{data:ee}=await y.refetch(),je=ee?.metadata_schema,be=je?nn(je[Yt]??{}):void 0,pt=be?.presets?.find(gt=>gt.key===M.key);if(!ee||!je||!be||!pt){Zn.error("This saved filter changed. Reload and try again.");return}const Dt=Lo(pt,k,P,be);await Be.mutateAsync({slug:ee.slug,metadata_schema:{...je,[Yt]:{...be,presets:be.presets?.map(gt=>gt.key===Dt.key?Dt:gt)}}}).then(()=>!0,()=>!1)&&(await y.refetch(),JSON.stringify(u.current)===R&&Ie(Dt))},E=b.useMemo(()=>Oi(e,n),[e,n]),T=$r(ce.data??[],n,{viewKey:r,shape:i??(r?void 0:E)},Re,k),L=T.kind==="builtin"?T.mode==="board"&&!xe?"table":T.mode:null,z=L==="graph";b.useEffect(()=>{i&&C&&L&&$i(e,n,L)},[i,C,L,e,n]);const G=["table",...xe?["board"]:[],"graph"],B=T.kind==="view"?T.view:null,F=T.kind==="missing"?T.key:null,me=T.kind==="inapplicable"?T:null,le=L==="table"?50:200,Se=`${n}?${I}&sort=${JSON.stringify(P.sort)}&size=${le}`,Oe=p.key===Se?p.page:0,Ke=b.useCallback(R=>v(ee=>({key:Se,page:R(ee.key===Se?ee.page:0)})),[Se]),$e=wn(n,o,{limit:le,offset:Oe*le,search:he.trim()||void 0,sortBy:ze,sortOrder:ye,segment:O,filters:k.filters,enabled:C&&!r&&!D}),Ye=wn(n,o,{limit:1,offset:0,parentId:null,search:he.trim()||void 0,segment:O,filters:k.filters,enabled:C&&!r&&!D&&!W}),{data:Je,error:$t}=$e,$=$e.isLoading||$e.isPending&&$e.fetchStatus==="paused",Z=D||m||(r?null:$t),te=!!r&&ce.data===void 0&&ce.isError,K=Je?.entities??[],ae=Je?.metadata?.has_more??!1,X=Je?.metadata?.total_count??0,Ae=K.length>0||he.trim().length>0||Oe>0||!!O||!!k.filters?.length,ie=c?.name?.trim()||qe(n),ge=c?.icon||void 0,oe=W,fe=Le,Me=!D&&(!l||!C||(r?ce.data===void 0&&!ce.isError:$||!W&&Ye.isLoading)),He=Je?.linked_entities??{},it=Ye.data?.metadata?.total_count,Qe=X>0&&typeof it=="number"?it<X:!1,ct=b.useMemo(()=>c?.measure_columns??[],[c?.measure_columns]),Xe=b.useCallback(R=>Ce({...P,columns:R}),[Ce,P]),lt=b.useMemo(()=>({entities:K,owner:e,schema:fe,entityTypeIcon:ge,isDerived:oe,measureColumns:ct,linkedEntityLookups:He,hasAnyParents:Qe,sorting:ue,onSortingChange:Fe,visibleColumns:P.columns,columnChoices:Qt(fe,oe,K),onVisibleColumnsChange:Xe,page:Oe,pageSize:le,totalCount:X,hasMore:ae,pageTitle:ie,onPrevPage:()=>Ke(R=>Math.max(0,R-1)),onNextPage:()=>Ke(R=>R+1)}),[K,e,fe,ge,oe,ct,He,Qe,ue,P.columns,Xe,Fe,Ke,Oe,le,X,ae,ie]),mn=X>K.length,fn=`showing first ${K.length} of ${X} — narrow with search`,hn=b.useMemo(()=>({owner:e,entityType:c,entities:K,totalCount:X,schema:fe,entityTypeIcon:ge}),[e,c,K,X,fe,ge]),At=b.useMemo(()=>({tableState:lt,boardState:hn,owner:e,schema:fe,entityType:c,entityTypeIcon:ge,totalCount:X,isTruncated:mn,truncationNotice:fn,canCreate:!oe,addLabel:`Add ${c?.name||qe(n)}`}),[lt,hn,e,fe,c,ge,X,mn,fn,oe,n]),_s=b.useMemo(()=>fi({canShowBoard:xe,builtinData:At,builtInLabels:{table:vt.table.label,board:vt.board.label}}),[xe,At]),pn=L?_s.find(R=>R.id===L)??null:null,Ms=pn?.template??js,Ts=pn?.data??At,gn=R=>void d({to:R===Vn?N:`${N}${zr(R)}`,search:J}),Pt=Ue(j),Ls=Na(B?.params,Pt,R=>void d({to:".",search:{...Ue(R),...J}})),Rs=()=>ke({...k,filters:[],segment:void 0},!1,Sa(B?.params,Pt)),yn=`Moved on ${c?.name||c?.slug||n} board`,xn=b.useMemo(()=>(R,ee)=>h.mutateAsync({entityId:R,metadata:ee,field_note:yn}),[h,yn]),Is=b.useMemo(()=>({updateEntity:xn,openCreate:()=>a(!0)}),[xn,a]),bn=R=>S?t.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:de("size-8 text-muted-foreground hover:text-foreground",R),"aria-label":"Edit type",title:"Edit type",onClick:()=>S.open({href:Fr(e,n),title:ie}),children:t.jsx(Dr,{className:"h-4 w-4"})}):null;return t.jsxs("div",{className:"@container space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Li,{ownerSlug:e,typeSlug:n,title:ie,shape:r?null:L}),bn(Ne||!C?"":"hidden @lg:inline-flex")]}),t.jsxs("div",{children:[Ne?t.jsx("div",{className:"max-w-3xl",children:t.jsx(Eo,{onClose:_e,entityTypeSlug:n,orgContext:o})}):null,!Ne&&C&&t.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${ie} views`,children:[bn("-mr-1 @lg:hidden"),!r&&G.length>1&&t.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:G.map(R=>{const ee=vt[R].icon,je=L===R;return t.jsx(Y,{type:"button",variant:"ghost",size:"sm","aria-pressed":je,title:vt[R].label,"data-testid":`shape-${R}`,className:de("h-7 px-2",je&&"bg-accent text-accent-foreground"),onClick:()=>void d({to:`${N}/${ls}/${R}`,search:J,replace:!0}),children:t.jsx(ee,{className:"h-4 w-4"})},R)})}),r&&t.jsx(Y,{variant:"ghost",onClick:()=>gn(Vn),children:"Records"}),!!w.presets?.length&&t.jsxs(sn,{open:q,onOpenChange:se,children:[t.jsx(rn,{asChild:!0,children:t.jsxs(Y,{variant:"outline",className:de("gap-2",A&&"border-dashed border-primary"),"data-edited":A||void 0,title:"Choose saved filter",children:[M?.label??(k.filters?.length||k.search?"Custom filter":"All records"),A?t.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,t.jsx(is,{className:"h-4 w-4 text-muted-foreground"})]})}),t.jsxs(an,{align:"start",className:"w-60 p-1",children:[t.jsx(Y,{variant:M?"ghost":"secondary",className:"w-full justify-start",onClick:()=>Ie(),children:"All records"}),w.presets.map(R=>t.jsx(Y,{variant:M?.key===R.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>Ie(R),children:R.label},R.key))]})]}),M&&A?t.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[t.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>Ie(M),children:"Reset"}),_?t.jsx(Y,{size:"sm",disabled:Be.isPending,onClick:()=>void f(),children:Be.isPending?"Saving…":"Save"}):null]}):null,!D&&t.jsx(Ho,{collection:k,schema:fe,label:ie,org:o??"",facetQuery:w.facetQuery,onChange:ke,viewFilters:Ls,onClearAll:Rs,segmentChip:U?{id:"segment",label:"Segment",op:"is",value:qe(U.name),title:U.description||void 0,editor:U.description?{kind:"custom",render:()=>t.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:U.description})}:void 0,onRemove:()=>ke({...k,segment:void 0})}:void 0},`filters:${n}:${V}`),ot.map(R=>t.jsx(Y,{"data-testid":`tab-${R.key}`,variant:r===R.key?"secondary":"ghost","aria-pressed":r===R.key,onClick:()=>gn(R.key),children:R.name},R.key)),t.jsx(Fo,{label:ie,search:k.search,onSearch:(R,ee)=>ke({...k,search:R},ee),className:"ml-auto min-w-40 max-w-64 flex-1"},`search:${n}:${V}`),!oe&&!r?t.jsxs(Y,{size:"sm","aria-label":`Add ${ie||"entity"}`,onClick:()=>Ge(),children:[t.jsx(mt,{className:"mr-2 h-4 w-4"}),"Add"]}):null]}),Ne?null:Me?z?t.jsx(cn,{label:`Loading ${ie} graph`}):t.jsx(Pi,{}):Z?t.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[Z.message||`Failed to load ${ie.toLowerCase()}.`,D&&t.jsx(Y,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>ke({}),children:"Clear filters"})]}):te?t.jsx(fs,{onRetry:()=>void ce.refetch()}):me?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[t.jsxs("h2",{className:"text-lg font-semibold",children:["“",me.view.name,"” doesn’t apply to the current filters"]}),t.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(me.when).map(([R,ee])=>`${R} is ${ee===null?"not supplied":String(ee)}`).join(" and "),"."]}),t.jsx(we,{to:N,search:J,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${ie}`})]}):F?t.jsx(hs,{viewKey:F,backTo:N,backLabel:`Back to ${ie}`}):B?t.jsx(ps,{orgSlug:e,viewKey:B.key,scope:{type:n,collection:k},params:Pt,onParamsChange:H,contentHash:B.content_hash,title:B.name,minHeight:320}):z&&Ae?t.jsx(ei,{ownerSlug:e,typeSlug:n,sourceBacked:W,records:K.map(R=>({...R,id:R.id??JSON.stringify([R.entity_type,R.slug])})),hasMore:ae}):Ae?t.jsx(ma,{template:Ms,data:Ts,actions:Is,components:Ti}):t.jsx(rs,{icon:Pr,iconElement:t.jsx(Rt,{icon:c?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${ie.toLowerCase()} yet`,description:oe?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${c?.name?.toLowerCase()||"entity"}.`,actionLabel:oe?void 0:`Add ${c?.name||"Entity"}`,onAction:oe?void 0:()=>Ge()})]})]})}function Pi(){return t.jsxs("div",{className:"space-y-4","aria-label":"Loading entities",role:"status",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx(ve,{className:"h-9 max-w-sm flex-1"}),t.jsx(ve,{className:"h-9 w-28"})]}),t.jsxs("div",{className:"overflow-hidden rounded-lg border",children:[t.jsx("div",{className:"border-b px-4 py-3",children:t.jsx(ve,{className:"h-3 w-1/3"})}),t.jsx("div",{className:"divide-y",children:Array.from({length:5}).map((e,n)=>t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[t.jsx(ve,{className:"h-3 flex-1"}),t.jsx(ve,{className:"h-3 w-16 shrink-0"})]},n))})]})]})}function Di({ownerSlug:e,typeScope:n,create:s,createType:a=!1,viewKey:r,shape:i}){const o=at(),{orgContext:l}=De(),y=ds({strict:!1}),c=n?Wr(n):void 0,x=c==="$member",m=()=>{o({to:"/$owner/data",params:{owner:e},search:{}})},h=v=>{if(!c)return;const j=Jn(e,c);o({to:j.to,params:j.params,search:v?{create:!0}:{},replace:!0})},p=a?t.jsx("div",{className:"mx-auto w-full max-w-3xl",children:t.jsx(Ca,{entityType:null,orgContext:l,onClose:m})}):c?t.jsx(Ai,{ownerSlug:e,entityTypeSlug:c,create:s,onCreateChange:h,viewKey:r,shape:i}):t.jsx(Fi,{ownerSlug:e,viewKey:r,search:y});return t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:x?t.jsx(_a,{children:p}):p})}function Fi({ownerSlug:e,viewKey:n,search:s}){const a=at(),{orgContext:r}=De(),{data:i,isError:o,refetch:l}=us(r),y=Br(i??[],n),c=Hr(),x=Vr(i??[]);return n&&i===void 0?o?t.jsx(fs,{onRetry:()=>void l()}):null:y.kind==="missing"?t.jsx(hs,{viewKey:y.key,backTo:`/${e}/data`,backLabel:"Back to Memory"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[c&&x.length>0?t.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-wrap gap-1",children:[t.jsx(we,{to:"/$owner/data",params:{owner:e},search:{},activeOptions:{exact:!0},"aria-current":n?void 0:"page",className:Un(!n),children:"Overview"}),x.map(m=>t.jsx(we,{to:"/$owner/data/-/views/$viewKey",params:{owner:e,viewKey:m.key},search:{},activeOptions:{exact:!0},"aria-current":n===m.key?"page":void 0,className:Un(n===m.key),children:m.name},m.key))]}):null,c&&o?t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Couldn’t load views."," ",t.jsx("button",{type:"button",onClick:()=>void l(),className:"underline underline-offset-4",children:"Retry"})]}):null,y.kind==="view"?t.jsxs(t.Fragment,{children:[t.jsx(Ea,{decls:y.view.params,params:Ue(s),onParamsChange:m=>void a({to:".",search:m})}),t.jsx(ps,{orgSlug:e,viewKey:y.view.key,scope:{},params:Ue(s),onParamsChange:m=>void a({to:".",search:m,replace:!0}),contentHash:y.view.content_hash,title:y.view.name,minHeight:400})]}):t.jsx(So,{ownerSlug:e})]})}const Un=e=>de("inline-flex min-h-10 max-w-full items-center rounded-md px-3 text-sm font-medium break-words focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",e?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground");function rc({ownerSlug:e,typeScope:n,create:s,createType:a=!1,viewKey:r,shape:i}){return t.jsxs("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:[t.jsx(qr,{}),t.jsx(Ur,{owner:e,children:o=>t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:t.jsx(Di,{ownerSlug:o.ownerSlug,typeScope:n,create:s,createType:a,viewKey:r,shape:i})})})]})}export{rc as M};
|
|
74
|
+
//# sourceMappingURL=memory-browse-page-p2vIbfkC.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=model-selector-
|
|
1
|
+
import{az as g,aA as N,j as s,eP as y,cY as m,dF as p,h as f,B as w,eR as b}from"./index-008wj-Pz.js";function M(o,r){const l=new Map(r.map(e=>[e.slug,e])),i=new Map,d=e=>{const a=e.model?.trim();if(!a)return;const t=`${e.slug}/${a}`;i.has(t)||i.set(t,{value:t,provider:e.provider,model:a,isDefault:e.isDefault})};for(const e of o){const a=l.get(e.kind)??l.get(e.slug),t={slug:e.slug,provider:e.displayName||e.slug,isDefault:e.isDefault};d({...t,model:e.capabilities.text?.model}),d({...t,model:a?.defaultModel});for(const x of a?.models??[])d({...t,model:x})}for(const e of r){if(!e.systemAvailable)continue;const a={slug:e.slug,provider:e.displayName||e.slug,isDefault:!1};d({...a,model:e.defaultModel});for(const t of e.models)d({...a,model:t})}return[...i.values()]}function _(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function S({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=g(),{data:a=[]}=N(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(y,{contentClassName:"w-[--radix-popover-trigger-width] min-w-[280px]",searchPlaceholder:"Search or type a model ref…",emptyText:"Type a full provider/model ref to use it.",trigger:c=>s.jsxs(w,{type:"button",variant:"outline",role:"combobox","aria-expanded":c,disabled:i,className:f("w-full justify-between font-normal",o?"":"text-muted-foreground",d),children:[s.jsx("span",{className:"truncate",children:o?h:l}),s.jsx(b,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(c,j)=>{const u=j.trim(),v=_(u,t);return s.jsxs(s.Fragment,{children:[s.jsxs(m,{value:"__inherit__ use default inherit",onSelect:()=>{r(""),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===""?"opacity-100":"opacity-0")}),s.jsx("span",{className:"text-muted-foreground",children:l})]}),s.jsxs(m,{value:"auto newest latest",onSelect:()=>{r("auto"),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o==="auto"?"opacity-100":"opacity-0")}),s.jsxs("span",{children:["auto"," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:"(newest for the provider)"})]})]}),t.map(n=>s.jsxs(m,{value:`${n.provider} ${n.model} ${n.value}`,onSelect:()=>{r(n.value),c()},className:"cursor-pointer",children:[s.jsx(p,{className:f("mr-2 h-4 w-4",o===n.value?"opacity-100":"opacity-0")}),s.jsxs("span",{className:"truncate",children:[n.provider," ",s.jsx("span",{className:"text-muted-foreground text-xs",children:n.model}),n.isDefault?s.jsx("span",{className:"ml-1.5 text-muted-foreground text-xs",children:"· org default"}):null]})]},n.value)),v?s.jsxs(m,{value:`__custom__ ${u}`,onSelect:()=>{r(u),c()},className:"cursor-pointer",children:[s.jsx(p,{className:"mr-2 h-4 w-4 opacity-0"}),s.jsxs("span",{children:["Use ",s.jsx("span",{className:"font-mono text-xs",children:u})]})]}):null]})}})}export{S as M,M as b,_ as s};
|
|
2
|
+
//# sourceMappingURL=model-selector-3l9lY50C.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as f}from"./cronstrue-xxpD1P2-.js";import{g7 as d}from"./index-008wj-Pz.js";function m(e){try{return f.toString(e.trim(),{throwExceptionOnParseError:!0})}catch{return`On schedule ${e.trim()}`}}function _(e,t){return t.get(e)??e}function k(e){return d(e.replace(/^\$/,""))}function h(e,t){const n=t?.display_name?.trim();return n&&t?.external_tenant_id===e?n:`#${e}`}function v(e,t){if(!e||typeof e!="object"||Array.isArray(e))return"";const n=e;return typeof n.repository=="string"?` in ${n.repository}`:typeof n.channel_id=="string"?` in ${h(n.channel_id,t)}`:typeof n.resource_ref=="string"?` for ${n.resource_ref}`:""}function $(e){return Array.isArray(e.triggers)?e.triggers.filter(t=>!!t&&typeof t=="object"):[]}function A(e,t,n){if(e.kind==="schedule"&&typeof e.cron=="string")return m(e.cron);if(e.kind==="event"&&e.source!=="workspace"&&typeof e.connector_key=="string"){const r=Array.isArray(e.event_types)?e.event_types.filter(u=>typeof u=="string"):[],o=r.length>0?r.join(" or "):"an event",i=typeof e.connection_id=="number"?n.get(e.connection_id):void 0;return`${_(e.connector_key,t)} sends ${o}${v(e.match,i)}`}if(e.kind==="event"&&e.source==="workspace"){const r=Array.isArray(e.event_types)?e.event_types.filter(u=>typeof u=="string"):[],o=r.length>0?r.join(" or "):"an event",i=typeof e.entity_type=="string"?` on ${k(e.entity_type)}`:"";return`another Automation writes ${o}${i}`}return null}function T(e){return e.health==="degraded"?"error":"enabled"}function w(e,t=new Map,n=new Map){const r=$(e),o=e.name?.trim()||"Untitled automation",i=r.some(s=>s.kind==="event"),u=r.some(s=>s.kind==="schedule"),p=i?"event":u?"schedule":"manual",c=r.map(s=>A(s,t,n)).filter(s=>!!s);let l="When started manually";c.length===1?l=`When ${c[0]}`:c.length>1&&(l=`When ${c[0]}${c.slice(1).map(s=>`, or when ${s}`).join("")}`);const y=r.some(s=>s.kind==="event"&&s.output==="reply_to_source")?"source":"silent";return{key:`automation:${e.automation_id}`,kind:p,when:l,does:o,output:{destination:y},state:T(e),sortTime:e.next_run_at?Date.parse(e.next_run_at):null,automation:e}}const a={event:0,schedule:1,manual:2};function S(e,t=new Map,n=new Map){return e.map(r=>w(r,t,n)).sort((r,o)=>r.state!==o.state?r.state==="enabled"?-1:1:a[r.kind]!==a[o.kind]?a[r.kind]-a[o.kind]:r.sortTime!==o.sortTime?r.sortTime===null?1:o.sortTime===null?-1:r.sortTime-o.sortTime:r.when.localeCompare(o.when)||r.key.localeCompare(o.key))}const j={kind:"all",output:"any",state:"any"};function E(e,t){return e.filter(n=>(t.kind==="all"||n.kind===t.kind)&&(t.output==="any"||(t.output==="reply"?n.output.destination==="source":n.output.destination==="silent"))&&(t.state==="any"||(t.state==="active"?n.state==="enabled":n.state==="error")))}function L(e){const t=Array.isArray(e.triggers)?e.triggers:[];for(const n of t)if(n&&typeof n=="object"&&n.kind==="event"&&n.source!=="workspace"&&typeof n.connector_key=="string")return n.connector_key;return null}export{j as D,w as d,L as e,E as f,S as m};
|
|
2
|
+
//# sourceMappingURL=model-udnQ_S43.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{iP as e,j as r}from"./index-008wj-Pz.js";import{a as m}from"./agents-workbench-CmGrMvPC.js";import"./agent-editor-form-QrIDroFL.js";import"./model-selector-3l9lY50C.js";import"./proposal-review-shell-CVkLnnKo.js";import"./runs-lG2ChtOt.js";function g(){const{owner:o,agentId:t}=e.useParams();return r.jsx(m,{owner:o,agentId:t,tab:"models"})}export{g as component};
|
|
2
|
+
//# sourceMappingURL=models-CQj7GIOp.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{v as S,ap as y,aD as k,ax as A,b8 as T,r as g,j as e,gs as L,L as p,gt as B,bi as R,S as b,h0 as w,av as $}from"./index-008wj-Pz.js";import{C as D,A as I}from"./create-automation-form-DHW6OUoS.js";import"./cronstrue-xxpD1P2-.js";import"./entity-options-DJv2EhVV.js";import"./connection-label-BobuYiAG.js";import"./use-automations-C4TSie1i.js";import"./model-selector-3l9lY50C.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-BFZa4EIt.js";import"./index-wHFQv1aT.js";import"./use-mention-search-PfZrNbu_.js";function O(n){return n.includes(":")?n.slice(n.indexOf(":")+1):n}function P({prefillAgentId:n,onCancel:t,initialTriggers:l,conversationSetup:x}){const{org:o}=y(),[c,h]=g.useState({ready:!1,triggers:[]}),[u,v]=g.useState(),a=g.useCallback(s=>{h(m=>JSON.stringify(m)===JSON.stringify(s)?m:s)},[]),r=u??l;return e.jsx(D,{startFromScratch:!!l,organizationId:o?.id??"",prefillAgentId:n,conversationSetup:x,onClose:t,onPrefillTriggers:s=>v(s.length>0?s:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!c.ready,createFields:{triggers:c.triggers},triggerFields:e.jsx(I,{organizationId:o?.id??null,initialTriggers:r,onChange:a},JSON.stringify(r??"new"))})}function E({owner:n,prefilled:t}){const l=S(),{org:x}=y(),o=k(x?.id??null,{status:"active",limit:500}),c=A(x?.id??null),{data:h=[]}=T(),u=!!(t?.platform&&(t.listen||t.resource)),v=u&&(o.isLoading||c.isLoading),a=g.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const d=o.data??[],N=t.connection?d.find(i=>i.slug===t.connection):(()=>{const i=d.filter(f=>f.connector_key!==t.platform?!1:t.resource?!0:f.facets.chat&&(f.external_tenant_id??"")===(t.team??""));return i.length===1?i[0]:void 0})();if(t.connection&&!N)return;const j=t.events?.split(",").map(i=>i.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...N?{connection_id:N.id}:{},event_types:j.length>0?j:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:O(t.listen??"")},execution:"turn",active_run:t.listen?"steer":"queue",output:t.listen?"reply_to_source":"silent",skip_if_unchanged:!t.listen}]},[o.data,t]),r=c.data?.find(d=>d.key===t?.platform)?.name,s=t?.label??t?.listen,m=g.useMemo(()=>t?.listen&&a&&s?{name:r?`${r}: ${s}`:s}:void 0,[s,r,a,t?.listen]),C=()=>void l({to:"/$owner/automations",params:{owner:n}}),_=a?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:u&&!o.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("div",{className:"flex flex-1 flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-4",children:[e.jsx(L,{crumbs:[e.jsx(p,{to:"/$owner/automations",params:{owner:n},className:B,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(R,{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:[h.length===0?"This workspace has no agents yet. ":"Choose the agent that answers here, or ",e.jsx(p,{to:"/$owner/agents/new",params:{owner:n},search:t,className:"underline underline-offset-4",children:h.length===0?"Create an agent":"create an agent"})," ","and come back to finish this setup."]}):null,v?e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{className:"h-10 w-full"}),e.jsx(b,{className:"h-32 w-full"})]}):u&&t?.connection&&!a?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"This connection is no longer available. Reopen setup from your conversation."}):e.jsx(P,{prefillAgentId:t?.agent,onCancel:C,initialTriggers:a,conversationSetup:m})]})})}function X(){const{owner:n}=w.useParams(),t=w.useSearch();return e.jsx($,{owner:n,children:()=>e.jsx(E,{owner:n,prefilled:t})})}export{X as component};
|
|
2
|
+
//# sourceMappingURL=new-BOwIHkre.js.map
|