@lobu/runtime-server 24.0.0 → 24.1.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/component.json +1 -1
- package/dist/connectors/x-dm-adapter.js +65 -30
- package/dist/db/migrations/20261021010000_views_compile_config_hash.sql +16 -0
- package/dist/dependencies.bun.lock +1 -1
- package/dist/owletto/dist/assets/{_-CC8cTmRg.js → _-BorucF19.js} +3 -3
- package/dist/owletto/dist/assets/_-CkGyNi0G.js +2 -0
- package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +2 -0
- package/dist/owletto/dist/assets/{_agentId-DWUFSrVp.js → _agentId-DgRrCE2B.js} +2 -2
- package/dist/owletto/dist/assets/{_automationId-BnHqdXOC.js → _automationId-DSrZIYcs.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-CefXIqy2.js → _connectorKey._connectionId-DWxv1uoi.js} +2 -2
- package/dist/owletto/dist/assets/{_connectorKey.index-C1QPGf9E.js → _connectorKey.index-BTP5ijdT.js} +2 -2
- package/dist/owletto/dist/assets/{_conversationId-DinuPCUp.js → _conversationId-98Y3RuRO.js} +2 -2
- package/dist/owletto/dist/assets/{_deploymentId-BeyzVjRm.js → _deploymentId-B1UWPY0i.js} +2 -2
- package/dist/owletto/dist/assets/{_eventId-3L_qeL_l.js → _eventId-BAnr8g8z.js} +2 -2
- package/dist/owletto/dist/assets/_name-BUfFO_A0.js +2 -0
- package/dist/owletto/dist/assets/{_owner-DbrKma4e.js → _owner-C79BwQ0I.js} +3 -3
- package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +2 -0
- package/dist/owletto/dist/assets/{_slug-ndDr_CUg.js → _slug-DbPdDc-5.js} +2 -2
- package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-CRKbM2Xy.js → accept-invitation-UXU5Fx2G.js} +2 -2
- package/dist/owletto/dist/assets/{activity-route-view-CFLNukhD.js → activity-route-view-D7ORHntE.js} +2 -2
- package/dist/owletto/dist/assets/{agent-card-controls-Be1Okb2C.js → agent-card-controls-CplnPhbv.js} +2 -2
- package/dist/owletto/dist/assets/{agent-client-setup-list-BA8dU_C6.js → agent-client-setup-list-BlXB4SE5.js} +2 -2
- package/dist/owletto/dist/assets/{agent-connect-pages-CAV-yXus.js → agent-connect-pages-BmknviTI.js} +2 -2
- package/dist/owletto/dist/assets/{agent-editor-form-Bi6WvYX-.js → agent-editor-form-DsSoeQeF.js} +2 -2
- package/dist/owletto/dist/assets/{agent-guardrails-route-DMOjG1D4.js → agent-guardrails-route-TdvvIc_J.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-De_2d8Lr.js → agent-loading-shells-B7v6Cffw.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-gZWl6mAe.js → agent-permissions-matrix-BkZu1LYE.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-JLaTamGR.js → agent-skill-context-DFucg4c4.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-DcK41PWj.js → agent-skills-route-B3vvvZZe.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-BBJoyTuC.js → agent-subpage-shell-CZJvnjNC.js} +2 -2
- package/dist/owletto/dist/assets/agent-thread-D38STyeu.js +6 -0
- package/dist/owletto/dist/assets/agents-DAOln24A.js +2 -0
- package/dist/owletto/dist/assets/{agents-workbench-CqaKGggb.js → agents-workbench-DJ67GZ93.js} +2 -2
- package/dist/owletto/dist/assets/{app._appId-Cl1fTuIt.js → app._appId-Cp78oEZ9.js} +2 -2
- package/dist/owletto/dist/assets/{automation-detail-content-BMLL4lxO.js → automation-detail-content-DSwbRpbx.js} +2 -2
- package/dist/owletto/dist/assets/automations-DAOln24A.js +2 -0
- package/dist/owletto/dist/assets/{callback-DTKKsfkz.js → callback-CBexCo3F.js} +2 -2
- package/dist/owletto/dist/assets/{card-yU0TmNRH.js → card-jzhQrMDP.js} +2 -2
- package/dist/owletto/dist/assets/{claim-DJfTvlT2.js → claim-B-wq745Q.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows--FrZfJol.js → client-rows-BYbsXGy9.js} +2 -2
- package/dist/owletto/dist/assets/{clients-L4K1UT8c.js → clients-BhNl1tVq.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-U54Gwjit.js → code-editor-CEqoCky-.js} +2 -2
- package/dist/owletto/dist/assets/connect-wx-qqLir.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId.activity-DTpSW1Xy.js → connected._clientId.activity-BqprYeOX.js} +2 -2
- package/dist/owletto/dist/assets/{connected._clientId.index-h9X5H1x8.js → connected._clientId.index-DhRoSzBr.js} +2 -2
- package/dist/owletto/dist/assets/{connection-ByvKkyFm.js → connection-CNm2ukrI.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-DWM9lTao.js → connection-feed-detail-WcGCA6qY.js} +2 -2
- package/dist/owletto/dist/assets/{connections-browser-CEwYrYqt.js → connections-browser-CrtnAs0Q.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-BocTm__v.js → connector-provenance-D-ECOlMJ.js} +2 -2
- package/dist/owletto/dist/assets/{connector-scope-lists-OYDOydtz.js → connector-scope-lists-CRFEpSvk.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-CyZpcE5f.js → connectors-CH4KBZyT.js} +2 -2
- package/dist/owletto/dist/assets/{consent-DdfINrVp.js → consent-C9ZpHb7V.js} +2 -2
- package/dist/owletto/dist/assets/{conversations-table-BSznfdYt.js → conversations-table-D_HOe1jN.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-Dr7tcIB-.js → core.esm-BupT3V0i.js} +2 -2
- package/dist/owletto/dist/assets/create-C4lptGWj.js +2 -0
- package/dist/owletto/dist/assets/{create-CBGwASon.js → create-CCjZxIkK.js} +2 -2
- package/dist/owletto/dist/assets/create-DkgUQAbB.js +2 -0
- package/dist/owletto/dist/assets/{create-automation-form-9T5WnoUs.js → create-automation-form-Bpy92SM5.js} +2 -2
- package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-BWFEyy_P.js → cronstrue-CWImw-kf.js} +2 -2
- package/dist/owletto/dist/assets/{deployments-wG_8QzOF.js → deployments-C5hvipQh.js} +2 -2
- package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +2 -0
- package/dist/owletto/dist/assets/{deployments-body-2xKS8gRo.js → deployments-body-DGII20dQ.js} +2 -2
- package/dist/owletto/dist/assets/{device-6z-xgsoW.js → device-D-7WBe9E.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-Cwq88RMU.js → device-pin-tombstone-2U0UMu3_.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-BDerBfD9.js → device._deviceId-Bn37UpWH.js} +2 -2
- package/dist/owletto/dist/assets/{entity-avatar-Cc1CuI-0.js → entity-avatar-mdh7Kq5D.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-DHdMC1Lx.js → entity-options-Clz_WXK-.js} +2 -2
- package/dist/owletto/dist/assets/{entity-page--OkXmlNP.js → entity-page-D3e4iPle.js} +2 -2
- package/dist/owletto/dist/assets/{entity-type-page-89RoK_-P.js → entity-type-page-DebN1vCM.js} +2 -2
- package/dist/owletto/dist/assets/{event-detail-D4YZRtrA.js → event-detail-DV_zfWnC.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +2 -0
- package/dist/owletto/dist/assets/{filter-editors-B1_QUpg_.js → filter-editors-Bwhqj7lY.js} +2 -2
- package/dist/owletto/dist/assets/{full-page-spinner-Cqih-8IW.js → full-page-spinner-BVbcpW3R.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-BiJollCA.js +2 -0
- package/dist/owletto/dist/assets/identity-HCFWtdaI.js +2 -0
- package/dist/owletto/dist/assets/index-8wxsyxqt.js +2 -0
- package/dist/owletto/dist/assets/{index-DYCqXaMf.js → index-9YuSRymd.js} +4 -4
- package/dist/owletto/dist/assets/index-B3c-0eZG.js +2 -0
- package/dist/owletto/dist/assets/{index-TgRS2v_F.js → index-B64PGxQm.js} +2 -2
- package/dist/owletto/dist/assets/{index-DfyDUpuI.js → index-BTlx9K_t.js} +2 -2
- package/dist/owletto/dist/assets/index-BX0EA_oB.js +2 -0
- package/dist/owletto/dist/assets/index-CdJJaQDX.js +2 -0
- package/dist/owletto/dist/assets/index-CfT_W8Vo.js +2 -0
- package/dist/owletto/dist/assets/{index-DYzWV5_z.js → index-CxF2XXzl.js} +2 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.js +2 -0
- package/dist/owletto/dist/assets/{index-ZNlrDc_f.js → index-D7gHOpfg.js} +2 -2
- package/dist/owletto/dist/assets/{index-DKPwCasf.js → index-DB1iWI_a.js} +2 -2
- package/dist/owletto/dist/assets/index-DMNzF8Lf.js +2 -0
- package/dist/owletto/dist/assets/index-DyB3IzOA.js +2 -0
- package/dist/owletto/dist/assets/{index-DAOyXG1X.js → index-fgAJydgX.js} +2 -2
- package/dist/owletto/dist/assets/{json-diff-DFvYINBT.js → json-diff-DIN5Jhfx.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-DFsEqLU1.js → list-skeleton-CepswBka.js} +2 -2
- package/dist/owletto/dist/assets/{login-DO0j-AYr.js → login-DxGYyE4n.js} +2 -2
- package/dist/owletto/dist/assets/{logout-BmNwoAf7.js → logout-Bkzc7J44.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-B2LrMWBU.js → member-scope-gate-DD4YBFn-.js} +2 -2
- package/dist/owletto/dist/assets/{memory-browse-page-Cjpl8EbB.js → memory-browse-page-D_UlBa27.js} +2 -2
- package/dist/owletto/dist/assets/{model-selector-TQcA93xm.js → model-selector-CDrAjH31.js} +2 -2
- package/dist/owletto/dist/assets/models-BAVeysNq.js +2 -0
- package/dist/owletto/dist/assets/{new-BMrFy5Qa.js → new-C2av0diq.js} +2 -2
- package/dist/owletto/dist/assets/{new-ByBhteWA.js → new-ktz9Cs_P.js} +2 -2
- package/dist/owletto/dist/assets/{new-DWp3deoW.js → new-snm1ctHn.js} +2 -2
- package/dist/owletto/dist/assets/{oauth-workspace-access-D_5uESuz.js → oauth-workspace-access-lZNZ9gul.js} +2 -2
- package/dist/owletto/dist/assets/{organization-DTFoYP4V.js → organization-Cb0W823y.js} +2 -2
- package/dist/owletto/dist/assets/{peek-pane-content-DF5iGC3c.js → peek-pane-content-BNR9ImQY.js} +2 -2
- package/dist/owletto/dist/assets/{permissions-C_auqxfP.js → permissions-Dv39zWKt.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-DsNiavG_.js → proposal-review-shell-CFhOqCLf.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +2 -0
- package/dist/owletto/dist/assets/{recent-3d99S2IE.js → recent-QhnLDU1_.js} +2 -2
- package/dist/owletto/dist/assets/{record-activity-C9KfBkXb.js → record-activity-ZJntBfN_.js} +2 -2
- package/dist/owletto/dist/assets/{record-field-peek-BBZcRuGT.js → record-field-peek-Brh1IQGy.js} +2 -2
- package/dist/owletto/dist/assets/{record-session-BizRugWs.js → record-session-Pbr5czGw.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-DqfcSn8M.js → reset-password-CzZw6RcC.js} +2 -2
- package/dist/owletto/dist/assets/{runs-panel-T1ZxTVz6.js → runs-panel-C0_DNTcq.js} +2 -2
- package/dist/owletto/dist/assets/{runs-table-D_8QlCCN.js → runs-table-B1APZv7d.js} +2 -2
- package/dist/owletto/dist/assets/{schema-value-normalization-CylKX3PK.js → schema-value-normalization-CKdPjdPC.js} +2 -2
- package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +2 -0
- package/dist/owletto/dist/assets/{settings-B_ClYztB.js → settings-VDNiffKU.js} +2 -2
- package/dist/owletto/dist/assets/skills-DgDGscm5.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-Cg249m1S.js → source-record-panels-BdfOVPWn.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-BYbFvHbJ.js → use-mention-search-Dcunv4L0.js} +2 -2
- package/dist/owletto/dist/assets/{view-param-filters-DMSqkN2J.js → view-param-filters-B0quibBi.js} +2 -2
- package/dist/owletto/dist/index.html +1 -1
- package/dist/server-main.bundle.mjs +354 -142
- package/npm-shrinkwrap.json +8 -8
- package/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +74 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +86 -0
- package/vendor/core/package.json +6 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-ksFp4zVf.js +0 -2
- package/dist/owletto/dist/assets/_agentId-MENLoohA.js +0 -2
- package/dist/owletto/dist/assets/_name-Dgedji78.js +0 -2
- package/dist/owletto/dist/assets/_shape-DtVfRFz_.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-CqLHzm7L.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-3CH5w8mr.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DHQY9A8u.js +0 -2
- package/dist/owletto/dist/assets/agent-thread-Buz3naVF.js +0 -6
- package/dist/owletto/dist/assets/agents-C-ReckCa.js +0 -2
- package/dist/owletto/dist/assets/automations-C-ReckCa.js +0 -2
- package/dist/owletto/dist/assets/connect-4zqtnDHb.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-Dj0SqgbE.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-sgtocSvf.js +0 -2
- package/dist/owletto/dist/assets/create-Cf5hp6Z8.js +0 -2
- package/dist/owletto/dist/assets/create-CwThQtd3.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-sNHQHNpg.js +0 -2
- package/dist/owletto/dist/assets/deployments-DHh9dyzv.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DsrkV2ix.js +0 -2
- package/dist/owletto/dist/assets/guardrails-B8Rs1be3.js +0 -2
- package/dist/owletto/dist/assets/identity-B0nH4yiC.js +0 -2
- package/dist/owletto/dist/assets/index-4TSkcsth.js +0 -2
- package/dist/owletto/dist/assets/index-BgkhXElB.js +0 -2
- package/dist/owletto/dist/assets/index-CoW4Bz3w.js +0 -2
- package/dist/owletto/dist/assets/index-Codw-Qqi.js +0 -2
- package/dist/owletto/dist/assets/index-DMyXd3bJ.js +0 -2
- package/dist/owletto/dist/assets/index-DYYZLcJ0.js +0 -2
- package/dist/owletto/dist/assets/index-Da6CrGEu.js +0 -2
- package/dist/owletto/dist/assets/index-DneshLbf.js +0 -2
- package/dist/owletto/dist/assets/models-D7aED5Sa.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-B2NUI89V.js +0 -2
- package/dist/owletto/dist/assets/settings-DgX1-xo7.js +0 -2
- package/dist/owletto/dist/assets/skills-Drw5tcZw.js +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,L as le,dF as Qt,dG as Ye,cy as Wt,by as Gt,g as gt,r as N,dH as yt,dI as Xt,W as Yt,J as Zt,dD as en,dh as tn,Q as ue,dJ as nn,dK as jt,dL as vt,dM as sn,dN as bt,cM as rn,dO as an,cA as on,o as Nt,u as Ze,dP as et,dQ as _t,S as Pe,B as E,A as ln,dR as dn,dS as Je,dT as wt,b7 as kt,dU as cn,dV as un,cN as mn,dW as Ct,dX as pn,ck as xn,dY as Ae,dZ as hn,d_ as Ne,d$ as _e,P as ce,e0 as St,e1 as tt,e2 as It,dr as fn,dt as gn,ds as yn,cz as At,e3 as jn,n as Rt,bJ as it,b$ as ot,$ as vn,e4 as bn,e5 as Nn,cm as _n,e6 as wn,e7 as Et,e8 as kn,e9 as Cn,a2 as Re,ea as Sn,eb as In,bQ as An,ec as Rn,bU as En,ed as Tn,dy as $n,ee as Pn,X as Fn,bk as Tt,ef as De,eg as Le,eh as Me,d1 as Fe,d8 as On,aR as Dn,di as Ln,i as Mn,bh as Bn,cg as zn,d6 as Un,db as Vn,dc as Hn,ei as qn,ej as Kn,ek as Jn,el as Qn,em as Wn,bM as Gn,en as Xn,eo as He,bd as lt,aj as Yn}from"./index-DYCqXaMf.js";import{c as Zn}from"./conversations-table-BSznfdYt.js";import{u as es}from"./clients-L4K1UT8c.js";import{J as ts,g as ns,c as ss,a as rs,F as as,S as nt,e as is,n as os}from"./schema-value-normalization-CylKX3PK.js";function ls(t,n){const s=n.parentEntityType&&n.parentEntitySlug?[{entity_type:n.parentEntityType,slug:n.parentEntitySlug},{entity_type:n.entityType,slug:n.entitySlug}]:[{entity_type:n.entityType,slug:n.entitySlug}];return Ye(t,s)}function ds({ownerSlug:t,entity:n,className:s}){const r=ls(t,n);return e.jsxs(le,{to:r,className:`flex items-center gap-1 text-primary hover:underline group ${s??""}`,children:[e.jsx("span",{className:"font-medium",children:n.entityName}),e.jsx(Qt,{className:"h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function $t(t){const n=Array.isArray(t?.records)?t.records:Array.isArray(t?.current)?t.current:[];return[t?.from_entity_id??t?.entity_id,t?.to_entity_id].map(s=>{const a=n.find(i=>i&&typeof i=="object"&&"id"in i&&i.id===s);return{id:String(s??"unknown"),name:typeof a?.name=="string"?a.name:`Record ${String(s??"unknown")}`}})}function Pt(t,n){return n==="rejected"?"The proposed relationship change was rejected. Both records remain available.":n==="failed"?"The relationship change failed. Both records remain available.":n==="completed"?t==="link"?"The records were linked. Both records remain available.":"The relationship was removed. Both records remain available.":n==="approved"||n==="confirmed"?"The relationship change was approved. Both records remain available.":t==="link"?"If approved, these records will be linked. Both records remain available.":"If approved, this relationship will be removed. Both records remain available."}function br(t){const n=$t(t.proposal);return{title:t.action==="link"?"Link records":"Unlink records",icon:"entity",impact:{level:"normal"},tone:"default",blocks:[...n.map((s,r)=>({type:"text",label:r===0?"From":"To",value:s.name})),{type:"text",label:"Relationship",value:String(t.proposal?.relationship_type??t.proposal?.relationship_type_slug??"Relationship")},{type:"text",value:Pt(t.action,typeof t.status=="string"?t.status:void 0),muted:!0},...typeof t.reason=="string"&&t.reason?[{type:"text",label:"Why this needs approval",value:t.reason}]:[]],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",confirm:t.action==="unlink",confirmPrompt:"Remove this relationship? Both records will remain available.",tool:"manage_operations",args:{action:"approve"},resolvedLabel:"Approval submitted."},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this relationship change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:"Relationship change rejected."}]}}function Ft(t,n,s){return{queryKey:["event-view-match",t,n.key,n.content_hash,s],queryFn:async()=>{try{const a=(await Wt("open_view",{key:n.key,scope:{event:s}},{slug:t})).scope?.event;if(!Number.isSafeInteger(a)||(a??0)<1)throw new Error("The view did not resolve its event subject");return a}catch(r){if(r instanceof Gt&&(r.status===400||r.status===404))return null;throw r}},staleTime:6e4}}function Nr(t,n){const s=gt(t??{slug:null,organizationId:null}),r=t?.slug??null,a=N.useMemo(()=>r?yt(s.data??[]):[],[r,s.data]),i=Xt({queries:a.map(l=>Ft(r,l,n))});return r?{views:a.flatMap((l,m)=>{const o=i[m]?.data;return o?[{...l,eventId:o}]:[]}),isLoading:s.data===void 0?!s.isError:i.some(l=>l.isPending),isError:s.isError||i.some(l=>l.isError),refetch:()=>{s.refetch();for(const l of i)l.isError&&l.refetch()}}:{views:[],isLoading:!1,isError:!1,refetch:()=>{}}}async function cs(t,n,s,r){const a=await Promise.all(s.map(i=>t.fetchQuery(Ft(n,i,r))));return s.find((i,l)=>a[l])??null}async function us(t,n,s,r){const a=await Yt(`${Zt}/api/${encodeURIComponent(t)}/events/${n}/actions/${encodeURIComponent(s.action)}`,{method:"POST",timeoutMs:9e4,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:s.value,interaction_id:r})});return await en(a,"Could not record interaction"),a.json()}function U(t){if(typeof t!="string")return;const n=t.trim();return n.length>0?n:void 0}function qe(t){return typeof t=="boolean"?t:void 0}function ms(t,n,s){const r=(s??"").toLowerCase();return!!(r==="prepare_comment"||r==="verify_staged_comment"||r.includes("prepare_")||r.includes("verify_staged")||n?.prepared===!0||typeof n?.verified=="boolean"||U(n?.reason_preview)&&U(n?.message)||U(t?.body)&&(U(t?.post_url)||U(t?.activity_id)))}function ps(t,n,s){if(!ms(t,n,s))return null;const r=(s??"").toLowerCase(),a=U(n?.body)??U(t?.body),i=U(n?.reason_preview)??U(t?.reason),l=U(n?.post_url)??U(t?.post_url)??(U(t?.activity_id)?`https://www.linkedin.com/feed/update/urn:li:activity:${U(t?.activity_id)}`:void 0),m=qe(n?.prepared),o=qe(n?.verified),c=qe(n?.banner_shown),p=U(n?.message),u=n?.match&&typeof n.match=="object"?n.match:null,h=U(u?.text_preview),v=U(u?.author);let I="generic";r==="verify_staged_comment"||r.includes("verify")||typeof o=="boolean"?I="verify":(r==="prepare_comment"||r.includes("prepare")||m===!0||a&&l)&&(I="prepare");const _=[];return m===!0&&_.push("Staged — not posted"),m===!1&&_.push("Not staged"),o===!0&&_.push("Verified posted"),o===!1&&_.push("Not verified as posted"),c===!0&&_.push("In-page banner"),c===!1&&_.push("No banner"),{kind:I,message:p,reason:i,body:a,postUrl:l,prepared:m,bannerShown:c,verified:o,matchPreview:h,matchAuthor:v,chips:_}}function Se(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function xs({template:t,data:n,onAction:s}){const[r,a]=N.useState(null),[i,l]=N.useState(!1),[m,o]=N.useState(null),[c,p]=N.useState(!1),u=N.useRef(!1),h=N.useRef(!0);N.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const v=async I=>{if(!(!s||u.current)){u.current=!0,l(!0),o(null),p(!1);try{const _=await s(I);if(!h.current)return;if(Se(_)&&_.kind==="sdk"){const j=_.result;if(!Se(j)||j.success!==!0){const w=Se(j)&&Se(j.error)?j.error.message:null;throw new Error(typeof w=="string"?w:"Could not update this event.")}if(j.return_truncated||!Se(j.return_value))throw new Error("The update did not return a complete data object.");a(j.return_value),p(!0)}}catch(_){h.current&&o(_ instanceof Error?_.message:"Could not update this event.")}finally{u.current=!1,h.current&&l(!1)}}};return e.jsxs("div",{className:"space-y-2",children:[i?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Updating…"}):null,c?e.jsx("p",{role:"status",className:"sr-only",children:"Updated"}):null,m?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[m," Previous data is still shown."]}):null,e.jsx("fieldset",{disabled:!s||i,"aria-busy":i,className:"min-w-0",children:e.jsx(ts,{template:{root:t.root},data:r??n,onAction:s?v:void 0,interactions:t.interactions})})]})}function hs(t){return t.type==="array"&&!!t.items&&(t.items?.type==="object"||!!t.items?.properties)}function fs(t){return(t.type==="object"||!!t.properties)&&Object.keys(t.properties??{}).length>0}function gs(t){const n=t?.properties??{};return Object.entries(n).filter(([,s])=>!("x-measure"in s)&&!("x-dimension"in s)).map(([s,r])=>({key:s,prop:r}))}function Be(t){return t.label??t.prop["x-table-label"]??ns(t.key,t.prop)}function ys(t){try{return ss(t)}catch{return t instanceof nn?t.text:t}}function dt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function js({value:t,prop:n,ownerSlug:s,orgContext:r}){const a=n["x-link-entity-type"],i=n["x-link-lookup-field"]||"slug",{data:l}=rn(a,r,{limit:an}),m=o=>{const c=l?.entities.find(p=>{const u=i==="slug"?p.slug:p.metadata?.[i];return u!=null&&String(u)===o});return c?{label:c.name,to:on(s,is(c))}:void 0};return e.jsx(nt,{value:t,prop:n,resolveLink:m})}function vs({field:t,value:n,context:s}){if(hs(t.prop)&&(n==null||Array.isArray(n))){const r=Array.isArray(n)?n.length:0,a=`${r} ${r===1?"item":"items"}`,i=s.dirtyKeys?.includes(t.key)??!1,l="inline-flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs tabular-nums";if(!s.openField)return e.jsx("span",{className:l,children:a});const m=s.openFieldKey===t.key;return e.jsxs("button",{type:"button","aria-pressed":m,"aria-label":`${Be(t)}: ${a}${i?", unsaved changes":""}`,className:ue(l,"hover:bg-muted/70 hover:text-foreground",m&&"ring-1 ring-primary"),onClick:()=>s.openField?.(t),children:[a,i?e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"· edited"}):null]})}return t.prop["x-link-entity-type"]&&s.orgContext&&n!=null?e.jsx(js,{value:n,prop:t.prop,ownerSlug:s.ownerSlug,orgContext:s.orgContext}):e.jsx(nt,{value:n,prop:t.prop})}function ct({field:t,control:n,labelId:s}){const r=rs(t.prop);return e.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5",children:[e.jsx("span",{id:s,className:"min-w-0 break-words",children:Be(t)}),r?e.jsxs(jt,{children:[e.jsx(vt,{asChild:!0,children:e.jsx("button",{type:"button",className:"shrink-0 text-muted-foreground/70 hover:text-foreground","aria-label":`About ${Be(t)}: ${r}`,children:e.jsx(sn,{className:"h-3 w-3"})})}),e.jsx(bt,{className:"max-w-xs",children:r})]}):null,n?e.jsx(as,{control:n}):null]})}function Ot({field:t,value:n,context:s,nested:r}){const a=N.useId(),i=r?void 0:s.controls?.[t.key],l=ys(n);if(fs(t.prop)&&(l==null||dt(l))){const m=Object.entries(t.prop.properties??{}).map(([c,p])=>({key:c,prop:p})),o=dt(l)?l:{};return e.jsxs("fieldset",{"aria-labelledby":a,className:"m-0 min-w-0 space-y-2 border-0 p-0",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:e.jsx(ct,{field:t,control:i,labelId:a})}),e.jsx("dl",{className:"space-y-2 border-l border-border pl-3",children:m.map(c=>e.jsx(Ot,{field:c,value:o[c.key],context:s,nested:!0},c.key))})]})}return e.jsxs("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-baseline gap-x-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:e.jsx(ct,{field:t,control:i,labelId:a})}),e.jsx("dd",{"aria-labelledby":a,className:ue("min-w-0 [overflow-wrap:anywhere]",t.numeric&&"tabular-nums"),children:e.jsx(vs,{field:t,value:l,context:s})})]})}function bs({fields:t,values:n,context:s}){return t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"This type declares no fields."}):e.jsx(tn,{delayDuration:200,children:e.jsx("dl",{className:"space-y-2.5 text-sm leading-5",children:t.map(r=>e.jsx(Ot,{field:r,value:n[r.key],context:s,nested:!1},r.key))})})}function Ns(t){return{href:"",key:`record-peer:${t.entityId}`,title:t.name?.trim()||"Record",recordPeer:{entityId:t.entityId,ownerSlug:t.ownerSlug,orgContext:t.orgContext}}}function _r({target:t}){const n=Nt(),s=Ze(),{data:r,isLoading:a,isError:i}=et(t.entityId,t.orgContext),{data:l}=_t(r?.entity_type??"",t.orgContext),[m,o]=N.useState(!1),[c,p]=N.useState(!1);if(a)return e.jsxs("div",{className:"space-y-3 px-5 py-5",children:[e.jsx(Pe,{className:"h-5 w-2/3"}),e.jsx(Pe,{className:"h-4 w-full"}),e.jsx(Pe,{className:"h-4 w-full"})]});if(i||!r)return e.jsx("p",{className:"px-5 py-5 text-sm text-muted-foreground",children:"This record is not available. It may have been deleted, or you may not have access to it."});const u=l?.metadata_schema,h=async()=>{o(!0),p(!1);try{const v=await dn(r.id,t.orgContext);s?.close(),await n({to:Ye(t.ownerSlug,v)})}catch{p(!0)}finally{o(!1)}};return e.jsxs("article",{className:"space-y-4 px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?.name??r.entity_type})]}),e.jsxs(E,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1 px-2 text-muted-foreground hover:text-foreground",disabled:m,"aria-busy":m,onClick:()=>void h(),children:["Open record",e.jsx(ln,{className:"h-3.5 w-3.5"})]})]}),c?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null,e.jsx(bs,{fields:gs(u),values:os(r.metadata??{},u),context:{ownerSlug:t.ownerSlug,orgContext:t.orgContext}})]})}function _s(t,n){const s=t.from_entity_id===n;return{id:s?t.to_entity_id:t.from_entity_id,name:s?t.to_entity_name:t.from_entity_name,type:s?t.to_entity_type:t.from_entity_type,self:t.from_entity_id===t.to_entity_id}}const ut="inline-flex max-w-full items-center truncate rounded-md border border-border px-1.5 py-0.5 text-xs";function Qe({peer:t,ownerSlug:n,orgContext:s}){const r=Ze();if(t.self||!t.type||!r)return e.jsx("span",{className:ue(ut,"text-muted-foreground"),children:t.name});const a=r.item?.recordPeer?.entityId===t.id;return e.jsx("button",{type:"button","aria-pressed":a,title:t.type,className:ue(ut,"hover:bg-muted",a&&"ring-1 ring-primary"),onClick:i=>{i.stopPropagation(),r.open(Ns({entityId:t.id,ownerSlug:n,orgContext:s,name:t.name}))},children:e.jsx("span",{className:"truncate",children:t.name})})}function wr({row:t,entityId:n,ownerSlug:s,orgContext:r}){const a=_s(t,n);return e.jsx(Qe,{peer:{id:a.id,type:a.type,self:a.self,name:a.self?"this record":a.name??`Record #${a.id}`},ownerSlug:s,orgContext:r})}const Dt={name:"Name",slug:"URL slug",parent_id:"Parent",content:"Content changed"};function be(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Te(t){return t==null||t===""}function ws(t,n){return Je(t??null)===Je(n??null)}function ks(t){return!!(t?.type==="array"&&(t.items?.type==="object"||t.items?.properties))}function Cs(t){return!!(t&&(t.type==="object"||t.properties)&&t.type!=="array")}function st(t,n){return Be({key:t,prop:n??{}})}function Ss(t,n){return t?.properties?.[n]}function We(t,n,s,r,a){if(ws(n,s))return;const i=o=>Array.isArray(o)?o:[];if((Array.isArray(n)||Te(n))&&(Array.isArray(s)||Te(s))&&(Array.isArray(n)||Array.isArray(s)||r?.type==="array")){const o=i(n),c=i(s);if(ks(r)||[...o,...c].some(j=>be(j))){const j=Math.min(o.length,c.length);for(let P=0;P<j;P++)We([...t,`item ${P+1}`],o[P],c[P],r?.items,a);const w=Math.max(0,c.length-o.length),K=Math.max(0,o.length-c.length);(w||K)&&a.push({kind:"items",path:t,added:w,removed:K});return}const u=j=>Je(j),h=new Set(o.map(u)),v=new Set(c.map(u)),I=c.filter(j=>!h.has(u(j))),_=o.filter(j=>!v.has(u(j)));a.push(I.length||_.length?{kind:"values",path:t,added:I,removed:_,prop:r?.items}:{kind:"reordered",path:t});return}if((be(n)||Te(n))&&(be(s)||Te(s))&&(be(n)||be(s)||Cs(r))){const o=be(n)?n:{},c=be(s)?s:{},p=[...new Set([...Object.keys(r?.properties??{}),...Object.keys(o),...Object.keys(c)])];for(const u of p){const h=Ss(r,u);We([...t,st(u,h)],o[u],c[u],h,a)}return}a.push({kind:"set",path:t,old:n,new:s,prop:r})}function Is(t,n){const s=Dt[t.field];if(s)return t.field==="content"?[{kind:"note",path:[s]}]:t.field==="parent_id"?[{kind:"parent",path:[s],old:t.old,new:t.new}]:[{kind:"set",path:[s],old:t.old,new:t.new}];const r=n?.properties?.[t.field],a=[];return We([st(t.field,r)],t.old,t.new,r,a),a}function As(t,n){const s=n?.properties;return t.map(r=>r.field==="content"?"Content":Dt[r.field]??st(r.field,s?.[r.field]))}const Rs="entity.updated",Es=new Set(["link","unlink","update_link"]);function mt(t){const n=typeof t=="string"||typeof t=="number"?Number(t):Number.NaN;return Number.isSafeInteger(n)&&n>0?n:null}function Ts(t){const n=t.split("_").join(" ").trim();return n?`${n.charAt(0).toUpperCase()}${n.slice(1)}`:t}function $s(t){const n=t.metadata;if(t.semantic_type!=="change"||!n||n._lobu_relationship_change!==!0||typeof n.op!="string"||!Es.has(n.op))return null;const s=mt(n.fromEntityId),r=mt(n.toEntityId);if(s==null||r==null)return null;const a=typeof n.relationshipTypeSlug=="string"?n.relationshipTypeSlug:null,i=Array.isArray(n.changes)?n.changes:[];return{op:n.op,fromId:s,toId:r,typeLabel:a?Ts(a):"relationship",changedFields:i.flatMap(l=>l&&typeof l=="object"&&typeof l.field=="string"?[l.field]:[])}}function Oe({id:t,recordId:n,ownerSlug:s}){const r=t===n,a={slug:s},{data:i,isLoading:l,isError:m}=et(r?void 0:t,a);return r?e.jsx(Qe,{peer:{id:t,name:"this record",type:null,self:!0},ownerSlug:s,orgContext:a}):l?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Record #",t]}):m||!i?e.jsx("span",{className:"text-xs text-muted-foreground",title:"Deleted, or you do not have access to it",children:"Unavailable record"}):e.jsx(Qe,{peer:{id:t,name:i.name,type:i.entity_type},ownerSlug:s,orgContext:a})}function Ps({change:t,recordId:n,ownerSlug:s}){const r=t.op==="link"?`Linked as ${t.typeLabel}`:t.op==="unlink"?`Unlinked ${t.typeLabel}`:`Updated ${t.typeLabel} link`,a=n===t.toId&&n!==t.fromId,i=n===t.fromId;return e.jsxs("span",{"data-testid":"relationship-change",className:"inline-flex flex-wrap items-center gap-1.5",children:[!i&&!a?e.jsx(Oe,{id:t.fromId,ownerSlug:s}):null,e.jsx("span",{children:a?`${r} from`:r}),a?e.jsx(Oe,{id:t.fromId,recordId:n,ownerSlug:s}):e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx(Oe,{id:t.toId,recordId:n,ownerSlug:s})]}),t.op==="update_link"&&t.changedFields.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",t.changedFields.join(", ")]}):null]})}function Fs(t){if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const s of t){if(!s||typeof s!="object"||typeof s.field!="string")return null;const{field:r,old:a,new:i}=s;n.push({field:r,old:a??null,new:i??null})}return n}function Os(t){const n=$s(t);if(n)return{kind:"relationship",change:n};const s=t.metadata;if(t.semantic_type!=="change"||!s)return null;const r=s._lobu_event_type;if(r!==Rs&&(r!==void 0||s.category))return null;const a=Fs(s.changes);if(!a)return null;const i=t.entity_ids?.[0];return{kind:"fields",entityId:typeof i=="number"?i:null,changes:a}}function Lt(t,n){const s={slug:n},{data:r}=et(t.entityType?void 0:t.entityId??void 0,s),{data:a}=_t(t.entityType??r?.entity_type??"",s);return a?.metadata_schema}const Ds=4;function $e({value:t,prop:n}){return e.jsx("span",{className:"inline-block max-w-[18rem] truncate align-bottom",title:typeof t=="string"?t:void 0,children:e.jsx(nt,{value:t,prop:n,empty:e.jsx("span",{className:"italic",children:"empty"})})})}function pt({id:t,ownerSlug:n}){const s=typeof t=="number"||typeof t=="string"?Number(t):Number.NaN;return Number.isSafeInteger(s)&&s>0?e.jsx(Oe,{id:s,ownerSlug:n}):e.jsx("span",{className:"italic text-muted-foreground",children:"empty"})}function Ge(t,n){return`${t} ${n}${t===1?"":"s"}`}function Ls({line:t,ownerSlug:n}){const s=e.jsx("span",{className:"text-muted-foreground",children:t.path.join(" · ")});switch(t.kind){case"note":return s;case"set":return e.jsxs(e.Fragment,{children:[s,": ",e.jsx($e,{value:t.old,prop:t.prop})," ",e.jsx("span",{"aria-hidden":"true",children:"→"})," ",e.jsx($e,{value:t.new,prop:t.prop})]});case"parent":return e.jsxs(e.Fragment,{children:[s,": ",e.jsx(pt,{id:t.old,ownerSlug:n})," ",e.jsx("span",{"aria-hidden":"true",children:"→"})," ",e.jsx(pt,{id:t.new,ownerSlug:n})]});case"items":return e.jsxs(e.Fragment,{children:[s,":"," ",[t.added?`${Ge(t.added,"item")} added`:null,t.removed?`${Ge(t.removed,"item")} removed`:null].filter(Boolean).join(", ")]});case"values":return e.jsxs(e.Fragment,{children:[s,":",t.added.map((r,a)=>e.jsxs("span",{className:"ml-1.5",children:["+",e.jsx($e,{value:r,prop:t.prop})]},`+${a}`)),t.removed.map((r,a)=>e.jsxs("span",{className:"ml-1.5 text-muted-foreground",children:["−",e.jsx($e,{value:r,prop:t.prop})]},`-${a}`))]});case"reordered":return e.jsxs(e.Fragment,{children:[s,": reordered"]})}}function Ms({change:t,ownerSlug:n}){const s=Lt(t,n);return e.jsxs(e.Fragment,{children:["Updated ",As(t.changes,s).join(", ")]})}function rt({changes:t,entityId:n,entityType:s,ownerSlug:r,showAll:a=!1}){const i=Lt({entityId:n,entityType:s},r),[l,m]=N.useState(a),o=t.flatMap(u=>Is(u,i)),c=l?o:o.slice(0,Ds),p=o.length-c.length;return e.jsxs("ul",{"data-testid":"field-changes",className:"space-y-0.5 text-sm",children:[c.map((u,h)=>e.jsx("li",{className:"min-w-0 truncate",children:e.jsx(Ls,{line:u,ownerSlug:r})},h)),p>0?e.jsx("li",{children:e.jsxs("button",{type:"button",className:"text-xs text-primary hover:underline",onClick:u=>{u.stopPropagation(),m(!0)},children:["+",Ge(p,"more change")]})}):null]})}function Bs({event:t,recordId:n,ownerSlug:s}){return t.kind==="relationship"?e.jsx(Ps,{change:t.change,recordId:n,ownerSlug:s}):e.jsx(Ms,{change:t,ownerSlug:s})}function zs({event:t,ownerSlug:n}){return t.kind==="fields"?e.jsx(rt,{changes:t.changes,entityId:t.entityId,ownerSlug:n}):null}function Mt(t){return{audit:t.semantic_type==="audit"&&t.origin_type==="tool_invocation",operation:t.interaction_type==="approval"||t.semantic_type==="operation",changeSet:t.semantic_type==="change_set"}}const Us={};function me(t){return t.replace(/_/g," ").replace(/\s+/g," ").trim().replace(/^./,n=>n.toUpperCase())}const Vs={notification:"Notification",tool_invocation:"Action",deployment:"Deployment",config_change:"Config change",message:"Message",msg:"Note",summary:"Summary"};function Hs(t){return t.author_name?t.author_name:t.platform?me(t.platform):t.origin_type?Vs[t.origin_type]??me(t.origin_type):null}function qs(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):Array.isArray(t)?t.length===0?"":t.every(n=>typeof n!="object")?t.map(n=>String(n)).join(", "):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(t,null,2)}):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(t,null,2)})}const Ke=1e5;function xt({value:t}){const n=JSON.stringify(t,null,2)??"null",s=n.length>Ke;return e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-3 font-mono text-xs",children:s?n.slice(0,Ke):n}),s&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",Ke.toLocaleString()," of"," ",n.length.toLocaleString()," characters."]})]})}function Ks(t){return Object.entries(t).filter(([,n])=>n==null?!1:typeof n=="string"?n.trim().length>0:Array.isArray(n)?n.length>0:typeof n=="object"?Object.keys(n).length>0:!0).sort(([n],[s])=>n.localeCompare(s))}function Js({breakdown:t}){if(!t)return null;const n=[{label:"Engagement",value:t.engagement,max:100},{label:"Criticality",value:t.criticality,max:100},{label:"Depth",value:t.depth,max:100},{label:"Authority",value:t.authority,max:100},{label:"Recency",value:t.recency,max:100},{label:"Quality",value:t.quality,max:100}];return e.jsx("div",{className:"space-y-2 text-sm",children:n.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-muted-foreground",children:s.label}),e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary",style:{width:`${s.value/s.max*100}%`}})}),e.jsx("span",{className:"w-8 text-right",children:s.value})]},s.label))})}function Qs({slug:t,value:n,isManual:s}){return e.jsxs(ce,{variant:"secondary",className:"text-xs",children:[t,": ",n,s&&e.jsx(Ct,{className:"ml-1 h-2.5 w-2.5 fill-current"})]})}function Ws(t){if(t&&typeof t=="object"){const n=t;if(Array.isArray(n.values))return{values:n.values.map(s=>String(s)).filter(s=>s.length>0),isManual:n.is_manual===!0};if(n.value!==void 0&&n.value!==null)return{values:[String(n.value)],isManual:n.is_manual===!0};if(typeof n.values=="string"&&n.values.length>0)return{values:[n.values],isManual:n.is_manual===!0}}return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?{values:[String(t)],isManual:!1}:{values:[],isManual:!1}}function Bt(t,n){if(t)switch(t){case"pending":return"pending_approval";case"approved":return"confirmed";case"rejected":return"rejected";case"completed":return"completed";case"failed":return"failed";default:return t}return n||"pending_approval"}function Xe(t){return!t||typeof t!="object"||Array.isArray(t)?null:t}function Gs(t){return t.replace(/\s+[—-]\s+pending approval$/i,"")}function ze(t){return t.replace(/^\$/,"").replace(/[_-]/g," ").replace(/\s+/g," ").trim().replace(/^./,n=>n.toUpperCase())}function zt(t,n,s){return t?.kind==="agent_session"&&t.agent_id?t.client_id?`${t.agent_id} via ${t.client_id}`:t.agent_id:t?.kind==="user"?"a person":n==="agent"?"an agent":s?`Automation ${s}`:"an Automation"}function Xs({ownerSlug:t,initiator:n,clientName:s,fallback:r}){const a=n?.client_id??s,{allOrgs:i,isAuthenticated:l}=Rt(),m=l&&i?.some(v=>v.slug===t),c=es(void 0,{ownerSlug:t,enabled:!!(a&&m)}).data?.find(v=>v.id===a)?.title,p=n&&n.kind!=="user"?zt(n,void 0,n.automation_id===void 0?void 0:String(n.automation_id)):r,u="font-medium text-foreground",h=`${u} underline-offset-4 hover:underline`;return n?.kind==="automation"&&n.automation_id?e.jsx(le,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:String(n.automation_id)},search:{view:"definition",run_id:void 0},className:h,children:p}):n?.kind==="agent_session"&&n.agent_id?e.jsx(le,{to:"/$owner/agents/$agentId",params:{owner:t,agentId:String(n.agent_id)},className:h,children:p}):a?e.jsxs(le,{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:a},className:`${h} inline-flex items-center gap-1 align-middle`,children:[e.jsx(Tt,{name:c??s??a}),c??p]}):e.jsx("span",{className:u,children:p})}function Ys(t){const n=Object.keys(t.fields),s=n.map(ze).join(", ")||"field",r=n.length===1?"field":"fields";return`Update ${t.entityType?ze(t.entityType).toLowerCase():"entity"} ${r}: ${s}`}function Zs(t,n){const s=Xe(n.fields);if(!s||Object.keys(s).length===0||n.action_key!=="entity_field_change"&&n.tool!=="entity_field_change")return null;const r=Xe(n.current)??{},a=t;return{fields:s,current:r,reason:typeof n.reason=="string"?n.reason:void 0,automationId:n.automation_id!=null?String(n.automation_id):void 0,automationName:typeof n.automation_name=="string"?n.automation_name:void 0,automationAgentId:typeof n.automation_agent_id=="string"?n.automation_agent_id:void 0,entityType:typeof n.entity_type=="string"?n.entity_type:void 0,entityName:(typeof n.entity_name=="string"?n.entity_name:void 0)??a.entity_name??void 0,entitySlug:typeof n.entity_slug=="string"?n.entity_slug:void 0,parentSlug:typeof n.parent_slug=="string"?n.parent_slug:void 0,parentEntityType:typeof n.parent_entity_type=="string"?n.parent_entity_type:void 0,attribution:typeof n.attribution=="string"?n.attribution:void 0,initiator:n.initiator&&typeof n.initiator=="object"?n.initiator:void 0}}function er(t){const n=t.entityType?ze(t.entityType).toLowerCase():"entity";return`${ze(t.operation)} ${n}`}function tr(t,n){if(n.action_key!=="entity_change"&&n.tool!=="entity_change")return null;const s=n.action;if(s!=="create"&&s!=="delete"&&s!=="link"&&s!=="unlink")return null;const r=t;return{operation:s,proposal:Xe(n.proposal),reason:typeof n.reason=="string"?n.reason:void 0,automationId:n.automation_id!=null?String(n.automation_id):void 0,automationName:typeof n.automation_name=="string"?n.automation_name:void 0,automationAgentId:typeof n.automation_agent_id=="string"?n.automation_agent_id:void 0,entityType:typeof n.entity_type=="string"?n.entity_type:void 0,entityName:(typeof n.entity_name=="string"?n.entity_name:void 0)??r.entity_name??void 0,entitySlug:typeof n.entity_slug=="string"?n.entity_slug:void 0,parentSlug:typeof n.parent_slug=="string"?n.parent_slug:void 0,parentEntityType:typeof n.parent_entity_type=="string"?n.parent_entity_type:void 0,attribution:typeof n.attribution=="string"?n.attribution:void 0,proposerRationale:typeof n.proposer_rationale=="string"?n.proposer_rationale:void 0,initiator:n.initiator&&typeof n.initiator=="object"?n.initiator:void 0}}function nr(t,n){return!n.entityType||!n.entitySlug?null:Ye(t,n.parentEntityType&&n.parentSlug?[{entity_type:n.parentEntityType,slug:n.parentSlug},{entity_type:n.entityType,slug:n.entitySlug}]:[{entity_type:n.entityType,slug:n.entitySlug}])}function Ut({ownerSlug:t,runId:n,details:s}){const a=Et(s.automationId,void 0,void 0,{ownerSlug:t,includeVersions:!1}).data?.automation,i=zt(s.initiator,s.attribution,s.automationId),l=a?.automation_name??s.automationName??i;return e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Requested by"," ",s.automationId?e.jsx(le,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:s.automationId},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:l}):e.jsx("span",{className:"font-medium text-foreground",children:l}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:" · "}),e.jsxs(le,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(n)},className:"font-medium text-foreground underline-offset-4 hover:underline",children:["Run #",n]})]})]})}function Vt({ownerSlug:t,details:n}){const s=nr(t,n);return n.entityName?e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Entity"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:s?e.jsx(le,{to:s,className:"underline-offset-4 hover:underline",children:n.entityName}):n.entityName})]}):null}function sr({ownerSlug:t,runId:n,details:s}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ut,{ownerSlug:t,runId:n,details:s}),e.jsx(Vt,{ownerSlug:t,details:s}),e.jsx("div",{className:"rounded-md border border-border/70 px-3 py-2",children:e.jsx(rt,{changes:Object.entries(s.fields).map(([r,a])=>({field:r,old:s.current[r]??null,new:a??null})),entityType:s.entityType,ownerSlug:t,showAll:!0})}),s.reason&&e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function rr({ownerSlug:t,runId:n,details:s,status:r}){const{operation:a}=s,i=a==="link"||a==="unlink";return e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ut,{ownerSlug:t,runId:n,details:s}),!i&&e.jsx(Vt,{ownerSlug:t,details:s}),e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Change"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:i?Pt(a,r):a==="create"?"Create a new entity after approval.":"Delete this entity after approval."}),i&&e.jsxs("div",{className:"mt-2 space-y-1 text-sm",children:[$t(s.proposal).map((l,m)=>e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:m===0?"From: ":"To: "}),l.name]},l.id)),e.jsxs("div",{className:"text-muted-foreground",children:["Relationship:"," ",String(s.proposal?.relationship_type??s.proposal?.relationship_type_slug??"Relationship")]})]})]}),!i&&s.proposal&&e.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Proposal"}),e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-xs leading-relaxed",children:JSON.stringify(s.proposal,null,2)})]}),s.proposerRationale&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:s.attribution==="agent"?"The agent's reasoning":"The Automation's reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.proposerRationale})]}),s.reason&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Why this needs approval"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:s.reason})]})]})}function ar({summary:t}){return e.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/30 p-3 text-sm",children:[t.chips.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.chips.map(n=>e.jsx(ce,{variant:"outline",className:"text-[10px] font-normal",children:n},n))}),t.message&&e.jsx("p",{className:"leading-relaxed text-foreground",children:t.message}),t.reason&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Why"}),e.jsx("div",{className:"mt-0.5 leading-relaxed",children:t.reason})]}),t.body&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t.kind==="verify"?"Expected comment":"Draft"}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed",children:t.body})]}),t.matchPreview&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsxs("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:["Matched comment",t.matchAuthor?` · ${t.matchAuthor}`:""]}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed text-muted-foreground",children:t.matchPreview})]}),t.postUrl&&e.jsxs("a",{href:t.postUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Open post",e.jsx(At,{className:"h-3 w-3"})]})]})}function ir({ownerSlug:t,content:n,batchReview:s}){const r=n.metadata||{},a=n.run_id??void 0,i=Zs(n,r),l=tr(n,r),m=(i?Ys(i):l?er(l):void 0)||r.operation_name||r.action_name||(n.title?Gs(n.title):void 0)||"Action",o=r.connection_name,c=r.operation_key||r.action_key||null,p=n.interaction_input_schema||r.input_schema||null,u=N.useMemo(()=>n.interaction_input||r.action_input||r.operation_input||Us,[n.interaction_input,r.action_input,r.operation_input]),h=n.interaction_output||r.action_output||void 0,v=ps(u,h??null,c),I=n.interaction_error||r.error_message||void 0,_=Bt(n.interaction_status,r.status),j=r.reviewed_by_name||r.reviewed_by_id||void 0,w=r.reject_reason||void 0,K=r.initiator,P=Sn({slug:t}),F=In({slug:t}),T=An(n.id,Rn(p,u),p),{values:g,setValues:B}=T,[k,D]=N.useState(null),[f,G]=N.useState(!1),[R,L]=N.useState(""),O=_==="pending_approval"&&k?k:_,A=O==="pending_approval",V=typeof r.source_run_id=="number";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kt,{className:"h-4 w-4 text-yellow-500"}),e.jsx("span",{className:"font-medium",children:m}),o&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["on ",o]}),O==="confirmed"&&e.jsx(ce,{variant:"outline",className:"text-blue-700 border-blue-300 bg-blue-50 dark:bg-blue-950/30 text-[10px]",children:"Approved"}),O==="completed"&&e.jsx(ce,{variant:"outline",className:"text-green-700 border-green-300 bg-green-50 dark:bg-green-950/30 text-[10px]",children:"Completed"}),O==="failed"&&e.jsx(ce,{variant:"outline",className:"text-red-700 border-red-300 bg-red-50 dark:bg-red-950/30 text-[10px]",children:"Failed"}),O==="rejected"&&e.jsx(ce,{variant:"outline",className:"text-muted-foreground text-[10px]",children:"Rejected"})]}),!i&&!l&&(n.author_name||j)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground",children:[n.author_name&&e.jsxs("span",{children:["Requested by"," ",e.jsx(Xs,{ownerSlug:t,initiator:K,clientName:n.author_name,fallback:n.author_name})]}),n.author_name&&j&&e.jsx("span",{children:"·"}),j&&e.jsxs("span",{children:[O==="rejected"?"Rejected":"Approved"," by"," ",e.jsx("span",{className:"font-medium text-foreground",children:j})]})]}),i&&e.jsx(sr,{ownerSlug:t,runId:a,details:i}),!i&&l&&e.jsx(rr,{ownerSlug:t,runId:a,details:l,status:O}),O==="rejected"&&w&&e.jsxs("div",{className:"rounded-md bg-muted/50 p-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"Reason:"})," ",w]}),v&&e.jsx(ar,{summary:v}),(A?T.revision:p)&&(A||Object.keys(u).length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:v?"Full input":"Input"}),A?e.jsxs(e.Fragment,{children:[e.jsx(En,{visible:T.hasConflict,onReload:T.reset}),e.jsx(Tn,{schema:T.revision,values:g,onValuesChange:B,fieldIdPrefix:`action-${n.id}-`},`action-${n.id}`)]}):v?e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw input"}),e.jsx("pre",{className:"mt-1 bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(u,null,2)})]}):e.jsx("pre",{className:"text-xs bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(u,null,2)})]}),O==="completed"&&h&&Object.keys(h).length>0&&!v&&e.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium",children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),"Output"]}),e.jsx("pre",{className:"text-xs text-green-800 dark:text-green-300 font-mono whitespace-pre-wrap",children:JSON.stringify(h,null,2)})]}),O==="completed"&&h&&Object.keys(h).length>0&&v&&e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw output"}),e.jsx("pre",{className:"mt-1 rounded bg-green-50 p-2 font-mono dark:bg-green-950/30 overflow-auto max-h-32",children:JSON.stringify(h,null,2)})]}),O==="failed"&&I&&e.jsxs("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-red-700 dark:text-red-400 font-medium",children:[e.jsx(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:I})]}),A&&!k&&V&&e.jsxs("div",{className:"pt-1 text-xs text-muted-foreground",children:["Review this proposal with the other changes in its Automation run.",s]}),A&&a&&!k&&!V&&e.jsx("div",{className:"flex items-center gap-2 pt-1",children:f?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"Reason (optional)",value:R,onChange:se=>L(se.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs(E,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>F.mutate({run_id:a,reason:R||void 0},{onSuccess:()=>{D("rejected")}}),disabled:F.isPending,children:[F.isPending&&e.jsx(Re,{size:"sm",className:"mr-1"}),"Confirm Reject"]}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{G(!1),L("")},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(E,{size:"sm",className:"h-7 text-xs",onClick:()=>P.mutate({run_id:a,input:Pn(g)},{onSuccess:()=>{D("confirmed")}}),disabled:!T.canSubmit||P.isPending||F.isPending,children:[P.isPending?e.jsx(Re,{size:"sm",className:"mr-1"}):e.jsx($n,{className:"h-3 w-3 mr-1"}),"Confirm"]}),e.jsxs(E,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>G(!0),disabled:P.isPending||F.isPending,children:[e.jsx(Fn,{className:"h-3 w-3 mr-1"}),"Reject"]})]})})]})}function or({content:t,ownerSlug:n}){const s=t.metadata||{},r=s.kind,a=t.run_id??null,i=typeof s.automation_id=="number"?s.automation_id:null,o=Et(i!=null?String(i):void 0,void 0,void 0,{includeVersions:!1,ownerSlug:n}).data?.automation?.automation_name??(i!=null?`Automation ${i}`:"An Automation"),c=kn({slug:n}),p=Cn({slug:n}),[u,h]=N.useState(!1),[v,I]=N.useState(""),[_,j]=N.useState(null);if(r==="automation_batch_reject"){const f=s.reason||void 0;return e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Proposals rejected"}),f&&e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:f}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Ask the agent to revise its proposals with this feedback."})]})}const w=Array.isArray(s.changes)?s.changes:[],K=typeof s.created_count=="number"?s.created_count:w.filter(f=>f.kind==="created").length,P=typeof s.updated_count=="number"?s.updated_count:w.filter(f=>f.kind==="updated").length,F=typeof s.denied_count=="number"?s.denied_count:w.filter(f=>f.kind==="denied").length,T=w.filter(f=>f.kind==="denied"),g=w.filter(f=>f.kind==="updated"&&Object.keys(f.applied||{}).length>0),B=typeof s.pending_proposal_count=="number"?s.pending_proposal_count:null,k=B==null||B>0,D=k?"proposed":"applied";return e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[e.jsxs("div",{className:"text-sm font-medium",children:[D==="proposed"?"Proposed":"Applied"," ",K," ","new + ",P," updated",F>0&&e.jsxs(e.Fragment,{children:[" + ",F," denied"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[i!=null?e.jsx(le,{to:"/$owner/automations/$automationId",params:{owner:n,automationId:String(i)},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:o}):e.jsx("span",{className:"font-medium text-foreground",children:o}),a!=null&&e.jsxs("span",{children:[" · run #",a]}),B!=null&&B>0&&e.jsxs("span",{children:[" · ",B," pending"]})]})]}),g.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:g.map(f=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:f.name}),e.jsx(rt,{changes:Object.entries(f.applied).map(([G,R])=>({field:G,old:R.old??null,new:R.new??null})),entityId:f.entityId,ownerSlug:n,showAll:!0})]},f.entityId))}),T.length>0&&e.jsx("div",{className:"mt-3 space-y-1.5",children:T.map(f=>e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-2.5 py-2",children:[e.jsxs("div",{className:"text-xs font-medium",children:[f.name," — not written"]}),f.denied&&e.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[f.denied.reason,e.jsxs("span",{className:"ml-1 opacity-70",children:["(refused by"," ",f.denied.source==="rule"?"a write rule":"org policy",")"]})]})]},`denied-${f.entityId}-${f.name}`))}),a!=null&&_==null&&k&&e.jsx("div",{className:"mt-3 border-t border-border/70 pt-3",children:u?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"What should the agent change?",value:v,onChange:f=>I(f.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs(E,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>p.mutate({run_id:a,reason:v||void 0},{onSuccess:()=>j("rejected")}),disabled:p.isPending,children:[p.isPending&&e.jsx(Re,{size:"sm",className:"mr-1"}),"Reject all"]}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{h(!1),I("")},children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(E,{size:"sm",className:"h-7 text-xs",onClick:()=>c.mutate({run_id:a},{onSuccess:()=>j("approved")}),disabled:c.isPending||p.isPending,children:[c.isPending&&e.jsx(Re,{size:"sm",className:"mr-1"}),"Approve all proposals"]}),e.jsx(E,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>h(!0),disabled:c.isPending||p.isPending,children:"Reject with feedback"})]})}),_==="approved"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals approved."}),_==="rejected"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Proposals rejected — ask the agent to revise them."}),a!=null&&_==null&&!k&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals reviewed."})]})}function Ie({presentation:t="summary",renderDetail:n,onFiltersChange:s,ownerSlug:r,content:a,isReply:i,showParentContext:l,connectorDefinitions:m,hideOriginator:o=!1,hideRunAction:c=!1,hideAttribution:p=!1,hideDetails:u=!1,recordId:h}){const[v,I]=N.useState(null),_=Nt(),j=t==="detail",w=Ze(),{currentOwner:K,allOrgs:P,isAuthenticated:F}=Rt(),T=r??K,g=T==="me"?null:T,B=N.useCallback(async y=>{if(!g){it.error("Open this event inside a workspace to interact with it.");return}const $=await us(g,Number(a.id),y,crypto.randomUUID());return"event_id"in $&&it.success("Recorded"),$},[a.id,g]),k=a.payload_data??{},{audit:D,operation:f,changeSet:G}=Mt(a),R=D&&(k.request!==void 0||k.request_status==="too_large"),L=D&&Array.isArray(k.sdk_call_trace)&&k.sdk_call_trace.length>0,O=T?ot(T,Number(a.id)):null,A=!j&&F?(P??[]).find(y=>y.slug===g):void 0,V=A?{slug:A.slug,organizationId:A.id}:null,se=gt(V??{slug:null,organizationId:null}),re=V?.slug??null,pe=N.useMemo(()=>re&&!D?yt(se.data??[],a.semantic_type):[],[re,D,se.data,a.semantic_type]),we=vn(),he=!!(!(f||G)&&V&&pe.length>0),Z=!j&&!!O,X=bn(w?.item?.href.split(/[?#]/)[0]??""),de=X?.owner===T&&X?.eventId===Number(a.id),ee=(y,$,z)=>{w?w.open({href:y,title:$,...z==null?{}:{runId:z}}):_({to:y})},ae=(y,$)=>{if(!g)return null;const z=`/${g}/events?run_ids=${y}`;return w?.item?.href===z?null:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>s?s({runIds:[y]}):ee(z,"Run activity",y),title:s?"Filter by this run":"Open run activity",children:[e.jsx(wn,{className:"h-3.5 w-3.5"}),$]})},fe=a.run_id!=null&&(s||!(w&&g&&a.automation_id!=null))?ae(a.run_id,s?"Run":"Open run"):null,Y=Nn(a),Q=a.automation_id,ke=w&&g&&Y!=null&&Q!=null?()=>w.open({href:`/${g}/automations/${Q}?run_id=${Y}`,title:`${a.automation_name??`Automation ${Q}`} · Run #${Y}`,runId:Y}):void 0,ge=()=>{if(he&&V&&g){const y=Number(a.id);cs(we,V.slug,pe,y).catch(()=>null).then($=>ee(ot(g,y,$?.key),a.title??"Event"));return}O&&ee(O,a.title??"Event")},ye=y=>{const $=y.target;if(!($ instanceof Element))return!1;const z=$.closest('a,button,input,select,textarea,[role="button"],[role="radio"]');return z!==null&&z!==y.currentTarget},ie=y=>{ye(y)||ge()},te=y=>{y.key!=="Enter"&&y.key!==" "||ye(y)||(y.preventDefault(),ge())},je=a.metadata?.source_run_id,H=Os(a),ve=j&&g?G?e.jsx(or,{content:a,ownerSlug:g}):f?e.jsx(ir,{ownerSlug:g,content:a,batchReview:typeof je=="number"?ae(je,"Review run"):null}):void 0:void 0,oe=j&&n?n(ve):{content:ve,nativeHeading:ve!=null};return e.jsx("div",{className:ue(i?"border-l-2 border-l-muted pl-4":"",Z&&"cursor-pointer rounded-lg p-3 transition-colors hover:bg-accent/40",Z&&de&&"bg-accent ring-1 ring-inset ring-primary/20"),...Z?{role:"button","aria-current":de?"true":void 0,tabIndex:0,onClick:ie,onKeyDown:te}:{},children:e.jsx(cr,{primaryContent:oe.content,nativeHeading:oe.nativeHeading,heading:H&&g?e.jsx(Bs,{event:H,recordId:h,ownerSlug:g}):void 0,body:H&&g?e.jsx(zs,{event:H,ownerSlug:g}):void 0,detailLinks:oe.links,headingAside:oe.headingAside,hideDetails:u,onFiltersChange:s,presentation:t,content:a,ownerSlug:T??void 0,showParentContext:l,connectorDefinitions:m,onRenderedAction:g?B:void 0,runAction:c?null:fe,hideOriginator:o,hideAttribution:p,runId:Y??a.run_id??null,onRunSelect:ke,auditDetails:j&&(R||L)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"request",label:"Request",available:R},{key:"calls",label:"SDK calls",available:L}].map(y=>y.available?e.jsxs(E,{variant:"outline",size:"sm","aria-expanded":v===y.key,onClick:()=>I($=>$===y.key?null:y.key),children:[v===y.key?e.jsx(Ne,{className:"h-3.5 w-3.5"}):e.jsx(_e,{className:"h-3.5 w-3.5"}),y.label]},y.key):null)}),v==="request"&&(k.request_status==="too_large"?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["The request was too large to retain",typeof k.request_bytes=="number"?` (${k.request_bytes.toLocaleString()} bytes).`:"."]}):e.jsx(xt,{value:k.request})),v==="calls"&&e.jsx(xt,{value:k.sdk_call_trace})]})})})}function lr(t,n){const s=t.payload_data??{},r=t.metadata??{};if(n.audit&&typeof s.success=="boolean")return s.success?"completed":"failed";if(n.changeSet)return r.kind==="automation_batch_reject"?"rejected":typeof r.pending_proposal_count!="number"?void 0:r.pending_proposal_count>0?"pending_approval":"completed";if(n.operation)return Bt(t.interaction_status,typeof r.status=="string"?r.status:void 0)}function dr(t){return t==="pending_approval"?"Needs approval":t==="confirmed"?"Approved":t?me(t):null}function cr({presentation:t,primaryContent:n,nativeHeading:s=!1,heading:r,body:a,detailLinks:i,headingAside:l,onFiltersChange:m,content:o,ownerSlug:c,showParentContext:p,connectorDefinitions:u,onRenderedAction:h,runAction:v,auditDetails:I,hideOriginator:_=!1,hideAttribution:j=!1,runId:w,onRunSelect:K,hideDetails:P=!1}){const[F,T]=N.useState(!1),g=o.metadata??{},B=typeof o.score=="number"&&Number.isFinite(o.score)?Math.round(o.score):"-",k=o.payload_type||"text",D=o.text_content||"",f=t==="summary",G=t==null&&(k==="text"||k==="markdown")&&D.length>500,R=G&&!F?`${D.slice(0,500)}...`:D,L=o.payload_data??{},O=Mt(o),{audit:A,operation:V,changeSet:se}=O,re=lr(o,O),pe=dr(re),we=f&&A&&typeof L.tool_name=="string"?me(L.tool_name):o.title,xe=A&&L.error&&typeof L.error=="object"?L.error.message:void 0,he=(typeof xe=="string"?xe:void 0)??o.interaction_error??(typeof g.error_message=="string"?g.error_message:void 0),Z=he||(A?"":D),[X,de]=N.useState(t!=="summary"&&A&&n==null&&i==null),ee=A?L.duration_ms:g.duration_ms,ae=typeof ee=="number"&&Number.isFinite(ee)&&ee>=0?ee:null,fe=A&&typeof L.sdk_call_count=="number"&&Number.isSafeInteger(L.sdk_call_count)&&L.sdk_call_count>=0?L.sdk_call_count:null,Y=g.thumbnail_url||g.thumbnail,Q=g.media_url,ke=f?[]:Ks(g),ge=Object.entries(o.classifications||{}).flatMap(([d,b])=>{const C=Ws(b);return C.values.map(J=>({slug:d,value:J,isManual:C.isManual}))}),ye=(()=>{const d=o.platform||(typeof g.platform=="string"?g.platform:null),b=o.connection_id!=null?o.connection_id:g.source_connection_id!=null?Number(g.source_connection_id):null;return{...o,platform:d,connection_id:b!=null&&Number.isFinite(b)?b:null}})(),ie=(()=>{const d=o.source_url??g.browser_url;if(typeof d!="string"||!URL.canParse(d))return null;const b=new URL(d);return b.protocol==="https:"||b.protocol==="http:"?b:null})(),te=o.occurred_at?new Date(o.occurred_at):null,je=A?wt:V?kt:se?cn:o.semantic_type==="notification"?un:mn,H=A?"SDK call":me(o.semantic_type||o.origin_type||"Event"),ve=e.jsx(_n,{platform:ye.platform,connectorDefinitions:u,sourceUrl:ie,label:H,fallback:e.jsx(je,{className:"h-4 w-4"})}),oe=ke.length>0?e.jsx("dl",{className:"grid gap-x-3 gap-y-2 text-sm sm:grid-cols-[minmax(140px,180px)_1fr]",children:ke.map(([d,b])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-muted-foreground",children:me(d)}),e.jsx("dd",{className:"min-w-0 break-words font-mono text-xs sm:text-sm",children:qs(b)})]},d))}):null,y=a?e.jsx("div",{className:"mt-1",children:a}):f?Z?e.jsx("p",{className:ue("line-clamp-2 text-sm whitespace-pre-wrap",he&&"text-destructive"),children:Z.slice(0,320)}):null:e.jsxs(e.Fragment,{children:[o.rating&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:[1,2,3,4,5].map(d=>e.jsx(Ct,{className:`h-4 w-4 ${d<=Number(o.rating)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},d))}),Y&&e.jsx("a",{href:Q||o.source_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block mb-2",children:e.jsx("img",{src:Y,alt:"",className:`rounded-md object-cover ${k==="media"?"max-h-96 w-full":"max-h-48"}`,loading:"lazy"})}),(()=>{switch(k){case"markdown":if(R)return e.jsx("div",{className:"max-w-none text-sm space-y-2",children:e.jsx(pn,{text:R})});break;case"json_template":{const d=o.payload_template;if(d?.root)return e.jsx(xs,{template:d,data:o.payload_data||{},onAction:n?void 0:h},`${c}:${o.id}`);if(R)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:R});break}case"media":return e.jsxs("div",{className:"space-y-3",children:[!Y&&Q&&e.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate block",children:Q}),R&&e.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:R})]});case"empty":return e.jsxs("div",{className:"space-y-3",children:[I,oe??(I?null:e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No content"}))]});default:if(R)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:R});break}return e.jsxs("div",{className:"space-y-3",children:[Q&&!Y&&e.jsx("a",{href:Q,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground truncate block",children:Q}),oe]})})()]}),$=n!=null||t==="detail"&&A,z=l!==void 0,x=$||i!=null;return N.useEffect(()=>{if(!z||!X)return;const d=b=>{b.key==="Escape"&&(b.preventDefault(),de(!1))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[z,X]),e.jsxs(e.Fragment,{children:[p&&o.parent_context&&e.jsxs("div",{className:"mb-3 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Replying to:"}),e.jsx("div",{className:"font-medium",children:o.parent_context.author_name}),e.jsx("div",{className:"text-muted-foreground line-clamp-2",children:o.parent_context.text_content})]}),e.jsxs("div",{className:ue("flex gap-3",t==="detail"&&"mb-5",z&&"relative"),children:[e.jsx(xn,{children:ve}),e.jsxs("div",{className:"min-w-0 flex-1",children:[t==="detail"&&(()=>{const d={semanticTypes:[o.semantic_type],...typeof o.automation_id=="number"?{producedByAutomationId:o.automation_id}:{},...typeof o.run_id=="number"?{runIds:[o.run_id]}:{}},b={semantic_types:o.semantic_type,...typeof o.automation_id=="number"?{produced_by:String(o.automation_id)}:{},...typeof o.run_id=="number"?{run_ids:String(o.run_id)}:{}};return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[o.semantic_type?m?e.jsx("button",{type:"button",className:"hover:underline",title:`Show all ${H} events`,onClick:()=>m(d),children:H}):c?e.jsx(le,{to:"/$owner/events",params:{owner:c},search:b,className:"hover:underline",title:`Show all ${H} events`,children:H}):e.jsx("span",{children:H}):e.jsx("span",{children:H}),te&&e.jsx("time",{dateTime:te.toISOString(),children:Ae(te)})]})})(),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[(r??we)&&!s&&e.jsx("h4",{className:ue("min-w-0 font-medium",t==="detail"?"text-xl leading-snug":"line-clamp-2 text-sm"),children:r??we}),t!=="detail"&&te&&e.jsx(hn,{at:te}),z&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pt-0.5",children:[l,x&&e.jsxs(E,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-muted-foreground hover:text-foreground","aria-expanded":X,onClick:()=>de(d=>!d),children:["Details",X?e.jsx(Ne,{className:"h-3.5 w-3.5"}):e.jsx(_e,{className:"h-3.5 w-3.5"})]})]})]}),f&&e.jsx("div",{className:"mt-1 text-muted-foreground",children:y}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[pe&&!s&&e.jsxs(ce,{variant:re==="failed"?"destructive":"secondary",className:"gap-1 text-xs",children:[re==="failed"?e.jsx(St,{className:"h-3 w-3"}):re==="completed"?e.jsx(tt,{className:"h-3 w-3"}):null,pe]}),fe!=null&&e.jsxs("span",{children:[fe," SDK ",fe===1?"call":"calls"]}),ae!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(It,{className:"h-3 w-3"}),ae<1e3?`${Math.round(ae)}ms`:`${Number((ae/1e3).toFixed(2))}s`]}),v,B==="-"||f&&(A||V||se)?null:o.score_breakdown?e.jsxs(fn,{children:[e.jsx(gn,{asChild:!0,children:e.jsx(E,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx("span",{className:"font-medium",children:B})})}),e.jsx(yn,{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(Js,{breakdown:o.score_breakdown})]})})]}):null,ie&&e.jsxs(jt,{children:[e.jsx(vt,{asChild:!0,children:e.jsx(E,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1",asChild:!0,children:e.jsxs("a",{href:ie.href,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(At,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:f?"sr-only":void 0,children:"View original"})]})})}),e.jsx(bt,{children:"View original"})]})]}),c&&!j&&e.jsx(jn,{owner:c,source:ye,connectorDefinitions:u,onFiltersChange:m,variant:"chips",className:"mt-2 text-xs",hideOriginator:_,runId:w,onRunSelect:K}),(o.author_name||!c)&&!(t==="detail"&&V)&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:o.author_name||Hs(o)})]}),z&&X&&x&&e.jsxs("div",{className:"absolute inset-x-0 top-full z-20 mt-2 max-h-[65vh] space-y-3 overflow-y-auto rounded-lg border bg-background p-3 shadow-lg",children:[i,$&&y]})]}),!f&&typeof xe=="string"&&e.jsx("p",{className:"mb-2 text-sm whitespace-pre-wrap text-destructive",children:xe}),n,!f&&!$&&y,($||i!=null)&&l===void 0&&!(P&&n!=null)&&e.jsxs("details",{className:"mt-5 border-t pt-3",open:X,onToggle:d=>de(d.currentTarget.open),children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Details"}),X&&e.jsxs("div",{className:"mt-3 space-y-3",children:[i,$&&y]})]}),G&&e.jsx(E,{variant:"link",size:"sm",className:"px-0 h-6 mt-1",onClick:()=>T(!F),children:F?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3 w-3 mr-1"})," Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-3 w-3 mr-1"})," Show more"]})}),ge.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:ge.map(d=>e.jsx(Qs,{slug:d.slug,value:d.value||"",isManual:d.isManual},d.slug))})]})}function ur({toolName:t,count:n,totalDurationMs:s,totalSdkCalls:r,newestAt:a,oldestAt:i,expanded:l,onToggle:m,children:o}){return e.jsx("div",{children:e.jsxs(De,{open:l,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(wt,{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(Le,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:m,children:[e.jsxs("span",{className:"min-w-0 truncate font-medium text-foreground",children:[me(t)," × ",n]}),l?e.jsx(Ne,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(Ht,{newestAt:a,oldestAt:i})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[e.jsxs(ce,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(tt,{className:"h-3 w-3"}),"Completed"]}),r!=null&&e.jsxs("span",{children:[r," SDK ",r===1?"call":"calls"]}),s!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(It,{className:"h-3 w-3"}),mr(s)]})]})]})]})}),e.jsx(Me,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:o})]})})}function mr(t){return t<1e3?`${Math.round(t)}ms`:`${Number((t/1e3).toFixed(2))}s`}function Ht({newestAt:t,oldestAt:n}){const s=ht(t),r=ht(n);return s!=null&&r!=null&&s.getTime()-r.getTime()>pr&&r?e.jsxs("time",{dateTime:s.toISOString(),title:`${Ae(r)} – ${Ae(s)}`,className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:[Fe(r,"HH:mm"),"–",Fe(s,"HH:mm")]}):s?e.jsx("time",{dateTime:s.toISOString(),title:Ae(s),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Fe(s,"HH:mm")}):null}const pr=300*1e3;function ht(t){if(t==null||t==="")return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:n}function xr({organizationId:t,clientId:n,activityId:s,activityKind:r,callCount:a,newestAt:i,oldestAt:l,expanded:m,onToggle:o,children:c}){const{data:p=[]}=On({limit:100,organizationId:t??null}),u=p.find(I=>I.activityId===s&&(n==null||I.clientId===n))??null,h=u?Zn(u):r==="session"?"MCP session":"Conversation",v=u?.clientName??null;return e.jsx("div",{children:e.jsxs(De,{open:m,children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background",children:e.jsx(Tt,{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(Le,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:o,children:[e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:h}),m?e.jsx(Ne,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(_e,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(Ht,{newestAt:i,oldestAt:l})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[`${a} ${a===1?"call":"calls"}`,v?` · ${v}`:null]})]})]})}),e.jsx(Me,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:c})]})})}function hr({onIntersect:t,enabled:n,rootMargin:s="400px"}){const r=N.useRef(null),a=N.useRef(t);return a.current=t,N.useEffect(()=>{const i=r.current;if(!i||!n)return;const l=new IntersectionObserver(m=>{m[0]?.isIntersecting&&a.current()},{rootMargin:s});return l.observe(i),()=>l.disconnect()},[n,s]),r}function ft(t){if(t==null||t==="")return null;const n=new Date(t);return Number.isNaN(n.getTime())?null:Fe(n,"d MMMM yyyy")}function fr({items:t,isLoading:n,emptyState:s,hasNextPage:r,isFetching:a,isFetchingNextPage:i,onLoadMore:l,autoLoadMore:m=!0,groupByDate:o=!0}){const c=hr({onIntersect:l,enabled:m&&r&&!a});return n&&t.length===0?e.jsx("div",{className:"space-y-4",children:["s1","s2","s3"].map(p=>e.jsx(Pe,{className:"h-32 rounded-lg"},p))}):e.jsxs("div",{children:[t.length===0?s!==void 0?s:e.jsx(Dn,{icon:Ln,title:"Nothing here yet",description:"No events match this view."}):t.map((p,u)=>{const h=ft(p.occurredAt),v=u>0?ft(t[u-1].occurredAt):null;return e.jsxs(N.Fragment,{children:[o&&h&&h!==v&&e.jsx("p",{className:"px-3 pb-2 pt-4 text-xs text-muted-foreground first:pt-0",children:h}),e.jsx("div",{className:"mb-1",children:p.content})]},p.key)}),e.jsx("div",{ref:c,className:"h-1"}),i?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(Re,{size:"xl",className:"text-muted-foreground"})}):r&&e.jsx(E,{size:"sm",variant:"outline",disabled:a,onClick:l,children:"Load more"})]})}function kr({presentation:t="summary",renderDetail:n,onFiltersChange:s,hideDetails:r=!1,organizationId:a,ownerSlug:i,entityId:l,filters:m,showEntityLinks:o=!1,hideOriginator:c=!1,emptyState:p,foldConsecutiveCalls:u=!1,groupByConversation:h=!1,groupByRun:v=!1,onRunSelect:I,runs:_,hideRunAction:j=!1,hideAttribution:w=!1,hiddenApprovalRunIds:K}){const{isAuthenticated:P,isReady:F}=Mn(),{isMember:T,isLoading:g}=Bn(),B=i==="me",k=!B&&F&&P&&T,D=!B&&F&&(!P||!g&&!T),{data:f=[]}=zn(F&&k?a:null),{data:G=[]}=Un(D?i:null),R=k?f:G,L=Vn(F&&k?a:null,l,m,i),O=Hn(D?i:null,l,m),A=D?O:L,{data:V,isLoading:se,error:re,fetchNextPage:pe,hasNextPage:we,isFetchingNextPage:xe}=A,he=N.useMemo(()=>V?.pages.flatMap(x=>x.content)??[],[V]),Z=N.useMemo(()=>{const x=qn(he,{foldRunSatellites:!v}),d=x.map(q=>q.head),b=new Map(x.map(q=>[q.head.id,q])),C=Kn(d,{groupByRun:v}),J=Array.from(C.entries()).map(([q,M])=>{const W=M.root||M.replies[0],Ce=W?b.get(W.id):void 0;return{rootId:q,group:M,history:Ce?.history??[],runId:Ce?.runId??null}});return K?Jn(J,K):J},[he,v,K]),[X,de]=N.useState(new Set),[ee,ae]=N.useState(new Set),[fe,Y]=N.useState(new Set),[Q,ke]=N.useState(new Set),[ge,ye]=N.useState(new Set),ie=(x,d)=>x(b=>{const C=new Set(b);return C.has(d)?C.delete(d):C.add(d),C}),te=(x,d)=>d.some(b=>x.has(b)),je=(x,d)=>x(b=>{const C=new Set(b),J=d.some(q=>C.has(q));for(const q of d)J?C.delete(q):C.add(q);return C}),H=u?Qn(Z):Z.map(x=>({kind:"single",node:x})),ve=h?Wn(H):H,oe=!B&&(!F||P&&g||k&&A.isPending);if(re)return e.jsx(Gn,{label:"events"});const y=x=>{if(x.kind==="fold"){const{fold:S}=x,at=S.nodes.map(Ue=>Ue.rootId),Jt=te(ee,at);return[{key:S.key,occurredAt:S.newestAt,content:e.jsx(ur,{toolName:S.toolName,count:S.nodes.length,totalDurationMs:S.totalDurationMs,totalSdkCalls:S.totalSdkCalls,newestAt:S.newestAt,oldestAt:S.oldestAt,expanded:Jt,onToggle:()=>je(ae,at),children:S.nodes.map(Ue=>{const Ve=Ue.group.root;return Ve?e.jsx(Ie,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:Ve,renderDetail:n,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w,hideDetails:r},Ve.id):null})})}]}const{rootId:d,group:b,history:C,runId:J}=x.node,q=b.replies.length>0,M=X.has(d),W=ge.has(d),Ce=Q.has(d),qt=b.replies.filter(S=>S.depth<=3),Ee=b.replies.filter(S=>S.depth>3),Kt=!b.root&&b.replies.length>0,ne=b.root||b.replies[0];return ne?[{key:d,occurredAt:ne.occurred_at,content:e.jsxs(e.Fragment,{children:[o&&i&&ne.entity_name&&ne.entity_type&&ne.entity_slug&&e.jsx("div",{className:"mb-2",children:e.jsx(ds,{ownerSlug:i,entity:{entityName:ne.entity_name,entityType:ne.entity_type,entitySlug:ne.entity_slug}})}),e.jsx(Ie,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:ne,renderDetail:n,showParentContext:Kt&&!!ne.parent_context,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w,hideDetails:r}),C.length>0&&e.jsxs(De,{open:Ce,children:[e.jsx(Le,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"mt-1 h-7 gap-1 text-xs text-muted-foreground",onClick:()=>ie(ke,d),children:[e.jsx(Yn,{className:"h-3.5 w-3.5"}),Ce?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Hide ",J!=null?`run #${J} `:"","history"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),J!=null?`Run #${J} · ${C.length===1?"1 earlier step":`${C.length} earlier steps`}`:C.length===1?"1 earlier state":`${C.length} earlier states`]})]})}),e.jsx(Me,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:C.map(S=>e.jsxs("div",{children:[e.jsx("time",{dateTime:new Date(S.occurred_at).toISOString(),title:Ae(S.occurred_at),className:"mb-1 block text-xs text-muted-foreground",children:lt(S.occurred_at)}),e.jsx(Ie,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:S,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w})]},S.id))})]}),q&&e.jsxs(De,{open:M,children:[e.jsx(Le,{asChild:!0,children:e.jsxs(E,{variant:"ghost",size:"sm",className:"mt-2 ml-6 gap-1",onClick:()=>ie(de,d),children:[e.jsx(He,{className:"h-3.5 w-3.5"}),M?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),"Hide ",b.replies.length," replies"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),"Show ",b.replies.length," replies"]})]})}),e.jsxs(Me,{className:"space-y-2 mt-2",children:[qt.map(S=>e.jsx(Ie,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:S,isReply:!0,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w},S.id)),Ee.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"ghost",size:"sm",className:"ml-12",onClick:()=>ie(ye,d),children:W?e.jsxs(e.Fragment,{children:["Hide ",Ee.length," nested replies"]}):e.jsxs(e.Fragment,{children:["Show ",Ee.length," nested replies"]})}),W&&Ee.map(S=>e.jsx(Ie,{presentation:t,recordId:l,onFiltersChange:s,ownerSlug:i,content:S,isReply:!0,connectorDefinitions:R,hideOriginator:c,hideRunAction:j,hideAttribution:w},S.id))]})]})]})]})}]:[]},$=x=>{const d=x.nodes.length;return{key:x.key,occurredAt:x.newestAt,content:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[I?e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1 text-xs font-medium",onClick:()=>I(x.runId),title:`Open run #${x.runId} conversation`,children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Run #",x.runId]}):e.jsxs("span",{className:"inline-flex h-7 items-center gap-1 px-1 text-xs font-medium",children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Run #",x.runId]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[x.status!=null?`· ${me(x.status)} · `:"· ",d===1?"1 event":`${d} events`,x.newestAt!=null?` · ${lt(x.newestAt)}`:""]})]}),e.jsx("div",{className:"mt-2 space-y-2 border-l-2 border-l-muted pl-4",children:x.nodes.flatMap(b=>y({kind:"single",node:b}).map(C=>e.jsx(N.Fragment,{children:C.content},C.key)))})]})}},z=x=>{const{block:d}=x,b=d.entries.flatMap(M=>M.kind==="fold"?M.fold.nodes.map(W=>W.rootId):[M.node.rootId]),C=te(fe,b),J=d.entries.flatMap(M=>y(M).map(W=>({key:W.key,content:W.content})));if(J.length===0)return[];const q=d.entries.reduce((M,W)=>M+(W.kind==="fold"?W.fold.nodes.length:1),0);return[{key:d.key,occurredAt:d.newestAt,content:e.jsx(xr,{organizationId:a,clientId:d.clientId,activityId:d.activityId,activityKind:d.activityKind,callCount:q,newestAt:d.newestAt,oldestAt:d.oldestAt,expanded:C,onToggle:()=>je(Y,b),children:J.map(M=>e.jsx(N.Fragment,{children:M.content},M.key))})}]};return e.jsx(fr,{groupByDate:t==="summary",isLoading:se||oe,emptyState:p,hasNextPage:!!we,isFetching:A.isFetching,isFetchingNextPage:xe,onLoadMore:()=>void pe(),items:v?Xn(Z,_).map(x=>"nodes"in x?$(x):y({kind:"single",node:x})[0]).filter(x=>x!=null):ve.flatMap(x=>x.kind==="context"?z(x):y(x))})}export{kr as E,wr as L,bs as R,vs as S,fr as a,cr as b,br as c,_r as d,hs as i,_s as l,gs as s,Nr as u};
|
|
2
|
-
//# sourceMappingURL=events-feed-DsrkV2ix.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iO as t,j as r}from"./index-DYCqXaMf.js";import{a as i}from"./agents-workbench-CqaKGggb.js";import"./agent-editor-form-Bi6WvYX-.js";import"./model-selector-TQcA93xm.js";import"./proposal-review-shell-DsNiavG_.js";function c(){const{owner:o,agentId:e}=t.useParams(),n=t.useSearch();return r.jsx(i,{owner:o,agentId:e,tab:"identity",runId:n.run_id})}export{c as component};
|
|
2
|
-
//# sourceMappingURL=identity-B0nH4yiC.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aq as s,ar as m,j as o}from"./index-DYCqXaMf.js";import{A as n}from"./activity-route-view-CFLNukhD.js";import{E as p}from"./events-feed-DsrkV2ix.js";import"./record-activity-C9KfBkXb.js";import"./filter-editors-B1_QUpg_.js";import"./connection-label-BobuYiAG.js";import"./source-record-panels-Cg249m1S.js";import"./clients-L4K1UT8c.js";import"./client-rows--FrZfJol.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./agent-loading-shells-De_2d8Lr.js";import"./member-scope-gate-B2LrMWBU.js";import"./public-shell-ready-B2NUI89V.js";import"./conversations-table-BSznfdYt.js";function A(){const{owner:r}=s.useParams(),e=s.useSearch();if(r==="me"){const t=m(e),i={sortBy:"date",sortOrder:"desc",...t.contentIds?.length?{contentIds:t.contentIds}:{clientIds:t.clientIds,mcpActivityId:t.mcpActivityId}};return o.jsxs("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 px-4 pt-2.5 pb-8 lg:px-6",children:[o.jsx("h1",{className:"text-lg font-semibold",children:"Your MCP activity"}),o.jsx(p,{organizationId:null,ownerSlug:"me",filters:i})]})}return o.jsx(n,{owner:r,search:e})}export{A as component};
|
|
2
|
-
//# sourceMappingURL=index-4TSkcsth.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{ic as n,j as o,ai as r}from"./index-DYCqXaMf.js";import{A as a}from"./agent-connect-pages-CAV-yXus.js";import"./agent-client-setup-list-BA8dU_C6.js";import"./clients-L4K1UT8c.js";import"./client-rows--FrZfJol.js";function g(){const{owner:t}=n.useParams();return o.jsx(r,{owner:t,children:({ownerSlug:e})=>o.jsx(a,{owner:e})})}export{g as component};
|
|
2
|
-
//# sourceMappingURL=index-BgkhXElB.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iR as r,j as e}from"./index-DYCqXaMf.js";import{A as i}from"./agent-skills-route-DcK41PWj.js";import"./agent-subpage-shell-BBJoyTuC.js";import"./agent-skill-context-JLaTamGR.js";import"./core.esm-Dr7tcIB-.js";import"./skill-editor-D_W3QlRz.js";import"./agent-loading-shells-De_2d8Lr.js";import"./agent-card-controls-Be1Okb2C.js";function l(){const{owner:t,agentId:o}=r.useParams();return e.jsx(i,{owner:t,agentId:o})}export{l as component};
|
|
2
|
-
//# sourceMappingURL=index-CoW4Bz3w.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{v as t,j as i}from"./index-DYCqXaMf.js";import{A as m}from"./activity-route-view-CFLNukhD.js";import"./record-activity-C9KfBkXb.js";import"./filter-editors-B1_QUpg_.js";import"./connection-label-BobuYiAG.js";import"./source-record-panels-Cg249m1S.js";import"./events-feed-DsrkV2ix.js";import"./conversations-table-BSznfdYt.js";import"./clients-L4K1UT8c.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./client-rows--FrZfJol.js";import"./agent-loading-shells-De_2d8Lr.js";import"./member-scope-gate-B2LrMWBU.js";import"./public-shell-ready-B2NUI89V.js";function y(){const{owner:o}=t.useParams(),r=t.useSearch();return i.jsx(m,{owner:o,search:r})}export{y as component};
|
|
2
|
-
//# sourceMappingURL=index-Codw-Qqi.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{bm as t,j as m,bn as p}from"./index-DYCqXaMf.js";import{M as i}from"./memory-browse-page-Cjpl8EbB.js";import"./public-shell-ready-B2NUI89V.js";import"./entity-type-page-89RoK_-P.js";import"./json-diff-DFvYINBT.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./code-editor-U54Gwjit.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./entity-avatar-Cc1CuI-0.js";import"./filter-editors-B1_QUpg_.js";import"./core.esm-Dr7tcIB-.js";import"./view-param-filters-DMSqkN2J.js";import"./app-bridge-BCm4muqj.js";import"./member-scope-gate-B2LrMWBU.js";function d(){const{owner:o,entityType:r}=t.useParams(),{create:e}=t.useSearch();return m.jsx(i,{ownerSlug:o,typeScope:p(r),create:e??!1})}export{d as component};
|
|
2
|
-
//# sourceMappingURL=index-DMyXd3bJ.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{as as r,j as e}from"./index-DYCqXaMf.js";import{M as m}from"./memory-browse-page-Cjpl8EbB.js";import"./public-shell-ready-B2NUI89V.js";import"./entity-type-page-89RoK_-P.js";import"./json-diff-DFvYINBT.js";import"./index-CDz3-ieP.js";import"./index-Vcq4gwWv.js";import"./code-editor-U54Gwjit.js";import"./schema-value-normalization-CylKX3PK.js";import"./card-yU0TmNRH.js";import"./entity-avatar-Cc1CuI-0.js";import"./filter-editors-B1_QUpg_.js";import"./core.esm-Dr7tcIB-.js";import"./view-param-filters-DMSqkN2J.js";import"./app-bridge-BCm4muqj.js";import"./member-scope-gate-B2LrMWBU.js";function M(){const{owner:t}=r.useParams(),o=r.useSearch();return e.jsx(m,{ownerSlug:t,create:!1,createType:o.create_type==="true"})}export{M as component};
|
|
2
|
-
//# sourceMappingURL=index-DYYZLcJ0.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iT as o,j as e}from"./index-DYCqXaMf.js";import{A as n}from"./agent-guardrails-route-DMOjG1D4.js";import"./model-selector-TQcA93xm.js";import"./agent-subpage-shell-BBJoyTuC.js";import"./agent-loading-shells-De_2d8Lr.js";import"./agent-card-controls-Be1Okb2C.js";function x(){const{owner:r,agentId:t}=o.useParams();return e.jsx(n,{owner:r,agentId:t})}export{x as component};
|
|
2
|
-
//# sourceMappingURL=index-DneshLbf.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iN as e,j as r}from"./index-DYCqXaMf.js";import{a as n}from"./agents-workbench-CqaKGggb.js";import"./agent-editor-form-Bi6WvYX-.js";import"./model-selector-TQcA93xm.js";import"./proposal-review-shell-DsNiavG_.js";function u(){const{owner:o,agentId:t}=e.useParams();return r.jsx(n,{owner:o,agentId:t,tab:"models"})}export{u as component};
|
|
2
|
-
//# sourceMappingURL=models-D7aED5Sa.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iL as t,j as r}from"./index-DYCqXaMf.js";import{a as s}from"./agents-workbench-CqaKGggb.js";import"./agent-editor-form-Bi6WvYX-.js";import"./model-selector-TQcA93xm.js";import"./proposal-review-shell-DsNiavG_.js";function g(){const{owner:o,agentId:e}=t.useParams(),n=t.useSearch();return r.jsx(s,{owner:o,agentId:e,tab:"settings",runId:n.run_id})}export{g as component};
|
|
2
|
-
//# sourceMappingURL=settings-DgX1-xo7.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iK as r,j as t,O as s}from"./index-DYCqXaMf.js";import{A as e}from"./agent-skill-context-JLaTamGR.js";import"./core.esm-Dr7tcIB-.js";import"./skill-editor-D_W3QlRz.js";function p(){const{agentId:o}=r.useParams();return t.jsx(e,{agentId:o,children:t.jsx(s,{})})}export{p as component};
|
|
2
|
-
//# sourceMappingURL=skills-Drw5tcZw.js.map
|