@lobu/runtime-server 24.1.1 → 24.2.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 +151 -37
- package/dist/catalogs/skills.json +2 -2
- package/dist/component.json +1 -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 +5 -3
- 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 +81 -83
- package/dist/embeddings-server.mjs +81 -11
- package/dist/guest.bundle.js +62 -25
- package/dist/owletto/dist/assets/_-Cjvw31gU.js +2 -0
- package/dist/owletto/dist/assets/_-iToIRRFt.js +3 -0
- package/dist/owletto/dist/assets/_agentId-CLdj0X7j.js +2 -0
- package/dist/owletto/dist/assets/_agentId-D5cAWjrP.js +2 -0
- package/dist/owletto/dist/assets/_automationId-BhEZmkJU.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DZtLc3WW.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-BoYpah_l.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-ML2TjCwN.js +2 -0
- package/dist/owletto/dist/assets/_eventId-BYc3I2EL.js +2 -0
- package/dist/owletto/dist/assets/_name-BsOZmvlH.js +2 -0
- package/dist/owletto/dist/assets/_owner-UuyQLJ-0.js +3 -0
- package/dist/owletto/dist/assets/_shape-BpnVAYWH.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-CYrGvNn-.js +2 -0
- package/dist/owletto/dist/assets/_slug-MHQU8ftJ.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CGAJ1ucr.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CMkhfs1k.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-D2T_a2dj.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-_G_lDz5K.js +2 -0
- package/dist/owletto/dist/assets/agent-card-controls-ColL5rdd.js +2 -0
- package/dist/owletto/dist/assets/{agent-client-setup-list-BlXB4SE5.js → agent-client-setup-list-BgyLhJCo.js} +2 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BryZas7Z.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-DsSoeQeF.js → agent-editor-form-C24p9LLg.js} +2 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-D9PpDgR-.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-B7v6Cffw.js → agent-loading-shells-jkf9DjdO.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-C8j8kRB1.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-DFucg4c4.js → agent-skill-context-B9giw2u2.js} +2 -2
- package/dist/owletto/dist/assets/agent-skills-route-BMZ3r1bP.js +2 -0
- package/dist/owletto/dist/assets/agent-subpage-shell-D49f-bzP.js +2 -0
- package/dist/owletto/dist/assets/{agent-thread-D38STyeu.js → agent-thread-BGHYHWDO.js} +4 -4
- package/dist/owletto/dist/assets/agents-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-D1YL3VAB.js +2 -0
- package/dist/owletto/dist/assets/app._appId-A51tx2jU.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-DCAZBKle.js +2 -0
- package/dist/owletto/dist/assets/automations-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/callback-WmyCei3R.js +2 -0
- package/dist/owletto/dist/assets/{card-jzhQrMDP.js → card-Cspo-4M6.js} +2 -2
- package/dist/owletto/dist/assets/{claim-B-wq745Q.js → claim-CCKdBtFt.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-CmK3DkSP.js +2 -0
- package/dist/owletto/dist/assets/client-rows-fFuxzFtE.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-CEqoCky-.js → code-editor-C8FJbT2P.js} +3 -3
- package/dist/owletto/dist/assets/connect-BmCUJ3lr.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-B6StGCPK.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-CPiMA6Bx.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-BialEDmu.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-X1wVi6v0.js +2 -0
- package/dist/owletto/dist/assets/{connection-CNm2ukrI.js → connection-DJd9bnEc.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-WcGCA6qY.js → connection-feed-detail-IO6G5QjL.js} +2 -2
- package/dist/owletto/dist/assets/connections-browser-CzdcZeiU.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-D-ECOlMJ.js → connector-provenance-bmBJJ9B4.js} +2 -2
- package/dist/owletto/dist/assets/connector-scope-lists-B44Q9W-j.js +2 -0
- package/dist/owletto/dist/assets/{connectors-CH4KBZyT.js → connectors-CTWPDH8f.js} +2 -2
- package/dist/owletto/dist/assets/{consent-C9ZpHb7V.js → consent-C_WBfmQ8.js} +2 -2
- package/dist/owletto/dist/assets/copy-button-kcjg8Giw.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-BupT3V0i.js → core.esm-CoJ5Splc.js} +2 -2
- package/dist/owletto/dist/assets/create-CQE5rD0i.js +2 -0
- package/dist/owletto/dist/assets/create-DQNlRTUX.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-y3tq2QIJ.js +3 -0
- package/dist/owletto/dist/assets/create-lOFSQV_5.js +2 -0
- package/dist/owletto/dist/assets/create._connectorKey-icyNicvn.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-CWImw-kf.js → cronstrue-CeUS_78Q.js} +2 -2
- package/dist/owletto/dist/assets/{device-D-7WBe9E.js → device-Br9JHadR.js} +2 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-7UpeD4Sq.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-DGMmjr01.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-BZIa-7i5.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-BcTafZ2e.js +2 -0
- package/dist/owletto/dist/assets/entity-page-CY7PF3X9.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-BzMZttzh.js +2 -0
- package/dist/owletto/dist/assets/{event-detail-DV_zfWnC.js → event-detail-C25TvOb_.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-C4VrjIc1.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-oNjBX9a2.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-DtmqQmgl.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-Acfam-JF.js +2 -0
- package/dist/owletto/dist/assets/identity-BkK8ggdp.js +2 -0
- package/dist/owletto/dist/assets/index-BhBYXtEN.js +2 -0
- package/dist/owletto/dist/assets/{index-BTlx9K_t.js → index-Bhop_otG.js} +2 -2
- package/dist/owletto/dist/assets/index-Bw5iV_J7.js +2 -0
- package/dist/owletto/dist/assets/index-C3dpyynY.js +2 -0
- package/dist/owletto/dist/assets/index-C3zAbslo.js +2 -0
- package/dist/owletto/dist/assets/index-CGKN_WN_.js +2 -0
- package/dist/owletto/dist/assets/{index-DB1iWI_a.js → index-CgRaCOzW.js} +2 -2
- package/dist/owletto/dist/assets/{index-D7gHOpfg.js → index-DRbaESbJ.js} +2 -2
- package/dist/owletto/dist/assets/index-DfIoxD5Q.js +2 -0
- package/dist/owletto/dist/assets/index-DijuudSs.js +2 -0
- package/dist/owletto/dist/assets/index-Dr7bouPX.css +1 -0
- package/dist/owletto/dist/assets/index-JmEl29py.js +7950 -0
- package/dist/owletto/dist/assets/index-NK2VKPoL.js +2 -0
- package/dist/owletto/dist/assets/index-_5qsmBkt.js +2 -0
- package/dist/owletto/dist/assets/{index-B64PGxQm.js → index-qkOKpRYs.js} +2 -2
- package/dist/owletto/dist/assets/index-wHFQv1aT.js +12 -0
- package/dist/owletto/dist/assets/index-wzYkECAe.js +2 -0
- package/dist/owletto/dist/assets/json-diff-4sMmayDd.js +4 -0
- package/dist/owletto/dist/assets/linked-record-peek-B0_B4PnF.js +97 -0
- package/dist/owletto/dist/assets/{list-skeleton-CepswBka.js → list-skeleton-BafzvpOM.js} +2 -2
- package/dist/owletto/dist/assets/login-XL5XxN6y.js +2 -0
- package/dist/owletto/dist/assets/{logout-Bkzc7J44.js → logout-CMxdhLbM.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-Dit3MXBQ.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-DTlM_9MY.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-CDrAjH31.js → model-selector-BeFuFH7p.js} +2 -2
- package/dist/owletto/dist/assets/models-BAVaDnKN.js +2 -0
- package/dist/owletto/dist/assets/new-1QLuS1o-.js +2 -0
- package/dist/owletto/dist/assets/{new-ktz9Cs_P.js → new-ChwqLmVY.js} +2 -2
- package/dist/owletto/dist/assets/new-D21LGMl6.js +2 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-lZNZ9gul.js → oauth-workspace-access-D15LYKSe.js} +2 -2
- package/dist/owletto/dist/assets/organization-CoUJYXx7.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-BvkYk72J.js +2 -0
- package/dist/owletto/dist/assets/permissions-C6UFdvz2.js +2 -0
- package/dist/owletto/dist/assets/proposal-review-shell-CmLy1MZf.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-_awBxu2Y.js +2 -0
- package/dist/owletto/dist/assets/record-activity-Doeu5kPO.js +2 -0
- package/dist/owletto/dist/assets/{record-session-Pbr5czGw.js → record-session-CJzFoVKc.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-CzZw6RcC.js → reset-password-Y-WO77iR.js} +2 -2
- package/dist/owletto/dist/assets/runs-B0zVYb-w.js +2 -0
- package/dist/owletto/dist/assets/runs-panel-Dkyybqos.js +2 -0
- package/dist/owletto/dist/assets/{runs-table-B1APZv7d.js → runs-table-9OVdfPXZ.js} +2 -2
- package/dist/owletto/dist/assets/schema-type-editor-panel-DcJqbCrU.js +2 -0
- package/dist/owletto/dist/assets/settings-Cfy9tCOF.js +2 -0
- package/dist/owletto/dist/assets/settings-Dg0D_l_w.js +2 -0
- package/dist/owletto/dist/assets/skills-oxA7P5Fe.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-BeAZeMLy.js +2 -0
- package/dist/owletto/dist/assets/status-dot-_LQZmEIX.js +2 -0
- package/dist/owletto/dist/assets/use-automations-DS3uz3pb.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-Dcunv4L0.js → use-mention-search-CAFbh-Dk.js} +4 -4
- package/dist/owletto/dist/assets/use-scroll-sentinel-BpQ70c28.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-FuOZyjMg.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-CWwlobOd.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +44298 -40801
- package/npm-shrinkwrap.json +389 -402
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -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/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 +3 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +113 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +41 -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/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +6 -1
- 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._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/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-pin-tombstone-2U0UMu3_.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/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-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-CxF2XXzl.js +0 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.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/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/runs-panel-C0_DNTcq.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 → .bun-tag-22d644c2873790db} +0 -0
|
@@ -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-JmEl29py.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-BafzvpOM.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{q as ke,a0 as Ne,k as Se,a1 as Ce,x as Ee,r as s,a2 as ae,j as e,a3 as b,a4 as Le,a5 as ce,a6 as q,a7 as Fe,a8 as Ue,a9 as Pe,Y as Me,K as Ie,Z as ze,aa as oe}from"./index-JmEl29py.js";import{C as Ae,c as Re}from"./card-Cspo-4M6.js";function $(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 qe({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,J]=s.useState(!1),[c,u]=s.useState(null),[I,r]=s.useState(null),[K,Q]=s.useState(!1),[fe,Z]=s.useState(!1),[G,pe]=s.useState(!1),Y=s.useRef(!1),L=l.callbackUrl,X=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&&K,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 q.social({provider:t,callbackURL:S(),newUserCallbackURL:L?S():`/?onboard_provider=${encodeURIComponent(t)}`}),C=$(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(Y.current||!y||m||F||!i||l.error)return;const t=l.provider;if(!t)return;Y.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 q.magicLink({email:a,callbackURL:S()}),Q(!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=$(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 q.email({email:a,password:k,callbackURL:S()}),g=$(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:$(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&&!G&&ie()},[H,i,m,G]);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);Z(!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}),J(!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.":X?"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"]}),X&&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(qe,{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),Z(!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 q.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&&(K?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:()=>Q(!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:()=>{J(!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-XL5XxN6y.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as n
|
|
2
|
-
//# sourceMappingURL=logout-
|
|
1
|
+
import{r as n,$ as o,j as e}from"./index-JmEl29py.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-CMxdhLbM.js.map
|
package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-Dit3MXBQ.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,k as c,an as d,s as u,aR as h,dA as b,B as p,L as x,v as g}from"./index-JmEl29py.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((n,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:n,ctaLabel:s,showCta:a,callbackUrl:r}){return e.jsx(h,{icon:b,title:t,description:n,children:s&&a?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:n,isReady:s}=c(),{isMember:a,isLoading:r}=d(),i=u({select:m=>m.href});return!s||r?e.jsx(j,{}):n?a?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-Dit3MXBQ.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import{r as b,j as t,d2 as zt,B as U,d3 as Pn,eZ as Es,e_ as Cs,bM as _s,T as me,S as ke,o as Ie,e$ as Wt,f0 as Ms,f1 as Ts,f2 as Rs,E as Le,bn as Et,bo as Ct,bp as _t,bq as Mt,br as ot,f3 as Ls,I as Je,f4 as Is,by as Fn,f5 as Dn,f6 as zn,f7 as Os,f8 as $s,f9 as As,dk as Ht,dS as Ps,fa as Fs,q as Ke,u as Bt,fb as Wn,fc as Hn,bK as Bn,X as Ds,fd as zs,fe as Vt,dW as Vn,bO as Ws,bP as Hs,ff as Bs,fg as Vs,fh as qs,bS as Us,bH as qn,fi as Un,fj as Ge,fk as mt,fl as Gs,fm as Ys,fn as qt,fo as Js,fp as $t,fq as At,fr as Ks,fs as Qs,cg as Gn,cN as ft,dF as Xs,d7 as Zs,dC as Ut,dE as Gt,ft as Yn,dD as Yt,bw as er,eV as tr,dQ as Jn,aR as Kn,eA as Qn,fu as We,eN as nr,cP as Ye,Q as nt,L as _e,er as sr,es as rr,et as Tt,eu as hn,ex as ar,ey as Rt,eB as or,e3 as ir,fv as lr,de as cr,cW as ur,cF as Xn,dG as dr,dH as mr,dI as fr,dJ as hr,cR as pn,fw as pr,fx as gr,cS as xr,dK as yr,fy as Zn,fz as es,ak as br,fA as vr,x as ts,fB as wr,b$ as ze,g as ns,fC as Lt,fD as jr,fE as kr,cZ as gn,b8 as Nr,fF as Sr,fG as Er,fH as Cr,bl as _r,fI as Mr,a as Tr,fJ as Rr,at as Lr}from"./index-JmEl29py.js";import{P as Ir}from"./public-shell-ready-_awBxu2Y.js";import{S as Or}from"./schema-type-editor-panel-DcJqbCrU.js";import{D as $r,c as Ar,l as Pr,p as Me,S as xn,n as Fr,e as wt,a as Dr,g as zr,f as yn,b as Wr,d as Hr,J as Br}from"./linked-record-peek-B0_B4PnF.js";import{S as Vr,E as Jt}from"./entity-avatar-BZIa-7i5.js";import{F as qr}from"./filter-editors-oNjBX9a2.js";import{u as Ur,a as Gr,D as Yr,P as Jr,b as ss,c as Kr,C as Qr}from"./core.esm-CoJ5Splc.js";import{v as Xr,V as rs,M as as,a as os,w as Zr,b as ea}from"./view-param-filters-FuOZyjMg.js";import{E as ta}from"./entity-type-page-BzMZttzh.js";import{M as na}from"./member-scope-gate-Dit3MXBQ.js";function bn(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 ht=(e,n,s)=>e<n?n:e>s?s:e;function sa(e,n,s,{padding:a=.12,minZoom:r=.2,maxZoom:i=1.2}={}){const c=Math.max(1,e.x1-e.x0),o=Math.max(1,e.y1-e.y0),u=ht(Math.min(n/(c*(1+a)),s/(o*(1+a))),r,i);return{z:u,x:n/2-(e.x0+e.x1)/2*u,y:s/2-(e.y0+e.y1)/2*u}}function ra(e,n,s=0){if(e===n){const y=e.x+e.w/2,x=e.y-e.h/2;return[{x:y-30,y:x},{x:y-30,y:x-26},{x:y+22,y:x-26},{x:y+22,y:e.y-6},{x:y,y:e.y-6}]}const a=s*8,r=e.x+e.w/2,i=e.y+ht(a,-e.h/2+6,e.h/2-6),c=n.x-n.w/2,o=n.y+ht(a,-n.h/2+6,n.h/2-6);if(c-r>=40){const y=(r+c)/2+a;return[{x:r,y:i},{x:y,y:i},{x:y,y:o},{x:c,y:o}]}const u=Math.max(e.y+e.h/2,n.y+n.h/2)+24+Math.abs(a),l=Math.min(e.y-e.h/2,n.y-n.h/2)-24-Math.abs(a),f=(i+o)/2,p=Math.abs(u-f)<=Math.abs(l-f)?u:l,h=r+24+Math.abs(a),m=c-24-Math.abs(a);return[{x:r,y:i},{x:h,y:i},{x:h,y:p},{x:m,y:p},{x:m,y:o},{x:c,y:o}]}function aa(e,n,s){const a=s.x-n.x,r=s.y-n.y,i=a*a+r*r,c=i?ht(((e.x-n.x)*a+(e.y-n.y)*r)/i,0,1):0;return Math.hypot(e.x-(n.x+c*a),e.y-(n.y+c*r))}function oa(e,n){let s=Number.POSITIVE_INFINITY;for(let a=0;a<n.length-1;a++)s=Math.min(s,aa(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 Ue{cells=new Set;static CELL_W=12;static CELL_H=16;keys(n){const s=[],a=Math.floor(n.x0/Ue.CELL_W),r=Math.floor(n.x1/Ue.CELL_W),i=Math.floor(n.y0/Ue.CELL_H),c=Math.floor(n.y1/Ue.CELL_H);for(let o=a;o<=r;o++)for(let u=i;u<=c;u++)s.push(o*1e5+u);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 la(e,n,s,a,r){const i=e.slice(0,-1).map((p,h)=>({i:h,length:Math.hypot(e[h+1].x-p.x,e[h+1].y-p.y)})).sort((p,h)=>h.length-p.length);if(i.length===0)return null;const c=p=>({x0:p.x-n/2,x1:p.x+n/2,y0:p.y-s/2,y1:p.y+s/2}),o=p=>({x:(e[p].x+e[p+1].x)/2,y:(e[p].y+e[p+1].y)/2});for(const{i:p,length:h}of i){if(!r&&h<n*.7)break;const m=o(p);if(a.isFree(c(m)))return a.reserve(c(m)),m}if(!r)return null;const u=o(i[0].i),f=[-1,1,-1.6,1.6].map(p=>({x:u.x,y:u.y+p*(s+12)})).find(p=>a.isFree(c(p)))??u;return a.reserve(c(f)),f}const ca='600 14px "DM Sans", system-ui, sans-serif',ua='400 11px "DM Sans", system-ui, sans-serif',da='500 9px "DM Sans", system-ui, sans-serif',ma='500 11px "DM Sans", system-ui, sans-serif',tt=18,vn=8;function wn(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 it(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 fa(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,c=(s.y-n.y)/r;e.moveTo(s.x-i*a-c*a*.55,s.y-c*a+i*a*.55),e.lineTo(s.x,s.y),e.lineTo(s.x-i*a+c*a*.55,s.y-c*a-i*a*.55)}function is({boxes:e,edges:n,label:s,onOpenBox:a,openLabel:r,onConnect:i,className:c}){const o=b.useRef(null),u=b.useRef(null),l=b.useRef(null),f=b.useRef({z:1,x:0,y:0}),p=b.useRef({w:0,h:0,dpr:1}),h=b.useRef(!0),m=b.useRef(new Map),y=b.useRef(null),x=b.useRef(null),j=b.useRef(new Map),C=b.useRef(null),E=b.useRef(""),S=b.useRef(!1),[v,g]=b.useState(()=>new Map),[w,_]=b.useState(null),[P,F]=b.useState(null),[B,G]=b.useState(null),[V,fe]=b.useState(null),[q,he]=b.useState(0),{placed:Q,movedIds:I}=b.useMemo(()=>{const k=new Map,d=new Set;for(const N of e){const R=v.get(N.id);R&&R.from.x===N.x&&R.from.y===N.y?(k.set(N.id,{...N,x:R.at.x,y:R.at.y}),d.add(N.id)):k.set(N.id,N)}return{placed:k,movedIds:d}},[e,v]),M=b.useMemo(()=>{const k=new Map;for(const N of n){const R=[N.source,N.target].sort().join("|");k.set(R,[...k.get(R)??[],N])}const d=new Map;for(const N of n){const R=Q.get(N.source),A=Q.get(N.target);if(!R||!A)continue;if(N.route&&!I.has(R.id)&&!I.has(A.id)){d.set(N.id,N.route);continue}const D=k.get([N.source,N.target].sort().join("|"))??[N];d.set(N.id,ra(R,A,D.indexOf(N)-(D.length-1)/2))}return d},[n,Q,I]),$=b.useCallback(()=>{h.current=!0},[]),Y=b.useCallback(()=>{const k=bn([...Q.values()]),{w:d,h:N}=p.current;!k||!d||!N||(f.current=sa(k,d,N),S.current=!0,$())},[Q,$]),z=k=>{f.current=k,S.current=!1,$()},ne=k=>{const d=bn(k),{w:N,h:R}=p.current;if(!d||!N||!R)return;const A=f.current,D=24;d.x0*A.z+A.x>=D&&d.y0*A.z+A.y>=D&&d.x1*A.z+A.x<=N-D&&d.y1*A.z+A.y<=R-D||z({...A,x:N/2-(d.x0+d.x1)/2*A.z,y:R/2-(d.y0+d.y1)/2*A.z})},oe=k=>{fe(k);const d=Q.get(k);d&&ne([d])},re=e.map(k=>`${k.id}@${Math.round(k.x)},${Math.round(k.y)}`).join(";");b.useEffect(()=>{!re||E.current===re||p.current.w&&(E.current=re,Y())},[re,Y]);const O=b.useRef(Y);O.current=Y;const ee=b.useRef(re);ee.current=re,b.useEffect(()=>{const k=o.current,d=u.current;if(!k||!d||typeof ResizeObserver>"u")return;const N=()=>{const A=window.devicePixelRatio||1,D=k.clientWidth,W=k.clientHeight;p.current={w:D,h:W,dpr:A},d.width=Math.round(D*A),d.height=Math.round(W*A);const J=ee.current;J&&D&&W&&(E.current!==J||S.current)&&(E.current=J,O.current()),$()};N();const R=new ResizeObserver(N);return R.observe(k),()=>R.disconnect()},[$]),b.useEffect(()=>{const k=l.current,d=u.current;if(!k||!d)return;const N=wn(d).muted;for(const R of k.querySelectorAll("[data-icon-key]")){const A=R.dataset.iconKey??"";if(m.current.has(A))continue;const D=R.querySelector("svg");if(!D){m.current.set(A,R.textContent??"");continue}const W=new XMLSerializer().serializeToString(D).replaceAll("currentColor",N),J=new Image;J.onload=$,J.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(W)}`,m.current.set(A,J)}},[e,q,$]);const ge=(k,d)=>{const N=f.current;return{x:(k-N.x)/N.z,y:(d-N.y)/N.z}},ye=(k,d)=>{const N=f.current,R=ge(k,d),A=w&&w.kind!=="edge"?Q.get(w.box.id):void 0;if(A&&i){const H=jn(A);if(Math.hypot(H.x*N.z+N.x-k,H.y*N.z+N.y-d)<=vn+3)return{kind:"handle",box:A}}const D=[...Q.values()];for(let H=D.length-1;H>=0;H--)if(ia(D[H],R))return{kind:"box",box:D[H]};let W=null,J=7/N.z;for(const H of n){const X=M.get(H.id);if(!X)continue;const ue=oa(R,X);ue<J&&(J=ue,W=H)}return W?{kind:"edge",edge:W}:null},ce=b.useMemo(()=>{const k=new Set;for(const N of[P,B])N&&k.add(N);w?.kind==="edge"&&k.add(w.edge.id);const d=w&&w.kind!=="edge"?w.box.id:V;if(d)for(const N of n)(N.source===d||N.target===d)&&k.add(N.id);for(const N of n)N.dimmed&&k.delete(N.id);return k},[n,w,P,B,V]);b.useEffect($,[Q,M,ce,w,V,$]);const Oe=b.useCallback(()=>{const k=u.current,d=k?.getContext("2d");if(!k||!d)return;const{w:N,h:R,dpr:A}=p.current,D=wn(k),{z:W,x:J,y:H}=f.current,X=L=>({x:L.x*W+J,y:L.y*W+H});d.setTransform(A,0,0,A,0,0),d.clearRect(0,0,N,R);const ue=w&&w.kind!=="edge"?w.box.id:null;d.lineJoin="round";for(const L of n){const le=M.get(L.id);if(!le)continue;const K=le.map(X),te=ce.has(L.id);d.globalAlpha=L.dimmed?.15:te?.95:.55,d.strokeStyle=te?D.foreground:D.muted,d.lineWidth=te?1.75:1.25,d.beginPath(),d.moveTo(K[0].x,K[0].y);for(const ae of K.slice(1))d.lineTo(ae.x,ae.y);L.directed&&fa(d,K[K.length-2],K[K.length-1],8),d.stroke()}const ie=new Ue;for(const L of Q.values()){const le=X(L),K=L.w*W,te=L.h*W,ae=le.x-K/2,xe=le.y-te/2;if(ie.reserve({x0:ae,y0:xe,x1:ae+K,y1:xe+te}),ae>N||xe>R||ae+K<0||xe+te<0)continue;const Fe=ue===L.id||C.current?.over?.id===L.id;if(d.globalAlpha=L.dimmed?.25:1,d.beginPath(),d.roundRect(ae,xe,K,te,8*W),d.fillStyle=L.muted?D.mutedSurface:D.card,d.fill(),d.lineWidth=Fe||V===L.id?1.5:1,d.strokeStyle=Fe||V===L.id?D.primary:D.border,d.stroke(),14*W<5)continue;const Ee=12*W,Ce=16*W,se=L.meta?xe+te/2-8*W:xe+te/2,we=m.current.get(L.icon??"");we instanceof HTMLImageElement&&we.complete?d.drawImage(we,ae+Ee,se-Ce/2,Ce,Ce):typeof we=="string"&&we&&(d.font=`${14*W}px system-ui, sans-serif`,d.textBaseline="middle",d.textAlign="left",d.fillText(we,ae+Ee,se));const pe=ae+Ee+Ce+8*W,et=12*W;d.textBaseline="middle",d.textAlign="left";let de=ae+K-et-pe;if(L.badge){d.font=da.replace("9px",`${9*W}px`);const Te=it(d,L.badge.toUpperCase(),de*.35),be=d.measureText(Te).width+8*W,Ne=ae+K-et-be;d.strokeStyle=D.border,d.lineWidth=1,d.beginPath(),d.roundRect(Ne,se-7*W,be,14*W,3*W),d.stroke(),d.fillStyle=D.muted,d.fillText(Te,Ne+4*W,se+.5),de-=be+6*W}d.font=ca.replace("14px",`${14*W}px`),d.fillStyle=D.foreground,d.fillText(it(d,L.title,de),pe,se+.5),L.meta&&(d.font=ua.replace("11px",`${11*W}px`),d.fillStyle=D.muted,d.fillText(it(d,L.meta,ae+K-Ee-pe),pe,xe+te/2+10*W))}const Be=C.current,Ae=Be?.from??(ue?Q.get(ue):void 0);if(i&&Ae&&Ae.w*W>=60){const L=X(jn(Ae));if(d.globalAlpha=1,Be){const le=X(Be.to);d.strokeStyle=D.primary,d.lineWidth=2,d.setLineDash([6,4]),d.beginPath(),d.moveTo(L.x,L.y),d.lineTo(le.x,le.y),d.stroke(),d.setLineDash([])}d.fillStyle=D.card,d.strokeStyle=D.primary,d.lineWidth=1.5,d.beginPath(),d.arc(L.x,L.y,vn,0,Math.PI*2),d.fill(),d.stroke(),d.beginPath(),d.moveTo(L.x-4,L.y),d.lineTo(L.x+4,L.y),d.moveTo(L.x,L.y-4),d.lineTo(L.x,L.y+4),d.stroke()}d.font=ma,d.textAlign="center",d.textBaseline="middle";const Pe=(L,le,K,te)=>{d.globalAlpha=1,d.fillStyle=D.background,d.strokeStyle=K?D.foreground:D.border,d.lineWidth=1,d.beginPath(),d.roundRect(L.x-te/2,L.y-tt/2,te,tt,5),d.fill(),d.stroke(),d.fillStyle=K?D.foreground:D.muted,d.fillText(le,L.x,L.y+.5)},Ve=[...n].sort((L,le)=>Number(ce.has(le.id))-Number(ce.has(L.id)));for(const L of Ve){const le=M.get(L.id);if(!le||L.dimmed&&!ce.has(L.id))continue;const K=le.map(X),te=ce.has(L.id),xe=(te?L.details:[L.summary]).map(se=>it(d,se,200)),Fe=Math.max(...xe.map(se=>d.measureText(se).width))+14,Ee=xe.length*(tt+2);if(!te&&W<.45)continue;const Ce=la(K,Fe,Ee,ie,te);Ce&&xe.forEach((se,we)=>{Pe({x:Ce.x,y:Ce.y-Ee/2+(tt+2)*we+tt/2},se,te,Fe)})}d.globalAlpha=1},[n,M,Q,ce,w,V,i]);b.useEffect(()=>{let k=0;const d=()=>{k=requestAnimationFrame(d),h.current&&(h.current=!1,Oe())};return k=requestAnimationFrame(d),document.addEventListener("visibilitychange",$),()=>{cancelAnimationFrame(k),document.removeEventListener("visibilitychange",$)}},[Oe,$]),b.useEffect(()=>{const k=new MutationObserver(()=>{m.current.clear(),he(d=>d+1),$()});return k.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>k.disconnect()},[$]);const Qe=(k,d,N)=>{const R=f.current,A=Math.min(3,Math.max(.15,R.z*k));z({z:A,x:d-(d-R.x)*(A/R.z),y:N-(N-R.y)*(A/R.z)})},Xe=k=>{const d=u.current?.getBoundingClientRect();return{x:k.clientX-(d?.left??0),y:k.clientY-(d?.top??0)}},Ze=k=>{if(k.button!==0&&k.pointerType==="mouse")return;k.currentTarget.setPointerCapture(k.pointerId);const d=Xe(k);if(k.pointerType==="touch"&&(j.current.set(k.pointerId,d),j.current.size===2)){const[A,D]=[...j.current.values()];y.current=null,C.current=null,x.current={d:Math.hypot(A.x-D.x,A.y-D.y)||1,mid:{x:(A.x+D.x)/2,y:(A.y+D.y)/2}};return}const N=ye(d.x,d.y),R={start:d,last:d,hit:N,moved:!1};if(N?.kind==="handle")C.current={from:N.box,to:ge(d.x,d.y),over:null};else if(N?.kind==="box"){const A=ge(d.x,d.y);R.grab={x:N.box.x-A.x,y:N.box.y-A.y}}y.current=R},He=k=>{const d=Xe(k);j.current.has(k.pointerId)&&j.current.set(k.pointerId,d);const N=x.current;if(N&&j.current.size===2){const[H,X]=[...j.current.values()],ue=Math.hypot(H.x-X.x,H.y-X.y)||1,ie={x:(H.x+X.x)/2,y:(H.y+X.y)/2};z({...f.current,x:f.current.x+ie.x-N.mid.x,y:f.current.y+ie.y-N.mid.y}),Qe(ue/N.d,ie.x,ie.y),x.current={d:ue,mid:ie};return}const R=y.current;if(!R){const H=ye(d.x,d.y);_(ue=>ha(ue,H)?ue:H);const X=u.current;X&&(X.style.cursor=H?.kind==="handle"?"crosshair":H?"pointer":"grab");return}const A=d.x-R.last.x,D=d.y-R.last.y;if(R.last=d,!R.moved&&Math.hypot(d.x-R.start.x,d.y-R.start.y)>4&&(R.moved=!0),!R.moved)return;const W=C.current;if(W){W.to=ge(d.x,d.y);const H=ye(d.x,d.y);W.over=H?.kind==="box"?H.box:null,$();return}const J=R.hit;if(J?.kind==="box"&&R.grab){const H=ge(d.x,d.y),X=e.find(ie=>ie.id===J.box.id);if(!X)return;const ue={x:H.x+R.grab.x,y:H.y+R.grab.y};g(ie=>new Map(ie).set(X.id,{at:ue,from:{x:X.x,y:X.y}}));return}z({...f.current,x:f.current.x+A,y:f.current.y+D}),u.current&&(u.current.style.cursor="grabbing")},jt=k=>{if(j.current.delete(k.pointerId),x.current){j.current.size<2&&(x.current=null),y.current=null;return}const d=y.current;y.current=null;const N=C.current;if(C.current=null,!d)return;if(u.current&&(u.current.style.cursor="grab"),N){$(),N.over&&i&&i(N.from.id,N.over.id);return}if(d.moved)return;const R=d.hit;R?.kind==="box"?a(R.box.id):R?.kind==="edge"?F(A=>A===R.edge.id?null:R.edge.id):F(null)},ve=k=>{j.current.delete(k.pointerId),x.current=null,y.current=null,C.current=null,$()};b.useEffect(()=>{const k=u.current;if(!k)return;const d=N=>{N.preventDefault();const R=Xe(N);N.ctrlKey||N.metaKey?Qe(Math.exp(-N.deltaY*(N.ctrlKey?.01:.002)),R.x,R.y):z({...f.current,x:f.current.x-N.deltaX,y:f.current.y-N.deltaY})};return k.addEventListener("wheel",d,{passive:!1}),()=>k.removeEventListener("wheel",d)});const st=k=>Qe(k,p.current.w/2,p.current.h/2),$e=[...new Set(e.map(k=>k.icon??""))];return t.jsxs("div",{ref:o,className:me("relative h-full w-full overflow-hidden",c),children:[t.jsx("canvas",{ref:u,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:Ze,onPointerMove:He,onPointerUp:jt,onPointerCancel:ve,onPointerLeave:()=>{y.current||_(null)}}),t.jsxs("ul",{ref:l,"aria-label":s,className:"sr-only",children:[$e.map(k=>t.jsx("li",{"aria-hidden":"true","data-icon-key":k,children:t.jsx(zt,{icon:k||null,className:"h-4 w-4"})},`icon:${k}`)),e.map(k=>t.jsx("li",{children:t.jsx("button",{type:"button",onClick:()=>a(k.id),onFocus:()=>oe(k.id),onBlur:()=>fe(null),children:r(k)})},k.id)),n.map(k=>t.jsx("li",{"data-revealed":ce.has(k.id)||void 0,children:t.jsx("button",{type:"button","aria-pressed":P===k.id,onClick:()=>F(d=>d===k.id?null:k.id),onFocus:()=>{G(k.id);const d=M.get(k.id);d&&ne(d.map(N=>({...N,w:0,h:0})))},onBlur:()=>G(null),children:k.ariaLabel})},k.id))]}),t.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[t.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>st(1.25),children:t.jsx(Pn,{className:"h-3.5 w-3.5"})}),t.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>st(.8),children:t.jsx(Es,{className:"h-3.5 w-3.5"})}),t.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:Y,children:t.jsx(Cs,{className:"h-3.5 w-3.5"})}),I.size>0?t.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>g(new Map),children:t.jsx(_s,{className:"h-3.5 w-3.5"})}):null]})]})}const jn=e=>({x:e.x+e.w/2,y:e.y});function ha(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 Kt({label:e,fill:n=!1,schemaActions:s=!1}){return t.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:me("flex min-w-0 flex-col gap-3",n&&"min-h-0 flex-1"),children:[t.jsx("div",{"aria-hidden":"true",children:t.jsx(ke,{className:"h-5 w-3/4 max-w-xl rounded-none"})}),t.jsxs("div",{className:me("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(ke,{className:"h-8 w-40 rounded-none"}),t.jsx(ke,{className:"h-8 w-36 rounded-none"})]}):null,t.jsxs("div",{className:me("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(ke,{className:"h-4 w-4 shrink-0 rounded-none"}),t.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[t.jsx(ke,{className:"h-3.5 w-24 rounded-none"}),t.jsx(ke,{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(ke,{className:"h-3 w-3 rounded-none"})},a))})]})]})]})}const kn="__new__";function Nn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function pa({entityTypes:e,initialSource:n="",initialTarget:s="",onDone:a}){const r=b.useId(),i=`${r}-relationship`,c=`${r}-name`,o=`${r}-symmetric`,u=`${r}-source`,l=`${r}-target`,{orgContext:f}=Ie(),{data:p=[]}=Wt(f),h=Ms(),m=Ts(),[y,x]=b.useState(""),[j,C]=b.useState(""),[E,S]=b.useState(!1),[v,g]=b.useState(n),[w,_]=b.useState(s),[P,F]=b.useState(null),B=y===kn,G=p.filter(q=>q.status==="active"&&q.purpose!==Rs&&(!q.organization_slug||q.organization_slug===f?.slug)),V=h.isPending||m.isPending,fe=async()=>{if(F(null),!y)return F("Pick a relationship");if(!v||!w)return F("Pick both ends");try{let q=y;if(B){const he=j.trim();if(!he)return F("Name the relationship");const Q=Nn(he);if(!Q)return F("Name must contain a letter or number");q=(await h.mutateAsync({slug:Q,name:he,is_symmetric:E})).relationship_type.slug,x(q)}await m.mutateAsync({slug:q,source_entity_type_slug:v,target_entity_type_slug:w}),a()}catch(q){F(q instanceof Error?q.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(Le,{htmlFor:i,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),t.jsxs(Et,{value:y,onValueChange:x,children:[t.jsx(Ct,{id:i,className:"h-8 text-xs",children:t.jsx(_t,{placeholder:"Pick or define one"})}),t.jsxs(Mt,{children:[G.map(q=>t.jsx(ot,{value:q.slug,children:q.name||q.slug},q.slug)),G.length>0?t.jsx(Ls,{}):null,t.jsx(ot,{value:kn,children:"Define a new one…"})]})]})]}),B?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Le,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),t.jsx(Je,{id:c,value:j,onChange:q=>C(q.target.value),placeholder:"works at",className:"h-8 text-xs"}),j.trim()?t.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",t.jsx("code",{children:Nn(j)||"—"})]}):null]}),t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs(Le,{htmlFor:o,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(Is,{id:o,checked:E,onCheckedChange:S})]})]}):null,t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Le,{htmlFor:u,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),t.jsxs(Et,{value:v,onValueChange:g,children:[t.jsx(Ct,{id:u,className:"h-8 text-xs",children:t.jsx(_t,{placeholder:"Type"})}),t.jsx(Mt,{children:e.map(q=>t.jsx(ot,{value:q.slug,children:q.label},q.slug))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Le,{htmlFor:l,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),t.jsxs(Et,{value:w,onValueChange:_,children:[t.jsx(Ct,{id:l,className:"h-8 text-xs",children:t.jsx(_t,{placeholder:"Type"})}),t.jsx(Mt,{children:e.map(q=>t.jsx(ot,{value:q.slug,children:q.label},q.slug))})]})]}),P?t.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P}):null,t.jsx(Fn,{onCancel:a,cancelDisabled:V,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:t.jsx(U,{type:"button",size:"sm",onClick:fe,disabled:V,children:V?"Saving…":"Add relationship"})})]})}const ls=288,ga=440,pt=240,gt=720,xa=320,Qt="lobu.schema-panel-width:v1";function xt(e,n){if(!Number.isFinite(e))return ls;const s=Math.max(pt,Math.min(gt,n-xa));return Math.round(Math.min(s,Math.max(pt,e)))}function ya(){const e=Dn(Qt);if(e===null)return null;const n=Number.parseInt(e,10);return!Number.isFinite(n)||n<pt||n>gt?null:n}function ba(e){zn(Qt,String(Math.round(e)))}function va(){Os(Qt)}function lt(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 It={exports:{}},Sn;function wa(){return Sn||(Sn=1,(function(e,n){(function(s){e.exports=s()})(function(){return(function(){function s(a,r,i){function c(l,f){if(!r[l]){if(!a[l]){var p=typeof lt=="function"&<if(!f&&p)return p(l,!0);if(o)return o(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var m=r[l]={exports:{}};a[l][0].call(m.exports,function(y){var x=a[l][1][y];return c(x||y)},m,m.exports,s,a,r,i)}return r[l].exports}for(var o=typeof lt=="function"&<,u=0;u<i.length;u++)c(i[u]);return c}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(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},i(h)}function c(h,m){if(!(h instanceof m))throw new TypeError("Cannot call a class as a function")}function o(h,m){for(var y=0;y<m.length;y++){var x=m[y];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(h,l(x.key),x)}}function u(h,m,y){return m&&o(h.prototype,m),Object.defineProperty(h,"prototype",{writable:!1}),h}function l(h){var m=f(h,"string");return i(m)=="symbol"?m:m+""}function f(h,m){if(i(h)!="object"||!h)return h;var y=h[Symbol.toPrimitive];if(y!==void 0){var x=y.call(h,m);if(i(x)!="object")return x;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(h)}r.default=(function(){function h(){var m=this,y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},x=y.defaultLayoutOptions,j=x===void 0?{}:x,C=y.algorithms,E=C===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:C,S=y.workerFactory,v=y.workerUrl;if(c(this,h),this.defaultLayoutOptions=j,this.initialized=!1,typeof v>"u"&&typeof S>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var g=S;typeof v<"u"&&typeof S>"u"&&(g=function(P){return new Worker(P)});var w=g(v);if(typeof w.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new p(w),this.worker.postMessage({cmd:"register",algorithms:E}).then(function(_){return m.initialized=!0}).catch(console.err)}return u(h,[{key:"layout",value:function(y){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},j=x.layoutOptions,C=j===void 0?this.defaultLayoutOptions:j,E=x.logging,S=E===void 0?!1:E,v=x.measureExecutionTime,g=v===void 0?!1:v;return y?this.worker.postMessage({cmd:"layout",graph:y,layoutOptions:C,options:{logging:S,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 p=(function(){function h(m){var y=this;if(c(this,h),m===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=m,this.worker.onmessage=function(x){setTimeout(function(){y.receive(y,x)},0)}}return u(h,[{key:"postMessage",value:function(y){var x=this.id||0;this.id=x+1,y.id=x;var j=this;return new Promise(function(C,E){j.resolvers[x]=function(S,v){S?(j.convertGwtStyleError(S),E(S)):C(v)},j.worker.postMessage(y)})}},{key:"receive",value:function(y,x){var j=x.data,C=y.resolvers[j.id];C&&(delete y.resolvers[j.id],j.error?C(j.error):C(null,j.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(y){if(y){var x=y.__java$exception;x&&(x.cause&&x.cause.backingJsObject&&(y.cause=x.cause.backingJsObject,this.convertGwtStyleError(y.cause)),delete y.__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)})})(It)),It.exports}var ja=wa();const ka=$s(ja);function Na(e){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:e?.name})}const Sa=200,Ea=320,Xt=56,Ca=7.4,_a=5.9,Ma=84,Ta=48;function cs(e,n){return Math.round(Math.min(Ea,Math.max(Sa,Ma+e.length*Ca,Ta+n.length*_a)))}function Ra(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 En(e,n){return e.slug<n.slug?-1:e.slug>n.slug?1:0}function us(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 La(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 Ia(e){const{entityTypes:n,relationshipTypes:s,rulesBySlug:a}=e,r=e.ownerSlug??"",i=[...n].sort(En),c=us(s,r).sort(En),o=g=>!g.organization_slug||g.organization_slug===r,u=g=>g.organization_slug||r,l=new Map;for(const g of i)l.set(g.slug,[...l.get(g.slug)??[],g]);const f=g=>(l.get(g.slug)?.length??0)>1?`${u(g)}:${g.slug}`:g.slug,p=new Set(i.filter(o).map(f)),h=g=>{const w=l.get(g)??[];return w.find(o)??(w.length===1?w[0]:void 0)},m=new Set(p),y=c.flatMap(g=>[...a[g.slug]??[]].sort((w,_)=>w.id-_.id).flatMap(w=>{const _=h(w.source_entity_type_slug),P=h(w.target_entity_type_slug);if(!_||!P)return[];const F=f(_),B=f(P);return!p.has(F)&&!p.has(B)?[]:(m.add(F),m.add(B),[{rt:g,source:F,target:B}])})),x=i.filter(g=>m.has(f(g))),j=[],C=new Map,E=new Map;for(const{rt:g,source:w,target:_}of y){const P=`${g.slug}|${w}|${_}`,F=E.get(P);if(F){F.ruleCount+=1;continue}const B={slug:g.slug,label:g.name||g.slug,ruleCount:1};E.set(P,B);const G=`${w}|${_}`,V=C.get(G);if(V){V.data.relationships.push(B),V.data.isSymmetric=V.data.isSymmetric&&g.is_symmetric;continue}const fe={id:`pair:${w}|${_}`,source:w,target:_,data:{relationships:[B],isSymmetric:g.is_symmetric}};C.set(G,fe),j.push(fe)}const S=new Map;for(const{rt:g,source:w,target:_}of y){const P=S.get(g.slug)??new Set;P.add(`${w}|${_}`),S.set(g.slug,P)}for(const{rt:g}of y)if(S.get(g.slug)?.size===1&&typeof g.relationship_count=="number")for(const w of E.values())w.slug===g.slug&&(w.linkCount=g.relationship_count);return{nodes:x.map(g=>{const w=g.name||g.slug,_=La(g),P=Ra(_,g.entity_count);return{id:f(g),width:cs(w,P),height:Xt,data:{slug:g.slug,label:w,icon:g.icon,isSystem:As(g),organizationSlug:o(g)?void 0:u(g),metaLabel:P}}}),edges:j}}function Oa(e){const n=new Map,s=o=>{const u=n.get(o);if(u===void 0||u===o)return o;const l=s(u);return n.set(o,l),l},a=(o,u)=>{const l=s(o),f=s(u);l!==f&&n.set(l,f)};for(const o of e.nodes)n.set(o.id,o.id);for(const o of e.edges)a(o.source,o.target);const r=new Set;for(const o of e.edges)r.add(o.source),r.add(o.target);const i=new Map;for(const o of e.nodes){if(!r.has(o.id))continue;const u=s(o.id);i.set(u,[...i.get(u)??[],o.id])}return[...i.values()].map(o=>{const u=[...o].sort(),l=new Set(u);return{id:u[0],slugs:u,edgeIds:e.edges.filter(f=>l.has(f.source)&&l.has(f.target)).map(f=>f.id)}}).sort((o,u)=>u.slugs.length-o.slugs.length||(o.id<u.id?-1:o.id>u.id?1:0))}const De=24,$a=72,Aa=16;let Cn=null;function Pa(){return Cn??=new ka({workerFactory:()=>new Na}),Cn}const Ot={"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 ds(e,{elk:n=Pa(),targetAspect:s}={}){const a=new Set;for(const x of e.edges)a.add(x.source),a.add(x.target);const r=e.nodes.filter(x=>a.has(x.id)),i=e.nodes.filter(x=>!a.has(x.id)),c=i.reduce((x,j)=>Math.max(x,j.width),0),o=i.length>0?De+c+$a:0,u=x=>({x:x.x+De+o,y:x.y+De});let l=[];const f=new Map;if(r.length>0){const x=e.edges.filter(v=>v.source!==v.target),j=v=>n.layout({id:"root",layoutOptions:v,children:r.map(g=>({id:g.id,width:g.width,height:g.height})),edges:x.map(g=>({id:g.id,sources:[g.source],targets:[g.target]}))});let C=await j(Ot);const E=s&&C.width&&C.height?s*C.width/C.height:1;if(E>1.08){const v=Number(Ot["elk.spacing.nodeNode"]),g=Math.min(E,2.2);C=await j({...Ot,"elk.spacing.nodeNode":String(Math.round(Math.min(180,v*g+Xt*(g-1))))})}const S=new Map((C.children??[]).map(v=>[v.id,v]));l=r.map(v=>{const g=S.get(v.id);return{...v,position:u({x:g?.x??0,y:g?.y??0})}});for(const v of C.edges??[]){const g=(v.sections??[]).flatMap(w=>[w.startPoint,...w.bendPoints??[],w.endPoint]);g.length>=2&&f.set(v.id,g.map(u))}}let p=De;const h=i.map(x=>{const j={x:De,y:p};return p+=x.height+Aa,{...x,position:j}}),m=new Map([...l,...h].map(x=>[x.id,x]));return{nodes:e.nodes.map(x=>m.get(x.id)??{...x,position:{x:De,y:De}}),edges:e.edges.map(x=>({...x,route:f.get(x.id)??null})),clusters:Oa(e)}}function Fa(e,n){return ds(Ia(e),n)}const _n={nodes:[],edges:[],clusters:[]};function Da(e,n){const{orgContext:s,hasOrgContext:a}=Ie(),{data:r=[],isLoading:i,isError:c}=Ht(s),{data:o=[],isLoading:u,isError:l}=Wt(s),f=b.useMemo(()=>us(o,e),[o,e]),p=b.useCallback(v=>{const g={};return f.forEach((w,_)=>{const P=v[_]?.data;P?.length&&(g[w.slug]=P)}),{rulesBySlug:g,isRulesLoading:v.some(w=>w.isLoading),isRulesError:v.some(w=>w.isError)}},[f]),{rulesBySlug:h,isRulesLoading:m,isRulesError:y}=Ps({queries:f.map(v=>({...Fs.queryOptions(v.slug,s),enabled:a})),combine:p}),x=b.useMemo(()=>({entityTypes:r,relationshipTypes:f,rulesBySlug:h,ownerSlug:e,targetAspect:n}),[r,f,h,e,n]),[j,C]=b.useState(null),E=i||u||m,S=c||l||y;return b.useEffect(()=>{if(E||S)return;let v=!1;return Fa(x,{targetAspect:x.targetAspect}).then(g=>{v||C({graph:g,isError:!1})}).catch(()=>{v||C({graph:_n,isError:!0})}),()=>{v=!0}},[x,E,S]),{graph:j?.graph??_n,isLoading:!S&&!j,isError:S||j?.isError===!0}}function Mn(e){const n=e.ruleCount>1?` ×${e.ruleCount}`:"",s=typeof e.linkCount=="number"?` · ${e.linkCount.toLocaleString()}`:"";return`${e.label}${n}${s}`}function za(e,n){const s=n?new Set(n.slugs):null,a=n?new Set(n.edgeIds):null,r=new Map(e.nodes.map(o=>[o.id,o.data.label])),i=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.organizationSlug,muted:o.data.isSystem,dimmed:s?!s.has(o.id):!1})),c=e.edges.map(o=>{const{relationships:u,isSymmetric:l}=o.data,f=u.map(p=>p.label).join(", ");return{id:o.id,source:o.source,target:o.target,route:o.route??null,summary:u.length===1?Mn(u[0]):`${u.length} relationships`,details:u.map(Mn),directed:!l,dimmed:a?!a.has(o.id):!1,ariaLabel:`${r.get(o.source)??o.source} ${l?"and":"to"} ${r.get(o.target)??o.target}: ${f}`}});return{boxes:i,edges:c}}function Wa({clusters:e,labelBySlug:n,focusedClusterId:s,onFocusCluster:a,endpointOptions:r,canAuthor:i,mode:c,onModeChange:o}){const u=f=>n.get(f)??f,l=()=>o({kind:"index"});return i&&c.kind==="create-type"?t.jsx(Or,{slug:null,onClose:l}):t.jsxs(t.Fragment,{children:[i?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsxs(U,{type:"button",variant:"outline",size:"sm",className:"h-8 justify-start text-xs",onClick:()=>o({kind:"create-type"}),children:[t.jsx(zs,{className:"mr-1.5 h-3.5 w-3.5"}),"Create entity type"]}),c.kind!=="new-relationship"?t.jsxs(U,{type:"button",variant:"outline",size:"sm",className:"h-8 justify-start text-xs",onClick:()=>o({kind:"new-relationship"}),children:[t.jsx(Vt,{className:"mr-1.5 h-3.5 w-3.5"}),"New relationship"]}):null]}),c.kind==="new-relationship"?t.jsx(pa,{entityTypes:r,initialSource:c.source,initialTarget:c.target,onDone:l},`${c.source??""}|${c.target??""}`):null]}):null,e.length>0?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Clusters"}),e.map(f=>{const p=f.id===s;return t.jsxs("button",{type:"button","aria-pressed":p,onClick:()=>a(p?null:f.id),className:me("rounded-md border bg-background px-2.5 py-2 text-left transition-colors","hover:border-primary/60 hover:bg-accent/50","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",p?"border-primary/70 bg-accent":"border-border"),children:[t.jsxs("span",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:u(f.slugs[0])}),t.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:f.slugs.length})]}),t.jsx("span",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",children:f.slugs.map(u).join(", ")})]},f.id)})]}):null]})}function Ha(e){const{mode:n,canAuthor:s,onModeChange:a,isPeekOpen:r}=e,i=s&&n.kind==="create-type",c=s&&n.kind==="new-relationship"?"New relationship":i?"New entity type":"Schema",o=b.useRef(null),u=JSON.stringify(n),l=b.useRef(u);return b.useEffect(()=>{l.current!==u&&(l.current=u,o.current?.focus({preventScroll:!0}))},[u]),t.jsx("aside",{style:{"--schema-panel-width":`${e.width}px`},className:me("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:me("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:o,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:c}),n.kind!=="index"?t.jsx(U,{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(Ds,{className:"h-4 w-4"})}):null]}),t.jsx("div",{className:me("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",n.kind==="index"?"pb-1":"p-4"),children:t.jsx(Wa,{...e})})]})})}function ms(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 Ba({width:e,maxWidth:n,onResize:s,onCommit:a,onReset:r,className:i}){const[c,o]=b.useState(!1),u=b.useRef(0),l=h=>{const m=ms(h);return m>0?m:h.parentElement?.clientWidth??0},f=h=>{if(h.button!==0)return;const m=h.currentTarget;if(!m.parentElement)return;h.preventDefault(),u.current=l(m);const x=h.clientX,j=e;o(!0),m.setPointerCapture(h.pointerId);const C=g=>xt(j-(g-x),u.current);let E=j;const S=g=>{E=C(g.clientX),s(E)},v=g=>{m.removeEventListener("pointermove",S),m.removeEventListener("pointerup",v),m.removeEventListener("pointercancel",v),o(!1),a(g.type==="pointercancel"?E:C(g.clientX))};m.addEventListener("pointermove",S),m.addEventListener("pointerup",v),m.addEventListener("pointercancel",v)},p=h=>{const m=l(h.currentTarget),y=x=>{h.preventDefault(),a(xt(e+x,m))};h.key==="ArrowLeft"?y(16):h.key==="ArrowRight"?y(-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":pt,"aria-valuemax":n,tabIndex:0,onPointerDown:f,onKeyDown:p,onDoubleClick:r,className:me("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",c&&"cursor-col-resize",i),children:t.jsx("div",{className:me("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",c&&"w-0.5 bg-primary")})})}function Va({ownerSlug:e}){const n=Ke(),s=Bt(),a=s?.item!=null,{orgContext:r}=Ie(),{isAdmin:i}=Wn(r.organizationId),[c,o]=b.useState(null),[u,l]=b.useState({kind:"index"}),f=s?.close,p=b.useCallback(O=>{O.kind!=="index"&&a&&f?.(),l(O)},[a,f]),[h,m]=b.useState(),y=b.useRef(null),x=b.useCallback(O=>{if(y.current?.disconnect(),y.current=null,!O||typeof ResizeObserver>"u")return;const ee=()=>{if(!O.clientWidth||!O.clientHeight)return;const ye=Math.round(O.clientHeight/O.clientWidth*10)/10;m(ce=>ce===ye?ce:ye)};ee();const ge=new ResizeObserver(ee);ge.observe(O),y.current=ge},[]),{graph:j,isLoading:C,isError:E}=Da(e,h),S=b.useMemo(()=>j.clusters.find(O=>O.id===c)??null,[j.clusters,c]),{boxes:v,edges:g}=b.useMemo(()=>za(j,S),[j,S]),w=b.useMemo(()=>new Map(j.nodes.map(O=>[O.id,O.data.slug])),[j.nodes]),_=b.useMemo(()=>new Map(j.nodes.map(O=>[O.id,O.data.label])),[j.nodes]),P=b.useMemo(()=>{const O=new Map;for(const ee of j.nodes)(!ee.data.organizationSlug||!O.has(ee.data.slug))&&O.set(ee.data.slug,{slug:ee.data.slug,label:ee.data.label});return[...O.values()]},[j.nodes]),F=b.useCallback(O=>void n(Hn(e,w.get(O)??O)),[n,e,w]),B=b.useCallback((O,ee)=>p({kind:"new-relationship",source:w.get(O)??O,target:w.get(ee)??ee}),[w,p]),G=j.nodes.some(O=>!O.data.isSystem&&!O.data.organizationSlug),V=i&&u.kind==="create-type",fe=i&&u.kind!=="index",[q,he]=b.useState(()=>ya()),Q=q??(V?ga:ls),[I,M]=b.useState(null),$=b.useRef(null),Y=b.useCallback(O=>{if($.current?.disconnect(),$.current=null,!O||typeof ResizeObserver>"u")return;const ee=O.children[1];if(!ee)return;const ge=()=>{const ce=ms(ee);ce>0&&M(Oe=>Oe===ce?Oe:ce)};ge();const ye=new ResizeObserver(ge);ye.observe(O),$.current=ye},[]),z=I===null?Q:xt(Q,I),ne=I===null?gt:xt(gt,I),oe=b.useCallback(O=>{he(O),ba(O)},[]),re=b.useCallback(()=>{he(null),va()},[]);return C?t.jsx(Kt,{label:"Loading workspace schema",fill:!0,schemaActions:i}):E?t.jsx(Bn,{label:"workspace schema"}):t.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[t.jsx("div",{className:me("flex flex-wrap items-center justify-between gap-3",fe&&"hidden lg:flex"),children:t.jsx("p",{className:"text-sm text-muted-foreground",children:G?j.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("div",{ref:Y,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:me("flex min-w-0 flex-1 flex-col lg:pb-8",fe&&"hidden lg:flex"),children:t.jsx("div",{ref:x,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:t.jsx(is,{boxes:v,edges:g,label:"Workspace schema",onOpenBox:F,openLabel:O=>`Open ${O.title}`,onConnect:i?B:void 0})})}),t.jsx(Ba,{width:z,maxWidth:ne,onResize:he,onCommit:oe,onReset:re,className:a||u.kind==="index"?"lg:hidden":void 0}),t.jsx(Ha,{width:z,clusters:j.clusters,labelBySlug:_,focusedClusterId:c,onFocusCluster:o,endpointOptions:P,canAuthor:i,mode:u,onModeChange:p,isPeekOpen:a})]})]})}function qa({onClose:e,entityTypeSlug:n,orgContext:s,onSuccess:a}){const{data:r,isLoading:i}=Vn(n,s),c=`${s.organizationId??s.slug}:${n}`,o=Ws(c,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},r?.metadata_schema),[u,l]=o.field("name"),[f,p]=o.field("customSlug"),[h,m]=o.field("useCustomSlug"),[y,x]=o.field("metadata"),[j,C]=Hs(c,null),E=Bs(),S=h?f:Vs(u),v=async F=>{if(F.preventDefault(),!o.canSubmit)return;if(C(null),!u.trim()){C("Name is required");return}const B=Ar(y),G={entityType:n,name:u.trim(),slug:h?f:void 0,metadata:Object.keys(B).length>0?B:void 0};try{const V=await E.mutateAsync(G);if(e(),V.approval_queued||!V.entity){qn.info("Create queued for approval");return}typeof V.entity.id=="number"&&a?.(V.entity.id)}catch(V){C(V instanceof Error?V.message:"Failed to create entity")}},g=r?.name||n,w=o.revision,_=`Create ${g}`,P=`Add a new ${g.toLowerCase()} to your workspace.`;return i?t.jsx(qs,{rows:6}):t.jsxs("form",{onSubmit:v,children:[t.jsx(Us,{visible:o.hasConflict,onReload:o.reset}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:_}),t.jsx("p",{className:"text-sm text-muted-foreground",children:P})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsxs(Le,{htmlFor:"name",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(Je,{id:"name",value:u,onChange:F=>l(F.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(Le,{htmlFor:"slug",children:"URL Slug"}),t.jsx("button",{type:"button",onClick:()=>m(!h),className:"text-xs text-muted-foreground hover:text-foreground",children:h?"Auto-generate":"Customize"})]}),h?t.jsx(Je,{id:"slug",value:f,onChange:F=>p(F.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:S||"slug-preview"})]}),w&&Object.keys(w).length>0?t.jsxs(t.Fragment,{children:[t.jsx(Vr,{className:"my-2"}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(Le,{className:"text-sm font-medium",children:"Additional Fields"}),t.jsx($r,{schema:o.revision,values:y,onValuesChange:x,orgContext:s})]})]}):null,j&&t.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:j})]}),t.jsx(Fn,{onCancel:e,cancelDisabled:E.isPending,className:"mt-2",children:t.jsx(U,{type:"submit",disabled:!o.canSubmit||E.isPending||!u.trim(),children:E.isPending?"Creating...":`Create ${g}`})})]})}function Ua(e){const n=e?.properties??{},s=Ks(e);return Object.entries(n).flatMap(([a,r])=>{const i=s.find(p=>p.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 c=[r,...Array.isArray(r.anyOf)?r.anyOf:[]],o=i?.options??[],u=o.find(p=>p.value!==null)?.value,l=c.find(p=>["string","number","integer","boolean"].includes(String(p.type)))??(u===void 0?void 0:{type:typeof u});if(!l)return[];const f=r.format==="date-time"||l.format==="date-time"?"datetime-local":r.format==="date"||l.format==="date"?"date":l.type==="number"||l.type==="integer"?"number":l.type==="boolean"?"boolean":"string";return[{field:a,label:String(r["x-table-label"]??r.title??a.replaceAll("_"," ")),type:f,options:f==="boolean"&&!o.some(p=>typeof p.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...o]:o}]})}function Ga(e){const n=e?.[At];return n===void 0?{}:qt(n)}function Ya(e,n,s){try{const a=Ga(n),r=e[Un],i=r===void 0?void 0:a.presets?.find(f=>f.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 c=i&&e[Ge]===void 0?{collection:mt(i)}:Gs(e,s);if(c.error)throw c.error;const o=e[Ys],u=o===void 0?i?.table??a.table??{}:qt({table:typeof o=="string"?JSON.parse(o):o}).table??{},l=!!i&&(Tn(c.collection)!==Tn(mt(i))||yt(u)!==yt(i.table??a.table??{}));return{...c,presentation:a,preset:i,table:u,edited:l}}catch(a){return{collection:{},presentation:{},table:{},edited:!1,error:a instanceof Error?a:new Error("Invalid collection configuration")}}}function Tn(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(ut)])}function ut(e){return JSON.stringify([e.field,e.op,e.value])}function yt(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function Ja(e,n){return n?{[Un]:n,[Ge]:$t(e)[Ge]??"{}"}:$t(e)}function Ka(e,n,s,a,r=new Date){let i=n.filters??[],c=e.relativeDate;if(c){const o=(mt({...e,selection:{}},r).filters??[]).map(ut),u=i.map(ut);o.every(l=>u.includes(l))?i=i.filter(l=>!o.includes(ut(l))):c=void 0}return{key:e.key,label:e.label,selection:{...n.search?{search:n.search}:{},...i.length?{filters:i}:{},...n.segment?{segment:n.segment}:{}},...yt(s)!==yt(a.table??{})?{table:s}:{},...c?{relativeDate:c}:{}}}function Qa(e,n,s){const a=[...e.filters??[]],r=s??(n.length===1&&n[0].op==="eq"?a.findIndex(c=>c.field===n[0].field&&c.op==="eq"):-1),i=r>=0?[...a.slice(0,r),...n,...a.slice(r+1)]:[...a,...n];return{...e,filters:Qs({filters:i}).filters}}function Xa(e,n){return{...e,filters:e.filters?.filter((s,a)=>a!==n)}}function Za(e,n){return{...typeof e.$preset=="string"?e[Ge]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[Ge]:String(Js(e[Ge]))}:$t(n),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const eo=[{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 to(e){return e.sort&&eo.some(n=>n.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function no(e,n,s,a,r){const i={...a,filters:a.filters?.filter(c=>c.field!==s)};return Gn({queryKey:["collection-facets",e,n,s,i],enabled:!!n&&!!s,staleTime:3e4,retry:!1,queryFn:async({signal:c})=>{const o=await ft("query_sdk",{title:`Value counts query for ${s}`,script:`const input = ${JSON.stringify({field:s,collection:i})};
|
|
2
|
+
${n}`},e,{signal:c}),u=o.return_value;if(!o.success||typeof u?.connection!="string"||typeof u.sql!="string")throw new Error(o.error?.message??"Value distribution is unavailable");if(c.aborted)throw new DOMException("Aborted","AbortError");const l=await ft("query_sql",{title:`Value counts for ${s}`,connection:u.connection,sql:u.sql,limit:51},e,{signal:c});if(l.error)throw new Error(l.error);if(!Array.isArray(l.rows))throw new Error("Source did not return value counts");const f=l.rows.map(p=>{const h=p,m=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 m!="number"||!Number.isSafeInteger(m)||m<0)throw new Error("Source returned an invalid value distribution");return{value:h.value,count:m}});return{values:f.slice(0,50),truncated:f.length>50||l.truncated===!0}}})}const so=300;function ro({label:e,search:n,onSearch:s,className:a}){const r=n??"",[i,c]=b.useState(r),o=b.useRef({search:n,onSearch:s});o.current={search:n,onSearch:s};const u=b.useRef(void 0);b.useEffect(()=>{const f=()=>{clearTimeout(u.current),c(o.current.search??"")};return window.addEventListener("popstate",f),()=>window.removeEventListener("popstate",f)},[]);const l=b.useRef(r);return b.useEffect(()=>{r!==l.current&&(l.current=r,c(r))},[r]),b.useEffect(()=>{if(i===(o.current.search??""))return;const f=setTimeout(()=>{const p=o.current.onSearch;l.current=i,p(i||void 0,!0)},so);return u.current=f,()=>clearTimeout(f)},[i]),t.jsxs("div",{className:`relative${a?` ${a}`:""}`,children:[t.jsx(Zs,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(Je,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:i,onChange:f=>c(f.target.value),className:"pl-9"})]})}const ao={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function oo({field:e,initial:n,org:s,facetQuery:a,collection:r,onApply:i,close:c}){const[o,u]=b.useState(n?.op??"eq"),[l,f]=b.useState(n?.value==null?"":String(n.value)),[p,h]=b.useState(""),[m,y]=b.useState(!1),[x,j]=b.useState(),C=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",E=no(s,a,e.field,r),S=w=>{try{const _=m?[{field:e.field,op:"gte",value:e.type==="number"?Number(l):l},{field:e.field,op:"lte",value:e.type==="number"?Number(p):p}]:[{field:e.field,op:o,value:w}];if(e.type==="datetime-local")for(const B of _)typeof B.value=="string"&&(B.value=new Date(B.value).toISOString());if(_.some(B=>typeof B.value=="number"&&!Number.isFinite(B.value)))throw new Error("Enter a valid number.");const P=_[0].value,F=_[1]?.value;if(m&&P!=null&&F!=null&&P>F)throw new Error("The lower bound must be before the upper bound.");i(_),c()}catch(_){j(_ instanceof Error?_.message:"Could not apply filter")}},v=[...e.options];for(const w of E.data?.values??[])v.some(_=>_.value===w.value)||v.push({value:w.value,label:w.value===null?"Not supplied":String(w.value)});const g=Math.max(1,...E.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:m?"range":o,onChange:w=>{y(w.target.value==="range"),w.target.value!=="range"&&u(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(),S(e.type==="number"?Number(l):l)},children:[t.jsx(Je,{required:!0,"aria-label":m?"From value":"Filter value",type:C,step:e.type==="number"?"any":void 0,value:l,onChange:w=>f(w.target.value),placeholder:"Enter a value…"}),m&&t.jsx(Je,{required:!0,"aria-label":"To value",type:C,step:e.type==="number"?"any":void 0,value:p,onChange:w=>h(w.target.value)}),t.jsx(U,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!m&&(o==="eq"||o==="neq")&&t.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:v.filter(w=>!l||w.label.toLowerCase().includes(l.toLowerCase())).map(w=>{const _=E.data?.values.find(P=>P.value===w.value)?.count;return t.jsxs("button",{type:"button","aria-label":w.label,onClick:()=>S(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:[_!==void 0&&t.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${_/g*100}%`}}),t.jsx("span",{className:"relative truncate",children:w.label}),t.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:_?.toLocaleString()})]},JSON.stringify(w.value))})}),a&&E.isFetching&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),E.isError&&t.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),E.data?.truncated&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),x&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:x})]})}function io({choices:e,visible:n,onChange:s}){return t.jsxs(Ut,{children:[t.jsx(Gt,{asChild:!0,children:t.jsx(U,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground","aria-label":"Choose columns",title:"Choose columns",children:t.jsx(Yn,{className:"h-4 w-4"})})}),t.jsxs(Yt,{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(c=>c.field);s(r.target.checked?[...i,a.field]:i.filter(c=>c!==a.field))}}),a.label]},a.field))]})]})}function lo({collection:e,schema:n,label:s,onChange:a,org:r,facetQuery:i,segmentChip:c,viewFilters:o,onClearAll:u}){const l=Ua(n),f=(y,x)=>({kind:"custom",className:"w-80",render:j=>t.jsx(oo,{field:y,initial:x==null?void 0:e.filters?.[x],org:r,facetQuery:i,collection:e,onApply:C=>a(Qa(e,C,x)),close:j})}),p=l.map(y=>({key:y.field,label:y.label,icon:t.jsx(Xs,{className:"h-4 w-4"}),editor:f(y)})),h=new Map,m=(e.filters??[]).map((y,x)=>{const j=`${y.field}:${y.op}:${JSON.stringify(y.value)}`,C=h.get(j)??0;h.set(j,C+1);const E=l.find(v=>v.field===y.field),S=E?.options.find(v=>v.value===y.value)?.label??String(y.value??"Not supplied");return{id:`${j}:${C}`,label:E?.label??y.field,op:ao[y.op],value:S,editor:E?f(E,x):void 0,onRemove:()=>a(Xa(e,x))}});if(c&&m.unshift(c),o?.fields.length){for(const y of p)y.group=s;p.push(...o.fields),m.push(...o.chips)}return!p.length&&!m.length?null:t.jsx(qr,{label:`${s} filters`,fields:p,chips:m,onClearAll:u??(()=>a({...e,filters:[],segment:void 0}))})}const bt=120,Re=12;function Rn(e,n){return typeof e.linkId=="number"&&typeof n.linkId=="number"?e.linkId-n.linkId:String(e.linkId).localeCompare(String(n.linkId))}function co(e){const n=e.records.slice(0,bt),s=l=>e.types.get(l)??{label:l},a=new Map;for(const l of n)a.set(String(l.id),{source:l.source,entityType:e.typeSlug,slug:l.slug,name:l.name,isFocus:!0,hasMoreLinks:!1});const r=new Map;for(const l of e.links){if(!a.has(String(l.recordId)))continue;const f=r.get(l.recordId)??new Map;f.set(l.linkId,l),r.set(l.recordId,f)}const i=new Map;for(const[l,f]of r){const p=[...f.values()].sort(Rn),h=a.get(String(l));h&&p.length>Re&&(h.hasMoreLinks=!0);for(const m of p.slice(0,Re)){i.set(m.linkId,m);const y=String(m.peer.id);a.has(y)||a.set(y,{source:m.peer.source,entityType:m.peer.type,slug:m.peer.slug,name:m.peer.name,isFocus:!1,hasMoreLinks:!1})}}const c=[];for(const[l,f]of a){const p=s(f.entityType),h=f.name||f.slug,m=f.hasMoreLinks?`${p.label} · ${Re}+ links`:p.label;c.push({id:l,data:{slug:f.slug,label:h,icon:p.icon,isSystem:!1,metaLabel:m},width:cs(h,m),height:Xt})}const o=new Map;for(const l of[...i.values()].sort(Rn)){const f=String(l.fromId),p=String(l.toId),h=JSON.stringify([f,p]),m=o.get(h)??{source:f,target:p,rels:new Map,symmetric:!0};m.symmetric&&=l.isSymmetric,m.rels.has(l.relSlug)||m.rels.set(l.relSlug,{slug:l.relSlug,label:l.relName,ruleCount:1}),o.set(h,m)}const u=[...o.entries()].map(([l,f])=>({id:`link:${l}`,source:f.source,target:f.target,data:{relationships:[...f.rels.values()],isSymmetric:f.symmetric}}));return{nodes:c,edges:u,records:a,hasMoreRecords:e.hasMore===!0||e.records.length>bt,listedCount:n.length,focusCount:n.length}}async function uo(e,n){const s=co(e);return{...await ds({nodes:s.nodes,edges:s.edges},n),records:s.records,hasMoreRecords:s.hasMoreRecords,listedCount:s.listedCount,focusCount:s.focusCount}}const mo=8,fo=3,ho=4;function dt(e){return`source:${JSON.stringify([e.type,e.key])}`}function po(e,n){return n.map(s=>{const a={type:e,key:s.slug};return{...s,id:dt(a),source:a}})}function Ln(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function go(e,n,s){const a=e.slice(0,mo),r=[];let i=0;return await Promise.all(Array.from({length:Math.min(fo,a.length)},async()=>{for(;i<a.length;){const c=i++,o=a[c];try{if(s?.aborted)throw s.reason;const u=await n(o),l=new Map(o.links.map(j=>[Ln(j),j]));for(const j of u.record_links){const C=Ln(j),E=l.get(C);(!E||E.occurred_at<j.occurred_at)&&l.set(C,j)}const f=new Map((o.relationships??[]).map(j=>[j.id,j]));for(const j of u.relationships??[])f.set(j.id,j);const p=[...f.values()].slice(0,Re+1),h=[...l.values()].slice(0,Re+1),m=(o.pagesRead??0)+1,y=!!u.next_cursor&&m>=ho,x=u.record_failures.length>0||!!u.relationship_failures?.length||y;r[c]={read:{record:o.record,links:h,failed:x,entityId:o.entityId,relationships:p},...!y&&(x||u.next_cursor&&h.length+p.length<=Re)?{next:{record:o.record,entityId:o.entityId,relationships:p,pagesRead:m,cursor:u.next_cursor??o.cursor,links:h}}:{}}}catch(u){if(s?.aborted)throw u;r[c]={read:{record:o.record,links:o.links,failed:!0,entityId:o.entityId,relationships:o.relationships},next:{...o,cursor:u instanceof er&&u.status===400?null:o.cursor}}}}})),{reads:r.map(c=>c.read),pending:[...r.flatMap(c=>c.next?[c.next]:[]),...e.slice(a.length)]}}function xo(e,n){const s=new Map;for(const i of e)for(const c of i.reads)s.set(String(c.entityId??dt(c.record)),c);const a=new Map(n.map(i=>[i.slug,i])),r=[];for(const[i,c]of s){for(const o of c.relationships??[]){const u=(x,j)=>typeof x=="number"?x:dt({type:j,key:x}),l=u(o.from_entity_id,o.from_entity_type),f=u(o.to_entity_id,o.to_entity_type),p=String(l)===i,h=p?f:l,m=p?o.to_entity_id:o.from_entity_id,y=(p?o.to_entity_type:o.from_entity_type)??"";r.push({recordId:i,linkId:o.id,fromId:l,toId:f,relSlug:o.relationship_type_slug,relName:o.relationship_type_name,isSymmetric:o.is_symmetric,peer:{id:h,name:(p?o.to_entity_name:o.from_entity_name)??String(m),slug:(p?o.to_entity_slug:o.from_entity_slug)??String(m),type:y,...typeof m=="string"?{source:{type:y,key:m}}:{}}})}for(const o of c.links){const u={type:o.entity_type,key:o.key},l=dt(u),f=a.get(o.relationship_type);let p=o.direction==="incoming"?l:i,h=o.direction==="incoming"?i:l;f?.is_symmetric&&p>h&&([p,h]=[h,p]),r.push({recordId:i,linkId:JSON.stringify([p,h,o.relationship_type]),fromId:p,toId:h,relSlug:o.relationship_type,relName:f?.name||o.relationship_type.replaceAll("_"," "),isSymmetric:f?.is_symmetric??!1,peer:{id:l,name:o.name||o.key,slug:o.key,type:o.entity_type,source:u}})}}return{links:r,checked:s.size,failed:[...s.values()].filter(i=>i.failed).length}}function yo(e,n,s,a,r,i=!1){const{orgContext:c}=Ie(),o=Ht(c),u=Wt(c),l=b.useMemo(()=>i?po(n,s):s,[i,n,s]),f=b.useMemo(()=>l.slice(0,bt).flatMap(v=>v.source?[{record:v.source,cursor:null,links:[]}]:typeof v.id=="number"?[{entityId:v.id,record:{type:n,key:v.slug},cursor:null,links:[]}]:[]),[l,n]),p=tr({queryKey:["source-records-graph",c.organizationId,e,n,f.map(v=>[v.record,v.entityId])],enabled:!0,initialPageParam:f,queryFn:({pageParam:v,signal:g})=>go(v,async w=>{const _=await ft("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:Re+1},e,{signal:g});return{..._,record_links:_.record_links??[],record_failures:_.record_failures??[],next_cursor:w.entityId===void 0?_.next_cursor:_.metadata?.has_more?String(Number(w.cursor??0)+Re+1):null}},g),getNextPageParam:v=>v.pending.length?v.pending:void 0,staleTime:3e4,retry:!1}),h=b.useMemo(()=>p.data?xo(p.data.pages,u.data??[]):void 0,[p.data,u.data]),m=h?.links,y=p.isError,x=JSON.stringify([c.organizationId,e,n,i,l.map(v=>[v.id,v.name,v.slug]),a]),j=b.useMemo(()=>new Map((o.data??[]).map(v=>[v.slug,{label:v.name||v.slug,icon:v.icon}])),[o.data]),[C,E]=b.useState(null);b.useEffect(()=>{if(!m)return;let v=!1;return uo({typeSlug:n,records:l,hasMore:a,links:m,types:j},{targetAspect:r}).then(g=>{v||E({graph:g,key:x,isError:!1})}).catch(()=>{v||E({graph:null,key:x,isError:!0})}),()=>{v=!0}},[m,n,l,a,j,r,x]);const S=C?.key===x?C:null;return{graph:S?.graph??null,isLoading:!y&&!S,isError:y||S?.isError===!0,sourceProgress:{checked:h?.checked??0,total:Math.min(s.length,bt),failed:h?.failed??0,hasMore:!!p.hasNextPage,isFetching:p.isFetching,loadMore:()=>{p.isFetching||p.fetchNextPage()}}}}function bo(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:c}=r.data,o=i.map(u=>u.label);return{id:r.id,source:r.source,target:r.target,route:r.route??null,summary:o.length===1?o[0]:`${o.length} relationships`,details:o,directed:!c,ariaLabel:`${n.get(r.source)??r.source} ${c?"and":"to"} ${n.get(r.target)??r.target}: ${o.join(", ")}`}});return{boxes:s,edges:a}}function vo({ownerSlug:e,typeSlug:n,records:s,hasMore:a,sourceBacked:r=!1}){const i=Ke(),c=Bt(),{orgContext:o}=Ie(),{data:u=[]}=Ht(o),l=u.find(g=>g.slug===n)?.name??n,[f,p]=b.useState(),h=b.useRef(null),m=b.useCallback(g=>{if(h.current?.disconnect(),h.current=null,!g||typeof ResizeObserver>"u")return;const w=()=>{if(!g.clientWidth||!g.clientHeight)return;const P=Math.round(g.clientHeight/g.clientWidth*10)/10;p(F=>F===P?F:P)};w();const _=new ResizeObserver(w);_.observe(g),h.current=_},[]),{graph:y,isLoading:x,isError:j,sourceProgress:C}=yo(e,n,s,a,f,r),E=b.useMemo(()=>y?bo(y):null,[y]),S=b.useCallback(g=>{const w=y?.records.get(g);if(w){if(c){c.open(Pr({...w.source?{record:w.source}:{entityId:Number(g)},ownerSlug:e,orgContext:o,name:w.name||w.slug}));return}i({to:Jn(e,[{entity_type:w.entityType,slug:w.slug}])})}},[y,e,o,c,i]);if(j)return t.jsx(Bn,{label:`${l} graph`});if(x||!y||!E)return t.jsx(Kt,{label:`Loading ${l} graph`});const v=C?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 ",C.checked," of ",C.total," records. Up to ",Re," relationships per record."]}),C.failed>0?t.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),C.hasMore?t.jsx(U,{variant:"outline",size:"sm",disabled:C.isFetching,onClick:C.loadMore,children:C.isFetching?"Loading…":C.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return y.focusCount===0?t.jsxs("div",{className:"space-y-3",children:[v,t.jsx(Kn,{icon:Vt,title:`No ${l} records match`,description:"Change the search or filters to see records here."})]}):t.jsxs("div",{className:"flex flex-col gap-2",children:[v,t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",y.hasMoreRecords?"the first ":"",y.focusCount," ",l," record",y.focusCount===1?"":"s",". Click a record to see it."]}),t.jsx("div",{ref:m,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:t.jsx(is,{boxes:E.boxes,edges:E.edges,label:`${l} records`,onOpenBox:S,openLabel:g=>`Show ${g.title}`})})]})}function wo({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 qe({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(wo,{direction:e.getIsSorted()})]})}function Pt(e,n,s){const a=Qn(e?.properties).filter(([i,c])=>(!n||i!=="name")&&!c["x-image"]&&c["x-table-column"]===!0);if(a.length)return a.map(([i,c])=>({field:i,label:c["x-table-label"]??We(i.replaceAll("_"," "))}));if(!n)return[];const r=s.find(i=>Object.keys(Me(i.metadata)).length>0);return Object.keys(Me(r?.metadata)).filter(i=>i!=="id"&&i!=="slug"&&i!=="name"&&!nr(e?.properties?.[i])).map(i=>({field:i,label:We(i.replaceAll("_"," "))}))}function jo(e){return e.some(n=>Object.hasOwn(Me(n.metadata),"name"))}function ko(e,n){return Ye(e,wt(n))}function No(e){return`${e.entityType}:${e.lookupField}`}const So=new Set(["stage","category","round_type","investor_type"]);function Eo(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 Co(e,n){if(Eo(e,n))return"currency";if(So.has(e)||e.endsWith("_slug"))return"enum"}function _o({entities:e,owner:n,schema:s,entityTypeIcon:a,isDerived:r,measureColumns:i,linkedEntityLookups:c,hasAnyParents:o,sorting:u,onSortingChange:l,visibleColumns:f,columnChoices:p,onVisibleColumnsChange:h,page:m,pageSize:y,totalCount:x,hasMore:j,pageTitle:C,onPrevPage:E,onNextPage:S}){const v=p?.length&&h?t.jsx(io,{choices:p,visible:f,onChange:h}):null,g=s?.properties,w=!r||jo(e),_=b.useMemo(()=>g?Object.fromEntries(Object.entries(g).flatMap(([I,M])=>M["x-link-entity-type"]?[[I,{entityType:M["x-link-entity-type"],lookupField:M["x-link-lookup-field"]||"slug"}]]:[])):{},[g]),P=b.useMemo(()=>g?Pt({properties:g},r,[]).map(({field:M})=>[M,g[M]]).map(([M,$])=>{const Y=_[M],z=Y?c[No(Y)]:void 0;return{id:r?M:`meta_${M}`,accessorFn:ne=>{const oe=Me(ne.metadata);return Fr(oe[M],$.enum)},header:({column:ne})=>{const oe=$["x-table-label"]||$.title||$.description||We(M.replace(/_/g," "));return r?t.jsx(qe,{column:ne,children:oe}):oe},cell:({getValue:ne})=>t.jsx(xn,{value:ne(),prop:$,format:Co(M,$),className:"text-muted-foreground",resolveLink:z?oe=>{const re=z[oe];return re?{label:re.name,to:Ye(n,[{entity_type:re.entity_type,slug:re.slug}])}:void 0}:void 0})}}):[],[r,_,c,n,g]),F=b.useMemo(()=>new Set(i),[i]),B=b.useMemo(()=>!r||P.length>0?[]:Pt({properties:g},!0,e).map(({field:M})=>M).map(M=>{const $=F.has(M);return{id:M,accessorFn:Y=>Me(Y.metadata)[M],header:({column:Y})=>t.jsxs(qe,{column:Y,children:[$?M:We(M.replace(/_/g," ")),$&&t.jsx(nt,{variant:"secondary",className:"font-normal lowercase",children:"measure"})]}),cell:({getValue:Y})=>t.jsx(xn,{value:Y(),prop:g?.[M],className:$?"tabular-nums":"text-muted-foreground"}),meta:$?{align:"right"}:void 0}}),[r,P,e,F,g]),G=b.useMemo(()=>{const I=s?.["x-table-relationships"];return!I||I.length===0?[]:I.map(M=>({id:`rel_${M.relationship_type}`,accessorFn:$=>$.relationships?.[M.relationship_type]??[],header:M.label,cell:({getValue:$})=>{const Y=$();return!Y||Y.length===0?t.jsx("span",{className:"text-muted-foreground",children:"-"}):t.jsx("div",{className:"flex flex-wrap gap-1",children:Y.map((z,ne)=>{const oe=Ye(n,[{entity_type:z.entity_type,slug:z.slug}]);return t.jsxs("span",{children:[t.jsx(_e,{to:oe,className:"text-primary hover:underline",onClick:re=>re.stopPropagation(),children:z.name}),ne<Y.length-1&&","]},z.id)})})}}))},[n,s]),V=b.useMemo(()=>o||e.some(M=>M.parent_name&&M.parent_slug&&M.parent_entity_type)?[{id:"parent",accessorFn:M=>M.parent_name,header:"Parent",cell:({row:M})=>{if(!M.original.parent_name||!M.original.parent_slug||!M.original.parent_entity_type)return t.jsx("span",{className:"text-muted-foreground",children:"-"});const $=Ye(n,[{entity_type:M.original.parent_entity_type,slug:M.original.parent_slug}]);return t.jsx(_e,{to:$,className:"text-primary hover:underline",children:M.original.parent_name})}}]:[],[e,o,n]),fe=b.useMemo(()=>{const I=[],M=e.some(z=>(z.total_content??0)>0),$=e.some(z=>(z.active_connections??0)>0),Y=e.some(z=>(z.automations_count??0)>0);return M&&I.push({accessorKey:"total_content",header:({column:z})=>t.jsx(qe,{column:z,alignRight:!0,children:"Activity"}),cell:({row:z,getValue:ne})=>{const oe=ne()??0;if(oe===0)return t.jsx("span",{className:"tabular-nums",children:"0"});const re=wt(z.original);return t.jsx(_e,{to:Jn(n,re),className:"tabular-nums hover:underline",children:oe})},meta:{align:"right"}}),$&&I.push({accessorKey:"active_connections",header:"Connectors",cell:({getValue:z})=>{const ne=z();return ne&&ne>0?t.jsxs(nt,{variant:"outline",className:"text-green-600 dark:text-green-400",children:[ne," active"]}):t.jsx("span",{className:"text-muted-foreground",children:"-"})},meta:{align:"right"}}),Y&&I.push({accessorKey:"automations_count",header:({column:z})=>t.jsx(qe,{column:z,alignRight:!0,children:"Automations"}),cell:({getValue:z})=>t.jsx("span",{className:"tabular-nums",children:z()??0}),meta:{align:"right"}}),I},[e,n]),q=b.useMemo(()=>[{accessorKey:"name",header:({column:I})=>w?t.jsx(qe,{column:I,children:"Name"}):"Name",cell:({row:I})=>{const M=Me(I.original.metadata);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Jt,{metadata:M,metadataSchema:s,name:I.original.name,typeIcon:a,className:"h-6 w-6 shrink-0"}),t.jsx("div",{className:"min-w-0",children:(()=>{const $=ko(n,I.original);return t.jsx(_e,{to:$,className:"block max-w-56 truncate font-medium hover:underline",title:I.original.name,children:I.original.name})})()})]})}},...V,...P,...B,...G,...fe,...r?[]:[{accessorKey:"created_at",header:({column:I})=>t.jsx(qe,{column:I,children:"Created"}),cell:({getValue:I})=>t.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:new Date(I()).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})}]],[n,V,P,B,G,fe,s,a,r,w]),he=Dr({data:e,columns:q,state:{sorting:u,columnVisibility:Object.fromEntries([...P,...B].flatMap(I=>I.id?[[I.id,!f||f.includes(r?I.id:I.id.replace(/^meta_/,""))]]:[]))},onSortingChange:l,getCoreRowModel:zr(),manualSorting:!0,enableSortingRemoval:!1}),Q=e.length>0||m>0;return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"rounded-lg border",children:t.jsxs(sr,{className:"min-w-[48rem]",children:[t.jsx(rr,{children:he.getHeaderGroups().map(I=>t.jsxs(Tt,{children:[I.headers.map(M=>t.jsx(hn,{"aria-sort":M.column.getIsSorted()==="asc"?"ascending":M.column.getIsSorted()==="desc"?"descending":void 0,className:M.column.columnDef.meta?.align==="right"?"text-right":"",children:M.isPlaceholder?null:yn(M.column.columnDef.header,M.getContext())},M.id)),v?t.jsx(hn,{className:"w-10 pr-2 text-right",children:v}):null]},I.id))}),t.jsx(ar,{children:he.getRowModel().rows.length?he.getRowModel().rows.map(I=>t.jsxs(Tt,{children:[I.getVisibleCells().map(M=>t.jsx(Rt,{className:M.column.columnDef.meta?.align==="right"?"whitespace-nowrap text-right":"",children:yn(M.column.columnDef.cell,M.getContext())},M.id)),v?t.jsx(Rt,{}):null]},I.id)):t.jsx(Tt,{children:t.jsx(Rt,{colSpan:q.length+(v?1:0),className:"h-24 text-center",children:"No results found."})})})]})}),Q&&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 ",x," ",C.toLowerCase()]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{children:["Page ",m+1," of ",Math.max(1,Math.ceil(x/y))]}),t.jsx(U,{variant:"outline",size:"sm",onClick:E,disabled:m===0,children:"Previous"}),t.jsx(U,{variant:"outline",size:"sm",onClick:S,disabled:!j,children:"Next"})]})]})]})}function Mo(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function fs(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function Zt(e){const n=e?.properties;if(!n)return null;const r=Qn(n).find(([,l])=>fs(l)==="workflowState");if(!r)return null;const[i,c]=r,o=c["x-lobu"]?.states,u=Array.isArray(o)&&o.length>0?o:(c.enum??[]).map(l=>({value:l}));return u.length===0||u.some(l=>typeof l.value!="string")?null:{field:i,states:u.map(l=>({...l,label:l.label||or(c,l.value)||Mo(l.value),terminal:l.terminal??["done","complete","completed","closed","archived"].includes(l.value.toLowerCase())}))}}function To(e){const n=e?.properties;if(!n)return null;const s=Object.entries(n),a=s.find(([,c])=>fs(c)==="sortRank"),r=s.find(([c])=>["rank","sort_rank","order"].includes(c)),i=a??r;return i?{field:i[0]}:null}function Ro(e,{isDerived:n}){const s=e?.["x-lobu"]?.defaultView;return(s==="table"||s==="board")&&!(n&&s!=="table")?s:n?"table":Zt(e)?"board":"table"}const hs={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},Lo={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function Io(e){const{canShowBoard:n,builtinData:s,builtInLabels:a}=e,r=["table",...n?["board"]:[]],i={table:hs,board:Lo};return r.map(c=>({id:c,label:a[c],builtInMode:c,template:i[c],data:s}))}function Ft(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function vt(e,n){if(!n)return e.created_at??String(e.id);const s=Me(e.metadata);return String(s[n.field]??e.created_at??e.id)}function Oo(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 Dt(e,n){const s=Me(e.metadata);return String(s[n]??"")}function ps(e,n){return[...e].sort((s,a)=>vt(s,n).localeCompare(vt(a,n)))}function $o(e,n,s,a,r){if(!n.startsWith("card:")||!s)return null;const i=Number(n.slice(5)),c=e.find(E=>E.id===i);if(!c)return null;const o=s.startsWith("column:")?s.slice(7):Dt(e.find(E=>`card:${E.id}`===s)??c,a.field);if(!o)return null;const u=ps(e.filter(E=>E.id!==i&&Dt(E,a.field)===o),r),l=s.startsWith("card:")?u.findIndex(E=>`card:${E.id}`===s):u.length,f=l>=0?l:u.length,p=f>0?u[f-1]:void 0,h=u[f],m=r?Oo(p?vt(p,r):void 0,h?vt(h,r):void 0):void 0,y=Me(c.metadata),x={[a.field]:o,...r&&m?{[r.field]:m}:{}};a.states.find(E=>E.value===o)?.terminal&&!y.completed_at&&(x.completed_at=new Date().toISOString());const C={...y,...x};return{entityId:i,changedMetadata:x,nextMetadata:C}}function In(e,n,s){return e.map(a=>a.id===n?{...a,metadata:s}:a)}function Ao({id:e,children:n,className:s}){const{setNodeRef:a,isOver:r}=ss({id:`column:${e}`});return t.jsx("div",{ref:a,className:me("min-h-[220px] rounded-lg bg-card p-2 transition-colors",r?"bg-accent/50":"",s),children:n})}function Po({entity:e,owner:n,statusField:s,entityTypeIcon:a,schema:r,didDragRef:i}){const c=Me(e.metadata),{attributes:o,listeners:u,setNodeRef:l,transform:f,isDragging:p}=Kr({id:`card:${e.id}`}),{setNodeRef:h,isOver:m}=ss({id:`card:${e.id}`}),y=Ye(n,wt(e)),x=j=>{i.current&&(j.preventDefault(),j.stopPropagation())};return t.jsx("div",{ref:j=>{l(j),h(j)},style:{transform:Qr.Translate.toString(f)},className:me(cr,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",p?"opacity-60":"",m?"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}`,...o,...u,children:t.jsx(lr,{className:"h-4 w-4"})}),t.jsx(Jt,{metadata:c,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(_e,{to:y,className:"font-medium text-foreground hover:underline",onClick:x,children:e.name}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof c.priority=="string"&&c.priority?t.jsx(nt,{variant:"outline",className:"text-xs",children:Ft(c.priority)}):null,typeof c[s]=="string"&&c[s]?t.jsx(nt,{variant:"secondary",className:"text-xs",children:Ft(String(c[s]))}):null]})]})]})})}function Fo({owner:e,entities:n,totalCount:s,schema:a,entityTypeIcon:r,onUpdate:i}){const c=b.useMemo(()=>Zt(a),[a]),o=b.useMemo(()=>To(a),[a]),[u,l]=b.useState(n),[f,p]=b.useState(()=>new Set),h=b.useRef(!1),m=Ur(Gr(Jr,{activationConstraint:{distance:6}})),y=b.useCallback(()=>{window.setTimeout(()=>{h.current=!1},0)},[]);b.useEffect(()=>{l(n)},[n]);const x=b.useMemo(()=>{if(!c)return new Map;const S=new Map(c.states.map(v=>[v.value,[]]));for(const v of u){const g=Dt(v,c.field),w=S.has(g)?g:c.states[0]?.value;w&&S.get(w)?.push(v)}for(const[v,g]of S)S.set(v,ps(g,o));return S},[u,o,c]);if(!c)return null;const j=S=>{p(v=>{const g=new Set(v);return g.has(S)?g.delete(S):g.add(S),g})},C=()=>{h.current=!0},E=S=>{const v=String(S.active.id),g=S.over?String(S.over.id):null,w=$o(u,v,g,c,o);if(!w){y();return}const{entityId:_,changedMetadata:P,nextMetadata:F}=w,G=u.find(V=>V.id===_)?.metadata;l(V=>In(V,_,F)),i(_,P).catch(()=>{l(V=>In(V,_,G))}),y()};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 ",Ft(c.field),typeof s=="number"&&s>u.length?t.jsxs(t.Fragment,{children:[" · ",t.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",u.length," of ",s," — narrow with search"]})]}):null]})]}),t.jsx(Yr,{sensors:m,onDragStart:C,onDragEnd:E,children:t.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:c.states.map(S=>{const v=x.get(S.value)??[],g=S.collapsed??S.terminal,w=g&&!f.has(S.value);return t.jsxs(Ao,{id:S.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:[S.terminal?t.jsx(ir,{className:"h-4 w-4 text-muted-foreground"}):null,t.jsx("h3",{className:"text-sm font-medium",children:S.label})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(nt,{variant:"secondary",className:"text-xs",children:v.length}),g?t.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>j(S.value),children:w?"Show":"Hide"}):null]})]}),w?t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[v.length," hidden ",S.label?.toLowerCase()," item",v.length===1?"":"s"]}):t.jsx("div",{className:"space-y-2",children:v.length>0?v.map(_=>t.jsx(Po,{entity:_,owner:e,statusField:c.field,entityTypeIcon:r,schema:a,didDragRef:h},_.id)):t.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",S.label?.toLowerCase()," items"]})})]},S.value)})})})]})}const Do=b.memo(Fo);function zo(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 gs(e,n){return{queryKey:["metric_series",e,zo(n)],queryFn:()=>ft("metric_series",{sql:n},{slug:e}),staleTime:6e4}}function xs(e,n){const s=!!e&&!!n,a=gs(e??"",n??"");return Gn({...a,enabled:s})}xs.queryOptions=(e,n)=>gs(e,n);function Wo(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 On=/^[a-z][a-z0-9_]*$/;function Ho(e){const n=Object.entries(e);for(const[r,i]of n){if(!On.test(r))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${r}'`);if(!On.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 Bo={"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 Vo(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 Ho(n)}catch{return null}}return typeof e.preset=="string"?Bo[e.preset]??null:null}function qo({owner:e,sql:n,lifecycle:s,preset:a,column:r,chart:i,height:c,width:o,color:u,label:l,className:f}){const p=b.useMemo(()=>Vo({sql:n,lifecycle:s,preset:a}),[n,s,a]),h=typeof e=="string"&&e?e:null,{data:m}=xs(h,p),y=String(r??""),x=b.useMemo(()=>Wo(m,y),[m,y]),j=b.useMemo(()=>!m?.columns?.length||!m.rows?[]:m.rows.map((E,S)=>({label:String(E[0]??"").slice(0,10),value:x[S]??0})),[m,x]);if(!h||!p||!y)return null;const C=i==="line"?t.jsx(Wr,{data:j,height:typeof c=="number"?c:void 0}):t.jsx(Hr,{data:x,height:typeof c=="number"?c:void 0,width:typeof o=="number"?o:void 0,color:typeof u=="string"?u:void 0});return l==null?t.jsx("div",{className:f,children:C}):t.jsxs("div",{className:f,children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:String(l)}),C]})}function Uo({metadata:e,metadataSchema:n,name:s,typeIcon:a,initialsFallback:r,className:i}){return t.jsx(Jt,{metadata:e,metadataSchema:n,name:String(s??""),typeIcon:a,initialsFallback:!!r,className:i})}function Go({entity:e,owner:n,className:s,onClick:a,children:r}){const i=e;if(!i)return t.jsx(t.Fragment,{children:r});const c=Ye(String(n??""),wt(i));return t.jsx(_e,{to:c,className:s,onClick:a,children:r})}function Yo({state:e}){return e?t.jsx(_o,{...e}):null}function Jo({state:e,onUpdate:n}){return e?t.jsx(Do,{...e,onUpdate:n}):null}const Ko={"entity-avatar":Uo,"entity-link":Go,"entity-table":Yo,"entity-board":Jo,"metric-series":qo};function Qo({ownerSlug:e,typeSlug:n,title:s,shape:a}){const[r,i]=b.useState(!1),c=Ke(),{visible:o,system:u,isTypesLoading:l}=ur(e),f=h=>{i(!1);const m=`/${e}/${Zn(h)}`;c({to:a?`${m}/${es}/${a}`:m})},p=h=>t.jsxs(xr,{value:`${h.name} ${h.slug}`,onSelect:()=>f(h.slug),children:[t.jsx(zt,{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(yr,{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(Ut,{open:r,onOpenChange:i,children:[t.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:t.jsx(Gt,{asChild:!0,children:t.jsxs(U,{type:"button",variant:"ghost",className:"-ml-2 h-auto gap-1.5 px-2 py-1 text-2xl font-semibold tracking-tight",children:[s,t.jsx(Xn,{className:"h-5 w-5 text-muted-foreground"})]})})}),t.jsx(Yt,{align:"start",className:"w-72 p-0",children:t.jsxs(dr,{children:[t.jsx(mr,{autoFocus:!0,placeholder:"Find a type…"}),t.jsxs(fr,{children:[t.jsx(hr,{children:l?"Loading types…":"No type matches."}),o.length>0?t.jsx(pn,{heading:"Types",children:o.map(p)}):null,u.length>0?t.jsx(pn,{heading:"System",children:u.map(p)}):null]}),t.jsx(pr,{}),t.jsxs(_e,{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(gr,{className:"h-4 w-4"}),"Schema map"]})]})})]})}function Xo(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,n])=>n.on==="entity").map(([n,s])=>({name:n,description:s.description}))}const ct={table:{label:"Table",icon:Sr},board:{label:"Board",icon:Yn},graph:{label:"Graph",icon:Vt}},ys=(e,n)=>`lobu.record-shape:v1:${e}/${n}`,Zo=new Set(["table","board","graph"]);function ei(e,n){const s=Dn(ys(e,n));return s&&Zo.has(s)?s:void 0}function ti(e,n,s){zn(ys(e,n),s)}const $n=":records";function ni({ownerSlug:e,entityTypeSlug:n,create:s,onCreateChange:a,viewKey:r,shape:i}){const{orgContext:c,hasOrgContext:o}=Ie(),u=Vn(n,c),{data:l,isLoading:f,error:p}=u;br(`/${e}`,c);const h=vr(),[m,y]=b.useState({key:"",page:0}),x=ts({strict:!1}),j=Ke(),C=Bt(),E=`/${e}/${Zn(n)}`,S=!f&&l?.slug===n,{collection:v,error:g,presentation:w,preset:_,edited:P,table:F}=b.useMemo(()=>Ya(x,l?.metadata_schema,!!r),[x,l?.metadata_schema,r]),B=S?g:void 0,G=b.useMemo(()=>Za(x,v),[x,v]),[V,fe]=b.useState(!1),[q,he]=b.useState(0),Q=v.search??"",I=v.segment,M=JSON.stringify(v),$=I?Xo(l).find(T=>T.name===I)??{name:I,description:""}:null,Y=T=>void j({to:".",search:{...ze(T),...G},replace:!0}),z=wr(u.data),ne=z?F.sort:to(F),oe=ne?.field,re=ne?.order,O=b.useMemo(()=>oe?[{id:oe,desc:re==="desc"}]:[],[oe,re]),ee=b.useCallback(T=>void j({to:".",search:{...r?ze(x):{},...G,$table:JSON.stringify(T)},replace:!0}),[j,r,x,G]),ge=b.useCallback(T=>{const Z=typeof T=="function"?T(O):T;Z[0]&&ee({...F,sort:{field:Z[0].id,order:Z[0].desc?"desc":"asc"}})},[O,ee,F]),ye=s===!0,ce=()=>a(!0),Oe=()=>a(!1),Qe=O[0]?.id,Xe=O[0]?O[0].desc?"desc":"asc":void 0,Ze=u.data?.metadata_schema,He=!!Zt(Ze)&&!z,jt=Ro(Ze,{isDerived:z}),ve=ns(c),st=Lt(ve.data??[],n,v),$e=(T,Z=!1,Se=ze(x))=>{const je=!r||!ve.data||Lt(ve.data,n,T).some(rt=>rt.key===r);j({to:je?".":E,search:{...je&&r?Se:{},...Ja(T,_?.key),$table:JSON.stringify(F)},replace:Z})},k=T=>{const Z=T?mt(T):{},Se=!r||Lt(ve.data??[],n,Z).some(je=>je.key===r);fe(!1),he(je=>je+1),j({to:Se?".":E,search:T?{$preset:T.key}:{}})},{isAdmin:d}=Wn(c.organizationId),N=jr(c),R=d&&!!l&&!u.isPlaceholderData,A=b.useRef(x);A.current=x;const D=async()=>{if(!_)return;const T=JSON.stringify(x),{data:Z}=await u.refetch(),Se=Z?.metadata_schema,je=Se?qt(Se[At]??{}):void 0,rt=je?.presets?.find(at=>at.key===_.key);if(!Z||!Se||!je||!rt){qn.error("This saved filter changed. Reload and try again.");return}const St=Ka(rt,v,F,je);await N.mutateAsync({slug:Z.slug,metadata_schema:{...Se,[At]:{...je,presets:je.presets?.map(at=>at.key===St.key?St:at)}}}).then(()=>!0,()=>!1)&&(await u.refetch(),JSON.stringify(A.current)===T&&k(St))},W=b.useMemo(()=>ei(e,n),[e,n]),J=kr(ve.data??[],n,{viewKey:r,shape:i??(r?void 0:W)},jt,v),H=J.kind==="builtin"?J.mode==="board"&&!He?"table":J.mode:null,X=H==="graph";b.useEffect(()=>{i&&S&&H&&ti(e,n,H)},[i,S,H,e,n]);const ue=["table",...He?["board"]:[],"graph"],ie=J.kind==="view"?J.view:null,Be=J.kind==="missing"?J.key:null,Ae=J.kind==="inapplicable"?J:null,Pe=H==="table"?50:200,Ve=`${n}?${M}&sort=${JSON.stringify(F.sort)}&size=${Pe}`,L=m.key===Ve?m.page:0,le=b.useCallback(T=>y(Z=>({key:Ve,page:T(Z.key===Ve?Z.page:0)})),[Ve]),K=gn(n,c,{limit:Pe,offset:L*Pe,search:Q.trim()||void 0,sortBy:Qe,sortOrder:Xe,segment:I,filters:v.filters,enabled:S&&!r&&!B}),te=gn(n,c,{limit:1,offset:0,parentId:null,search:Q.trim()||void 0,segment:I,filters:v.filters,enabled:S&&!r&&!B&&!z}),{data:ae,error:xe}=K,Fe=K.isLoading||K.isPending&&K.fetchStatus==="paused",Ee=B||p||(r?null:xe),Ce=!!r&&ve.data===void 0&&ve.isError,se=ae?.entities??[],we=ae?.metadata?.has_more??!1,pe=ae?.metadata?.total_count??0,et=se.length>0||Q.trim().length>0||L>0||!!I||!!v.filters?.length,de=l?.name?.trim()||We(n),Te=l?.icon||void 0,be=z,Ne=Ze,bs=!B&&(!o||!S||(r?ve.data===void 0&&!ve.isError:Fe||!z&&te.isLoading)),en=ae?.linked_entities??{},tn=te.data?.metadata?.total_count,nn=pe>0&&typeof tn=="number"?tn<pe:!1,sn=b.useMemo(()=>l?.measure_columns??[],[l?.measure_columns]),rn=b.useCallback(T=>ee({...F,columns:T}),[ee,F]),an=b.useMemo(()=>({entities:se,owner:e,schema:Ne,entityTypeIcon:Te,isDerived:be,measureColumns:sn,linkedEntityLookups:en,hasAnyParents:nn,sorting:O,onSortingChange:ge,visibleColumns:F.columns,columnChoices:Pt(Ne,be,se),onVisibleColumnsChange:rn,page:L,pageSize:Pe,totalCount:pe,hasMore:we,pageTitle:de,onPrevPage:()=>le(T=>Math.max(0,T-1)),onNextPage:()=>le(T=>T+1)}),[se,e,Ne,Te,be,sn,en,nn,O,F.columns,rn,ge,le,L,Pe,pe,we,de]),on=pe>se.length,ln=`showing first ${se.length} of ${pe} — narrow with search`,cn=b.useMemo(()=>({owner:e,entityType:l,entities:se,totalCount:pe,schema:Ne,entityTypeIcon:Te}),[e,l,se,pe,Ne,Te]),kt=b.useMemo(()=>({tableState:an,boardState:cn,owner:e,schema:Ne,entityType:l,entityTypeIcon:Te,totalCount:pe,isTruncated:on,truncationNotice:ln,canCreate:!be,addLabel:`Add ${l?.name||We(n)}`}),[an,cn,e,Ne,l,Te,pe,on,ln,be,n]),vs=b.useMemo(()=>Io({canShowBoard:He,builtinData:kt,builtInLabels:{table:ct.table.label,board:ct.board.label}}),[He,kt]),un=H?vs.find(T=>T.id===H)??null:null,ws=un?.template??hs,js=un?.data??kt,dn=T=>void j({to:T===$n?E:`${E}${Cr(T)}`,search:G}),Nt=ze(x),ks=Xr(ie?.params,Nt,T=>void j({to:".",search:{...ze(T),...G}})),Ns=()=>$e({...v,filters:[],segment:void 0},!1,Zr(ie?.params,Nt)),mn=`Moved on ${l?.name||l?.slug||n} board`,fn=b.useMemo(()=>(T,Z)=>h.mutateAsync({entityId:T,metadata:Z,field_note:mn}),[h,mn]),Ss=b.useMemo(()=>({updateEntity:fn,openCreate:()=>a(!0)}),[fn,a]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Qo,{ownerSlug:e,typeSlug:n,title:de,shape:r?null:H}),C?t.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"size-8 text-muted-foreground hover:text-foreground","aria-label":"Edit type",title:"Edit type",onClick:()=>C.open({href:`/${e}/events?${new URLSearchParams({type:n})}`,title:de}),children:t.jsx(Nr,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{children:[ye?t.jsx("div",{className:"max-w-3xl",children:t.jsx(qa,{onClose:Oe,entityTypeSlug:n,orgContext:c})}):null,!ye&&S&&t.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${de} views`,children:[!r&&ue.length>1&&t.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:ue.map(T=>{const Z=ct[T].icon,Se=H===T;return t.jsx(U,{type:"button",variant:"ghost",size:"sm","aria-pressed":Se,title:ct[T].label,"data-testid":`shape-${T}`,className:me("h-7 px-2",Se&&"bg-accent text-accent-foreground"),onClick:()=>void j({to:`${E}/${es}/${T}`,search:G,replace:!0}),children:t.jsx(Z,{className:"h-4 w-4"})},T)})}),r&&t.jsx(U,{variant:"ghost",onClick:()=>dn($n),children:"Records"}),!!w.presets?.length&&t.jsxs(Ut,{open:V,onOpenChange:fe,children:[t.jsx(Gt,{asChild:!0,children:t.jsxs(U,{variant:"outline",className:me("gap-2",P&&"border-dashed border-primary"),"data-edited":P||void 0,title:"Choose saved filter",children:[_?.label??(v.filters?.length||v.search?"Custom filter":"All records"),P?t.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,t.jsx(Xn,{className:"h-4 w-4 text-muted-foreground"})]})}),t.jsxs(Yt,{align:"start",className:"w-60 p-1",children:[t.jsx(U,{variant:_?"ghost":"secondary",className:"w-full justify-start",onClick:()=>k(),children:"All records"}),w.presets.map(T=>t.jsx(U,{variant:_?.key===T.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>k(T),children:T.label},T.key))]})]}),_&&P?t.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[t.jsx(U,{variant:"ghost",size:"sm",onClick:()=>k(_),children:"Reset"}),R?t.jsx(U,{size:"sm",disabled:N.isPending,onClick:()=>void D(),children:N.isPending?"Saving…":"Save"}):null]}):null,!B&&t.jsx(lo,{collection:v,schema:Ne,label:de,org:c??"",facetQuery:w.facetQuery,onChange:$e,viewFilters:ks,onClearAll:Ns,segmentChip:$?{id:"segment",label:"Segment",op:"is",value:We($.name),title:$.description||void 0,editor:$.description?{kind:"custom",render:()=>t.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:$.description})}:void 0,onRemove:()=>$e({...v,segment:void 0})}:void 0},`filters:${n}:${q}`),st.map(T=>t.jsx(U,{"data-testid":`tab-${T.key}`,variant:r===T.key?"secondary":"ghost","aria-pressed":r===T.key,onClick:()=>dn(T.key),children:T.name},T.key)),t.jsx(ro,{label:de,search:v.search,onSearch:(T,Z)=>$e({...v,search:T},Z),className:"ml-auto w-full sm:w-64"},`search:${n}:${q}`),!be&&!r?t.jsxs(U,{size:"sm",onClick:()=>ce(),children:[t.jsx(Pn,{className:"mr-2 h-4 w-4"}),"Add ",de||"Entity"]}):null]}),ye?null:bs?X?t.jsx(Kt,{label:`Loading ${de} graph`}):t.jsx(si,{}):Ee?t.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[Ee.message||`Failed to load ${de.toLowerCase()}.`,B&&t.jsx(U,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>$e({}),children:"Clear filters"})]}):Ce?t.jsx(rs,{onRetry:()=>void ve.refetch()}):Ae?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:["“",Ae.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(Ae.when).map(([T,Z])=>`${T} is ${Z===null?"not supplied":String(Z)}`).join(" and "),"."]}),t.jsx(_e,{to:E,search:G,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${de}`})]}):Be?t.jsx(as,{viewKey:Be,backTo:E,backLabel:`Back to ${de}`}):ie?t.jsx(os,{orgSlug:e,viewKey:ie.key,scope:{type:n,collection:v},params:Nt,onParamsChange:Y,contentHash:ie.content_hash,title:ie.name,minHeight:320}):X&&et?t.jsx(vo,{ownerSlug:e,typeSlug:n,sourceBacked:z,records:se.map(T=>({...T,id:T.id??JSON.stringify([T.entity_type,T.slug])})),hasMore:we}):et?t.jsx(Br,{template:ws,data:js,actions:Ss,components:Ko}):t.jsx(Kn,{icon:Er,iconElement:t.jsx(zt,{icon:l?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${de.toLowerCase()} yet`,description:be?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${l?.name?.toLowerCase()||"entity"}.`,actionLabel:be?void 0:`Add ${l?.name||"Entity"}`,onAction:be?void 0:()=>ce()})]})]})}function si(){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(ke,{className:"h-9 max-w-sm flex-1"}),t.jsx(ke,{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(ke,{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(ke,{className:"h-3 flex-1"}),t.jsx(ke,{className:"h-3 w-16 shrink-0"})]},n))})]})]})}function ri({ownerSlug:e,typeScope:n,create:s,createType:a=!1,viewKey:r,shape:i}){const c=Ke(),{orgContext:o}=Ie(),u=ts({strict:!1}),l=n?_r(n):void 0,f=l==="$member",p=()=>{c({to:"/$owner/data",params:{owner:e},search:{}})},h=y=>{if(!l)return;const x=Hn(e,l);c({to:x.to,params:x.params,search:y?{create:!0}:{},replace:!0})},m=a?t.jsx("div",{className:"mx-auto w-full max-w-3xl",children:t.jsx(ta,{entityType:null,orgContext:o,onClose:p})}):l?t.jsx(ni,{ownerSlug:e,entityTypeSlug:l,create:s,onCreateChange:h,viewKey:r,shape:i}):t.jsx(ai,{ownerSlug:e,viewKey:r,search:u});return t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:f?t.jsx(na,{children:m}):m})}function ai({ownerSlug:e,viewKey:n,search:s}){const a=Ke(),{orgContext:r}=Ie(),{data:i,isError:c,refetch:o}=ns(r),u=Mr(i??[],n),l=Tr(),f=Rr(i??[]);return n&&i===void 0?c?t.jsx(rs,{onRetry:()=>void o()}):null:u.kind==="missing"?t.jsx(as,{viewKey:u.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:[l&&f.length>0?t.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-wrap gap-1",children:[t.jsx(_e,{to:"/$owner/data",params:{owner:e},search:{},activeOptions:{exact:!0},"aria-current":n?void 0:"page",className:An(!n),children:"Overview"}),f.map(p=>t.jsx(_e,{to:"/$owner/data/-/views/$viewKey",params:{owner:e,viewKey:p.key},search:{},activeOptions:{exact:!0},"aria-current":n===p.key?"page":void 0,className:An(n===p.key),children:p.name},p.key))]}):null,l&&c?t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Couldn’t load views."," ",t.jsx("button",{type:"button",onClick:()=>void o(),className:"underline underline-offset-4",children:"Retry"})]}):null,u.kind==="view"?t.jsxs(t.Fragment,{children:[t.jsx(ea,{decls:u.view.params,params:ze(s),onParamsChange:p=>void a({to:".",search:p})}),t.jsx(os,{orgSlug:e,viewKey:u.view.key,scope:{},params:ze(s),onParamsChange:p=>void a({to:".",search:p,replace:!0}),contentHash:u.view.content_hash,title:u.view.name,minHeight:400})]}):t.jsx(Va,{ownerSlug:e})]})}const An=e=>me("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 xi({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(Ir,{}),t.jsx(Lr,{owner:e,children:c=>t.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:t.jsx(ri,{ownerSlug:c.ownerSlug,typeScope:n,create:s,createType:a,viewKey:r,shape:i})})})]})}export{xi as M};
|
|
74
|
+
//# sourceMappingURL=memory-browse-page-DTlM_9MY.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ax as g,ay as y,j as s,
|
|
2
|
-
//# sourceMappingURL=model-selector-
|
|
1
|
+
import{ax as g,ay as y,j as s,eJ as N,cS as m,dK as p,T as f,B as w,eL as b}from"./index-JmEl29py.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 S(o,r){const l=o.trim();return l.length>0&&l!=="auto"&&!r.some(i=>i.value===l)}function D({value:o,onChange:r,placeholder:l,disabled:i,className:d}){const{data:e=[]}=g(),{data:a=[]}=y(),t=M(e,a),x=t.find(c=>c.value===o),h=o==="auto"?"auto":x?.value??o;return s.jsx(N,{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=S(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{D as M,M as b,S as s};
|
|
2
|
+
//# sourceMappingURL=model-selector-BeFuFH7p.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{iW as e,j as r}from"./index-JmEl29py.js";import{a as m}from"./agents-workbench-D1YL3VAB.js";import"./agent-editor-form-C24p9LLg.js";import"./model-selector-BeFuFH7p.js";import"./proposal-review-shell-CmLy1MZf.js";import"./runs-B0zVYb-w.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-BAVaDnKN.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{h2 as o,q as p,a0 as x,k as h,an as f,a$ as b,j as a,aC as w,gd as A,aS as C,ge as L,L as j,gf as S,fh as N,aR as k,bQ as y}from"./index-JmEl29py.js";import{A as E}from"./agent-editor-form-C24p9LLg.js";import"./model-selector-BeFuFH7p.js";const R="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function $(){const{owner:e}=o.useParams(),t=o.useSearch(),r=p(),i=x(),{isAuthenticated:c}=h(),{isMember:g,isLoading:m}=f(),n=c&&g,{data:u=[],isLoading:d}=b({enabled:n});return a.jsx("div",{className:R,children:a.jsxs(w,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(A,{breadcrumb:a.jsx(L,{crumbs:[a.jsx(j,{to:"/$owner/agents",params:{owner:e},className:S,children:"Agents"},"agents")]}),icon:a.jsx(C.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),m||n&&d?a.jsx(N,{rows:1}):n?a.jsx(E,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const l=["agents",e];if(await i.refetchQueries({queryKey:l,exact:!0}),t.platform&&t.listen){await r({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await r({to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:s},search:{run_id:void 0}})}}):a.jsx(k,{icon:y,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{$ as component};
|
|
2
|
+
//# sourceMappingURL=new-1QLuS1o-.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=new-
|
|
1
|
+
import{q as R,k as F,z as E,r,j as e,E as v,I as S,B as L,F as N,G as U}from"./index-JmEl29py.js";import{C as I,a as k,b as A,c as T}from"./card-Cspo-4M6.js";import{F as q}from"./full-page-spinner-DtmqQmgl.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function H(){const l=R(),{session:u,isReady:d}=F(),{slug:n,name:i}=E.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(q,{});const P=a=>{const s=U(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},z=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(I,{children:[e.jsx(k,{children:e.jsx(A,{children:"Create organization"})}),e.jsx(T,{children:e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{H as component};
|
|
2
|
+
//# sourceMappingURL=new-ChwqLmVY.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{q as p,an as N,cA as w,r as l,j as e,ge as _,L as f,gf as b,ba as y,S as j,gO as v,at as C}from"./index-JmEl29py.js";import{C as A,A as S}from"./create-automation-form-y3tq2QIJ.js";import"./cronstrue-CeUS_78Q.js";import"./entity-options-BcTafZ2e.js";import"./connection-label-BobuYiAG.js";import"./use-automations-DS3uz3pb.js";import"./model-selector-BeFuFH7p.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-C8FJbT2P.js";import"./index-wHFQv1aT.js";import"./use-mention-search-CAFbh-Dk.js";function k(n){return n.includes(":")?n.slice(n.indexOf(":")+1):n}function T({prefillAgentId:n,onCancel:t,initialTriggers:m}){const{org:g}=N(),[o,i]=l.useState({ready:!1,triggers:[]}),[a,x]=l.useState(),d=l.useCallback(s=>{i(u=>JSON.stringify(u)===JSON.stringify(s)?u:s)},[]),c=a??m;return e.jsx(A,{startFromScratch:!!m,organizationId:g?.id??"",prefillAgentId:n,onClose:t,onPrefillTriggers:s=>x(s.length>0?s:void 0),onSuccess:t,hideHeader:!0,hideCancel:!0,submitLabel:"Create Automation",submitDisabled:!o.ready,createFields:{triggers:o.triggers},triggerFields:e.jsx(S,{organizationId:g?.id??null,initialTriggers:c,onChange:d},JSON.stringify(c??"new"))})}function B({owner:n,prefilled:t}){const m=p(),{org:g}=N(),o=w(g?.id??null,{status:"active",limit:500}),i=!!(t?.platform&&(t.listen||t.resource)),a=l.useMemo(()=>{if(!t?.platform||!t.listen&&!t.resource)return;const c=o.data??[],s=t.connection?c.find(r=>r.slug===t.connection):(()=>{const r=c.filter(h=>h.connector_key!==t.platform?!1:t.resource?!0:h.facets.chat&&(h.external_tenant_id??"")===(t.team??""));return r.length===1?r[0]:void 0})();if(t.connection&&!s)return;const u=t.events?.split(",").map(r=>r.trim()).filter(Boolean)??[];return[{kind:"event",source:"connector",connector_key:t.platform,...s?{connection_id:s.id}:{},event_types:u.length>0?u:t.listen?["message.created"]:[],match:t.resource?{resource_ref:t.resource,...t.resource_type?{resource_type:t.resource_type}:{}}:{channel_id:k(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]),x=()=>void m({to:"/$owner/automations",params:{owner:n}}),d=a?t?.resource?`React to changes on ${t.label??t.resource}.`:`React to messages in ${t?.label??t?.listen}.`:i&&!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(_,{crumbs:[e.jsx(f,{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(y,{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:d}),t?.listen&&a?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose an agent below, or"," ",e.jsx(f,{to:"/$owner/agents/new",params:{owner:n},search:t,className:"underline underline-offset-4",children:"create an agent"})," ","and return to this conversation setup."]}):null,i&&o.isLoading?e.jsxs("div",{className:"space-y-3",children:[e.jsx(j,{className:"h-10 w-full"}),e.jsx(j,{className:"h-32 w-full"})]}):i&&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(T,{prefillAgentId:t?.agent,onCancel:x,initialTriggers:a})]})})}function z(){const{owner:n}=v.useParams(),t=v.useSearch();return e.jsx(C,{owner:n,children:()=>e.jsx(B,{owner:n,prefilled:t})})}export{z as component};
|
|
2
|
+
//# sourceMappingURL=new-D21LGMl6.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,P as y,Q as $,T as E,B as R,r as u,U as z}from"./index-9YuSRymd.js";const W=["mcp:read","mcp:write","mcp:admin"],P=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],S={read:0,write:1,admin:2};function I(s){return s.includes("mcp:admin")?"admin":s.includes("mcp:write")?"write":s.includes("mcp:read")?"read":null}function D(s,a){const r=s.filter(x=>!W.includes(x));if(!a)return r;const i=I(s);return!i||S[a]>S[i]?r:["mcp:read",...a==="write"||a==="admin"?["mcp:write"]:[],...a==="admin"?["mcp:admin"]:[],...r]}function H({idPrefix:s,clientName:a,requestedScopes:r,accessLevel:i,onAccessLevelChange:x,sensitiveScopesAcknowledged:v=!1,onSensitiveScopesAcknowledgedChange:g,disabled:b=!1}){const k=I(r),f=r.includes("profile:read"),p=r.includes("device_worker:run"),o=r.includes("connections:token"),j=p||o,c=r.filter(n=>!W.includes(n)&&n!=="profile:read"&&n!=="device_worker:run"&&n!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{"aria-labelledby":`${s}-application`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-application`,className:"text-sm font-medium",children:"Application"}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a||"Unnamed application"})})]}),k&&e.jsxs("fieldset",{className:"space-y-2",disabled:b,children:[e.jsx("legend",{className:"text-sm font-medium",children:"Access level"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose the maximum access this application should receive."}),e.jsx("div",{className:"space-y-2",children:P.filter(n=>S[n.value]<=S[k]).map(n=>{const l=`${s}-access-${n.value}`,h=i===n.value;return e.jsxs("label",{htmlFor:l,className:$("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:l,type:"radio",name:`${s}-access-level`,value:n.value,checked:h,onChange:()=>x(n.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[n.title,n.risk==="high"&&e.jsx(y,{variant:"destructive",children:"High risk"})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:n.description})]})]},n.value)})})]}),f&&e.jsxs("section",{"aria-labelledby":`${s}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(y,{variant:"secondary",children:"Included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to."})]})]}),c.length>0&&e.jsxs("section",{"aria-labelledby":`${s}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:c.map(n=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:n},n))})]}),j&&e.jsxs("section",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Device capabilities"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These capabilities are fixed by the device request and cannot be reduced here."})]}),e.jsxs("ul",{className:"space-y-2",children:[p&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Operate this device"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run jobs and Automations through capabilities advertised by this device."})]}),o&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Use connected services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request short-lived access for services you connected to Lobu."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-background p-3",children:[e.jsx(E,{id:`${s}-sensitive-acknowledgement`,checked:v,disabled:b,onCheckedChange:n=>g?.(n===!0),className:"mt-0.5"}),e.jsx("label",{htmlFor:`${s}-sensitive-acknowledgement`,className:"cursor-pointer text-sm font-medium text-foreground",children:"I initiated this request and confirmed that the device code matches."})]})]})]})}function T({idPrefix:s,orgList:a,selectedOrgIds:r,onWorkspaceAccessChange:i,onSelectedOrgChange:x,orgsLoading:v,orgsError:g,onRetry:b,disabled:k=!1,deviceHomeOrgId:f=null,allowMultiple:p}){const o=`${s}-workspace-access-legend`,j=r.length===a.length;return v?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]}):g?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:b,children:"Retry"})]})]}):a.length===0?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]}):e.jsxs("fieldset",{className:"space-y-3",disabled:k,children:[e.jsx("legend",{id:o,className:"sr-only",children:"Workspace access"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:p?"Choose where this application can operate.":"Choose one workspace this application can access."})]}),p&&!j&&e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:()=>i("all_current"),children:["Select all ",a.length]})]}),f&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p?"The device workspace is always included. Additional workspaces grant MCP access only.":"MCP access follows the device workspace."}),e.jsx("div",{className:"space-y-2",children:a.map(c=>{const n=`${s}-workspace-${c.id}`,l=c.id===f,h=r.includes(c.id);return e.jsxs("div",{className:$("flex items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary/40 bg-primary/5"),children:[e.jsx(E,{id:n,checked:h,disabled:k||l||f!==null&&!p,onCheckedChange:N=>x(c.id,N===!0),className:"mt-0.5"}),e.jsxs("label",{htmlFor:n,className:"min-w-0 flex-1 cursor-pointer space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[c.name,c.isPersonal&&e.jsx(y,{variant:"outline",children:"Personal"}),l&&e.jsx(y,{variant:"secondary",children:"Device workspace"})]}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:c.slug})]})]},c.id)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("p",{"aria-live":"polite",children:[r.length," of ",a.length," workspaces selected."]}),j&&e.jsx(y,{variant:"secondary",children:"All currently available"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),r.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function q(s,a){u.useEffect(()=>{if(a||s)return;const r=new URL("/auth/login",window.location.origin);r.searchParams.set("callbackUrl",window.location.href),window.location.href=r.toString()},[s,a])}function F(s,a){return s.length===a.length&&s.every((r,i)=>r===a[i])}function V(s={}){const{requireDeviceHome:a=!1,deviceHomeOrgId:r=null,allowMultiple:i=!0}=s,{data:x,error:v,isPending:g,refetch:b}=z(),[k,f]=u.useState("selected"),[p,o]=u.useState([]),j=u.useRef(!1),c=u.useMemo(()=>x?x.filter(t=>t.is_member).map(t=>({id:t.id,name:t.name,slug:t.slug,isPersonal:t.is_personal===!0})):[],[x]),n=c.find(t=>t.isPersonal)?.id??null,l=a?r&&c.some(t=>t.id===r)?r:n:null,h=u.useRef(c);h.current=c;const N=v instanceof Error?v.message:v?"Unable to load workspaces":null;u.useEffect(()=>{if(g||N)return;const t=c.map(d=>d.id),m=new Set(t);o(d=>{const C=j.current?d.filter(A=>m.has(A)):[n??t[0]].filter(A=>!!A);return j.current=!0,F(d,C)?d:C})},[c,N,g,n]);const L=u.useCallback(t=>{if(t==="all_current"){if(!i)return;o(h.current.map(m=>m.id))}f(t)},[i]),M=u.useCallback((t,m)=>{h.current.some(d=>d.id===t)&&(a&&(t===l||!i)||(f("selected"),o(d=>m?i?d.includes(t)?d:[...d,t]:[t]:d.filter(C=>C!==t))))},[i,l,a]),w=u.useMemo(()=>{if(a&&l&&!i)return[l];const t=new Set(p);return a&&l&&t.add(l),c.filter(m=>t.has(m.id)).map(m=>m.id)},[i,p,l,c,a]),_=u.useCallback(()=>{const t=h.current,m=t.find(d=>d.isPersonal)?.id??t[0]?.id;j.current=t.length>0,f("selected"),o(m?[m]:[])},[]),O=!g&&!N&&c.length>0&&w.length>0&&(i||w.length===1)&&(!a||l!==null&&w.includes(l)),U=u.useCallback(()=>{b()},[b]);return{orgList:c,workspaceAccess:k,setWorkspaceAccess:L,selectedOrgIds:w,toggleSelectedOrgId:M,resetWorkspaceSelection:_,personalOrgId:n,deviceHomeOrgId:l,orgsLoading:g,orgsError:N,retryOrgs:U,workspaceSelectionReady:O}}function K(s){if(!s)return null;try{return new URL(s).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}export{H as A,T as W,I as a,q as b,K as g,D as s,V as u};
|
|
2
|
-
//# sourceMappingURL=oauth-workspace-access-
|
|
1
|
+
import{j as e,Q as y,T as $,U as E,B as R,r as u,V as z}from"./index-JmEl29py.js";const W=["mcp:read","mcp:write","mcp:admin"],F=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],S={read:0,write:1,admin:2};function I(s){return s.includes("mcp:admin")?"admin":s.includes("mcp:write")?"write":s.includes("mcp:read")?"read":null}function D(s,a){const r=s.filter(x=>!W.includes(x));if(!a)return r;const i=I(s);return!i||S[a]>S[i]?r:["mcp:read",...a==="write"||a==="admin"?["mcp:write"]:[],...a==="admin"?["mcp:admin"]:[],...r]}function H({idPrefix:s,clientName:a,requestedScopes:r,accessLevel:i,onAccessLevelChange:x,sensitiveScopesAcknowledged:v=!1,onSensitiveScopesAcknowledgedChange:g,disabled:b=!1}){const k=I(r),f=r.includes("profile:read"),p=r.includes("device_worker:run"),o=r.includes("connections:token"),j=p||o,c=r.filter(n=>!W.includes(n)&&n!=="profile:read"&&n!=="device_worker:run"&&n!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("section",{"aria-labelledby":`${s}-application`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-application`,className:"text-sm font-medium",children:"Application"}),e.jsx("div",{className:"rounded-lg border p-4",children:e.jsx("span",{className:"text-sm font-semibold text-foreground",children:a||"Unnamed application"})})]}),k&&e.jsxs("fieldset",{className:"space-y-2",disabled:b,children:[e.jsx("legend",{className:"text-sm font-medium",children:"Access level"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose the maximum access this application should receive."}),e.jsx("div",{className:"space-y-2",children:F.filter(n=>S[n.value]<=S[k]).map(n=>{const l=`${s}-access-${n.value}`,h=i===n.value;return e.jsxs("label",{htmlFor:l,className:$("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:l,type:"radio",name:`${s}-access-level`,value:n.value,checked:h,onChange:()=>x(n.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[n.title,n.risk==="high"&&e.jsx(y,{variant:"destructive",children:"High risk"})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:n.description})]})]},n.value)})})]}),f&&e.jsxs("section",{"aria-labelledby":`${s}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(y,{variant:"secondary",children:"Included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to."})]})]}),c.length>0&&e.jsxs("section",{"aria-labelledby":`${s}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:c.map(n=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:n},n))})]}),j&&e.jsxs("section",{className:"space-y-3 rounded-md border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Device capabilities"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"These capabilities are fixed by the device request and cannot be reduced here."})]}),e.jsxs("ul",{className:"space-y-2",children:[p&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Operate this device"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run jobs and Automations through capabilities advertised by this device."})]}),o&&e.jsxs("li",{className:"rounded-md bg-background/70 p-3",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Use connected services"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request short-lived access for services you connected to Lobu."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-background p-3",children:[e.jsx(E,{id:`${s}-sensitive-acknowledgement`,checked:v,disabled:b,onCheckedChange:n=>g?.(n===!0),className:"mt-0.5"}),e.jsx("label",{htmlFor:`${s}-sensitive-acknowledgement`,className:"cursor-pointer text-sm font-medium text-foreground",children:"I initiated this request and confirmed that the device code matches."})]})]})]})}function T({idPrefix:s,orgList:a,selectedOrgIds:r,onWorkspaceAccessChange:i,onSelectedOrgChange:x,orgsLoading:v,orgsError:g,onRetry:b,disabled:k=!1,deviceHomeOrgId:f=null,allowMultiple:p}){const o=`${s}-workspace-access-legend`,j=r.length===a.length;return v?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]}):g?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(R,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:b,children:"Retry"})]})]}):a.length===0?e.jsxs("section",{"aria-labelledby":o,className:"space-y-2",children:[e.jsx("p",{id:o,className:"text-sm font-medium",children:"Workspace access"}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]}):e.jsxs("fieldset",{className:"space-y-3",disabled:k,children:[e.jsx("legend",{id:o,className:"sr-only",children:"Workspace access"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:p?"Choose where this application can operate.":"Choose one workspace this application can access."})]}),p&&!j&&e.jsxs(R,{type:"button",variant:"outline",size:"sm",onClick:()=>i("all_current"),children:["Select all ",a.length]})]}),f&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p?"The device workspace is always included. Additional workspaces grant MCP access only.":"MCP access follows the device workspace."}),e.jsx("div",{className:"space-y-2",children:a.map(c=>{const n=`${s}-workspace-${c.id}`,l=c.id===f,h=r.includes(c.id);return e.jsxs("div",{className:$("flex items-start gap-3 rounded-md border p-3 transition-colors",h&&"border-primary/40 bg-primary/5"),children:[e.jsx(E,{id:n,checked:h,disabled:k||l||f!==null&&!p,onCheckedChange:N=>x(c.id,N===!0),className:"mt-0.5"}),e.jsxs("label",{htmlFor:n,className:"min-w-0 flex-1 cursor-pointer space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[c.name,c.isPersonal&&e.jsx(y,{variant:"outline",children:"Personal"}),l&&e.jsx(y,{variant:"secondary",children:"Device workspace"})]}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:c.slug})]})]},c.id)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("p",{"aria-live":"polite",children:[r.length," of ",a.length," workspaces selected."]}),j&&e.jsx(y,{variant:"secondary",children:"All currently available"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),r.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function V(s,a){u.useEffect(()=>{if(a||s)return;const r=new URL("/auth/login",window.location.origin);r.searchParams.set("callbackUrl",window.location.href),window.location.href=r.toString()},[s,a])}function P(s,a){return s.length===a.length&&s.every((r,i)=>r===a[i])}function q(s={}){const{requireDeviceHome:a=!1,deviceHomeOrgId:r=null,allowMultiple:i=!0}=s,{data:x,error:v,isPending:g,refetch:b}=z(),[k,f]=u.useState("selected"),[p,o]=u.useState([]),j=u.useRef(!1),c=u.useMemo(()=>x?x.filter(t=>t.is_member).map(t=>({id:t.id,name:t.name,slug:t.slug,isPersonal:t.is_personal===!0})):[],[x]),n=c.find(t=>t.isPersonal)?.id??null,l=a?r&&c.some(t=>t.id===r)?r:n:null,h=u.useRef(c);h.current=c;const N=v instanceof Error?v.message:v?"Unable to load workspaces":null;u.useEffect(()=>{if(g||N)return;const t=c.map(d=>d.id),m=new Set(t);o(d=>{const C=j.current?d.filter(A=>m.has(A)):[n??t[0]].filter(A=>!!A);return j.current=!0,P(d,C)?d:C})},[c,N,g,n]);const L=u.useCallback(t=>{if(t==="all_current"){if(!i)return;o(h.current.map(m=>m.id))}f(t)},[i]),M=u.useCallback((t,m)=>{h.current.some(d=>d.id===t)&&(a&&(t===l||!i)||(f("selected"),o(d=>m?i?d.includes(t)?d:[...d,t]:[t]:d.filter(C=>C!==t))))},[i,l,a]),w=u.useMemo(()=>{if(a&&l&&!i)return[l];const t=new Set(p);return a&&l&&t.add(l),c.filter(m=>t.has(m.id)).map(m=>m.id)},[i,p,l,c,a]),_=u.useCallback(()=>{const t=h.current,m=t.find(d=>d.isPersonal)?.id??t[0]?.id;j.current=t.length>0,f("selected"),o(m?[m]:[])},[]),O=!g&&!N&&c.length>0&&w.length>0&&(i||w.length===1)&&(!a||l!==null&&w.includes(l)),U=u.useCallback(()=>{b()},[b]);return{orgList:c,workspaceAccess:k,setWorkspaceAccess:L,selectedOrgIds:w,toggleSelectedOrgId:M,resetWorkspaceSelection:_,personalOrgId:n,deviceHomeOrgId:l,orgsLoading:g,orgsError:N,retryOrgs:U,workspaceSelectionReady:O}}function K(s){if(!s)return null;try{return new URL(s).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}export{H as A,T as W,I as a,V as b,K as g,D as s,q as u};
|
|
2
|
+
//# sourceMappingURL=oauth-workspace-access-D15LYKSe.js.map
|