@lobu/runtime-server 22.0.0 → 23.0.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 +1353 -181
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +14 -1
- package/dist/connectors/google_gmail.ts +1 -0
- package/dist/connectors/jira-helpers.ts +313 -0
- package/dist/connectors/jira.ts +29 -221
- package/dist/connectors/linkedin-browser-script.ts +13 -0
- package/dist/connectors/linkedin-draft-page.js +104 -0
- package/dist/connectors/linkedin-drafts.ts +73 -0
- package/dist/connectors/linkedin-identity.ts +32 -0
- package/dist/connectors/linkedin-inbox-adapter.js +1185 -0
- package/dist/connectors/linkedin-inbox.ts +156 -0
- package/dist/connectors/linkedin-like.ts +114 -0
- package/dist/connectors/linkedin-takeout.ts +577 -0
- package/dist/connectors/linkedin.ts +3998 -0
- package/dist/connectors/takeout-utils.ts +240 -0
- package/dist/connectors/tiktok-inbox-page.js +9 -9
- package/dist/connectors/tiktok-web-page.js +21 -15
- package/dist/connectors/tiktok_web.ts +63 -30
- package/dist/connectors/whatsapp-web-adapter.js +64 -564
- package/dist/connectors/whatsapp-web-helpers.ts +30 -444
- package/dist/connectors/whatsapp-web-identity.ts +20 -6
- package/dist/connectors/whatsapp_web.ts +45 -645
- package/dist/connectors/x-dm-adapter.js +556 -0
- package/dist/connectors/x-identity.ts +31 -2
- package/dist/connectors/x.ts +266 -120
- package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
- package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
- package/dist/dependencies.bun.lock +41 -41
- package/dist/guest.bundle.js +288 -148
- package/dist/owletto/dist/assets/_-3J-IrxWk.js +2 -0
- package/dist/owletto/dist/assets/{_-CEPl6gU4.js → _-DYUE3ix4.js} +3 -3
- package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +2 -0
- package/dist/owletto/dist/assets/{_agentId-CBC_SadO.js → _agentId-Cam7Z0N7.js} +2 -2
- package/dist/owletto/dist/assets/{_automationId-YTTNksw6.js → _automationId-CXEiKVZJ.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-fK0h7RAp.js → _connectorKey._connectionId-CS85l61t.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey.index-C7TPS598.js → _connectorKey.index-clVDIyW0.js} +2 -2
- package/dist/owletto/dist/assets/{_conversationId-CEhxlTIo.js → _conversationId-Ci2k-BuN.js} +2 -2
- package/dist/owletto/dist/assets/{_deploymentId-BQfYN1U2.js → _deploymentId-BuUzGtVL.js} +2 -2
- package/dist/owletto/dist/assets/{_eventId-Cl8GSdjg.js → _eventId-B0662F8h.js} +2 -2
- package/dist/owletto/dist/assets/_name-CwWePlOl.js +2 -0
- package/dist/owletto/dist/assets/{_owner-cUtGHqSw.js → _owner-dTWkrKsK.js} +3 -3
- package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +2 -0
- package/dist/owletto/dist/assets/{_slug-CU1PuHB9.js → _slug-DQHutM41.js} +2 -2
- package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-D3OgJG4i.js → accept-invitation-w17IFTtf.js} +2 -2
- package/dist/owletto/dist/assets/{activity-route-view-DQglkhXU.js → activity-route-view-CMqYiiKM.js} +2 -2
- package/dist/owletto/dist/assets/{agent-card-controls-DzRs4Ix9.js → agent-card-controls-mnTN2AZt.js} +2 -2
- package/dist/owletto/dist/assets/{agent-client-setup-list-B2SvH7xD.js → agent-client-setup-list-Bg3hBfUV.js} +2 -2
- package/dist/owletto/dist/assets/{agent-connect-pages-B6uKvT_X.js → agent-connect-pages-B_vrqLVc.js} +2 -2
- package/dist/owletto/dist/assets/{agent-editor-form-oUnIYHd7.js → agent-editor-form-hTs7eO_U.js} +2 -2
- package/dist/owletto/dist/assets/{agent-guardrails-route-BaV1VpDh.js → agent-guardrails-route-BOrCXcAl.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-CtZJM2Gc.js → agent-loading-shells-Dqcvky-k.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-Ds48KFK9.js → agent-permissions-matrix-BOo_4r_4.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-DPk5r08w.js → agent-skill-context-CCdvtlmH.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-DYpB5H1J.js → agent-skills-route-BUxIswuq.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-B3K_jPYR.js → agent-subpage-shell-D92imvSt.js} +2 -2
- package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +6 -0
- package/dist/owletto/dist/assets/agents-9XjpDj_S.js +2 -0
- package/dist/owletto/dist/assets/{agents-workbench-CMyk4PI7.js → agents-workbench-Bt5QCYQ7.js} +2 -2
- package/dist/owletto/dist/assets/{app._appId-DH1Qutz6.js → app._appId-CKv7_squ.js} +2 -2
- package/dist/owletto/dist/assets/{automation-detail-content-CEDNboId.js → automation-detail-content-vUwVumXf.js} +2 -2
- package/dist/owletto/dist/assets/automations-9XjpDj_S.js +2 -0
- package/dist/owletto/dist/assets/{callback-CU-hb8JB.js → callback-BRgcL8gz.js} +2 -2
- package/dist/owletto/dist/assets/{card-DIF8SF9b.js → card-Djgp00r_.js} +2 -2
- package/dist/owletto/dist/assets/{claim-DELEa-gH.js → claim-BYUZnyMp.js} +2 -2
- package/dist/owletto/dist/assets/{clients-CpG676mg.js → clients-D3Zbjxin.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-V27Z4o3P.js → code-editor-DHeyRGZI.js} +2 -2
- package/dist/owletto/dist/assets/connect-CfsFsy9P.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId.activity-DQWcUqKM.js → connected._clientId.activity-Ckdz6I0y.js} +2 -2
- package/dist/owletto/dist/assets/{connected._clientId.index-BC3R303A.js → connected._clientId.index-CNxafNeo.js} +2 -2
- package/dist/owletto/dist/assets/{connection-DySpRE9x.js → connection-C3XXFEqh.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-C_D68j6d.js → connection-feed-detail-CIJJLDP8.js} +2 -2
- package/dist/owletto/dist/assets/{connections-browser-Cnv2iBbZ.js → connections-browser-CKZjzRz6.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-CNXtzYg5.js → connector-provenance-8-d8hl10.js} +2 -2
- package/dist/owletto/dist/assets/{connector-scope-lists-BKDetNDc.js → connector-scope-lists-CadPVsI3.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-BJnk1z_2.js → connectors-lvLJ30lo.js} +2 -2
- package/dist/owletto/dist/assets/{consent-BVzxrAO9.js → consent-CdSvVCgx.js} +2 -2
- package/dist/owletto/dist/assets/{conversations-table-DfZGICl7.js → conversations-table-BdXoZAfc.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-DiTpULFl.js → core.esm-CYvgWCuv.js} +2 -2
- package/dist/owletto/dist/assets/create-0xW9eXxG.js +2 -0
- package/dist/owletto/dist/assets/{create-JRFM8mMf.js → create-B0qhrrX4.js} +2 -2
- package/dist/owletto/dist/assets/create-CAfF-yI1.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-CtSSeYj3.js +3 -0
- package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-DPXl0qA2.js → cronstrue-n4qGUraE.js} +2 -2
- package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +2 -0
- package/dist/owletto/dist/assets/{deployments-DCQdFdwG.js → deployments-RvUdVkj3.js} +2 -2
- package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-BMp7UsMo.js} +2 -2
- package/dist/owletto/dist/assets/{device-CntqYW65.js → device-CPU6CjkJ.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-Bz4JHHMK.js → device-pin-tombstone-CrjG7gPo.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-D4plO3GM.js → device._deviceId-Cs3ZmXWo.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-UJs64GdQ.js → entity-options-uXjgT7y9.js} +2 -2
- package/dist/owletto/dist/assets/{entity-page-Djz6T50J.js → entity-page-Dc0LGr5U.js} +2 -2
- package/dist/owletto/dist/assets/{entity-type-page-OznRag6A.js → entity-type-page-CwZxa0BR.js} +2 -2
- package/dist/owletto/dist/assets/{event-detail-04qOUGIP.js → event-detail-ve2d6Gbb.js} +2 -2
- package/dist/owletto/dist/assets/{events-feed-fucGZSJR.js → events-feed-BtvhZF1f.js} +2 -2
- package/dist/owletto/dist/assets/{filter-editors-DCQgGLyR.js → filter-editors-Cj-v6NtH.js} +2 -2
- package/dist/owletto/dist/assets/{full-page-spinner-KpV2FS2u.js → full-page-spinner-DqpH99np.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +2 -0
- package/dist/owletto/dist/assets/identity-BigVSBCl.js +2 -0
- package/dist/owletto/dist/assets/{index-BEvyBdOU.js → index-B9uPN6FC.js} +2 -2
- package/dist/owletto/dist/assets/{index-BNh2cidi.js → index-BQVliQW1.js} +2 -2
- package/dist/owletto/dist/assets/index-BfedB4Rc.js +2 -0
- package/dist/owletto/dist/assets/index-CUw3aKBI.js +2 -0
- package/dist/owletto/dist/assets/index-CXhxUkv3.js +2 -0
- package/dist/owletto/dist/assets/{index-_oPeVpL_.js → index-Cr5hwh-C.js} +66 -66
- package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +2 -0
- package/dist/owletto/dist/assets/index-DKSx8JN_.js +2 -0
- package/dist/owletto/dist/assets/{index-D3s8rhG9.js → index-DVk7Ug0d.js} +2 -2
- package/dist/owletto/dist/assets/index-DmZuKGf8.js +2 -0
- package/dist/owletto/dist/assets/{index-DCdkwg9H.js → index-Hio-HRfo.js} +2 -2
- package/dist/owletto/dist/assets/{index-BJXkc60S.js → index-ICgKp3YK.js} +2 -2
- package/dist/owletto/dist/assets/index-cPcroOH0.js +2 -0
- package/dist/owletto/dist/assets/{index-BOzuAbvi.js → index-n7sTbNv4.js} +2 -2
- package/dist/owletto/dist/assets/index-xiFpcWKv.js +2 -0
- package/dist/owletto/dist/assets/{json-diff-D_Ym3Uku.js → json-diff-DBoag_OS.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-Bl0OS39L.js → list-skeleton-C_GuoxAH.js} +2 -2
- package/dist/owletto/dist/assets/{login-QHdxqX-4.js → login-Ci6ixHuL.js} +2 -2
- package/dist/owletto/dist/assets/{logout-DUccApuZ.js → logout-CLGgeZB7.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-CFbrq1by.js → member-scope-gate-B44INDPY.js} +2 -2
- package/dist/owletto/dist/assets/{memory-browse-page-IrIXuZTF.js → memory-browse-page-DyQiRvzl.js} +2 -2
- package/dist/owletto/dist/assets/{model-selector-CB1BDvlW.js → model-selector-dAbDgJvx.js} +2 -2
- package/dist/owletto/dist/assets/models-DpVP7ZwX.js +2 -0
- package/dist/owletto/dist/assets/{new-BWo8_Pms.js → new-BUb7AnEW.js} +2 -2
- package/dist/owletto/dist/assets/{new-B5UsLiy6.js → new-BkdULx2r.js} +2 -2
- package/dist/owletto/dist/assets/{new-DpmDXmFI.js → new-CHOr-EcI.js} +2 -2
- package/dist/owletto/dist/assets/{oauth-workspace-access-PGyTnW2K.js → oauth-workspace-access-BxsjwgdH.js} +2 -2
- package/dist/owletto/dist/assets/{organization-BH8PYlVu.js → organization-gxGeDjIV.js} +2 -2
- package/dist/owletto/dist/assets/{peek-pane-content-B2AFNTzP.js → peek-pane-content-CHoQHe2H.js} +2 -2
- package/dist/owletto/dist/assets/{permissions-CwN_YP3u.js → permissions-aPHaKLec.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-DKKGu4Ww.js → proposal-review-shell-UcZr87_Q.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +2 -0
- package/dist/owletto/dist/assets/{recent-DqdZE_TI.js → recent-D-65Pgu-.js} +2 -2
- package/dist/owletto/dist/assets/{record-activity-CvgZyCmw.js → record-activity-CBXH6v1d.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-BL6VcwQH.js → renderer-mEDnVW0O.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-DAvBYkiI.js → reset-password-uX_V6bip.js} +2 -2
- package/dist/owletto/dist/assets/{runs-BWtc5rmc.js → runs-C0rCgGwX.js} +2 -2
- package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +2 -0
- package/dist/owletto/dist/assets/{runs-table-DxIiqrSk.js → runs-table-syPJ6r6T.js} +2 -2
- package/dist/owletto/dist/assets/{settings-Crxlwps-.js → settings-9NkNA1G1.js} +2 -2
- package/dist/owletto/dist/assets/settings-E-10sLQX.js +2 -0
- package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-CRIPMWfN.js → source-record-panels-CPyzlfD1.js} +2 -2
- package/dist/owletto/dist/assets/{status-dot-C5KDvvm9.js → status-dot-B-EWMgq6.js} +2 -2
- package/dist/owletto/dist/assets/{tabs-B4Er9hJj.js → tabs-DqIIkCX-.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-DqEykWl_.js → use-mention-search-By8RZyKW.js} +2 -2
- package/dist/owletto/dist/assets/{view-param-filters-Cylutoy1.js → view-param-filters-CqLZQrnO.js} +2 -2
- package/dist/owletto/dist/index.html +1 -1
- package/dist/server-main.bundle.mjs +11447 -10762
- package/npm-shrinkwrap.json +160 -160
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
- package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
- package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
- package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
- package/vendor/connector-sdk/dist/index.d.ts +3 -0
- package/vendor/connector-sdk/dist/index.js +2 -0
- package/vendor/connector-sdk/package.json +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +0 -1
- package/vendor/core/dist/connector-query-errors.d.ts +32 -0
- package/vendor/core/dist/connector-query-errors.js +41 -1
- package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +8 -131
- package/vendor/core/dist/contracts/worker/protocol.js +9 -61
- package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
- package/vendor/core/dist/device-pin-tombstones.js +57 -0
- package/vendor/core/dist/index.d.ts +2 -1
- package/vendor/core/dist/index.js +1 -0
- package/vendor/core/dist/logger.js +10 -25
- package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
- package/vendor/core/dist/worker/wire.d.ts +0 -10
- package/vendor/core/package.json +6 -6
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-C_zNZben.js +0 -2
- package/dist/owletto/dist/assets/_agentId-QQW91cHX.js +0 -2
- package/dist/owletto/dist/assets/_name-t3oBJ6Zf.js +0 -2
- package/dist/owletto/dist/assets/_shape-bo2lMVCu.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-Dwm4Q4wI.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-Bh6E_NxA.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-D4jKl-Zf.js +0 -2
- package/dist/owletto/dist/assets/agent-thread-C8UaUTWc.js +0 -6
- package/dist/owletto/dist/assets/agents-F4mGI2oF.js +0 -2
- package/dist/owletto/dist/assets/automations-F4mGI2oF.js +0 -2
- package/dist/owletto/dist/assets/connect-B2YL6qIK.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-B6LDmDRV.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-D_HaKoI1.js +0 -2
- package/dist/owletto/dist/assets/create-CUqO6Kfk.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-_4vUkrls.js +0 -3
- package/dist/owletto/dist/assets/create-iHcxV0xd.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-CCYLEicg.js +0 -2
- package/dist/owletto/dist/assets/deployments-ihkhK1zV.js +0 -2
- package/dist/owletto/dist/assets/guardrails-molekzAF.js +0 -2
- package/dist/owletto/dist/assets/identity-BJcaG66g.js +0 -2
- package/dist/owletto/dist/assets/index-B04ON9Jv.js +0 -2
- package/dist/owletto/dist/assets/index-BOsK-K-2.js +0 -2
- package/dist/owletto/dist/assets/index-Bk1x7A67.js +0 -2
- package/dist/owletto/dist/assets/index-CFnx5huL.js +0 -2
- package/dist/owletto/dist/assets/index-Dbd1jusf.js +0 -2
- package/dist/owletto/dist/assets/index-DqZuqC08.js +0 -2
- package/dist/owletto/dist/assets/index-Dr-Xg_xO.js +0 -2
- package/dist/owletto/dist/assets/index-KPOvMVa-.js +0 -2
- package/dist/owletto/dist/assets/models-DnMb3n-Z.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-7KYnww6e.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-BO3h5RkS.js +0 -2
- package/dist/owletto/dist/assets/settings-4Ev-0iNL.js +0 -2
- package/dist/owletto/dist/assets/skills-D0X430X8.js +0 -2
- package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
- package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{k as ee,iS as re,r as _,j as e,S as M,m as U,iT as oe,M as le,P as te,cd as ce,iU as de,dk as F,v as me,eu as H,iV as J,iW as ue,b_ as X,dY as he,eL as ge,eq as xe,eN as pe,iX as fe,bO as ve,bP as D,ex as ye,bS as je,y as z,I as Q,f3 as be,b7 as _e,B as E,eX as Ne,dN as we,eO as Se,L as ke,gj as Ee}from"./index-_oPeVpL_.js";import{R as Ce}from"./record-activity-CvgZyCmw.js";import{T as Te,a as Pe,b as I,d as L,e as G,c as Z,S as De,D as Ie,E as Fe}from"./tabs-B4Er9hJj.js";import{a as Le}from"./source-record-panels-CRIPMWfN.js";import{V as B,a as K,M as Re,b as $e}from"./view-param-filters-Cylutoy1.js";import{a as Ae}from"./renderer-BL6VcwQH.js";import"./filter-editors-DCQgGLyR.js";import"./connection-label-BobuYiAG.js";import"./runs-BWtc5rmc.js";import"./clients-CpG676mg.js";import"./client-rows-EJSKR6z1.js";import"./events-feed-fucGZSJR.js";import"./conversations-table-DfZGICl7.js";import"./agent-loading-shells-CtZJM2Gc.js";import"./member-scope-gate-CFbrq1by.js";import"./app-bridge-BCm4muqj.js";import"./card-DIF8SF9b.js";function Oe({entityId:t,ownerSlug:s}){const{orgContext:l}=ee(),{data:r,isLoading:m}=re(t,l),a=_.useMemo(()=>{if(!r)return[];const o=new Map;for(const c of r.rows){const d=o.get(c.relationship_type_slug);d?d.rows.push(c):o.set(c.relationship_type_slug,{slug:c.relationship_type_slug,label:c.relationship_type_name,rows:[c]})}return[...o.values()]},[r]);return m?e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{className:"h-4 w-32"}),e.jsx(M,{className:"h-12 w-full rounded-lg"}),e.jsx(M,{className:"h-12 w-full rounded-lg"})]}):!r||r.rows.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this entity yet."}):e.jsx("div",{className:"space-y-3",children:a.map(({slug:o,label:c,rows:d})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[c,e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:d.length})]}),e.jsx("ul",{className:"space-y-1",children:d.map(x=>e.jsx(Ve,{entityId:t,row:x,ownerSlug:s},x.id))})]},o))})}function Ve({entityId:t,row:s,ownerSlug:l}){const r=U(),{orgContext:m}=ee(),[a,o]=_.useState(!1),[c,d]=_.useState(!1),x=s.from_entity_id===s.to_entity_id,p=s.from_entity_id===t,u=x?"this entity":p?s.to_entity_name??`Entity #${s.to_entity_id}`:s.from_entity_name??`Entity #${s.from_entity_id}`,h=p?s.to_entity_type:s.from_entity_type,N=p?s.to_entity_id:s.from_entity_id,i=h?`${h} · ${u}`:u;async function g(){o(!0),d(!1);try{const b=[],v=new Set;let y=N;for(;y!==null;){if(v.has(y))throw new Error("Cyclic entity ancestry");v.add(y);const{entity:j}=await ce("manage_entity",{action:"get",entity_id:y},de(m));b.unshift({entity_type:j.entity_type,slug:j.slug}),y=j.parent_id}await r({to:F(l,b)})}catch{d(!0)}finally{o(!1)}}return e.jsxs("li",{className:te("flex items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5"),children:[e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),x||!h?e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:i}):e.jsxs("button",{type:"button",onClick:g,disabled:a,"aria-busy":a,className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm hover:underline",children:i}),h?e.jsx(le,{variant:"outline",className:"shrink-0 text-[9px] px-1.5 py-0 h-4 text-muted-foreground",children:h}):null]}),c?e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null]})}function Me(t,s){const l=new Set([...Object.keys(t),...Object.keys(s)]);let r=!1;const m={};for(const a of l){const o=a in t,c=a in s;if(!o&&c){m[a]=s[a];continue}o&&(m[a]=t[a],(!c||JSON.stringify(t[a])!==JSON.stringify(s[a]))&&(r=!0))}return r?m:void 0}function ze({entity:t,entityTypeSlug:s,orgContext:l,onDeleted:r}){const{isAdmin:m,isLoading:a}=xe(l.organizationId),o=m&&!a,{data:c,isLoading:d}=H(s,l),x=pe(),p=fe(),u=c?.metadata_schema,h=t.field_controls,N=_.useMemo(()=>G(t.metadata??{},u),[t.metadata,u]),i=ve(t.id,{name:t.name,slug:t.slug,metadata:N},u),[g,b]=i.field("name"),[v,y]=i.field("slug"),[j,C]=i.field("metadata"),[w,T]=D(t.id,""),[P,n]=D(t.id,null),[se,$]=D(t.id,!1),[W,A]=D(t.id,null),O=_.useMemo(()=>i.hasInvalidInput?void 0:Me(Z(j),Z(i.baseline.metadata)),[i.baseline.metadata,j,i.hasInvalidInput]),V=O!==void 0,ae=g!==i.baseline.name||v!==i.baseline.slug||V,ie=async f=>{if(f.preventDefault(),!(!o||!i.canSubmit)){if(n(null),!g.trim()){n("Name is required");return}try{await x.mutateAsync({entityId:t.id,name:g.trim()!==i.baseline.name.trim()?g.trim():void 0,slug:v,metadata:O,field_note:V&&w.trim()||void 0}),i.accept(i.values,{name:g.trim(),slug:v,metadata:G({...we(i.baseline.metadata),...O},u)}),T("")}catch(q){n(q instanceof Error?q.message:"Failed to update entity")}}},ne=async()=>{if(o){A(null);try{await p.mutateAsync({entityId:t.id}),$(!1),r?.()}catch(f){A(f instanceof Error?f.message:"Failed to delete entity")}}},Y=[t.total_content>0&&`${t.total_content} content item${t.total_content===1?"":"s"}`,t.automations_count>0&&`${t.automations_count} Automation${t.automations_count===1?"":"s"}`,t.active_connections>0&&`${t.active_connections} connector${t.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return d?e.jsx(ye,{rows:6}):e.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[e.jsx(je,{visible:i.hasConflict,onReload:i.reset}),!o&&e.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:a?"Checking edit permissions…":"You can view this record. Ask a workspace owner or admin to make changes."}),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(Q,{id:"sidebar-name",readOnly:!o,value:g,onChange:f=>b(f.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(Q,{id:"sidebar-slug",readOnly:!o,value:v,onChange:f=>y(f.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),i.revision&&Object.keys(i.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsx(Ie,{schema:i.revision,values:j,onValuesChange:C,readonly:!o,fieldControls:h,orgContext:l})]}),o&&V&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(be,{id:"sidebar-correction-note",value:w,onChange:f=>T(f.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),P&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P}),o&&(se?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(_e,{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 "',t.name,'"?']}),Y&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",Y,". This cannot be easily undone."]})]})]}),W&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:W}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(E,{type:"button",variant:"ghost",size:"sm",onClick:()=>{$(!1),A(null)},children:"Cancel"}),e.jsx(E,{type:"button",variant:"destructive",size:"sm",onClick:ne,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${c?.name||"entity"}`})]})]}):e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(E,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>$(!0),children:"Delete"}),e.jsx(E,{type:"submit",size:"sm",disabled:!i.canSubmit||!ae||x.isPending||!g.trim(),children:x.isPending?"Saving...":"Save"})]}))]})}function Be({entity:t,schema:s}){const l=new Set(t.measure_columns??[]),r=t.metadata??{},m=Object.keys(r).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&s?.properties?.[a]?.const===void 0);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx("dl",{className:"space-y-2.5 text-sm leading-5",children:m.map(a=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-baseline gap-x-3",children:[e.jsx("dt",{className:"break-words text-muted-foreground",children:String(s?.properties?.[a]?.["x-table-label"]??(l.has(a)?a:he(a.replace(/_/g," "))))}),e.jsx("dd",{className:te("min-w-0 [overflow-wrap:anywhere]",l.has(a)&&"tabular-nums"),children:ge(r[a])})]},a))})]})}const R=":overview",S=":activity",k=":relationships";function Ue({active:t,children:s}){const[l,r]=_.useState(t);return _.useEffect(()=>{t&&r(!0)},[t]),!t&&!l?null:e.jsx(L,{value:R,forceMount:!0,hidden:!t,children:s})}const He={},We=()=>{};function Ye({namespace:t,entity:s,recordUrl:l,viewKey:r,onDeleted:m}){const a=me({strict:!1}),o=U(),c={slug:t.slug,organizationId:t.id},d=Ae(c),{data:x}=H(s.entity_type,c),p=d.data??[],u={type:s.entity_type,id:s.id,slug:s.slug,parentId:s.parent_id},h=J(p,u,"overview"),N=J(p,u,"tab"),i=ue(N,r),g=!r&&a.tab==="relationships",b=!r&&!g&&(h.length===0||a.tab==="activity"),v=!r&&!g&&!b,y=n=>`${l}${Ne(n)}`,j=n=>void o({to:".",search:n,replace:!0}),C={type:s.entity_type,entity:s.is_derived?s.slug:s.id},w=s.is_derived?e.jsx(Be,{entity:s,schema:x?.metadata_schema}):e.jsx(ze,{entity:s,entityTypeSlug:s.entity_type,orgContext:c,onDeleted:m}),T=s.is_derived?e.jsx(Le,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:c}):e.jsx(Oe,{entityId:s.id,ownerSlug:t.slug}),P=e.jsxs(e.Fragment,{children:[d.isError&&e.jsx(B,{onRetry:()=>void d.refetch()}),h.map(n=>e.jsx("section",{className:"mb-4 min-w-0","data-testid":"view-card","data-view":n.key,children:e.jsx(K,{orgSlug:t.slug,viewKey:n.key,scope:C,params:He,onParamsChange:We,contentHash:n.content_hash,title:n.name,minHeight:160})},n.key))]});return r&&d.data===void 0?d.isError?e.jsx(B,{onRetry:()=>void d.refetch()}):null:!r&&!g&&a.tab!=="activity"&&d.data===void 0&&!d.isError?e.jsxs("div",{className:"mt-4 grid gap-6 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsx("aside",{className:"min-w-0 lg:pr-2",children:w}),e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading views…"})]}):i.kind==="missing"?e.jsx(Re,{viewKey:i.key,backTo:l,backLabel:`Back to ${s.name}`}):e.jsxs("div",{className:"mt-4 grid gap-6 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsx("aside",{className:"min-w-0 lg:pr-2",children:w}),e.jsxs(Te,{className:"min-w-0",value:i.kind==="tab"?i.view.key:g?k:b?S:R,onValueChange:n=>void o({to:n===R||n===S||n===k?l:y(n),search:n===k?{tab:"relationships"}:n===S?{tab:"activity"}:{}}),children:[e.jsxs(Pe,{className:"max-w-full justify-start overflow-x-auto",children:[h.length>0&&e.jsx(I,{value:R,children:h.length===1?h[0].name:"Overview"}),e.jsx(I,{value:S,children:"Activity"}),e.jsx(I,{value:k,children:"Relationships"}),N.map(n=>e.jsx(I,{value:n.key,"data-testid":`tab-${n.key}`,children:n.name},n.key))]}),h.length>0&&e.jsx(Ue,{active:v,children:P},`${t.id}/${s.entity_type}/${s.is_derived?s.slug:s.id}`),e.jsx(L,{value:k,children:T}),e.jsxs(L,{value:S,children:[d.isError&&e.jsx(B,{onRetry:()=>void d.refetch()}),e.jsx(Ce,{entity:s,organizationId:t.id,ownerSlug:t.slug})]}),i.kind==="tab"&&e.jsxs(L,{value:i.view.key,children:[e.jsx($e,{decls:i.view.params,params:X(a),onParamsChange:n=>void o({to:".",search:n})}),e.jsx(K,{orgSlug:t.slug,viewKey:i.view.key,scope:C,params:X(a),onParamsChange:j,contentHash:i.view.content_hash,title:i.view.name,minHeight:320})]})]})]})}function qe(t){return t?.trim()?t:void 0}function mt({namespace:t,path:s,entity:l,viewKey:r}){const m=U(),{data:a}=H(l.entity_type,{slug:t.slug}),o=qe(a?.icon),c=s.map(u=>({entity_type:u.entity_type,slug:u.slug})),d=`/${t.slug}/${Se(l.entity_type)}`,x=F(t.slug,c),p=s.length>1?F(t.slug,c.slice(0,-1)):d;return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 py-6 lg:px-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:e.jsx(E,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs(ke,{to:p,children:[e.jsx(Ee,{className:"mr-1 h-4 w-4"}),"Back"]})})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{metadata:l.metadata,metadataSchema:a?.metadata_schema,name:l.name,typeIcon:o,className:"h-6 w-6"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:l.name})]})]}),e.jsx(Ye,{namespace:t,entity:l,recordUrl:x,viewKey:r,onDeleted:()=>{const u=s.slice(0,-1);u.length>0?m({to:F(t.slug,u)}):m({to:d})}})]})}export{mt as EntityPage};
|
|
2
|
-
//# sourceMappingURL=entity-page-
|
|
1
|
+
import{k as ee,iP as re,r as _,j as e,S as M,m as U,iQ as oe,M as le,P as te,cd as ce,iR as de,dk as R,v as me,eu as H,iS as J,iT as ue,b_ as Q,dY as he,eL as ge,eq as xe,eN as pe,iU as fe,bO as ve,bP as D,ex as ye,bS as je,y as z,I as X,f3 as be,b7 as _e,B as E,eX as Ne,dN as we,eO as Se,L as ke,gj as Ee}from"./index-Cr5hwh-C.js";import{R as Ce}from"./record-activity-CBXH6v1d.js";import{T as Te,a as Pe,b as I,d as F,e as G,c as Z,S as De,D as Ie,E as Re}from"./tabs-DqIIkCX-.js";import{a as Fe}from"./source-record-panels-CPyzlfD1.js";import{V as B,a as K,M as Le,b as $e}from"./view-param-filters-CqLZQrnO.js";import{a as Ae}from"./renderer-mEDnVW0O.js";import"./filter-editors-Cj-v6NtH.js";import"./connection-label-BobuYiAG.js";import"./runs-C0rCgGwX.js";import"./clients-D3Zbjxin.js";import"./client-rows-EJSKR6z1.js";import"./events-feed-BtvhZF1f.js";import"./conversations-table-BdXoZAfc.js";import"./agent-loading-shells-Dqcvky-k.js";import"./member-scope-gate-B44INDPY.js";import"./app-bridge-BCm4muqj.js";import"./card-Djgp00r_.js";function Oe({entityId:t,ownerSlug:s}){const{orgContext:l}=ee(),{data:r,isLoading:m}=re(t,l),a=_.useMemo(()=>{if(!r)return[];const o=new Map;for(const c of r.rows){const d=o.get(c.relationship_type_slug);d?d.rows.push(c):o.set(c.relationship_type_slug,{slug:c.relationship_type_slug,label:c.relationship_type_name,rows:[c]})}return[...o.values()]},[r]);return m?e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{className:"h-4 w-32"}),e.jsx(M,{className:"h-12 w-full rounded-lg"}),e.jsx(M,{className:"h-12 w-full rounded-lg"})]}):!r||r.rows.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this entity yet."}):e.jsx("div",{className:"space-y-3",children:a.map(({slug:o,label:c,rows:d})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[c,e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:d.length})]}),e.jsx("ul",{className:"space-y-1",children:d.map(x=>e.jsx(Ve,{entityId:t,row:x,ownerSlug:s},x.id))})]},o))})}function Ve({entityId:t,row:s,ownerSlug:l}){const r=U(),{orgContext:m}=ee(),[a,o]=_.useState(!1),[c,d]=_.useState(!1),x=s.from_entity_id===s.to_entity_id,p=s.from_entity_id===t,u=x?"this entity":p?s.to_entity_name??`Entity #${s.to_entity_id}`:s.from_entity_name??`Entity #${s.from_entity_id}`,h=p?s.to_entity_type:s.from_entity_type,N=p?s.to_entity_id:s.from_entity_id,i=h?`${h} · ${u}`:u;async function g(){o(!0),d(!1);try{const b=[],v=new Set;let y=N;for(;y!==null;){if(v.has(y))throw new Error("Cyclic entity ancestry");v.add(y);const{entity:j}=await ce("manage_entity",{action:"get",entity_id:y},de(m));b.unshift({entity_type:j.entity_type,slug:j.slug}),y=j.parent_id}await r({to:R(l,b)})}catch{d(!0)}finally{o(!1)}}return e.jsxs("li",{className:te("flex items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5"),children:[e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),x||!h?e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:i}):e.jsxs("button",{type:"button",onClick:g,disabled:a,"aria-busy":a,className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm hover:underline",children:i}),h?e.jsx(le,{variant:"outline",className:"shrink-0 text-[9px] px-1.5 py-0 h-4 text-muted-foreground",children:h}):null]}),c?e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null]})}function Me(t,s){const l=new Set([...Object.keys(t),...Object.keys(s)]);let r=!1;const m={};for(const a of l){const o=a in t,c=a in s;if(!o&&c){m[a]=s[a];continue}o&&(m[a]=t[a],(!c||JSON.stringify(t[a])!==JSON.stringify(s[a]))&&(r=!0))}return r?m:void 0}function ze({entity:t,entityTypeSlug:s,orgContext:l,onDeleted:r}){const{isAdmin:m,isLoading:a}=xe(l.organizationId),o=m&&!a,{data:c,isLoading:d}=H(s,l),x=pe(),p=fe(),u=c?.metadata_schema,h=t.field_controls,N=_.useMemo(()=>G(t.metadata??{},u),[t.metadata,u]),i=ve(t.id,{name:t.name,slug:t.slug,metadata:N},u),[g,b]=i.field("name"),[v,y]=i.field("slug"),[j,C]=i.field("metadata"),[w,T]=D(t.id,""),[P,n]=D(t.id,null),[se,$]=D(t.id,!1),[W,A]=D(t.id,null),O=_.useMemo(()=>i.hasInvalidInput?void 0:Me(Z(j),Z(i.baseline.metadata)),[i.baseline.metadata,j,i.hasInvalidInput]),V=O!==void 0,ae=g!==i.baseline.name||v!==i.baseline.slug||V,ie=async f=>{if(f.preventDefault(),!(!o||!i.canSubmit)){if(n(null),!g.trim()){n("Name is required");return}try{await x.mutateAsync({entityId:t.id,name:g.trim()!==i.baseline.name.trim()?g.trim():void 0,slug:v,metadata:O,field_note:V&&w.trim()||void 0}),i.accept(i.values,{name:g.trim(),slug:v,metadata:G({...we(i.baseline.metadata),...O},u)}),T("")}catch(q){n(q instanceof Error?q.message:"Failed to update entity")}}},ne=async()=>{if(o){A(null);try{await p.mutateAsync({entityId:t.id}),$(!1),r?.()}catch(f){A(f instanceof Error?f.message:"Failed to delete entity")}}},Y=[t.total_content>0&&`${t.total_content} content item${t.total_content===1?"":"s"}`,t.automations_count>0&&`${t.automations_count} Automation${t.automations_count===1?"":"s"}`,t.active_connections>0&&`${t.active_connections} connector${t.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return d?e.jsx(ye,{rows:6}):e.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[e.jsx(je,{visible:i.hasConflict,onReload:i.reset}),!o&&e.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:a?"Checking edit permissions…":"You can view this record. Ask a workspace owner or admin to make changes."}),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(X,{id:"sidebar-name",readOnly:!o,value:g,onChange:f=>b(f.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(X,{id:"sidebar-slug",readOnly:!o,value:v,onChange:f=>y(f.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),i.revision&&Object.keys(i.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsx(Ie,{schema:i.revision,values:j,onValuesChange:C,readonly:!o,fieldControls:h,orgContext:l})]}),o&&V&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(be,{id:"sidebar-correction-note",value:w,onChange:f=>T(f.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),P&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P}),o&&(se?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(_e,{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 "',t.name,'"?']}),Y&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",Y,". This cannot be easily undone."]})]})]}),W&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:W}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(E,{type:"button",variant:"ghost",size:"sm",onClick:()=>{$(!1),A(null)},children:"Cancel"}),e.jsx(E,{type:"button",variant:"destructive",size:"sm",onClick:ne,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${c?.name||"entity"}`})]})]}):e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(E,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>$(!0),children:"Delete"}),e.jsx(E,{type:"submit",size:"sm",disabled:!i.canSubmit||!ae||x.isPending||!g.trim(),children:x.isPending?"Saving...":"Save"})]}))]})}function Be({entity:t,schema:s}){const l=new Set(t.measure_columns??[]),r=t.metadata??{},m=Object.keys(r).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&s?.properties?.[a]?.const===void 0);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx("dl",{className:"space-y-2.5 text-sm leading-5",children:m.map(a=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-baseline gap-x-3",children:[e.jsx("dt",{className:"break-words text-muted-foreground",children:String(s?.properties?.[a]?.["x-table-label"]??(l.has(a)?a:he(a.replace(/_/g," "))))}),e.jsx("dd",{className:te("min-w-0 [overflow-wrap:anywhere]",l.has(a)&&"tabular-nums"),children:ge(r[a])})]},a))})]})}const L=":overview",S=":activity",k=":relationships";function Ue({active:t,children:s}){const[l,r]=_.useState(t);return _.useEffect(()=>{t&&r(!0)},[t]),!t&&!l?null:e.jsx(F,{value:L,forceMount:!0,hidden:!t,children:s})}const He={},We=()=>{};function Ye({namespace:t,entity:s,recordUrl:l,viewKey:r,onDeleted:m}){const a=me({strict:!1}),o=U(),c={slug:t.slug,organizationId:t.id},d=Ae(c),{data:x}=H(s.entity_type,c),p=d.data??[],u={type:s.entity_type,id:s.id,slug:s.slug,parentId:s.parent_id},h=J(p,u,"overview"),N=J(p,u,"tab"),i=ue(N,r),g=!r&&a.tab==="relationships",b=!r&&!g&&(h.length===0||a.tab==="activity"),v=!r&&!g&&!b,y=n=>`${l}${Ne(n)}`,j=n=>void o({to:".",search:n,replace:!0}),C={type:s.entity_type,entity:s.is_derived?s.slug:s.id},w=s.is_derived?e.jsx(Be,{entity:s,schema:x?.metadata_schema}):e.jsx(ze,{entity:s,entityTypeSlug:s.entity_type,orgContext:c,onDeleted:m}),T=s.is_derived?e.jsx(Fe,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:c}):e.jsx(Oe,{entityId:s.id,ownerSlug:t.slug}),P=e.jsxs(e.Fragment,{children:[d.isError&&e.jsx(B,{onRetry:()=>void d.refetch()}),h.map(n=>e.jsx("section",{className:"mb-4 min-w-0","data-testid":"view-card","data-view":n.key,children:e.jsx(K,{orgSlug:t.slug,viewKey:n.key,scope:C,params:He,onParamsChange:We,contentHash:n.content_hash,title:n.name,minHeight:160})},n.key))]});return r&&d.data===void 0?d.isError?e.jsx(B,{onRetry:()=>void d.refetch()}):null:!r&&!g&&a.tab!=="activity"&&d.data===void 0&&!d.isError?e.jsxs("div",{className:"mt-4 grid gap-6 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsx("aside",{className:"min-w-0 lg:pr-2",children:w}),e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading views…"})]}):i.kind==="missing"?e.jsx(Le,{viewKey:i.key,backTo:l,backLabel:`Back to ${s.name}`}):e.jsxs("div",{className:"mt-4 grid gap-6 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsx("aside",{className:"min-w-0 lg:pr-2",children:w}),e.jsxs(Te,{className:"min-w-0",value:i.kind==="tab"?i.view.key:g?k:b?S:L,onValueChange:n=>void o({to:n===L||n===S||n===k?l:y(n),search:n===k?{tab:"relationships"}:n===S?{tab:"activity"}:{}}),children:[e.jsxs(Pe,{className:"max-w-full justify-start overflow-x-auto",children:[h.length>0&&e.jsx(I,{value:L,children:h.length===1?h[0].name:"Overview"}),e.jsx(I,{value:S,children:"Activity"}),e.jsx(I,{value:k,children:"Relationships"}),N.map(n=>e.jsx(I,{value:n.key,"data-testid":`tab-${n.key}`,children:n.name},n.key))]}),h.length>0&&e.jsx(Ue,{active:v,children:P},`${t.id}/${s.entity_type}/${s.is_derived?s.slug:s.id}`),e.jsx(F,{value:k,children:T}),e.jsxs(F,{value:S,children:[d.isError&&e.jsx(B,{onRetry:()=>void d.refetch()}),e.jsx(Ce,{entity:s,organizationId:t.id,ownerSlug:t.slug})]}),i.kind==="tab"&&e.jsxs(F,{value:i.view.key,children:[e.jsx($e,{decls:i.view.params,params:Q(a),onParamsChange:n=>void o({to:".",search:n})}),e.jsx(K,{orgSlug:t.slug,viewKey:i.view.key,scope:C,params:Q(a),onParamsChange:j,contentHash:i.view.content_hash,title:i.view.name,minHeight:320})]})]})]})}function qe(t){return t?.trim()?t:void 0}function mt({namespace:t,path:s,entity:l,viewKey:r}){const m=U(),{data:a}=H(l.entity_type,{slug:t.slug}),o=qe(a?.icon),c=s.map(u=>({entity_type:u.entity_type,slug:u.slug})),d=`/${t.slug}/${Se(l.entity_type)}`,x=R(t.slug,c),p=s.length>1?R(t.slug,c.slice(0,-1)):d;return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 py-6 lg:px-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:e.jsx(E,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs(ke,{to:p,children:[e.jsx(Ee,{className:"mr-1 h-4 w-4"}),"Back"]})})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Re,{metadata:l.metadata,metadataSchema:a?.metadata_schema,name:l.name,typeIcon:o,className:"h-6 w-6"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:l.name})]})]}),e.jsx(Ye,{namespace:t,entity:l,recordUrl:x,viewKey:r,onDeleted:()=>{const u=s.slice(0,-1);u.length>0?m({to:R(t.slug,u)}):m({to:d})}})]})}export{mt as EntityPage};
|
|
2
|
+
//# sourceMappingURL=entity-page-Dc0LGr5U.js.map
|
package/dist/owletto/dist/assets/{entity-type-page-OznRag6A.js → entity-type-page-CwZxa0BR.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,M as $,k as W,ed as me,em as xe,eg as Q,bx as ae,r as x,ee as he,ef as pe,d5 as ge,d7 as fe,B as f,cy as V,d6 as je,y as C,bn as q,bo as P,bp as M,bq as I,br as R,I as T,a1 as ve,ep as Ne,e_ as ye,e$ as be,X as H,dv as ne,dj as re,Q as Se,a_ as le,f0 as ie,f1 as we,b7 as oe,f2 as Ce,eS as ke,bO as Ee,bP as Y,bS as _e,f3 as Re,by as Te,f4 as Oe,f5 as De,P as G}from"./index-_oPeVpL_.js";import{J as B}from"./json-diff-D_Ym3Uku.js";import{C as ce}from"./code-editor-V27Z4o3P.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(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{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!==Q),d=i.filter(m=>m.purpose===Q),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(J,{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(J,{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(J,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Le,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function J({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(""),[w,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[D,S]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),S(!1),_(null)},O=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),U=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const K=k.trim()||F(g);if(!K){_("Slug is required");return}l=(await u.mutateAsync({slug:K,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!w){_("Select a target entity type");return}const L=y==="source"?s:w,ue=y==="source"?w: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(V,{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=>S(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:w,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:U,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ve({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(V,{className:"h-3 w-3"})})]})]})}const Ue=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Be({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(V,{className:"h-3 w-3"})})]})]})}function Je({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:Ue.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(Se,{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(Ve,{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(Be,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function X({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 Z(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(""),[w,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)),Z(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)),Z(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),S=()=>{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(X,{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(we,{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(Je,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:S,className:"w-full",children:[e.jsx(V,{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(X,{value:h,onChange:D,error:w})]})}function He(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ke({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,w]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,D]=o.field("metadataSchema"),[S,A]=o.field("backingSql"),[_,u]=Y(i,n),[p,v]=Y(i,null),O=S.trim().length>0,F=l=>{h(l),!n&&!_&&w(He(l))},U=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:S.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),w(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:S,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:U,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Ze({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,w]=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){w(null);try{await N.mutateAsync(s.slug),a()}catch(S){w(S instanceof Error?S.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:G("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:G("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(Ke,{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(S=>e.jsx(qe,{entry:S},S.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),w(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{Ze as E};
|
|
2
|
-
//# sourceMappingURL=entity-type-page-
|
|
1
|
+
import{j as e,M as $,k as W,ed as me,em as xe,eg as Q,bx as ae,r as x,ee as he,ef as pe,d5 as ge,d7 as fe,B as f,cy as V,d6 as je,y as C,bn as q,bo as P,bp as M,bq as I,br as R,I as T,a1 as ve,ep as Ne,e_ as ye,e$ as be,X as H,dv as ne,dj as re,Q as Se,a_ as le,f0 as ie,f1 as we,b7 as oe,f2 as Ce,eS as ke,bO as Ee,bP as Y,bS as _e,f3 as Re,by as Te,f4 as Oe,f5 as De,P as G}from"./index-Cr5hwh-C.js";import{J as B}from"./json-diff-DBoag_OS.js";import{C as ce}from"./code-editor-DHeyRGZI.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(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{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!==Q),d=i.filter(m=>m.purpose===Q),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(J,{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(J,{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(J,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Le,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function J({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(""),[w,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[D,S]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),S(!1),_(null)},O=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),U=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const K=k.trim()||F(g);if(!K){_("Slug is required");return}l=(await u.mutateAsync({slug:K,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!w){_("Select a target entity type");return}const L=y==="source"?s:w,ue=y==="source"?w: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(V,{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=>S(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:w,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:U,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ve({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(V,{className:"h-3 w-3"})})]})]})}const Ue=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Be({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(V,{className:"h-3 w-3"})})]})]})}function Je({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:Ue.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(Se,{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(Ve,{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(Be,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function X({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 Z(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(""),[w,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)),Z(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)),Z(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),S=()=>{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(X,{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(we,{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(Je,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:S,className:"w-full",children:[e.jsx(V,{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(X,{value:h,onChange:D,error:w})]})}function He(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ke({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,w]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,D]=o.field("metadataSchema"),[S,A]=o.field("backingSql"),[_,u]=Y(i,n),[p,v]=Y(i,null),O=S.trim().length>0,F=l=>{h(l),!n&&!_&&w(He(l))},U=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:S.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),w(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:S,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:U,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Ze({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,w]=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){w(null);try{await N.mutateAsync(s.slug),a()}catch(S){w(S instanceof Error?S.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:G("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:G("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(Ke,{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(S=>e.jsx(qe,{entry:S},S.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),w(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{Ze as E};
|
|
2
|
+
//# sourceMappingURL=entity-type-page-CwZxa0BR.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as J,T as Z,r as D,fJ as q,fs as I,j as s,bZ as M,L as Q}from"./index-
|
|
2
|
-
//# sourceMappingURL=event-detail-
|
|
1
|
+
import{g as J,T as Z,r as D,fJ as q,fs as I,j as s,bZ as M,L as Q}from"./index-Cr5hwh-C.js";import{u as W,E as X}from"./events-feed-BtvhZF1f.js";import{b as Y,a as z,V as K,M as ee}from"./view-param-filters-CqLZQrnO.js";const se={},te="calc(100dvh - 120px)";function ie({owner:n,organizationId:o,eventId:c,viewKey:r,params:g,onParamsChange:d,onSelectView:p,dense:m=!1,fullBleed:k=!1}){const{isAuthenticated:y,isReady:E}=J(),{data:T,isLoading:w}=Z(),O=T?.some(t=>t.id===o&&t.is_member),i=n!=="me"&&o!==null&&E&&y&&!w&&O,a=W(i?{slug:n,organizationId:o}:null,c),[j,b]=D.useState(se),[P,L]=D.useState(null),u=q(a.views,r),e=i&&!a.isLoading&&!a.isError&&u.kind==="view"?u.view:null,v=e?`${I(n,e.key)}/${e.content_hash}/${e.eventId}`:null,f=e!==null&&P===v,V=M(n,c),F=n!=="me"&&(!E||y&&(w||a.isLoading)),H=e!==null&&!f&&!F,h=k&&H,U=(k||m)&&H,N=F?s.jsx("div",{role:"status",className:"py-8 text-sm text-muted-foreground",children:"Loading event view…"}):e&&!f?s.jsxs(s.Fragment,{children:[s.jsx(Y,{decls:e.params,params:g??j,onParamsChange:t=>d?d(e.key,t,{replace:!1}):b(t)}),s.jsx(z,{orgSlug:n,viewKey:e.key,scope:{event:e.eventId},params:g??j,onParamsChange:t=>d?d(e.key,t):b(t),onLoadError:()=>L(v),contentHash:e.content_hash,title:e.name,minHeight:m?240:320,fixedHeight:U?te:void 0},v)]}):void 0;return s.jsxs("div",{className:h?"w-full space-y-3":"mx-auto w-full max-w-3xl space-y-3",...h?{"data-testid":"event-view-fullbleed"}:{},children:[i&&a.isError&&s.jsx(K,{onRetry:a.refetch}),(i||n==="me"&&r)&&!a.isLoading&&!a.isError&&u.kind==="missing"&&s.jsx(ee,{viewKey:u.key,backTo:V,backLabel:"Back to the event"}),f&&s.jsxs("div",{role:"alert",className:"rounded-md border p-3 text-sm",children:[s.jsx("p",{children:"The custom view couldn’t load. The event content is shown below."}),s.jsx("button",{type:"button",className:"mt-2 underline",onClick:()=>L(null),children:"Retry custom view"})]}),s.jsx(X,{presentation:"detail",organizationId:o,ownerSlug:n,filters:{contentIds:[c],...n==="me"?{sortBy:"date",sortOrder:"desc"}:{}},dense:m,hideDetails:m,renderDetail:t=>{const x=N!=null&&(t==null||!!r),A=(i?a.views:[]).filter(l=>!x||l.key!==e?.key).map(l=>({key:l.key,name:l.name,href:M(n,c,l.key)})),S=l=>l.length?s.jsx("nav",{"aria-label":"Event views",className:"flex flex-wrap gap-3 text-sm",children:l.map(({key:$,name:C,href:B})=>s.jsx(Q,{to:B,className:"underline",onClick:p?G=>{G.preventDefault(),p(B)}:void 0,children:C},$))}):null,R=[...A],_=[...A];return i&&r&&t!=null&&_.unshift({key:":event",name:"Event details",href:V}),{content:x?N:t,nativeHeading:!x&&t!=null,headingAside:h?S(R):void 0,links:h?null:S(_)}}})]})}export{ie as E};
|
|
2
|
+
//# sourceMappingURL=event-detail-ve2d6Gbb.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,L as oe,dj as bt,dk as Ye,cd as _t,bw as wt,r as h,dl as Ze,dm as kt,V as Ct,H as St,di as Rt,aR as At,dn as Xe,b6 as et,dp as It,dq as Tt,cr as Et,aV as $t,P as Te,dr as tt,ds as Dt,dt as be,dc as Ce,B as $,du as ve,dv as ye,M as pe,dw as st,dx as ze,dy as nt,d5 as Pt,d7 as Ot,d6 as Ft,dz as Mt,dA as Lt,ce as rt,dB as Bt,dC as zt,m as Ht,u as Vt,k as at,bH as Ue,bZ as qe,Z as Ut,dD as qt,dE as Jt,dF as Kt,dG as it,dH as Qt,dI as Wt,a1 as Se,dJ as Gt,dK as Yt,bO as Zt,dL as Xt,bS as es,dM as ts,dd as ss,dN as ns,X as rs,bi as ot,dO as Ee,dP as $e,dQ as De,cO as as,S as is,aQ as os,cY as ls,g as ds,t as cs,cL as us,cM as ms,cR as ps,cS as xs,dR as hs,dS as fs,dT as gs,dU as vs,bK as ys,dV as js,dW as Fe,bc as Je,ai as Ns}from"./index-_oPeVpL_.js";import{c as bs}from"./conversations-table-DfZGICl7.js";import{a as lt,J as _s}from"./renderer-BL6VcwQH.js";import{u as ws}from"./clients-CpG676mg.js";function ks(s,t){const n=t.parentEntityType&&t.parentEntitySlug?[{entity_type:t.parentEntityType,slug:t.parentEntitySlug},{entity_type:t.entityType,slug:t.entitySlug}]:[{entity_type:t.entityType,slug:t.entitySlug}];return Ye(s,n)}function Cs({ownerSlug:s,entity:t,className:n}){const r=ks(s,t);return e.jsxs(oe,{to:r,className:`flex items-center gap-1 text-primary hover:underline group ${n??""}`,children:[e.jsx("span",{className:"font-medium",children:t.entityName}),e.jsx(bt,{className:"h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function dt(s){const t=Array.isArray(s?.records)?s.records:Array.isArray(s?.current)?s.current:[];return[s?.from_entity_id??s?.entity_id,s?.to_entity_id].map(n=>{const i=t.find(l=>l&&typeof l=="object"&&"id"in l&&l.id===n);return{id:String(n??"unknown"),name:typeof i?.name=="string"?i.name:`Record ${String(n??"unknown")}`}})}function ct(s,t){return t==="rejected"?"The proposed relationship change was rejected. Both records remain available.":t==="failed"?"The relationship change failed. Both records remain available.":t==="completed"?s==="link"?"The records were linked. Both records remain available.":"The relationship was removed. Both records remain available.":t==="approved"||t==="confirmed"?"The relationship change was approved. Both records remain available.":s==="link"?"If approved, these records will be linked. Both records remain available.":"If approved, this relationship will be removed. Both records remain available."}function mn(s){const t=dt(s.proposal);return{title:s.action==="link"?"Link records":"Unlink records",icon:"entity",impact:{level:"normal"},tone:"default",blocks:[...t.map((n,r)=>({type:"text",label:r===0?"From":"To",value:n.name})),{type:"text",label:"Relationship",value:String(s.proposal?.relationship_type??s.proposal?.relationship_type_slug??"Relationship")},{type:"text",value:ct(s.action,typeof s.status=="string"?s.status:void 0),muted:!0},...typeof s.reason=="string"&&s.reason?[{type:"text",label:"Why this needs approval",value:s.reason}]:[]],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",confirm:s.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 ut(s,t,n){return{queryKey:["event-view-match",s,t.key,t.content_hash,n],queryFn:async()=>{try{const i=(await _t("open_view",{key:t.key,scope:{event:n}},{slug:s})).scope?.event;if(!Number.isSafeInteger(i)||(i??0)<1)throw new Error("The view did not resolve its event subject");return i}catch(r){if(r instanceof wt&&(r.status===400||r.status===404))return null;throw r}},staleTime:6e4}}function pn(s,t){const n=lt(s??{slug:null,organizationId:null}),r=s?.slug??null,i=h.useMemo(()=>r?Ze(n.data??[]):[],[r,n.data]),l=kt({queries:i.map(a=>ut(r,a,t))});return r?{views:i.flatMap((a,u)=>{const N=l[u]?.data;return N?[{...a,eventId:N}]:[]}),isLoading:n.data===void 0?!n.isError:l.some(a=>a.isPending),isError:n.isError||l.some(a=>a.isError),refetch:()=>{n.refetch();for(const a of l)a.isError&&a.refetch()}}:{views:[],isLoading:!1,isError:!1,refetch:()=>{}}}async function Ss(s,t,n,r){const i=await Promise.all(n.map(l=>s.fetchQuery(ut(t,l,r))));return n.find((l,a)=>i[a])??null}async function Rs(s,t,n,r){const i=await Ct(`${St}/api/${encodeURIComponent(s)}/events/${t}/actions/${encodeURIComponent(n.action)}`,{method:"POST",timeoutMs:9e4,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n.value,interaction_id:r})});return await Rt(i,"Could not record interaction"),i.json()}function z(s){if(typeof s!="string")return;const t=s.trim();return t.length>0?t:void 0}function Me(s){return typeof s=="boolean"?s:void 0}function As(s,t,n){const r=(n??"").toLowerCase();return!!(r==="prepare_comment"||r==="verify_staged_comment"||r.includes("prepare_")||r.includes("verify_staged")||t?.prepared===!0||typeof t?.verified=="boolean"||z(t?.reason_preview)&&z(t?.message)||z(s?.body)&&(z(s?.post_url)||z(s?.activity_id)))}function Is(s,t,n){if(!As(s,t,n))return null;const r=(n??"").toLowerCase(),i=z(t?.body)??z(s?.body),l=z(t?.reason_preview)??z(s?.reason),a=z(t?.post_url)??z(s?.post_url)??(z(s?.activity_id)?`https://www.linkedin.com/feed/update/urn:li:activity:${z(s?.activity_id)}`:void 0),u=Me(t?.prepared),N=Me(t?.verified),j=Me(t?.banner_shown),b=z(t?.message),f=t?.match&&typeof t.match=="object"?t.match:null,m=z(f?.text_preview),v=z(f?.author);let S="generic";r==="verify_staged_comment"||r.includes("verify")||typeof N=="boolean"?S="verify":(r==="prepare_comment"||r.includes("prepare")||u===!0||i&&a)&&(S="prepare");const g=[];return u===!0&&g.push("Staged — not posted"),u===!1&&g.push("Not staged"),N===!0&&g.push("Verified posted"),N===!1&&g.push("Not verified as posted"),j===!0&&g.push("In-page banner"),j===!1&&g.push("No banner"),{kind:S,message:b,reason:l,body:i,postUrl:a,prepared:u,bannerShown:j,verified:N,matchPreview:m,matchAuthor:v,chips:g}}function we(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function Ts({template:s,data:t,onAction:n}){const[r,i]=h.useState(null),[l,a]=h.useState(!1),[u,N]=h.useState(null),[j,b]=h.useState(!1),f=h.useRef(!1),m=h.useRef(!0);h.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const v=async S=>{if(!(!n||f.current)){f.current=!0,a(!0),N(null),b(!1);try{const g=await n(S);if(!m.current)return;if(we(g)&&g.kind==="sdk"){const _=g.result;if(!we(_)||_.success!==!0){const I=we(_)&&we(_.error)?_.error.message:null;throw new Error(typeof I=="string"?I:"Could not update this event.")}if(_.return_truncated||!we(_.return_value))throw new Error("The update did not return a complete data object.");i(_.return_value),b(!0)}}catch(g){m.current&&N(g instanceof Error?g.message:"Could not update this event.")}finally{f.current=!1,m.current&&a(!1)}}};return e.jsxs("div",{className:"space-y-2",children:[l?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Updating…"}):null,j?e.jsx("p",{role:"status",className:"sr-only",children:"Updated"}):null,u?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[u," Previous data is still shown."]}):null,e.jsx("fieldset",{disabled:!n||l,"aria-busy":l,className:"min-w-0",children:e.jsx(_s,{template:{root:s.root},data:r??t,onAction:n?v:void 0,interactions:s.interactions})})]})}function mt(s){return{audit:s.semantic_type==="audit"&&s.origin_type==="tool_invocation",operation:s.interaction_type==="approval"||s.semantic_type==="operation",changeSet:s.semantic_type==="change_set"}}const Es={};function xe(s){return s.replace(/_/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}const $s={notification:"Notification",tool_invocation:"Action",deployment:"Deployment",config_change:"Config change",message:"Message",msg:"Note",summary:"Summary"};function Ds(s){return s.author_name?s.author_name:s.platform?xe(s.platform):s.origin_type?$s[s.origin_type]??xe(s.origin_type):null}function Ps(s){return s==null?"":typeof s=="string"?s:typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"?String(s):Array.isArray(s)?s.length===0?"":s.every(t=>typeof t!="object")?s.map(t=>String(t)).join(", "):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(s,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(s,null,2)})}const Le=1e5;function Ke({value:s}){const t=JSON.stringify(s,null,2)??"null",n=t.length>Le;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:n?t.slice(0,Le):t}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",Le.toLocaleString()," of"," ",t.length.toLocaleString()," characters."]})]})}function Os(s){return Object.entries(s).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:typeof t=="object"?Object.keys(t).length>0:!0).sort(([t],[n])=>t.localeCompare(n))}function Fs({breakdown:s}){if(!s)return null;const t=[{label:"Engagement",value:s.engagement,max:100},{label:"Criticality",value:s.criticality,max:100},{label:"Depth",value:s.depth,max:100},{label:"Authority",value:s.authority,max:100},{label:"Recency",value:s.recency,max:100},{label:"Quality",value:s.quality,max:100}];return e.jsx("div",{className:"space-y-2 text-sm",children:t.map(n=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-muted-foreground",children:n.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:`${n.value/n.max*100}%`}})}),e.jsx("span",{className:"w-8 text-right",children:n.value})]},n.label))})}function Ms({slug:s,value:t,isManual:n}){return e.jsxs(pe,{variant:"secondary",className:"text-xs",children:[s,": ",t,n&&e.jsx(tt,{className:"ml-1 h-2.5 w-2.5 fill-current"})]})}function Ls(s){if(s&&typeof s=="object"){const t=s;if(Array.isArray(t.values))return{values:t.values.map(n=>String(n)).filter(n=>n.length>0),isManual:t.is_manual===!0};if(t.value!==void 0&&t.value!==null)return{values:[String(t.value)],isManual:t.is_manual===!0};if(typeof t.values=="string"&&t.values.length>0)return{values:[t.values],isManual:t.is_manual===!0}}return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"?{values:[String(s)],isManual:!1}:{values:[],isManual:!1}}function pt(s,t){if(s)switch(s){case"pending":return"pending_approval";case"approved":return"confirmed";case"rejected":return"rejected";case"completed":return"completed";case"failed":return"failed";default:return s}return t||"pending_approval"}function Be(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function Qe(s){return s==null||s===""?"Not set":typeof s=="string"?s:JSON.stringify(s,null,2)}function Bs(s){return s.replace(/\s+[—-]\s+pending approval$/i,"")}function Re(s){return s.replace(/^\$/,"").replace(/[_-]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}function xt(s,t,n){return s?.kind==="agent_session"&&s.agent_id?s.client_id?`${s.agent_id} via ${s.client_id}`:s.agent_id:s?.kind==="user"?"a person":t==="agent"?"an agent":n?`Automation ${n}`:"an Automation"}function zs({ownerSlug:s,initiator:t,clientName:n,fallback:r}){const i=t?.client_id??n,{allOrgs:l,isAuthenticated:a}=at(),u=a&&l?.some(v=>v.slug===s),j=ws(void 0,{ownerSlug:s,enabled:!!(i&&u)}).data?.find(v=>v.id===i)?.title,b=t&&t.kind!=="user"?xt(t,void 0,t.automation_id===void 0?void 0:String(t.automation_id)):r,f="font-medium text-foreground",m=`${f} underline-offset-4 hover:underline`;return t?.kind==="automation"&&t.automation_id?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:s,automationId:String(t.automation_id)},search:{view:"definition",run_id:void 0},className:m,children:b}):t?.kind==="agent_session"&&t.agent_id?e.jsx(oe,{to:"/$owner/agents/$agentId",params:{owner:s,agentId:String(t.agent_id)},className:m,children:b}):i?e.jsxs(oe,{to:"/$owner/agents/connected/$clientId",params:{owner:s,clientId:i},className:`${m} inline-flex items-center gap-1 align-middle`,children:[e.jsx(ot,{name:j??n??i}),j??b]}):e.jsx("span",{className:f,children:b})}function Hs(s){const t=Object.keys(s.fields),n=t.map(Re).join(", ")||"field",r=t.length===1?"field":"fields";return`Update ${s.entityType?Re(s.entityType).toLowerCase():"entity"} ${r}: ${n}`}function Vs(s,t){const n=Be(t.fields);if(!n||Object.keys(n).length===0||t.action_key!=="entity_field_change"&&t.tool!=="entity_field_change")return null;const r=Be(t.current)??{},i=s;return{fields:n,current:r,reason:typeof t.reason=="string"?t.reason:void 0,automationId:t.automation_id!=null?String(t.automation_id):void 0,automationName:typeof t.automation_name=="string"?t.automation_name:void 0,automationAgentId:typeof t.automation_agent_id=="string"?t.automation_agent_id:void 0,entityType:typeof t.entity_type=="string"?t.entity_type:void 0,entityName:(typeof t.entity_name=="string"?t.entity_name:void 0)??i.entity_name??void 0,entitySlug:typeof t.entity_slug=="string"?t.entity_slug:void 0,parentSlug:typeof t.parent_slug=="string"?t.parent_slug:void 0,parentEntityType:typeof t.parent_entity_type=="string"?t.parent_entity_type:void 0,attribution:typeof t.attribution=="string"?t.attribution:void 0,initiator:t.initiator&&typeof t.initiator=="object"?t.initiator:void 0}}function Us(s){const t=s.entityType?Re(s.entityType).toLowerCase():"entity";return`${Re(s.operation)} ${t}`}function qs(s,t){if(t.action_key!=="entity_change"&&t.tool!=="entity_change")return null;const n=t.action;if(n!=="create"&&n!=="delete"&&n!=="link"&&n!=="unlink")return null;const r=s;return{operation:n,proposal:Be(t.proposal),reason:typeof t.reason=="string"?t.reason:void 0,automationId:t.automation_id!=null?String(t.automation_id):void 0,automationName:typeof t.automation_name=="string"?t.automation_name:void 0,automationAgentId:typeof t.automation_agent_id=="string"?t.automation_agent_id:void 0,entityType:typeof t.entity_type=="string"?t.entity_type:void 0,entityName:(typeof t.entity_name=="string"?t.entity_name:void 0)??r.entity_name??void 0,entitySlug:typeof t.entity_slug=="string"?t.entity_slug:void 0,parentSlug:typeof t.parent_slug=="string"?t.parent_slug:void 0,parentEntityType:typeof t.parent_entity_type=="string"?t.parent_entity_type:void 0,attribution:typeof t.attribution=="string"?t.attribution:void 0,proposerRationale:typeof t.proposer_rationale=="string"?t.proposer_rationale:void 0,initiator:t.initiator&&typeof t.initiator=="object"?t.initiator:void 0}}function Js(s,t){return!t.entityType||!t.entitySlug?null:Ye(s,t.parentEntityType&&t.parentSlug?[{entity_type:t.parentEntityType,slug:t.parentSlug},{entity_type:t.entityType,slug:t.entitySlug}]:[{entity_type:t.entityType,slug:t.entitySlug}])}function ht({ownerSlug:s,runId:t,details:n}){const i=it(n.automationId,void 0,void 0,{ownerSlug:s,includeVersions:!1}).data?.automation,l=xt(n.initiator,n.attribution,n.automationId),a=i?.automation_name??n.automationName??l;return e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Requested by"," ",n.automationId?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:s,automationId:n.automationId},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:a}):e.jsx("span",{className:"font-medium text-foreground",children:a}),t&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:" · "}),e.jsxs(oe,{to:"/$owner/events",params:{owner:s},search:{run_ids:String(t)},className:"font-medium text-foreground underline-offset-4 hover:underline",children:["Run #",t]})]})]})}function ft({ownerSlug:s,details:t}){const n=Js(s,t);return t.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:n?e.jsx(oe,{to:n,className:"underline-offset-4 hover:underline",children:t.entityName}):t.entityName})]}):null}function gt({label:s,before:t,after:n}){return e.jsxs("div",{className:"rounded-md border border-border/70 overflow-hidden",children:[e.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium",children:s}),e.jsxs("div",{className:"grid gap-px bg-border/70 sm:grid-cols-2",children:[e.jsxs("div",{className:"bg-background p-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Current"}),e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:Qe(t)})]}),e.jsxs("div",{className:"bg-background p-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Proposed"}),e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:Qe(n)})]})]})]})}function Ks({ownerSlug:s,runId:t,details:n}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ht,{ownerSlug:s,runId:t,details:n}),e.jsx(ft,{ownerSlug:s,details:n}),Object.entries(n.fields).map(([r,i])=>e.jsx(gt,{label:Re(r),before:n.current[r],after:i},r)),n.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:n.reason})]})]})}function Qs({ownerSlug:s,runId:t,details:n,status:r}){const{operation:i}=n,l=i==="link"||i==="unlink";return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ht,{ownerSlug:s,runId:t,details:n}),!l&&e.jsx(ft,{ownerSlug:s,details:n}),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:l?ct(i,r):i==="create"?"Create a new entity after approval.":"Delete this entity after approval."}),l&&e.jsxs("div",{className:"mt-2 space-y-1 text-sm",children:[dt(n.proposal).map((a,u)=>e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:u===0?"From: ":"To: "}),a.name]},a.id)),e.jsxs("div",{className:"text-muted-foreground",children:["Relationship:"," ",String(n.proposal?.relationship_type??n.proposal?.relationship_type_slug??"Relationship")]})]})]}),!l&&n.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(n.proposal,null,2)})]}),n.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:n.attribution==="agent"?"The agent's reasoning":"The Automation's reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:n.proposerRationale})]}),n.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:n.reason})]})]})}function Ws({summary:s}){return e.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/30 p-3 text-sm",children:[s.chips.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.chips.map(t=>e.jsx(pe,{variant:"outline",className:"text-[10px] font-normal",children:t},t))}),s.message&&e.jsx("p",{className:"leading-relaxed text-foreground",children:s.message}),s.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:s.reason})]}),s.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:s.kind==="verify"?"Expected comment":"Draft"}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed",children:s.body})]}),s.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",s.matchAuthor?` · ${s.matchAuthor}`:""]}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed text-muted-foreground",children:s.matchPreview})]}),s.postUrl&&e.jsxs("a",{href:s.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 Gs({ownerSlug:s,content:t,batchReview:n}){const r=t.metadata||{},i=t.run_id??void 0,l=Vs(t,r),a=qs(t,r),u=(l?Hs(l):a?Us(a):void 0)||r.operation_name||r.action_name||(t.title?Bs(t.title):void 0)||"Action",N=r.connection_name,j=r.operation_key||r.action_key||null,b=t.interaction_input_schema||r.input_schema||null,f=h.useMemo(()=>t.interaction_input||r.action_input||r.operation_input||Es,[t.interaction_input,r.action_input,r.operation_input]),m=t.interaction_output||r.action_output||void 0,v=Is(f,m??null,j),S=t.interaction_error||r.error_message||void 0,g=pt(t.interaction_status,r.status),_=r.reviewed_by_name||r.reviewed_by_id||void 0,I=r.reject_reason||void 0,H=r.initiator,q=Gt({slug:s}),x=Yt({slug:s}),y=Zt(t.id,Xt(b,f),b),{values:V,setValues:k}=y,[w,J]=h.useState(null),[c,T]=h.useState(!1),[M,P]=h.useState(""),E=g==="pending_approval"&&w?w:g,F=E==="pending_approval",W=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(et,{className:"h-4 w-4 text-yellow-500"}),e.jsx("span",{className:"font-medium",children:u}),N&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["on ",N]}),E==="confirmed"&&e.jsx(pe,{variant:"outline",className:"text-blue-700 border-blue-300 bg-blue-50 dark:bg-blue-950/30 text-[10px]",children:"Approved"}),E==="completed"&&e.jsx(pe,{variant:"outline",className:"text-green-700 border-green-300 bg-green-50 dark:bg-green-950/30 text-[10px]",children:"Completed"}),E==="failed"&&e.jsx(pe,{variant:"outline",className:"text-red-700 border-red-300 bg-red-50 dark:bg-red-950/30 text-[10px]",children:"Failed"}),E==="rejected"&&e.jsx(pe,{variant:"outline",className:"text-muted-foreground text-[10px]",children:"Rejected"})]}),!l&&!a&&(t.author_name||_)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground",children:[t.author_name&&e.jsxs("span",{children:["Requested by"," ",e.jsx(zs,{ownerSlug:s,initiator:H,clientName:t.author_name,fallback:t.author_name})]}),t.author_name&&_&&e.jsx("span",{children:"·"}),_&&e.jsxs("span",{children:[E==="rejected"?"Rejected":"Approved"," by"," ",e.jsx("span",{className:"font-medium text-foreground",children:_})]})]}),l&&e.jsx(Ks,{ownerSlug:s,runId:i,details:l}),!l&&a&&e.jsx(Qs,{ownerSlug:s,runId:i,details:a,status:E}),E==="rejected"&&I&&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:"})," ",I]}),v&&e.jsx(Ws,{summary:v}),(F?y.revision:b)&&(F||Object.keys(f).length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:v?"Full input":"Input"}),F?e.jsxs(e.Fragment,{children:[e.jsx(es,{visible:y.hasConflict,onReload:y.reset}),e.jsx(ts,{schema:y.revision,values:V,onValuesChange:k,fieldIdPrefix:`action-${t.id}-`},`action-${t.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(f,null,2)})]}):e.jsx("pre",{className:"text-xs bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(f,null,2)})]}),E==="completed"&&m&&Object.keys(m).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(ze,{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(m,null,2)})]}),E==="completed"&&m&&Object.keys(m).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(m,null,2)})]}),E==="failed"&&S&&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(st,{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:S})]}),F&&!w&&W&&e.jsxs("div",{className:"pt-1 text-xs text-muted-foreground",children:["Review this proposal with the other changes in its Automation run.",n]}),F&&i&&!w&&!W&&e.jsx("div",{className:"flex items-center gap-2 pt-1",children:c?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"Reason (optional)",value:M,onChange:se=>P(se.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>x.mutate({run_id:i,reason:M||void 0},{onSuccess:()=>{J("rejected")}}),disabled:x.isPending,children:[x.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Confirm Reject"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{T(!1),P("")},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>q.mutate({run_id:i,input:ns(V)},{onSuccess:()=>{J("confirmed")}}),disabled:!y.canSubmit||q.isPending||x.isPending,children:[q.isPending?e.jsx(Se,{size:"sm",className:"mr-1"}):e.jsx(ss,{className:"h-3 w-3 mr-1"}),"Confirm"]}),e.jsxs($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>T(!0),disabled:q.isPending||x.isPending,children:[e.jsx(rs,{className:"h-3 w-3 mr-1"}),"Reject"]})]})})]})}function Ys({content:s,ownerSlug:t}){const n=s.metadata||{},r=n.kind,i=s.run_id??null,l=typeof n.automation_id=="number"?n.automation_id:null,N=it(l!=null?String(l):void 0,void 0,void 0,{includeVersions:!1,ownerSlug:t}).data?.automation?.automation_name??(l!=null?`Automation ${l}`:"An Automation"),j=Qt({slug:t}),b=Wt({slug:t}),[f,m]=h.useState(!1),[v,S]=h.useState(""),[g,_]=h.useState(null);if(r==="automation_batch_reject"){const c=n.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"}),c&&e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:c}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Ask the agent to revise its proposals with this feedback."})]})}const I=Array.isArray(n.changes)?n.changes:[],H=typeof n.created_count=="number"?n.created_count:I.filter(c=>c.kind==="created").length,q=typeof n.updated_count=="number"?n.updated_count:I.filter(c=>c.kind==="updated").length,x=typeof n.denied_count=="number"?n.denied_count:I.filter(c=>c.kind==="denied").length,y=I.filter(c=>c.kind==="denied"),V=I.filter(c=>c.kind==="updated"&&Object.keys(c.applied||{}).length>0),k=typeof n.pending_proposal_count=="number"?n.pending_proposal_count:null,w=k==null||k>0,J=w?"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:[J==="proposed"?"Proposed":"Applied"," ",H," ","new + ",q," updated",x>0&&e.jsxs(e.Fragment,{children:[" + ",x," denied"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l!=null?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:String(l)},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:N}):e.jsx("span",{className:"font-medium text-foreground",children:N}),i!=null&&e.jsxs("span",{children:[" · run #",i]}),k!=null&&k>0&&e.jsxs("span",{children:[" · ",k," pending"]})]})]}),V.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:V.map(c=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:c.name}),Object.entries(c.applied).map(([T,M])=>e.jsx(gt,{label:T,before:M.old,after:M.new},T))]},c.entityId))}),y.length>0&&e.jsx("div",{className:"mt-3 space-y-1.5",children:y.map(c=>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:[c.name," — not written"]}),c.denied&&e.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[c.denied.reason,e.jsxs("span",{className:"ml-1 opacity-70",children:["(refused by"," ",c.denied.source==="rule"?"a write rule":"org policy",")"]})]})]},`denied-${c.entityId}-${c.name}`))}),i!=null&&g==null&&w&&e.jsx("div",{className:"mt-3 border-t border-border/70 pt-3",children:f?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:c=>S(c.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>b.mutate({run_id:i,reason:v||void 0},{onSuccess:()=>_("rejected")}),disabled:b.isPending,children:[b.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Reject all"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{m(!1),S("")},children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>j.mutate({run_id:i},{onSuccess:()=>_("approved")}),disabled:j.isPending||b.isPending,children:[j.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Approve all proposals"]}),e.jsx($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>m(!0),disabled:j.isPending||b.isPending,children:"Reject with feedback"})]})}),g==="approved"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals approved."}),g==="rejected"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Proposals rejected — ask the agent to revise them."}),i!=null&&g==null&&!w&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals reviewed."})]})}function ke({presentation:s="summary",renderDetail:t,onFiltersChange:n,ownerSlug:r,content:i,isReply:l,showParentContext:a,connectorDefinitions:u,hideOriginator:N=!1,hideRunAction:j=!1,hideAttribution:b=!1,hideDetails:f=!1}){const[m,v]=h.useState(null),S=Ht(),g=s==="detail",_=Vt(),{currentOwner:I,allOrgs:H,isAuthenticated:q}=at(),x=r??I,y=x==="me"?null:x,V=h.useCallback(async p=>{if(!y){Ue.error("Open this event inside a workspace to interact with it.");return}const D=await Rs(y,Number(i.id),p,crypto.randomUUID());return"event_id"in D&&Ue.success("Recorded"),D},[i.id,y]),k=i.payload_data??{},{audit:w,operation:J,changeSet:c}=mt(i),T=w&&(k.request!==void 0||k.request_status==="too_large"),M=w&&Array.isArray(k.sdk_call_trace)&&k.sdk_call_trace.length>0,P=x?qe(x,Number(i.id)):null,E=!g&&q?(H??[]).find(p=>p.slug===y):void 0,F=E?{slug:E.slug,organizationId:E.id}:null,W=lt(F??{slug:null,organizationId:null}),se=F?.slug??null,he=h.useMemo(()=>se&&!w?Ze(W.data??[],i.semantic_type):[],[se,w,W.data,i.semantic_type]),le=Ut(),je=!!(!(J||c)&&F&&he.length>0),K=!g&&!!P,X=qt(_?.item?.href.split(/[?#]/)[0]??""),ne=X?.owner===x&&X?.eventId===Number(i.id),ee=(p,D,O)=>{_?_.open({href:p,title:D,...O==null?{}:{runId:O}}):S({to:p})},de=(p,D)=>{if(!y)return null;const O=`/${y}/events?run_ids=${p}`;return _?.item?.href===O?null:e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n?n({runIds:[p]}):ee(O,"Run activity",p),title:n?"Filter by this run":"Open run activity",children:[e.jsx(Kt,{className:"h-3.5 w-3.5"}),D]})},ce=i.run_id!=null&&(n||!(_&&y&&i.automation_id!=null))?de(i.run_id,n?"Run":"Open run"):null,U=Jt(i),ue=i.automation_id,Ne=_&&y&&U!=null&&ue!=null?()=>_.open({href:`/${y}/automations/${ue}?run_id=${U}`,title:`${i.automation_name??`Automation ${ue}`} · Run #${U}`,runId:U}):void 0,me=()=>{if(je&&F&&y){const p=Number(i.id);Ss(le,F.slug,he,p).catch(()=>null).then(D=>ee(qe(y,p,D?.key),i.title??"Event"));return}P&&ee(P,i.title??"Event")},re=p=>{const D=p.target;if(!(D instanceof Element))return!1;const O=D.closest('a,button,input,select,textarea,[role="button"],[role="radio"]');return O!==null&&O!==p.currentTarget},Z=p=>{re(p)||me()},ae=p=>{p.key!=="Enter"&&p.key!==" "||re(p)||(p.preventDefault(),me())},fe=i.metadata?.source_run_id,Q=g&&y?c?e.jsx(Ys,{content:i,ownerSlug:y}):J?e.jsx(Gs,{ownerSlug:y,content:i,batchReview:typeof fe=="number"?de(fe,"Review run"):null}):void 0:void 0,ie=g&&t?t(Q):{content:Q,nativeHeading:Q!=null};return e.jsx("div",{className:Te(l?"border-l-2 border-l-muted pl-4":"",K&&"cursor-pointer rounded-lg p-3 transition-colors hover:bg-accent/40",K&&ne&&"bg-accent ring-1 ring-inset ring-primary/20"),...K?{role:"button","aria-current":ne?"true":void 0,tabIndex:0,onClick:Z,onKeyDown:ae}:{},children:e.jsx(en,{primaryContent:ie.content,nativeHeading:ie.nativeHeading,detailLinks:ie.links,headingAside:ie.headingAside,hideDetails:f,onFiltersChange:n,presentation:s,content:i,ownerSlug:x??void 0,showParentContext:a,connectorDefinitions:u,onRenderedAction:y?V:void 0,runAction:j?null:ce,hideOriginator:N,hideAttribution:b,runId:U??i.run_id??null,onRunSelect:Ne,auditDetails:g&&(T||M)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"request",label:"Request",available:T},{key:"calls",label:"SDK calls",available:M}].map(p=>p.available?e.jsxs($,{variant:"outline",size:"sm","aria-expanded":m===p.key,onClick:()=>v(D=>D===p.key?null:p.key),children:[m===p.key?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(ye,{className:"h-3.5 w-3.5"}),p.label]},p.key):null)}),m==="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(Ke,{value:k.request})),m==="calls"&&e.jsx(Ke,{value:k.sdk_call_trace})]})})})}function Zs(s,t){const n=s.payload_data??{},r=s.metadata??{};if(t.audit&&typeof n.success=="boolean")return n.success?"completed":"failed";if(t.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(t.operation)return pt(s.interaction_status,typeof r.status=="string"?r.status:void 0)}function Xs(s){return s==="pending_approval"?"Needs approval":s==="confirmed"?"Approved":s?xe(s):null}function en({presentation:s,primaryContent:t,nativeHeading:n=!1,detailLinks:r,headingAside:i,onFiltersChange:l,content:a,ownerSlug:u,showParentContext:N,connectorDefinitions:j,onRenderedAction:b,runAction:f,auditDetails:m,hideOriginator:v=!1,hideAttribution:S=!1,runId:g,onRunSelect:_,hideDetails:I=!1}){const[H,q]=h.useState(!1),x=a.metadata??{},y=typeof a.score=="number"&&Number.isFinite(a.score)?Math.round(a.score):"-",V=a.payload_type||"text",k=a.text_content||"",w=s==="summary",J=s==null&&(V==="text"||V==="markdown")&&k.length>500,c=J&&!H?`${k.slice(0,500)}...`:k,T=a.payload_data??{},M=mt(a),{audit:P,operation:E,changeSet:F}=M,W=Zs(a,M),se=Xs(W),he=w&&P&&typeof T.tool_name=="string"?xe(T.tool_name):a.title,le=P&&T.error&&typeof T.error=="object"?T.error.message:void 0,_e=(typeof le=="string"?le:void 0)??a.interaction_error??(typeof x.error_message=="string"?x.error_message:void 0),je=_e||(P?"":k),[K,X]=h.useState(s!=="summary"&&P&&t==null&&r==null),ne=P?T.duration_ms:x.duration_ms,ee=typeof ne=="number"&&Number.isFinite(ne)&&ne>=0?ne:null,de=P&&typeof T.sdk_call_count=="number"&&Number.isSafeInteger(T.sdk_call_count)&&T.sdk_call_count>=0?T.sdk_call_count:null,ce=x.thumbnail_url||x.thumbnail,U=x.media_url,ue=w?[]:Os(x),Ne=Object.entries(a.classifications||{}).flatMap(([o,d])=>{const R=Ls(d);return R.values.map(A=>({slug:o,value:A,isManual:R.isManual}))}),me=(()=>{const o=a.platform||(typeof x.platform=="string"?x.platform:null),d=a.connection_id!=null?a.connection_id:x.source_connection_id!=null?Number(x.source_connection_id):null;return{...a,platform:o,connection_id:d!=null&&Number.isFinite(d)?d:null}})(),re=(()=>{const o=a.source_url??x.browser_url;if(typeof o!="string"||!URL.canParse(o))return null;const d=new URL(o);return d.protocol==="https:"||d.protocol==="http:"?d:null})(),Z=a.occurred_at?new Date(a.occurred_at):null,ae=me.platform?At(me.platform,j??[]):null,fe=P?Xe:E?et:F?It:a.semantic_type==="notification"?Tt:Et,Q=P?"SDK call":xe(a.semantic_type||a.origin_type||"Event"),ie=e.jsx($t,{plain:!0,name:ae?.name??re?.hostname??Q,icon:ae?.icon,faviconDomain:ae?.faviconDomain??re?.hostname,fallback:e.jsx(fe,{className:"h-4 w-4"}),className:"h-5 w-5 rounded-sm text-xs"}),p=ue.length>0?e.jsx("dl",{className:"grid gap-x-3 gap-y-2 text-sm sm:grid-cols-[minmax(140px,180px)_1fr]",children:ue.map(([o,d])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-muted-foreground",children:xe(o)}),e.jsx("dd",{className:"min-w-0 break-words font-mono text-xs sm:text-sm",children:Ps(d)})]},o))}):null,D=w?je?e.jsx("p",{className:Te("line-clamp-2 text-sm whitespace-pre-wrap",_e&&"text-destructive"),children:je.slice(0,320)}):null:e.jsxs(e.Fragment,{children:[a.rating&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:[1,2,3,4,5].map(o=>e.jsx(tt,{className:`h-4 w-4 ${o<=Number(a.rating)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},o))}),ce&&e.jsx("a",{href:U||a.source_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block mb-2",children:e.jsx("img",{src:ce,alt:"",className:`rounded-md object-cover ${V==="media"?"max-h-96 w-full":"max-h-48"}`,loading:"lazy"})}),(()=>{switch(V){case"markdown":if(c)return e.jsx("div",{className:"max-w-none text-sm space-y-2",children:e.jsx(Dt,{text:c})});break;case"json_template":{const o=a.payload_template;if(o?.root)return e.jsx(Ts,{template:o,data:a.payload_data||{},onAction:t?void 0:b},`${u}:${a.id}`);if(c)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:c});break}case"media":return e.jsxs("div",{className:"space-y-3",children:[!ce&&U&&e.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate block",children:U}),c&&e.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:c})]});case"empty":return e.jsxs("div",{className:"space-y-3",children:[m,p??(m?null:e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No content"}))]});default:if(c)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:c});break}return e.jsxs("div",{className:"space-y-3",children:[U&&!ce&&e.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground truncate block",children:U}),p]})})()]}),O=t!=null||s==="detail"&&P,ge=i!==void 0,Ae=O||r!=null;return h.useEffect(()=>{if(!ge||!K)return;const o=d=>{d.key==="Escape"&&(d.preventDefault(),X(!1))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[ge,K]),e.jsxs(e.Fragment,{children:[N&&a.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:a.parent_context.author_name}),e.jsx("div",{className:"text-muted-foreground line-clamp-2",children:a.parent_context.text_content})]}),e.jsxs("div",{className:Te("flex gap-3",s==="detail"&&"mb-5",ge&&"relative"),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:ie}),e.jsxs("div",{className:"min-w-0 flex-1",children:[s==="detail"&&(()=>{const o={semanticTypes:[a.semantic_type],...typeof a.automation_id=="number"?{producedByAutomationId:a.automation_id}:{},...typeof a.run_id=="number"?{runIds:[a.run_id]}:{}},d={semantic_types:a.semantic_type,...typeof a.automation_id=="number"?{produced_by:String(a.automation_id)}:{},...typeof a.run_id=="number"?{run_ids:String(a.run_id)}:{}};return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[a.semantic_type?l?e.jsx("button",{type:"button",className:"hover:underline",title:`Show all ${Q} events`,onClick:()=>l(o),children:Q}):u?e.jsx(oe,{to:"/$owner/events",params:{owner:u},search:d,className:"hover:underline",title:`Show all ${Q} events`,children:Q}):e.jsx("span",{children:Q}):e.jsx("span",{children:Q}),Z&&e.jsx("time",{dateTime:Z.toISOString(),children:be(Z)})]})})(),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[he&&!n&&e.jsx("h4",{className:Te("min-w-0 font-medium",s==="detail"?"text-xl leading-snug":"line-clamp-2 text-sm"),children:he}),s!=="detail"&&Z&&e.jsx("time",{dateTime:Z.toISOString(),title:be(Z),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Ce(Z,"HH:mm")}),ge&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pt-0.5",children:[i,Ae&&e.jsxs($,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-muted-foreground hover:text-foreground","aria-expanded":K,onClick:()=>X(o=>!o),children:["Details",K?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(ye,{className:"h-3.5 w-3.5"})]})]})]}),w&&e.jsx("div",{className:"mt-1 text-muted-foreground",children:D}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[se&&!n&&e.jsxs(pe,{variant:W==="failed"?"destructive":"secondary",className:"gap-1 text-xs",children:[W==="failed"?e.jsx(st,{className:"h-3 w-3"}):W==="completed"?e.jsx(ze,{className:"h-3 w-3"}):null,se]}),de!=null&&e.jsxs("span",{children:[de," SDK ",de===1?"call":"calls"]}),ee!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"h-3 w-3"}),ee<1e3?`${Math.round(ee)}ms`:`${Number((ee/1e3).toFixed(2))}s`]}),f,y==="-"||w&&(P||E||F)?null:a.score_breakdown?e.jsxs(Pt,{children:[e.jsx(Ot,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx("span",{className:"font-medium",children:y})})}),e.jsx(Ft,{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(Fs,{breakdown:a.score_breakdown})]})})]}):null,re&&e.jsxs(Mt,{children:[e.jsx(Lt,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1",asChild:!0,children:e.jsxs("a",{href:re.href,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:w?"sr-only":void 0,children:"View original"})]})})}),e.jsx(Bt,{children:"View original"})]})]}),u&&!S&&e.jsx(zt,{owner:u,source:me,connectorDefinitions:j,onFiltersChange:l,variant:"chips",className:"mt-2 text-xs",hideOriginator:v,runId:g,onRunSelect:_}),(a.author_name||!u)&&!(s==="detail"&&E)&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:a.author_name||Ds(a)})]}),ge&&K&&Ae&&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:[r,O&&D]})]}),!w&&typeof le=="string"&&e.jsx("p",{className:"mb-2 text-sm whitespace-pre-wrap text-destructive",children:le}),t,!w&&!O&&D,(O||r!=null)&&i===void 0&&!(I&&t!=null)&&e.jsxs("details",{className:"mt-5 border-t pt-3",open:K,onToggle:o=>X(o.currentTarget.open),children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Details"}),K&&e.jsxs("div",{className:"mt-3 space-y-3",children:[r,O&&D]})]}),J&&e.jsx($,{variant:"link",size:"sm",className:"px-0 h-6 mt-1",onClick:()=>q(!H),children:H?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3 w-3 mr-1"})," Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3 w-3 mr-1"})," Show more"]})}),Ne.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:Ne.map(o=>e.jsx(Ms,{slug:o.slug,value:o.value||"",isManual:o.isManual},o.slug))})]})}function tn({toolName:s,count:t,totalDurationMs:n,totalSdkCalls:r,newestAt:i,oldestAt:l,expanded:a,onToggle:u,children:N}){return e.jsx("div",{children:e.jsxs(Ee,{open:a,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(Xe,{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($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:u,children:[e.jsxs("span",{className:"min-w-0 truncate font-medium text-foreground",children:[xe(s)," × ",t]}),a?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(vt,{newestAt:i,oldestAt:l})]}),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(pe,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(ze,{className:"h-3 w-3"}),"Completed"]}),r!=null&&e.jsxs("span",{children:[r," SDK ",r===1?"call":"calls"]}),n!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"h-3 w-3"}),sn(n)]})]})]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:N})]})})}function sn(s){return s<1e3?`${Math.round(s)}ms`:`${Number((s/1e3).toFixed(2))}s`}function vt({newestAt:s,oldestAt:t}){const n=We(s),r=We(t);return n!=null&&r!=null&&n.getTime()-r.getTime()>nn&&r?e.jsxs("time",{dateTime:n.toISOString(),title:`${be(r)} – ${be(n)}`,className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:[Ce(r,"HH:mm"),"–",Ce(n,"HH:mm")]}):n?e.jsx("time",{dateTime:n.toISOString(),title:be(n),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Ce(n,"HH:mm")}):null}const nn=300*1e3;function We(s){if(s==null||s==="")return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t}function rn({organizationId:s,clientId:t,activityId:n,activityKind:r,callCount:i,newestAt:l,oldestAt:a,expanded:u,onToggle:N,children:j}){const{data:b=[]}=as({limit:100,organizationId:s??null}),f=b.find(S=>S.activityId===n&&(t==null||S.clientId===t))??null,m=f?bs(f):r==="session"?"MCP session":"Conversation",v=f?.clientName??null;return e.jsx("div",{children:e.jsxs(Ee,{open:u,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(ot,{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($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:N,children:[e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:m}),u?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(vt,{newestAt:l,oldestAt:a})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[`${i} ${i===1?"call":"calls"}`,v?` · ${v}`:null]})]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:j})]})})}function an({onIntersect:s,enabled:t,rootMargin:n="400px"}){const r=h.useRef(null),i=h.useRef(s);return i.current=s,h.useEffect(()=>{const l=r.current;if(!l||!t)return;const a=new IntersectionObserver(u=>{u[0]?.isIntersecting&&i.current()},{rootMargin:n});return a.observe(l),()=>a.disconnect()},[t,n]),r}function Ge(s){if(s==null||s==="")return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:Ce(t,"d MMMM yyyy")}function on({items:s,isLoading:t,emptyState:n,dense:r,hasNextPage:i,isFetching:l,isFetchingNextPage:a,onLoadMore:u,autoLoadMore:N=!0,groupByDate:j=!0}){const b=an({onIntersect:u,enabled:N&&i&&!l});return t&&s.length===0?e.jsx("div",{className:"space-y-4",children:["s1","s2","s3"].map(f=>e.jsx(is,{className:"h-32 rounded-lg"},f))}):e.jsxs("div",{className:r?"":"pt-1",children:[s.length===0?n!==void 0?n:e.jsx(os,{icon:ls,title:"Nothing here yet",description:"No events match this view."}):s.map((f,m)=>{const v=Ge(f.occurredAt),S=m>0?Ge(s[m-1].occurredAt):null;return e.jsxs(h.Fragment,{children:[j&&v&&v!==S&&e.jsx("p",{className:"px-3 pb-2 pt-4 text-xs text-muted-foreground",children:v}),e.jsx("div",{className:"mb-1",children:f.content})]},f.key)}),e.jsx("div",{ref:b,className:"h-1"}),a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(Se,{size:"xl",className:"text-muted-foreground"})}):i&&e.jsx($,{size:"sm",variant:"outline",disabled:l,onClick:u,children:"Load more"})]})}function xn({presentation:s="summary",renderDetail:t,onFiltersChange:n,hideDetails:r=!1,organizationId:i,ownerSlug:l,entityId:a,filters:u,showEntityLinks:N=!1,hideOriginator:j=!1,emptyState:b,dense:f=!1,foldConsecutiveCalls:m=!1,groupByConversation:v=!1,groupByRun:S=!1,onRunSelect:g,runs:_,hideRunAction:I=!1,hideAttribution:H=!1}){const{isAuthenticated:q,isReady:x}=ds(),{isMember:y,isLoading:V}=cs(),k=l==="me",w=!k&&x&&q&&y,J=!k&&x&&(!q||!V&&!y),{data:c=[]}=us(x&&w?i:null),{data:T=[]}=ms(J?l:null),M=w?c:T,P=ps(x&&w?i:null,a,u,l),E=xs(J?l:null,a,u),F=J?E:P,{data:W,isLoading:se,error:he,fetchNextPage:le,hasNextPage:_e,isFetchingNextPage:je}=F,K=h.useMemo(()=>W?.pages.flatMap(o=>o.content)??[],[W]),X=h.useMemo(()=>{const o=hs(K,{foldRunSatellites:!S}),d=o.map(L=>L.head),R=new Map(o.map(L=>[L.head.id,L])),A=fs(d,{groupByRun:S});return Array.from(A.entries()).map(([L,Y])=>{const B=Y.root||Y.replies[0],G=B?R.get(B.id):void 0;return{rootId:L,group:Y,history:G?.history??[],runId:G?.runId??null}})},[K,S]),[ne,ee]=h.useState(new Set),[de,ce]=h.useState(new Set),[U,ue]=h.useState(new Set),[Ne,me]=h.useState(new Set),[re,Z]=h.useState(new Set),ae=(o,d)=>o(R=>{const A=new Set(R);return A.has(d)?A.delete(d):A.add(d),A}),fe=(o,d)=>d.some(R=>o.has(R)),Q=(o,d)=>o(R=>{const A=new Set(R),L=d.some(Y=>A.has(Y));for(const Y of d)L?A.delete(Y):A.add(Y);return A}),ie=m?gs(X):X.map(o=>({kind:"single",node:o})),p=v?vs(ie):ie,D=!k&&(!x||q&&V||w&&F.isPending);if(he)return e.jsx(ys,{label:"events"});const O=o=>{if(o.kind==="fold"){const{fold:C}=o,Ve=C.nodes.map(Pe=>Pe.rootId),Nt=fe(de,Ve);return[{key:C.key,occurredAt:C.newestAt,content:e.jsx(tn,{toolName:C.toolName,count:C.nodes.length,totalDurationMs:C.totalDurationMs,totalSdkCalls:C.totalSdkCalls,newestAt:C.newestAt,oldestAt:C.oldestAt,expanded:Nt,onToggle:()=>Q(ce,Ve),children:C.nodes.map(Pe=>{const Oe=Pe.group.root;return Oe?e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:Oe,renderDetail:t,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H,hideDetails:r},Oe.id):null})})}]}const{rootId:d,group:R,history:A,runId:L}=o.node,Y=R.replies.length>0,B=ne.has(d),G=re.has(d),He=Ne.has(d),yt=R.replies.filter(C=>C.depth<=3),Ie=R.replies.filter(C=>C.depth>3),jt=!R.root&&R.replies.length>0,te=R.root||R.replies[0];return te?[{key:d,occurredAt:te.occurred_at,content:e.jsxs(e.Fragment,{children:[N&&l&&te.entity_name&&te.entity_type&&te.entity_slug&&e.jsx("div",{className:"mb-2",children:e.jsx(Cs,{ownerSlug:l,entity:{entityName:te.entity_name,entityType:te.entity_type,entitySlug:te.entity_slug}})}),e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:te,renderDetail:t,showParentContext:jt&&!!te.parent_context,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H,hideDetails:r}),A.length>0&&e.jsxs(Ee,{open:He,children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-1 h-7 gap-1 text-xs text-muted-foreground",onClick:()=>ae(me,d),children:[e.jsx(Ns,{className:"h-3.5 w-3.5"}),He?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",L!=null?`run #${L} `:"","history"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),L!=null?`Run #${L} · ${A.length===1?"1 earlier step":`${A.length} earlier steps`}`:A.length===1?"1 earlier state":`${A.length} earlier states`]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:A.map(C=>e.jsxs("div",{children:[e.jsx("time",{dateTime:new Date(C.occurred_at).toISOString(),title:be(C.occurred_at),className:"mb-1 block text-xs text-muted-foreground",children:Je(C.occurred_at)}),e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H})]},C.id))})]}),Y&&e.jsxs(Ee,{open:B,children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-2 ml-6 gap-1",onClick:()=>ae(ee,d),children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),B?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",R.replies.length," replies"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),"Show ",R.replies.length," replies"]})]})}),e.jsxs(De,{className:"space-y-2 mt-2",children:[yt.map(C=>e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,isReply:!0,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H},C.id)),Ie.length>0&&e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"ghost",size:"sm",className:"ml-12",onClick:()=>ae(Z,d),children:G?e.jsxs(e.Fragment,{children:["Hide ",Ie.length," nested replies"]}):e.jsxs(e.Fragment,{children:["Show ",Ie.length," nested replies"]})}),G&&Ie.map(C=>e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,isReply:!0,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H},C.id))]})]})]})]})}]:[]},ge=o=>{const d=o.nodes.length;return{key:o.key,occurredAt:o.newestAt,content:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[g?e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1 text-xs font-medium",onClick:()=>g(o.runId),title:`Open run #${o.runId} conversation`,children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),"Run #",o.runId]}):e.jsxs("span",{className:"inline-flex h-7 items-center gap-1 px-1 text-xs font-medium",children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),"Run #",o.runId]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.status!=null?`· ${xe(o.status)} · `:"· ",d===1?"1 event":`${d} events`,o.newestAt!=null?` · ${Je(o.newestAt)}`:""]})]}),e.jsx("div",{className:"mt-2 space-y-2 border-l-2 border-l-muted pl-4",children:o.nodes.flatMap(R=>O({kind:"single",node:R}).map(A=>e.jsx(h.Fragment,{children:A.content},A.key)))})]})}},Ae=o=>{const{block:d}=o,R=d.entries.flatMap(B=>B.kind==="fold"?B.fold.nodes.map(G=>G.rootId):[B.node.rootId]),A=fe(U,R),L=d.entries.flatMap(B=>O(B).map(G=>({key:G.key,content:G.content})));if(L.length===0)return[];const Y=d.entries.reduce((B,G)=>B+(G.kind==="fold"?G.fold.nodes.length:1),0);return[{key:d.key,occurredAt:d.newestAt,content:e.jsx(rn,{organizationId:i,clientId:d.clientId,activityId:d.activityId,activityKind:d.activityKind,callCount:Y,newestAt:d.newestAt,oldestAt:d.oldestAt,expanded:A,onToggle:()=>Q(ue,R),children:L.map(B=>e.jsx(h.Fragment,{children:B.content},B.key))})}]};return e.jsx(on,{groupByDate:s==="summary",dense:f,isLoading:se||D,emptyState:b,hasNextPage:!!_e,isFetching:F.isFetching,isFetchingNextPage:je,onLoadMore:()=>void le(),items:S?js(X,_).map(o=>"nodes"in o?ge(o):O({kind:"single",node:o})[0]).filter(o=>o!=null):p.flatMap(o=>o.kind==="context"?Ae(o):O(o))})}export{xn as E,on as a,en as b,mn as c,pn as u};
|
|
2
|
-
//# sourceMappingURL=events-feed-
|
|
1
|
+
import{j as e,L as oe,dj as bt,dk as Ye,cd as _t,bw as wt,r as h,dl as Ze,dm as kt,V as Ct,H as St,di as Rt,aR as At,dn as Xe,b6 as et,dp as It,dq as Tt,cr as Et,aV as $t,P as Te,dr as tt,ds as Dt,dt as be,dc as Ce,B as $,du as ve,dv as ye,M as pe,dw as st,dx as ze,dy as nt,d5 as Pt,d7 as Ot,d6 as Ft,dz as Mt,dA as Lt,ce as rt,dB as Bt,dC as zt,m as Ht,u as Vt,k as at,bH as Ue,bZ as qe,Z as Ut,dD as qt,dE as Jt,dF as Kt,dG as it,dH as Qt,dI as Wt,a1 as Se,dJ as Gt,dK as Yt,bO as Zt,dL as Xt,bS as es,dM as ts,dd as ss,dN as ns,X as rs,bi as ot,dO as Ee,dP as $e,dQ as De,cO as as,S as is,aQ as os,cY as ls,g as ds,t as cs,cL as us,cM as ms,cR as ps,cS as xs,dR as hs,dS as fs,dT as gs,dU as vs,bK as ys,dV as js,dW as Fe,bc as Je,ai as Ns}from"./index-Cr5hwh-C.js";import{c as bs}from"./conversations-table-BdXoZAfc.js";import{a as lt,J as _s}from"./renderer-mEDnVW0O.js";import{u as ws}from"./clients-D3Zbjxin.js";function ks(s,t){const n=t.parentEntityType&&t.parentEntitySlug?[{entity_type:t.parentEntityType,slug:t.parentEntitySlug},{entity_type:t.entityType,slug:t.entitySlug}]:[{entity_type:t.entityType,slug:t.entitySlug}];return Ye(s,n)}function Cs({ownerSlug:s,entity:t,className:n}){const r=ks(s,t);return e.jsxs(oe,{to:r,className:`flex items-center gap-1 text-primary hover:underline group ${n??""}`,children:[e.jsx("span",{className:"font-medium",children:t.entityName}),e.jsx(bt,{className:"h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function dt(s){const t=Array.isArray(s?.records)?s.records:Array.isArray(s?.current)?s.current:[];return[s?.from_entity_id??s?.entity_id,s?.to_entity_id].map(n=>{const i=t.find(l=>l&&typeof l=="object"&&"id"in l&&l.id===n);return{id:String(n??"unknown"),name:typeof i?.name=="string"?i.name:`Record ${String(n??"unknown")}`}})}function ct(s,t){return t==="rejected"?"The proposed relationship change was rejected. Both records remain available.":t==="failed"?"The relationship change failed. Both records remain available.":t==="completed"?s==="link"?"The records were linked. Both records remain available.":"The relationship was removed. Both records remain available.":t==="approved"||t==="confirmed"?"The relationship change was approved. Both records remain available.":s==="link"?"If approved, these records will be linked. Both records remain available.":"If approved, this relationship will be removed. Both records remain available."}function mn(s){const t=dt(s.proposal);return{title:s.action==="link"?"Link records":"Unlink records",icon:"entity",impact:{level:"normal"},tone:"default",blocks:[...t.map((n,r)=>({type:"text",label:r===0?"From":"To",value:n.name})),{type:"text",label:"Relationship",value:String(s.proposal?.relationship_type??s.proposal?.relationship_type_slug??"Relationship")},{type:"text",value:ct(s.action,typeof s.status=="string"?s.status:void 0),muted:!0},...typeof s.reason=="string"&&s.reason?[{type:"text",label:"Why this needs approval",value:s.reason}]:[]],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",confirm:s.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 ut(s,t,n){return{queryKey:["event-view-match",s,t.key,t.content_hash,n],queryFn:async()=>{try{const i=(await _t("open_view",{key:t.key,scope:{event:n}},{slug:s})).scope?.event;if(!Number.isSafeInteger(i)||(i??0)<1)throw new Error("The view did not resolve its event subject");return i}catch(r){if(r instanceof wt&&(r.status===400||r.status===404))return null;throw r}},staleTime:6e4}}function pn(s,t){const n=lt(s??{slug:null,organizationId:null}),r=s?.slug??null,i=h.useMemo(()=>r?Ze(n.data??[]):[],[r,n.data]),l=kt({queries:i.map(a=>ut(r,a,t))});return r?{views:i.flatMap((a,u)=>{const N=l[u]?.data;return N?[{...a,eventId:N}]:[]}),isLoading:n.data===void 0?!n.isError:l.some(a=>a.isPending),isError:n.isError||l.some(a=>a.isError),refetch:()=>{n.refetch();for(const a of l)a.isError&&a.refetch()}}:{views:[],isLoading:!1,isError:!1,refetch:()=>{}}}async function Ss(s,t,n,r){const i=await Promise.all(n.map(l=>s.fetchQuery(ut(t,l,r))));return n.find((l,a)=>i[a])??null}async function Rs(s,t,n,r){const i=await Ct(`${St}/api/${encodeURIComponent(s)}/events/${t}/actions/${encodeURIComponent(n.action)}`,{method:"POST",timeoutMs:9e4,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n.value,interaction_id:r})});return await Rt(i,"Could not record interaction"),i.json()}function z(s){if(typeof s!="string")return;const t=s.trim();return t.length>0?t:void 0}function Me(s){return typeof s=="boolean"?s:void 0}function As(s,t,n){const r=(n??"").toLowerCase();return!!(r==="prepare_comment"||r==="verify_staged_comment"||r.includes("prepare_")||r.includes("verify_staged")||t?.prepared===!0||typeof t?.verified=="boolean"||z(t?.reason_preview)&&z(t?.message)||z(s?.body)&&(z(s?.post_url)||z(s?.activity_id)))}function Is(s,t,n){if(!As(s,t,n))return null;const r=(n??"").toLowerCase(),i=z(t?.body)??z(s?.body),l=z(t?.reason_preview)??z(s?.reason),a=z(t?.post_url)??z(s?.post_url)??(z(s?.activity_id)?`https://www.linkedin.com/feed/update/urn:li:activity:${z(s?.activity_id)}`:void 0),u=Me(t?.prepared),N=Me(t?.verified),j=Me(t?.banner_shown),b=z(t?.message),f=t?.match&&typeof t.match=="object"?t.match:null,m=z(f?.text_preview),v=z(f?.author);let S="generic";r==="verify_staged_comment"||r.includes("verify")||typeof N=="boolean"?S="verify":(r==="prepare_comment"||r.includes("prepare")||u===!0||i&&a)&&(S="prepare");const g=[];return u===!0&&g.push("Staged — not posted"),u===!1&&g.push("Not staged"),N===!0&&g.push("Verified posted"),N===!1&&g.push("Not verified as posted"),j===!0&&g.push("In-page banner"),j===!1&&g.push("No banner"),{kind:S,message:b,reason:l,body:i,postUrl:a,prepared:u,bannerShown:j,verified:N,matchPreview:m,matchAuthor:v,chips:g}}function we(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function Ts({template:s,data:t,onAction:n}){const[r,i]=h.useState(null),[l,a]=h.useState(!1),[u,N]=h.useState(null),[j,b]=h.useState(!1),f=h.useRef(!1),m=h.useRef(!0);h.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const v=async S=>{if(!(!n||f.current)){f.current=!0,a(!0),N(null),b(!1);try{const g=await n(S);if(!m.current)return;if(we(g)&&g.kind==="sdk"){const _=g.result;if(!we(_)||_.success!==!0){const I=we(_)&&we(_.error)?_.error.message:null;throw new Error(typeof I=="string"?I:"Could not update this event.")}if(_.return_truncated||!we(_.return_value))throw new Error("The update did not return a complete data object.");i(_.return_value),b(!0)}}catch(g){m.current&&N(g instanceof Error?g.message:"Could not update this event.")}finally{f.current=!1,m.current&&a(!1)}}};return e.jsxs("div",{className:"space-y-2",children:[l?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Updating…"}):null,j?e.jsx("p",{role:"status",className:"sr-only",children:"Updated"}):null,u?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[u," Previous data is still shown."]}):null,e.jsx("fieldset",{disabled:!n||l,"aria-busy":l,className:"min-w-0",children:e.jsx(_s,{template:{root:s.root},data:r??t,onAction:n?v:void 0,interactions:s.interactions})})]})}function mt(s){return{audit:s.semantic_type==="audit"&&s.origin_type==="tool_invocation",operation:s.interaction_type==="approval"||s.semantic_type==="operation",changeSet:s.semantic_type==="change_set"}}const Es={};function xe(s){return s.replace(/_/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}const $s={notification:"Notification",tool_invocation:"Action",deployment:"Deployment",config_change:"Config change",message:"Message",msg:"Note",summary:"Summary"};function Ds(s){return s.author_name?s.author_name:s.platform?xe(s.platform):s.origin_type?$s[s.origin_type]??xe(s.origin_type):null}function Ps(s){return s==null?"":typeof s=="string"?s:typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"?String(s):Array.isArray(s)?s.length===0?"":s.every(t=>typeof t!="object")?s.map(t=>String(t)).join(", "):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(s,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(s,null,2)})}const Le=1e5;function Ke({value:s}){const t=JSON.stringify(s,null,2)??"null",n=t.length>Le;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:n?t.slice(0,Le):t}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",Le.toLocaleString()," of"," ",t.length.toLocaleString()," characters."]})]})}function Os(s){return Object.entries(s).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:typeof t=="object"?Object.keys(t).length>0:!0).sort(([t],[n])=>t.localeCompare(n))}function Fs({breakdown:s}){if(!s)return null;const t=[{label:"Engagement",value:s.engagement,max:100},{label:"Criticality",value:s.criticality,max:100},{label:"Depth",value:s.depth,max:100},{label:"Authority",value:s.authority,max:100},{label:"Recency",value:s.recency,max:100},{label:"Quality",value:s.quality,max:100}];return e.jsx("div",{className:"space-y-2 text-sm",children:t.map(n=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-muted-foreground",children:n.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:`${n.value/n.max*100}%`}})}),e.jsx("span",{className:"w-8 text-right",children:n.value})]},n.label))})}function Ms({slug:s,value:t,isManual:n}){return e.jsxs(pe,{variant:"secondary",className:"text-xs",children:[s,": ",t,n&&e.jsx(tt,{className:"ml-1 h-2.5 w-2.5 fill-current"})]})}function Ls(s){if(s&&typeof s=="object"){const t=s;if(Array.isArray(t.values))return{values:t.values.map(n=>String(n)).filter(n=>n.length>0),isManual:t.is_manual===!0};if(t.value!==void 0&&t.value!==null)return{values:[String(t.value)],isManual:t.is_manual===!0};if(typeof t.values=="string"&&t.values.length>0)return{values:[t.values],isManual:t.is_manual===!0}}return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"?{values:[String(s)],isManual:!1}:{values:[],isManual:!1}}function pt(s,t){if(s)switch(s){case"pending":return"pending_approval";case"approved":return"confirmed";case"rejected":return"rejected";case"completed":return"completed";case"failed":return"failed";default:return s}return t||"pending_approval"}function Be(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function Qe(s){return s==null||s===""?"Not set":typeof s=="string"?s:JSON.stringify(s,null,2)}function Bs(s){return s.replace(/\s+[—-]\s+pending approval$/i,"")}function Re(s){return s.replace(/^\$/,"").replace(/[_-]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}function xt(s,t,n){return s?.kind==="agent_session"&&s.agent_id?s.client_id?`${s.agent_id} via ${s.client_id}`:s.agent_id:s?.kind==="user"?"a person":t==="agent"?"an agent":n?`Automation ${n}`:"an Automation"}function zs({ownerSlug:s,initiator:t,clientName:n,fallback:r}){const i=t?.client_id??n,{allOrgs:l,isAuthenticated:a}=at(),u=a&&l?.some(v=>v.slug===s),j=ws(void 0,{ownerSlug:s,enabled:!!(i&&u)}).data?.find(v=>v.id===i)?.title,b=t&&t.kind!=="user"?xt(t,void 0,t.automation_id===void 0?void 0:String(t.automation_id)):r,f="font-medium text-foreground",m=`${f} underline-offset-4 hover:underline`;return t?.kind==="automation"&&t.automation_id?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:s,automationId:String(t.automation_id)},search:{view:"definition",run_id:void 0},className:m,children:b}):t?.kind==="agent_session"&&t.agent_id?e.jsx(oe,{to:"/$owner/agents/$agentId",params:{owner:s,agentId:String(t.agent_id)},className:m,children:b}):i?e.jsxs(oe,{to:"/$owner/agents/connected/$clientId",params:{owner:s,clientId:i},className:`${m} inline-flex items-center gap-1 align-middle`,children:[e.jsx(ot,{name:j??n??i}),j??b]}):e.jsx("span",{className:f,children:b})}function Hs(s){const t=Object.keys(s.fields),n=t.map(Re).join(", ")||"field",r=t.length===1?"field":"fields";return`Update ${s.entityType?Re(s.entityType).toLowerCase():"entity"} ${r}: ${n}`}function Vs(s,t){const n=Be(t.fields);if(!n||Object.keys(n).length===0||t.action_key!=="entity_field_change"&&t.tool!=="entity_field_change")return null;const r=Be(t.current)??{},i=s;return{fields:n,current:r,reason:typeof t.reason=="string"?t.reason:void 0,automationId:t.automation_id!=null?String(t.automation_id):void 0,automationName:typeof t.automation_name=="string"?t.automation_name:void 0,automationAgentId:typeof t.automation_agent_id=="string"?t.automation_agent_id:void 0,entityType:typeof t.entity_type=="string"?t.entity_type:void 0,entityName:(typeof t.entity_name=="string"?t.entity_name:void 0)??i.entity_name??void 0,entitySlug:typeof t.entity_slug=="string"?t.entity_slug:void 0,parentSlug:typeof t.parent_slug=="string"?t.parent_slug:void 0,parentEntityType:typeof t.parent_entity_type=="string"?t.parent_entity_type:void 0,attribution:typeof t.attribution=="string"?t.attribution:void 0,initiator:t.initiator&&typeof t.initiator=="object"?t.initiator:void 0}}function Us(s){const t=s.entityType?Re(s.entityType).toLowerCase():"entity";return`${Re(s.operation)} ${t}`}function qs(s,t){if(t.action_key!=="entity_change"&&t.tool!=="entity_change")return null;const n=t.action;if(n!=="create"&&n!=="delete"&&n!=="link"&&n!=="unlink")return null;const r=s;return{operation:n,proposal:Be(t.proposal),reason:typeof t.reason=="string"?t.reason:void 0,automationId:t.automation_id!=null?String(t.automation_id):void 0,automationName:typeof t.automation_name=="string"?t.automation_name:void 0,automationAgentId:typeof t.automation_agent_id=="string"?t.automation_agent_id:void 0,entityType:typeof t.entity_type=="string"?t.entity_type:void 0,entityName:(typeof t.entity_name=="string"?t.entity_name:void 0)??r.entity_name??void 0,entitySlug:typeof t.entity_slug=="string"?t.entity_slug:void 0,parentSlug:typeof t.parent_slug=="string"?t.parent_slug:void 0,parentEntityType:typeof t.parent_entity_type=="string"?t.parent_entity_type:void 0,attribution:typeof t.attribution=="string"?t.attribution:void 0,proposerRationale:typeof t.proposer_rationale=="string"?t.proposer_rationale:void 0,initiator:t.initiator&&typeof t.initiator=="object"?t.initiator:void 0}}function Js(s,t){return!t.entityType||!t.entitySlug?null:Ye(s,t.parentEntityType&&t.parentSlug?[{entity_type:t.parentEntityType,slug:t.parentSlug},{entity_type:t.entityType,slug:t.entitySlug}]:[{entity_type:t.entityType,slug:t.entitySlug}])}function ht({ownerSlug:s,runId:t,details:n}){const i=it(n.automationId,void 0,void 0,{ownerSlug:s,includeVersions:!1}).data?.automation,l=xt(n.initiator,n.attribution,n.automationId),a=i?.automation_name??n.automationName??l;return e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Requested by"," ",n.automationId?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:s,automationId:n.automationId},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:a}):e.jsx("span",{className:"font-medium text-foreground",children:a}),t&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:" · "}),e.jsxs(oe,{to:"/$owner/events",params:{owner:s},search:{run_ids:String(t)},className:"font-medium text-foreground underline-offset-4 hover:underline",children:["Run #",t]})]})]})}function ft({ownerSlug:s,details:t}){const n=Js(s,t);return t.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:n?e.jsx(oe,{to:n,className:"underline-offset-4 hover:underline",children:t.entityName}):t.entityName})]}):null}function gt({label:s,before:t,after:n}){return e.jsxs("div",{className:"rounded-md border border-border/70 overflow-hidden",children:[e.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium",children:s}),e.jsxs("div",{className:"grid gap-px bg-border/70 sm:grid-cols-2",children:[e.jsxs("div",{className:"bg-background p-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Current"}),e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:Qe(t)})]}),e.jsxs("div",{className:"bg-background p-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Proposed"}),e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:Qe(n)})]})]})]})}function Ks({ownerSlug:s,runId:t,details:n}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ht,{ownerSlug:s,runId:t,details:n}),e.jsx(ft,{ownerSlug:s,details:n}),Object.entries(n.fields).map(([r,i])=>e.jsx(gt,{label:Re(r),before:n.current[r],after:i},r)),n.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:n.reason})]})]})}function Qs({ownerSlug:s,runId:t,details:n,status:r}){const{operation:i}=n,l=i==="link"||i==="unlink";return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ht,{ownerSlug:s,runId:t,details:n}),!l&&e.jsx(ft,{ownerSlug:s,details:n}),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:l?ct(i,r):i==="create"?"Create a new entity after approval.":"Delete this entity after approval."}),l&&e.jsxs("div",{className:"mt-2 space-y-1 text-sm",children:[dt(n.proposal).map((a,u)=>e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:u===0?"From: ":"To: "}),a.name]},a.id)),e.jsxs("div",{className:"text-muted-foreground",children:["Relationship:"," ",String(n.proposal?.relationship_type??n.proposal?.relationship_type_slug??"Relationship")]})]})]}),!l&&n.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(n.proposal,null,2)})]}),n.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:n.attribution==="agent"?"The agent's reasoning":"The Automation's reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:n.proposerRationale})]}),n.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:n.reason})]})]})}function Ws({summary:s}){return e.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/30 p-3 text-sm",children:[s.chips.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.chips.map(t=>e.jsx(pe,{variant:"outline",className:"text-[10px] font-normal",children:t},t))}),s.message&&e.jsx("p",{className:"leading-relaxed text-foreground",children:s.message}),s.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:s.reason})]}),s.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:s.kind==="verify"?"Expected comment":"Draft"}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed",children:s.body})]}),s.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",s.matchAuthor?` · ${s.matchAuthor}`:""]}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed text-muted-foreground",children:s.matchPreview})]}),s.postUrl&&e.jsxs("a",{href:s.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 Gs({ownerSlug:s,content:t,batchReview:n}){const r=t.metadata||{},i=t.run_id??void 0,l=Vs(t,r),a=qs(t,r),u=(l?Hs(l):a?Us(a):void 0)||r.operation_name||r.action_name||(t.title?Bs(t.title):void 0)||"Action",N=r.connection_name,j=r.operation_key||r.action_key||null,b=t.interaction_input_schema||r.input_schema||null,f=h.useMemo(()=>t.interaction_input||r.action_input||r.operation_input||Es,[t.interaction_input,r.action_input,r.operation_input]),m=t.interaction_output||r.action_output||void 0,v=Is(f,m??null,j),S=t.interaction_error||r.error_message||void 0,g=pt(t.interaction_status,r.status),_=r.reviewed_by_name||r.reviewed_by_id||void 0,I=r.reject_reason||void 0,H=r.initiator,q=Gt({slug:s}),x=Yt({slug:s}),y=Zt(t.id,Xt(b,f),b),{values:V,setValues:k}=y,[w,J]=h.useState(null),[c,T]=h.useState(!1),[M,P]=h.useState(""),E=g==="pending_approval"&&w?w:g,F=E==="pending_approval",W=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(et,{className:"h-4 w-4 text-yellow-500"}),e.jsx("span",{className:"font-medium",children:u}),N&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["on ",N]}),E==="confirmed"&&e.jsx(pe,{variant:"outline",className:"text-blue-700 border-blue-300 bg-blue-50 dark:bg-blue-950/30 text-[10px]",children:"Approved"}),E==="completed"&&e.jsx(pe,{variant:"outline",className:"text-green-700 border-green-300 bg-green-50 dark:bg-green-950/30 text-[10px]",children:"Completed"}),E==="failed"&&e.jsx(pe,{variant:"outline",className:"text-red-700 border-red-300 bg-red-50 dark:bg-red-950/30 text-[10px]",children:"Failed"}),E==="rejected"&&e.jsx(pe,{variant:"outline",className:"text-muted-foreground text-[10px]",children:"Rejected"})]}),!l&&!a&&(t.author_name||_)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground",children:[t.author_name&&e.jsxs("span",{children:["Requested by"," ",e.jsx(zs,{ownerSlug:s,initiator:H,clientName:t.author_name,fallback:t.author_name})]}),t.author_name&&_&&e.jsx("span",{children:"·"}),_&&e.jsxs("span",{children:[E==="rejected"?"Rejected":"Approved"," by"," ",e.jsx("span",{className:"font-medium text-foreground",children:_})]})]}),l&&e.jsx(Ks,{ownerSlug:s,runId:i,details:l}),!l&&a&&e.jsx(Qs,{ownerSlug:s,runId:i,details:a,status:E}),E==="rejected"&&I&&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:"})," ",I]}),v&&e.jsx(Ws,{summary:v}),(F?y.revision:b)&&(F||Object.keys(f).length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:v?"Full input":"Input"}),F?e.jsxs(e.Fragment,{children:[e.jsx(es,{visible:y.hasConflict,onReload:y.reset}),e.jsx(ts,{schema:y.revision,values:V,onValuesChange:k,fieldIdPrefix:`action-${t.id}-`},`action-${t.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(f,null,2)})]}):e.jsx("pre",{className:"text-xs bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(f,null,2)})]}),E==="completed"&&m&&Object.keys(m).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(ze,{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(m,null,2)})]}),E==="completed"&&m&&Object.keys(m).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(m,null,2)})]}),E==="failed"&&S&&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(st,{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:S})]}),F&&!w&&W&&e.jsxs("div",{className:"pt-1 text-xs text-muted-foreground",children:["Review this proposal with the other changes in its Automation run.",n]}),F&&i&&!w&&!W&&e.jsx("div",{className:"flex items-center gap-2 pt-1",children:c?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"Reason (optional)",value:M,onChange:se=>P(se.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>x.mutate({run_id:i,reason:M||void 0},{onSuccess:()=>{J("rejected")}}),disabled:x.isPending,children:[x.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Confirm Reject"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{T(!1),P("")},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>q.mutate({run_id:i,input:ns(V)},{onSuccess:()=>{J("confirmed")}}),disabled:!y.canSubmit||q.isPending||x.isPending,children:[q.isPending?e.jsx(Se,{size:"sm",className:"mr-1"}):e.jsx(ss,{className:"h-3 w-3 mr-1"}),"Confirm"]}),e.jsxs($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>T(!0),disabled:q.isPending||x.isPending,children:[e.jsx(rs,{className:"h-3 w-3 mr-1"}),"Reject"]})]})})]})}function Ys({content:s,ownerSlug:t}){const n=s.metadata||{},r=n.kind,i=s.run_id??null,l=typeof n.automation_id=="number"?n.automation_id:null,N=it(l!=null?String(l):void 0,void 0,void 0,{includeVersions:!1,ownerSlug:t}).data?.automation?.automation_name??(l!=null?`Automation ${l}`:"An Automation"),j=Qt({slug:t}),b=Wt({slug:t}),[f,m]=h.useState(!1),[v,S]=h.useState(""),[g,_]=h.useState(null);if(r==="automation_batch_reject"){const c=n.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"}),c&&e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:c}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Ask the agent to revise its proposals with this feedback."})]})}const I=Array.isArray(n.changes)?n.changes:[],H=typeof n.created_count=="number"?n.created_count:I.filter(c=>c.kind==="created").length,q=typeof n.updated_count=="number"?n.updated_count:I.filter(c=>c.kind==="updated").length,x=typeof n.denied_count=="number"?n.denied_count:I.filter(c=>c.kind==="denied").length,y=I.filter(c=>c.kind==="denied"),V=I.filter(c=>c.kind==="updated"&&Object.keys(c.applied||{}).length>0),k=typeof n.pending_proposal_count=="number"?n.pending_proposal_count:null,w=k==null||k>0,J=w?"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:[J==="proposed"?"Proposed":"Applied"," ",H," ","new + ",q," updated",x>0&&e.jsxs(e.Fragment,{children:[" + ",x," denied"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l!=null?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:String(l)},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:N}):e.jsx("span",{className:"font-medium text-foreground",children:N}),i!=null&&e.jsxs("span",{children:[" · run #",i]}),k!=null&&k>0&&e.jsxs("span",{children:[" · ",k," pending"]})]})]}),V.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:V.map(c=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:c.name}),Object.entries(c.applied).map(([T,M])=>e.jsx(gt,{label:T,before:M.old,after:M.new},T))]},c.entityId))}),y.length>0&&e.jsx("div",{className:"mt-3 space-y-1.5",children:y.map(c=>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:[c.name," — not written"]}),c.denied&&e.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[c.denied.reason,e.jsxs("span",{className:"ml-1 opacity-70",children:["(refused by"," ",c.denied.source==="rule"?"a write rule":"org policy",")"]})]})]},`denied-${c.entityId}-${c.name}`))}),i!=null&&g==null&&w&&e.jsx("div",{className:"mt-3 border-t border-border/70 pt-3",children:f?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:c=>S(c.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>b.mutate({run_id:i,reason:v||void 0},{onSuccess:()=>_("rejected")}),disabled:b.isPending,children:[b.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Reject all"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{m(!1),S("")},children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>j.mutate({run_id:i},{onSuccess:()=>_("approved")}),disabled:j.isPending||b.isPending,children:[j.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Approve all proposals"]}),e.jsx($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>m(!0),disabled:j.isPending||b.isPending,children:"Reject with feedback"})]})}),g==="approved"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals approved."}),g==="rejected"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Proposals rejected — ask the agent to revise them."}),i!=null&&g==null&&!w&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals reviewed."})]})}function ke({presentation:s="summary",renderDetail:t,onFiltersChange:n,ownerSlug:r,content:i,isReply:l,showParentContext:a,connectorDefinitions:u,hideOriginator:N=!1,hideRunAction:j=!1,hideAttribution:b=!1,hideDetails:f=!1}){const[m,v]=h.useState(null),S=Ht(),g=s==="detail",_=Vt(),{currentOwner:I,allOrgs:H,isAuthenticated:q}=at(),x=r??I,y=x==="me"?null:x,V=h.useCallback(async p=>{if(!y){Ue.error("Open this event inside a workspace to interact with it.");return}const D=await Rs(y,Number(i.id),p,crypto.randomUUID());return"event_id"in D&&Ue.success("Recorded"),D},[i.id,y]),k=i.payload_data??{},{audit:w,operation:J,changeSet:c}=mt(i),T=w&&(k.request!==void 0||k.request_status==="too_large"),M=w&&Array.isArray(k.sdk_call_trace)&&k.sdk_call_trace.length>0,P=x?qe(x,Number(i.id)):null,E=!g&&q?(H??[]).find(p=>p.slug===y):void 0,F=E?{slug:E.slug,organizationId:E.id}:null,W=lt(F??{slug:null,organizationId:null}),se=F?.slug??null,he=h.useMemo(()=>se&&!w?Ze(W.data??[],i.semantic_type):[],[se,w,W.data,i.semantic_type]),le=Ut(),je=!!(!(J||c)&&F&&he.length>0),K=!g&&!!P,X=qt(_?.item?.href.split(/[?#]/)[0]??""),ne=X?.owner===x&&X?.eventId===Number(i.id),ee=(p,D,O)=>{_?_.open({href:p,title:D,...O==null?{}:{runId:O}}):S({to:p})},de=(p,D)=>{if(!y)return null;const O=`/${y}/events?run_ids=${p}`;return _?.item?.href===O?null:e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n?n({runIds:[p]}):ee(O,"Run activity",p),title:n?"Filter by this run":"Open run activity",children:[e.jsx(Kt,{className:"h-3.5 w-3.5"}),D]})},ce=i.run_id!=null&&(n||!(_&&y&&i.automation_id!=null))?de(i.run_id,n?"Run":"Open run"):null,U=Jt(i),ue=i.automation_id,Ne=_&&y&&U!=null&&ue!=null?()=>_.open({href:`/${y}/automations/${ue}?run_id=${U}`,title:`${i.automation_name??`Automation ${ue}`} · Run #${U}`,runId:U}):void 0,me=()=>{if(je&&F&&y){const p=Number(i.id);Ss(le,F.slug,he,p).catch(()=>null).then(D=>ee(qe(y,p,D?.key),i.title??"Event"));return}P&&ee(P,i.title??"Event")},re=p=>{const D=p.target;if(!(D instanceof Element))return!1;const O=D.closest('a,button,input,select,textarea,[role="button"],[role="radio"]');return O!==null&&O!==p.currentTarget},Z=p=>{re(p)||me()},ae=p=>{p.key!=="Enter"&&p.key!==" "||re(p)||(p.preventDefault(),me())},fe=i.metadata?.source_run_id,Q=g&&y?c?e.jsx(Ys,{content:i,ownerSlug:y}):J?e.jsx(Gs,{ownerSlug:y,content:i,batchReview:typeof fe=="number"?de(fe,"Review run"):null}):void 0:void 0,ie=g&&t?t(Q):{content:Q,nativeHeading:Q!=null};return e.jsx("div",{className:Te(l?"border-l-2 border-l-muted pl-4":"",K&&"cursor-pointer rounded-lg p-3 transition-colors hover:bg-accent/40",K&&ne&&"bg-accent ring-1 ring-inset ring-primary/20"),...K?{role:"button","aria-current":ne?"true":void 0,tabIndex:0,onClick:Z,onKeyDown:ae}:{},children:e.jsx(en,{primaryContent:ie.content,nativeHeading:ie.nativeHeading,detailLinks:ie.links,headingAside:ie.headingAside,hideDetails:f,onFiltersChange:n,presentation:s,content:i,ownerSlug:x??void 0,showParentContext:a,connectorDefinitions:u,onRenderedAction:y?V:void 0,runAction:j?null:ce,hideOriginator:N,hideAttribution:b,runId:U??i.run_id??null,onRunSelect:Ne,auditDetails:g&&(T||M)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"request",label:"Request",available:T},{key:"calls",label:"SDK calls",available:M}].map(p=>p.available?e.jsxs($,{variant:"outline",size:"sm","aria-expanded":m===p.key,onClick:()=>v(D=>D===p.key?null:p.key),children:[m===p.key?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(ye,{className:"h-3.5 w-3.5"}),p.label]},p.key):null)}),m==="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(Ke,{value:k.request})),m==="calls"&&e.jsx(Ke,{value:k.sdk_call_trace})]})})})}function Zs(s,t){const n=s.payload_data??{},r=s.metadata??{};if(t.audit&&typeof n.success=="boolean")return n.success?"completed":"failed";if(t.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(t.operation)return pt(s.interaction_status,typeof r.status=="string"?r.status:void 0)}function Xs(s){return s==="pending_approval"?"Needs approval":s==="confirmed"?"Approved":s?xe(s):null}function en({presentation:s,primaryContent:t,nativeHeading:n=!1,detailLinks:r,headingAside:i,onFiltersChange:l,content:a,ownerSlug:u,showParentContext:N,connectorDefinitions:j,onRenderedAction:b,runAction:f,auditDetails:m,hideOriginator:v=!1,hideAttribution:S=!1,runId:g,onRunSelect:_,hideDetails:I=!1}){const[H,q]=h.useState(!1),x=a.metadata??{},y=typeof a.score=="number"&&Number.isFinite(a.score)?Math.round(a.score):"-",V=a.payload_type||"text",k=a.text_content||"",w=s==="summary",J=s==null&&(V==="text"||V==="markdown")&&k.length>500,c=J&&!H?`${k.slice(0,500)}...`:k,T=a.payload_data??{},M=mt(a),{audit:P,operation:E,changeSet:F}=M,W=Zs(a,M),se=Xs(W),he=w&&P&&typeof T.tool_name=="string"?xe(T.tool_name):a.title,le=P&&T.error&&typeof T.error=="object"?T.error.message:void 0,_e=(typeof le=="string"?le:void 0)??a.interaction_error??(typeof x.error_message=="string"?x.error_message:void 0),je=_e||(P?"":k),[K,X]=h.useState(s!=="summary"&&P&&t==null&&r==null),ne=P?T.duration_ms:x.duration_ms,ee=typeof ne=="number"&&Number.isFinite(ne)&&ne>=0?ne:null,de=P&&typeof T.sdk_call_count=="number"&&Number.isSafeInteger(T.sdk_call_count)&&T.sdk_call_count>=0?T.sdk_call_count:null,ce=x.thumbnail_url||x.thumbnail,U=x.media_url,ue=w?[]:Os(x),Ne=Object.entries(a.classifications||{}).flatMap(([o,d])=>{const R=Ls(d);return R.values.map(A=>({slug:o,value:A,isManual:R.isManual}))}),me=(()=>{const o=a.platform||(typeof x.platform=="string"?x.platform:null),d=a.connection_id!=null?a.connection_id:x.source_connection_id!=null?Number(x.source_connection_id):null;return{...a,platform:o,connection_id:d!=null&&Number.isFinite(d)?d:null}})(),re=(()=>{const o=a.source_url??x.browser_url;if(typeof o!="string"||!URL.canParse(o))return null;const d=new URL(o);return d.protocol==="https:"||d.protocol==="http:"?d:null})(),Z=a.occurred_at?new Date(a.occurred_at):null,ae=me.platform?At(me.platform,j??[]):null,fe=P?Xe:E?et:F?It:a.semantic_type==="notification"?Tt:Et,Q=P?"SDK call":xe(a.semantic_type||a.origin_type||"Event"),ie=e.jsx($t,{plain:!0,name:ae?.name??re?.hostname??Q,icon:ae?.icon,faviconDomain:ae?.faviconDomain??re?.hostname,fallback:e.jsx(fe,{className:"h-4 w-4"}),className:"h-5 w-5 rounded-sm text-xs"}),p=ue.length>0?e.jsx("dl",{className:"grid gap-x-3 gap-y-2 text-sm sm:grid-cols-[minmax(140px,180px)_1fr]",children:ue.map(([o,d])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-muted-foreground",children:xe(o)}),e.jsx("dd",{className:"min-w-0 break-words font-mono text-xs sm:text-sm",children:Ps(d)})]},o))}):null,D=w?je?e.jsx("p",{className:Te("line-clamp-2 text-sm whitespace-pre-wrap",_e&&"text-destructive"),children:je.slice(0,320)}):null:e.jsxs(e.Fragment,{children:[a.rating&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:[1,2,3,4,5].map(o=>e.jsx(tt,{className:`h-4 w-4 ${o<=Number(a.rating)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},o))}),ce&&e.jsx("a",{href:U||a.source_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block mb-2",children:e.jsx("img",{src:ce,alt:"",className:`rounded-md object-cover ${V==="media"?"max-h-96 w-full":"max-h-48"}`,loading:"lazy"})}),(()=>{switch(V){case"markdown":if(c)return e.jsx("div",{className:"max-w-none text-sm space-y-2",children:e.jsx(Dt,{text:c})});break;case"json_template":{const o=a.payload_template;if(o?.root)return e.jsx(Ts,{template:o,data:a.payload_data||{},onAction:t?void 0:b},`${u}:${a.id}`);if(c)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:c});break}case"media":return e.jsxs("div",{className:"space-y-3",children:[!ce&&U&&e.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate block",children:U}),c&&e.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:c})]});case"empty":return e.jsxs("div",{className:"space-y-3",children:[m,p??(m?null:e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No content"}))]});default:if(c)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:c});break}return e.jsxs("div",{className:"space-y-3",children:[U&&!ce&&e.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground truncate block",children:U}),p]})})()]}),O=t!=null||s==="detail"&&P,ge=i!==void 0,Ae=O||r!=null;return h.useEffect(()=>{if(!ge||!K)return;const o=d=>{d.key==="Escape"&&(d.preventDefault(),X(!1))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[ge,K]),e.jsxs(e.Fragment,{children:[N&&a.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:a.parent_context.author_name}),e.jsx("div",{className:"text-muted-foreground line-clamp-2",children:a.parent_context.text_content})]}),e.jsxs("div",{className:Te("flex gap-3",s==="detail"&&"mb-5",ge&&"relative"),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:ie}),e.jsxs("div",{className:"min-w-0 flex-1",children:[s==="detail"&&(()=>{const o={semanticTypes:[a.semantic_type],...typeof a.automation_id=="number"?{producedByAutomationId:a.automation_id}:{},...typeof a.run_id=="number"?{runIds:[a.run_id]}:{}},d={semantic_types:a.semantic_type,...typeof a.automation_id=="number"?{produced_by:String(a.automation_id)}:{},...typeof a.run_id=="number"?{run_ids:String(a.run_id)}:{}};return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[a.semantic_type?l?e.jsx("button",{type:"button",className:"hover:underline",title:`Show all ${Q} events`,onClick:()=>l(o),children:Q}):u?e.jsx(oe,{to:"/$owner/events",params:{owner:u},search:d,className:"hover:underline",title:`Show all ${Q} events`,children:Q}):e.jsx("span",{children:Q}):e.jsx("span",{children:Q}),Z&&e.jsx("time",{dateTime:Z.toISOString(),children:be(Z)})]})})(),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[he&&!n&&e.jsx("h4",{className:Te("min-w-0 font-medium",s==="detail"?"text-xl leading-snug":"line-clamp-2 text-sm"),children:he}),s!=="detail"&&Z&&e.jsx("time",{dateTime:Z.toISOString(),title:be(Z),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Ce(Z,"HH:mm")}),ge&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pt-0.5",children:[i,Ae&&e.jsxs($,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-muted-foreground hover:text-foreground","aria-expanded":K,onClick:()=>X(o=>!o),children:["Details",K?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(ye,{className:"h-3.5 w-3.5"})]})]})]}),w&&e.jsx("div",{className:"mt-1 text-muted-foreground",children:D}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[se&&!n&&e.jsxs(pe,{variant:W==="failed"?"destructive":"secondary",className:"gap-1 text-xs",children:[W==="failed"?e.jsx(st,{className:"h-3 w-3"}):W==="completed"?e.jsx(ze,{className:"h-3 w-3"}):null,se]}),de!=null&&e.jsxs("span",{children:[de," SDK ",de===1?"call":"calls"]}),ee!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"h-3 w-3"}),ee<1e3?`${Math.round(ee)}ms`:`${Number((ee/1e3).toFixed(2))}s`]}),f,y==="-"||w&&(P||E||F)?null:a.score_breakdown?e.jsxs(Pt,{children:[e.jsx(Ot,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx("span",{className:"font-medium",children:y})})}),e.jsx(Ft,{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(Fs,{breakdown:a.score_breakdown})]})})]}):null,re&&e.jsxs(Mt,{children:[e.jsx(Lt,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1",asChild:!0,children:e.jsxs("a",{href:re.href,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:w?"sr-only":void 0,children:"View original"})]})})}),e.jsx(Bt,{children:"View original"})]})]}),u&&!S&&e.jsx(zt,{owner:u,source:me,connectorDefinitions:j,onFiltersChange:l,variant:"chips",className:"mt-2 text-xs",hideOriginator:v,runId:g,onRunSelect:_}),(a.author_name||!u)&&!(s==="detail"&&E)&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:a.author_name||Ds(a)})]}),ge&&K&&Ae&&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:[r,O&&D]})]}),!w&&typeof le=="string"&&e.jsx("p",{className:"mb-2 text-sm whitespace-pre-wrap text-destructive",children:le}),t,!w&&!O&&D,(O||r!=null)&&i===void 0&&!(I&&t!=null)&&e.jsxs("details",{className:"mt-5 border-t pt-3",open:K,onToggle:o=>X(o.currentTarget.open),children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Details"}),K&&e.jsxs("div",{className:"mt-3 space-y-3",children:[r,O&&D]})]}),J&&e.jsx($,{variant:"link",size:"sm",className:"px-0 h-6 mt-1",onClick:()=>q(!H),children:H?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3 w-3 mr-1"})," Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3 w-3 mr-1"})," Show more"]})}),Ne.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:Ne.map(o=>e.jsx(Ms,{slug:o.slug,value:o.value||"",isManual:o.isManual},o.slug))})]})}function tn({toolName:s,count:t,totalDurationMs:n,totalSdkCalls:r,newestAt:i,oldestAt:l,expanded:a,onToggle:u,children:N}){return e.jsx("div",{children:e.jsxs(Ee,{open:a,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(Xe,{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($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:u,children:[e.jsxs("span",{className:"min-w-0 truncate font-medium text-foreground",children:[xe(s)," × ",t]}),a?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(vt,{newestAt:i,oldestAt:l})]}),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(pe,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(ze,{className:"h-3 w-3"}),"Completed"]}),r!=null&&e.jsxs("span",{children:[r," SDK ",r===1?"call":"calls"]}),n!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"h-3 w-3"}),sn(n)]})]})]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:N})]})})}function sn(s){return s<1e3?`${Math.round(s)}ms`:`${Number((s/1e3).toFixed(2))}s`}function vt({newestAt:s,oldestAt:t}){const n=We(s),r=We(t);return n!=null&&r!=null&&n.getTime()-r.getTime()>nn&&r?e.jsxs("time",{dateTime:n.toISOString(),title:`${be(r)} – ${be(n)}`,className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:[Ce(r,"HH:mm"),"–",Ce(n,"HH:mm")]}):n?e.jsx("time",{dateTime:n.toISOString(),title:be(n),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Ce(n,"HH:mm")}):null}const nn=300*1e3;function We(s){if(s==null||s==="")return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t}function rn({organizationId:s,clientId:t,activityId:n,activityKind:r,callCount:i,newestAt:l,oldestAt:a,expanded:u,onToggle:N,children:j}){const{data:b=[]}=as({limit:100,organizationId:s??null}),f=b.find(S=>S.activityId===n&&(t==null||S.clientId===t))??null,m=f?bs(f):r==="session"?"MCP session":"Conversation",v=f?.clientName??null;return e.jsx("div",{children:e.jsxs(Ee,{open:u,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(ot,{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($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:N,children:[e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:m}),u?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(vt,{newestAt:l,oldestAt:a})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[`${i} ${i===1?"call":"calls"}`,v?` · ${v}`:null]})]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:j})]})})}function an({onIntersect:s,enabled:t,rootMargin:n="400px"}){const r=h.useRef(null),i=h.useRef(s);return i.current=s,h.useEffect(()=>{const l=r.current;if(!l||!t)return;const a=new IntersectionObserver(u=>{u[0]?.isIntersecting&&i.current()},{rootMargin:n});return a.observe(l),()=>a.disconnect()},[t,n]),r}function Ge(s){if(s==null||s==="")return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:Ce(t,"d MMMM yyyy")}function on({items:s,isLoading:t,emptyState:n,dense:r,hasNextPage:i,isFetching:l,isFetchingNextPage:a,onLoadMore:u,autoLoadMore:N=!0,groupByDate:j=!0}){const b=an({onIntersect:u,enabled:N&&i&&!l});return t&&s.length===0?e.jsx("div",{className:"space-y-4",children:["s1","s2","s3"].map(f=>e.jsx(is,{className:"h-32 rounded-lg"},f))}):e.jsxs("div",{className:r?"":"pt-1",children:[s.length===0?n!==void 0?n:e.jsx(os,{icon:ls,title:"Nothing here yet",description:"No events match this view."}):s.map((f,m)=>{const v=Ge(f.occurredAt),S=m>0?Ge(s[m-1].occurredAt):null;return e.jsxs(h.Fragment,{children:[j&&v&&v!==S&&e.jsx("p",{className:"px-3 pb-2 pt-4 text-xs text-muted-foreground",children:v}),e.jsx("div",{className:"mb-1",children:f.content})]},f.key)}),e.jsx("div",{ref:b,className:"h-1"}),a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(Se,{size:"xl",className:"text-muted-foreground"})}):i&&e.jsx($,{size:"sm",variant:"outline",disabled:l,onClick:u,children:"Load more"})]})}function xn({presentation:s="summary",renderDetail:t,onFiltersChange:n,hideDetails:r=!1,organizationId:i,ownerSlug:l,entityId:a,filters:u,showEntityLinks:N=!1,hideOriginator:j=!1,emptyState:b,dense:f=!1,foldConsecutiveCalls:m=!1,groupByConversation:v=!1,groupByRun:S=!1,onRunSelect:g,runs:_,hideRunAction:I=!1,hideAttribution:H=!1}){const{isAuthenticated:q,isReady:x}=ds(),{isMember:y,isLoading:V}=cs(),k=l==="me",w=!k&&x&&q&&y,J=!k&&x&&(!q||!V&&!y),{data:c=[]}=us(x&&w?i:null),{data:T=[]}=ms(J?l:null),M=w?c:T,P=ps(x&&w?i:null,a,u,l),E=xs(J?l:null,a,u),F=J?E:P,{data:W,isLoading:se,error:he,fetchNextPage:le,hasNextPage:_e,isFetchingNextPage:je}=F,K=h.useMemo(()=>W?.pages.flatMap(o=>o.content)??[],[W]),X=h.useMemo(()=>{const o=hs(K,{foldRunSatellites:!S}),d=o.map(L=>L.head),R=new Map(o.map(L=>[L.head.id,L])),A=fs(d,{groupByRun:S});return Array.from(A.entries()).map(([L,Y])=>{const B=Y.root||Y.replies[0],G=B?R.get(B.id):void 0;return{rootId:L,group:Y,history:G?.history??[],runId:G?.runId??null}})},[K,S]),[ne,ee]=h.useState(new Set),[de,ce]=h.useState(new Set),[U,ue]=h.useState(new Set),[Ne,me]=h.useState(new Set),[re,Z]=h.useState(new Set),ae=(o,d)=>o(R=>{const A=new Set(R);return A.has(d)?A.delete(d):A.add(d),A}),fe=(o,d)=>d.some(R=>o.has(R)),Q=(o,d)=>o(R=>{const A=new Set(R),L=d.some(Y=>A.has(Y));for(const Y of d)L?A.delete(Y):A.add(Y);return A}),ie=m?gs(X):X.map(o=>({kind:"single",node:o})),p=v?vs(ie):ie,D=!k&&(!x||q&&V||w&&F.isPending);if(he)return e.jsx(ys,{label:"events"});const O=o=>{if(o.kind==="fold"){const{fold:C}=o,Ve=C.nodes.map(Pe=>Pe.rootId),Nt=fe(de,Ve);return[{key:C.key,occurredAt:C.newestAt,content:e.jsx(tn,{toolName:C.toolName,count:C.nodes.length,totalDurationMs:C.totalDurationMs,totalSdkCalls:C.totalSdkCalls,newestAt:C.newestAt,oldestAt:C.oldestAt,expanded:Nt,onToggle:()=>Q(ce,Ve),children:C.nodes.map(Pe=>{const Oe=Pe.group.root;return Oe?e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:Oe,renderDetail:t,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H,hideDetails:r},Oe.id):null})})}]}const{rootId:d,group:R,history:A,runId:L}=o.node,Y=R.replies.length>0,B=ne.has(d),G=re.has(d),He=Ne.has(d),yt=R.replies.filter(C=>C.depth<=3),Ie=R.replies.filter(C=>C.depth>3),jt=!R.root&&R.replies.length>0,te=R.root||R.replies[0];return te?[{key:d,occurredAt:te.occurred_at,content:e.jsxs(e.Fragment,{children:[N&&l&&te.entity_name&&te.entity_type&&te.entity_slug&&e.jsx("div",{className:"mb-2",children:e.jsx(Cs,{ownerSlug:l,entity:{entityName:te.entity_name,entityType:te.entity_type,entitySlug:te.entity_slug}})}),e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:te,renderDetail:t,showParentContext:jt&&!!te.parent_context,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H,hideDetails:r}),A.length>0&&e.jsxs(Ee,{open:He,children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-1 h-7 gap-1 text-xs text-muted-foreground",onClick:()=>ae(me,d),children:[e.jsx(Ns,{className:"h-3.5 w-3.5"}),He?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",L!=null?`run #${L} `:"","history"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),L!=null?`Run #${L} · ${A.length===1?"1 earlier step":`${A.length} earlier steps`}`:A.length===1?"1 earlier state":`${A.length} earlier states`]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:A.map(C=>e.jsxs("div",{children:[e.jsx("time",{dateTime:new Date(C.occurred_at).toISOString(),title:be(C.occurred_at),className:"mb-1 block text-xs text-muted-foreground",children:Je(C.occurred_at)}),e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H})]},C.id))})]}),Y&&e.jsxs(Ee,{open:B,children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-2 ml-6 gap-1",onClick:()=>ae(ee,d),children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),B?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",R.replies.length," replies"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),"Show ",R.replies.length," replies"]})]})}),e.jsxs(De,{className:"space-y-2 mt-2",children:[yt.map(C=>e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,isReply:!0,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H},C.id)),Ie.length>0&&e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"ghost",size:"sm",className:"ml-12",onClick:()=>ae(Z,d),children:G?e.jsxs(e.Fragment,{children:["Hide ",Ie.length," nested replies"]}):e.jsxs(e.Fragment,{children:["Show ",Ie.length," nested replies"]})}),G&&Ie.map(C=>e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,isReply:!0,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H},C.id))]})]})]})]})}]:[]},ge=o=>{const d=o.nodes.length;return{key:o.key,occurredAt:o.newestAt,content:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[g?e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1 text-xs font-medium",onClick:()=>g(o.runId),title:`Open run #${o.runId} conversation`,children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),"Run #",o.runId]}):e.jsxs("span",{className:"inline-flex h-7 items-center gap-1 px-1 text-xs font-medium",children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),"Run #",o.runId]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.status!=null?`· ${xe(o.status)} · `:"· ",d===1?"1 event":`${d} events`,o.newestAt!=null?` · ${Je(o.newestAt)}`:""]})]}),e.jsx("div",{className:"mt-2 space-y-2 border-l-2 border-l-muted pl-4",children:o.nodes.flatMap(R=>O({kind:"single",node:R}).map(A=>e.jsx(h.Fragment,{children:A.content},A.key)))})]})}},Ae=o=>{const{block:d}=o,R=d.entries.flatMap(B=>B.kind==="fold"?B.fold.nodes.map(G=>G.rootId):[B.node.rootId]),A=fe(U,R),L=d.entries.flatMap(B=>O(B).map(G=>({key:G.key,content:G.content})));if(L.length===0)return[];const Y=d.entries.reduce((B,G)=>B+(G.kind==="fold"?G.fold.nodes.length:1),0);return[{key:d.key,occurredAt:d.newestAt,content:e.jsx(rn,{organizationId:i,clientId:d.clientId,activityId:d.activityId,activityKind:d.activityKind,callCount:Y,newestAt:d.newestAt,oldestAt:d.oldestAt,expanded:A,onToggle:()=>Q(ue,R),children:L.map(B=>e.jsx(h.Fragment,{children:B.content},B.key))})}]};return e.jsx(on,{groupByDate:s==="summary",dense:f,isLoading:se||D,emptyState:b,hasNextPage:!!_e,isFetching:F.isFetching,isFetchingNextPage:je,onLoadMore:()=>void le(),items:S?js(X,_).map(o=>"nodes"in o?ge(o):O({kind:"single",node:o})[0]).filter(o=>o!=null):p.flatMap(o=>o.kind==="context"?Ae(o):O(o))})}export{xn as E,on as a,en as b,mn as c,pn as u};
|
|
2
|
+
//# sourceMappingURL=events-feed-BtvhZF1f.js.map
|