@lobu/runtime-server 24.1.0 → 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 +44222 -40683
- 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 +0,0 @@
|
|
|
1
|
-
import{o as x,bh as C,j as e,bp as _,bq as m,br as S,bs as b,bt as c,eR as u}from"./index-9YuSRymd.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:p,placeholder:d="Choose a connection",includeWorkspaceEvents:i=!1,ariaLabel:g="Connection"}){const f=x(),l=C().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;f({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(_,{value:r,onValueChange:j,disabled:p,children:[e.jsx(m,{"aria-label":g,children:e.jsx(S,{placeholder:d})}),e.jsxs(b,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx(c,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(c,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||i?e.jsx(u,{}):null,e.jsx(c,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{y as C,v as f};
|
|
2
|
-
//# sourceMappingURL=entity-options-Clz_WXK-.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d2 as pe,r as S,bQ as fe,fk as ge,dS as X,j as e,B as N,u as H,jb as ve,S as Y,fu as ne,jg as je,w as ye,o as ie,jh as be,bR as L,g as ke,dQ as re,e_ as _e,jc as Ne,ji as we,b9 as Se,c0 as J,fi as Re,f4 as Fe,gP as Ee,gQ as De,gR as Ce,gS as Le,gT as Pe,jj as Be,bU as Ie,z,I as Z,fN as Te,b8 as Ve,fl as Oe,dG as U,i as Ae,jk as Me,L as $e,gK as ze}from"./index-9YuSRymd.js";import{R as Ue}from"./record-activity-ZJntBfN_.js";import{n as Ke,c as K,g as He,D as We,S as Ge}from"./schema-value-normalization-CKdPjdPC.js";import{r as Qe}from"./record-field-peek-Brh1IQGy.js";import{S as qe,E as Xe}from"./entity-avatar-mdh7Kq5D.js";import{a as oe,V as ee,M as Ye,b as Je}from"./view-param-filters-B0quibBi.js";import{a as Ze}from"./source-record-panels-BdfOVPWn.js";import{l as et,L as tt,s as W,R as le,i as st,S as at}from"./events-feed-DO3IiJO2.js";import{a as nt}from"./record-session-Pbr5czGw.js";import"./filter-editors-Bwhqj7lY.js";import"./connection-label-BobuYiAG.js";import"./clients-BhNl1tVq.js";import"./client-rows-BYbsXGy9.js";import"./agent-loading-shells-B7v6Cffw.js";import"./member-scope-gate-DD4YBFn-.js";import"./card-jzhQrMDP.js";import"./app-bridge-BCm4muqj.js";import"./conversations-table-D_HOe1jN.js";function it(t,s){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const n=!!(t.condition??!0),i=t.blockerFn;return{shouldBlockFn:async()=>n&&i!==void 0?await i():n,enableBeforeUnload:n,withResolver:i===void 0}}function rt(t,s){const{shouldBlockFn:n,enableBeforeUnload:i=!0,disabled:a=!1,withResolver:c=!1}=it(t),o=pe(),{history:r}=o,[m,x]=S.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return S.useEffect(()=>{const p=async f=>{function l(j){const g=o.parseLocation(j),_=o.getMatchedRoutes(g.pathname);return _.foundRoute===void 0?{routeId:"__notFound__",fullPath:g.pathname,pathname:g.pathname,params:_.routeParams,search:o.options.parseSearch(j.search)}:{routeId:_.foundRoute.id,fullPath:_.foundRoute.fullPath,pathname:g.pathname,params:_.routeParams,search:o.options.parseSearch(j.search)}}const h=l(f.currentLocation),d=l(f.nextLocation);if(h.routeId==="__notFound__"&&d.routeId!=="__notFound__")return!1;const u=await n({action:f.action,current:h,next:d});if(!c)return u;if(!u)return!1;const b=await new Promise(j=>{x({status:"blocked",current:h,next:d,action:f.action,proceed:()=>j(!1),reset:()=>j(!0)})});return x({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),b};return a?void 0:r.block({blockerFn:p,enableBeforeUnload:i})},[n,i,a,c,r,o]),m}function $(t,s){return X(K(t))===X(K(s))}function ot(t,s){const n={};for(const i of new Set([...Object.keys(t),...Object.keys(s)]))$(t[i],s[i])||(n[i]=K(t[i])??null);return Object.keys(n).length>0?n:void 0}function lt(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(n=>{try{return!$(t[n],s[n])}catch{return!0}})}function te(t,s){return{name:t.name,slug:t.slug,metadata:Ke(t.metadata??{},s)}}function ct(t,s,n){const i=new Set(n),a={},c={},o=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const r of o){const m=i.has(r),x=m?t.values.metadata[r]:t.baseline.metadata[r],p=$(x,s.metadata[r])?x:s.metadata[r];p!==void 0&&(a[r]=p);let f=!1;if(!m)try{f=!$(t.values.metadata[r],t.baseline.metadata[r])}catch{f=!0}const l=f?t.values.metadata[r]:p;l!==void 0&&(c[r]=l)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:c}}}function dt({entity:t,schema:s,orgContext:n}){const i=S.useMemo(()=>te(t,s),[t,s]),a=fe(t.id,i,s),c=ge(n),{values:o,baseline:r,commit:m}=a,x=S.useMemo(()=>lt(o.metadata,r.metadata),[o.metadata,r.metadata]),p=o.name!==r.name||o.slug!==r.slug,f=S.useCallback((h,d)=>a.setValues(u=>({...u,metadata:{...u.metadata,[h]:d}})),[a.setValues]),l=async({note:h}={})=>{if(!a.canSubmit)return null;const d=ot(o.metadata,r.metadata),u=o.name.trim()!==r.name.trim();if(!d&&!p)return null;const b=await c.mutateAsync({entityId:t.id,name:u?o.name.trim():void 0,slug:o.slug,metadata:d,field_note:d&&h?.trim()||void 0}),j=te(b.entity,s);return m(g=>ct(g,j,Object.keys(d??{})),j),{held:b.blocked_fields??[],approvalUrl:b.approval_url}};return{values:o,baseline:r,revision:a.revision,setValues:a.setValues,setMetadataField:f,reset:a.reset,save:l,saving:c.isPending,dirtyKeys:x,identityDirty:p,isDirty:p||x.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const ut=3,mt=50;function ce(t){const s=S.useRef(null);return S.useEffect(()=>{t&&(s.current?.scrollIntoView?.({block:"start"}),s.current?.focus())},[t]),s}function I({headingRef:t,children:s}){return e.jsx("h3",{ref:t,tabIndex:-1,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground outline-none",children:s})}function ht({entityId:t,entityName:s,ownerSlug:n,orgContext:i,focus:a,collapsed:c=!1}){const o=H(),r=ce(a),{data:m,isLoading:x,isError:p,refetch:f}=ve(t,i,{limit:mt});if(x)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsx(Y,{className:"h-4 w-24"}),e.jsx(Y,{className:"h-6 w-full rounded-md"})]});if(p||!m)return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Could not load this record's links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void f(),children:"Retry"})]})]});if(m.countsByType.length===0)return a?e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No links to other records yet."})]}):null;if(c){const l=m.countsByType.flatMap(h=>{const d=h.count===1?m.rows.find(b=>b.relationship_type_slug===h.relationship_type_slug):void 0,u=d?et(d,t):void 0;return[h.relationship_type_name,u?.self?"this record":u?.name??String(h.count)]});return e.jsxs("section",{className:"space-y-1","aria-label":"Linked records",children:[e.jsx(I,{headingRef:r,children:"Linked"}),e.jsx("p",{"data-testid":"linked-summary",className:"truncate text-sm text-muted-foreground",children:l.join(" · ")})]})}return e.jsxs("section",{className:"space-y-3","aria-label":"Linked records",children:[e.jsx(I,{headingRef:r,children:"Linked"}),m.countsByType.map(l=>{const h=m.rows.filter(u=>u.relationship_type_slug===l.relationship_type_slug).slice(0,ut),d=l.count>h.length;return e.jsxs("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-baseline gap-x-3 text-sm",children:[e.jsxs("p",{className:"text-muted-foreground",children:[l.relationship_type_name,d?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",l.count]}):null]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[h.map(u=>e.jsx(tt,{row:u,entityId:t,ownerSlug:n,orgContext:i},u.id)),d&&o?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>o.open({href:"",key:`record-links:${t}:${l.relationship_type_slug}`,title:`${l.relationship_type_name} · ${l.count}`,recordLinks:{entityId:t,entityName:s,ownerSlug:n,orgContext:i,relationshipType:l.relationship_type_slug,label:l.relationship_type_name}}),children:["Show all ",l.count]}):null]})]},l.relationship_type_slug)})]})}function xt({record:t,ownerSlug:s,orgContext:n,focus:i}){const[a,c]=S.useState(i),o=ce(i);return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:o,children:"Linked"}),a?e.jsx(Ze,{record:t,ownerSlug:s,orgContext:n}):e.jsx(N,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>c(!0),children:"Find linked records"})]})}const pt="$name";function de({outcome:t,schema:s}){if(!t||t.held.length===0)return null;const n=s?.properties??{},i=t.held.map(a=>a===pt?"Name":He(a,n[a]??{}));return e.jsxs("div",{role:"status",className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300",children:[i.join(", ")," ",i.length===1?"needs":"need"," approval before ",i.length===1?"it changes":"they change",".",t.approvalUrl?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:t.approvalUrl,className:"underline",children:"Review"})]}):null]})}const ft=320,gt={},vt=()=>{};function jt({view:t,orgSlug:s,recordUrl:n,scope:i}){const a=H(),c=`${n}${ne(t.key)}`,o=a?()=>a.open({href:c,title:t.name}):void 0;return e.jsxs("section",{className:"min-w-0 rounded-lg border","data-testid":"view-card","data-view":t.key,children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-4 pt-3 pb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-sm font-medium",children:t.name}),t.description?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description}):null]}),o?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:o,"aria-label":`Open ${t.name}`,children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Open"]}):null]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(oe,{orgSlug:s,viewKey:t.key,scope:i,params:gt,onParamsChange:vt,contentHash:t.content_hash,title:t.name,minHeight:64,displayMode:"inline",maxHeight:ft,onRequestDisplayMode:o?r=>{r==="fullscreen"&&o()}:void 0})})]})}function yt({recordUrl:t,dirty:s,onDiscard:n}){const i=rt({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:c})=>c.pathname!==t&&!c.pathname.startsWith(`${t}${ne("")}`)}),a=i.status==="blocked";return e.jsx(Ee,{open:a,onOpenChange:c=>{!c&&a&&i.reset()},children:e.jsxs(De,{className:"max-w-sm",children:[e.jsxs(Ce,{children:[e.jsx(Le,{children:"Discard unsaved changes?"}),e.jsx(Pe,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",onClick:()=>a&&i.reset(),children:"Keep editing"}),e.jsx(N,{type:"button",variant:"destructive",onClick:()=>{a&&(n(),i.proceed())},children:"Discard"})]})]})})}const se=6;function bt({entity:t,ownerSlug:s,orgContext:n,recordUrl:i,schema:a,entityTypeName:c,isTypeLoading:o,record:r,canEdit:m,editing:x,onEditingChange:p,outcome:f,onSaved:l,formId:h,fieldLimit:d,onDeleted:u}){const b=x&&m,j=H(),g={entity:{id:t.id,name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:n,schema:a,record:r,editing:b};nt(g);const _=j?.item?.recordField,D={ownerSlug:s,orgContext:n,controls:t.field_controls,dirtyKeys:r.dirtyKeys,openField:j?C=>j.open(Qe(g,C.key)):void 0,openFieldKey:_?.entityId===t.id?_.field:void 0},R=e.jsx(yt,{recordUrl:i,dirty:b&&r.isDirty,onDiscard:()=>{r.reset(),p(!1)}});if(o)return e.jsx(Fe,{rows:6});if(b)return e.jsxs(e.Fragment,{children:[R,e.jsx(kt,{formId:h,entity:t,entityTypeName:c,schema:a,record:r,orgContext:n,renderControl:(C,F,E)=>st(F)?e.jsx(at,{field:{key:C,prop:F},value:E,context:D}):void 0,onSaved:l,onDeleted:u,onDone:()=>p(!1)})]});const w=W(r.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(de,{outcome:f,schema:a}),e.jsx(le,{fields:d===void 0?w:w.slice(0,d),values:r.values.metadata,context:D})]})}function kt({formId:t,entity:s,entityTypeName:n,schema:i,record:a,orgContext:c,renderControl:o,onSaved:r,onDeleted:m,onDone:x}){const p=Be(),f=s.field_controls,{name:l,slug:h,metadata:d}=a.values,u=v=>a.setValues(y=>({...y,name:v})),b=v=>a.setValues(y=>({...y,slug:v})),j=v=>a.setValues(y=>({...y,metadata:v})),[g,_]=L(s.id,""),[D,R]=L(s.id,null),[w,C]=L(s.id,null),[F,E]=L(s.id,!1),[V,T]=L(s.id,null),O=a.dirtyKeys.length>0,P=async v=>{if(v.preventDefault(),!!a.canSubmit){if(R(null),!l.trim()){R("Name is required");return}try{const y=await a.save({note:g});C(y),r(y),_(""),y?.held.length||x()}catch(y){R(y instanceof Error?y.message:"Failed to update entity")}}},B=async()=>{T(null);try{await p.mutateAsync({entityId:s.id}),E(!1),m?.()}catch(v){T(v instanceof Error?v.message:"Failed to delete entity")}},A=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return e.jsxs("form",{id:t,onSubmit:P,className:"space-y-4",children:[e.jsx(Ie,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(z,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(Z,{id:"sidebar-name",value:l,onChange:v=>u(v.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(Z,{id:"sidebar-slug",value:h,onChange:v=>b(v.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(qe,{}),e.jsx(We,{schema:a.revision,values:d,onValuesChange:j,fieldControls:f,orgContext:c,renderControl:o})]}),O&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(Te,{id:"sidebar-correction-note",value:g,onChange:v=>_(v.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),D&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:D}),e.jsx(de,{outcome:w,schema:i}),F?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(Ve,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),A&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",A,". This cannot be easily undone."]})]})]}),V&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:V}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{E(!1),T(null)},children:"Cancel"}),e.jsx(N,{type:"button",variant:"destructive",size:"sm",onClick:B,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${n||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>E(!0),children:"Delete"})})]})}function ue(t,s){const n=new Set(t.measure_columns??[]),i=s?.properties??{};return Object.keys(t.metadata??{}).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&i[a]?.const===void 0).map(a=>({key:a,prop:i[a]??{},label:i[a]?.["x-table-label"]??(n.has(a)?a:Re(a.replace(/_/g," "))),numeric:n.has(a)}))}function _t({entity:t,schema:s,ownerSlug:n,fieldLimit:i}){const a=ue(t,s);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx(le,{fields:i===void 0?a:a.slice(0,i),values:t.metadata??{},context:{ownerSlug:n}})]})}const Nt=720,ae="owletto:record-details-expanded";function wt(){const[t,s]=S.useState(()=>{try{return window.localStorage.getItem(ae)==="1"}catch{return!1}});return[t,i=>{s(i);try{window.localStorage.setItem(ae,i?"1":"0")}catch{}}]}function St({schema:t,metadata:s}){const n=W(t).filter(({key:i,prop:a})=>a["x-table-column"]===!0&&!a["x-image"]&&s[i]!==void 0&&s[i]!==null&&s[i]!=="");return n.length===0?null:e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:n.map(({key:i,prop:a},c)=>e.jsxs("span",{children:[c>0?" · ":null,e.jsx(Ge,{value:s[i],prop:a})]},i))})}function Rt({namespace:t,entity:s,recordUrl:n,viewKey:i,title:a,onDeleted:c}){const o=ye({strict:!1}),r=ie(),m=S.useRef(null),x=be(m,Nt),[p,f]=wt(),[l,h]=L(s.id,!1),d={slug:t.slug,organizationId:t.id},u=ke(d),{data:b,isLoading:j}=re(s.entity_type,d),g=b?.metadata_schema,{isAdmin:_,isLoading:D}=_e(d.organizationId),R=_&&!D&&!s.is_derived,w=dt({entity:s,schema:g,orgContext:d}),[C,F]=L(s.id,null),E=`record-form-${s.id}`,V=l&&R,T=u.data??[],O=Ne(T,{type:s.entity_type,id:s.id}),P=we(O,i),B=!i&&o.tab==="relationships",A=k=>void r({to:".",search:k,replace:!0}),v={type:s.entity_type,entity:s.is_derived?s.slug:s.id},y=x&&!p&&!l&&!B,G=s.is_derived?ue(s,g).length:W(g).length,Q=y?se:void 0,q=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx(_t,{entity:s,schema:g,ownerSlug:t.slug,fieldLimit:Q}),e.jsx(xt,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:d,focus:B})]}):e.jsxs(e.Fragment,{children:[e.jsx(bt,{entity:s,ownerSlug:t.slug,orgContext:d,recordUrl:n,schema:g,entityTypeName:b?.name,isTypeLoading:j,record:w,canEdit:R,editing:l,onEditingChange:h,outcome:C,onSaved:F,formId:E,fieldLimit:Q,onDeleted:c}),e.jsx(ht,{entityId:s.id,entityName:s.name,ownerSlug:t.slug,orgContext:d,focus:B,collapsed:y})]}),x&&!l&&!B?e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!y,onClick:()=>f(y),children:y?G>se?`Show all ${G} fields`:"Show all details":"Show fewer"}):null]}),me=k=>e.jsx("div",{ref:m,className:"min-w-0 space-y-4",children:x?e.jsxs(e.Fragment,{children:[e.jsx(St,{schema:g,metadata:s.metadata??{}}),e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:q}),k]}):e.jsxs("div",{className:"grid grid-cols-[18rem_minmax(0,1fr)] gap-6",children:[e.jsx("aside",{className:"sticky top-12 max-h-[calc(100dvh-7rem)] min-w-0 self-start overflow-y-auto overscroll-contain pr-2 pb-16",children:q}),k]})}),he=V?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{w.reset(),F(null),h(!1)},children:"Cancel"}),e.jsx(N,{type:"submit",form:E,size:"sm",disabled:!w.canSubmit||!w.isDirty||w.saving||!w.values.name.trim(),children:w.saving?"Saving...":"Save"})]}):R&&!j?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{F(null),h(!0)},children:[e.jsx(Se,{className:"h-3.5 w-3.5"}),"Edit"]}):null,M=k=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"record-header",className:"sticky top-0 z-30 -mx-4 flex h-12 items-center justify-between gap-3 bg-background px-4 lg:-mx-6 lg:px-6",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:a}),he]}),k]});if(i&&u.data===void 0)return M(u.isError?e.jsx(ee,{onRetry:()=>void u.refetch()}):null);if(P.kind==="missing")return M(e.jsx(Ye,{viewKey:P.key,backTo:n,backLabel:`Back to ${s.name}`}));if(P.kind==="view"){const{view:k}=P;return M(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(Je,{decls:k.params,params:J(o),onParamsChange:xe=>void r({to:".",search:xe})}),e.jsx(oe,{orgSlug:t.slug,viewKey:k.key,scope:v,params:J(o),onParamsChange:A,contentHash:k.content_hash,title:k.name,minHeight:320})]}))}return M(me(e.jsxs("div",{className:"min-w-0 space-y-4",children:[u.isError&&e.jsx(ee,{onRetry:()=>void u.refetch()}),O.map(k=>e.jsx(jt,{view:k,orgSlug:t.slug,recordUrl:n,scope:v},k.key)),e.jsxs("section",{"aria-labelledby":"record-activity-heading",className:"min-w-0",children:[e.jsx("h2",{id:"record-activity-heading",className:"mb-2 text-sm font-medium text-muted-foreground",children:"Activity"}),e.jsx(Ue,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function Ft(t){return t?.trim()?t:void 0}function Gt({namespace:t,path:s,entity:n,viewKey:i}){const a=ie(),{data:c}=re(n.entity_type,{slug:t.slug}),o=Ft(c?.icon),r=s.map(l=>({entity_type:l.entity_type,slug:l.slug})),m=`/${t.slug}/${Oe(n.entity_type)}`,x=U(t.slug,r),p=s.length>1?U(t.slug,r.slice(0,-1)):m,f=Ae().session?.user.id;return S.useEffect(()=>{f&&Me(f,t.slug,{id:n.id,name:n.name,entityType:n.entity_type,url:x})},[f,t.slug,n.id,n.name,n.entity_type,x]),e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsx("div",{children:e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:e.jsx(N,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs($e,{to:p,children:[e.jsx(ze,{className:"mr-1 h-4 w-4"}),"Back"]})})})}),e.jsx(Rt,{namespace:t,entity:n,recordUrl:x,viewKey:i,title:e.jsxs(e.Fragment,{children:[e.jsx(Xe,{metadata:n.metadata,metadataSchema:c?.metadata_schema,name:n.name,typeIcon:o,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:n.name})]}),onDeleted:()=>{const l=s.slice(0,-1);l.length>0?a({to:U(t.slug,l)}):a({to:m})}})]})}export{Gt as EntityPage};
|
|
2
|
-
//# sourceMappingURL=entity-page-D3e4iPle.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,P as $,n as W,eN as me,eW as xe,eQ as K,bz as ae,r as x,eO as he,eP as pe,dr as ge,dt as fe,B as f,cT as U,ds as je,z as C,bp as q,bq as P,br as M,bs as I,bt as R,I as T,a2 as ve,eZ as Ne,fI as ye,fJ as be,X as H,d$ as ne,dF as re,T as we,a$ as le,fK as ie,fL as Se,b8 as oe,fM as Ce,fp as ke,bQ as Ee,bR as Y,bU as _e,fN as Re,bA as Te,fO as Oe,fP as De,Q as Z}from"./index-9YuSRymd.js";import{J}from"./json-diff-DIN5Jhfx.js";import{C as ce}from"./code-editor-CEqoCky-.js";function Ae(s){switch(s){case"create":return"default";case"update":return"secondary";case"delete":return"destructive";default:return"outline"}}function Fe(s){switch(s){case"create":return"Created";case"update":return"Updated";case"delete":return"Deleted";default:return s}}function ze(s){try{return new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}catch{return s}}function qe({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:Ae(s.action),children:Fe(s.action)}),s.actor&&e.jsx("span",{className:"text-xs text-muted-foreground",children:s.actor})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ze(s.created_at)}),s.action==="update"&&e.jsx(J,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(J,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(J,{before:s.before_payload,after:null})]})]})}function Pe({entityType:s}){const{orgContext:a}=W(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==K),d=i.filter(m=>m.purpose===K),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(B,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(B,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(B,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Le,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function B({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Me,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Me({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=W(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx($,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx($,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Ie,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Ie({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(H,{className:"h-3 w-3"})})})]})}function Le({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=W(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[D,w]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),w(!1),_(null)},O=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),V=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const Q=k.trim()||F(g);if(!Q){_("Slug is required");return}l=(await u.mutateAsync({slug:Q,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!S){_("Select a target entity type");return}const L=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:L,target_entity_type_slug:ue}),O(!1)}catch(l){_(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:O,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(U,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(I,{children:[a.map(l=>e.jsx(R,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),k||E("")}}),e.jsx(T,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:k,onChange:l=>E(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"source",children:"This type → other"}),e.jsx(R,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(I,{children:r.map(l=>e.jsxs(R,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:V,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ue({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(U,{className:"h-3 w-3"})})]})]})}const Ve=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Je({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(U,{className:"h-3 w-3"})})]})]})}function Be({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(T,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(I,{children:Ve.map(t=>e.jsx(R,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ue,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(T,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(T,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"none",children:"None"}),e.jsx(R,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(R,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Je,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function G({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function X(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function $e(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"?a:"auto"}function We({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),X(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=$e(u,p),O=u.some(F=>F.name.trim());m(O?JSON.stringify(v,null,2):""),a(O?v:void 0)},[a]),k=x.useCallback(u=>{i(u),j(u,o)},[j,o]),E=x.useCallback(u=>{d(u),j(t,u)},[j,t]),D=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),X(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{k([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,k(v)},_=u=>{k(t.filter((p,v)=>v!==u))};return c?e.jsx(G,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Be,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(U,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, otherwise table)."})]}),e.jsxs(q,{value:o,onValueChange:u=>E(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"auto",children:"Auto"}),e.jsx(R,{value:"table",children:"Table"}),e.jsx(R,{value:"board",children:"Board"})]})]})]})]}):e.jsx(G,{value:h,onChange:D,error:S})]})}function He(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Qe({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,D]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[_,u]=Y(i,n),[p,v]=Y(i,null),O=w.trim().length>0,F=l=>{h(l),!n&&!_&&S(He(l))},V=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=O?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:E,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:E,backing:l}),c()}catch(L){v(L instanceof Error?L.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(T,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(T,{id:"et-slug",value:m,onChange:l=>{u(!0),S(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(T,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{id:"et-color",value:j,onChange:l=>k(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),O?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx(We,{value:E,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(Pe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Te,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:V,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Xe({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=Oe(),{data:y,isLoading:b}=De(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,k=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},E=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",D=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:Z("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:Z("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:E}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D})]}),e.jsx("div",{className:"py-4",children:e.jsx(Qe,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"History"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(qe,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:k,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Xe as E};
|
|
2
|
-
//# sourceMappingURL=entity-type-page-DebN1vCM.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,L as le,dF as Gt,dG as Ye,cy as Xt,by as Yt,g as yt,r as N,dH as jt,dI as Zt,W as en,J as tn,dD as nn,dh as sn,Q as ue,dJ as rn,dK as vt,dL as bt,dM as an,dN as Nt,cM as on,dO as ln,cA as dn,o as _t,u as Ze,dP as et,dQ as wt,S as Oe,B as E,A as cn,dR as un,dS as Je,dT as kt,b7 as Ct,dU as mn,dV as pn,cN as xn,dW as St,dX as hn,ck as fn,dY as Ee,dZ as gn,d_ as Ne,d$ as _e,P as ce,e0 as It,e1 as tt,e2 as At,dr as yn,dt as jn,ds as vn,cz as Rt,e3 as bn,n as Et,bJ as ot,b$ as lt,$ as Nn,e4 as _n,e5 as wn,cm as kn,e6 as Cn,e7 as Tt,e8 as Sn,e9 as In,a2 as Te,ea as An,eb as Rn,bQ as En,ec as Tn,bU as $n,ed as Pn,dy as Fn,ee as On,X as Dn,bk as $t,ef as Me,eg as Be,eh as ze,d1 as De,d8 as Ln,aR as Mn,di as Bn,i as zn,bh as Un,cg as Vn,d6 as Hn,db as qn,dc as Kn,ei as Jn,ej as Qn,ek as Wn,el as Gn,em as Xn,bM as Yn,en as Zn,eo as He,bd as dt,aj as es}from"./index-9YuSRymd.js";import{c as ts}from"./conversations-table-D_HOe1jN.js";import{u as ns}from"./clients-BhNl1tVq.js";import{J as ss,g as rs,c as as,a as is,F as os,S as nt,e as ls,n as ds}from"./schema-value-normalization-CKdPjdPC.js";function Pt(t,n){if(!t||typeof t!="object"||Array.isArray(t))return null;const s=t.title;if(typeof s!="string")return null;const r=s.trim();return r&&r!==n?r:null}function cs(t,n){const s=n.parentEntityType&&n.parentEntitySlug?[{entity_type:n.parentEntityType,slug:n.parentEntitySlug},{entity_type:n.entityType,slug:n.entitySlug}]:[{entity_type:n.entityType,slug:n.entitySlug}];return Ye(t,s)}function us({ownerSlug:t,entity:n,className:s}){const r=cs(t,n);return e.jsxs(le,{to:r,className:`flex items-center gap-1 text-primary hover:underline group ${s??""}`,children:[e.jsx("span",{className:"font-medium",children:n.entityName}),e.jsx(Gt,{className:"h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function Ft(t){const n=Array.isArray(t?.records)?t.records:Array.isArray(t?.current)?t.current:[];return[t?.from_entity_id??t?.entity_id,t?.to_entity_id].map(s=>{const a=n.find(i=>i&&typeof i=="object"&&"id"in i&&i.id===s);return{id:String(s??"unknown"),name:typeof a?.name=="string"?a.name:`Record ${String(s??"unknown")}`}})}function Ot(t,n){return n==="rejected"?"The proposed relationship change was rejected. Both records remain available.":n==="failed"?"The relationship change failed. Both records remain available.":n==="completed"?t==="link"?"The records were linked. Both records remain available.":"The relationship was removed. Both records remain available.":n==="approved"||n==="confirmed"?"The relationship change was approved. Both records remain available.":t==="link"?"If approved, these records will be linked. Both records remain available.":"If approved, this relationship will be removed. Both records remain available."}function _r(t){const n=Ft(t.proposal);return{title:t.action==="link"?"Link records":"Unlink records",icon:"entity",impact:{level:"normal"},tone:"default",blocks:[...n.map((s,r)=>({type:"text",label:r===0?"From":"To",value:s.name})),{type:"text",label:"Relationship",value:String(t.proposal?.relationship_type??t.proposal?.relationship_type_slug??"Relationship")},{type:"text",value:Ot(t.action,typeof t.status=="string"?t.status:void 0),muted:!0},...typeof t.reason=="string"&&t.reason?[{type:"text",label:"Why this needs approval",value:t.reason}]:[]],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",confirm:t.action==="unlink",confirmPrompt:"Remove this relationship? Both records will remain available.",tool:"manage_operations",args:{action:"approve"},resolvedLabel:"Approval submitted."},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this relationship change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:"Relationship change rejected."}]}}function Dt(t,n,s){return{queryKey:["event-view-match",t,n.key,n.content_hash,s],queryFn:async()=>{try{const a=(await Xt("open_view",{key:n.key,scope:{event:s}},{slug:t})).scope?.event;if(!Number.isSafeInteger(a)||(a??0)<1)throw new Error("The view did not resolve its event subject");return a}catch(r){if(r instanceof Yt&&(r.status===400||r.status===404))return null;throw r}},staleTime:6e4}}function wr(t,n){const s=yt(t??{slug:null,organizationId:null}),r=t?.slug??null,a=N.useMemo(()=>r?jt(s.data??[]):[],[r,s.data]),i=Zt({queries:a.map(l=>Dt(r,l,n))});return r?{views:a.flatMap((l,m)=>{const o=i[m]?.data;return o?[{...l,eventId:o}]:[]}),isLoading:s.data===void 0?!s.isError:i.some(l=>l.isPending),isError:s.isError||i.some(l=>l.isError),refetch:()=>{s.refetch();for(const l of i)l.isError&&l.refetch()}}:{views:[],isLoading:!1,isError:!1,refetch:()=>{}}}async function ms(t,n,s,r){const a=await Promise.all(s.map(i=>t.fetchQuery(Dt(n,i,r))));return s.find((i,l)=>a[l])??null}async function ps(t,n,s,r){const a=await en(`${tn}/api/${encodeURIComponent(t)}/events/${n}/actions/${encodeURIComponent(s.action)}`,{method:"POST",timeoutMs:9e4,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:s.value,interaction_id:r})});return await nn(a,"Could not record interaction"),a.json()}function U(t){if(typeof t!="string")return;const n=t.trim();return n.length>0?n:void 0}function qe(t){return typeof t=="boolean"?t:void 0}function xs(t,n,s){const r=(s??"").toLowerCase();return!!(r==="prepare_comment"||r==="verify_staged_comment"||r.includes("prepare_")||r.includes("verify_staged")||n?.prepared===!0||typeof n?.verified=="boolean"||U(n?.reason_preview)&&U(n?.message)||U(t?.body)&&(U(t?.post_url)||U(t?.activity_id)))}function hs(t,n,s){if(!xs(t,n,s))return null;const r=(s??"").toLowerCase(),a=U(n?.body)??U(t?.body),i=U(n?.reason_preview)??U(t?.reason),l=U(n?.post_url)??U(t?.post_url)??(U(t?.activity_id)?`https://www.linkedin.com/feed/update/urn:li:activity:${U(t?.activity_id)}`:void 0),m=qe(n?.prepared),o=qe(n?.verified),c=qe(n?.banner_shown),p=U(n?.message),u=n?.match&&typeof n.match=="object"?n.match:null,h=U(u?.text_preview),v=U(u?.author);let I="generic";r==="verify_staged_comment"||r.includes("verify")||typeof o=="boolean"?I="verify":(r==="prepare_comment"||r.includes("prepare")||m===!0||a&&l)&&(I="prepare");const _=[];return m===!0&&_.push("Staged — not posted"),m===!1&&_.push("Not staged"),o===!0&&_.push("Verified posted"),o===!1&&_.push("Not verified as posted"),c===!0&&_.push("In-page banner"),c===!1&&_.push("No banner"),{kind:I,message:p,reason:i,body:a,postUrl:l,prepared:m,bannerShown:c,verified:o,matchPreview:h,matchAuthor:v,chips:_}}function Ae(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function fs({template:t,data:n,onAction:s}){const[r,a]=N.useState(null),[i,l]=N.useState(!1),[m,o]=N.useState(null),[c,p]=N.useState(!1),u=N.useRef(!1),h=N.useRef(!0);N.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const v=async I=>{if(!(!s||u.current)){u.current=!0,l(!0),o(null),p(!1);try{const _=await s(I);if(!h.current)return;if(Ae(_)&&_.kind==="sdk"){const j=_.result;if(!Ae(j)||j.success!==!0){const w=Ae(j)&&Ae(j.error)?j.error.message:null;throw new Error(typeof w=="string"?w:"Could not update this event.")}if(j.return_truncated||!Ae(j.return_value))throw new Error("The update did not return a complete data object.");a(j.return_value),p(!0)}}catch(_){h.current&&o(_ instanceof Error?_.message:"Could not update this event.")}finally{u.current=!1,h.current&&l(!1)}}};return e.jsxs("div",{className:"space-y-2",children:[i?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Updating…"}):null,c?e.jsx("p",{role:"status",className:"sr-only",children:"Updated"}):null,m?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[m," Previous data is still shown."]}):null,e.jsx("fieldset",{disabled:!s||i,"aria-busy":i,className:"min-w-0",children:e.jsx(ss,{template:{root:t.root},data:r??n,onAction:s?v:void 0,interactions:t.interactions})})]})}function gs(t){return t.type==="array"&&!!t.items&&(t.items?.type==="object"||!!t.items?.properties)}function ys(t){return(t.type==="object"||!!t.properties)&&Object.keys(t.properties??{}).length>0}function js(t){const n=t?.properties??{};return Object.entries(n).filter(([,s])=>!("x-measure"in s)&&!("x-dimension"in s)).map(([s,r])=>({key:s,prop:r}))}function Ue(t){return t.label??t.prop["x-table-label"]??rs(t.key,t.prop)}function vs(t){try{return as(t)}catch{return t instanceof rn?t.text:t}}function ct(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function bs({value:t,prop:n,ownerSlug:s,orgContext:r}){const a=n["x-link-entity-type"],i=n["x-link-lookup-field"]||"slug",{data:l}=on(a,r,{limit:ln}),m=o=>{const c=l?.entities.find(p=>{const u=i==="slug"?p.slug:p.metadata?.[i];return u!=null&&String(u)===o});return c?{label:c.name,to:dn(s,ls(c))}:void 0};return e.jsx(nt,{value:t,prop:n,resolveLink:m})}function Ns({field:t,value:n,context:s}){if(gs(t.prop)&&(n==null||Array.isArray(n))){const r=Array.isArray(n)?n.length:0,a=`${r} ${r===1?"item":"items"}`,i=s.dirtyKeys?.includes(t.key)??!1,l="inline-flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs tabular-nums";if(!s.openField)return e.jsx("span",{className:l,children:a});const m=s.openFieldKey===t.key;return e.jsxs("button",{type:"button","aria-pressed":m,"aria-label":`${Ue(t)}: ${a}${i?", unsaved changes":""}`,className:ue(l,"hover:bg-muted/70 hover:text-foreground",m&&"ring-1 ring-primary"),onClick:()=>s.openField?.(t),children:[a,i?e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"· edited"}):null]})}return t.prop["x-link-entity-type"]&&s.orgContext&&n!=null?e.jsx(bs,{value:n,prop:t.prop,ownerSlug:s.ownerSlug,orgContext:s.orgContext}):e.jsx(nt,{value:n,prop:t.prop})}function ut({field:t,control:n,labelId:s}){const r=is(t.prop);return e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5",children:[e.jsx("span",{id:s,className:"min-w-0 break-words",children:Ue(t)}),r?e.jsxs(vt,{children:[e.jsx(bt,{asChild:!0,children:e.jsx("button",{type:"button",className:"shrink-0 text-muted-foreground/70 hover:text-foreground","aria-label":`About ${Ue(t)}: ${r}`,children:e.jsx(an,{className:"h-3 w-3"})})}),e.jsx(Nt,{className:"max-w-xs",children:r})]}):null,n?e.jsx(os,{control:n}):null]})}function Lt({field:t,value:n,context:s,nested:r}){const a=N.useId(),i=r?void 0:s.controls?.[t.key],l=vs(n);if(ys(t.prop)&&(l==null||ct(l))){const m=Object.entries(t.prop.properties??{}).map(([c,p])=>({key:c,prop:p})),o=ct(l)?l:{};return e.jsxs("fieldset",{"aria-labelledby":a,className:"m-0 min-w-0 space-y-2 border-0 p-0",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:e.jsx(ut,{field:t,control:i,labelId:a})}),e.jsx("dl",{className:"space-y-2 border-l border-border pl-3",children:m.map(c=>e.jsx(Lt,{field:c,value:o[c.key],context:s,nested:!0},c.key))})]})}return e.jsxs("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-baseline gap-x-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:e.jsx(ut,{field:t,control:i,labelId:a})}),e.jsx("dd",{"aria-labelledby":a,className:ue("min-w-0 [overflow-wrap:anywhere]",t.numeric&&"tabular-nums"),children:e.jsx(Ns,{field:t,value:l,context:s})})]})}function _s({fields:t,values:n,context:s}){return t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"This type declares no fields."}):e.jsx(sn,{delayDuration:200,children:e.jsx("dl",{className:"space-y-2.5 text-sm leading-5",children:t.map(r=>e.jsx(Lt,{field:r,value:n[r.key],context:s,nested:!1},r.key))})})}function ws(t){return{href:"",key:`record-peer:${t.entityId}`,title:t.name?.trim()||"Record",recordPeer:{entityId:t.entityId,ownerSlug:t.ownerSlug,orgContext:t.orgContext}}}function kr({target:t}){const n=_t(),s=Ze(),{data:r,isLoading:a,isError:i}=et(t.entityId,t.orgContext),{data:l}=wt(r?.entity_type??"",t.orgContext),[m,o]=N.useState(!1),[c,p]=N.useState(!1);if(a)return e.jsxs("div",{className:"space-y-3 px-5 py-5",children:[e.jsx(Oe,{className:"h-5 w-2/3"}),e.jsx(Oe,{className:"h-4 w-full"}),e.jsx(Oe,{className:"h-4 w-full"})]});if(i||!r)return e.jsx("p",{className:"px-5 py-5 text-sm text-muted-foreground",children:"This record is not available. It may have been deleted, or you may not have access to it."});const u=l?.metadata_schema,h=async()=>{o(!0),p(!1);try{const v=await un(r.id,t.orgContext);s?.close(),await n({to:Ye(t.ownerSlug,v)})}catch{p(!0)}finally{o(!1)}};return e.jsxs("article",{className:"space-y-4 px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?.name??r.entity_type})]}),e.jsxs(E,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1 px-2 text-muted-foreground hover:text-foreground",disabled:m,"aria-busy":m,onClick:()=>void h(),children:["Open record",e.jsx(cn,{className:"h-3.5 w-3.5"})]})]}),c?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null,e.jsx(_s,{fields:js(u),values:ds(r.metadata??{},u),context:{ownerSlug:t.ownerSlug,orgContext:t.orgContext}})]})}function ks(t,n){const s=t.from_entity_id===n;return{id:s?t.to_entity_id:t.from_entity_id,name:s?t.to_entity_name:t.from_entity_name,type:s?t.to_entity_type:t.from_entity_type,self:t.from_entity_id===t.to_entity_id}}const mt="inline-flex max-w-full items-center truncate rounded-md border border-border px-1.5 py-0.5 text-xs";function Qe({peer:t,ownerSlug:n,orgContext:s}){const r=Ze();if(t.self||!t.type||!r)return e.jsx("span",{className:ue(mt,"text-muted-foreground"),children:t.name});const a=r.item?.recordPeer?.entityId===t.id;return e.jsx("button",{type:"button","aria-pressed":a,title:t.type,className:ue(mt,"hover:bg-muted",a&&"ring-1 ring-primary"),onClick:i=>{i.stopPropagation(),r.open(ws({entityId:t.id,ownerSlug:n,orgContext:s,name:t.name}))},children:e.jsx("span",{className:"truncate",children:t.name})})}function Cr({row:t,entityId:n,ownerSlug:s,orgContext:r}){const a=ks(t,n);return e.jsx(Qe,{peer:{id:a.id,type:a.type,self:a.self,name:a.self?"this record":a.name??`Record #${a.id}`},ownerSlug:s,orgContext:r})}const Mt={name:"Name",slug:"URL slug",parent_id:"Parent",content:"Content changed"};function be(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Pe(t){return t==null||t===""}function Cs(t,n){return Je(t??null)===Je(n??null)}function Ss(t){return!!(t?.type==="array"&&(t.items?.type==="object"||t.items?.properties))}function Is(t){return!!(t&&(t.type==="object"||t.properties)&&t.type!=="array")}function st(t,n){return Ue({key:t,prop:n??{}})}function As(t,n){return t?.properties?.[n]}function We(t,n,s,r,a){if(Cs(n,s))return;const i=o=>Array.isArray(o)?o:[];if((Array.isArray(n)||Pe(n))&&(Array.isArray(s)||Pe(s))&&(Array.isArray(n)||Array.isArray(s)||r?.type==="array")){const o=i(n),c=i(s);if(Ss(r)||[...o,...c].some(j=>be(j))){const j=Math.min(o.length,c.length);for(let P=0;P<j;P++)We([...t,`item ${P+1}`],o[P],c[P],r?.items,a);const w=Math.max(0,c.length-o.length),K=Math.max(0,o.length-c.length);(w||K)&&a.push({kind:"items",path:t,added:w,removed:K});return}const u=j=>Je(j),h=new Set(o.map(u)),v=new Set(c.map(u)),I=c.filter(j=>!h.has(u(j))),_=o.filter(j=>!v.has(u(j)));a.push(I.length||_.length?{kind:"values",path:t,added:I,removed:_,prop:r?.items}:{kind:"reordered",path:t});return}if((be(n)||Pe(n))&&(be(s)||Pe(s))&&(be(n)||be(s)||Is(r))){const o=be(n)?n:{},c=be(s)?s:{},p=[...new Set([...Object.keys(r?.properties??{}),...Object.keys(o),...Object.keys(c)])];for(const u of p){const h=As(r,u);We([...t,st(u,h)],o[u],c[u],h,a)}return}a.push({kind:"set",path:t,old:n,new:s,prop:r})}function Rs(t,n){const s=Mt[t.field];if(s)return t.field==="content"?[{kind:"note",path:[s]}]:t.field==="parent_id"?[{kind:"parent",path:[s],old:t.old,new:t.new}]:[{kind:"set",path:[s],old:t.old,new:t.new}];const r=n?.properties?.[t.field],a=[];return We([st(t.field,r)],t.old,t.new,r,a),a}function Es(t,n){const s=n?.properties;return t.map(r=>r.field==="content"?"Content":Mt[r.field]??st(r.field,s?.[r.field]))}const Ts="entity.updated",$s=new Set(["link","unlink","update_link"]);function pt(t){const n=typeof t=="string"||typeof t=="number"?Number(t):Number.NaN;return Number.isSafeInteger(n)&&n>0?n:null}function Ps(t){const n=t.split("_").join(" ").trim();return n?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:t}function Fs(t){const n=t.metadata;if(t.semantic_type!=="change"||!n||n._lobu_relationship_change!==!0||typeof n.op!="string"||!$s.has(n.op))return null;const s=pt(n.fromEntityId),r=pt(n.toEntityId);if(s==null||r==null)return null;const a=typeof n.relationshipTypeSlug=="string"?n.relationshipTypeSlug:null,i=Array.isArray(n.changes)?n.changes:[];return{op:n.op,fromId:s,toId:r,typeLabel:a?Ps(a):"relationship",changedFields:i.flatMap(l=>l&&typeof l=="object"&&typeof l.field=="string"?[l.field]:[])}}function Le({id:t,recordId:n,ownerSlug:s}){const r=t===n,a={slug:s},{data:i,isLoading:l,isError:m}=et(r?void 0:t,a);return r?e.jsx(Qe,{peer:{id:t,name:"this record",type:null,self:!0},ownerSlug:s,orgContext:a}):l?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Record #",t]}):m||!i?e.jsx("span",{className:"text-xs text-muted-foreground",title:"Deleted, or you do not have access to it",children:"Unavailable record"}):e.jsx(Qe,{peer:{id:t,name:i.name,type:i.entity_type},ownerSlug:s,orgContext:a})}function Os({change:t,recordId:n,ownerSlug:s}){const r=t.op==="link"?`Linked as ${t.typeLabel}`:t.op==="unlink"?`Unlinked ${t.typeLabel}`:`Updated ${t.typeLabel} link`,a=n===t.toId&&n!==t.fromId,i=n===t.fromId;return e.jsxs("span",{"data-testid":"relationship-change",className:"inline-flex flex-wrap items-center gap-1.5",children:[!i&&!a?e.jsx(Le,{id:t.fromId,ownerSlug:s}):null,e.jsx("span",{children:a?`${r} from`:r}),a?e.jsx(Le,{id:t.fromId,recordId:n,ownerSlug:s}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx(Le,{id:t.toId,recordId:n,ownerSlug:s})]}),t.op==="update_link"&&t.changedFields.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",t.changedFields.join(", ")]}):null]})}function Ds(t){if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const s of t){if(!s||typeof s!="object"||typeof s.field!="string")return null;const{field:r,old:a,new:i}=s;n.push({field:r,old:a??null,new:i??null})}return n}function Ls(t){const n=Fs(t);if(n)return{kind:"relationship",change:n};const s=t.metadata;if(t.semantic_type!=="change"||!s)return null;const r=s._lobu_event_type;if(r!==Ts&&(r!==void 0||s.category))return null;const a=Ds(s.changes);if(!a)return null;const i=t.entity_ids?.[0];return{kind:"fields",entityId:typeof i=="number"?i:null,changes:a}}function Bt(t,n){const s={slug:n},{data:r}=et(t.entityType?void 0:t.entityId??void 0,s),{data:a}=wt(t.entityType??r?.entity_type??"",s);return a?.metadata_schema}const Ms=4;function Fe({value:t,prop:n}){return e.jsx("span",{className:"inline-block max-w-[18rem] truncate align-bottom",title:typeof t=="string"?t:void 0,children:e.jsx(nt,{value:t,prop:n,empty:e.jsx("span",{className:"italic",children:"empty"})})})}function xt({id:t,ownerSlug:n}){const s=typeof t=="number"||typeof t=="string"?Number(t):Number.NaN;return Number.isSafeInteger(s)&&s>0?e.jsx(Le,{id:s,ownerSlug:n}):e.jsx("span",{className:"italic text-muted-foreground",children:"empty"})}function Ge(t,n){return`${t} ${n}${t===1?"":"s"}`}function Bs({line:t,ownerSlug:n}){const s=e.jsx("span",{className:"text-muted-foreground",children:t.path.join(" · ")});switch(t.kind){case"note":return s;case"set":return e.jsxs(e.Fragment,{children:[s,": ",e.jsx(Fe,{value:t.old,prop:t.prop})," ",e.jsx("span",{"aria-hidden":"true",children:"→"})," ",e.jsx(Fe,{value:t.new,prop:t.prop})]});case"parent":return e.jsxs(e.Fragment,{children:[s,": ",e.jsx(xt,{id:t.old,ownerSlug:n})," ",e.jsx("span",{"aria-hidden":"true",children:"→"})," ",e.jsx(xt,{id:t.new,ownerSlug:n})]});case"items":return e.jsxs(e.Fragment,{children:[s,":"," ",[t.added?`${Ge(t.added,"item")} added`:null,t.removed?`${Ge(t.removed,"item")} removed`:null].filter(Boolean).join(", ")]});case"values":return e.jsxs(e.Fragment,{children:[s,":",t.added.map((r,a)=>e.jsxs("span",{className:"ml-1.5",children:["+",e.jsx(Fe,{value:r,prop:t.prop})]},`+${a}`)),t.removed.map((r,a)=>e.jsxs("span",{className:"ml-1.5 text-muted-foreground",children:["−",e.jsx(Fe,{value:r,prop:t.prop})]},`-${a}`))]});case"reordered":return e.jsxs(e.Fragment,{children:[s,": reordered"]})}}function zs({change:t,ownerSlug:n}){const s=Bt(t,n);return e.jsxs(e.Fragment,{children:["Updated ",Es(t.changes,s).join(", ")]})}function rt({changes:t,entityId:n,entityType:s,ownerSlug:r,showAll:a=!1}){const i=Bt({entityId:n,entityType:s},r),[l,m]=N.useState(a),o=t.flatMap(u=>Rs(u,i)),c=l?o:o.slice(0,Ms),p=o.length-c.length;return e.jsxs("ul",{"data-testid":"field-changes",className:"space-y-0.5 text-sm",children:[c.map((u,h)=>e.jsx("li",{className:"min-w-0 truncate",children:e.jsx(Bs,{line:u,ownerSlug:r})},h)),p>0?e.jsx("li",{children:e.jsxs("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:u=>{u.stopPropagation(),m(!0)},children:["+",Ge(p,"more change")]})}):null]})}function Us({event:t,recordId:n,ownerSlug:s}){return t.kind==="relationship"?e.jsx(Os,{change:t.change,recordId:n,ownerSlug:s}):e.jsx(zs,{change:t,ownerSlug:s})}function Vs({event:t,ownerSlug:n}){return t.kind==="fields"?e.jsx(rt,{changes:t.changes,entityId:t.entityId,ownerSlug:n}):null}function zt(t){return{audit:t.semantic_type==="audit"&&t.origin_type==="tool_invocation",operation:t.interaction_type==="approval"||t.semantic_type==="operation",changeSet:t.semantic_type==="change_set"}}const Hs={};function me(t){return t.replace(/_/g," ").replace(/\s+/g," ").trim().replace(/^./,n=>n.toUpperCase())}const qs={notification:"Notification",tool_invocation:"Action",deployment:"Deployment",config_change:"Config change",message:"Message",msg:"Note",summary:"Summary"};function Ks(t){return t.author_name?t.author_name:t.platform?me(t.platform):t.origin_type?qs[t.origin_type]??me(t.origin_type):null}function Js(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):Array.isArray(t)?t.length===0?"":t.every(n=>typeof n!="object")?t.map(n=>String(n)).join(", "):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(t,null,2)}):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(t,null,2)})}const Ke=1e5;function ht({value:t}){const n=JSON.stringify(t,null,2)??"null",s=n.length>Ke;return e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-3 font-mono text-xs",children:s?n.slice(0,Ke):n}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",Ke.toLocaleString()," of"," ",n.length.toLocaleString()," characters."]})]})}function Qs(t){return Object.entries(t).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim().length>0:Array.isArray(n)?n.length>0:typeof n=="object"?Object.keys(n).length>0:!0).sort(([n],[s])=>n.localeCompare(s))}function Ws({breakdown:t}){if(!t)return null;const n=[{label:"Engagement",value:t.engagement,max:100},{label:"Criticality",value:t.criticality,max:100},{label:"Depth",value:t.depth,max:100},{label:"Authority",value:t.authority,max:100},{label:"Recency",value:t.recency,max:100},{label:"Quality",value:t.quality,max:100}];return e.jsx("div",{className:"space-y-2 text-sm",children:n.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-muted-foreground",children:s.label}),e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary",style:{width:`${s.value/s.max*100}%`}})}),e.jsx("span",{className:"w-8 text-right",children:s.value})]},s.label))})}function Gs({slug:t,value:n,isManual:s}){return e.jsxs(ce,{variant:"secondary",className:"text-xs",children:[t,": ",n,s&&e.jsx(St,{className:"ml-1 h-2.5 w-2.5 fill-current"})]})}function Xs(t){if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.values))return{values:n.values.map(s=>String(s)).filter(s=>s.length>0),isManual:n.is_manual===!0};if(n.value!==void 0&&n.value!==null)return{values:[String(n.value)],isManual:n.is_manual===!0};if(typeof n.values=="string"&&n.values.length>0)return{values:[n.values],isManual:n.is_manual===!0}}return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?{values:[String(t)],isManual:!1}:{values:[],isManual:!1}}function Ut(t,n){if(t)switch(t){case"pending":return"pending_approval";case"approved":return"confirmed";case"rejected":return"rejected";case"completed":return"completed";case"failed":return"failed";default:return t}return n||"pending_approval"}function Xe(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function Ys(t){return t.replace(/\s+[—-]\s+pending approval$/i,"")}function Ve(t){return t.replace(/^\$/,"").replace(/[_-]/g," ").replace(/\s+/g," ").trim().replace(/^./,n=>n.toUpperCase())}function Vt(t,n,s){return t?.kind==="agent_session"&&t.agent_id?t.client_id?`${t.agent_id} via ${t.client_id}`:t.agent_id:t?.kind==="user"?"a person":n==="agent"?"an agent":s?`Automation ${s}`:"an Automation"}function Zs({ownerSlug:t,initiator:n,clientName:s,fallback:r}){const a=n?.client_id??s,{allOrgs:i,isAuthenticated:l}=Et(),m=l&&i?.some(v=>v.slug===t),c=ns(void 0,{ownerSlug:t,enabled:!!(a&&m)}).data?.find(v=>v.id===a)?.title,p=n&&n.kind!=="user"?Vt(n,void 0,n.automation_id===void 0?void 0:String(n.automation_id)):r,u="font-medium text-foreground",h=`${u} underline-offset-4 hover:underline`;return n?.kind==="automation"&&n.automation_id?e.jsx(le,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:String(n.automation_id)},search:{view:"definition",run_id:void 0},className:h,children:p}):n?.kind==="agent_session"&&n.agent_id?e.jsx(le,{to:"/$owner/agents/$agentId",params:{owner:t,agentId:String(n.agent_id)},className:h,children:p}):a?e.jsxs(le,{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:a},className:`${h} inline-flex items-center gap-1 align-middle`,children:[e.jsx($t,{name:c??s??a}),c??p]}):e.jsx("span",{className:u,children:p})}function er(t){const n=Object.keys(t.fields),s=n.map(Ve).join(", ")||"field",r=n.length===1?"field":"fields";return`Update ${t.entityType?Ve(t.entityType).toLowerCase():"entity"} ${r}: ${s}`}function tr(t,n){const s=Xe(n.fields);if(!s||Object.keys(s).length===0||n.action_key!=="entity_field_change"&&n.tool!=="entity_field_change")return null;const r=Xe(n.current)??{},a=t;return{fields:s,current:r,reason:typeof n.reason=="string"?n.reason:void 0,automationId:n.automation_id!=null?String(n.automation_id):void 0,automationName:typeof n.automation_name=="string"?n.automation_name:void 0,automationAgentId:typeof n.automation_agent_id=="string"?n.automation_agent_id:void 0,entityType:typeof n.entity_type=="string"?n.entity_type:void 0,entityName:(typeof n.entity_name=="string"?n.entity_name:void 0)??a.entity_name??void 0,entitySlug:typeof n.entity_slug=="string"?n.entity_slug:void 0,parentSlug:typeof n.parent_slug=="string"?n.parent_slug:void 0,parentEntityType:typeof n.parent_entity_type=="string"?n.parent_entity_type:void 0,attribution:typeof n.attribution=="string"?n.attribution:void 0,initiator:n.initiator&&typeof n.initiator=="object"?n.initiator:void 0}}function nr(t){const n=t.entityType?Ve(t.entityType).toLowerCase():"entity";return`${Ve(t.operation)} ${n}`}function sr(t,n){if(n.action_key!=="entity_change"&&n.tool!=="entity_change")return null;const s=n.action;if(s!=="create"&&s!=="delete"&&s!=="link"&&s!=="unlink")return null;const r=t;return{operation:s,proposal:Xe(n.proposal),reason:typeof n.reason=="string"?n.reason:void 0,automationId:n.automation_id!=null?String(n.automation_id):void 0,automationName:typeof n.automation_name=="string"?n.automation_name:void 0,automationAgentId:typeof n.automation_agent_id=="string"?n.automation_agent_id:void 0,entityType:typeof n.entity_type=="string"?n.entity_type:void 0,entityName:(typeof n.entity_name=="string"?n.entity_name:void 0)??r.entity_name??void 0,entitySlug:typeof n.entity_slug=="string"?n.entity_slug:void 0,parentSlug:typeof n.parent_slug=="string"?n.parent_slug:void 0,parentEntityType:typeof n.parent_entity_type=="string"?n.parent_entity_type:void 0,attribution:typeof n.attribution=="string"?n.attribution:void 0,proposerRationale:typeof n.proposer_rationale=="string"?n.proposer_rationale:void 0,initiator:n.initiator&&typeof n.initiator=="object"?n.initiator:void 0}}function rr(t,n){return!n.entityType||!n.entitySlug?null:Ye(t,n.parentEntityType&&n.parentSlug?[{entity_type:n.parentEntityType,slug:n.parentSlug},{entity_type:n.entityType,slug:n.entitySlug}]:[{entity_type:n.entityType,slug:n.entitySlug}])}function Ht({ownerSlug:t,runId:n,details:s}){const a=Tt(s.automationId,void 0,void 0,{ownerSlug:t,includeVersions:!1}).data?.automation,i=Vt(s.initiator,s.attribution,s.automationId),l=a?.automation_name??s.automationName??i;return e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Requested by"," ",s.automationId?e.jsx(le,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:s.automationId},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:l}):e.jsx("span",{className:"font-medium text-foreground",children:l}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:" · "}),e.jsxs(le,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(n)},className:"font-medium text-foreground underline-offset-4 hover:underline",children:["Run #",n]})]})]})}function qt({ownerSlug:t,details:n}){const s=rr(t,n);return n.entityName?e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Entity"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:s?e.jsx(le,{to:s,className:"underline-offset-4 hover:underline",children:n.entityName}):n.entityName})]}):null}function ar({ownerSlug:t,runId:n,details:s}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ht,{ownerSlug:t,runId:n,details:s}),e.jsx(qt,{ownerSlug:t,details:s}),e.jsx("div",{className:"rounded-md border border-border/70 px-3 py-2",children:e.jsx(rt,{changes:Object.entries(s.fields).map(([r,a])=>({field:r,old:s.current[r]??null,new:a??null})),entityType:s.entityType,ownerSlug:t,showAll:!0})}),s.reason&&e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function ir({ownerSlug:t,runId:n,details:s,status:r}){const{operation:a}=s,i=a==="link"||a==="unlink";return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ht,{ownerSlug:t,runId:n,details:s}),!i&&e.jsx(qt,{ownerSlug:t,details:s}),e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Change"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:i?Ot(a,r):a==="create"?"Create a new entity after approval.":"Delete this entity after approval."}),i&&e.jsxs("div",{className:"mt-2 space-y-1 text-sm",children:[Ft(s.proposal).map((l,m)=>e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:m===0?"From: ":"To: "}),l.name]},l.id)),e.jsxs("div",{className:"text-muted-foreground",children:["Relationship:"," ",String(s.proposal?.relationship_type??s.proposal?.relationship_type_slug??"Relationship")]})]})]}),!i&&s.proposal&&e.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Proposal"}),e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-xs leading-relaxed",children:JSON.stringify(s.proposal,null,2)})]}),s.proposerRationale&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s.attribution==="agent"?"The agent's reasoning":"The Automation's reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.proposerRationale})]}),s.reason&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Why this needs approval"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function or({summary:t}){return e.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/30 p-3 text-sm",children:[t.chips.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.chips.map(n=>e.jsx(ce,{variant:"outline",className:"text-[10px] font-normal",children:n},n))}),t.message&&e.jsx("p",{className:"leading-relaxed text-foreground",children:t.message}),t.reason&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Why"}),e.jsx("div",{className:"mt-0.5 leading-relaxed",children:t.reason})]}),t.body&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t.kind==="verify"?"Expected comment":"Draft"}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed",children:t.body})]}),t.matchPreview&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsxs("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:["Matched comment",t.matchAuthor?` · ${t.matchAuthor}`:""]}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed text-muted-foreground",children:t.matchPreview})]}),t.postUrl&&e.jsxs("a",{href:t.postUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Open post",e.jsx(Rt,{className:"h-3 w-3"})]})]})}function lr({ownerSlug:t,content:n,batchReview:s}){const r=n.metadata||{},a=n.run_id??void 0,i=tr(n,r),l=sr(n,r),m=(i?er(i):l?nr(l):void 0)||r.operation_name||r.action_name||(n.title?Ys(n.title):void 0)||"Action",o=r.connection_name,c=r.operation_key||r.action_key||null,p=n.interaction_input_schema||r.input_schema||null,u=N.useMemo(()=>n.interaction_input||r.action_input||r.operation_input||Hs,[n.interaction_input,r.action_input,r.operation_input]),h=n.interaction_output||r.action_output||void 0,v=hs(u,h??null,c),I=n.interaction_error||r.error_message||void 0,_=Ut(n.interaction_status,r.status),j=r.reviewed_by_name||r.reviewed_by_id||void 0,w=r.reject_reason||void 0,K=r.initiator,P=An({slug:t}),F=Rn({slug:t}),T=En(n.id,Tn(p,u),p),{values:g,setValues:B}=T,[k,L]=N.useState(null),[f,G]=N.useState(!1),[R,O]=N.useState(""),D=_==="pending_approval"&&k?k:_,A=D==="pending_approval",V=typeof r.source_run_id=="number";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ct,{className:"h-4 w-4 text-yellow-500"}),e.jsx("span",{className:"font-medium",children:m}),o&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["on ",o]}),D==="confirmed"&&e.jsx(ce,{variant:"outline",className:"text-blue-700 border-blue-300 bg-blue-50 dark:bg-blue-950/30 text-[10px]",children:"Approved"}),D==="completed"&&e.jsx(ce,{variant:"outline",className:"text-green-700 border-green-300 bg-green-50 dark:bg-green-950/30 text-[10px]",children:"Completed"}),D==="failed"&&e.jsx(ce,{variant:"outline",className:"text-red-700 border-red-300 bg-red-50 dark:bg-red-950/30 text-[10px]",children:"Failed"}),D==="rejected"&&e.jsx(ce,{variant:"outline",className:"text-muted-foreground text-[10px]",children:"Rejected"})]}),!i&&!l&&(n.author_name||j)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground",children:[n.author_name&&e.jsxs("span",{children:["Requested by"," ",e.jsx(Zs,{ownerSlug:t,initiator:K,clientName:n.author_name,fallback:n.author_name})]}),n.author_name&&j&&e.jsx("span",{children:"·"}),j&&e.jsxs("span",{children:[D==="rejected"?"Rejected":"Approved"," by"," ",e.jsx("span",{className:"font-medium text-foreground",children:j})]})]}),i&&e.jsx(ar,{ownerSlug:t,runId:a,details:i}),!i&&l&&e.jsx(ir,{ownerSlug:t,runId:a,details:l,status:D}),D==="rejected"&&w&&e.jsxs("div",{className:"rounded-md bg-muted/50 p-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"Reason:"})," ",w]}),v&&e.jsx(or,{summary:v}),(A?T.revision:p)&&(A||Object.keys(u).length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:v?"Full input":"Input"}),A?e.jsxs(e.Fragment,{children:[e.jsx($n,{visible:T.hasConflict,onReload:T.reset}),e.jsx(Pn,{schema:T.revision,values:g,onValuesChange:B,fieldIdPrefix:`action-${n.id}-`},`action-${n.id}`)]}):v?e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw input"}),e.jsx("pre",{className:"mt-1 bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(u,null,2)})]}):e.jsx("pre",{className:"text-xs bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(u,null,2)})]}),D==="completed"&&h&&Object.keys(h).length>0&&!v&&e.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium",children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),"Output"]}),e.jsx("pre",{className:"text-xs text-green-800 dark:text-green-300 font-mono whitespace-pre-wrap",children:JSON.stringify(h,null,2)})]}),D==="completed"&&h&&Object.keys(h).length>0&&v&&e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw output"}),e.jsx("pre",{className:"mt-1 rounded bg-green-50 p-2 font-mono dark:bg-green-950/30 overflow-auto max-h-32",children:JSON.stringify(h,null,2)})]}),D==="failed"&&I&&e.jsxs("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-red-700 dark:text-red-400 font-medium",children:[e.jsx(It,{className:"h-3.5 w-3.5"}),"Error"]}),e.jsx("p",{className:"text-xs text-red-800 dark:text-red-300 font-mono mt-1",children:I})]}),A&&!k&&V&&e.jsxs("div",{className:"pt-1 text-xs text-muted-foreground",children:["Review this proposal with the other changes in its Automation run.",s]}),A&&a&&!k&&!V&&e.jsx("div",{className:"flex items-center gap-2 pt-1",children:f?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"Reason (optional)",value:R,onChange:se=>O(se.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs(E,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>F.mutate({run_id:a,reason:R||void 0},{onSuccess:()=>{L("rejected")}}),disabled:F.isPending,children:[F.isPending&&e.jsx(Te,{size:"sm",className:"mr-1"}),"Confirm Reject"]}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{G(!1),O("")},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(E,{size:"sm",className:"h-7 text-xs",onClick:()=>P.mutate({run_id:a,input:On(g)},{onSuccess:()=>{L("confirmed")}}),disabled:!T.canSubmit||P.isPending||F.isPending,children:[P.isPending?e.jsx(Te,{size:"sm",className:"mr-1"}):e.jsx(Fn,{className:"h-3 w-3 mr-1"}),"Confirm"]}),e.jsxs(E,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>G(!0),disabled:P.isPending||F.isPending,children:[e.jsx(Dn,{className:"h-3 w-3 mr-1"}),"Reject"]})]})})]})}function dr({content:t,ownerSlug:n}){const s=t.metadata||{},r=s.kind,a=t.run_id??null,i=typeof s.automation_id=="number"?s.automation_id:null,o=Tt(i!=null?String(i):void 0,void 0,void 0,{includeVersions:!1,ownerSlug:n}).data?.automation?.automation_name??(i!=null?`Automation ${i}`:"An Automation"),c=Sn({slug:n}),p=In({slug:n}),[u,h]=N.useState(!1),[v,I]=N.useState(""),[_,j]=N.useState(null);if(r==="automation_batch_reject"){const f=s.reason||void 0;return e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Proposals rejected"}),f&&e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:f}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Ask the agent to revise its proposals with this feedback."})]})}const w=Array.isArray(s.changes)?s.changes:[],K=typeof s.created_count=="number"?s.created_count:w.filter(f=>f.kind==="created").length,P=typeof s.updated_count=="number"?s.updated_count:w.filter(f=>f.kind==="updated").length,F=typeof s.denied_count=="number"?s.denied_count:w.filter(f=>f.kind==="denied").length,T=w.filter(f=>f.kind==="denied"),g=w.filter(f=>f.kind==="updated"&&Object.keys(f.applied||{}).length>0),B=typeof s.pending_proposal_count=="number"?s.pending_proposal_count:null,k=B==null||B>0,L=k?"proposed":"applied";return e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[e.jsxs("div",{className:"text-sm font-medium",children:[L==="proposed"?"Proposed":"Applied"," ",K," ","new + ",P," updated",F>0&&e.jsxs(e.Fragment,{children:[" + ",F," denied"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[i!=null?e.jsx(le,{to:"/$owner/automations/$automationId",params:{owner:n,automationId:String(i)},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:o}):e.jsx("span",{className:"font-medium text-foreground",children:o}),a!=null&&e.jsxs("span",{children:[" · run #",a]}),B!=null&&B>0&&e.jsxs("span",{children:[" · ",B," pending"]})]})]}),g.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:g.map(f=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:f.name}),e.jsx(rt,{changes:Object.entries(f.applied).map(([G,R])=>({field:G,old:R.old??null,new:R.new??null})),entityId:f.entityId,ownerSlug:n,showAll:!0})]},f.entityId))}),T.length>0&&e.jsx("div",{className:"mt-3 space-y-1.5",children:T.map(f=>e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-2.5 py-2",children:[e.jsxs("div",{className:"text-xs font-medium",children:[f.name," — not written"]}),f.denied&&e.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[f.denied.reason,e.jsxs("span",{className:"ml-1 opacity-70",children:["(refused by"," ",f.denied.source==="rule"?"a write rule":"org policy",")"]})]})]},`denied-${f.entityId}-${f.name}`))}),a!=null&&_==null&&k&&e.jsx("div",{className:"mt-3 border-t border-border/70 pt-3",children:u?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"What should the agent change?",value:v,onChange:f=>I(f.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs(E,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>p.mutate({run_id:a,reason:v||void 0},{onSuccess:()=>j("rejected")}),disabled:p.isPending,children:[p.isPending&&e.jsx(Te,{size:"sm",className:"mr-1"}),"Reject all"]}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{h(!1),I("")},children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(E,{size:"sm",className:"h-7 text-xs",onClick:()=>c.mutate({run_id:a},{onSuccess:()=>j("approved")}),disabled:c.isPending||p.isPending,children:[c.isPending&&e.jsx(Te,{size:"sm",className:"mr-1"}),"Approve all proposals"]}),e.jsx(E,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>h(!0),disabled:c.isPending||p.isPending,children:"Reject with feedback"})]})}),_==="approved"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals approved."}),_==="rejected"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Proposals rejected — ask the agent to revise them."}),a!=null&&_==null&&!k&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals reviewed."})]})}function Re({presentation:t="summary",renderDetail:n,onFiltersChange:s,ownerSlug:r,content:a,isReply:i,showParentContext:l,connectorDefinitions:m,hideOriginator:o=!1,hideRunAction:c=!1,hideAttribution:p=!1,hideDetails:u=!1,recordId:h}){const[v,I]=N.useState(null),_=_t(),j=t==="detail",w=Ze(),{currentOwner:K,allOrgs:P,isAuthenticated:F}=Et(),T=r??K,g=T==="me"?null:T,B=N.useCallback(async y=>{if(!g){ot.error("Open this event inside a workspace to interact with it.");return}const $=await ps(g,Number(a.id),y,crypto.randomUUID());return"event_id"in $&&ot.success("Recorded"),$},[a.id,g]),k=a.payload_data??{},{audit:L,operation:f,changeSet:G}=zt(a),R=L&&(k.request!==void 0||k.request_status==="too_large"),O=L&&Array.isArray(k.sdk_call_trace)&&k.sdk_call_trace.length>0,D=T?lt(T,Number(a.id)):null,A=!j&&F?(P??[]).find(y=>y.slug===g):void 0,V=A?{slug:A.slug,organizationId:A.id}:null,se=yt(V??{slug:null,organizationId:null}),re=V?.slug??null,pe=N.useMemo(()=>re&&!L?jt(se.data??[],a.semantic_type):[],[re,L,se.data,a.semantic_type]),we=Nn(),he=!!(!(f||G)&&V&&pe.length>0),Z=!j&&!!D,X=_n(w?.item?.href.split(/[?#]/)[0]??""),de=X?.owner===T&&X?.eventId===Number(a.id),ee=(y,$,z)=>{w?w.open({href:y,title:$,...z==null?{}:{runId:z}}):_({to:y})},ae=(y,$)=>{if(!g)return null;const z=`/${g}/events?run_ids=${y}`;return w?.item?.href===z?null:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>s?s({runIds:[y]}):ee(z,"Run activity",y),title:s?"Filter by this run":"Open run activity",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),$]})},fe=a.run_id!=null&&(s||!(w&&g&&a.automation_id!=null))?ae(a.run_id,s?"Run":"Open run"):null,Y=wn(a),Q=a.automation_id,ke=w&&g&&Y!=null&&Q!=null?()=>w.open({href:`/${g}/automations/${Q}?run_id=${Y}`,title:`${a.automation_name??`Automation ${Q}`} · Run #${Y}`,runId:Y}):void 0,ge=()=>{if(he&&V&&g){const y=Number(a.id);ms(we,V.slug,pe,y).catch(()=>null).then($=>ee(lt(g,y,$?.key),a.title??"Event"));return}D&&ee(D,a.title??"Event")},ye=y=>{const $=y.target;if(!($ instanceof Element))return!1;const z=$.closest('a,button,input,select,textarea,[role="button"],[role="radio"]');return z!==null&&z!==y.currentTarget},ie=y=>{ye(y)||ge()},te=y=>{y.key!=="Enter"&&y.key!==" "||ye(y)||(y.preventDefault(),ge())},je=a.metadata?.source_run_id,H=Ls(a),ve=j&&g?G?e.jsx(dr,{content:a,ownerSlug:g}):f?e.jsx(lr,{ownerSlug:g,content:a,batchReview:typeof je=="number"?ae(je,"Review run"):null}):void 0:void 0,oe=j&&n?n(ve):{content:ve,nativeHeading:ve!=null};return e.jsx("div",{className:ue(i?"border-l-2 border-l-muted pl-4":"",Z&&"cursor-pointer rounded-lg p-3 transition-colors hover:bg-accent/40",Z&&de&&"bg-accent ring-1 ring-inset ring-primary/20"),...Z?{role:"button","aria-current":de?"true":void 0,tabIndex:0,onClick:ie,onKeyDown:te}:{},children:e.jsx(mr,{primaryContent:oe.content,nativeHeading:oe.nativeHeading,heading:H&&g?e.jsx(Us,{event:H,recordId:h,ownerSlug:g}):void 0,body:H&&g?e.jsx(Vs,{event:H,ownerSlug:g}):void 0,detailLinks:oe.links,headingAside:oe.headingAside,hideDetails:u,onFiltersChange:s,presentation:t,content:a,ownerSlug:T??void 0,showParentContext:l,connectorDefinitions:m,onRenderedAction:g?B:void 0,runAction:c?null:fe,hideOriginator:o,hideAttribution:p,runId:Y??a.run_id??null,onRunSelect:ke,auditDetails:j&&(R||O)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"request",label:"Request",available:R},{key:"calls",label:"SDK calls",available:O}].map(y=>y.available?e.jsxs(E,{variant:"outline",size:"sm","aria-expanded":v===y.key,onClick:()=>I($=>$===y.key?null:y.key),children:[v===y.key?e.jsx(Ne,{className:"h-3.5 w-3.5"}):e.jsx(_e,{className:"h-3.5 w-3.5"}),y.label]},y.key):null)}),v==="request"&&(k.request_status==="too_large"?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["The request was too large to retain",typeof k.request_bytes=="number"?` (${k.request_bytes.toLocaleString()} bytes).`:"."]}):e.jsx(ht,{value:k.request})),v==="calls"&&e.jsx(ht,{value:k.sdk_call_trace})]})})})}function cr(t,n){const s=t.payload_data??{},r=t.metadata??{};if(n.audit&&typeof s.success=="boolean")return s.success?"completed":"failed";if(n.changeSet)return r.kind==="automation_batch_reject"?"rejected":typeof r.pending_proposal_count!="number"?void 0:r.pending_proposal_count>0?"pending_approval":"completed";if(n.operation)return Ut(t.interaction_status,typeof r.status=="string"?r.status:void 0)}function ur(t){return t==="pending_approval"?"Needs approval":t==="confirmed"?"Approved":t?me(t):null}function mr({presentation:t,primaryContent:n,nativeHeading:s=!1,heading:r,body:a,detailLinks:i,headingAside:l,onFiltersChange:m,content:o,ownerSlug:c,showParentContext:p,connectorDefinitions:u,onRenderedAction:h,runAction:v,auditDetails:I,hideOriginator:_=!1,hideAttribution:j=!1,runId:w,onRunSelect:K,hideDetails:P=!1}){const[F,T]=N.useState(!1),g=o.metadata??{},B=typeof o.score=="number"&&Number.isFinite(o.score)?Math.round(o.score):"-",k=o.payload_type||"text",L=o.text_content||"",f=t==="summary",G=t==null&&(k==="text"||k==="markdown")&&L.length>500,R=G&&!F?`${L.slice(0,500)}...`:L,O=o.payload_data??{},D=zt(o),{audit:A,operation:V,changeSet:se}=D,re=cr(o,D),pe=ur(re),we=(A?Pt(O,O.tool_name):null)??(f&&A&&typeof O.tool_name=="string"?me(O.tool_name):o.title),xe=A&&O.error&&typeof O.error=="object"?O.error.message:void 0,he=(typeof xe=="string"?xe:void 0)??o.interaction_error??(typeof g.error_message=="string"?g.error_message:void 0),Z=he||(A?"":L),[X,de]=N.useState(t!=="summary"&&A&&n==null&&i==null),ee=A?O.duration_ms:g.duration_ms,ae=typeof ee=="number"&&Number.isFinite(ee)&&ee>=0?ee:null,fe=A&&typeof O.sdk_call_count=="number"&&Number.isSafeInteger(O.sdk_call_count)&&O.sdk_call_count>=0?O.sdk_call_count:null,Y=g.thumbnail_url||g.thumbnail,Q=g.media_url,ke=f?[]:Qs(g),ge=Object.entries(o.classifications||{}).flatMap(([d,b])=>{const S=Xs(b);return S.values.map(J=>({slug:d,value:J,isManual:S.isManual}))}),ye=(()=>{const d=o.platform||(typeof g.platform=="string"?g.platform:null),b=o.connection_id!=null?o.connection_id:g.source_connection_id!=null?Number(g.source_connection_id):null;return{...o,platform:d,connection_id:b!=null&&Number.isFinite(b)?b:null}})(),ie=(()=>{const d=o.source_url??g.browser_url;if(typeof d!="string"||!URL.canParse(d))return null;const b=new URL(d);return b.protocol==="https:"||b.protocol==="http:"?b:null})(),te=o.occurred_at?new Date(o.occurred_at):null,je=A?kt:V?Ct:se?mn:o.semantic_type==="notification"?pn:xn,H=A?"SDK call":me(o.semantic_type||o.origin_type||"Event"),ve=e.jsx(kn,{platform:ye.platform,connectorDefinitions:u,sourceUrl:ie,label:H,fallback:e.jsx(je,{className:"h-4 w-4"})}),oe=ke.length>0?e.jsx("dl",{className:"grid gap-x-3 gap-y-2 text-sm sm:grid-cols-[minmax(140px,180px)_1fr]",children:ke.map(([d,b])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-muted-foreground",children:me(d)}),e.jsx("dd",{className:"min-w-0 break-words font-mono text-xs sm:text-sm",children:Js(b)})]},d))}):null,y=a?e.jsx("div",{className:"mt-1",children:a}):f?Z?e.jsx("p",{className:ue("line-clamp-2 text-sm whitespace-pre-wrap",he&&"text-destructive"),children:Z.slice(0,320)}):null:e.jsxs(e.Fragment,{children:[o.rating&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:[1,2,3,4,5].map(d=>e.jsx(St,{className:`h-4 w-4 ${d<=Number(o.rating)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},d))}),Y&&e.jsx("a",{href:Q||o.source_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block mb-2",children:e.jsx("img",{src:Y,alt:"",className:`rounded-md object-cover ${k==="media"?"max-h-96 w-full":"max-h-48"}`,loading:"lazy"})}),(()=>{switch(k){case"markdown":if(R)return e.jsx("div",{className:"max-w-none text-sm space-y-2",children:e.jsx(hn,{text:R})});break;case"json_template":{const d=o.payload_template;if(d?.root)return e.jsx(fs,{template:d,data:o.payload_data||{},onAction:n?void 0:h},`${c}:${o.id}`);if(R)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:R});break}case"media":return e.jsxs("div",{className:"space-y-3",children:[!Y&&Q&&e.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate block",children:Q}),R&&e.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:R})]});case"empty":return e.jsxs("div",{className:"space-y-3",children:[I,oe??(I?null:e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No content"}))]});default:if(R)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:R});break}return e.jsxs("div",{className:"space-y-3",children:[Q&&!Y&&e.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground truncate block",children:Q}),oe]})})()]}),$=n!=null||t==="detail"&&A,z=l!==void 0,x=$||i!=null;return N.useEffect(()=>{if(!z||!X)return;const d=b=>{b.key==="Escape"&&(b.preventDefault(),de(!1))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[z,X]),e.jsxs(e.Fragment,{children:[p&&o.parent_context&&e.jsxs("div",{className:"mb-3 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Replying to:"}),e.jsx("div",{className:"font-medium",children:o.parent_context.author_name}),e.jsx("div",{className:"text-muted-foreground line-clamp-2",children:o.parent_context.text_content})]}),e.jsxs("div",{className:ue("flex gap-3",t==="detail"&&"mb-5",z&&"relative"),children:[e.jsx(fn,{children:ve}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t==="detail"&&(()=>{const d={semanticTypes:[o.semantic_type],...typeof o.automation_id=="number"?{producedByAutomationId:o.automation_id}:{},...typeof o.run_id=="number"?{runIds:[o.run_id]}:{}},b={semantic_types:o.semantic_type,...typeof o.automation_id=="number"?{produced_by:String(o.automation_id)}:{},...typeof o.run_id=="number"?{run_ids:String(o.run_id)}:{}};return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[o.semantic_type?m?e.jsx("button",{type:"button",className:"hover:underline",title:`Show all ${H} events`,onClick:()=>m(d),children:H}):c?e.jsx(le,{to:"/$owner/events",params:{owner:c},search:b,className:"hover:underline",title:`Show all ${H} events`,children:H}):e.jsx("span",{children:H}):e.jsx("span",{children:H}),te&&e.jsx("time",{dateTime:te.toISOString(),children:Ee(te)})]})})(),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[(r??we)&&!s&&e.jsx("h4",{className:ue("min-w-0 font-medium",t==="detail"?"text-xl leading-snug":"line-clamp-2 text-sm"),children:r??we}),t!=="detail"&&te&&e.jsx(gn,{at:te}),z&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pt-0.5",children:[l,x&&e.jsxs(E,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-muted-foreground hover:text-foreground","aria-expanded":X,onClick:()=>de(d=>!d),children:["Details",X?e.jsx(Ne,{className:"h-3.5 w-3.5"}):e.jsx(_e,{className:"h-3.5 w-3.5"})]})]})]}),f&&e.jsx("div",{className:"mt-1 text-muted-foreground",children:y}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[pe&&!s&&e.jsxs(ce,{variant:re==="failed"?"destructive":"secondary",className:"gap-1 text-xs",children:[re==="failed"?e.jsx(It,{className:"h-3 w-3"}):re==="completed"?e.jsx(tt,{className:"h-3 w-3"}):null,pe]}),fe!=null&&e.jsxs("span",{children:[fe," SDK ",fe===1?"call":"calls"]}),ae!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(At,{className:"h-3 w-3"}),ae<1e3?`${Math.round(ae)}ms`:`${Number((ae/1e3).toFixed(2))}s`]}),v,B==="-"||f&&(A||V||se)?null:o.score_breakdown?e.jsxs(yn,{children:[e.jsx(jn,{asChild:!0,children:e.jsx(E,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx("span",{className:"font-medium",children:B})})}),e.jsx(vn,{className:"w-64",align:"end",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:"Score Breakdown"}),e.jsx(Ws,{breakdown:o.score_breakdown})]})})]}):null,ie&&e.jsxs(vt,{children:[e.jsx(bt,{asChild:!0,children:e.jsx(E,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1",asChild:!0,children:e.jsxs("a",{href:ie.href,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Rt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:f?"sr-only":void 0,children:"View original"})]})})}),e.jsx(Nt,{children:"View original"})]})]}),c&&!j&&e.jsx(bn,{owner:c,source:ye,connectorDefinitions:u,onFiltersChange:m,variant:"chips",className:"mt-2 text-xs",hideOriginator:_,runId:w,onRunSelect:K}),(o.author_name||!c)&&!(t==="detail"&&V)&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:o.author_name||Ks(o)})]}),z&&X&&x&&e.jsxs("div",{className:"absolute inset-x-0 top-full z-20 mt-2 max-h-[65vh] space-y-3 overflow-y-auto rounded-lg border bg-background p-3 shadow-lg",children:[i,$&&y]})]}),!f&&typeof xe=="string"&&e.jsx("p",{className:"mb-2 text-sm whitespace-pre-wrap text-destructive",children:xe}),n,!f&&!$&&y,($||i!=null)&&l===void 0&&!(P&&n!=null)&&e.jsxs("details",{className:"mt-5 border-t pt-3",open:X,onToggle:d=>de(d.currentTarget.open),children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Details"}),X&&e.jsxs("div",{className:"mt-3 space-y-3",children:[i,$&&y]})]}),G&&e.jsx(E,{variant:"link",size:"sm",className:"px-0 h-6 mt-1",onClick:()=>T(!F),children:F?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"})," Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-3 w-3 mr-1"})," Show more"]})}),ge.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:ge.map(d=>e.jsx(Gs,{slug:d.slug,value:d.value||"",isManual:d.isManual},d.slug))})]})}function pr({toolName:t,count:n,titles:s=[],totalDurationMs:r,totalSdkCalls:a,newestAt:i,oldestAt:l,expanded:m,onToggle:o,children:c}){return e.jsx("div",{children:e.jsxs(Me,{open:m,children:[e.jsx("div",{className:"rounded-lg p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{"aria-hidden":!0,className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:e.jsx(kt,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx(Be,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:o,children:[e.jsxs("span",{className:"min-w-0 truncate font-medium text-foreground",children:[me(t)," × ",n]}),m?e.jsx(Ne,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(Kt,{newestAt:i,oldestAt:l})]}),s.length>0&&e.jsx("p",{className:"mt-0.5 truncate text-sm text-muted-foreground",children:s.join(" · ")}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[e.jsxs(ce,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(tt,{className:"h-3 w-3"}),"Completed"]}),a!=null&&e.jsxs("span",{children:[a," SDK ",a===1?"call":"calls"]}),r!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(At,{className:"h-3 w-3"}),xr(r)]})]})]})]})}),e.jsx(ze,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:c})]})})}function xr(t){return t<1e3?`${Math.round(t)}ms`:`${Number((t/1e3).toFixed(2))}s`}function Kt({newestAt:t,oldestAt:n}){const s=ft(t),r=ft(n);return s!=null&&r!=null&&s.getTime()-r.getTime()>hr&&r?e.jsxs("time",{dateTime:s.toISOString(),title:`${Ee(r)} – ${Ee(s)}`,className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:[De(r,"HH:mm"),"–",De(s,"HH:mm")]}):s?e.jsx("time",{dateTime:s.toISOString(),title:Ee(s),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:De(s,"HH:mm")}):null}const hr=300*1e3;function ft(t){if(t==null||t==="")return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:n}function fr({organizationId:t,clientId:n,activityId:s,activityKind:r,callCount:a,newestAt:i,oldestAt:l,expanded:m,onToggle:o,children:c}){const{data:p=[]}=Ln({limit:100,organizationId:t??null}),u=p.find(I=>I.activityId===s&&(n==null||I.clientId===n))??null,h=u?ts(u):r==="session"?"MCP session":"Conversation",v=u?.clientName??null;return e.jsx("div",{children:e.jsxs(Me,{open:m,children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background",children:e.jsx($t,{name:v})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx(Be,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:o,children:[e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:h}),m?e.jsx(Ne,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(Kt,{newestAt:i,oldestAt:l})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[`${a} ${a===1?"call":"calls"}`,v?` · ${v}`:null]})]})]})}),e.jsx(ze,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:c})]})})}function gr({onIntersect:t,enabled:n,rootMargin:s="400px"}){const r=N.useRef(null),a=N.useRef(t);return a.current=t,N.useEffect(()=>{const i=r.current;if(!i||!n)return;const l=new IntersectionObserver(m=>{m[0]?.isIntersecting&&a.current()},{rootMargin:s});return l.observe(i),()=>l.disconnect()},[n,s]),r}function gt(t){if(t==null||t==="")return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:De(n,"d MMMM yyyy")}function yr({items:t,isLoading:n,emptyState:s,hasNextPage:r,isFetching:a,isFetchingNextPage:i,onLoadMore:l,autoLoadMore:m=!0,groupByDate:o=!0}){const c=gr({onIntersect:l,enabled:m&&r&&!a});return n&&t.length===0?e.jsx("div",{className:"space-y-4",children:["s1","s2","s3"].map(p=>e.jsx(Oe,{className:"h-32 rounded-lg"},p))}):e.jsxs("div",{children:[t.length===0?s!==void 0?s:e.jsx(Mn,{icon:Bn,title:"Nothing here yet",description:"No events match this view."}):t.map((p,u)=>{const h=gt(p.occurredAt),v=u>0?gt(t[u-1].occurredAt):null;return e.jsxs(N.Fragment,{children:[o&&h&&h!==v&&e.jsx("p",{className:"px-3 pb-2 pt-4 text-xs text-muted-foreground first:pt-0",children:h}),e.jsx("div",{className:"mb-1",children:p.content})]},p.key)}),e.jsx("div",{ref:c,className:"h-1"}),i?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(Te,{size:"xl",className:"text-muted-foreground"})}):r&&e.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:l,children:"Load more"})]})}function Sr({presentation:t="summary",renderDetail:n,onFiltersChange:s,hideDetails:r=!1,organizationId:a,ownerSlug:i,entityId:l,filters:m,showEntityLinks:o=!1,hideOriginator:c=!1,emptyState:p,foldConsecutiveCalls:u=!1,groupByConversation:h=!1,groupByRun:v=!1,onRunSelect:I,runs:_,hideRunAction:j=!1,hideAttribution:w=!1,hiddenApprovalRunIds:K}){const{isAuthenticated:P,isReady:F}=zn(),{isMember:T,isLoading:g}=Un(),B=i==="me",k=!B&&F&&P&&T,L=!B&&F&&(!P||!g&&!T),{data:f=[]}=Vn(F&&k?a:null),{data:G=[]}=Hn(L?i:null),R=k?f:G,O=qn(F&&k?a:null,l,m,i),D=Kn(L?i:null,l,m),A=L?D:O,{data:V,isLoading:se,error:re,fetchNextPage:pe,hasNextPage:we,isFetchingNextPage:xe}=A,he=N.useMemo(()=>V?.pages.flatMap(x=>x.content)??[],[V]),Z=N.useMemo(()=>{const x=Jn(he,{foldRunSatellites:!v}),d=x.map(q=>q.head),b=new Map(x.map(q=>[q.head.id,q])),S=Qn(d,{groupByRun:v}),J=Array.from(S.entries()).map(([q,M])=>{const W=M.root||M.replies[0],Se=W?b.get(W.id):void 0;return{rootId:q,group:M,history:Se?.history??[],runId:Se?.runId??null}});return K?Wn(J,K):J},[he,v,K]),[X,de]=N.useState(new Set),[ee,ae]=N.useState(new Set),[fe,Y]=N.useState(new Set),[Q,ke]=N.useState(new Set),[ge,ye]=N.useState(new Set),ie=(x,d)=>x(b=>{const S=new Set(b);return S.has(d)?S.delete(d):S.add(d),S}),te=(x,d)=>d.some(b=>x.has(b)),je=(x,d)=>x(b=>{const S=new Set(b),J=d.some(q=>S.has(q));for(const q of d)J?S.delete(q):S.add(q);return S}),H=u?Gn(Z):Z.map(x=>({kind:"single",node:x})),ve=h?Xn(H):H,oe=!B&&(!F||P&&g||k&&A.isPending);if(re)return e.jsx(Yn,{label:"events"});const y=x=>{if(x.kind==="fold"){const{fold:C}=x,at=C.nodes.map(Ie=>Ie.rootId),Wt=te(ee,at);return[{key:C.key,occurredAt:C.newestAt,content:e.jsx(pr,{toolName:C.toolName,count:C.nodes.length,titles:[...new Set(C.nodes.flatMap(Ie=>{const Ce=Ie.group.root?.payload_data,it=Pt(Ce,Ce?.tool_name);return it?[it]:[]}))],totalDurationMs:C.totalDurationMs,totalSdkCalls:C.totalSdkCalls,newestAt:C.newestAt,oldestAt:C.oldestAt,expanded:Wt,onToggle:()=>je(ae,at),children:C.nodes.map(Ie=>{const Ce=Ie.group.root;return Ce?e.jsx(Re,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:Ce,renderDetail:n,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w,hideDetails:r},Ce.id):null})})}]}const{rootId:d,group:b,history:S,runId:J}=x.node,q=b.replies.length>0,M=X.has(d),W=ge.has(d),Se=Q.has(d),Jt=b.replies.filter(C=>C.depth<=3),$e=b.replies.filter(C=>C.depth>3),Qt=!b.root&&b.replies.length>0,ne=b.root||b.replies[0];return ne?[{key:d,occurredAt:ne.occurred_at,content:e.jsxs(e.Fragment,{children:[o&&i&&ne.entity_name&&ne.entity_type&&ne.entity_slug&&e.jsx("div",{className:"mb-2",children:e.jsx(us,{ownerSlug:i,entity:{entityName:ne.entity_name,entityType:ne.entity_type,entitySlug:ne.entity_slug}})}),e.jsx(Re,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:ne,renderDetail:n,showParentContext:Qt&&!!ne.parent_context,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w,hideDetails:r}),S.length>0&&e.jsxs(Me,{open:Se,children:[e.jsx(Be,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"mt-1 h-7 gap-1 text-xs text-muted-foreground",onClick:()=>ie(ke,d),children:[e.jsx(es,{className:"h-3.5 w-3.5"}),Se?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Hide ",J!=null?`run #${J} `:"","history"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),J!=null?`Run #${J} · ${S.length===1?"1 earlier step":`${S.length} earlier steps`}`:S.length===1?"1 earlier state":`${S.length} earlier states`]})]})}),e.jsx(ze,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:S.map(C=>e.jsxs("div",{children:[e.jsx("time",{dateTime:new Date(C.occurred_at).toISOString(),title:Ee(C.occurred_at),className:"mb-1 block text-xs text-muted-foreground",children:dt(C.occurred_at)}),e.jsx(Re,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:C,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w})]},C.id))})]}),q&&e.jsxs(Me,{open:M,children:[e.jsx(Be,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"mt-2 ml-6 gap-1",onClick:()=>ie(de,d),children:[e.jsx(He,{className:"h-3.5 w-3.5"}),M?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Hide ",b.replies.length," replies"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),"Show ",b.replies.length," replies"]})]})}),e.jsxs(ze,{className:"space-y-2 mt-2",children:[Jt.map(C=>e.jsx(Re,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:C,isReply:!0,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w},C.id)),$e.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"ghost",size:"sm",className:"ml-12",onClick:()=>ie(ye,d),children:W?e.jsxs(e.Fragment,{children:["Hide ",$e.length," nested replies"]}):e.jsxs(e.Fragment,{children:["Show ",$e.length," nested replies"]})}),W&&$e.map(C=>e.jsx(Re,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:C,isReply:!0,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w},C.id))]})]})]})]})}]:[]},$=x=>{const d=x.nodes.length;return{key:x.key,occurredAt:x.newestAt,content:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[I?e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1 text-xs font-medium",onClick:()=>I(x.runId),title:`Open run #${x.runId} conversation`,children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Run #",x.runId]}):e.jsxs("span",{className:"inline-flex h-7 items-center gap-1 px-1 text-xs font-medium",children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Run #",x.runId]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[x.status!=null?`· ${me(x.status)} · `:"· ",d===1?"1 event":`${d} events`,x.newestAt!=null?` · ${dt(x.newestAt)}`:""]})]}),e.jsx("div",{className:"mt-2 space-y-2 border-l-2 border-l-muted pl-4",children:x.nodes.flatMap(b=>y({kind:"single",node:b}).map(S=>e.jsx(N.Fragment,{children:S.content},S.key)))})]})}},z=x=>{const{block:d}=x,b=d.entries.flatMap(M=>M.kind==="fold"?M.fold.nodes.map(W=>W.rootId):[M.node.rootId]),S=te(fe,b),J=d.entries.flatMap(M=>y(M).map(W=>({key:W.key,content:W.content})));if(J.length===0)return[];const q=d.entries.reduce((M,W)=>M+(W.kind==="fold"?W.fold.nodes.length:1),0);return[{key:d.key,occurredAt:d.newestAt,content:e.jsx(fr,{organizationId:a,clientId:d.clientId,activityId:d.activityId,activityKind:d.activityKind,callCount:q,newestAt:d.newestAt,oldestAt:d.oldestAt,expanded:S,onToggle:()=>je(Y,b),children:J.map(M=>e.jsx(N.Fragment,{children:M.content},M.key))})}]};return e.jsx(yr,{groupByDate:t==="summary",isLoading:se||oe,emptyState:p,hasNextPage:!!we,isFetching:A.isFetching,isFetchingNextPage:xe,onLoadMore:()=>void pe(),items:v?Zn(Z,_).map(x=>"nodes"in x?$(x):y({kind:"single",node:x})[0]).filter(x=>x!=null):ve.flatMap(x=>x.kind==="context"?z(x):y(x))})}export{Sr as E,Cr as L,_s as R,Ns as S,yr as a,mr as b,_r as c,kr as d,gs as i,ks as l,js as s,Pt as t,wr as u};
|
|
2
|
-
//# sourceMappingURL=events-feed-DO3IiJO2.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{dq as P,j as e,B as h,Q as g,r as m,dr as C,X as z,ds as k,dt as S,cT as O,C as B,du as D,dv as E,dw as F,dx as L,cE as $,cF as R,T as I,d1 as j,dy as Q,dz as _,dA as N,dB as b,I as y,dC as A}from"./index-9YuSRymd.js";function w(s,t,n){return P(s,-t,n)}const T="w-72";function M({editor:s,close:t,header:n,footer:o}){const[r,a]=m.useState("");return e.jsxs(e.Fragment,{children:[n,s.kind==="list"?e.jsxs(D,{shouldFilter:!s.onQueryChange,children:[e.jsx(E,{autoFocus:!0,placeholder:s.searchPlaceholder,value:r,onValueChange:d=>{a(d),s.onQueryChange?.(d)}}),e.jsxs(F,{children:[e.jsx(L,{children:s.emptyText}),e.jsx($,{children:s.items(t,r)})]})]}):s.render(t),o]})}function q({chip:s,editor:t}){const[n,o]=m.useState(!1),r=s.onRemove!=null,a=[s.label,s.op,s.value].filter(Boolean).join(" "),d=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:s.label}),s.op?e.jsx("span",{className:"text-muted-foreground",children:s.op}):null,e.jsx("span",{className:"min-w-0 truncate font-medium",children:s.value})]}),l=t?e.jsx(S,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Edit filter: ${a}`,className:"flex min-w-0 items-center gap-1.5 pl-2.5 pr-1 focus-visible:outline-none",children:d})}):e.jsx("span",{className:"flex min-w-0 items-center gap-1.5 pl-2.5 pr-1",children:d});return e.jsxs(C,{open:n,onOpenChange:o,children:[e.jsxs("div",{"data-filter-chip":s.id,title:s.title,className:g("inline-flex h-8 max-w-full items-stretch rounded-md border text-sm",s.tone==="warning"?"border-amber-500/60 bg-amber-500/10":r?"bg-muted":"border-dashed bg-transparent",n&&"ring-1 ring-ring",!r&&"pr-1.5"),children:[l,r?e.jsx("button",{type:"button","aria-label":`Remove filter: ${a}`,onClick:s.onRemove,className:"flex w-7 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(z,{className:"h-3.5 w-3.5"})}):null]}),t?e.jsx(k,{align:"start",className:g("p-0",T,t.className),children:e.jsx(M,{editor:t,close:()=>o(!1),footer:r?e.jsx("div",{className:"border-t p-1",children:e.jsx(h,{variant:"ghost",size:"sm",className:"w-full justify-start text-destructive hover:text-destructive",onClick:()=>{o(!1),s.onRemove?.()},children:"Remove filter"})}):null})}):null]})}function H({fields:s}){const[t,n]=m.useState(!1),[o,r]=m.useState(),a=s.find(i=>i.key===o),d=[...new Set(s.map(i=>i.group??""))],l=()=>{n(!1),r(void 0)};return e.jsxs(C,{open:t,onOpenChange:i=>{n(i),i||r(void 0)},children:[e.jsx(S,{asChild:!0,children:e.jsxs(h,{variant:"outline",size:"sm",className:"h-8 border-dashed font-normal text-muted-foreground",children:[e.jsx(O,{className:"mr-1 h-3.5 w-3.5"}),"Filter"]})}),e.jsx(k,{align:"start",className:g("p-0",T,a?.editor.className),children:a?e.jsx(M,{editor:a.editor,close:l,header:e.jsxs("div",{className:"flex items-center gap-1 border-b px-1 py-1 text-sm font-medium",children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Back to filters",onClick:()=>r(void 0),children:e.jsx(B,{className:"h-4 w-4"})}),a.label]})},a.key):e.jsxs(D,{children:[e.jsx(E,{autoFocus:!0,placeholder:"Filter by…"}),e.jsxs(F,{children:[e.jsx(L,{children:"No matching filter"}),d.map(i=>e.jsx($,{heading:i||void 0,children:s.filter(c=>(c.group??"")===i).map(c=>e.jsxs(R,{value:`${c.label} ${c.key}`,onSelect:()=>r(c.key),className:"gap-2",children:[c.icon?e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:c.icon}):null,c.label]},c.key))},i))]})]})})]})}function K({fields:s,chips:t,meta:n,actions:o,trailing:r,onClearAll:a,hasClearableState:d=!1,className:l,label:i="Filters"}){const c=s.filter(u=>u.inMenu!==!1),x=t.filter(u=>u.onRemove).length;return e.jsxs("div",{role:"search","aria-label":i,className:g("flex min-w-0 flex-wrap items-center gap-2",l),children:[t.map(u=>e.jsx(q,{chip:u,editor:u.editor??s.find(f=>f.key===(u.field??u.id))?.editor},u.id)),c.length>0?e.jsx(H,{fields:c}):null,o,e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[n?e.jsx("span",{className:"text-sm text-muted-foreground",children:n}):null,a&&(x>0||d)?e.jsx(h,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground",onClick:a,children:"Clear all"}):null,r]})]})}function U({selected:s}){return e.jsx(Q,{className:g("h-4 w-4 shrink-0",s?"opacity-100":"opacity-0")})}function Y({searchPlaceholder:s,emptyText:t="No options",options:n,selected:o,multiple:r=!1,onSelect:a}){return{kind:"list",searchPlaceholder:s,emptyText:t,items:d=>n.map(l=>{const i=o.includes(l.value);return e.jsxs(R,{value:`${l.label} ${l.keywords??l.value}`,onSelect:()=>{a(l.value),r||d()},className:"gap-2",children:[r?e.jsx(I,{checked:i,className:"mr-1"}):e.jsx(U,{selected:i}),l.icon,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.label}),l.count!=null?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:l.count.toLocaleString()}):null]},l.value)})}}function Z([s,t],n,o){return s<=n?`≤ ${t}`:t>=o?`≥ ${s}`:`${s}–${t}`}function V({value:s,min:t,max:n,onApply:o,close:r}){const[a,d]=m.useState(String(s?.[0]??t)),[l,i]=m.useState(String(s?.[1]??n)),[c,x]=m.useState(),u=f=>{f.preventDefault();const v=Number(a),p=Number(l);if(!Number.isFinite(v)||!Number.isFinite(p)){x("Enter a number.");return}if(v<t||p>n){x(`Use values between ${t} and ${n}.`);return}if(v>p){x("The lower bound must not exceed the upper bound.");return}o([v,p]),r()};return e.jsxs("form",{className:"space-y-3 p-3",onSubmit:u,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-2",children:[e.jsx(y,{"aria-label":"From",type:"number",min:t,max:n,value:a,onChange:f=>d(f.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(y,{"aria-label":"To",type:"number",min:t,max:n,value:l,onChange:f=>i(f.target.value)})]}),c?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:c}):null,e.jsx(h,{type:"submit",size:"sm",className:"w-full",children:"Apply"})]})}function ee(s){return{kind:"custom",render:t=>e.jsx(V,{...s,close:t})}}const G=[{label:"Today",range:()=>[N(new Date),b(new Date)]},{label:"Last 7 days",range:()=>[N(w(new Date,6)),b(new Date)]},{label:"Last 30 days",range:()=>[N(w(new Date,29)),b(new Date)]},{label:"This month",range:()=>[A(new Date),b(new Date)]}];function se([s,t]){return j(s,"yyyy-MM-dd")===j(t,"yyyy-MM-dd")?j(s,"LLL d, y"):`${j(s,"LLL d")} – ${j(t,"LLL d, y")}`}function W({value:s,onApply:t,close:n}){const[o,r]=m.useState(s?{from:s[0],to:s[1]}:void 0);return e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"flex flex-col gap-0.5 border-b p-2 sm:w-36 sm:border-b-0 sm:border-r",children:G.map(a=>e.jsx(h,{variant:"ghost",size:"sm",className:"justify-start font-normal",onClick:()=>{t(a.range()),n()},children:a.label},a.label))}),e.jsx(_,{mode:"range",defaultMonth:o?.from,selected:o,onSelect:a=>{r(a),a?.from&&a.to&&a.from!==a.to&&(t([N(a.from),b(a.to)]),n())},numberOfMonths:1})]})}function te(s){return{kind:"custom",className:"w-auto",render:t=>e.jsx(W,{...s,close:t})}}function X({type:s,label:t,value:n,onApply:o,close:r}){const[a,d]=m.useState(n==null?"":String(n)),[l,i]=m.useState(),c=x=>{if(x.preventDefault(),s==="number"){const u=Number(a);if(a.trim()===""||!Number.isFinite(u)){i("Enter a number.");return}o(u)}else o(a);r()};return e.jsxs("form",{className:"space-y-3 p-3",onSubmit:c,children:[e.jsx(y,{autoFocus:!0,"aria-label":t,type:s,step:s==="number"?"any":void 0,value:a,onChange:x=>d(x.target.value),placeholder:"Enter a value…"}),l?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:l}):null,e.jsx(h,{type:"submit",size:"sm",className:"w-full",children:"Apply"})]})}function ae(s){return{kind:"custom",render:t=>e.jsx(X,{...s,close:t})}}export{K as F,U as S,Z as a,te as d,se as f,Y as o,ee as r,ae as v};
|
|
2
|
-
//# sourceMappingURL=filter-editors-Bwhqj7lY.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iO as t,j as r}from"./index-9YuSRymd.js";import{a as i}from"./agents-workbench-DJ67GZ93.js";import"./agent-editor-form-DsSoeQeF.js";import"./model-selector-CDrAjH31.js";import"./proposal-review-shell-CFhOqCLf.js";function c(){const{owner:o,agentId:e}=t.useParams(),n=t.useSearch();return r.jsx(i,{owner:o,agentId:e,tab:"identity",runId:n.run_id})}export{c as component};
|
|
2
|
-
//# sourceMappingURL=identity-HCFWtdaI.js.map
|