@lobu/runtime-server 24.8.0 → 24.9.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 +83 -6
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +6 -2
- package/dist/connectors/github.ts +16 -3
- package/dist/connectors/market_quotes.ts +388 -91
- package/dist/connectors/postgres.ts +21 -14
- package/dist/connectors/x-dm-adapter.js +55 -21
- package/dist/connectors/x.ts +1 -1
- package/dist/db/migrations/20261109010000_workspace_navigation.sql +14 -0
- package/dist/db/migrations/20261110010000_view_resources.sql +11 -0
- package/dist/dependencies.bun.lock +61 -61
- package/dist/owletto/dist/assets/_-B2C9B2RM.js +2 -0
- package/dist/owletto/dist/assets/_-CjyiGzwB.js +3 -0
- package/dist/owletto/dist/assets/_agentId-DKHXGvS2.js +2 -0
- package/dist/owletto/dist/assets/_agentId-bna2tPsW.js +2 -0
- package/dist/owletto/dist/assets/_automationId-CowRFD4E.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-dE6im18z.js +2 -0
- package/dist/owletto/dist/assets/{_connectorKey.index-DM5MTO8c.js → _connectorKey.index-DqwSv8Zs.js} +2 -2
- package/dist/owletto/dist/assets/{_conversationId-OJrZjd0o.js → _conversationId-zcs-S3dY.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-BVOVizs4.js +2 -0
- package/dist/owletto/dist/assets/_owner-DsvIC94q.js +3 -0
- package/dist/owletto/dist/assets/_shape-CWjpzcvv.js +2 -0
- package/dist/owletto/dist/assets/_slug-DuCxYsJk.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-BqVeHB6Z.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-DzyOCG5U.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-BC-ZIsrf.js → accept-invitation-k1u3zBcn.js} +2 -2
- package/dist/owletto/dist/assets/activity-route-view-jTBMW7a9.js +2 -0
- package/dist/owletto/dist/assets/{agent-connect-pages-CdDjrHjn.js → agent-connect-pages-D3mVM_q4.js} +4 -4
- package/dist/owletto/dist/assets/{agent-editor-form-CDAHRNWl.js → agent-editor-form-Bnc_q5WD.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-BupiSjR-.js → agent-loading-shells-xteN-pyK.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-ju7L2M0l.js → agent-permissions-matrix-C_ayr0pd.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-B0ZYVE3n.js → agent-skill-context-r0O0BVOu.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-ByU0xhXn.js → agent-subpage-shell-C2KpYdu3.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-DiVKn1WX.js → agent-thread-Bv_chdPy.js} +3 -3
- package/dist/owletto/dist/assets/{app._appId-BQWElSoP.js → app._appId-BUcNaSMS.js} +2 -2
- package/dist/owletto/dist/assets/{assist-composer-igTXq3DL.js → assist-composer-B1LykXpD.js} +2 -2
- package/dist/owletto/dist/assets/automation-run-now-CjkJIkaZ.js +2 -0
- package/dist/owletto/dist/assets/{callback-Dmaio9CX.js → callback-kSLa4n5s.js} +2 -2
- package/dist/owletto/dist/assets/{card-rE4Ctuy6.js → card-C01y1O-W.js} +2 -2
- package/dist/owletto/dist/assets/{claim-BN17CPYh.js → claim-Dnux9Lqf.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-B7xVaUA-.js → client-activity-scopes-BBIq16tG.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-B3LULJxW.js → client-rows-DGh1O-Fu.js} +2 -2
- package/dist/owletto/dist/assets/{clients-CydgUHrc.js → clients-BCvjAJDT.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-UppEMWpt.js → code-editor-BdRMYojw.js} +2 -2
- package/dist/owletto/dist/assets/connect-DZeFSGIH.js +2 -0
- package/dist/owletto/dist/assets/connect-menu-D4w-JhJW.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-IZEMQJ64.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId-CaF-ZWlZ.js → connected._clientId-BsDzltNz.js} +2 -2
- package/dist/owletto/dist/assets/{connection-D8ZAMHBT.js → connection-C7glVpPE.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-CJYqryAV.js → connection-feed-detail-CJju0qiw.js} +2 -2
- package/dist/owletto/dist/assets/{connector-page-shell-C23dWdKz.js → connector-page-shell-BeuyjiB2.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-CW4CXtCz.js → connector-provenance-B2C2cjBg.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-Bp08_KPq.js → connectors-DSQ5AWPf.js} +2 -2
- package/dist/owletto/dist/assets/{consent-_PpYI1cT.js → consent-B6Aw_89N.js} +2 -2
- package/dist/owletto/dist/assets/{copy-button-1ALlvZU1.js → copy-button-BhXeXLIm.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-6koO33th.js → core.esm-CJUp2aNZ.js} +3 -3
- package/dist/owletto/dist/assets/create-CWcza8NT.js +2 -0
- package/dist/owletto/dist/assets/{create-kUevP9Xx.js → create-DUlRsFNn.js} +2 -2
- package/dist/owletto/dist/assets/{create-automation-form-BhujNbRr.js → create-automation-form-D141prEG.js} +3 -3
- package/dist/owletto/dist/assets/{create-Drx9tcnG.js → create-bGOYifof.js} +2 -2
- package/dist/owletto/dist/assets/create._connectorKey-Ds4tpwHP.js +2 -0
- package/dist/owletto/dist/assets/{custom-guardrail-edits-B_aCgvoZ.js → custom-guardrail-edits-DuQ28xv3.js} +2 -2
- package/dist/owletto/dist/assets/{definition-comparison-3zKUSTt8.js → definition-comparison-BUDNuAN_.js} +2 -2
- package/dist/owletto/dist/assets/{detail-page-skeleton-BmxqqIsH.js → detail-page-skeleton-BRHaq5Sj.js} +2 -2
- package/dist/owletto/dist/assets/{device-D2eUt_nr.js → device-D3fzoIrM.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-BFPbTM_o.js → device-pin-tombstone-BIM-ziCH.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-Dqtmb1Xp.js → device._deviceId-BnPqTgK1.js} +2 -2
- package/dist/owletto/dist/assets/{dynamic-schema-form-D3KnzCsW.js → dynamic-schema-form-OkIZImgp.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-CpeX7iiX.js +2 -0
- package/dist/owletto/dist/assets/entity-page-Cjc8oXA2.js +2 -0
- package/dist/owletto/dist/assets/{entity-pages-DJNSQrfB.js → entity-pages-18xSANrS.js} +2 -2
- package/dist/owletto/dist/assets/entity-schema-graph-uwZ-P0t8.js +2 -0
- package/dist/owletto/dist/assets/{entity-type-page-CouHZbc9.js → entity-type-page-MgZ7_0oh.js} +2 -2
- package/dist/owletto/dist/assets/event-detail-D6AH6a2C.js +2 -0
- package/dist/owletto/dist/assets/events-feed-BI7wNRUY.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-DDTwyYt0.js +3 -0
- package/dist/owletto/dist/assets/{full-page-spinner-B7A6Ycyi.js → full-page-spinner-DWo519BU.js} +2 -2
- package/dist/owletto/dist/assets/index-9tTjJo_J.css +1 -0
- package/dist/owletto/dist/assets/{index-B-dZruj6.js → index-BW7IFKXC.js} +2 -2
- package/dist/owletto/dist/assets/{index-C7QM3aqU.js → index-BYcFrinP.js} +2 -2
- package/dist/owletto/dist/assets/index-BhJsTy-C.js +2 -0
- package/dist/owletto/dist/assets/index-CEcsgXDj.js +2 -0
- package/dist/owletto/dist/assets/index-CPscKk2u.js +2 -0
- package/dist/owletto/dist/assets/{index-DXfYVs5m.js → index-Cd8jMsz8.js} +2 -2
- package/dist/owletto/dist/assets/index-CdDNNAx2.js +7906 -0
- package/dist/owletto/dist/assets/index-CfJ2-EpK.js +2 -0
- package/dist/owletto/dist/assets/{index-BztXeLBN.js → index-D1UCJQl1.js} +2 -2
- package/dist/owletto/dist/assets/index-D5DM4g2w.js +2 -0
- package/dist/owletto/dist/assets/index-DmqnKGqW.js +2 -0
- package/dist/owletto/dist/assets/index-DznAbTOF.js +2 -0
- package/dist/owletto/dist/assets/{json-diff-CJK-gzCt.js → json-diff-C-WQqyIf.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-bQAZ0hQp.js → list-skeleton-0B1bTrAK.js} +2 -2
- package/dist/owletto/dist/assets/{login-DLqL54Rk.js → login-CH7P2AyR.js} +2 -2
- package/dist/owletto/dist/assets/{logout-H0F3IfiO.js → logout-D474YsYQ.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-Doic_6qX.js → member-scope-gate-CH_0jHiM.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-Ba4aYavw.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-BrfaDwIg.js → model-selector-XYmk7Iru.js} +2 -2
- package/dist/owletto/dist/assets/needs-you-list-Bd4iiiqm.js +2 -0
- package/dist/owletto/dist/assets/new-BOsrRqp8.js +2 -0
- package/dist/owletto/dist/assets/{new-5GkxlOuQ.js → new-CJ6TF3Vc.js} +2 -2
- package/dist/owletto/dist/assets/{new-BiA4DGoN.js → new-DGPOjak2.js} +2 -2
- package/dist/owletto/dist/assets/new-Q0XqiZq2.js +2 -0
- package/dist/owletto/dist/assets/{organization-CLrcmgNK.js → organization-hD_Z6TSd.js} +2 -2
- package/dist/owletto/dist/assets/peek-pane-content-Cc8YX1oy.js +2 -0
- package/dist/owletto/dist/assets/{pending-seed-DYYOoCvj.js → pending-seed-D7-ld7as.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-BVwOMoq9.js → proposal-review-shell-BWRJidwb.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-CRyAZATw.js +2 -0
- package/dist/owletto/dist/assets/record-activity-9ux6SfCd.js +2 -0
- package/dist/owletto/dist/assets/{record-session-KuEDuF3S.js → record-session-ClKBr1_C.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-ucwCQmBk.js → renderer-DZ0w2k2r.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-BkiAmXZW.js → reset-password-D2RfrEVZ.js} +2 -2
- package/dist/owletto/dist/assets/{run-initiator-8vdkq-3o.js → run-initiator-B8IRlRd-.js} +2 -2
- package/dist/owletto/dist/assets/runs-CuC7WMtd.js +2 -0
- package/dist/owletto/dist/assets/runs-list-8gUPWjP4.js +2 -0
- package/dist/owletto/dist/assets/{schema-value-CefbtPIY.js → schema-value-k19Ata7u.js} +3 -3
- package/dist/owletto/dist/assets/scoped-feed-bar-L7h-Ca4u.js +2 -0
- package/dist/owletto/dist/assets/{settings-DvzkRYQy.js → settings-BZqntV3E.js} +2 -2
- package/dist/owletto/dist/assets/{source-record-panels-LJIWGtHb.js → source-record-panels-C4UItfdk.js} +2 -2
- package/dist/owletto/dist/assets/{status-variants-BxHtpMOj.js → status-variants-BR_iGWN5.js} +2 -2
- package/dist/owletto/dist/assets/subDays-hOwerOLo.js +2 -0
- package/dist/owletto/dist/assets/{table-1O-ik4_O.js → table-C3DMoL4K.js} +2 -2
- package/dist/owletto/dist/assets/use-automations-CdtiVLCv.js +2 -0
- package/dist/owletto/dist/assets/{use-login-redirect-CfCbEeJR.js → use-login-redirect-CYlVkAhE.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-CA-evCDf.js → use-mention-search-CtbixPEE.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-BdN8OU35.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-BerT4Z1d.js → views-access-required-CvIIxdS_.js} +2 -2
- package/dist/owletto/dist/index.html +19 -12
- package/dist/server-main.bundle.mjs +4245 -2432
- package/npm-shrinkwrap.json +328 -328
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +23 -2
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/classify-error.d.ts +3 -4
- package/vendor/core/dist/classify-error.js +8 -8
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
- package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +39 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +11 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
- package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
- package/vendor/core/dist/contracts/tools/navigation.js +284 -0
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
- package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
- package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
- package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
- package/vendor/core/dist/contracts/tools/view-host.js +28 -1
- package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
- package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
- package/vendor/core/dist/errors.d.ts +17 -24
- package/vendor/core/dist/errors.js +17 -24
- package/vendor/core/dist/types.d.ts +0 -6
- package/vendor/core/package.json +11 -1
- package/vendor/views/dist/api.d.ts +30 -5
- package/vendor/views/dist/api.js +22 -8
- package/vendor/views/dist/bridge.d.ts +17 -0
- package/vendor/views/dist/bridge.js +49 -1
- package/vendor/views/dist/components.d.ts +27 -5
- package/vendor/views/dist/components.js +57 -7
- package/vendor/views/dist/embed.d.ts +98 -0
- package/vendor/views/dist/embed.js +418 -0
- package/vendor/views/dist/index.d.ts +3 -1
- package/vendor/views/dist/index.js +1 -0
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-B0tmXZ86.js +0 -2
- package/dist/owletto/dist/assets/_-DwXULq4r.js +0 -3
- package/dist/owletto/dist/assets/_agentId-B1dNkhnr.js +0 -2
- package/dist/owletto/dist/assets/_agentId-sYjvnBaB.js +0 -2
- package/dist/owletto/dist/assets/_automationId-Bnw_CnT_.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-D7Z8DQ-B.js +0 -2
- package/dist/owletto/dist/assets/_eventId-CfB0_2zK.js +0 -2
- package/dist/owletto/dist/assets/_owner-BDvTUY0a.js +0 -3
- package/dist/owletto/dist/assets/_shape-BZidoJMB.js +0 -2
- package/dist/owletto/dist/assets/_slug-R989vOiM.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BDUSrpe5.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BnFqh5-t.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-CN2dOiCD.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-BJwRU6qT.js +0 -2
- package/dist/owletto/dist/assets/connect-OdHpIVV9.js +0 -2
- package/dist/owletto/dist/assets/connect-menu-B9u86bb2.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-EI1tcdSE.js +0 -2
- package/dist/owletto/dist/assets/connector-boxes-BWPXijAk.js +0 -2
- package/dist/owletto/dist/assets/create-DULVO0HS.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-N6fhcIPy.js +0 -2
- package/dist/owletto/dist/assets/entity-options-IUdQ-64R.js +0 -2
- package/dist/owletto/dist/assets/entity-page-B3Im65EI.js +0 -2
- package/dist/owletto/dist/assets/event-detail-CvaRN1qB.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DwOkLk6A.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-DQ5V4Cvh.js +0 -2
- package/dist/owletto/dist/assets/home-stream-Bg97PUBJ.js +0 -2
- package/dist/owletto/dist/assets/home-toolbar-CpCcHA6z.js +0 -2
- package/dist/owletto/dist/assets/index-9PGnv4-5.js +0 -2
- package/dist/owletto/dist/assets/index-C2TCKJDP.js +0 -7901
- package/dist/owletto/dist/assets/index-CWn46a4y.js +0 -2
- package/dist/owletto/dist/assets/index-CxJONizf.js +0 -2
- package/dist/owletto/dist/assets/index-DJhb3li3.js +0 -2
- package/dist/owletto/dist/assets/index-DY-YGnCe.js +0 -2
- package/dist/owletto/dist/assets/index-j3v7ITPb.js +0 -2
- package/dist/owletto/dist/assets/index-oiy6ygaI.js +0 -2
- package/dist/owletto/dist/assets/index-pEgtAY1t.js +0 -2
- package/dist/owletto/dist/assets/index-xAvK3IyQ.css +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-CUea2Llz.js +0 -74
- package/dist/owletto/dist/assets/new-M-MX_T5C.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-B29OcHwm.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-BbjPgh3k.js +0 -2
- package/dist/owletto/dist/assets/record-activity-BCpNKaUo.js +0 -2
- package/dist/owletto/dist/assets/runs-B_iywKWb.js +0 -2
- package/dist/owletto/dist/assets/runs-list-CJJFRhTl.js +0 -2
- package/dist/owletto/dist/assets/schema-type-editor-panel-C4e8pq1A.js +0 -2
- package/dist/owletto/dist/assets/scoped-feed-bar-CapleZvS.js +0 -2
- package/dist/owletto/dist/assets/subDays-DwIOMzYC.js +0 -2
- package/dist/owletto/dist/assets/use-automations-lV8PuE8L.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-Bp84PUMd.js +0 -2
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import{r as v,j as n,B as U,dh as it,fE as Es,fF as Cs,bV as _s,i as ae,dE as Et,m as We,bn as Ms,cs as $n,q as Ts,fG as Rs,dC as Is,fH as Ls,G as Oe,fI as Kt,fJ as $s,fK as Os,fL as As,T as $e,bg as Lt,bh as $t,bi as Ot,bj as At,bk as ut,fM as Ps,U as et,fN as Ds,bI as On,fO as An,fP as Pn,fQ as Fs,x as Ct,fR as zs,c as tt,u as Jt,eH as Dn,ct as Ws,d4 as Bs,d5 as Hs,fS as Vs,aH as Us,fT as Fn,b2 as Gs,b9 as qs,bT as zn,a6 as Ys,L as He,X as Ks,el as Wn,bX as Js,bY as Xs,fU as Qs,fV as Zs,cz as er,c0 as tr,bo as Bn,fW as Hn,fX as Qe,fY as yt,fZ as nr,f_ as sr,f$ as Xt,g0 as rr,g1 as Bt,g2 as Ht,g3 as or,g4 as ar,cC as Vn,cP as xt,e5 as ir,da as cr,bG as lr,ei as dr,fr as ur,eV as mr,b0 as Un,g5 as Gn,fi as fr,fC as pr,eE as hr,a2 as Vt,dm as qn,g6 as gr,dN as yr,du as xr,e3 as Yn,e4 as Kn,e6 as Jn,e7 as Xn,e8 as br,e9 as vr,ea as wr,eb as kr,dp as un,g7 as Nr,cV as Sr,dq as jr,a4 as Er,g8 as Qn,g9 as Zn,ax as Cr,ga as _r,M as es,gb as Mr,c9 as Be,w as ts,gc as Pt,gd as Tr,ge as Rr,dx as mn,gf as Dt,gg as Ir,gh as Lr,gi as $r,cL as Or,gj as Ar,gk as Pr,be as Dr,gl as Fr,a as zr,gm as Wr,gn as Br,ar as Hr,aF as Vr}from"./index-C2TCKJDP.js";import{P as Ur}from"./public-shell-ready-BbjPgh3k.js";import{A as Gr}from"./connector-boxes-BWPXijAk.js";import{u as qr}from"./use-automations-lV8PuE8L.js";import{f as Yr}from"./feed-event-kinds-BYuZCoU4.js";import{S as Kr}from"./schema-type-editor-panel-C4e8pq1A.js";import{D as Jr,c as Xr}from"./dynamic-schema-form-D3KnzCsW.js";import{S as Qr,E as ns,a as Zr,e as eo,b as to,c as no}from"./entity-pages-DJNSQrfB.js";import{a as so}from"./filter-editors-DQ5V4Cvh.js";import{l as ro,p as _t,e as ss,a as oo,S as ao,J as io}from"./renderer-ucwCQmBk.js";import{u as co,a as lo,D as uo,P as mo,b as rs,c as fo,C as po}from"./core.esm-6koO33th.js";import{v as ho,V as os,M as as,a as is,w as go,b as yo}from"./view-param-filters-Bp84PUMd.js";import{E as xo}from"./entity-type-page-CouHZbc9.js";import{M as bo}from"./member-scope-gate-Doic_6qX.js";function fn(e){let t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)t=Math.min(t,i.x-i.w/2),o=Math.max(o,i.x+i.w/2),s=Math.min(s,i.y-i.h/2),r=Math.max(r,i.y+i.h/2);return Number.isFinite(t)?{x0:t,y0:s,x1:o,y1:r}:null}const bt=(e,t,s)=>e<t?t:e>s?s:e;function vo(e,t,s,{padding:o=.12,minZoom:r=.2,maxZoom:i=1.2}={}){const a=Math.max(1,e.x1-e.x0),l=Math.max(1,e.y1-e.y0),m=bt(Math.min(t/(a*(1+o)),s/(l*(1+o))),r,i);return{z:m,x:t/2-(e.x0+e.x1)/2*m,y:s/2-(e.y0+e.y1)/2*m}}function wo(e,t,s=0){if(e===t){const x=e.x+e.w/2,d=e.y-e.h/2;return[{x:x-30,y:d},{x:x-30,y:d-26},{x:x+22,y:d-26},{x:x+22,y:e.y-6},{x,y:e.y-6}]}const o=s*8,r=e.x+e.w/2,i=e.y+bt(o,-e.h/2+6,e.h/2-6),a=t.x-t.w/2,l=t.y+bt(o,-t.h/2+6,t.h/2-6);if(a-r>=40){const x=(r+a)/2+o;return[{x:r,y:i},{x,y:i},{x,y:l},{x:a,y:l}]}const m=Math.max(e.y+e.h/2,t.y+t.h/2)+24+Math.abs(o),c=Math.min(e.y-e.h/2,t.y-t.h/2)-24-Math.abs(o),y=(i+l)/2,p=Math.abs(m-y)<=Math.abs(c-y)?m:c,f=r+24+Math.abs(o),h=a-24-Math.abs(o);return[{x:r,y:i},{x:f,y:i},{x:f,y:p},{x:h,y:p},{x:h,y:l},{x:a,y:l}]}function ko(e,t,s){const o=s.x-t.x,r=s.y-t.y,i=o*o+r*r,a=i?bt(((e.x-t.x)*o+(e.y-t.y)*r)/i,0,1):0;return Math.hypot(e.x-(t.x+a*o),e.y-(t.y+a*r))}function No(e,t){let s=Number.POSITIVE_INFINITY;for(let o=0;o<t.length-1;o++)s=Math.min(s,ko(e,t[o],t[o+1]));return s}function So(e,t){return Math.abs(t.x-e.x)<=e.w/2&&Math.abs(t.y-e.y)<=e.h/2}class Xe{cells=new Set;static CELL_W=12;static CELL_H=16;keys(t){const s=[],o=Math.floor(t.x0/Xe.CELL_W),r=Math.floor(t.x1/Xe.CELL_W),i=Math.floor(t.y0/Xe.CELL_H),a=Math.floor(t.y1/Xe.CELL_H);for(let l=o;l<=r;l++)for(let m=i;m<=a;m++)s.push(l*1e5+m);return s}isFree(t){return this.keys(t).every(s=>!this.cells.has(s))}reserve(t){for(const s of this.keys(t))this.cells.add(s)}}function jo(e,t,s,o,r){const i=e.slice(0,-1).map((p,f)=>({i:f,length:Math.hypot(e[f+1].x-p.x,e[f+1].y-p.y)})).sort((p,f)=>f.length-p.length);if(i.length===0)return null;const a=p=>({x0:p.x-t/2,x1:p.x+t/2,y0:p.y-s/2,y1:p.y+s/2}),l=p=>({x:(e[p].x+e[p+1].x)/2,y:(e[p].y+e[p+1].y)/2});for(const{i:p,length:f}of i){if(!r&&f<t*.7)break;const h=l(p);if(o.isFree(a(h)))return o.reserve(a(h)),h}if(!r)return null;const m=l(i[0].i),y=[-1,1,-1.6,1.6].map(p=>({x:m.x,y:m.y+p*(s+12)})).find(p=>o.isFree(a(p)))??m;return o.reserve(a(y)),y}const Eo=e=>n.jsx(Et,{icon:e||null,className:"h-4 w-4"}),Co='600 14px "DM Sans", system-ui, sans-serif',_o='400 11px "DM Sans", system-ui, sans-serif',Mo='500 9px "DM Sans", system-ui, sans-serif',To='500 11px "DM Sans", system-ui, sans-serif',at=18,pn=8;function hn(e){const t=getComputedStyle(e),s=(o,r)=>t.getPropertyValue(o).trim()||r;return{foreground:s("--foreground","#141414"),muted:s("--muted-foreground","#545454"),card:s("--card","#ffffff"),background:s("--background","#fcfcfb"),border:s("--border","#e7e4dc"),primary:s("--primary","#2f63e8"),mutedSurface:s("--muted","#f3f1ea")}}function mt(e,t,s){if(e.measureText(t).width<=s)return t;let o=0,r=t.length;for(;o<r;){const i=Math.ceil((o+r)/2);e.measureText(`${t.slice(0,i)}…`).width<=s?o=i:r=i-1}return`${t.slice(0,o)}…`}function Ro(e,t,s,o){const r=Math.hypot(s.x-t.x,s.y-t.y);if(r<1)return;const i=(s.x-t.x)/r,a=(s.y-t.y)/r;e.moveTo(s.x-i*o-a*o*.55,s.y-a*o+i*o*.55),e.lineTo(s.x,s.y),e.lineTo(s.x-i*o+a*o*.55,s.y-a*o-i*o*.55)}function cs({boxes:e,edges:t,label:s,onOpenBox:o,openLabel:r,onConnect:i,renderIcon:a=Eo,className:l}){const m=v.useRef(null),c=v.useRef(null),y=v.useRef(null),p=v.useRef({z:1,x:0,y:0}),f=v.useRef({w:0,h:0,dpr:1}),h=v.useRef(!0),x=v.useRef(new Map),d=v.useRef(null),N=v.useRef(null),_=v.useRef(new Map),j=v.useRef(null),E=v.useRef(""),k=v.useRef(!1),[b,w]=v.useState(()=>new Map),[M,P]=v.useState(null),[A,I]=v.useState(null),[F,B]=v.useState(null),[J,W]=v.useState(null),[se,me]=v.useState(0),{placed:X,movedIds:Ee}=v.useMemo(()=>{const C=new Map,u=new Set;for(const g of e){const S=b.get(g.id);S&&S.from.x===g.x&&S.from.y===g.y?(C.set(g.id,{...g,x:S.at.x,y:S.at.y}),u.add(g.id)):C.set(g.id,g)}return{placed:C,movedIds:u}},[e,b]),ue=v.useMemo(()=>{const C=new Map;for(const g of t){const S=[g.source,g.target].sort().join("|");C.set(S,[...C.get(S)??[],g])}const u=new Map;for(const g of t){const S=X.get(g.source),T=X.get(g.target);if(!S||!T)continue;if(g.route&&!Ee.has(S.id)&&!Ee.has(T.id)){u.set(g.id,g.route);continue}const R=C.get([g.source,g.target].sort().join("|"))??[g];u.set(g.id,wo(S,T,R.indexOf(g)-(R.length-1)/2))}return u},[t,X,Ee]),G=v.useCallback(()=>{h.current=!0},[]),te=v.useCallback(()=>{const C=fn([...X.values()]),{w:u,h:g}=f.current;!C||!u||!g||(p.current=vo(C,u,g),k.current=!0,G())},[X,G]),xe=C=>{p.current=C,k.current=!1,G()},Ce=C=>{const u=fn(C),{w:g,h:S}=f.current;if(!u||!g||!S)return;const T=p.current,R=24;u.x0*T.z+T.x>=R&&u.y0*T.z+T.y>=R&&u.x1*T.z+T.x<=g-R&&u.y1*T.z+T.y<=S-R||xe({...T,x:g/2-(u.x0+u.x1)/2*T.z,y:S/2-(u.y0+u.y1)/2*T.z})},Ve=C=>{W(C);const u=X.get(C);u&&Ce([u])},ie=e.map(C=>`${C.id}@${Math.round(C.x)},${Math.round(C.y)}`).join(";");v.useEffect(()=>{!ie||E.current===ie||f.current.w&&(E.current=ie,te())},[ie,te]);const ke=v.useRef(te);ke.current=te;const Ae=v.useRef(ie);Ae.current=ie,v.useEffect(()=>{const C=m.current,u=c.current;if(!C||!u||typeof ResizeObserver>"u")return;const g=()=>{const T=window.devicePixelRatio||1,R=C.clientWidth,O=C.clientHeight;f.current={w:R,h:O,dpr:T},u.width=Math.round(R*T),u.height=Math.round(O*T);const H=Ae.current;H&&R&&O&&(E.current!==H||k.current)&&(E.current=H,ke.current()),G()};g();const S=new ResizeObserver(g);return S.observe(C),()=>S.disconnect()},[G]);const[be,Ue]=v.useState(0);v.useEffect(()=>{const C=y.current,u=c.current;if(!C||!u)return;const g=hn(u).muted;for(const S of C.querySelectorAll("[data-icon-key]")){const T=S.dataset.iconKey??"";if(x.current.has(T))continue;const R=S.querySelector("svg"),O=R?null:S.querySelector("img")?.src;if(!R&&!O){x.current.set(T,S.textContent??"");continue}const H=new Image;if(H.onload=G,H.onerror=()=>{x.current.delete(T),Ue(z=>z+1)},R){const z=R.cloneNode(!0);z.getAttribute("width")||z.setAttribute("width","24"),z.getAttribute("height")||z.setAttribute("height","24");const D=new XMLSerializer().serializeToString(z).replaceAll("currentColor",g);H.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(D)}`}else O&&(H.src=O);x.current.set(T,H)}},[e,se,be,G]);const Ne=(C,u)=>{const g=p.current;return{x:(C-g.x)/g.z,y:(u-g.y)/g.z}},Pe=(C,u)=>{const g=p.current,S=Ne(C,u),T=M&&M.kind!=="edge"?X.get(M.box.id):void 0;if(T&&i){const z=gn(T);if(Math.hypot(z.x*g.z+g.x-C,z.y*g.z+g.y-u)<=pn+3)return{kind:"handle",box:T}}const R=[...X.values()];for(let z=R.length-1;z>=0;z--)if(So(R[z],S))return{kind:"box",box:R[z]};let O=null,H=7/g.z;for(const z of t){const D=ue.get(z.id);if(!D)continue;const ce=No(S,D);ce<H&&(H=ce,O=z)}return O?{kind:"edge",edge:O}:null},fe=v.useMemo(()=>{const C=new Set;for(const g of[A,F])g&&C.add(g);M?.kind==="edge"&&C.add(M.edge.id);const u=M&&M.kind!=="edge"?M.box.id:J;if(u)for(const g of t)(g.source===u||g.target===u)&&C.add(g.id);for(const g of t)g.dimmed&&C.delete(g.id);return C},[t,M,A,F,J]);v.useEffect(G,[X,ue,fe,M,J,G]);const _e=v.useCallback(()=>{const C=c.current,u=C?.getContext("2d");if(!C||!u)return;const{w:g,h:S,dpr:T}=f.current,R=hn(C),O=getComputedStyle(C),H=new Map,z=$=>{let Y=H.get($);return Y===void 0&&(Y=O.getPropertyValue($).trim(),H.set($,Y)),Y},{z:D,x:ce,y:oe}=p.current,ve=$=>({x:$.x*D+ce,y:$.y*D+oe});u.setTransform(T,0,0,T,0,0),u.clearRect(0,0,g,S);const Re=M&&M.kind!=="edge"?M.box.id:null;u.lineJoin="round";for(const $ of t){const Y=ue.get($.id);if(!Y)continue;const Q=Y.map(ve),V=fe.has($.id);u.globalAlpha=$.dimmed?.15:V?.95:.55,u.strokeStyle=V?R.foreground:R.muted,u.lineWidth=V?1.75:1.25,u.beginPath(),u.moveTo(Q[0].x,Q[0].y);for(const Z of Q.slice(1))u.lineTo(Z.x,Z.y);$.directed&&Ro(u,Q[Q.length-2],Q[Q.length-1],8),u.stroke()}const Ge=new Xe;for(const $ of X.values()){const Y=ve($),Q=$.w*D,V=$.h*D,Z=Y.x-Q/2,q=Y.y-V/2;if(Ge.reserve({x0:Z,y0:q,x1:Z+Q,y1:q+V}),Z>g||q>S||Z+Q<0||q+V<0)continue;const Le=Re===$.id||j.current?.over?.id===$.id;u.globalAlpha=$.dimmed?.25:1,u.beginPath(),u.roundRect(Z,q,Q,V,8*D),u.fillStyle=$.muted?R.mutedSurface:R.card,u.fill(),u.lineWidth=Le||J===$.id?1.5:1,u.strokeStyle=Le||J===$.id?R.primary:R.border,u.stroke();const ne=$.accent&&z($.accent);if(ne&&(u.save(),u.clip(),u.fillStyle=ne,u.fillRect(Z,q,3*D,V),u.restore()),14*D<5)continue;const de=12*D,ee=16*D,le=$.meta?q+V/2-8*D:q+V/2,Se=x.current.get($.icon??"");Se instanceof HTMLImageElement&&Se.complete&&Se.naturalWidth>0?u.drawImage(Se,Z+de,le-ee/2,ee,ee):typeof Se=="string"&&Se&&(u.font=`${14*D}px system-ui, sans-serif`,u.textBaseline="middle",u.textAlign="left",u.fillText(Se,Z+de,le));const ze=Z+de+ee+8*D,st=12*D;u.textBaseline="middle",u.textAlign="left";let Ke=Z+Q-st-ze;if($.badge){u.font=Mo.replace("9px",`${9*D}px`);const rt=mt(u,$.badge.toUpperCase(),Ke*.35),Je=u.measureText(rt).width+8*D,ot=Z+Q-st-Je;u.strokeStyle=R.border,u.lineWidth=1,u.beginPath(),u.roundRect(ot,le-7*D,Je,14*D,3*D),u.stroke(),u.fillStyle=R.muted,u.fillText(rt,ot+4*D,le+.5),Ke-=Je+6*D}u.font=Co.replace("14px",`${14*D}px`),u.fillStyle=R.foreground,u.fillText(mt(u,$.title,Ke),ze,le+.5),$.meta&&(u.font=_o.replace("11px",`${11*D}px`),u.fillStyle=R.muted,u.fillText(mt(u,$.meta,Z+Q-de-ze),ze,q+V/2+10*D))}const Ie=j.current,qe=Ie?.from??(Re?X.get(Re):void 0);if(i&&qe&&qe.w*D>=60){const $=ve(gn(qe));if(u.globalAlpha=1,Ie){const Y=ve(Ie.to);u.strokeStyle=R.primary,u.lineWidth=2,u.setLineDash([6,4]),u.beginPath(),u.moveTo($.x,$.y),u.lineTo(Y.x,Y.y),u.stroke(),u.setLineDash([])}u.fillStyle=R.card,u.strokeStyle=R.primary,u.lineWidth=1.5,u.beginPath(),u.arc($.x,$.y,pn,0,Math.PI*2),u.fill(),u.stroke(),u.beginPath(),u.moveTo($.x-4,$.y),u.lineTo($.x+4,$.y),u.moveTo($.x,$.y-4),u.lineTo($.x,$.y+4),u.stroke()}u.font=To,u.textAlign="center",u.textBaseline="middle";const Ye=($,Y,Q,V)=>{u.globalAlpha=1,u.fillStyle=R.background,u.strokeStyle=Q?R.foreground:R.border,u.lineWidth=1,u.beginPath(),u.roundRect($.x-V/2,$.y-at/2,V,at,5),u.fill(),u.stroke(),u.fillStyle=Q?R.foreground:R.muted,u.fillText(Y,$.x,$.y+.5)},Mt=[...t].sort(($,Y)=>Number(fe.has(Y.id))-Number(fe.has($.id)));for(const $ of Mt){const Y=ue.get($.id);if(!Y||$.dimmed&&!fe.has($.id))continue;const Q=Y.map(ve),V=fe.has($.id),q=(V?$.details:[$.summary]).map(ee=>mt(u,ee,200)),Le=Math.max(...q.map(ee=>u.measureText(ee).width))+14,ne=q.length*(at+2);if(!V&&D<.45)continue;const de=jo(Q,Le,ne,Ge,V);de&&q.forEach((ee,le)=>{Ye({x:de.x,y:de.y-ne/2+(at+2)*le+at/2},ee,V,Le)})}u.globalAlpha=1},[t,ue,X,fe,M,J,i]);v.useEffect(()=>{let C=0;const u=()=>{C=requestAnimationFrame(u),h.current&&(h.current=!1,_e())};return C=requestAnimationFrame(u),document.addEventListener("visibilitychange",G),()=>{cancelAnimationFrame(C),document.removeEventListener("visibilitychange",G)}},[_e,G]),v.useEffect(()=>{const C=new MutationObserver(()=>{x.current.clear(),me(u=>u+1),G()});return C.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>C.disconnect()},[G]);const pe=(C,u,g)=>{const S=p.current,T=Math.min(3,Math.max(.15,S.z*C));xe({z:T,x:u-(u-S.x)*(T/S.z),y:g-(g-S.y)*(T/S.z)})},Me=C=>{const u=c.current?.getBoundingClientRect();return{x:C.clientX-(u?.left??0),y:C.clientY-(u?.top??0)}},re=C=>{if(C.button!==0&&C.pointerType==="mouse")return;C.currentTarget.setPointerCapture(C.pointerId);const u=Me(C);if(C.pointerType==="touch"&&(_.current.set(C.pointerId,u),_.current.size===2)){const[T,R]=[..._.current.values()];d.current=null,j.current=null,N.current={d:Math.hypot(T.x-R.x,T.y-R.y)||1,mid:{x:(T.x+R.x)/2,y:(T.y+R.y)/2}};return}const g=Pe(u.x,u.y),S={start:u,last:u,hit:g,moved:!1};if(g?.kind==="handle")j.current={from:g.box,to:Ne(u.x,u.y),over:null};else if(g?.kind==="box"){const T=Ne(u.x,u.y);S.grab={x:g.box.x-T.x,y:g.box.y-T.y}}d.current=S},nt=C=>{const u=Me(C);_.current.has(C.pointerId)&&_.current.set(C.pointerId,u);const g=N.current;if(g&&_.current.size===2){const[z,D]=[..._.current.values()],ce=Math.hypot(z.x-D.x,z.y-D.y)||1,oe={x:(z.x+D.x)/2,y:(z.y+D.y)/2};xe({...p.current,x:p.current.x+oe.x-g.mid.x,y:p.current.y+oe.y-g.mid.y}),pe(ce/g.d,oe.x,oe.y),N.current={d:ce,mid:oe};return}const S=d.current;if(!S){const z=Pe(u.x,u.y);P(ce=>Io(ce,z)?ce:z);const D=c.current;D&&(D.style.cursor=z?.kind==="handle"?"crosshair":z?"pointer":"grab");return}const T=u.x-S.last.x,R=u.y-S.last.y;if(S.last=u,!S.moved&&Math.hypot(u.x-S.start.x,u.y-S.start.y)>4&&(S.moved=!0),!S.moved)return;const O=j.current;if(O){O.to=Ne(u.x,u.y);const z=Pe(u.x,u.y);O.over=z?.kind==="box"?z.box:null,G();return}const H=S.hit;if(H?.kind==="box"&&S.grab){const z=Ne(u.x,u.y),D=e.find(oe=>oe.id===H.box.id);if(!D)return;const ce={x:z.x+S.grab.x,y:z.y+S.grab.y};w(oe=>new Map(oe).set(D.id,{at:ce,from:{x:D.x,y:D.y}}));return}xe({...p.current,x:p.current.x+T,y:p.current.y+R}),c.current&&(c.current.style.cursor="grabbing")},ge=C=>{if(_.current.delete(C.pointerId),N.current){_.current.size<2&&(N.current=null),d.current=null;return}const u=d.current;d.current=null;const g=j.current;if(j.current=null,!u)return;if(c.current&&(c.current.style.cursor="grab"),g){G(),g.over&&i&&i(g.from.id,g.over.id);return}if(u.moved)return;const S=u.hit;S?.kind==="box"?o(S.box.id):S?.kind==="edge"?I(T=>T===S.edge.id?null:S.edge.id):I(null)},Te=C=>{_.current.delete(C.pointerId),N.current=null,d.current=null,j.current=null,G()};v.useEffect(()=>{const C=c.current;if(!C)return;const u=g=>{g.preventDefault();const S=Me(g);g.ctrlKey||g.metaKey?pe(Math.exp(-g.deltaY*(g.ctrlKey?.01:.002)),S.x,S.y):xe({...p.current,x:p.current.x-g.deltaX,y:p.current.y-g.deltaY})};return C.addEventListener("wheel",u,{passive:!1}),()=>C.removeEventListener("wheel",u)});const De=C=>pe(C,f.current.w/2,f.current.h/2),Fe=[...new Set(e.map(C=>C.icon??""))];return n.jsxs("div",{ref:m,className:ae("relative h-full w-full overflow-hidden",l),children:[n.jsx("canvas",{ref:c,"aria-hidden":"true",className:"block h-full w-full cursor-grab touch-none",onPointerDown:re,onPointerMove:nt,onPointerUp:ge,onPointerCancel:Te,onPointerLeave:()=>{d.current||P(null)}}),n.jsxs("ul",{ref:y,"aria-label":s,className:"sr-only",children:[Fe.map(C=>n.jsx("li",{"aria-hidden":"true","data-icon-key":C,children:a(C)},`icon:${C}`)),e.map(C=>n.jsx("li",{children:n.jsx("button",{type:"button",onClick:()=>o(C.id),onFocus:()=>Ve(C.id),onBlur:()=>W(null),children:r(C)})},C.id)),t.map(C=>n.jsx("li",{"data-revealed":fe.has(C.id)||void 0,children:n.jsx("button",{type:"button","aria-pressed":A===C.id,onClick:()=>I(u=>u===C.id?null:C.id),onFocus:()=>{B(C.id);const u=ue.get(C.id);u&&Ce(u.map(g=>({...g,w:0,h:0})))},onBlur:()=>B(null),children:C.ariaLabel})},C.id))]}),n.jsxs("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:[n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom in",onClick:()=>De(1.25),children:n.jsx(it,{className:"h-3.5 w-3.5"})}),n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Zoom out",onClick:()=>De(.8),children:n.jsx(Es,{className:"h-3.5 w-3.5"})}),n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Fit to view",onClick:te,children:n.jsx(Cs,{className:"h-3.5 w-3.5"})}),Ee.size>0?n.jsx(U,{type:"button",variant:"outline",size:"icon",className:"h-7 w-7","aria-label":"Reset layout",onClick:()=>w(new Map),children:n.jsx(_s,{className:"h-3.5 w-3.5"})}):null]})]})}const gn=e=>({x:e.x+e.w/2,y:e.y});function Io(e,t){return!e||!t?e===t:e.kind==="edge"||t.kind==="edge"?e.kind==="edge"&&t.kind==="edge"&&e.edge.id===t.edge.id:e.kind===t.kind&&e.box.id===t.box.id}function Qt({label:e,fill:t=!1,schemaActions:s=!1}){return n.jsxs("div",{role:"status","aria-label":e,"aria-busy":"true",className:ae("flex min-w-0 flex-col gap-3",t&&"min-h-0 flex-1"),children:[n.jsx("div",{className:"flex min-w-0 items-center gap-3",children:n.jsx("div",{"aria-hidden":"true",className:"min-w-0 flex-1",children:n.jsx(We,{className:"h-5 w-3/4 max-w-xl rounded-none"})})}),n.jsxs("div",{className:ae("relative flex min-h-0 flex-col",t&&"flex-1"),"aria-hidden":"true",children:[s?n.jsxs("div",{className:"z-10 flex flex-wrap justify-end gap-2 lg:absolute lg:top-0 lg:right-0",children:[n.jsx(We,{className:"h-8 w-40 rounded-none"}),n.jsx(We,{className:"h-8 w-36 rounded-none"})]}):null,n.jsxs("div",{className:ae("relative min-h-[420px]",t?"flex-1":"h-[70vh]"),children:[n.jsxs("div",{className:"absolute top-1/2 left-1/2 flex h-16 w-52 -translate-x-1/2 -translate-y-1/2 items-center gap-3 rounded-xl border border-border bg-card px-4",children:[n.jsx(We,{className:"h-4 w-4 shrink-0 rounded-none"}),n.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[n.jsx(We,{className:"h-3.5 w-24 rounded-none"}),n.jsx(We,{className:"h-2.5 w-32 rounded-none"})]})]}),n.jsx("div",{className:"absolute bottom-3 left-3 flex flex-col gap-1",children:["in","out","fit"].map(o=>n.jsx("div",{className:"flex h-7 w-7 items-center justify-center border border-input bg-background",children:n.jsx(We,{className:"h-3 w-3 rounded-none"})},o))})]})]})]})}const yn={trigger:"runs on arrival",delivery:"delivers here"};function Lo(e){const t=new Map,s=(o,r,i,a)=>{const l=Number(o);if(!Number.isInteger(l)||l<=0)return;const m=t.get(l)??[],c=m.find(y=>y.automation.automation_id===r.automation_id);if(c){if(c.reason===i)for(const y of a)c.eventTypes.includes(y)||c.eventTypes.push(y);return}m.push({automation:r,reason:i,eventTypes:[...a]}),t.set(l,m)};for(const o of e){for(const r of o.triggers??[]){const i=Array.isArray(r.event_types)?r.event_types.map(String):[];s(r.connection_id,o,"trigger",i)}s(o.delivery_target?.connection_id,o,"delivery",[])}return t}function $o(e){const t=new Map;for(const s of e){const o=t.get(s.connection_id)??[];o.push(s),t.set(s.connection_id,o)}return t}function Oo(e){const t=(s,o,r)=>`${s} ${s===1?o:r}`;return[t(e.feeds,"feed","feeds"),e.actions>0?t(e.actions,"action","actions"):null,e.automations>0?t(e.automations,"Automation","Automations"):null].filter(Boolean).join(" · ")}function ft(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ft={exports:{}},xn;function Ao(){return xn||(xn=1,(function(e,t){(function(s){e.exports=s()})(function(){return(function(){function s(o,r,i){function a(c,y){if(!r[c]){if(!o[c]){var p=typeof ft=="function"&&ft;if(!y&&p)return p(c,!0);if(l)return l(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var h=r[c]={exports:{}};o[c][0].call(h.exports,function(x){var d=o[c][1][x];return a(d||x)},h,h.exports,s,o,r,i)}return r[c].exports}for(var l=typeof ft=="function"&&ft,m=0;m<i.length;m++)a(i[m]);return a}return s})()({1:[function(s,o,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;function i(f){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},i(f)}function a(f,h){if(!(f instanceof h))throw new TypeError("Cannot call a class as a function")}function l(f,h){for(var x=0;x<h.length;x++){var d=h[x];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(f,c(d.key),d)}}function m(f,h,x){return h&&l(f.prototype,h),Object.defineProperty(f,"prototype",{writable:!1}),f}function c(f){var h=y(f,"string");return i(h)=="symbol"?h:h+""}function y(f,h){if(i(f)!="object"||!f)return f;var x=f[Symbol.toPrimitive];if(x!==void 0){var d=x.call(f,h);if(i(d)!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(f)}r.default=(function(){function f(){var h=this,x=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},d=x.defaultLayoutOptions,N=d===void 0?{}:d,_=x.algorithms,j=_===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:_,E=x.workerFactory,k=x.workerUrl;if(a(this,f),this.defaultLayoutOptions=N,this.initialized=!1,typeof k>"u"&&typeof E>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var b=E;typeof k<"u"&&typeof E>"u"&&(b=function(P){return new Worker(P)});var w=b(k);if(typeof w.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new p(w),this.worker.postMessage({cmd:"register",algorithms:j}).then(function(M){return h.initialized=!0}).catch(console.err)}return m(f,[{key:"layout",value:function(x){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},N=d.layoutOptions,_=N===void 0?this.defaultLayoutOptions:N,j=d.logging,E=j===void 0?!1:j,k=d.measureExecutionTime,b=k===void 0?!1:k;return x?this.worker.postMessage({cmd:"layout",graph:x,layoutOptions:_,options:{logging:E,measureExecutionTime:b}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}])})();var p=(function(){function f(h){var x=this;if(a(this,f),h===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=h,this.worker.onmessage=function(d){setTimeout(function(){x.receive(x,d)},0)}}return m(f,[{key:"postMessage",value:function(x){var d=this.id||0;this.id=d+1,x.id=d;var N=this;return new Promise(function(_,j){N.resolvers[d]=function(E,k){E?(N.convertGwtStyleError(E),j(E)):_(k)},N.worker.postMessage(x)})}},{key:"receive",value:function(x,d){var N=d.data,_=x.resolvers[N.id];_&&(delete x.resolvers[N.id],N.error?_(N.error):_(null,N.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(x){if(x){var d=x.__java$exception;d&&(d.cause&&d.cause.backingJsObject&&(x.cause=d.cause.backingJsObject,this.convertGwtStyleError(x.cause)),delete x.__java$exception)}}}])})()},{}],2:[function(s,o,r){var i=s("./elk-api.js").default;Object.defineProperty(o.exports,"__esModule",{value:!0}),o.exports=i,i.default=i},{"./elk-api.js":1}]},{},[2])(2)})})(Ft)),Ft.exports}var Po=Ao();const Do=Ms(Po);function Fo(e){return new Worker("/assets/elk-worker.min-BENGc9gn.js",{name:e?.name})}const zo=200,Wo=320,Ze=56,Bo=7.4,Ho=5.9,Vo=84,Uo=48;function ct(e,t){return Math.round(Math.min(Wo,Math.max(zo,Vo+e.length*Bo,Uo+t.length*Ho)))}function Go(e,t){const s=[];return e>0&&s.push(`${e} ${e===1?"field":"fields"}`),typeof t=="number"&&s.push(`${t.toLocaleString()} ${t===1?"record":"records"}`),s.join(" · ")}function bn(e,t){return e.slug<t.slug?-1:e.slug>t.slug?1:0}function ls(e,t){const s=new Set;return e.filter(o=>o.status!=="active"||o.organization_slug&&o.organization_slug!==t||s.has(o.slug)?!1:(s.add(o.slug),!0))}function qo(e){const t=e.metadata_schema;if(!t||typeof t!="object")return 0;const s=t.properties;return!s||typeof s!="object"?0:Object.keys(s).length}function ds(e){const{entityTypes:t,relationshipTypes:s,rulesBySlug:o}=e,r=e.ownerSlug??"",i=[...t].sort(bn),a=ls(s,r).sort(bn),l=b=>!b.organization_slug||b.organization_slug===r,m=b=>b.organization_slug||r,c=new Map;for(const b of i)c.set(b.slug,[...c.get(b.slug)??[],b]);const y=b=>(c.get(b.slug)?.length??0)>1?`${m(b)}:${b.slug}`:b.slug,p=new Set(i.filter(l).map(y)),f=b=>{const w=c.get(b)??[];return w.find(l)??(w.length===1?w[0]:void 0)},h=new Set(p),x=a.flatMap(b=>[...o[b.slug]??[]].sort((w,M)=>w.id-M.id).flatMap(w=>{const M=f(w.source_entity_type_slug),P=f(w.target_entity_type_slug);if(!M||!P)return[];const A=y(M),I=y(P);return!p.has(A)&&!p.has(I)?[]:(h.add(A),h.add(I),[{rt:b,source:A,target:I}])})),d=i.filter(b=>h.has(y(b))),N=[],_=new Map,j=new Map;for(const{rt:b,source:w,target:M}of x){const P=`${b.slug}|${w}|${M}`,A=j.get(P);if(A){A.ruleCount+=1;continue}const I={slug:b.slug,label:b.name||b.slug,ruleCount:1};j.set(P,I);const F=`${w}|${M}`,B=_.get(F);if(B){B.data.relationships.push(I),B.data.isSymmetric=B.data.isSymmetric&&b.is_symmetric;continue}const J={id:`pair:${w}|${M}`,source:w,target:M,data:{relationships:[I],isSymmetric:b.is_symmetric}};_.set(F,J),N.push(J)}const E=new Map;for(const{rt:b,source:w,target:M}of x){const P=E.get(b.slug)??new Set;P.add(`${w}|${M}`),E.set(b.slug,P)}for(const{rt:b}of x)if(E.get(b.slug)?.size===1&&typeof b.relationship_count=="number")for(const w of j.values())w.slug===b.slug&&(w.linkCount=b.relationship_count);return{nodes:d.map(b=>{const w=b.name||b.slug,M=qo(b),P=Go(M,b.entity_count);return{id:y(b),width:ct(w,P),height:Ze,data:{slug:b.slug,label:w,icon:b.icon,isSystem:$n(b),organizationSlug:l(b)?void 0:m(b),metaLabel:P}}}),edges:N}}const we=24,Yo=72,Ko=16,Jo=48,Xo=64,zt=16,Qo=720;function Zo(e,t){const s=new Map(e.map(i=>[i.id,i.id])),o=i=>{const a=s.get(i)??i;if(a===i)return i;const l=o(a);return s.set(i,l),l};for(const i of t)s.set(o(i.source),o(i.target));const r=new Map;for(const i of e){const a=o(i.id);r.set(a,[...r.get(a)??[],i])}return[...r.values()].sort((i,a)=>a.length-i.length)}function ea(e,t,s,o){const r=new Map(e.flatMap((y,p)=>y.map(f=>[f.id,p]))),i=e.map(()=>({top:1/0,bottom:-1/0})),a=(y,p,f)=>{const h=i[r.get(y)??0];h.top=Math.min(h.top,p),h.bottom=Math.max(h.bottom,f)};for(const y of t)a(y.id,y.position.y,y.position.y+y.height);for(const y of s)for(const p of o.get(y.id)??[])a(y.source,p.y,p.y);let l=we;const m=i.map(({top:y,bottom:p})=>{const f=l-y;return l=p+f+Jo,f}),c=y=>m[r.get(y)??0];for(const y of s){const p=o.get(y.id);p&&o.set(y.id,p.map(f=>({x:f.x,y:f.y+c(y.source)})))}return t.map(y=>({...y,position:{x:y.position.x,y:y.position.y+c(y.id)}}))}function ta(e,t){const s=we,o=Math.max(s+Qo,...t.map(l=>l.position.x+l.width));let r=t.length>0?Math.max(...t.map(l=>l.position.y+l.height))+Xo:we;const i=[...new Set(e.map(l=>l.lane??0))].sort((l,m)=>l-m),a=[];for(const l of i){let m=s,c=0;for(const y of e.filter(p=>(p.lane??0)===l))m>s&&m+y.width>o&&(m=s,r+=c+zt,c=0),a.push({...y,position:{x:m,y:r}}),m+=y.width+zt,c=Math.max(c,y.height);r+=c+zt*2}return a}let vn=null;function na(){return vn??=new Do({workerFactory:()=>new Fo}),vn}const Wt={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"48","elk.spacing.edgeEdge":"14","elk.spacing.edgeNode":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.crossingMinimization.semiInteractive":"true"};async function Zt(e,{elk:t=na(),targetAspect:s}={}){const o=new Set;for(const b of e.edges)o.add(b.source),o.add(b.target);const r=e.nodes.some(b=>b.lane!==void 0),i=e.nodes.filter(b=>o.has(b.id)),a=r?Zo(i,e.edges):[i],l=a.flat(),m=e.nodes.filter(b=>!o.has(b.id)),c=r?[]:m,y=r?m:[],p=c.reduce((b,w)=>Math.max(b,w.width),0),f=c.length>0?we+p+Yo:0,h=b=>({x:b.x+we+f,y:b.y+we});let x=[];const d=new Map;if(l.length>0){const b=e.edges.filter(I=>I.source!==I.target),w=I=>t.layout({id:"root",layoutOptions:r?{...I,"elk.partitioning.activate":"true","elk.separateConnectedComponents":"false"}:I,children:l.map(F=>({id:F.id,width:F.width,height:F.height,...r?{layoutOptions:{"elk.partitioning.partition":String(F.lane??1)}}:{}})),edges:b.map(F=>({id:F.id,sources:[F.layoutReversed?F.target:F.source],targets:[F.layoutReversed?F.source:F.target]}))});let M=await w(Wt);const P=s&&M.width&&M.height?s*M.width/M.height:1;if(P>1.08){const I=Number(Wt["elk.spacing.nodeNode"]),F=Math.min(P,2.2);M=await w({...Wt,"elk.spacing.nodeNode":String(Math.round(Math.min(180,I*F+Ze*(F-1))))})}const A=new Map((M.children??[]).map(I=>[I.id,I]));x=l.map(I=>{const F=A.get(I.id);return{...I,position:h({x:F?.x??0,y:F?.y??0})}});for(const I of M.edges??[]){const F=(I.sections??[]).flatMap(J=>[J.startPoint,...J.bendPoints??[],J.endPoint]);if(F.length<2)continue;const B=e.edges.find(J=>J.id===I.id)?.layoutReversed;d.set(I.id,(B?[...F].reverse():F).map(h))}}let N=we;const _=c.map(b=>{const w={x:we,y:N};return N+=b.height+Ko,{...b,position:w}});r&&(x=ea(a,x,e.edges,d));const j=ta(y,x),E=new Map([...x,..._,...j].map(b=>[b.id,b]));return{nodes:e.nodes.map(b=>E.get(b.id)??{...b,position:{x:we,y:we}}),edges:e.edges.map(b=>({...b,route:d.get(b.id)??null}))}}function sa(e,t){return Zt(ds(e),t)}const Ut="connector:",wn=e=>`${Ut}${e}`,ra={event:"Zap",schedule:"CalendarClock",manual:"Hand"},oa=0,aa=1,kn=2;function ia(e,t){const s=new Map;for(const{kind:o,targets:r}of Yr(e?.feeds_schema?.[t]))for(const{entityType:i,creates:a}of r){const l=s.get(i)??{creates:!1,eventKinds:new Set};l.creates||=a,l.eventKinds.add(o),s.set(i,l)}return s}function ca(e,t){const s=new Map(e.connectorDefs.map(d=>[d.key,d])),o=new Map(e.connectorDefs.map(d=>[d.key,d.name])),r=new Map(e.connections.map(d=>[d.id,d])),i=$o(e.feeds),a=d=>`connection:${d}`,l=d=>`automation:${d}`,m=[],c=(d,N,_,j,E=!1)=>{m.push({id:`flow:${d}->${N}`,source:d,target:N,layoutReversed:E,data:{relationships:[],isSymmetric:!1,flow:{summary:_,details:j}}})},y=new Set(e.connections.map(d=>d.id));for(const d of e.connections){const N=new Map;for(const _ of i.get(d.id)??[]){const j=ia(s.get(d.connector_key),_.feed_key);for(const[E,k]of j){const b=N.get(E)??{creates:!1,eventKinds:new Set};b.creates||=k.creates;for(const w of k.eventKinds)b.eventKinds.add(w);N.set(E,b)}}for(const[_,j]of N){const E=t.get(_);E&&c(a(d.id),E,j.creates?"creates records":"links records",[`From ${[...j.eventKinds].sort().join(", ")} events`])}}const p=Lo(e.automations);for(const[d,N]of p)if(y.has(d))for(const{automation:_,reason:j,eventTypes:E}of N){const k=l(_.automation_id);j==="trigger"?c(a(d),k,yn.trigger,E.length>0?[`On ${[...E].sort().join(", ")}`]:[]):c(k,a(d),yn.delivery,[],!0)}const f=[];for(const d of e.automations){const N=l(d.automation_id),_=d.entity_type?t.get(d.entity_type):void 0;_&&c(_,N,"anchored here",[d.entity_name?`On ${d.entity_name}`:""].filter(Boolean));const j=Ts(d,o,r),E=Rs(d),k=d.health==="degraded"?"Needs attention":void 0;f.push({id:N,lane:kn,width:ct(`${j.does} ${k??""}`,j.when),height:Ze,data:{slug:N,label:j.does,icon:E?wn(E):ra[j.kind],isSystem:!1,badge:k,metaLabel:j.when,ref:{kind:"automation",automationId:d.automation_id}}})}const h=[];for(const d of e.metrics){const N=t.get(d.typeSlug);if(!N)continue;const _=`metric:${d.typeSlug}:${d.name}`;c(N,_,"measures",[d.description].filter(Boolean)),h.push({id:_,lane:kn,width:ct(d.name,d.agg),height:Ze,data:{slug:_,label:d.name,icon:"ChartColumn",isSystem:!1,metaLabel:d.agg,ref:{kind:"metric",typeSlug:d.typeSlug,name:d.name}}})}return{nodes:[...e.connections.map(d=>{const N=Is(d),_=Ls(d,s.get(d.connector_key)),j=Oo({feeds:i.get(d.id)?.length||d.feed_count,actions:d.operations_summary?.total??0,automations:p.get(d.id)?.length??0}),E=_.needsAttention?"Needs attention":d.device_label??void 0;return{id:a(d.id),lane:oa,width:ct(`${N} ${E??""}`,j),height:Ze,data:{slug:a(d.id),label:N,icon:wn(d.connector_key),isSystem:!1,badge:E,metaLabel:j,ref:{kind:"connection",connectorKey:d.connector_key,connectionId:d.id}}}}),...f,...h],edges:m}}function us(e){switch(e.data.ref?.kind){case"connection":return"connections";case"automation":return"automations";case"metric":return"metrics";default:return"entities"}}function la(e,t){const s=new Map;for(const m of e.nodes)(!m.data.organizationSlug||!s.has(m.data.slug))&&s.set(m.data.slug,m.id);const o=ca(t,s),{layers:r}=t,i=[...o.nodes,...e.nodes.map(m=>({...m,lane:aa}))].filter(m=>r[us(m)]),a=new Set(i.map(m=>m.id)),l=[...e.edges,...o.edges].filter(m=>a.has(m.source)&&a.has(m.target));return{nodes:i,edges:l}}const Nn="__new__";function Sn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function da({entityTypes:e,initialSource:t="",initialTarget:s="",onDone:o}){const r=v.useId(),i=`${r}-relationship`,a=`${r}-name`,l=`${r}-symmetric`,m=`${r}-source`,c=`${r}-target`,{orgContext:y}=Oe(),{data:p=[]}=Kt(y),f=$s(),h=Os(),[x,d]=v.useState(""),[N,_]=v.useState(""),[j,E]=v.useState(!1),[k,b]=v.useState(t),[w,M]=v.useState(s),[P,A]=v.useState(null),I=x===Nn,F=p.filter(W=>W.status==="active"&&W.purpose!==As&&(!W.organization_slug||W.organization_slug===y?.slug)),B=f.isPending||h.isPending,J=async()=>{if(A(null),!x)return A("Pick a relationship");if(!k||!w)return A("Pick both ends");try{let W=x;if(I){const se=N.trim();if(!se)return A("Name the relationship");const me=Sn(se);if(!me)return A("Name must contain a letter or number");W=(await f.mutateAsync({slug:me,name:se,is_symmetric:j})).relationship_type.slug,d(W)}await h.mutateAsync({slug:W,source_entity_type_slug:k,target_entity_type_slug:w}),o()}catch(W){A(W instanceof Error?W.message:"Could not save")}};return n.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3",children:[n.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:"Relationships are defined once for the workspace, then paired with the types they connect."}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:i,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Relationship"}),n.jsxs(Lt,{value:x,onValueChange:d,children:[n.jsx($t,{id:i,className:"h-8 text-xs",children:n.jsx(Ot,{placeholder:"Pick or define one"})}),n.jsxs(At,{children:[F.map(W=>n.jsx(ut,{value:W.slug,children:W.name||W.slug},W.slug)),F.length>0?n.jsx(Ps,{}):null,n.jsx(ut,{value:Nn,children:"Define a new one…"})]})]})]}),I?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:a,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"Name"}),n.jsx(et,{id:a,value:N,onChange:W=>_(W.target.value),placeholder:"works at",className:"h-8 text-xs"}),N.trim()?n.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Slug: ",n.jsx("code",{children:Sn(N)||"—"})]}):null]}),n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs($e,{htmlFor:l,className:"text-xs font-normal",children:["Symmetric",n.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:"Both ends mean the same thing, like “connected with”."})]}),n.jsx(Ds,{id:l,checked:j,onCheckedChange:E})]})]}):null,n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:m,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"From"}),n.jsxs(Lt,{value:k,onValueChange:b,children:[n.jsx($t,{id:m,className:"h-8 text-xs",children:n.jsx(Ot,{placeholder:"Type"})}),n.jsx(At,{children:e.map(W=>n.jsx(ut,{value:W.slug,children:W.label},W.slug))})]})]}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx($e,{htmlFor:c,className:"text-xs after:ml-1 after:text-destructive after:content-['*']",children:"To"}),n.jsxs(Lt,{value:w,onValueChange:M,children:[n.jsx($t,{id:c,className:"h-8 text-xs",children:n.jsx(Ot,{placeholder:"Type"})}),n.jsx(At,{children:e.map(W=>n.jsx(ut,{value:W.slug,children:W.label},W.slug))})]})]}),P?n.jsx("p",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P}):null,n.jsx(On,{onCancel:o,cancelDisabled:B,className:"[&>button]:h-7 [&>button]:px-3 [&>button]:text-xs",children:n.jsx(U,{type:"button",size:"sm",onClick:J,disabled:B,children:B?"Saving…":"Add relationship"})})]})}const ms=288,ua=440,vt=240,wt=720,ma=320,en="lobu.schema-panel-width:v1";function kt(e,t){if(!Number.isFinite(e))return ms;const s=Math.max(vt,Math.min(wt,t-ma));return Math.round(Math.min(s,Math.max(vt,e)))}function fa(){const e=An(en);if(e===null)return null;const t=Number.parseInt(e,10);return!Number.isFinite(t)||t<vt||t>wt?null:t}function pa(e){Pn(en,String(Math.round(e)))}function ha(){Fs(en)}const jn={nodes:[],edges:[]};function ga(e,t,s){const{orgContext:o}=Oe(),{data:r=[],isLoading:i,isError:a}=Ct(o),{data:l=[],isLoading:m,isError:c}=Kt(o),y=v.useMemo(()=>ls(l,e),[l,e]),{data:p,isLoading:f,isError:h}=zs(o),x=v.useMemo(()=>{const k=new Map(y.map(w=>[w.id,w.slug])),b={};for(const w of p??[]){const M=k.get(w.relationship_type_id);M&&(b[M]??=[]).push(w)}return b},[p,y]),d=v.useMemo(()=>({entityTypes:r,relationshipTypes:y,rulesBySlug:x,ownerSlug:e,targetAspect:t,flow:s}),[r,y,x,e,t,s]),[N,_]=v.useState(null),j=i||m||f,E=a||c||h;return v.useEffect(()=>{if(j||E)return;let k=!1;const b={targetAspect:d.targetAspect};let w;return d.flow?w=Zt(la(ds(d),d.flow),b):w=sa(d,b),w.then(M=>{k||_({graph:M,isError:!1})}).catch(()=>{k||_({graph:jn,isError:!0})}),()=>{k=!0}},[d,j,E]),{graph:N?.graph??jn,isLoading:!E&&!N,isError:E||N?.isError===!0}}function En(e){const t=e.ruleCount>1?` ×${e.ruleCount}`:"",s=typeof e.linkCount=="number"?` · ${e.linkCount.toLocaleString()}`:"";return`${e.label}${t}${s}`}const Gt={connections:"--chart-3",entities:"--chart-5",automations:"--chart-2",metrics:"--chart-4"};function ya(e,t){const s=e.nodes.some(a=>a.data.ref),o=new Map(e.nodes.map(a=>[a.id,a.data.label])),r=e.nodes.map(a=>({id:a.id,x:a.position.x+a.width/2,y:a.position.y+a.height/2,w:a.width,h:a.height,title:a.data.label,meta:a.data.metaLabel,icon:a.data.icon,badge:a.data.badge??a.data.organizationSlug,muted:a.data.isSystem,dimmed:t?!t.nodes.has(a.id):!1,accent:s?Gt[us(a)]:void 0})),i=e.edges.map(a=>{const{relationships:l,isSymmetric:m,flow:c}=a.data;if(c)return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:c.summary,details:[c.summary,...c.details],directed:!0,dimmed:t?!t.edges.has(a.id):!1,ariaLabel:`${o.get(a.source)??a.source} to ${o.get(a.target)??a.target}: ${c.summary}`};const y=l.map(p=>p.label).join(", ");return{id:a.id,source:a.source,target:a.target,route:a.route??null,summary:l.length===1?En(l[0]):`${l.length} relationships`,details:l.map(En),directed:!m,dimmed:t?!t.edges.has(a.id):!1,ariaLabel:`${o.get(a.source)??a.source} ${m?"and":"to"} ${o.get(a.target)??a.target}: ${y}`}});return{boxes:r,edges:i}}const Cn=[{key:"connections",label:"Connections"},{key:"entities",label:"Entities"},{key:"automations",label:"Automations"},{key:"metrics",label:"Metrics"}],xa={count:"Count",count_distinct:"Distinct count",sum:"Sum",min:"Minimum",max:"Maximum"};function ba({metric:e,ownerSlug:t}){const s=(o,r)=>r.length>0?n.jsxs("section",{className:"flex flex-col gap-1.5",children:[n.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:o}),n.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:r.map(i=>n.jsxs("li",{children:[n.jsx("span",{className:"font-medium",children:i.name}),i.description?n.jsx("span",{className:"text-muted-foreground",children:` · ${i.description}`}):null]},i.name))})]}):null;return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"flex flex-col gap-1",children:[n.jsxs("p",{className:"text-sm",children:[xa[e.agg]??e.agg," of"," ",n.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:e.eventSet})," ","events, per ",e.typeLabel]}),e.description?n.jsx("p",{className:"text-sm text-muted-foreground",children:e.description}):null]}),s("Data from",e.sources.map(o=>({name:o,description:""}))),s("Group by",e.dimensions),s("Segments",e.segments),n.jsx(U,{asChild:!0,variant:"outline",size:"sm",className:"self-start",children:n.jsxs(He,{to:"/$owner/$entityType",params:{owner:t,entityType:e.typeSlug},children:["Open ",e.typeLabel]})})]})}function va({ownerSlug:e,metric:t,endpointOptions:s,canAuthor:o,mode:r,onModeChange:i}){const a=()=>i({kind:"index"});return r.kind==="metric"?t?n.jsx(ba,{metric:t,ownerSlug:e}):null:o?r.kind==="create-type"?n.jsx(Kr,{slug:null,onClose:a}):r.kind==="new-relationship"?n.jsx(da,{entityTypes:s,initialSource:r.source,initialTarget:r.target,onDone:a},`${r.source??""}|${r.target??""}`):null:null}function wa(e){const{mode:t,canAuthor:s,onModeChange:o,isPeekOpen:r}=e,i=s&&t.kind==="create-type",a=t.kind==="metric"?t.name:s&&t.kind==="new-relationship"?"New relationship":i?"New entity type":"Data map",l=v.useRef(null),m=JSON.stringify(t),c=v.useRef(m);return v.useEffect(()=>{c.current!==m&&(c.current=m,l.current?.focus({preventScroll:!0}))},[m]),n.jsx("aside",{style:{"--schema-panel-width":`${e.width}px`},className:ae("order-first flex w-full shrink-0 flex-col lg:order-none lg:w-[var(--schema-panel-width)]",t.kind==="index"?"lg:absolute lg:top-0 lg:right-6 lg:z-10 lg:w-max lg:max-w-[calc(100%-3rem)] lg:max-h-[calc(100%-2rem)]":"bg-background lg:relative",r&&"lg:hidden"),children:n.jsxs("div",{className:ae("flex min-h-0 flex-1 flex-col",t.kind!=="index"&&"lg:absolute lg:inset-0"),children:[n.jsxs("div",{className:t.kind==="index"?"sr-only":"flex h-11 shrink-0 items-center gap-1 border-b border-border px-3",children:[n.jsx("h2",{ref:l,tabIndex:-1,className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground outline-none",children:a}),t.kind!=="index"?n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Close",onClick:()=>o({kind:"index"}),children:n.jsx(Ks,{className:"h-4 w-4"})}):null]}),n.jsx("div",{className:ae("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto",t.kind==="index"?"pb-1":"p-4"),children:n.jsx(va,{...e})})]})})}function fs(e){const t=e.previousElementSibling,s=e.nextElementSibling;if(t instanceof HTMLElement&&s instanceof HTMLElement){const o=t.clientWidth+s.clientWidth;if(o>0)return o}return 0}function ka({width:e,maxWidth:t,onResize:s,onCommit:o,onReset:r,className:i}){const[a,l]=v.useState(!1),m=v.useRef(0),c=f=>{const h=fs(f);return h>0?h:f.parentElement?.clientWidth??0},y=f=>{if(f.button!==0)return;const h=f.currentTarget;if(!h.parentElement)return;f.preventDefault(),m.current=c(h);const d=f.clientX,N=e;l(!0),h.setPointerCapture(f.pointerId);const _=b=>kt(N-(b-d),m.current);let j=N;const E=b=>{j=_(b.clientX),s(j)},k=b=>{h.removeEventListener("pointermove",E),h.removeEventListener("pointerup",k),h.removeEventListener("pointercancel",k),l(!1),o(b.type==="pointercancel"?j:_(b.clientX))};h.addEventListener("pointermove",E),h.addEventListener("pointerup",k),h.addEventListener("pointercancel",k)},p=f=>{const h=c(f.currentTarget),x=d=>{f.preventDefault(),o(kt(e+d,h))};f.key==="ArrowLeft"?x(16):f.key==="ArrowRight"?x(-16):f.key==="Home"&&(f.preventDefault(),r())};return n.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize map panel","aria-valuenow":e,"aria-valuemin":vt,"aria-valuemax":t,tabIndex:0,onPointerDown:y,onKeyDown:p,onDoubleClick:r,className:ae("group hidden shrink-0 cursor-col-resize touch-none items-stretch justify-center px-1.5 outline-none lg:flex",a&&"cursor-col-resize",i),children:n.jsx("div",{className:ae("w-px rounded-full bg-border transition-[background-color,width] group-hover:w-0.5 group-hover:bg-primary/60 group-focus-visible:w-0.5 group-focus-visible:bg-primary",a&&"w-0.5 bg-primary")})})}function Na({ownerSlug:e}){const t=tt(),s=Jt(),o=s?.item!=null,{orgContext:r}=Oe(),{isAdmin:i}=Dn(r.organizationId),[a,l]=v.useState({connections:!0,entities:!0,automations:!0,metrics:!0}),[m,c]=v.useState({kind:"index"}),y=s?.close,p=v.useCallback(g=>{g.kind!=="index"&&o&&y?.(),c(g)},[o,y]),[f,h]=v.useState(),x=v.useRef(null),d=v.useCallback(g=>{if(x.current?.disconnect(),x.current=null,!g||typeof ResizeObserver>"u")return;const S=()=>{if(!g.clientWidth||!g.clientHeight)return;const R=Math.round(g.clientHeight/g.clientWidth*10)/10;h(O=>O===R?O:R)};S();const T=new ResizeObserver(S);T.observe(g),x.current=T},[]),N=r.organizationId,_=Ws(N),j=Bs(N),E=Hs(N),k=qr(N??void 0),{data:b}=Ct(r),w=v.useMemo(()=>b?.filter(g=>Vs(g,e)),[b,e]),M=v.useMemo(()=>(w??[]).flatMap(g=>Object.entries(g.metrics_config?.measures??{}).map(([S,T])=>({typeSlug:g.slug,name:S,agg:T.agg,description:T.description}))),[w]),P=_.isLoading||j.isLoading||E.isLoading||k.isLoading,A=v.useMemo(()=>P?null:{connections:_.data??[],feeds:j.data??[],connectorDefs:E.data??[],automations:k.data??[],metrics:M,layers:a},[P,_.data,j.data,E.data,k.data,M,a]),{graph:I,isLoading:F,isError:B}=ga(e,f,A),J=F||P,W={connections:!P&&(_.data??[]).length===0,entities:!1,automations:!P&&(k.data??[]).length===0,metrics:!P&&M.length===0},se=m.kind==="metric"?m:null,me=v.useMemo(()=>{if(!se)return null;const g=`metric:${se.typeSlug}:${se.name}`,S=I.edges.find(O=>O.target===g);if(!S)return null;const T=S.source,R=I.edges.filter(O=>O.target===T&&I.nodes.find(H=>H.id===O.source)?.data.ref?.kind==="connection");return{typeId:T,nodes:new Set([g,T,...R.map(O=>O.source)]),edges:new Set([S.id,...R.map(O=>O.id)]),sources:R.map(O=>I.nodes.find(H=>H.id===O.source)?.data.label??O.source)}},[se,I]),{boxes:X,edges:Ee}=v.useMemo(()=>ya(I,me),[I,me]),ue=v.useMemo(()=>{if(!se)return null;const g=w?.find(R=>R.slug===se.typeSlug),S=g?.metrics_config,T=S?.measures?.[se.name];return!g||!T?null:{name:se.name,typeSlug:g.slug,typeLabel:g.name||g.slug,agg:T.agg,eventSet:T.eventSet,description:T.description,dimensions:Object.entries(S?.dimensions??{}).map(([R,O])=>({name:R,description:O.description})),segments:Object.entries(S?.segments??{}).map(([R,O])=>({name:R,description:O.description})),sources:me?.sources??[]}},[se,w,me]),G=v.useMemo(()=>new Map(I.nodes.map(g=>[g.id,g.data.slug])),[I.nodes]),te=v.useMemo(()=>new Map(I.nodes.flatMap(g=>g.data.ref?[[g.id,g.data.ref]]:[])),[I.nodes]),{data:xe=[]}=Us(r.organizationId),Ce=v.useMemo(()=>{const g=new Map;for(const S of I.nodes)S.data.ref||(!S.data.organizationSlug||!g.has(S.data.slug))&&g.set(S.data.slug,{slug:S.data.slug,label:S.data.label});return[...g.values()]},[I.nodes]),Ve=v.useCallback(g=>{const S=te.get(g);if(S?.kind==="connection"){t({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:S.connectorKey,connectionId:String(S.connectionId)},search:{}});return}if(S?.kind==="metric"){p({kind:"metric",typeSlug:S.typeSlug,name:S.name});return}if(S?.kind==="automation"){t({to:"/$owner/automations/$automationId",params:{owner:e,automationId:S.automationId},search:{view:"activity",run_id:void 0}});return}t(Fn(e,G.get(g)??g))},[t,e,G,te,p]),ie=v.useCallback((g,S)=>{te.has(g)||te.has(S)||p({kind:"new-relationship",source:G.get(g)??g,target:G.get(S)??S})},[G,te,p]),ke=!!w?.some(g=>!$n(g)),Ae=I.nodes.some(g=>g.data.ref),be="size-6 text-muted-foreground hover:text-foreground",Ue={connections:n.jsx(Gr,{ownerSlug:e,catalog:xe,trigger:n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:be,"aria-label":"New connector",title:"New connector",children:n.jsx(it,{className:"size-3.5"})})}),entities:n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:be,"aria-label":"Create entity type",title:"Create entity type",onClick:()=>p({kind:"create-type"}),children:n.jsx(it,{className:"size-3.5"})}),automations:n.jsx(U,{asChild:!0,variant:"ghost",size:"icon",className:be,children:n.jsx(He,{to:"/$owner/automations/new",params:{owner:e},"aria-label":"New Automation",title:"New Automation",children:n.jsx(it,{className:"size-3.5"})})})},Ne=v.useCallback(g=>{const S=g.startsWith(Ut)?g.slice(Ut.length):null;if(!S)return n.jsx(Et,{icon:g||null,className:"h-4 w-4"});const T=Gs(S,E.data??[],{name:_.data?.find(R=>R.connector_key===S)?.connector_name??S});return n.jsx(qs,{plain:!0,icon:T.icon,iconUrl:T.iconUrl,name:T.name,faviconDomain:T.faviconDomain})},[E.data,_.data]),Pe=i&&m.kind==="create-type",fe=m.kind==="metric"||i&&m.kind!=="index",[_e,pe]=v.useState(()=>fa()),Me=_e??(Pe?ua:ms),[re,nt]=v.useState(null),ge=v.useRef(null),Te=v.useCallback(g=>{if(ge.current?.disconnect(),ge.current=null,!g||typeof ResizeObserver>"u")return;const S=g.children[1];if(!S)return;const T=()=>{const O=fs(S);O>0&&nt(H=>H===O?H:O)};T();const R=new ResizeObserver(T);R.observe(g),ge.current=R},[]),De=re===null?Me:kt(Me,re),Fe=re===null?wt:kt(wt,re),C=v.useCallback(g=>{pe(g),pa(g)},[]),u=v.useCallback(()=>{pe(null),ha()},[]);return J?n.jsx(Qt,{label:"Loading data map",fill:!0,schemaActions:i}):B?n.jsx("div",{className:"flex min-w-0 flex-col gap-3",children:n.jsx(zn,{label:"data map"})}):n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[n.jsxs("div",{className:ae("flex flex-wrap items-center justify-between gap-3",fe&&"hidden lg:flex"),children:[n.jsx("div",{className:"flex min-w-0 items-center gap-3",children:n.jsx("p",{className:"min-w-0 text-sm text-muted-foreground",children:Ae?"Where records come from and what uses them.":ke?I.edges.length>0?"Your record types and how they relate.":"Your record types.":i?"Add the types of record you track.":"No record types yet."})}),n.jsxs("fieldset",{className:"m-0 flex min-w-0 shrink-0 flex-wrap items-center gap-x-4 gap-y-1 border-0 p-0 text-sm",children:[n.jsx("legend",{className:"sr-only",children:"Show on the map"}),Cn.map(({key:g,label:S})=>{const T=`memory-map-show-${g}`,R=a[g]&&!W[g]&&Cn.filter(({key:O})=>a[O]&&!W[O]).length===1;return n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[n.jsx(Ys,{id:T,checked:a[g],disabled:R,style:{borderColor:`var(${Gt[g]})`,backgroundColor:a[g]?`var(${Gt[g]})`:void 0},onCheckedChange:O=>l(H=>({...H,[g]:O===!0}))}),n.jsx("label",{htmlFor:T,className:"inline-flex cursor-pointer select-none items-center",children:S}),i?Ue[g]:null]},g)})]})]}),n.jsxs("div",{ref:Te,className:"relative flex min-h-0 min-w-0 flex-1 flex-col gap-3 lg:-mr-6 lg:-mb-8 lg:flex-row lg:gap-0",children:[n.jsx("div",{className:ae("flex min-w-0 flex-1 flex-col lg:pb-8",fe&&"hidden lg:flex"),children:n.jsx("div",{ref:d,className:"min-h-[420px] min-w-0 flex-1 overflow-hidden rounded-lg bg-background",children:n.jsx(cs,{boxes:X,edges:Ee,label:"Data map",onOpenBox:Ve,openLabel:g=>`Open ${g.title}`,onConnect:i?ie:void 0,renderIcon:Ne})})}),n.jsx(ka,{width:De,maxWidth:Fe,onResize:pe,onCommit:C,onReset:u,className:o||m.kind==="index"?"lg:hidden":void 0}),n.jsx(wa,{width:De,metric:ue,ownerSlug:e,endpointOptions:Ce,canAuthor:i,mode:m,onModeChange:p,isPeekOpen:o})]})]})}function Sa({onClose:e,entityTypeSlug:t,orgContext:s,onSuccess:o}){const{data:r,isLoading:i}=Wn(t,s),a=`${s.organizationId??s.slug}:${t}`,l=Js(a,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},r?.metadata_schema),[m,c]=l.field("name"),[y,p]=l.field("customSlug"),[f,h]=l.field("useCustomSlug"),[x,d]=l.field("metadata"),[N,_]=Xs(a,null),j=Qs(),E=f?y:Zs(m),k=async A=>{if(A.preventDefault(),!l.canSubmit)return;if(_(null),!m.trim()){_("Name is required");return}const I=Xr(x),F={entityType:t,name:m.trim(),slug:f?y:void 0,metadata:Object.keys(I).length>0?I:void 0};try{const B=await j.mutateAsync(F);if(e(),B.approval_queued||!B.entity){Bn.info("Create queued for approval");return}typeof B.entity.id=="number"&&o?.(B.entity.id)}catch(B){_(B instanceof Error?B.message:"Failed to create entity")}},b=r?.name||t,w=l.revision,M=`Create ${b}`,P=`Add a new ${b.toLowerCase()} to your workspace.`;return i?n.jsx(er,{rows:6}):n.jsxs("form",{onSubmit:k,children:[n.jsx(tr,{visible:l.hasConflict,onReload:l.reset}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:M}),n.jsx("p",{className:"text-sm text-muted-foreground",children:P})]}),n.jsxs("div",{className:"grid gap-4 py-4",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsxs($e,{htmlFor:"name",children:["Name ",n.jsx("span",{className:"text-destructive",children:"*"})]}),n.jsx(et,{id:"name",value:m,onChange:A=>c(A.target.value),placeholder:`Enter ${b.toLowerCase()} name`,autoFocus:!0})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx($e,{htmlFor:"slug",children:"URL Slug"}),n.jsx("button",{type:"button",onClick:()=>h(!f),className:"text-xs text-muted-foreground hover:text-foreground",children:f?"Auto-generate":"Customize"})]}),f?n.jsx(et,{id:"slug",value:y,onChange:A=>p(A.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):n.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:E||"slug-preview"})]}),w&&Object.keys(w).length>0?n.jsxs(n.Fragment,{children:[n.jsx(Qr,{className:"my-2"}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx($e,{className:"text-sm font-medium",children:"Additional Fields"}),n.jsx(Jr,{schema:l.revision,values:x,onValuesChange:d,orgContext:s})]})]}):null,N&&n.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:N})]}),n.jsx(On,{onCancel:e,cancelDisabled:j.isPending,className:"mt-2",children:n.jsx(U,{type:"submit",disabled:!l.canSubmit||j.isPending||!m.trim(),children:j.isPending?"Creating...":`Create ${b}`})})]})}function ja(e){const t=e?.properties??{},s=or(e);return Object.entries(t).flatMap(([o,r])=>{const i=s.find(p=>p.field===o);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(o)||!r||r.const!==void 0||r["x-table-column"]!==!0&&r["x-facet"]!==!0&&!i)return[];const a=[r,...Array.isArray(r.anyOf)?r.anyOf:[]],l=i?.options??[],m=l.find(p=>p.value!==null)?.value,c=a.find(p=>["string","number","integer","boolean"].includes(String(p.type)))??(m===void 0?void 0:{type:typeof m});if(!c)return[];const y=r.format==="date-time"||c.format==="date-time"?"datetime-local":r.format==="date"||c.format==="date"?"date":c.type==="number"||c.type==="integer"?"number":c.type==="boolean"?"boolean":"string";return[{field:o,label:String(r["x-table-label"]??r.title??o.replaceAll("_"," ")),type:y,options:y==="boolean"&&!l.some(p=>typeof p.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...l]:l}]})}function Ea(e){const t=e?.[Ht];return t===void 0?{}:Xt(t)}function Ca(e,t,s){try{const o=Ea(t),r=e[Hn],i=r===void 0?void 0:o.presets?.find(y=>y.key===r);if(r!==void 0&&!i)throw new Error("This saved filter is unavailable. Choose another filter.");if(i&&!s&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const a=i&&e[Qe]===void 0?{collection:yt(i)}:nr(e,s);if(a.error)throw a.error;const l=e[sr],m=l===void 0?i?.table??o.table??{}:Xt({table:typeof l=="string"?JSON.parse(l):l}).table??{},c=!!i&&(_n(a.collection)!==_n(yt(i))||Nt(m)!==Nt(i.table??o.table??{}));return{...a,presentation:o,preset:i,table:m,edited:c}}catch(o){return{collection:{},presentation:{},table:{},edited:!1,error:o instanceof Error?o:new Error("Invalid collection configuration")}}}function _n(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(ht)])}function ht(e){return JSON.stringify([e.field,e.op,e.value])}function Nt(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function _a(e,t){return t?{[Hn]:t,[Qe]:Bt(e)[Qe]??"{}"}:Bt(e)}function Ma(e,t,s,o,r=new Date){let i=t.filters??[],a=e.relativeDate;if(a){const l=(yt({...e,selection:{}},r).filters??[]).map(ht),m=i.map(ht);l.every(c=>m.includes(c))?i=i.filter(c=>!l.includes(ht(c))):a=void 0}return{key:e.key,label:e.label,selection:{...t.search?{search:t.search}:{},...i.length?{filters:i}:{},...t.segment?{segment:t.segment}:{}},...Nt(s)!==Nt(o.table??{})?{table:s}:{},...a?{relativeDate:a}:{}}}function Ta(e,t,s){const o=[...e.filters??[]],r=s??(t.length===1&&t[0].op==="eq"?o.findIndex(a=>a.field===t[0].field&&a.op==="eq"):-1),i=r>=0?[...o.slice(0,r),...t,...o.slice(r+1)]:[...o,...t];return{...e,filters:ar({filters:i}).filters}}function Ra(e,t){return{...e,filters:e.filters?.filter((s,o)=>o!==t)}}function Ia(e,t){return{...typeof e.$preset=="string"?e[Qe]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[Qe]:String(rr(e[Qe]))}:Bt(t),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const La=[{field:"name",label:"Name"},{field:"created_at",label:"Created"},{field:"total_content",label:"Activity count"},{field:"active_connections",label:"Connections"},{field:"automations_count",label:"Automations"},{field:"children_count",label:"Children"}];function $a(e){return e.sort&&La.some(t=>t.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Oa(e,t,s,o,r){const i={...o,filters:o.filters?.filter(a=>a.field!==s)};return Vn({queryKey:["collection-facets",e,t,s,i],enabled:!!t&&!!s,staleTime:3e4,retry:!1,queryFn:async({signal:a})=>{const l=await xt("query_sdk",{title:`Value counts query for ${s}`,script:`const input = ${JSON.stringify({field:s,collection:i})};
|
|
2
|
-
${t}`},e,{signal:a}),m=l.return_value;if(!l.success||typeof m?.connection!="string"||typeof m.sql!="string")throw new Error(l.error?.message??"Value distribution is unavailable");if(a.aborted)throw new DOMException("Aborted","AbortError");const c=await xt("query_sql",{title:`Value counts for ${s}`,connection:m.connection,sql:m.sql,limit:51},e,{signal:a});if(c.error)throw new Error(c.error);if(!Array.isArray(c.rows))throw new Error("Source did not return value counts");const y=c.rows.map(p=>{const f=p,h=typeof f.count=="string"&&/^\d+$/.test(f.count)?Number(f.count):f.count;if(!(f.value===null||["string","number","boolean"].includes(typeof f.value))||typeof h!="number"||!Number.isSafeInteger(h)||h<0)throw new Error("Source returned an invalid value distribution");return{value:f.value,count:h}});return{values:y.slice(0,50),truncated:y.length>50||c.truncated===!0}}})}const Aa=300;function Pa({label:e,search:t,onSearch:s,className:o}){const r=t??"",[i,a]=v.useState(r),l=v.useRef({search:t,onSearch:s});l.current={search:t,onSearch:s};const m=v.useRef(void 0);v.useEffect(()=>{const y=()=>{clearTimeout(m.current),a(l.current.search??"")};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[]);const c=v.useRef(r);return v.useEffect(()=>{r!==c.current&&(c.current=r,a(r))},[r]),v.useEffect(()=>{if(i===(l.current.search??""))return;const y=setTimeout(()=>{const p=l.current.onSearch;c.current=i,p(i||void 0,!0)},Aa);return m.current=y,()=>clearTimeout(y)},[i]),n.jsxs("div",{className:`relative${o?` ${o}`:""}`,children:[n.jsx(cr,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(et,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:i,onChange:y=>a(y.target.value),className:"pl-9"})]})}const Da={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Fa({field:e,initial:t,org:s,facetQuery:o,collection:r,onApply:i,close:a}){const[l,m]=v.useState(t?.op??"eq"),[c,y]=v.useState(t?.value==null?"":String(t.value)),[p,f]=v.useState(""),[h,x]=v.useState(!1),[d,N]=v.useState(),_=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",j=Oa(s,o,e.field,r),E=w=>{try{const M=h?[{field:e.field,op:"gte",value:e.type==="number"?Number(c):c},{field:e.field,op:"lte",value:e.type==="number"?Number(p):p}]:[{field:e.field,op:l,value:w}];if(e.type==="datetime-local")for(const I of M)typeof I.value=="string"&&(I.value=new Date(I.value).toISOString());if(M.some(I=>typeof I.value=="number"&&!Number.isFinite(I.value)))throw new Error("Enter a valid number.");const P=M[0].value,A=M[1]?.value;if(h&&P!=null&&A!=null&&P>A)throw new Error("The lower bound must be before the upper bound.");i(M),a()}catch(M){N(M instanceof Error?M.message:"Could not apply filter")}},k=[...e.options];for(const w of j.data?.values??[])k.some(M=>M.value===w.value)||k.push({value:w.value,label:w.value===null?"Not supplied":String(w.value)});const b=Math.max(1,...j.data?.values.map(w=>w.count)??[]);return n.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[n.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:h?"range":l,onChange:w=>{x(w.target.value==="range"),w.target.value!=="range"&&m(w.target.value)},children:[n.jsx("option",{value:"eq",children:"is"}),n.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"lt",children:"less than / before"}),n.jsx("option",{value:"lte",children:"at most / on or before"}),n.jsx("option",{value:"gt",children:"greater than / after"}),n.jsx("option",{value:"gte",children:"at least / on or after"}),t?null:n.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&n.jsxs("form",{className:"space-y-2",onSubmit:w=>{w.preventDefault(),E(e.type==="number"?Number(c):c)},children:[n.jsx(et,{required:!0,"aria-label":h?"From value":"Filter value",type:_,step:e.type==="number"?"any":void 0,value:c,onChange:w=>y(w.target.value),placeholder:"Enter a value…"}),h&&n.jsx(et,{required:!0,"aria-label":"To value",type:_,step:e.type==="number"?"any":void 0,value:p,onChange:w=>f(w.target.value)}),n.jsx(U,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!h&&(l==="eq"||l==="neq")&&n.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:k.filter(w=>!c||w.label.toLowerCase().includes(c.toLowerCase())).map(w=>{const M=j.data?.values.find(P=>P.value===w.value)?.count;return n.jsxs("button",{type:"button","aria-label":w.label,onClick:()=>E(w.value),className:"relative flex w-full items-center justify-between gap-3 overflow-hidden rounded px-2 py-1.5 text-left text-sm hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[M!==void 0&&n.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${M/b*100}%`}}),n.jsx("span",{className:"relative truncate",children:w.label}),n.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:M?.toLocaleString()})]},JSON.stringify(w.value))})}),o&&j.isFetching&&n.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),j.isError&&n.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),j.data?.truncated&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),d&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d})]})}function za({collection:e,schema:t,label:s,onChange:o,org:r,facetQuery:i,segmentChip:a,viewFilters:l,onClearAll:m}){const c=ja(t),y=(x,d)=>({kind:"custom",className:"w-80",render:N=>n.jsx(Fa,{field:x,initial:d==null?void 0:e.filters?.[d],org:r,facetQuery:i,collection:e,onApply:_=>o(Ta(e,_,d)),close:N})}),p=c.map(x=>({key:x.field,label:x.label,icon:n.jsx(ir,{className:"h-4 w-4"}),editor:y(x)})),f=new Map,h=(e.filters??[]).map((x,d)=>{const N=`${x.field}:${x.op}:${JSON.stringify(x.value)}`,_=f.get(N)??0;f.set(N,_+1);const j=c.find(k=>k.field===x.field),E=j?.options.find(k=>k.value===x.value)?.label??String(x.value??"Not supplied");return{id:`${N}:${_}`,label:j?.label??x.field,op:Da[x.op],value:E,editor:j?y(j,d):void 0,onRemove:()=>o(Ra(e,d))}});if(a&&h.unshift(a),l?.fields.length){for(const x of p)x.group=s;p.push(...l.fields),h.push(...l.chips)}return!p.length&&!h.length?null:n.jsx(so,{label:`${s} filters`,fields:p,chips:h,onClearAll:m??(()=>o({...e,filters:[],segment:void 0}))})}const St=120,je=12;function Mn(e,t){return typeof e.linkId=="number"&&typeof t.linkId=="number"?e.linkId-t.linkId:String(e.linkId).localeCompare(String(t.linkId))}function Wa(e){const t=e.records.slice(0,St),s=c=>e.types.get(c)??{label:c},o=new Map;for(const c of t)o.set(String(c.id),{source:c.source,entityType:e.typeSlug,slug:c.slug,name:c.name,isFocus:!0,hasMoreLinks:!1});const r=new Map;for(const c of e.links){if(!o.has(String(c.recordId)))continue;const y=r.get(c.recordId)??new Map;y.set(c.linkId,c),r.set(c.recordId,y)}const i=new Map;for(const[c,y]of r){const p=[...y.values()].sort(Mn),f=o.get(String(c));f&&p.length>je&&(f.hasMoreLinks=!0);for(const h of p.slice(0,je)){i.set(h.linkId,h);const x=String(h.peer.id);o.has(x)||o.set(x,{source:h.peer.source,...h.peer.remote?{remote:h.peer.remote}:{},entityType:h.peer.type,slug:h.peer.slug,name:h.peer.name,isFocus:!1,hasMoreLinks:!1})}}const a=[];for(const[c,y]of o){const p=y.remote?{label:y.entityType}:s(y.entityType),f=y.name||y.slug,h=y.hasMoreLinks?`${p.label} · ${je}+ links`:p.label;a.push({id:c,data:{slug:y.slug,label:f,icon:p.icon,isSystem:!1,metaLabel:h},width:ct(f,h),height:Ze})}const l=new Map;for(const c of[...i.values()].sort(Mn)){const y=String(c.fromId),p=String(c.toId),f=JSON.stringify([y,p]),h=l.get(f)??{source:y,target:p,rels:new Map,symmetric:!0};h.symmetric&&=c.isSymmetric,h.rels.has(c.relSlug)||h.rels.set(c.relSlug,{slug:c.relSlug,label:c.relName,ruleCount:1}),l.set(f,h)}const m=[...l.entries()].map(([c,y])=>({id:`link:${c}`,source:y.source,target:y.target,data:{relationships:[...y.rels.values()],isSymmetric:y.symmetric}}));return{nodes:a,edges:m,records:o,hasMoreRecords:e.hasMore===!0||e.records.length>St,listedCount:t.length,focusCount:t.length}}async function Ba(e,t){const s=Wa(e);return{...await Zt({nodes:s.nodes,edges:s.edges},t),records:s.records,hasMoreRecords:s.hasMoreRecords,listedCount:s.listedCount,focusCount:s.focusCount}}const Ha=8,Va=3,Ua=4;function gt(e){return`source:${JSON.stringify([e.type,e.key])}`}function Ga(e,t){return t.map(s=>{const o={type:e,key:s.slug};return{...s,id:gt(o),source:o}})}function Tn(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function qa(e,t,s){const o=e.slice(0,Ha),r=[];let i=0;return await Promise.all(Array.from({length:Math.min(Va,o.length)},async()=>{for(;i<o.length;){const a=i++,l=o[a];try{if(s?.aborted)throw s.reason;const m=await t(l),c=new Map(l.links.map(N=>[Tn(N),N]));for(const N of m.record_links){const _=Tn(N),j=c.get(_);(!j||j.occurred_at<N.occurred_at)&&c.set(_,N)}const y=new Map((l.relationships??[]).map(N=>[N.id,N]));for(const N of m.relationships??[])y.set(N.id,N);const p=[...y.values()].slice(0,je+1),f=[...c.values()].slice(0,je+1),h=(l.pagesRead??0)+1,x=!!m.next_cursor&&h>=Ua,d=m.record_failures.length>0||!!m.relationship_failures?.length||x;r[a]={read:{record:l.record,links:f,failed:d,entityId:l.entityId,relationships:p},...!x&&(d||m.next_cursor&&f.length+p.length<=je)?{next:{record:l.record,entityId:l.entityId,relationships:p,pagesRead:h,cursor:m.next_cursor??l.cursor,links:f}}:{}}}catch(m){if(s?.aborted)throw m;r[a]={read:{record:l.record,links:l.links,failed:!0,entityId:l.entityId,relationships:l.relationships},next:{...l,cursor:m instanceof lr&&m.status===400?null:l.cursor}}}}})),{reads:r.map(a=>a.read),pending:[...r.flatMap(a=>a.next?[a.next]:[]),...e.slice(o.length)]}}function Ya(e,t){const s=new Map;for(const i of e)for(const a of i.reads)s.set(String(a.entityId??gt(a.record)),a);const o=new Map(t.map(i=>[i.slug,i])),r=[];for(const[i,a]of s){for(const l of a.relationships??[]){const m=(N,_,j)=>j?`remote:${j}`:typeof N=="number"?N:gt({type:_,key:N}),c=m(l.from_entity_id,l.from_entity_type,l.from_entity_url),y=m(l.to_entity_id,l.to_entity_type,l.to_entity_url),p=String(c)===i,f=p?y:c,h=p?l.to_entity_id:l.from_entity_id,x=p?l.to_entity_url:l.from_entity_url,d=(p?l.to_entity_type:l.from_entity_type)??"";r.push({recordId:i,linkId:l.id,fromId:c,toId:y,relSlug:l.relationship_type_slug,relName:l.relationship_type_name,isSymmetric:l.is_symmetric,peer:{id:f,name:(p?l.to_entity_name:l.from_entity_name)??String(h),slug:(p?l.to_entity_slug:l.from_entity_slug)??String(h),type:d,...x?{remote:{url:dr(x)}}:typeof h=="string"?{source:{type:d,key:h}}:{}}})}for(const l of a.links){const m={type:l.entity_type,key:l.key},c=gt(m),y=o.get(l.relationship_type);let p=l.direction==="incoming"?c:i,f=l.direction==="incoming"?i:c;y?.is_symmetric&&p>f&&([p,f]=[f,p]),r.push({recordId:i,linkId:JSON.stringify([p,f,l.relationship_type]),fromId:p,toId:f,relSlug:l.relationship_type,relName:y?.name||l.relationship_type.replaceAll("_"," "),isSymmetric:y?.is_symmetric??!1,peer:{id:c,name:l.name||l.key,slug:l.key,type:l.entity_type,source:m}})}}return{links:r,checked:s.size,failed:[...s.values()].filter(i=>i.failed).length}}function Ka(e,t,s,o,r,i=!1){const{orgContext:a}=Oe(),l=Ct(a),m=Kt(a),c=v.useMemo(()=>i?Ga(t,s):s,[i,t,s]),y=v.useMemo(()=>c.slice(0,St).flatMap(k=>k.source?[{record:k.source,cursor:null,links:[]}]:typeof k.id=="number"?[{entityId:k.id,record:{type:t,key:k.slug},cursor:null,links:[]}]:[]),[c,t]),p=ur({queryKey:["source-records-graph",a.organizationId,e,t,y.map(k=>[k.record,k.entityId])],enabled:!0,initialPageParam:y,queryFn:({pageParam:k,signal:b})=>qa(k,async w=>{const M=await xt("manage_entity",{action:"list_links",...w.entityId===void 0?{record:w.record,cursor:w.cursor}:{entity_id:w.entityId,offset:Number(w.cursor??0)},limit:je+1},e,{signal:b});return{...M,record_links:M.record_links??[],record_failures:M.record_failures??[],next_cursor:w.entityId===void 0?M.next_cursor:M.metadata?.has_more?String(Number(w.cursor??0)+je+1):null}},b),getNextPageParam:k=>k.pending.length?k.pending:void 0,staleTime:3e4,retry:!1}),f=v.useMemo(()=>p.data?Ya(p.data.pages,m.data??[]):void 0,[p.data,m.data]),h=f?.links,x=p.isError,d=JSON.stringify([a.organizationId,e,t,i,c.map(k=>[k.id,k.name,k.slug]),o]),N=v.useMemo(()=>new Map((l.data??[]).map(k=>[k.slug,{label:k.name||k.slug,icon:k.icon}])),[l.data]),[_,j]=v.useState(null);v.useEffect(()=>{if(!h)return;let k=!1;return Ba({typeSlug:t,records:c,hasMore:o,links:h,types:N},{targetAspect:r}).then(b=>{k||j({graph:b,key:d,isError:!1})}).catch(()=>{k||j({graph:null,key:d,isError:!0})}),()=>{k=!0}},[h,t,c,o,N,r,d]);const E=_?.key===d?_:null;return{graph:E?.graph??null,isLoading:!x&&!E,isError:x||E?.isError===!0,sourceProgress:{checked:f?.checked??0,total:Math.min(s.length,St),failed:f?.failed??0,hasMore:!!p.hasNextPage,isFetching:p.isFetching,loadMore:()=>{p.isFetching||p.fetchNextPage()}}}}function Ja(e){const t=new Map(e.nodes.map(r=>[r.id,r.data.label])),s=e.nodes.map(r=>({id:r.id,x:r.position.x+r.width/2,y:r.position.y+r.height/2,w:r.width,h:r.height,title:r.data.label,meta:r.data.metaLabel,icon:r.data.icon,muted:e.records.get(r.id)?.isFocus===!1})),o=e.edges.map(r=>{const{relationships:i,isSymmetric:a}=r.data,l=i.map(m=>m.label);return{id:r.id,source:r.source,target:r.target,route:r.route??null,summary:l.length===1?l[0]:`${l.length} relationships`,details:l,directed:!a,ariaLabel:`${t.get(r.source)??r.source} ${a?"and":"to"} ${t.get(r.target)??r.target}: ${l.join(", ")}`}});return{boxes:s,edges:o}}function Xa({ownerSlug:e,typeSlug:t,records:s,hasMore:o,sourceBacked:r=!1}){const i=tt(),a=Jt(),{orgContext:l}=Oe(),{data:m=[]}=Ct(l),c=m.find(b=>b.slug===t)?.name??t,[y,p]=v.useState(),f=v.useRef(null),h=v.useCallback(b=>{if(f.current?.disconnect(),f.current=null,!b||typeof ResizeObserver>"u")return;const w=()=>{if(!b.clientWidth||!b.clientHeight)return;const P=Math.round(b.clientHeight/b.clientWidth*10)/10;p(A=>A===P?A:P)};w();const M=new ResizeObserver(w);M.observe(b),f.current=M},[]),{graph:x,isLoading:d,isError:N,sourceProgress:_}=Ka(e,t,s,o,y,r),j=v.useMemo(()=>x?Ja(x):null,[x]),E=v.useCallback(b=>{const w=x?.records.get(b);if(w){if(w.remote){w.remote.url&&window.open(w.remote.url,"_blank","noopener,noreferrer");return}if(a){a.open(ro({...w.source?{record:w.source}:{entityId:Number(b)},ownerSlug:e,orgContext:l,name:w.name||w.slug}));return}i({to:mr(e,[{entity_type:w.entityType,slug:w.slug}])})}},[x,e,l,a,i]);if(N)return n.jsx(zn,{label:`${c} graph`});if(d||!x||!j)return n.jsx(Qt,{label:`Loading ${c} graph`});const k=_?n.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[n.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[n.jsxs("p",{children:["Checked ",_.checked," of ",_.total," records. Up to ",je," relationships per record."]}),_.failed>0?n.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),_.hasMore?n.jsx(U,{variant:"outline",size:"sm",disabled:_.isFetching,onClick:_.loadMore,children:_.isFetching?"Loading…":_.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return x.focusCount===0?n.jsxs("div",{className:"space-y-3",children:[k,n.jsx(Un,{icon:Gn,title:`No ${c} records match`,description:"Change the search or filters to see records here."})]}):n.jsxs("div",{className:"flex flex-col gap-2",children:[k,n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",x.hasMoreRecords?"the first ":"",x.focusCount," ",c," record",x.focusCount===1?"":"s",". Click a record to see it."]}),n.jsx("div",{ref:h,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:n.jsx(cs,{boxes:j.boxes,edges:j.edges,label:`${c} records`,onOpenBox:E,openLabel:b=>`Show ${b.title}`})})]})}function Qa(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function ps(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function tn(e){const t=e?.properties;if(!t)return null;const r=fr(t).find(([,c])=>ps(c)==="workflowState");if(!r)return null;const[i,a]=r,l=a["x-lobu"]?.states,m=Array.isArray(l)&&l.length>0?l:(a.enum??[]).map(c=>({value:c}));return m.length===0||m.some(c=>typeof c.value!="string")?null:{field:i,states:m.map(c=>({...c,label:c.label||pr(a,c.value)||Qa(c.value),terminal:c.terminal??["done","complete","completed","closed","archived"].includes(c.value.toLowerCase())}))}}function Za(e){const t=e?.properties;if(!t)return null;const s=Object.entries(t),o=s.find(([,a])=>ps(a)==="sortRank"),r=s.find(([a])=>["rank","sort_rank","order"].includes(a)),i=o??r;return i?{field:i[0]}:null}function ei(e,{isDerived:t}){const s=e?.["x-lobu"]?.defaultView;return(s==="table"||s==="board")&&!(t&&s!=="table")?s:t?"table":tn(e)?"board":"table"}const hs={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},ti={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function ni(e){const{canShowBoard:t,builtinData:s,builtInLabels:o}=e,r=["table",...t?["board"]:[]],i={table:hs,board:ti};return r.map(a=>({id:a,label:o[a],builtInMode:a,template:i[a],data:s}))}function qt(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function jt(e,t){if(!t)return e.created_at??String(e.id);const s=_t(e.metadata);return String(s[t.field]??e.created_at??e.id)}function si(e,t){const s=e?Number(e):Number.NaN,o=t?Number(t):Number.NaN;return Number.isFinite(s)&&Number.isFinite(o)&&s<o?String((s+o)/2):Number.isFinite(s)?String(s+1):Number.isFinite(o)?String(o-1):String(Date.now())}function Yt(e,t){const s=_t(e.metadata);return String(s[t]??"")}function gs(e,t){return[...e].sort((s,o)=>jt(s,t).localeCompare(jt(o,t)))}function ri(e,t,s,o,r){if(!t.startsWith("card:")||!s)return null;const i=Number(t.slice(5)),a=e.find(j=>j.id===i);if(!a)return null;const l=s.startsWith("column:")?s.slice(7):Yt(e.find(j=>`card:${j.id}`===s)??a,o.field);if(!l)return null;const m=gs(e.filter(j=>j.id!==i&&Yt(j,o.field)===l),r),c=s.startsWith("card:")?m.findIndex(j=>`card:${j.id}`===s):m.length,y=c>=0?c:m.length,p=y>0?m[y-1]:void 0,f=m[y],h=r?si(p?jt(p,r):void 0,f?jt(f,r):void 0):void 0,x=_t(a.metadata),d={[o.field]:l,...r&&h?{[r.field]:h}:{}};o.states.find(j=>j.value===l)?.terminal&&!x.completed_at&&(d.completed_at=new Date().toISOString());const _={...x,...d};return{entityId:i,changedMetadata:d,nextMetadata:_}}function Rn(e,t,s){return e.map(o=>o.id===t?{...o,metadata:s}:o)}function oi({id:e,children:t,className:s}){const{setNodeRef:o,isOver:r}=rs({id:`column:${e}`});return n.jsx("div",{ref:o,className:ae("min-h-[220px] rounded-lg bg-card p-2 transition-colors",r?"bg-accent/50":"",s),children:t})}function ai({entity:e,owner:t,statusField:s,entityTypeIcon:o,schema:r,didDragRef:i}){const a=_t(e.metadata),{attributes:l,listeners:m,setNodeRef:c,transform:y,isDragging:p}=fo({id:`card:${e.id}`}),{setNodeRef:f,isOver:h}=rs({id:`card:${e.id}`}),x=qn(t,ss(e)),d=N=>{i.current&&(N.preventDefault(),N.stopPropagation())};return n.jsx("div",{ref:N=>{c(N),f(N)},style:{transform:po.Translate.toString(y)},className:ae(yr,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",p?"opacity-60":"",h?"ring-1 ring-ring":""),children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("button",{type:"button",className:"mt-0.5 shrink-0 cursor-grab touch-none text-muted-foreground/60 hover:text-foreground active:cursor-grabbing","aria-label":`Drag ${e.name}`,...l,...m,children:n.jsx(gr,{className:"h-4 w-4"})}),n.jsx(ns,{metadata:a,metadataSchema:r,name:e.name,typeIcon:o,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx(He,{to:x,className:"font-medium text-foreground hover:underline",onClick:d,children:e.name}),n.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof a.priority=="string"&&a.priority?n.jsx(Vt,{variant:"outline",className:"text-xs",children:qt(a.priority)}):null,typeof a[s]=="string"&&a[s]?n.jsx(Vt,{variant:"secondary",className:"text-xs",children:qt(String(a[s]))}):null]})]})]})})}function ii({owner:e,entities:t,totalCount:s,schema:o,entityTypeIcon:r,onUpdate:i}){const a=v.useMemo(()=>tn(o),[o]),l=v.useMemo(()=>Za(o),[o]),[m,c]=v.useState(t),[y,p]=v.useState(()=>new Set),f=v.useRef(!1),h=co(lo(mo,{activationConstraint:{distance:6}})),x=v.useCallback(()=>{window.setTimeout(()=>{f.current=!1},0)},[]);v.useEffect(()=>{c(t)},[t]);const d=v.useMemo(()=>{if(!a)return new Map;const E=new Map(a.states.map(k=>[k.value,[]]));for(const k of m){const b=Yt(k,a.field),w=E.has(b)?b:a.states[0]?.value;w&&E.get(w)?.push(k)}for(const[k,b]of E)E.set(k,gs(b,l));return E},[m,l,a]);if(!a)return null;const N=E=>{p(k=>{const b=new Set(k);return b.has(E)?b.delete(E):b.add(E),b})},_=()=>{f.current=!0},j=E=>{const k=String(E.active.id),b=E.over?String(E.over.id):null,w=ri(m,k,b,a,l);if(!w){x();return}const{entityId:M,changedMetadata:P,nextMetadata:A}=w,F=m.find(B=>B.id===M)?.metadata;c(B=>Rn(B,M,A)),i(M,P).catch(()=>{c(B=>Rn(B,M,F))}),x()};return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-base font-semibold",children:"Board"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",qt(a.field),typeof s=="number"&&s>m.length?n.jsxs(n.Fragment,{children:[" · ",n.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",m.length," of ",s," — narrow with search"]})]}):null]})]}),n.jsx(uo,{sensors:h,onDragStart:_,onDragEnd:j,children:n.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:a.states.map(E=>{const k=d.get(E.value)??[],b=E.collapsed??E.terminal,w=b&&!y.has(E.value);return n.jsxs(oi,{id:E.value,children:[n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[E.terminal?n.jsx(hr,{className:"h-4 w-4 text-muted-foreground"}):null,n.jsx("h3",{className:"text-sm font-medium",children:E.label})]}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(Vt,{variant:"secondary",className:"text-xs",children:k.length}),b?n.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>N(E.value),children:w?"Show":"Hide"}):null]})]}),w?n.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[k.length," hidden ",E.label?.toLowerCase()," item",k.length===1?"":"s"]}):n.jsx("div",{className:"space-y-2",children:k.length>0?k.map(M=>n.jsx(ai,{entity:M,owner:e,statusField:a.field,entityTypeIcon:r,schema:o,didDragRef:f},M.id)):n.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",E.label?.toLowerCase()," items"]})})]},E.value)})})})]})}const ci=v.memo(ii);function li(e){let t=0;for(let s=0;s<e.length;s++)t=(t<<5)-t+e.charCodeAt(s),t|=0;return t.toString(36)}function ys(e,t){return{queryKey:["metric_series",e,li(t)],queryFn:()=>xt("metric_series",{sql:t},{slug:e}),staleTime:6e4}}function xs(e,t){const s=!!e&&!!t,o=ys(e??"",t??"");return Vn({...o,enabled:s})}xs.queryOptions=(e,t)=>ys(e,t);function di(e,t){if(!e?.columns?.length||!e.rows)return[];const s=e.columns.indexOf(t);return s<0?[]:e.rows.map(o=>Number(o[s])||0)}const In=/^[a-z][a-z0-9_]*$/;function ui(e){const t=Object.entries(e);for(const[r,i]of t){if(!In.test(r))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${r}'`);if(!In.test(i))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${i}'`)}const s=t.flatMap(([r,i])=>[`COUNT(*) FILTER (
|
|
3
|
-
WHERE semantic_type = 'change'
|
|
4
|
-
AND metadata->>'category' = 'lifecycle'
|
|
5
|
-
AND metadata->>'entity_type' = '${i}'
|
|
6
|
-
AND metadata->>'op' = 'created'
|
|
7
|
-
) AS ${r}_added`,`COUNT(*) FILTER (
|
|
8
|
-
WHERE semantic_type = 'change'
|
|
9
|
-
AND metadata->>'category' = 'lifecycle'
|
|
10
|
-
AND metadata->>'entity_type' = '${i}'
|
|
11
|
-
AND metadata->>'op' = 'deleted'
|
|
12
|
-
) AS ${r}_removed`]).join(`,
|
|
13
|
-
`),o=t.map(([r])=>` SUM(COALESCE(b.${r}_added, 0) - COALESCE(b.${r}_removed, 0))
|
|
14
|
-
OVER (ORDER BY d.bucket) AS ${r}`).join(`,
|
|
15
|
-
`);return`
|
|
16
|
-
WITH days AS (
|
|
17
|
-
SELECT generate_series(
|
|
18
|
-
date_trunc('day', now() - interval '13 days'),
|
|
19
|
-
date_trunc('day', now()),
|
|
20
|
-
interval '1 day'
|
|
21
|
-
) AS bucket
|
|
22
|
-
),
|
|
23
|
-
buckets AS (
|
|
24
|
-
SELECT
|
|
25
|
-
date_trunc('day', created_at) AS bucket,
|
|
26
|
-
${s}
|
|
27
|
-
FROM events
|
|
28
|
-
WHERE created_at > now() - interval '14 days'
|
|
29
|
-
GROUP BY 1
|
|
30
|
-
)
|
|
31
|
-
SELECT d.bucket,
|
|
32
|
-
${o}
|
|
33
|
-
FROM days d
|
|
34
|
-
LEFT JOIN buckets b ON b.bucket = d.bucket
|
|
35
|
-
ORDER BY d.bucket
|
|
36
|
-
`}const mi={"memory-activity":`
|
|
37
|
-
WITH days AS (
|
|
38
|
-
SELECT generate_series(
|
|
39
|
-
date_trunc('day', now() - interval '13 days'),
|
|
40
|
-
date_trunc('day', now()),
|
|
41
|
-
interval '1 day'
|
|
42
|
-
) AS bucket
|
|
43
|
-
),
|
|
44
|
-
buckets AS (
|
|
45
|
-
SELECT
|
|
46
|
-
date_trunc('day', created_at) AS bucket,
|
|
47
|
-
COUNT(*) FILTER (
|
|
48
|
-
WHERE semantic_type NOT IN ('change', 'audit', 'operation')
|
|
49
|
-
) AS events_count,
|
|
50
|
-
COUNT(*) FILTER (
|
|
51
|
-
WHERE semantic_type = 'change'
|
|
52
|
-
AND metadata->>'category' = 'lifecycle'
|
|
53
|
-
AND metadata->>'entity_type' = 'connection'
|
|
54
|
-
AND metadata->>'op' = 'created'
|
|
55
|
-
) AS connections_added,
|
|
56
|
-
COUNT(*) FILTER (
|
|
57
|
-
WHERE semantic_type = 'change'
|
|
58
|
-
AND metadata->>'category' = 'lifecycle'
|
|
59
|
-
AND metadata->>'entity_type' = 'connection'
|
|
60
|
-
AND metadata->>'op' = 'deleted'
|
|
61
|
-
) AS connections_removed
|
|
62
|
-
FROM events
|
|
63
|
-
WHERE created_at > now() - interval '14 days'
|
|
64
|
-
GROUP BY 1
|
|
65
|
-
)
|
|
66
|
-
SELECT d.bucket,
|
|
67
|
-
COALESCE(b.events_count, 0)::int AS events,
|
|
68
|
-
SUM(COALESCE(b.connections_added, 0) - COALESCE(b.connections_removed, 0))
|
|
69
|
-
OVER (ORDER BY d.bucket) AS connections
|
|
70
|
-
FROM days d
|
|
71
|
-
LEFT JOIN buckets b ON b.bucket = d.bucket
|
|
72
|
-
ORDER BY d.bucket
|
|
73
|
-
`};function fi(e){if(typeof e.sql=="string"&&e.sql.trim())return e.sql;if(e.lifecycle&&typeof e.lifecycle=="object"){const t=Object.fromEntries(Object.entries(e.lifecycle).map(([s,o])=>[s,String(o)]));if(Object.keys(t).length>0)try{return ui(t)}catch{return null}}return typeof e.preset=="string"?mi[e.preset]??null:null}function pi({owner:e,sql:t,lifecycle:s,preset:o,column:r,chart:i,height:a,width:l,color:m,label:c,className:y}){const p=v.useMemo(()=>fi({sql:t,lifecycle:s,preset:o}),[t,s,o]),f=typeof e=="string"&&e?e:null,{data:h}=xs(f,p),x=String(r??""),d=v.useMemo(()=>di(h,x),[h,x]),N=v.useMemo(()=>!h?.columns?.length||!h.rows?[]:h.rows.map((j,E)=>({label:String(j[0]??"").slice(0,10),value:d[E]??0})),[h,d]);if(!f||!p||!x)return null;const _=i==="line"?n.jsx(oo,{data:N,height:typeof a=="number"?a:void 0}):n.jsx(ao,{data:d,height:typeof a=="number"?a:void 0,width:typeof l=="number"?l:void 0,color:typeof m=="string"?m:void 0});return c==null?n.jsx("div",{className:y,children:_}):n.jsxs("div",{className:y,children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:String(c)}),_]})}function hi({metadata:e,metadataSchema:t,name:s,typeIcon:o,initialsFallback:r,className:i}){return n.jsx(ns,{metadata:e,metadataSchema:t,name:String(s??""),typeIcon:o,initialsFallback:!!r,className:i})}function gi({entity:e,owner:t,className:s,onClick:o,children:r}){const i=e;if(!i)return n.jsx(n.Fragment,{children:r});const a=qn(String(t??""),ss(i));return n.jsx(He,{to:a,className:s,onClick:o,children:r})}function yi({state:e}){return e?n.jsx(Zr,{...e}):null}function xi({state:e,onUpdate:t}){return e?n.jsx(ci,{...e,onUpdate:t}):null}const bi={"entity-avatar":hi,"entity-link":gi,"entity-table":yi,"entity-board":xi,"metric-series":pi};function vi({ownerSlug:e,typeSlug:t,title:s,shape:o}){const[r,i]=v.useState(!1),a=tt(),{visible:l,system:m,isTypesLoading:c}=xr(e),y=f=>{i(!1);const h=`/${e}/${Qn(f)}`;a({to:o?`${h}/${Zn}/${o}`:h})},p=f=>n.jsxs(jr,{value:`${f.name} ${f.slug}`,onSelect:()=>y(f.slug),children:[n.jsx(Et,{icon:f.icon,className:"mr-2 h-4 w-4 shrink-0"}),n.jsx("span",{className:"flex-1 truncate",children:f.name||f.slug}),f.slug===t?n.jsx(Er,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,f.entity_count!=null?n.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:f.entity_count.toLocaleString()}):null]},f.slug);return n.jsxs(Yn,{open:r,onOpenChange:i,children:[n.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:n.jsx(Kn,{asChild:!0,children:n.jsxs(U,{type:"button",variant:"ghost",className:"-ml-2 h-auto gap-1.5 px-2 py-1 text-2xl font-semibold tracking-tight",children:[s,n.jsx(Jn,{className:"h-5 w-5 text-muted-foreground"})]})})}),n.jsx(Xn,{align:"start",className:"w-72 p-0",children:n.jsxs(br,{children:[n.jsx(vr,{autoFocus:!0,placeholder:"Find a type…"}),n.jsxs(wr,{children:[n.jsx(kr,{children:c?"Loading types…":"No type matches."}),l.length>0?n.jsx(un,{heading:"Types",children:l.map(p)}):null,m.length>0?n.jsx(un,{heading:"System",children:m.map(p)}):null]}),n.jsx(Nr,{}),n.jsxs(He,{to:"/$owner/data",params:{owner:e},onClick:()=>i(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[n.jsx(Sr,{className:"h-4 w-4"}),"Data map"]})]})})]})}function wi(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,t])=>t.on==="entity").map(([t,s])=>({name:t,description:s.description}))}const pt={table:{label:"Table",icon:$r},board:{label:"Board",icon:Lr},graph:{label:"Graph",icon:Gn}},bs=(e,t)=>`lobu.record-shape:v1:${e}/${t}`,ki=new Set(["table","board","graph"]);function Ni(e,t){const s=An(bs(e,t));return s&&ki.has(s)?s:void 0}function Si(e,t,s){Pn(bs(e,t),s)}const Ln=":records";function ji({ownerSlug:e,entityTypeSlug:t,create:s,onCreateChange:o,viewKey:r,shape:i}){const{orgContext:a,hasOrgContext:l}=Oe(),m=Wn(t,a),{data:c,isLoading:y,error:p}=m;Cr(`/${e}`,a);const f=_r(),[h,x]=v.useState({key:"",page:0}),d=es({strict:!1}),N=tt(),_=Jt(),j=`/${e}/${Qn(t)}`,E=!y&&c?.slug===t,{collection:k,error:b,presentation:w,preset:M,edited:P,table:A}=v.useMemo(()=>Ca(d,c?.metadata_schema,!!r),[d,c?.metadata_schema,r]),I=E?b:void 0,F=v.useMemo(()=>Ia(d,k),[d,k]),[B,J]=v.useState(!1),[W,se]=v.useState(0),me=k.search??"",X=k.segment,Ee=JSON.stringify(k),ue=X?wi(c).find(L=>L.name===X)??{name:X,description:""}:null,G=L=>void N({to:".",search:{...Be(L),...F},replace:!0}),te=Mr(m.data),xe=te?A.sort:$a(A),Ce=xe?.field,Ve=xe?.order,ie=v.useMemo(()=>Ce?[{id:Ce,desc:Ve==="desc"}]:[],[Ce,Ve]),ke=v.useCallback(L=>void N({to:".",search:{...r?Be(d):{},...F,$table:JSON.stringify(L)},replace:!0}),[N,r,d,F]),Ae=v.useCallback(L=>{const K=typeof L=="function"?L(ie):L;K[0]&&ke({...A,sort:{field:K[0].id,order:K[0].desc?"desc":"asc"}})},[ie,ke,A]),be=s===!0,Ue=()=>o(!0),Ne=()=>o(!1),Pe=ie[0]?.id,fe=ie[0]?ie[0].desc?"desc":"asc":void 0,_e=m.data?.metadata_schema,pe=!!tn(_e)&&!te,Me=ei(_e,{isDerived:te}),re=ts(a),nt=Pt(re.data??[],t,k),ge=(L,K=!1,ye=Be(d))=>{const he=!r||!re.data||Pt(re.data,t,L).some(lt=>lt.key===r);N({to:he?".":j,search:{...he&&r?ye:{},..._a(L,M?.key),$table:JSON.stringify(A)},replace:K})},Te=L=>{const K=L?yt(L):{},ye=!r||Pt(re.data??[],t,K).some(he=>he.key===r);J(!1),se(he=>he+1),N({to:ye?".":j,search:L?{$preset:L.key}:{}})},{isAdmin:De}=Dn(a.organizationId),Fe=Tr(a),C=De&&!!c&&!m.isPlaceholderData,u=v.useRef(d);u.current=d;const g=async()=>{if(!M)return;const L=JSON.stringify(d),{data:K}=await m.refetch(),ye=K?.metadata_schema,he=ye?Xt(ye[Ht]??{}):void 0,lt=he?.presets?.find(dt=>dt.key===M.key);if(!K||!ye||!he||!lt){Bn.error("This saved filter changed. Reload and try again.");return}const It=Ma(lt,k,A,he);await Fe.mutateAsync({slug:K.slug,metadata_schema:{...ye,[Ht]:{...he,presets:he.presets?.map(dt=>dt.key===It.key?It:dt)}}}).then(()=>!0,()=>!1)&&(await m.refetch(),JSON.stringify(u.current)===L&&Te(It))},S=v.useMemo(()=>Ni(e,t),[e,t]),T=Rr(re.data??[],t,{viewKey:r,shape:i??(r?void 0:S)},Me,k),R=T.kind==="builtin"?T.mode==="board"&&!pe?"table":T.mode:null,O=R==="graph";v.useEffect(()=>{i&&E&&R&&Si(e,t,R)},[i,E,R,e,t]);const H=["table",...pe?["board"]:[],"graph"],z=T.kind==="view"?T.view:null,D=T.kind==="missing"?T.key:null,ce=T.kind==="inapplicable"?T:null,oe=R==="table"?50:200,ve=`${t}?${Ee}&sort=${JSON.stringify(A.sort)}&size=${oe}`,Re=h.key===ve?h.page:0,Ge=v.useCallback(L=>x(K=>({key:ve,page:L(K.key===ve?K.page:0)})),[ve]),Ie=mn(t,a,{limit:oe,offset:Re*oe,search:me.trim()||void 0,sortBy:Pe,sortOrder:fe,segment:X,filters:k.filters,enabled:E&&!r&&!I}),qe=mn(t,a,{limit:1,offset:0,parentId:null,search:me.trim()||void 0,segment:X,filters:k.filters,enabled:E&&!r&&!I&&!te}),{data:Ye,error:Mt}=Ie,$=Ie.isLoading||Ie.isPending&&Ie.fetchStatus==="paused",Y=I||p||(r?null:Mt),Q=!!r&&re.data===void 0&&re.isError,V=Ye?.entities??[],Z=Ye?.metadata?.has_more??!1,q=Ye?.metadata?.total_count??0,Le=V.length>0||me.trim().length>0||Re>0||!!X||!!k.filters?.length,ne=c?.name?.trim()||Dt(t),de=c?.icon||void 0,ee=te,le=_e,Se=!I&&(!l||!E||(r?re.data===void 0&&!re.isError:$||!te&&qe.isLoading)),ze=Ye?.linked_entities??{},st=qe.data?.metadata?.total_count,Ke=q>0&&typeof st=="number"?st<q:!1,rt=v.useMemo(()=>c?.measure_columns??[],[c?.measure_columns]),Je=v.useCallback(L=>ke({...A,columns:L}),[ke,A]),ot=v.useMemo(()=>({entities:V,owner:e,schema:le,entityTypeIcon:de,isDerived:ee,measureColumns:rt,linkedEntityLookups:ze,hasAnyParents:Ke,sorting:ie,onSortingChange:Ae,visibleColumns:A.columns,columnChoices:eo(le,ee,V),onVisibleColumnsChange:Je,page:Re,pageSize:oe,totalCount:q,hasMore:Z,pageTitle:ne,onPrevPage:()=>Ge(L=>Math.max(0,L-1)),onNextPage:()=>Ge(L=>L+1)}),[V,e,le,de,ee,rt,ze,Ke,ie,A.columns,Je,Ae,Ge,Re,oe,q,Z,ne]),nn=q>V.length,sn=`showing first ${V.length} of ${q} — narrow with search`,rn=v.useMemo(()=>({owner:e,entityType:c,entities:V,totalCount:q,schema:le,entityTypeIcon:de}),[e,c,V,q,le,de]),Tt=v.useMemo(()=>({tableState:ot,boardState:rn,owner:e,schema:le,entityType:c,entityTypeIcon:de,totalCount:q,isTruncated:nn,truncationNotice:sn,canCreate:!ee,addLabel:`Add ${c?.name||Dt(t)}`}),[ot,rn,e,le,c,de,q,nn,sn,ee,t]),vs=v.useMemo(()=>ni({canShowBoard:pe,builtinData:Tt,builtInLabels:{table:pt.table.label,board:pt.board.label}}),[pe,Tt]),on=R?vs.find(L=>L.id===R)??null:null,ws=on?.template??hs,ks=on?.data??Tt,an=L=>void N({to:L===Ln?j:`${j}${Pr(L)}`,search:F}),Rt=Be(d),Ns=ho(z?.params,Rt,L=>void N({to:".",search:{...Be(L),...F}})),Ss=()=>ge({...k,filters:[],segment:void 0},!1,go(z?.params,Rt)),cn=`Moved on ${c?.name||c?.slug||t} board`,ln=v.useMemo(()=>(L,K)=>f.mutateAsync({entityId:L,metadata:K,field_note:cn}),[f,cn]),js=v.useMemo(()=>({updateEntity:ln,openCreate:()=>o(!0)}),[ln,o]),dn=L=>_?n.jsx(U,{type:"button",variant:"ghost",size:"icon",className:ae("size-8 text-muted-foreground hover:text-foreground",L),"aria-label":"Edit type",title:"Edit type",onClick:()=>_.open({href:Ar(e,t),title:ne}),children:n.jsx(Or,{className:"h-4 w-4"})}):null;return n.jsx(to,{title:n.jsx(vi,{ownerSlug:e,typeSlug:t,title:ne,shape:r?null:R}),actions:dn(be||!E?"":"hidden @lg:inline-flex"),controls:n.jsxs(n.Fragment,{children:[be?n.jsx("div",{className:"max-w-3xl",children:n.jsx(Sa,{onClose:Ne,entityTypeSlug:t,orgContext:a})}):null,!be&&E&&n.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${ne} views`,children:[dn("-mr-1 @lg:hidden"),!r&&H.length>1&&n.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:H.map(L=>{const K=pt[L].icon,ye=R===L;return n.jsx(U,{type:"button",variant:"ghost",size:"sm","aria-pressed":ye,title:pt[L].label,"data-testid":`shape-${L}`,className:ae("h-7 px-2",ye&&"bg-accent text-accent-foreground"),onClick:()=>void N({to:`${j}/${Zn}/${L}`,search:F,replace:!0}),children:n.jsx(K,{className:"h-4 w-4"})},L)})}),r&&n.jsx(U,{variant:"ghost",onClick:()=>an(Ln),children:"Records"}),!!w.presets?.length&&n.jsxs(Yn,{open:B,onOpenChange:J,children:[n.jsx(Kn,{asChild:!0,children:n.jsxs(U,{variant:"outline",className:ae("gap-2",P&&"border-dashed border-primary"),"data-edited":P||void 0,title:"Choose saved filter",children:[M?.label??(k.filters?.length||k.search?"Custom filter":"All records"),P?n.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,n.jsx(Jn,{className:"h-4 w-4 text-muted-foreground"})]})}),n.jsxs(Xn,{align:"start",className:"w-60 p-1",children:[n.jsx(U,{variant:M?"ghost":"secondary",className:"w-full justify-start",onClick:()=>Te(),children:"All records"}),w.presets.map(L=>n.jsx(U,{variant:M?.key===L.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>Te(L),children:L.label},L.key))]})]}),M&&P?n.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[n.jsx(U,{variant:"ghost",size:"sm",onClick:()=>Te(M),children:"Reset"}),C?n.jsx(U,{size:"sm",disabled:Fe.isPending,onClick:()=>void g(),children:Fe.isPending?"Saving…":"Save"}):null]}):null,!I&&n.jsx(za,{collection:k,schema:le,label:ne,org:a??"",facetQuery:w.facetQuery,onChange:ge,viewFilters:Ns,onClearAll:Ss,segmentChip:ue?{id:"segment",label:"Segment",op:"is",value:Dt(ue.name),title:ue.description||void 0,editor:ue.description?{kind:"custom",render:()=>n.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:ue.description})}:void 0,onRemove:()=>ge({...k,segment:void 0})}:void 0},`filters:${t}:${W}`),nt.map(L=>n.jsx(U,{"data-testid":`tab-${L.key}`,variant:r===L.key?"secondary":"ghost","aria-pressed":r===L.key,onClick:()=>an(L.key),children:L.name},L.key)),n.jsx(Pa,{label:ne,search:k.search,onSearch:(L,K)=>ge({...k,search:L},K),className:"ml-auto min-w-40 max-w-64 flex-1"},`search:${t}:${W}`),!ee&&!r?n.jsxs(U,{size:"sm","aria-label":`Add ${ne||"entity"}`,onClick:()=>Ue(),children:[n.jsx(it,{className:"mr-2 h-4 w-4"}),"Add"]}):null]})]}),children:be?null:Se?O?n.jsx(Qt,{label:`Loading ${ne} graph`}):n.jsx(no,{}):Y?n.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[Y.message||`Failed to load ${ne.toLowerCase()}.`,I&&n.jsx(U,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>ge({}),children:"Clear filters"})]}):Q?n.jsx(os,{onRetry:()=>void re.refetch()}):ce?n.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[n.jsxs("h2",{className:"text-lg font-semibold",children:["“",ce.view.name,"” doesn’t apply to the current filters"]}),n.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(ce.when).map(([L,K])=>`${L} is ${K===null?"not supplied":String(K)}`).join(" and "),"."]}),n.jsx(He,{to:j,search:F,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${ne}`})]}):D?n.jsx(as,{viewKey:D,backTo:j,backLabel:`Back to ${ne}`}):z?n.jsx(is,{orgSlug:e,viewKey:z.key,scope:{type:t,collection:k},params:Rt,onParamsChange:G,contentHash:z.content_hash,title:z.name,minHeight:320}):O&&Le?n.jsx(Xa,{ownerSlug:e,typeSlug:t,sourceBacked:te,records:V.map(L=>({...L,id:L.id??JSON.stringify([L.entity_type,L.slug])})),hasMore:Z}):Le?n.jsx(io,{template:ws,data:ks,actions:js,components:bi}):n.jsx(Un,{icon:Ir,iconElement:n.jsx(Et,{icon:c?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${ne.toLowerCase()} yet`,description:ee?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${c?.name?.toLowerCase()||"entity"}.`,actionLabel:ee?void 0:`Add ${c?.name||"Entity"}`,onAction:ee?void 0:()=>Ue()})})}function Ei(e,t){return ae("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",t,e?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground")}function Ci({ownerSlug:e,typeScope:t,create:s,createType:o=!1,viewKey:r,shape:i}){const a=tt(),{orgContext:l}=Oe(),m=es({strict:!1}),c=t?Dr(t):void 0,y=c==="$member",p=()=>{a({to:"/$owner/data",params:{owner:e},search:{}})},f=x=>{if(!c)return;const d=Fn(e,c);a({to:d.to,params:d.params,search:x?{create:!0}:{},replace:!0})},h=o?n.jsx("div",{className:"mx-auto w-full max-w-3xl",children:n.jsx(xo,{entityType:null,orgContext:l,onClose:p})}):c?n.jsx(ji,{ownerSlug:e,entityTypeSlug:c,create:s,onCreateChange:f,viewKey:r,shape:i}):n.jsx(_i,{ownerSlug:e,viewKey:r,search:m});return n.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:y?n.jsx(bo,{children:h}):h})}function _i({ownerSlug:e,viewKey:t,search:s}){const o=tt(),{orgContext:r}=Oe(),{data:i,isError:a,error:l,refetch:m}=ts(r),c=Fr(i??[],t),y=zr(),p=Wr(i??[]),f=a?Br(l,{subject:"Views"}):null;if(t&&i===void 0)return a?n.jsx(os,{error:l,onRetry:()=>void m()}):null;if(c.kind==="missing")return n.jsx(as,{viewKey:c.key,backTo:`/${e}/data`,backLabel:"Back to Memory"});const h=y?p:[];return n.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[h.length>0?n.jsx("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-wrap items-center gap-1",children:h.map(x=>n.jsx(He,{to:"/$owner/data/-/views/$viewKey",params:{owner:e,viewKey:x.key},search:{},activeOptions:{exact:!0},"aria-current":t===x.key?"page":void 0,className:Mi(t===x.key),children:x.name},x.key))}):null,y&&f?n.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[f.title,"."," ",f.retryable?n.jsx("button",{type:"button",onClick:()=>void m(),className:"underline underline-offset-4",children:"Retry"}):null]}):null,c.kind==="view"?n.jsxs(n.Fragment,{children:[n.jsx(yo,{decls:c.view.params,params:Be(s),onParamsChange:x=>void o({to:".",search:x})}),n.jsx(is,{orgSlug:e,viewKey:c.view.key,scope:{},params:Be(s),onParamsChange:x=>void o({to:".",search:x,replace:!0}),contentHash:c.view.content_hash,title:c.view.name,minHeight:400})]}):n.jsx(Na,{ownerSlug:e})]})}const Mi=e=>Ei(e,"min-h-8 max-w-full gap-2 px-3 text-sm break-words");function Ui({ownerSlug:e,typeScope:t,create:s,createType:o=!1,viewKey:r,shape:i}){return n.jsxs(Hr,{inset:r?"flush":"page",className:r?"gap-0 pt-0 pb-0":"gap-6 pt-2.5 pb-8",children:[n.jsx(Ur,{}),n.jsx(Vr,{owner:e,children:a=>n.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:n.jsx(Ci,{ownerSlug:a.ownerSlug,typeScope:t,create:s,createType:o,viewKey:r,shape:i})})})]})}export{Ui as M};
|
|
74
|
-
//# sourceMappingURL=memory-browse-page-CUea2Llz.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{hQ as o,c as l,ad as x,z as h,n as b,s as w,j as a,ar as j,as as A,cu as L,b1 as f,cw as C,L as N,cx as S,cz as k,b0 as y,b_ as E}from"./index-C2TCKJDP.js";import{A as O}from"./agent-editor-form-CDAHRNWl.js";import"./definition-comparison-3zKUSTt8.js";import"./json-diff-CJK-gzCt.js";import"./code-editor-UppEMWpt.js";import"./index-Vcq4gwWv.js";import"./schema-value-CefbtPIY.js";import"./model-selector-BrfaDwIg.js";function Q(){const{owner:e}=o.useParams(),t=o.useSearch(),r=l(),i=x(),{isAuthenticated:c}=h(),{isMember:m,isLoading:g}=b(),n=c&&m,{data:u=[],isLoading:d}=w({enabled:n});return a.jsx(j,{className:"gap-3 pt-2.5 pb-8",children:a.jsxs(A,{className:"flex flex-1 flex-col gap-6",children:[a.jsx(L,{breadcrumb:a.jsx(C,{crumbs:[a.jsx(N,{to:"/$owner",params:{owner:e},search:{section:"agent"},className:S,children:"Agents"},"agents")]}),icon:a.jsx(f.agents.icon,{className:"h-6 w-6"}),title:"Build a managed agent",caption:"Create an agent that Lobu runs and manages for this workspace."}),g||n&&d?a.jsx(k,{rows:1}):n?a.jsx(O,{mode:{kind:"create"},existingAgentIds:u.map(s=>s.agentId),onCreated:async s=>{const p=["agents",e];if(await i.refetchQueries({queryKey:p,exact:!0}),t.platform&&t.listen){await r({to:"/$owner/automations/new",params:{owner:e},search:{...t,agent:s}});return}await r({to:"/$owner/agents/$agentId",params:{owner:e,agentId:s}})}}):a.jsx(y,{icon:E,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{Q as component};
|
|
2
|
-
//# sourceMappingURL=new-M-MX_T5C.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,d_ as ae,jG as z,jH as oe,jI as X,jJ as ce,jK as le,r as g,jL as de,u as D,aH as ue,ct as me,m as $,ii as pe,ja as xe,B as k,jM as he,jN as K,jO as fe,dA as ge,jP as je,y as L,ai as P,ax as ee,cg as te,eH as ye,G as ve,x as Ne,g8 as we,H as ke,L as H,jQ as be,fT as Ae,gb as Ce,g5 as Se,jR as Ie,gj as G,e$ as $e,aF as Le,jS as Pe,n as Re,w as _e,jT as Te,cC as Oe,eA as Ee,cP as ze,eZ as De,f0 as Me,f6 as O,p as Fe,jU as Be,jV as Ke,d3 as He,jW as Ue,eG as Ve,a7 as We,jX as qe,A as Ge,jY as Qe}from"./index-C2TCKJDP.js";import{u as Ye,A as Ze}from"./automation-detail-content-BJwRU6qT.js";import{A as Je}from"./agent-loading-shells-BupiSjR-.js";import{s as Xe,h as et,R as tt,A as st}from"./agent-thread-DiVKn1WX.js";import{C as nt,a as rt,c as it,A as at}from"./connection-feed-detail-CJYqryAV.js";import{O as ot}from"./connect-menu-B9u86bb2.js";import{E as R,R as ct,b as lt,s as Q,p as Y,e as dt,f as ut}from"./events-feed-DwOkLk6A.js";import{S as mt}from"./source-record-panels-LJIWGtHb.js";import{S as pt}from"./schema-type-editor-panel-C4e8pq1A.js";import{c as xt,s as ht,k as ft}from"./renderer-ucwCQmBk.js";import{E as gt}from"./event-detail-CvaRN1qB.js";import{V as jt,R as yt}from"./views-access-required-BerT4Z1d.js";import{V as vt,a as Nt}from"./view-param-filters-Bp84PUMd.js";import{S as wt,g as kt}from"./status-variants-BxHtpMOj.js";import{a as bt}from"./use-automations-lV8PuE8L.js";import"./home-stream-Bg97PUBJ.js";import"./filter-editors-DQ5V4Cvh.js";import"./subDays-DwIOMzYC.js";import"./list-skeleton-bQAZ0hQp.js";import"./clients-CydgUHrc.js";import"./client-activity-scopes-B7xVaUA-.js";import"./client-rows-B3LULJxW.js";import"./home-toolbar-CpCcHA6z.js";import"./scoped-feed-bar-CapleZvS.js";import"./event-kind-options-fHAIXu24.js";import"./create-automation-form-BhujNbRr.js";import"./entity-options-IUdQ-64R.js";import"./device-automation-Dp3faMvp.js";import"./model-selector-BrfaDwIg.js";import"./skill-editor-D_W3QlRz.js";import"./code-editor-UppEMWpt.js";import"./index-Vcq4gwWv.js";import"./json-diff-CJK-gzCt.js";import"./use-mention-search-CA-evCDf.js";import"./proposal-review-shell-BVwOMoq9.js";import"./runs-B_iywKWb.js";import"./definition-comparison-3zKUSTt8.js";import"./schema-value-CefbtPIY.js";import"./runs-list-CJJFRhTl.js";import"./run-initiator-8vdkq-3o.js";import"./app-bridge-C4nPtae3.js";import"./pending-seed-DYYOoCvj.js";import"./feed-event-kinds-BYuZCoU4.js";import"./copy-button-1ALlvZU1.js";import"./entity-type-page-CouHZbc9.js";import"./card-rE4Ctuy6.js";import"./table-1O-ik4_O.js";import"./dynamic-schema-form-D3KnzCsW.js";import"./record-session-KuEDuF3S.js";function At(t){if(!t||typeof t!="object")return[];const s=t.properties;if(!s)return[];const r=Array.isArray(t.required)?new Set(t.required.map(String)):new Set;return Object.entries(s).map(([n,i])=>({name:n,type:String(i.type??"any"),required:r.has(n),description:typeof i.description=="string"?i.description:void 0}))}function Ct({fields:t}){return t.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No fields."}):e.jsx("ul",{className:"space-y-2",children:t.map(s=>e.jsxs("li",{className:"space-y-0.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[e.jsx("code",{className:"text-xs font-medium text-foreground",children:s.name}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/70",children:s.type}),s.required?e.jsx("span",{className:"text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"required"}):null]}),s.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description}):null]},s.name))})}function M({item:t,hideHeading:s=!1}){const r=t.schemaSections;return r?e.jsxs("article",{className:s?"space-y-4":"space-y-4 px-5 py-5",children:[!s&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ae,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h2",{className:"text-base font-medium text-foreground",children:t.title}),r.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:r.description}):null]})]}),r.sections.map(n=>{const i=At(n.schema);return e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:n.title}),n.description?e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.description}):null]}),e.jsx(Ct,{fields:i})]},n.title)})]}):null}function St({actions:t}){const s=Object.entries(t).map(([r,n])=>{const i=n;return{id:r,name:i.name??r,description:i.description,action:i}});return e.jsx(z,{entries:s,label:"actions",renderDetail:({name:r,action:n})=>e.jsx(M,{hideHeading:!0,item:{href:"",title:r,schemaSections:X(n)}})})}function It({feeds:t}){const s=Object.entries(t).map(([r,n])=>{const i=n;return{id:r,name:i.name??r,description:i.description,feed:i}});return e.jsx(z,{entries:s,label:"feed types",renderDetail:({name:r,feed:n})=>e.jsx(M,{hideHeading:!0,item:{href:"",title:r,schemaSections:oe(n)}})})}function $t(t){const s=[];return t.forEach((r,n)=>{s.push({id:`sep:${r.runId}`,role:"system",parts:[{type:"text",text:Lt(r,n)}],createdAt:r.completedAt?new Date(r.completedAt).getTime():void 0});for(const i of r.messages)s.push({...i,id:`r${r.runId}:${i.id}`})}),s}function Lt(t,s){const r=(t.pendingActionCount??0)>0?`Waiting for you (${t.pendingActionCount})`:t.status==="completed"?"Completed":t.status??"Completed",n=(t.autoAppliedCount??0)>0?` · ${t.autoAppliedCount} applied automatically`:"",i=t.completedAt?new Date(t.completedAt).toLocaleString():null;return i?`Run ${s+1} · ${r}${n} · ${i}`:`Run ${s+1} · ${r}${n}`}const se=Symbol("trusted-automation-interaction");function Pt(t){return Object.defineProperty(t,se,{value:!0}),t}function Rt(t){return{title:`${t} items waiting for you`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:[{type:"text",value:"Review the individual proposals below, or decide the whole run at once.",muted:!0}],actions:[{id:"approve-all",label:"Approve all",variant:"primary",icon:"check",confirm:!0,confirmPrompt:`Approve all ${t} proposals?`,tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved all ${t} proposals.`},{id:"reject-all",label:"Reject all",variant:"outline",icon:"x",confirm:!0,confirmPrompt:`Reject all ${t} proposals?`,tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected all ${t} proposals.`}]}}const _t=new Set(["automation-approval-batch"]);function Tt(t){return new Promise(s=>{t({onSettled:(r,n)=>s(!!n)})})}function Ot(){const t=ce(),s=le();return g.useMemo(()=>({toolNames:_t,resolve:(r,n)=>{if(!n||typeof n!="object"||n[se]!==!0)return null;const i=n;if(r==="automation-approval-batch"){const o=typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0?i.runId:null,l=typeof i.count=="number"&&Number.isSafeInteger(i.count)&&i.count>1?i.count:null,a=Array.isArray(i.runIds)?i.runIds.filter(d=>typeof d=="number"&&Number.isSafeInteger(d)&&d>0):[];return o===null||l===null||a.length!==l||new Set(a).size!==l?null:{view:Rt(l),handlers:{manage_operations:d=>d.action!=="approve"&&d.action!=="reject"?Promise.resolve(!0):Tt(p=>d.action==="approve"?t.mutate({run_id:o,run_ids:a},p):s.mutate({run_id:o,run_ids:a},p))}}}return null}}),[t,s])}const Et=/(?:^|\n)Run this Automation now/;function zt(t){return t.role==="user"&&t.parts.some(s=>s.type==="text"&&Et.test(s.text))}function Dt(t){return`history-interaction:${t.runId}:${t.eventId??"error"}`}function Mt({agentId:t,automationId:s,ownerSlug:r,runId:n}){const{data:i,isLoading:o}=de(t,s,{orgSlug:r,...n!=null?{runId:n}:{}}),l=Ot(),a=D(),d=g.useCallback(m=>{a?.open({href:`/${r}/automations/${s}?view=activity&run_id=${m}`,title:`Automation run #${m}`,runId:m})},[a,r,s]),p=g.useMemo(()=>{const m=i?.runs??[],b=(n!=null?m.filter(x=>x.runId===n):m).slice().reverse();return $t(b.map(x=>{const j=x.messages.map(u=>Xe(u,{showToolCalls:!0})).filter(u=>u!==null&&!zt(u));x.task?.trim()&&j.unshift({id:"task",role:"user",parts:[{type:"text",text:x.task.trim()}]});const N=x.actions??[],y=N.filter(u=>u.status==="pending");if(y.length>1){const u=y.map(h=>h.runId).sort((h,C)=>h-C);j.push({id:"approval-batch",role:"assistant",parts:[{type:"tool-call",toolCallId:`approval-batch-${x.runId}`,toolName:"automation-approval-batch",args:Pt({runId:x.runId,count:y.length,runIds:u})}]})}for(const u of N){const h=et([u],{workspaceSlug:r,agentId:t,webOrigin:typeof window>"u"?null:window.location.origin});h&&j.push({...h,id:Dt(u)})}return{runId:x.runId,completedAt:x.completedAt,status:x.status,pendingActionCount:x.pendingActionCount,autoAppliedCount:x.autoAppliedCount,messages:j}}))},[t,i,r,n]);return o?e.jsx(Je,{readOnly:!0}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No run transcripts yet. Recent runs will show here when the Automation fires (failed runs appear with their prompt even without a full transcript)."}):e.jsx("div",{className:"flex h-[calc(100dvh-12rem)] min-h-[24rem] min-w-0 flex-1 flex-col",children:e.jsx(tt,{messages:p,workspaceSlug:r,children:e.jsx(st,{readOnly:!0,readerPositionMode:"runs",interactionExtension:l,onRunSelect:n==null&&a?d:void 0})})})}function Ft({panel:t}){const s=ue(t.organizationId),r=t.section==="connections"||!!t.connectionId,n=me(t.organizationId,{connectorKey:t.connectorKey,connectionIds:t.connectionId?[t.connectionId]:void 0,enabled:r}),i=s.data?.find(l=>l.key===t.connectorKey),o=n.data?.find(l=>l.id===t.connectionId&&l.connector_key===t.connectorKey);return s.isLoading||r&&n.isLoading?e.jsx("div",{className:"p-5",children:e.jsx($,{className:"h-28 w-full"})}):s.isError||r&&n.isError?e.jsx("p",{role:"alert",className:"p-5 text-sm",children:"Could not load this connector. Close the pane and try again."}):t.connectionId&&!o||!i&&!o&&t.section!=="connections"?e.jsx("p",{className:"p-5 text-sm",children:"This connection is no longer available."}):e.jsx("div",{className:"p-5",children:t.section==="connections"?e.jsx(pe,{connections:n.data??[],connector:i,connectorKey:t.connectorKey,ownerSlug:t.ownerSlug}):o&&t.section==="data"?e.jsx(nt,{connection:o,ownerSlug:t.ownerSlug}):o?e.jsx(Ht,{connection:o,connector:i,panel:t}):i?t.section==="oauth-apps"?e.jsx(ot,{connector:i,organizationId:t.organizationId,newApp:!!t.newApp}):t.section==="feeds"?e.jsx(Bt,{connector:i}):i.installed===!1?e.jsx(Kt,{connector:i,ownerSlug:t.ownerSlug}):e.jsx(Vt,{connector:i,ownerSlug:t.ownerSlug}):null},`${t.connectorKey}:${t.connectionId??"connector"}:${t.section}`)}function Bt({connector:t}){return e.jsx(It,{feeds:t.feeds_schema??{}})}function Kt({connector:t,ownerSlug:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection."," ",e.jsx(K,{ownerSlug:s,connectorKey:t.key})]}),e.jsx(St,{actions:t.actions_schema??{}})]})}function Ht({connection:t,connector:s,panel:r}){const[n,i]=g.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:n,children:r.section==="feeds"?e.jsx(Ut,{connection:t,connector:s,ownerSlug:r.ownerSlug}):e.jsx(xe,{connection:t,ownerSlug:r.ownerSlug,inPeek:!0,onReviewPermissions:s?()=>i(!0):void 0})}),n&&s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>i(!1),children:"Back to actions"}),e.jsx("h2",{className:"text-base font-semibold",children:"Provider permissions"}),e.jsx(he,{connection:t,connectorDef:s})]})]})}function Ut({connection:t,connector:s,ownerSlug:r}){const{data:n=[],isLoading:i,isError:o}=ge(t.id),[l,a]=g.useState(!1),d=t.facets?.chat??!1;if(i)return e.jsx($,{className:"h-28 w-full"});if(o)return e.jsx("p",{role:"alert",children:"Could not load sources. Close the pane and try again."});const p=n.map(m=>({id:String(m.id),name:m.display_name||m.feed_key,status:je(m)??(m.operations.includes("sync")?"Sync enabled":"Live access"),feed:m}));return e.jsxs(e.Fragment,{children:[e.jsx("div",{hidden:l,children:e.jsx(z,{entries:p,label:d?"channels":"feeds",action:Object.keys(s?.feeds_schema??{}).length>0?e.jsx(k,{size:"sm",variant:"outline",onClick:()=>a(!0),children:d?"Add channel":"Add feed"}):void 0,renderDetail:({feed:m})=>m.store==="channel_messages"?e.jsx(rt,{feed:m,hideHeader:!0}):e.jsx(it,{feed:m,connectorDef:s,ownerSlug:r})})}),l&&s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold",children:d?"Add channel":"Add feed"}),e.jsx(at,{organizationId:t.organization_id,connections:[t],connectorDefinitions:[s],onClose:()=>a(!1)})]})]})}function Vt({connector:t,ownerSlug:s}){const{data:r=[],isLoading:n,isError:i}=fe(t.key);if(n)return e.jsx($,{className:"h-28 w-full"});if(i)return e.jsx("p",{role:"alert",children:"Could not load actions. Close the pane and try again."});const o=t.actions_schema??{},l=r.map(a=>({id:a.operation_key,name:a.name??a.operation_key,description:a.description,operation:a}));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Policy depends on connection. Click an action to inspect its inputs."," ",e.jsx(K,{ownerSlug:s,connectorKey:t.key})]}),e.jsx(z,{entries:l,label:"actions",renderControl:()=>e.jsx(K,{ownerSlug:s,connectorKey:t.key}),renderDetail:({operation:a,name:d})=>o[a.operation_key]?e.jsx(M,{hideHeading:!0,item:{href:"",title:d,schemaSections:X(o[a.operation_key])}}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No input fields."})})]})}function Wt({owner:t,name:s,agentId:r,clientIds:n}){const{data:i,isLoading:o}=L(t==="me"?null:t,{slug:t}),l=i?.workspace,a=t!=="me"&&l?.type==="organization"?l.id:null,d=n?.join(",")??"",p=g.useMemo(()=>({sortBy:"date",sortOrder:"desc",...r?{agentId:r}:{clientIds:d.split(",").filter(Boolean)}}),[r,d]);return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):e.jsx("div",{className:"space-y-3 px-4 py-4",children:e.jsx(R,{organizationId:a,ownerSlug:t,filters:p,hideOriginator:!0,groupStretches:!0,emptyState:e.jsxs("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:["No activity from ",s," yet."]})})})}function qt({owner:t,path:s}){const{data:r,isLoading:n}=L(t,{slug:t}),i=r?.workspace,o=i?.type==="organization"?i.id:null,l=o?{slug:t}:void 0,{data:a,isLoading:d}=ee(`/${t}/${te(s)}`,l),p=a?.entity,m=p?.id;return n||d?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):o?m==null?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't find this record. It may have been deleted, or it may live in a workspace you can't access."}):p?.is_derived?e.jsx(mt,{record:{type:p.entity_type,key:p.slug},orgContext:l}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{organizationId:o,ownerSlug:t,entityId:typeof m=="number"?m:void 0,filters:{sortBy:"date",sortOrder:"desc"},emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to this record yet."})})}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."})}function Gt(t){if(Array.isArray(t.enum))return`One of ${t.enum.length}`;if(t.format==="date"||t.format==="date-time")return"Date";if(t.format==="uri")return"Link";if(t.format==="email")return"Email";const s=Array.isArray(t.type)?t.type[0]:t.type;return s==="array"?"List":s==="object"?"Group":s==="integer"||s==="number"?"Number":s==="boolean"?"Yes / no":"Text"}function Qt({owner:t,typeSlug:s,view:r}){const{data:n,isLoading:i}=L(t,{slug:t}),o=n?.workspace,l=o?.type==="organization"?o.id:null,{isAdmin:a}=ye(l??void 0),{orgContext:d}=ve(),{data:p,isSuccess:m}=Ne(d),v=(p??[]).find(A=>A.slug===s),b=m&&!v,x=`/${t}/${we(s)}`,{pathname:j}=ke(),N=j===x||j===`${x}/`||j.startsWith(`${x}/-/`),y=g.useMemo(()=>xt(v?.metadata_schema),[v?.metadata_schema]),u=D(),h=u?.close;g.useEffect(()=>{b&&h?.()},[b,h]);const C=g.useMemo(()=>({entityTypes:[s],sortBy:"date",sortOrder:"desc"}),[s]);if(i)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]});if(b)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This entity type no longer exists."});if(!l)return e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."});const _=v?.name??s;return e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-4 py-2.5",children:[N?null:e.jsx(k,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs(H,{...Ae(t,s),children:[e.jsx(be,{className:"mr-1.5 h-3.5 w-3.5"}),"Browse records"]})}),v&&!N&&!Ce(v)&&v.entity_count!==0?e.jsx(k,{asChild:!0,variant:"outline",size:"sm",className:"h-8 text-xs",children:e.jsxs(H,{to:"/$owner/$entityType/-/$shape",params:{owner:t,entityType:s,shape:"graph"},search:Ie(G(t,s)),children:[e.jsx(Se,{className:"mr-1.5 h-3.5 w-3.5"}),"Graph"]})}):null,r!=="activity"&&u?e.jsxs(k,{type:"button",variant:"ghost",size:"sm",className:"ml-auto h-8 gap-1.5 text-xs text-muted-foreground hover:text-foreground",onClick:()=>u.open({href:G(t,s,"activity"),title:`${_} activity`}),children:[e.jsx($e,{className:"h-3.5 w-3.5"}),"Activity"]}):null]}),r==="activity"?e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{organizationId:l,ownerSlug:t,filters:C,showEntityLinks:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing has happened to these records yet."})})}):a?e.jsx("div",{className:"p-4",children:e.jsx(pt,{slug:s,onClose:()=>h?.()})}):y.length>0?e.jsxs("section",{"aria-labelledby":"entity-type-peek-fields",className:"px-4 py-4",children:[e.jsx("h3",{id:"entity-type-peek-fields",className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Fields"}),e.jsx("dl",{className:"divide-y divide-border/60 text-sm",children:y.map(A=>e.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-1.5",title:A.prop.description,children:[e.jsx("dt",{className:"min-w-0 truncate",children:ht(A)}),e.jsx("dd",{className:"shrink-0 text-xs text-muted-foreground",children:Gt(A.prop)})]},A.key))})]}):e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This type has no fields yet."})]})}function Yt({owner:t,eventId:s,viewKey:r}){const n=D(),i=(o,l)=>e.jsx(gt,{owner:l,organizationId:o,eventId:s,viewKey:r,dense:!0,onSelectView:n?a=>n.retarget(a):void 0},`${l}/${s}/${r??""}`);return e.jsx("div",{className:"px-4 py-4",children:t==="me"?i(null,t):e.jsx(Le,{owner:t,children:({organizationId:o,ownerSlug:l})=>o?i(o,l):e.jsx("div",{className:"h-40 animate-pulse rounded-md bg-muted/40"})})})}function Zt({owner:t,feedId:s,semanticTypes:r}){const{data:n,isLoading:i}=L(t==="me"?null:t,{slug:t}),o=n?.workspace,l=t!=="me"&&o?.type==="organization"?o.id:null,a=g.useMemo(()=>({feedIds:[s],...r?.length?{semanticTypes:r}:{},sortBy:"date",sortOrder:"desc"}),[s,r]);return t!=="me"&&i?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):l==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{organizationId:l,ownerSlug:t,filters:a,showEntityLinks:!0,hideOriginator:!0,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:r?.length===1?`No ${r[0]} events from this feed yet.`:"No matching events from this feed yet."})})})}function E({owner:t,runId:s,runIds:r,contentIds:n}){const{data:i,isLoading:o}=L(t==="me"?null:t,{slug:t}),l=i?.workspace,a=t!=="me"&&l?.type==="organization"?l.id:null,d=g.useMemo(()=>{if(t==="me")return n?.length?{contentIds:n,sortBy:"date",sortOrder:"desc"}:void 0;const m=r??(s!=null?[s]:void 0);if(!(!m?.length&&!n?.length))return{...m?.length?{runIds:m}:{},...n?.length?{contentIds:n}:{}}},[t,n,s,r]),p=d!=null;return t!=="me"&&o?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]}):t!=="me"&&a==null?e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Couldn't resolve this workspace."}):p?e.jsx("div",{className:"px-4 py-4",children:e.jsx(R,{presentation:"detail",organizationId:a,ownerSlug:t,filters:d,emptyState:e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:s!=null||r?.length?"No matching events from this run yet.":"No matching events yet."})})}):e.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Nothing to preview."})}const F=25;function Jt({target:t}){const[s,r]=g.useState(0),{data:n,isLoading:i,isError:o,refetch:l}=Pe(t.entityId,t.orgContext,{relationshipType:t.relationshipType,limit:F,offset:s}),a=n?.total;return e.jsxs("div",{className:"space-y-3 px-5 py-4",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.label," · ",t.entityName,a!==void 0?` · ${a} current ${a===1?"link":"links"}`:n?` · ${n.rows.length} shown`:""]}),e.jsx(ct,{count:n?.failures?.length??0,onRetry:()=>void l()}),i?e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{className:"h-6 w-full"}),e.jsx($,{className:"h-6 w-full"})]}):o||!n?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Could not load these links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void l(),children:"Retry"})]}):n.rows.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No links on this page."}):e.jsx("ul",{className:"divide-y divide-border",children:n.rows.map(d=>e.jsx("li",{className:"flex items-center justify-between gap-3 py-1.5",children:e.jsx(lt,{row:d,entityId:t.entityId,ownerSlug:t.ownerSlug,orgContext:t.orgContext})},d.id))}),n&&(s>0||n.hasMore)?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{type:"button",variant:"outline",size:"sm",disabled:s===0,onClick:()=>r(Math.max(0,s-F)),children:"Previous"}),e.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground",children:[n.rows.length," shown",a===void 0?"":` of ${a}`]}),e.jsx(k,{type:"button",variant:"outline",size:"sm",disabled:!n.hasMore,onClick:()=>r(s+F),children:"Next"})]}):null]})}function Xt({owner:t,path:s,viewKey:r}){const[n,i]=g.useState({}),{data:o,isLoading:l}=L(t,{slug:t}),a=o?.workspace,d=a?.type==="organization"?a.id:null,p=d?{slug:t,organizationId:d}:void 0,{data:m,isLoading:v}=ee(`/${t}/${te(s)}`,p),{isMember:b,isPublic:x,isLoading:j}=Re(t),N=b||x,y=_e({slug:t,organizationId:b?d:null}),u=m?.entity;if(l||v||j||N&&y.isLoading)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(P,{className:"mr-2"})," Loading…"]});if(!N)return e.jsx(jt,{});if(y.isError)return e.jsx(vt,{onRetry:()=>void y.refetch()});const h=u?Te(y.data??[],{type:u.entity_type,id:u.id??u.slug}).find(C=>C.key===r):void 0;return!d||!u||!h?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"This view isn't attached to this record any more."}):e.jsx("div",{className:"px-4 py-4",children:e.jsx(Nt,{orgSlug:t,viewKey:h.key,scope:{type:u.entity_type,entity:u.is_derived?u.slug:u.id??u.slug},params:n,onParamsChange:i,contentHash:h.content_hash,title:h.name,minHeight:320})})}function ne({owner:t,runId:s}){const r=Oe({queryKey:["run-outcome",t,s],queryFn:async()=>{const i=await ze("manage_operations",{action:"get_run",run_id:s},{slug:t});if(!i.run)throw new Error(i.error||"Run not found");return i.run},enabled:t!=="me",staleTime:15e3,refetchInterval:i=>["pending","claimed","running"].includes(i.state.data?.status??"")?5e3:!1});if(t==="me")return null;if(r.isLoading)return e.jsx("p",{role:"status",className:"px-4 pt-4 text-xs text-muted-foreground",children:"Loading run…"});if(!r.data)return e.jsx("p",{role:"alert",className:"px-4 pt-4 text-sm text-destructive",children:"Could not load this run."});const n=r.data;return e.jsxs("section",{"aria-label":"Run outcome",className:"space-y-2 border-b px-4 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(wt,{status:kt(n.status),children:n.status}),e.jsx("time",{dateTime:n.created_at,className:"text-xs text-muted-foreground",children:Ee(n.created_at)})]}),n.connection_display_name?e.jsx("p",{className:"text-sm",children:n.connection_display_name}):null,n.error_message?e.jsx("p",{className:"whitespace-pre-wrap break-words text-sm text-destructive",children:n.error_message}):null,r.isError?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Could not refresh this run. Showing its last known outcome."}):null]})}const Z=30;function I({label:t,children:s}){return e.jsxs("section",{className:"border-t px-4 py-3 first:border-t-0",children:[e.jsx("h3",{className:"mb-1.5 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),s]})}function B({label:t,detail:s}){return e.jsxs("div",{className:"flex items-baseline gap-3 py-0.5 text-sm",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),e.jsx("span",{className:"shrink-0 truncate text-xs text-muted-foreground",children:s})]})}function es({stretch:t,ownerSlug:s,connectorDefinitions:r,connectionName:n,sourceConnection:i,showEntity:o}){const l=D(),a=g.useMemo(()=>De(t),[t]),d=g.useMemo(()=>Me(t),[t]),[p,m]=g.useState(!1),[v,b]=g.useState(new Set),x=c=>e.jsx("li",{children:e.jsx(ut,{content:c,ownerSlug:s,connectorDefinitions:r,connectionName:n,showEntity:o})},c.id),j=c=>e.jsx("ul",{className:"-mx-1 divide-y overflow-hidden rounded-lg border",children:c.map(x)}),N=[...a.failedCalls.map(c=>c.content),...a.failedOperations.flatMap(c=>O(c)??[])],y=t.changes.flatMap(c=>O(c)??[]),u=[...t.calls.map(c=>c.content),...t.operations.flatMap(c=>O(c)??[])].sort((c,f)=>new Date(f.occurred_at).getTime()-new Date(c.occurred_at).getTime()),h=p?u:u.slice(0,Z),C=(c,f)=>e.jsxs(k,{variant:"ghost",size:"sm",className:"mt-2",onClick:f,children:["Show all ",c]});if(t.source){const{source:c}=t,f=t.flagged.flatMap(w=>O(w)??[]),ie=d.reduce((w,W)=>w+W.items.length,0),T=i?.(c.connectionId)??null;return e.jsxs("div",{className:"pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-4 pt-3 pb-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:c.name}),e.jsxs("span",{children:["· ",Q(t)]}),e.jsxs("span",{children:["· ",Y(ie,"item")]}),f.length>0?e.jsxs("span",{children:["· ",f.length," failed"]}):null,T&&l?e.jsxs(k,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>l.open({href:`/${s}/connectors/${encodeURIComponent(T.connectorKey)}/${c.connectionId}`,key:`connection:${c.connectionId}`,title:c.name,connectorPanel:{section:"data",connectorKey:T.connectorKey,connectionId:c.connectionId,organizationId:T.organizationId,ownerSlug:s}}),children:["All data from ",c.name]}):null]}),f.length>0?e.jsx(I,{label:`Failed · ${f.length}`,children:j(f)}):null,d.map(w=>{const q=v.has(w.type)?w.items:w.items.slice(0,Z);return e.jsxs(I,{label:w.label,children:[j(q),w.items.length>q.length?C(w.items.length,()=>b(new Set([...v,w.type]))):null]},w.type)})]})}const _=a.did.reduce((c,f)=>c+f.count,0),A=a.lookedAt.reduce((c,f)=>c+f.count,0),S=t.apps.length===1?t.apps[0]:null,V=S?.key.startsWith("client:")?`/${s}/events?client_ids=${encodeURIComponent(S.key.slice(7))}`:S?.key.startsWith("agent:")?`/${s}/events?agent=${encodeURIComponent(S.key.slice(6))}`:null;return e.jsxs("div",{className:"pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-4 pt-3 pb-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:dt(t)}),e.jsxs("span",{children:["· ",Q(t)]}),e.jsxs("span",{children:["· ",Y(t.calls.length,"call")]}),e.jsxs("span",{children:["· ",N.length," failed"]}),V&&S&&l?e.jsxs(k,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>l.open({href:V,title:S.name}),children:["All activity from ",S.name]}):null]}),N.length>0?e.jsx(I,{label:`Failed · ${N.length}`,children:j(N)}):null,t.kind==="background"?null:e.jsxs(I,{label:`Changed · ${y.length||a.changeSteps.reduce((c,f)=>c+f.count,0)}`,children:[y.length>0?j(y):null,a.changeSteps.map(c=>e.jsx(B,{label:c.title,detail:`${c.methods.join(" · ")} · ${c.count}`},c.title)),y.length===0&&a.changeSteps.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing changed."}):null]}),_>0?e.jsx(I,{label:`Did · ${_}`,children:a.did.map(c=>e.jsx(B,{label:c.group,detail:c.items.length>0?c.items.slice(0,5).map(f=>`${f.item} ${f.count}`).join(" · ")+(c.items.length>5?` · ${c.items.length-5} more`:""):String(c.count)},c.group))}):null,A>0?e.jsx(I,{label:`Looked at · ${A}`,children:a.lookedAt.map(c=>e.jsx(B,{label:c.title,detail:`${c.methods.join(" · ")} · ${c.count}`},c.title))}):null,e.jsxs(I,{label:`Raw calls · ${u.length}`,children:[j(h),u.length>h.length?C(u.length,()=>m(!0)):null]})]})}function Js({item:t}){if(t.connectorPanel)return e.jsx(Ft,{panel:t.connectorPanel});if(t.schemaSections)return e.jsx(M,{item:t});if(t.recordField)return e.jsx(yt,{target:t.recordField});if(t.recordPeer)return e.jsx(ft,{target:t.recordPeer});if(t.recordLinks)return e.jsx(Jt,{target:t.recordLinks});if(t.workStretch)return e.jsx(es,{...t.workStretch});if(typeof t.browserUrl=="string"&&t.browserUrl.length>0)return e.jsx(J,{item:t});const s=t.href?Fe(t.href):null;return s?s.kind==="memory"?"runId"in s?e.jsxs(e.Fragment,{children:[e.jsx(ne,{owner:s.owner,runId:s.runId}),e.jsx(U,{title:"What it produced",children:e.jsx(E,{owner:s.owner,runId:s.runId})}),e.jsx(re,{owner:s.owner,runId:s.runId})]}):"runIds"in s?e.jsx(E,{owner:s.owner,runIds:s.runIds}):e.jsx(E,{owner:s.owner,contentIds:s.contentIds}):s.kind==="entity"?e.jsx(qt,{owner:s.owner,path:s.path}):s.kind==="entity-type"?e.jsx(Qt,{owner:s.owner,typeSlug:s.typeSlug,view:s.view}):s.kind==="record-view"?e.jsx(Xt,{owner:s.owner,path:s.path,viewKey:s.viewKey}):s.kind==="event"?e.jsx(Yt,{owner:s.owner,eventId:s.eventId,viewKey:s.viewKey}):s.kind==="feed"?e.jsx(Zt,{owner:s.owner,feedId:s.feedId,semanticTypes:s.semanticTypes}):s.kind==="agent"?e.jsx(Wt,{owner:s.owner,name:t.title,agentId:s.agentId,clientIds:s.clientIds}):t.runId?e.jsx(ts,{owner:s.owner,automationId:s.automationId,runId:t.runId}):e.jsx(ss,{owner:s.owner,automationId:s.automationId}):e.jsx(J,{item:t})}function J({item:t}){const s=t.body,r=t.notificationType??"generic",n=t.createdAt,i=t.browserUrl??null,o=t.browserHandoff??null;return e.jsxs("article",{className:"space-y-4 px-5 py-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Be,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ke(r)}),n?e.jsx("span",{children:He(n)}):null]})]}),s?e.jsx("div",{className:"text-sm leading-6 text-foreground/90",children:e.jsx(Ue,{text:s,linkPolicy:r==="action_approval_needed"?"app-links":"strip"})}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional details were provided."}),t.owner&&t.sourceAttribution?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground/80",children:"Generated from"}),e.jsx(Ve,{owner:t.owner,source:t.sourceAttribution,className:"text-xs"})]}):null,i?e.jsx("div",{className:"space-y-2",children:o?.state==="expired"?e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o.error_message??"This draft expired before the page was opened."}):o?.state==="completed"||o?.state==="preparing"?e.jsx("p",{className:"text-sm text-muted-foreground",children:o.state==="preparing"?"Preparing draft — keep your browser tab open.":"Draft prepared — review and post in your browser."}):e.jsxs(k,{type:"button",size:"sm",className:"h-8 text-sm",onClick:()=>{qe(i)},children:[e.jsx(We,{className:"mr-1.5 h-3.5 w-3.5"}),"Open post"]})}):null]})}function U({title:t,children:s}){return e.jsxs("section",{"aria-label":t,className:"border-b",children:[e.jsx("h2",{className:"px-4 pt-4 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),s]})}function re({owner:t,runId:s}){return t==="me"?null:e.jsx("div",{className:"px-4 py-3",children:e.jsxs(H,{to:"/$owner/events",params:{owner:t},search:{run_ids:String(s)},className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Open in Activity",e.jsx(Ge,{"aria-hidden":"true",className:"h-3.5 w-3.5"})]})})}function ts({owner:t,automationId:s,runId:r}){const{organizationId:n}=Ye(t),i=bt(s,void 0,n),o=Qe(i.data?.automation);return e.jsxs(e.Fragment,{children:[e.jsx(ne,{owner:t,runId:r}),e.jsx(U,{title:"What it produced",children:e.jsx(E,{owner:t,runId:r})}),o?e.jsx(U,{title:"How it ran",children:e.jsx(Mt,{agentId:o,automationId:s,ownerSlug:t,runId:r})}):i.isLoading?e.jsx($,{className:"m-4 h-24 rounded-lg"}):null,e.jsx(re,{owner:t,runId:r})]})}function ss({owner:t,automationId:s}){return e.jsx("div",{className:"px-4 py-4",children:e.jsx(Ze,{owner:t,agentId:null,automationId:s,view:"activity",onDone:()=>{}})})}export{Js as PeekPaneContent};
|
|
2
|
-
//# sourceMappingURL=peek-pane-content-B29OcHwm.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aG as fn,j as n,r as k,c as V,H as ne,cQ as hn,cC as Ct,cP as St,L as Se,a7 as vn,dm as yn,S as Nt,dn as gn,cJ as xn,dp as _t,dq as E,be as dt,dr as bn,ds as jn,av as kn,dt as Cn,au as Sn,du as Nn,dv as te,ch as _n,dw as It,dx as In,ax as Tn,dy as En,s as An,cB as Fn,aC as je,dz as Rn,dA as Pn,n as Tt,d4 as Et,dB as Mn,dC as ut,dD as Ln,dE as On,dh as At,dF as wn,dG as $n,cn as Dn,b9 as Bn,bg as Kn,bh as Gn,dH as Ft,bi as Vn,bj as Qn,bk as Un,da as Wn,U as Hn,i as De,X as zn,dI as qn,dJ as Jn,bJ as Yn,dK as Zn,dL as Xn,dM as es,dN as Rt,dO as mt,z as ts,dP as ns,dQ as Pe,dR as pt,d5 as ss,dS as os,x as as,ct as is,dT as rs,dU as cs,t as ls,dV as ds,dW as us,dX as ms,bT as ps,dY as fs,dZ as hs,cG as vs,b0 as ft,d_ as ht,d$ as Pt,cj as Me,cp as Mt,B as Lt,e0 as ys,e1 as Le,dd as gs}from"./index-C2TCKJDP.js";import{T as vt}from"./home-toolbar-CpCcHA6z.js";import{S as B,F as xs,a as bs,o as X,d as js,r as ks,f as Cs,b as Ss}from"./filter-editors-DQ5V4Cvh.js";import{u as Ns}from"./runs-B_iywKWb.js";import{e as _s,f as Fe,C as Ot,c as Is}from"./event-kind-options-fHAIXu24.js";import{S as Ts}from"./source-record-panels-LJIWGtHb.js";import{u as Es}from"./clients-CydgUHrc.js";import{u as As}from"./client-activity-scopes-B7xVaUA-.js";import{g as Fs}from"./client-rows-B3LULJxW.js";import{E as Rs}from"./events-feed-DwOkLk6A.js";import{E as Ps}from"./run-initiator-8vdkq-3o.js";import{L as Ms,u as Ls}from"./renderer-ucwCQmBk.js";import{E as Os}from"./agent-loading-shells-BupiSjR-.js";import{M as ws}from"./member-scope-gate-Doic_6qX.js";const Be=k.createContext(null);function $s({organizationId:e,isWorkspaceLoading:t,children:a}){const{data:s=[],isLoading:o}=fn(e);return n.jsx(Be.Provider,{value:{groups:s,isLoading:!!t||o},children:a})}function Ds(){const e=k.useContext(Be);if(!e)throw new Error("useMemoryConnectorGroups must be used within MemoryConnectorGroupsProvider");return e}function Bs(){return k.useContext(Be)}function wt(e){const{parse:t,serialize:a,filterKeys:s,clearClassifications:o=!0,replace:i=!0,merge:u}=e,d=V(),h=ne(),l=k.useMemo(()=>{const g=new URLSearchParams;for(const[r,p]of Object.entries(h.search||{}))p!=null&&g.set(r,typeof p=="object"&&!Array.isArray(p)?JSON.stringify(p):String(p));return t(g)},[h.search,t]),m=k.useCallback((g,r)=>{const p=u?u(l,g):{...l,...g},y=a(p),S={};for(const[N,x]of Object.entries(h.search||{}))x!=null&&(S[N]=x);for(const N of s)delete S[N];if(o)for(const N of Object.keys(S))N.startsWith("clf_")&&delete S[N];for(const[N,x]of Object.entries(y))x!==void 0&&(S[N]=x);d({to:h.pathname,search:S,replace:r?.replace??i})},[l,a,s,o,u,d,h,i]),v=k.useCallback(()=>{const g={};for(const[r,p]of Object.entries(h.search||{}))p!=null&&(s.includes(r)||o&&r.startsWith("clf_")||(g[r]=p));d({to:h.pathname,search:g,replace:i})},[d,h.pathname,h.search,s,o,i]);return{filters:l,updateFilters:m,clearFilters:v}}function Ks(e){const{slug:t}=hn();return Ct({queryKey:["schedules",t,e],queryFn:async()=>((await St("manage_schedules",{action:"list",action_type:"wake_agent",include_paused:!0})).schedules??[]).filter(s=>s.action_args?.agent_id===e),enabled:!!t&&!!e,staleTime:3e4})}function Gs(e,t){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:t.connector_key,connectionId:String(t.connection_id)},search:{feedId:t.id}}}function Vs(e,t){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:e,connectorKey:t.connector_key,connectionId:String(t.id)}}}function Qs(e,t){return{to:"/$owner/agents/connected/$clientId",params:{owner:e,clientId:t}}}function Us(e,t){return{to:"/$owner/automations/$automationId",params:{owner:e,automationId:t}}}function Ws(e,t,a){return{to:"/$owner/events",params:{owner:e},search:{agent:t,schedule:a}}}function ve({id:e,label:t,value:a,sourceLink:s,details:o,onRemove:i}){return{id:e,label:t,op:"is",value:a,onRemove:i,editor:s||o?{kind:"custom",className:"w-80",render:()=>n.jsxs("div",{className:"flex flex-col gap-2 p-3 text-sm",children:[s?n.jsxs(Se,{to:s.to,params:s.params,search:s.search,className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-foreground hover:underline",children:[n.jsx("span",{className:"truncate",children:a}),n.jsx(vn,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}):n.jsx("span",{className:"font-medium",children:a}),o]})}:void 0}}function Hs({ownerSlug:e,clientIds:t,linkedUser:a,linkedUserEntitySlug:s}){const o=e&&s?yn(e,[{entity_type:"$member",slug:s}]):null;return n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"inline-flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground",children:[n.jsx("span",{children:t.length===1?"Client ID":"Client IDs"}),t.map(i=>n.jsx("code",{className:"break-all text-foreground",children:i},i))]}),a?n.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:["Granted by",o?n.jsx(Se,{to:o,className:"font-medium text-foreground hover:underline",children:a}):n.jsx("span",{className:"font-medium text-foreground",children:a})]}):null]})}function zs(e,t=!0){return Ct({queryKey:["automations-list","activity",e],queryFn:async()=>{const a=await Promise.all(["active","archived"].map(s=>St("manage_automations",{action:"list",status:s,include_details:!1},{slug:e})));return[...new Map(a.flatMap(s=>s.automations).map(s=>[Number(s.automation_id),s])).values()].sort((s,o)=>s.name.localeCompare(o.name))},enabled:t&&!!e,staleTime:3e4})}function ee({to:e,params:t,search:a,label:s}){return n.jsx(Se,{to:e,params:t,search:a,onClick:o=>o.stopPropagation(),onPointerDown:o=>o.stopPropagation(),className:"shrink-0 rounded-md p-1 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 focus-visible:opacity-100","aria-label":`Manage ${s}`,children:n.jsx(Nt,{className:"h-3.5 w-3.5"})})}const Oe=["produced","analyzed"],ke=e=>e==="produced"?"Produced by":"Analyzed by";function qs({enabled:e,...t}){const a=Js(t,e);if(!e)return{fields:[],chips:[]};const s=Ys(t);return{fields:[a.field,s.field],chips:[...a.chips,...s.chips]}}function Js({ownerSlug:e,filters:t,onFiltersChange:a},s){const o=zs(e,s),i=o.data??[],u=m=>m==="produced"?t.producedByAutomationId:t.automationId,d=m=>i.find(v=>Number(v.automation_id)===m)?.name??`#${m}`,h=Oe.flatMap(m=>{const v=u(m);return v==null?[]:[{id:`automation-${m}`,field:"automation",label:ke(m),value:d(v),onRemove:()=>a(m==="produced"?{producedByAutomationId:null}:{automationId:null})}]}),l={kind:"list",className:"w-80",searchPlaceholder:"Search Automations...",emptyText:o.isLoading?"Loading Automations...":"No Automations found",items:m=>n.jsxs(n.Fragment,{children:[Oe.map(v=>{const g=u(v),r=i.map(y=>({id:Number(y.automation_id),label:`${y.name}${y.status==="archived"?" (archived)":""}`}));g!=null&&!r.some(y=>y.id===g)&&r.unshift({id:g,label:`Automation #${g} (selected)`});const p=y=>{a(v==="produced"?{producedByAutomationId:y}:{automationId:y}),m()};return n.jsx(_t,{heading:ke(v),children:r.map(y=>n.jsxs(E,{"aria-label":y.label,value:`${v} ${y.label} ${y.id}`,onSelect:()=>p(y.id),className:"group",children:[n.jsx(B,{selected:g===y.id}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.label}),n.jsx(ee,{...Us(e,String(y.id)),label:y.label})]},y.id))},v)}),o.isError?n.jsx(E,{forceMount:!0,onSelect:()=>void o.refetch(),children:"Could not load Automations. Retry"}):null]})};return{chips:h,field:{key:"automation",label:"Automation",group:"Scope",icon:n.jsx(gn,{className:"h-4 w-4"}),editor:l}}}function Ys(e){const{filters:t,onFiltersChange:a}=e,s=[];t.runIds?.length&&s.push({id:"run-produced",field:"run",label:"Produced by run",value:t.runIds.map(i=>`#${i}`).join(", "),onRemove:()=>a({runIds:null})}),t.runId!=null&&s.push({id:"run-analyzed",field:"run",label:"Analyzed by run",value:`#${t.runId}`,onRemove:()=>a({runId:null})});const o={kind:"list",className:"w-96",searchPlaceholder:"Search runs or enter a run ID...",emptyText:"No matching runs. Enter an exact run ID or load more.",items:(i,u)=>Oe.map(d=>n.jsx(Zs,{...e,mode:d,query:u,close:i},d))};return{chips:s,field:{key:"run",label:"Run",group:"Scope",icon:n.jsx(xn,{className:"h-4 w-4"}),editor:o}}}function Zs({ownerSlug:e,filters:t,onFiltersChange:a,mode:s,query:o,close:i}){const u=s==="produced"?t.producedByAutomationId:t.automationId,d=Ns({workspace:!0},{automationIds:u==null?void 0:[u],runTypes:s==="analyzed"?["automation"]:void 0,connectionIds:s==="produced"?t.connectionIds??void 0:void 0,feedIds:s==="produced"?t.feedIds??void 0:void 0},e),h=s==="produced"?t.runIds??[]:t.runId==null?[]:[t.runId],l=d.data?.pages.flatMap(r=>r.runs)??[],m=[...new Map(l.map(r=>[r.id,{id:r.id,label:`Run #${r.id} · ${r.feed_display_name??r.operation_key??r.run_type} · ${r.status}`}])).values()];for(const r of h)m.some(p=>p.id===r)||m.unshift({id:r,label:`Run #${r} (selected)`});const v=r=>{if(s==="produced"){const p=h.includes(r)?h.filter(y=>y!==r):[...h,r];a({runIds:p.length?p:null})}else a({runId:r}),i()},g=/^\d+$/.test(o.trim())?Number(o.trim()):0;return n.jsxs(_t,{heading:ke(s),children:[m.map(r=>n.jsxs(E,{value:`${s} ${r.label}`,onSelect:()=>v(r.id),children:[n.jsx(B,{selected:h.includes(r.id)}),n.jsx("span",{className:"truncate",children:r.label})]},r.id)),Number.isSafeInteger(g)&&g>0&&!m.some(r=>r.id===g)?n.jsxs(E,{value:`${s} ${g}`,onSelect:()=>v(g),children:[ke(s)," run #",g]}):null,d.isLoading?n.jsx(E,{disabled:!0,forceMount:!0,children:"Loading runs..."}):null,d.isError?n.jsx(E,{forceMount:!0,onSelect:()=>void(d.isFetchNextPageError?d.fetchNextPage():d.refetch()),children:"Could not load runs. Retry"}):null,!d.isLoading&&!d.isError&&!m.length?n.jsx(E,{disabled:!0,forceMount:!0,children:"No runs found"}):null,d.hasNextPage?n.jsx(E,{forceMount:!0,disabled:d.isFetching,onSelect:()=>void d.fetchNextPage(),children:d.isFetchingNextPage?"Loading more runs...":"Load more runs"}):null]})}const Ke="Scope",Re="Source",W="h-4 w-4";function se(){return ne().search??{}}function $t(e){const{pathname:t}=ne(),a=t.startsWith(`/${e}/events/`),s=kn(t,a?1:0),o=!!(s&&!a&&!Cn(s.split("/")[0]));return{pathname:t,embedded:o,recordPath:o?Sn(s)?.entityPath:a?s:void 0}}function Dt(e){const t=se(),{recordPath:a,pathname:s,embedded:o}=$t(e);return i=>{const u=te(e,t,i,a);return o?{to:s,search:u.search}:u}}const yt=e=>new Set((e??"").split(",").map(t=>t.trim()).filter(Boolean));function Xs({ownerSlug:e,sourceRead:t=!1,filters:a,onFiltersChange:s}){const o=se(),{recordPath:i,embedded:u}=$t(e),d=i?i.split("/").at(-2):void 0,h=typeof o.type=="string"&&o.type.trim()?o.type.trim():void 0,l=(d?dt(d):void 0)??(h?dt(h):void 0),m=bn(o),v=jn(o),g=typeof o.feed_ids=="string"?o.feed_ids:typeof o.feed_ids=="number"?String(o.feed_ids):void 0,r=eo(e,l,!u),p=to(e,l,i,u),y=no(e,m,!t),S=qs({ownerSlug:e,filters:a,onFiltersChange:s,enabled:!t}),N=so(e,v,g);return[r,p,y,S,N].reduce((x,M)=>({fields:[...x.fields,...M.fields],chips:[...x.chips,...M.chips]}),{fields:[],chips:[]})}function eo(e,t,a){const s=V(),o=se(),{visible:i}=Nn(e);if(!a)return{fields:[],chips:[]};const u=i.find(h=>h.slug===t),d={kind:"list",searchPlaceholder:"Search types...",emptyText:"No entity types",items:h=>n.jsxs(n.Fragment,{children:[i.map(l=>n.jsxs(E,{onSelect:()=>{s(te(e,o,{entity:void 0,create:void 0,type:l.slug})),h()},className:"group gap-2",children:[n.jsx(B,{selected:l.slug===t}),n.jsx(On,{icon:l.icon,className:"h-4 w-4 shrink-0"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.name}),typeof l.entity_count=="number"?n.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:l.entity_count}):null,n.jsx(ee,{to:"/$owner/entity-types/$slug",params:{owner:e,slug:l.slug},label:l.name})]},l.id)),n.jsxs(E,{onSelect:()=>{s(wn(e)),h()},className:"text-muted-foreground",children:[n.jsx(At,{className:"h-4 w-4 shrink-0"}),"Add entity type"]})]})};return{fields:[{key:"type",label:"Entity type",group:Ke,icon:n.jsx(_n,{className:W}),editor:d}],chips:t?[{id:"type",label:"Entity type",op:"is",value:u?.name??t,onRemove:()=>void s(te(e,o,{type:void 0}))}]:[]}}function to(e,t,a,s){const o=V(),i=se(),[u,d]=k.useState(""),[h,l]=k.useState(0),m=It(u,250),v={slug:e},{data:g,isLoading:r,isError:p,refetch:y}=In(t??"",v,{search:m,offset:h,limit:30,enabled:!s&&!!t}),{data:S}=Tn(a?`/${e}/${a}`:"",v),N=a?S?.entity:void 0,x=N?.name??(a?a.split("/").at(-1):void 0);if(s)return{fields:[],chips:x?[{id:"entity",label:"Entity",op:"is",value:x}]:[]};if(!t)return{fields:[],chips:[]};const M={kind:"list",searchPlaceholder:"Search entities...",emptyText:r?"Loading entities...":"No matching entities",className:"w-80",onQueryChange:F=>{d(F),l(0)},items:F=>n.jsxs(n.Fragment,{children:[p?n.jsx(E,{onSelect:()=>void y(),children:"Could not load entities. Retry"}):g?.entities.map(I=>n.jsxs(E,{value:I.slug,onSelect:()=>{const R=$n([...I.parent_slug&&I.parent_entity_type?[{entity_type:I.parent_entity_type,slug:I.parent_slug}]:[],{entity_type:I.entity_type,slug:I.slug}]);o(te(e,i,{type:t},R)),F()},children:[n.jsx(B,{selected:N?.slug===I.slug}),I.name]},I.slug)),h>0&&n.jsx(E,{onSelect:()=>l(Math.max(0,h-30)),children:"Previous entities"}),g?.metadata.has_more&&n.jsx(E,{disabled:r,onSelect:()=>l(h+30),children:"More entities"})]})};return{fields:[{key:"entity",label:"Entity",group:Ke,icon:n.jsx(En,{className:W}),editor:M}],chips:x?[{id:"entity",label:"Entity",op:"is",value:x,onRemove:()=>void o(te(e,i,{type:t}))}]:[]}}function no(e,t,a){const s=V(),o=Dt(e),{data:i=[]}=An(),u=k.useMemo(()=>[...i].sort((l,m)=>l.name.localeCompare(m.name)),[i]);if(!a)return{fields:[],chips:[]};const d=u.find(l=>l.agentId===t),h={kind:"list",searchPlaceholder:"Search agents...",emptyText:"No agents",items:l=>u.map(m=>n.jsxs(E,{onSelect:()=>{s(o({agent:m.agentId,schedule:void 0})),l()},className:"gap-2",children:[n.jsx(B,{selected:m.agentId===t}),n.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-medium",children:m.name.trim().charAt(0).toUpperCase()||"?"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.name})]},m.agentId))};return{fields:[{key:"agent",label:"Agent",group:Ke,icon:n.jsx(Fn,{className:W}),editor:h}],chips:t?[{id:"agent",label:"Agent",op:"is",value:d?.name??t,onRemove:()=>void s(o({agent:void 0,schedule:void 0}))}]:[]}}function so(e,t,a){const s=V(),o=Dt(e),{groups:i}=Ds(),u=se(),d=je({platforms:String(u.platforms??u.platform??"")}).platforms??[],h=k.useMemo(()=>yt(t),[t]),l=k.useMemo(()=>yt(a),[a]),m=d.length===1?d[0]:Rn(i,h),v=i.find(_=>_.connector_key===m),g=h.size===1?Number([...h][0]):void 0,r=Pn(g),{org:p}=Tt(),y=Et(p?.id,{feedIds:[...l].map(Number),enabled:g==null&&l.size>0}),S=g==null?y:r,N=S.data??[],x={platforms:void 0,platform:void 0,connection_ids:void 0,feed_ids:void 0},M={kind:"list",searchPlaceholder:"Search connectors...",emptyText:"No connectors",items:_=>n.jsxs(n.Fragment,{children:[i.map(b=>{const A=b.connector_name??b.connector_key;return n.jsxs(E,{disabled:b.connections.length===0,onSelect:()=>{s(o({...x,platforms:b.connector_key})),_()},className:"group gap-2",children:[n.jsx(B,{selected:b.connector_key===v?.connector_key}),n.jsx(Bn,{plain:!0,name:A,faviconDomain:b.favicon_domain,className:"h-5 w-5 shrink-0 rounded-md text-[10px]"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:A}),b.connection_count>0?n.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:b.connection_count}):null,n.jsx(ee,{to:"/$owner/connectors/$connectorKey",params:{owner:e,connectorKey:b.connector_key},label:A})]},b.connector_key)}),n.jsx(E,{asChild:!0,onSelect:_,className:"text-muted-foreground",children:n.jsxs(Se,{to:"/$owner/connectors/create",params:{owner:e},className:"flex items-center gap-2",children:[n.jsx(At,{className:"h-4 w-4 shrink-0"}),"Add connector"]})})]})},F=[{key:"connector",label:"Connector",group:Re,icon:n.jsx(Dn,{className:W}),editor:M}],I=[],R=v?.connector_name??v?.connector_key??(d.join(", ")||(h.size?`Connections ${[...h].join(", ")}`:void 0));if(R&&I.push({id:"connector",label:"Connector",op:"is",value:R,onRemove:()=>void s(o(x))}),v){F.push({key:"connection",label:"Connection",group:Re,icon:n.jsx(Mn,{className:W}),editor:K(v)});const _=h.size===1?v.connections.find(b=>h.has(String(b.id))):void 0;_&&I.push({id:"connection",label:"Connection",op:"is",value:ut({display_name:_.display_name,connector_name:v.connector_name,connector_key:v.connector_key}),onRemove:()=>void s(o({...x,platforms:v.connector_key}))})}if((g||a)&&F.push({key:"feed",label:"Feed",group:Re,icon:n.jsx(Ln,{className:W}),editor:Q()}),l.size>0){const _=l.size===1?N.find(b=>l.has(String(b.id))):void 0;I.push({id:"feed",label:"Feed",op:"is",value:_?ye(_):`#${a}`,onRemove:()=>void s(o({...g!=null?{connection_ids:String(g)}:{},feed_ids:void 0}))})}return{fields:F,chips:I};function K(_){return{kind:"list",searchPlaceholder:"Search connections...",emptyText:"No connections",items:b=>_.connections.map(A=>{const O=ut({display_name:A.display_name,connector_name:_.connector_name,connector_key:_.connector_key});return n.jsxs(E,{onSelect:()=>{s(o({connection_ids:String(A.id),feed_ids:void 0})),b()},className:"group gap-2",children:[n.jsx(B,{selected:h.has(String(A.id))}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:O}),A.feed_count>0?n.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:A.feed_count}):null,n.jsx(ee,{...Vs(e,{id:A.id,connector_key:_.connector_key}),label:O})]},A.id)})}}function Q(){return{kind:"list",searchPlaceholder:"Search feeds...",emptyText:S.isLoading?"Loading feeds...":"No feeds",items:_=>N.map(b=>n.jsxs(E,{"aria-label":ye(b),onSelect:()=>{s(o({...g!=null?{connection_ids:String(g)}:{},feed_ids:String(b.id)})),_()},className:"group gap-2",children:[n.jsx(B,{selected:l.has(String(b.id))}),n.jsx("span",{className:"min-w-0 flex-1 truncate",children:ye(b)}),n.jsx(ee,{...Gs(e,b),label:ye(b)})]},b.id))}}}function ye(e){return e.display_name?.trim()||e.feed_key}const Ce=[{value:"date-desc",label:"Newest first"},{value:"date-asc",label:"Oldest first"},{value:"score-desc",label:"Highest score"},{value:"score-asc",label:"Lowest score"}],Bt={value:"notifications",label:"Notifications"};function oo({value:e,onChange:t,withNotifications:a=!1}){const s=a?[Bt,...Ce]:Ce,o=s.find(i=>i.value===e)?.label??"Newest first";return n.jsxs(Kn,{value:e,onValueChange:t,children:[n.jsxs(Gn,{"aria-label":"Sort",className:"h-8 w-auto shrink-0 gap-2 bg-muted px-2.5",children:[n.jsx(Ft,{"aria-hidden":"true",className:"h-3.5 w-3.5 text-muted-foreground"}),n.jsx(Vn,{children:o})]}),n.jsx(Qn,{align:"end",className:"min-w-40",children:s.map(i=>n.jsx(Un,{value:i.value,children:i.label},i.value))})]})}const gt=[{value:"user",label:"Manual review"},{value:"system",label:"Auto-classified"},{value:"llm",label:"LLM-classified"}],xt=[{value:"pending",label:"Pending approval"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],ge=0,xe=100,Z="Event",U="h-4 w-4";function ao(e,t,a,s){const o=e.engagementRange??[ge,xe],i=e.reviewStatus,u=e.interactionStatus,d=e.semanticTypes??[],h=[{key:"kind",label:"Event kind",group:Z,icon:n.jsx(qn,{className:U}),editor:X({searchPlaceholder:"Search event kinds...",emptyText:"No event kinds found",options:_s(a,d).map(v=>({value:v,label:Fe(v)})),selected:d,multiple:!0,onSelect:v=>{const g=d.includes(v)?d.filter(r=>r!==v):[...d,v];t({semanticTypes:g.length>0?g:void 0})}})},{key:"date",label:"Date",group:Z,icon:n.jsx(Jn,{className:U}),editor:js({value:e.dateRange??void 0,onApply:v=>t({dateRange:v})})},{key:"approval",label:"Approval",group:Z,icon:n.jsx(Yn,{className:U}),editor:X({searchPlaceholder:"Search statuses...",options:[...xt],selected:u?[u]:[],onSelect:v=>t({interactionStatus:v})})},{key:"review",label:"Reviewed by",group:Z,icon:n.jsx(Zn,{className:U}),editor:X({searchPlaceholder:"Search reviewers...",options:[...gt],selected:i&&i!=="all"?[i]:[],onSelect:v=>t({reviewStatus:v})})},{key:"score",label:"Engagement score",group:Z,icon:n.jsx(Xn,{className:U}),editor:ks({value:o,min:ge,max:xe,onApply:v=>t({engagementRange:v})})}],l=[],m=e.eventCategory!=null&&d.length===1&&d[0]===Ot;return d.length&&!m&&l.push({id:"kind",label:"Kind",value:d.length<=2?d.map(Fe).join(", "):`${d.length} kinds`,title:d.map(Fe).join(", "),onRemove:()=>t({semanticTypes:void 0})}),e.dateRange&&l.push({id:"date",label:"Date",op:"is",value:Cs(e.dateRange),onRemove:()=>t({dateRange:null})}),u&&!(s&&u==="pending")&&l.push({id:"approval",label:"Approval",op:"is",value:xt.find(v=>v.value===u)?.label??u,onRemove:()=>t({interactionStatus:null})}),i&&i!=="all"&&l.push({id:"review",label:"Reviewed by",op:"is",value:gt.find(v=>v.value===i)?.label??i,onRemove:()=>t({reviewStatus:void 0})}),(o[0]!==ge||o[1]!==xe)&&l.push({id:"score",label:"Engagement score",value:Ss(o,ge,xe),onRemove:()=>t({engagementRange:void 0})}),{fields:h,chips:l}}function Kt({filters:e,onFiltersChange:t,eventKinds:a=[],searchQuery:s,onSearchChange:o,scope:i,extraFields:u=[],drillChips:d=[],onShowNotifications:h,sourceRead:l=!1,filterTrailing:m,filterActions:v,quickFilters:g,needsYou:r=!1,toolbarLeading:p,toolbarTrailing:y,searchPlaceholder:S="Search events...",onClearFilters:N}){const x=s.trim().length>0,M=l?{fields:[],chips:[]}:ao(e,t,a,r),F=`${e.sortBy??"date"}-${e.sortOrder??"desc"}`,I=b=>{const[A,O]=b.split("-");t({sortBy:A,sortOrder:O})},R=p!=null||y!=null,K=R&&!l?{fields:[{key:"sort",label:"Order",group:"Order",icon:n.jsx(Ft,{className:U}),editor:X({searchPlaceholder:"Search orders...",options:[...Ce],selected:[F],onSelect:I})}],chips:F==="date-desc"?[]:[{id:"sort",label:"Order",value:Ce.find(b=>b.value===F)?.label??F,onRemove:()=>t({sortBy:"date",sortOrder:"desc"})}]}:{fields:[],chips:[]},Q=[...g?.fields??[],...M.fields,...i?.fields??[],...u,...K.fields],_=[...g?.chips??[],...i?.chips??[],...d,...M.chips,...K.chips];return n.jsxs("div",{className:"w-full space-y-2.5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p,!l&&n.jsxs("div",{className:"relative min-w-0 flex-1",children:[n.jsx(Wn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(Hn,{type:"search","aria-label":"Search events",placeholder:S,value:s,onChange:b=>o(b.target.value),className:De("h-8 pl-9",R&&vt,x&&"pr-9")}),x&&n.jsx("button",{type:"button","aria-label":"Clear search",onClick:()=>o(""),className:"absolute right-0.5 top-1/2 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:n.jsx(zn,{className:"h-3.5 w-3.5"})})]}),!l&&!R&&n.jsx(oo,{value:F,withNotifications:h!=null,onChange:b=>{if(b===Bt.value){h?.();return}I(b)}}),y,R?n.jsx(xs,{fields:Q,triggerClassName:vt}):null]}),n.jsx(bs,{label:"Event filters",menu:!R,clearAllMin:R?2:1,fields:Q,chips:_,actions:v,trailing:m,onClearAll:N,hasClearableState:x})]})}function Gt({ownerSlug:e,...t}){const a=Xs({ownerSlug:e,sourceRead:t.sourceRead,filters:t.filters,onFiltersChange:t.onFiltersChange});return n.jsx(Kt,{...t,scope:a})}const we=3600*1e3,bt=24*we;function jt(e){const t=e instanceof Date?e:new Date(String(e));return Number.isNaN(t.getTime())?null:t}function kt(e){return e.toISOString().split("T")[0]}function $e(e){return e.toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"})}function io(e){const a=e[e.length-1].date.getTime()-e[0].date.getTime()>180*bt,s=new Map;for(const o of e){const i=new Date(o.date);a&&i.setUTCDate(i.getUTCDate()-i.getUTCDay()),s.set(i.getTime(),(s.get(i.getTime())??0)+o.count)}return[...s.entries()].sort(([o],[i])=>o-i).map(([o,i])=>{const u=new Date(o);return{start:u,end:new Date(o+(a?7:1)*bt),count:i,label:`${u.getUTCMonth()+1}/${u.getUTCDate()}`,tooltip:a?`Week of ${$e(u)}`:$e(u)}})}function ro(e){const t=u=>{const d=new Date(u);return d.setMinutes(0,0,0),d.getTime()},a=new Map;for(const u of e)a.set(t(u),(a.get(t(u))??0)+1);const s=Math.min(...a.keys()),o=Math.max(...a.keys()),i=[];for(let u=s;u<=o;u+=we){const d=new Date(u);i.push({start:d,end:new Date(u+we),count:a.get(u)??0,label:mt(d,"HH:mm"),tooltip:mt(d,"MMM d, HH:mm")})}return i}function co({entityId:e,organizationId:t,ownerSlug:a,eventTimes:s,selectedRange:o,onSelectRange:i}){const{data:u,isLoading:d,error:h}=es(t,{entityId:e},{slug:a}),l=k.useMemo(()=>(u??[]).map(p=>{const y=jt(p.date);return y?{date:y,count:p.count}:null}).filter(p=>p!==null).sort((p,y)=>p.date.getTime()-y.date.getTime()),[u]),m=k.useMemo(()=>{if(l.length===0)return[];if(l.length>1)return io(l);const[p]=l,y=kt(p.date),S=(s??[]).map(jt).filter(N=>N!==null&&kt(N)===y);return S.length===p.count?ro(S):[]},[l,s]),v=k.useCallback(p=>{const y=m[p.dataIndex];y&&i&&i(y.start,y.end)},[m,i]),g=k.useCallback(p=>{if(i&&p.startValue!==void 0&&p.endValue!==void 0){const y=new Date(p.startValue),S=new Date(p.endValue);i(y,S)}},[i]),r=k.useMemo(()=>{if(m.length<2)return null;let p;if(o){const[y,S]=o,N=m.filter(x=>x.start<S&&x.end>y);N.length>0&&(p=[[{xAxis:N[0].label},{xAxis:N[N.length-1].label}]])}return{tooltip:{trigger:"axis",axisPointer:{type:"line"},formatter:y=>{const S=y[0];return`${m[S.dataIndex]?.tooltip}: ${S.value} items`}},grid:{left:50,right:20,top:20,bottom:60},xAxis:{type:"category",boundaryGap:!1,data:m.map(y=>y.label)},yAxis:{type:"value",minInterval:1,splitLine:{lineStyle:{color:"rgba(0,0,0,0.05)"}}},dataZoom:[{type:"slider",start:0,end:100,height:20,bottom:10,borderColor:"transparent",backgroundColor:"rgba(0,0,0,0.02)",fillerColor:"rgba(99, 102, 241, 0.1)",handleStyle:{color:"#6366f1"}}],series:[{type:"line",smooth:!0,areaStyle:{opacity:.3,color:new Ms(0,0,0,1,[{offset:0,color:"rgba(99, 102, 241, 0.5)"},{offset:1,color:"rgba(99, 102, 241, 0.05)"}])},lineStyle:{width:2,color:"#6366f1"},itemStyle:{color:"#6366f1"},showSymbol:!1,data:m.map(y=>y.count),markLine:{silent:!0,symbol:"none",label:{position:"insideEndTop",formatter:"avg: {c}",fontSize:10,color:"#9ca3af"},lineStyle:{color:"#d1d5db",type:"dashed",width:1},data:[{type:"average",name:"Average"}]},markArea:p?{silent:!0,itemStyle:{color:"rgba(99, 102, 241, 0.1)"},data:p}:void 0}]}},[m,o]);if(d||h)return n.jsx("div",{className:De(Rt,"p-4"),children:n.jsx("div",{className:"flex h-48 w-full items-center justify-center",children:d?n.jsx(Os,{}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load timeline"})})});if(l.length===0)return null;if(!r){const[p]=l;return n.jsxs("p",{className:"text-xs text-muted-foreground",children:[p.count===1?"1 event":`All ${p.count} events`," on"," ",$e(p.date),"."]})}return n.jsx(lo,{option:r,onClick:v,onDataZoom:g})}function lo({option:e,onClick:t,onDataZoom:a}){const{chartRef:s,setOption:o}=Ls({onClick:t,onDataZoom:a});return k.useEffect(()=>{o(e,!0)},[e,o]),n.jsx("div",{"data-testid":"events-timeline",className:De(Rt,"p-4 relative"),children:n.jsx("div",{ref:s,className:"h-48 w-full"})})}const be={config:"Configuration",deployment:"Applies"};function uo({organizationId:e,ownerSlug:t,entityId:a,hideSourceFilter:s=!1,scopedEntityTypes:o,pinned:i,onShowNotifications:u,emptyState:d,toolbar:h}){const{isAuthenticated:l,isReady:m}=ts(),{isMember:v,isLoading:g}=Tt(),r=m&&l&&v,p=m&&(!l||!g&&!v),y=V(),S=ne(),N=ns(),{filters:x,updateFilters:M,clearFilters:F}=wt({parse:je,serialize:Me,filterKeys:Mt,replace:!1,merge:Pt}),[I,R]=k.useState(x.searchQuery||""),[K,Q]=k.useState(Pe(x)||s&&(a!=null||!!o?.length)),_=I.trim(),b=_.length>=3?_:void 0,A=It(b,1e3),O=k.useRef(!1);k.useEffect(()=>N.history.subscribe(({location:c,action:f})=>{const C=je(new URLSearchParams(c.search)).searchQuery??"";!(f.type==="BACK"||f.type==="FORWARD"||f.type==="GO")&&O.current&&(C===(x.searchQuery??"")||C===(b??""))||(O.current=!1,R(C))}),[N.history,b,x.searchQuery]);const j=k.useMemo(()=>{const{afterOccurredAt:c,afterId:f,...C}=x;return pt({...C,...o?.length?{entityTypes:o}:{}})},[x,o]),P=M;k.useEffect(()=>{O.current&&(x.searchQuery||void 0)!==A&&M({searchQuery:A})},[A,M,x.searchQuery]);const Ge=()=>{O.current=!1,R(""),s&&t?y({...Le(t,S.search??{}),...a!==void 0&&!S.pathname.startsWith(`/${t}/events/`)?{to:S.pathname}:{}}):F()},oe=Pe(pt(x)),ae=a===void 0,{data:Vt=[]}=ss(m&&r?e:null),{data:Qt=[]}=os(p?t:null),Ve=r?Vt:Qt,{data:Qe=[]}=as(r&&e?{organizationId:e}:void 0),ie=Bs(),re=j.connectionIds,Ne=(re?.length??0)>0,{data:Ue=[]}=is(m&&r?e??"":"",{connectionIds:re??void 0,enabled:!ie&&m&&r&&Ne}),We=j.feedIds,_e=(We?.length??0)>0,{data:He=[]}=Et(m&&r?e:null,{feedIds:We??void 0,enabled:m&&r&&_e}),ze=k.useMemo(()=>ie?ie.groups.flatMap(c=>c.connections.map(f=>({id:f.id,display_name:f.display_name,connector_name:c.connector_name,connector_key:c.connector_key}))):Ue,[Ue,ie]),Ie=k.useMemo(()=>{const c=new Set(re??[]);return[...new Set([...j.platforms??[],...ze.filter(f=>c.has(f.id)).map(f=>f.connector_key)])]},[re,ze,j.platforms]),Te=k.useMemo(()=>He.map(c=>({connectorKey:c.connector_key,feedKey:c.feed_key})),[He]),Ut=k.useMemo(()=>Ne&&Ie.length===0||_e&&Te.length===0?[]:Is({connectors:Ve,entityTypes:Qe,selectedPlatforms:Ie,selectedFeeds:Te,selectedEntityTypes:j.entityTypes}),[Ve,j.entityTypes,Ne,_e,Ie,Te,Qe]),L=j.clientIds,ce=(L?.length??0)>0,{data:qe=[]}=Es(null,{enabled:m&&r&&ce}),le=k.useMemo(()=>{if(!L)return[];const c=new Set(L);return Fs(qe).filter(f=>f.clientIds.some(C=>c.has(C)))},[L,qe]),Je=k.useMemo(()=>{if(!ce||!L)return null;const c=le.map(f=>f.title);return c.length>0?c.join(", "):L.length>1?`${L.length} client registrations`:"Client registration"},[le,L,ce]),de=le.length===1?le[0]:null,Wt=t&&de?Qs(t,de.clientId):void 0,ue=j.mcpActivityId??null,{data:Ye=[]}=As({enabled:m&&r&&ce&&!!ue,clientIds:L??[],limit:100}),Ze=k.useMemo(()=>{if(!ue)return null;const c=Ye.find(C=>C.activityId===ue);if(!c)return"Selected conversation";const f=c.title?.trim();return f||(c.activityKind==="session"?"MCP session":c.clientId)},[ue,Ye]),H=j.agentId,z=j.schedule,{data:Xe=[]}=Ks(H??void 0),et=k.useMemo(()=>!z||!H?null:Xe.find(f=>f.id===z)?.description?.trim()||"Scheduled task",[H,z,Xe]),{data:Ht}=rs(m&&r?e:null,a),{data:zt}=cs(p&&!ae?t:null,a),tt=r?Ht:zt,me=k.useMemo(()=>{const c=new Map;for(const f of tt||[]){const C=f.automation_name??"__global__";c.has(C)||c.set(C,{automationName:f.automation_name??null,classifiers:[]});const T=c.get(C),$=f.attribute_values||{},w=Object.keys($);let he=null;const q={};for(const[J,G]of Object.entries($))if(G.parent)for(const[Ae,Y]of Object.entries(G.parent))he=Ae,q[Y]||(q[Y]=[]),q[Y].push(J);const D=T.classifiers.find(J=>J.slug===f.slug);if(D){const J=new Set([...D.values,...w]);D.values=[...J];for(const[G,Ae]of Object.entries(q)){D.valuesByParentValue[G]||(D.valuesByParentValue[G]=[]);const Y=new Set([...D.valuesByParentValue[G],...Ae]);D.valuesByParentValue[G]=[...Y]}he&&(D.parentSlug=he)}else T.classifiers.push({slug:f.slug,name:f.name,values:w,parentSlug:he,valuesByParentValue:q})}for(const f of c.values())f.classifiers.sort((C,T)=>C.parentSlug===null&&T.parentSlug!==null?-1:C.parentSlug!==null&&T.parentSlug===null?1:0);return[...c.values()]},[tt]),qt=ls(m&&r?e:null,a,j,t),Jt=ds(p?t:null,a,j),Yt=p?Jt:qt,{data:Ee,isLoading:Zt,error:Xt}=Yt,en=k.useMemo(()=>Ee?.pages.flatMap(c=>c.content.map(f=>f.occurred_at)),[Ee]),nt=Ee?.pages[0],tn=(nt?.content.length??0)>0,st=me.some(c=>c.classifiers.length>0),nn=us(m&&r&&st?e:null,a,j,t),sn=ms(p&&st?t:null,a,j),on=(p?sn:nn).data?.classification_stats,an=k.useCallback(()=>{P({beforeOccurredAt:void 0,beforeId:void 0,afterOccurredAt:void 0,afterId:void 0}),window.scrollTo({top:0,behavior:"smooth"})},[P]),rn=(c,f)=>{P({dateRange:[c,f]})},ot=(c,f)=>{const C={...j.classificationFilters||{}};if(f.length>0)C[c]=f;else{delete C[c];for(const T of me)for(const $ of T.classifiers)$.parentSlug===c&&delete C[$.slug]}P({classificationFilters:C})},cn=(c,f)=>{const C=j.classificationFilters?.[c]||[];ot(c,C.includes(f)?C.filter(T=>T!==f):[...C,f])},ln=c=>ot(c,[]);if(Xt)return n.jsx(ps,{label:"knowledge"});const at=!m||l&&g||r&&!e||Zt,pe={fields:[],chips:[]};for(const c of me)for(const f of c.classifiers){const C=j.classificationFilters?.[f.slug]??[],T=f.parentSlug?j.classificationFilters?.[f.parentSlug]??[]:void 0,$=T?[...new Set(T.flatMap(w=>f.valuesByParentValue[w]??[]))]:f.values;$.length>0&&pe.fields.push({key:`clf:${f.slug}`,label:f.name,group:c.automationName??"Classifiers",icon:n.jsx(fs,{className:"h-4 w-4"}),editor:X({searchPlaceholder:`Search ${f.name.toLowerCase()}...`,options:$.map(w=>({value:w,label:w,count:on?.[f.slug]?.[w]})),selected:C,multiple:!0,onSelect:w=>cn(f.slug,w)})})}for(const[c,f]of Object.entries(j.classificationFilters??{})){if(f.length===0)continue;const C=me.flatMap(T=>T.classifiers).find(T=>T.slug===c);pe.chips.push({id:`clf:${c}`,field:`clf:${c}`,label:C?.name??c,op:f.length>1?"is any of":"is",value:f.join(", "),onRemove:()=>ln(c)})}const dn=[j.contentIds?.length?ve({id:"contentIds",label:j.contentIds.length>1?"Events":"Event",value:`#${j.contentIds.join(", #")}`,onRemove:()=>P({contentIds:void 0})}):null,Ze?ve({id:"mcpActivityId",label:"Conversation",value:Ze,onRemove:()=>P({mcpActivityId:void 0})}):null,Je?ve({id:"clientIds",label:"Connected app",value:Je,sourceLink:Wt,details:L&&L.length>0?n.jsx(Hs,{ownerSlug:t,clientIds:L,linkedUser:de?.linkedUser,linkedUserEntitySlug:de?.linkedUserEntitySlug}):void 0,onRemove:()=>P({clientIds:void 0})}):null,et?ve({id:"schedule",label:"Schedule",value:et,sourceLink:t&&H&&z?Ws(t,H,z):void 0,onRemove:()=>P({schedule:void 0,runIds:void 0})}):null,...j.eventCategory?[be[j.eventCategory]?{id:"event-category",label:be[j.eventCategory],value:"",onRemove:()=>P({eventCategory:void 0,semanticTypes:void 0})}:{id:"event-category",label:"Category",op:"is",value:j.eventCategory,onRemove:()=>P({eventCategory:void 0})}]:[],...j.resourceKind||j.resourceId?[{id:"resource",label:"Resource",op:"is",value:`${j.resourceKind}: ${j.resourceId}`,onRemove:()=>P({resourceKind:void 0,resourceId:void 0})}]:[],...pe.chips].filter(c=>c!=null),un=!!(r&&a&&e),it=i&&!oe?i:void 0,rt=ae&&r&&u!=null,fe={fields:[],chips:[]};if(rt){const c=x.interactionStatus==="pending";fe.fields.push({key:"needs-you",label:"Needs you",icon:n.jsx(gs,{className:"h-4 w-4"}),editor:{kind:"toggle",checked:c,onToggle:()=>P({interactionStatus:c?null:"pending"})}}),c&&fe.chips.push({id:"needs-you",label:"Needs you",value:"",onRemove:()=>P({interactionStatus:null})})}if(ae&&r)for(const[c,f,C]of[["config",be.config,Nt],["deployment",be.deployment,hs]]){const T=x.eventCategory===c;fe.fields.push({key:`category:${c}`,label:f,icon:n.jsx(C,{className:"h-4 w-4"}),editor:{kind:"toggle",checked:T,onToggle:()=>P({eventCategory:T?void 0:c,semanticTypes:T?void 0:[Ot],resourceKind:void 0,resourceId:void 0})}})}const ct={quickFilters:fe,needsYou:rt,toolbarLeading:h?.leading,toolbarTrailing:h?.trailing,searchPlaceholder:h?"Search activity":void 0,filterTrailing:un?n.jsxs(Lt,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground","aria-pressed":K,onClick:()=>Q(c=>!c),children:[n.jsx(ys,{className:"mr-1.5 h-3.5 w-3.5"}),"Timeline"]}):void 0,onClearFilters:Ge,onShowNotifications:u,filters:j,onFiltersChange:P,eventKinds:Ut,searchQuery:I,onSearchChange:c=>{O.current=!0,R(c)},extraFields:pe.fields,drillChips:dn},mn=!at&&!!nt&&!tn&&!oe,pn=l?r?"Activity is the workspace's live feed — every message, email, file, and record a connector pulls in lands here as an event. Connect your data to start collecting.":"Activity is the workspace's live feed of connector events. Join this workspace to add connectors and collect knowledge here.":"No public knowledge items are available yet",lt=!!(r&&t);return n.jsx(vs,{children:n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:s?"sticky top-0 z-10 -mx-4 bg-background px-4 pb-2 lg:-mx-6 lg:px-6":void 0,children:s&&t?n.jsx(Gt,{...ct,ownerSlug:t}):n.jsx(Kt,{...ct})}),K&&r&&a&&e&&n.jsx(co,{entityId:a,organizationId:e,ownerSlug:t||"",eventTimes:en,selectedRange:j.dateRange||void 0,onSelectRange:rn}),it?.rows,at?n.jsx(Ps,{}):mn?d??n.jsx(ft,{icon:ht,title:"No activity yet",description:pn,actionLabel:lt?"Add a connector":void 0,onAction:lt&&t?()=>void y({to:"/$owner/connectors/create",params:{owner:t}}):void 0}):n.jsx(Rs,{organizationId:e,ownerSlug:t,entityId:a,filters:j,showEntityLinks:ae,groupStretches:!0,onGoToLatest:j.beforeOccurredAt?an:void 0,hiddenApprovalRunIds:it?.hiddenApprovalRunIds,emptyState:n.jsx(ft,{icon:ht,title:"No results found",description:"Try adjusting your filters to find what you are looking for",actionLabel:oe?"Clear filters":void 0,onAction:oe?Ge:void 0})})]})})}function mo({record:e,ownerSlug:t}){const a=ne(),s=V(),{filters:o,updateFilters:i}=wt({parse:je,serialize:Me,filterKeys:Mt,replace:!1,merge:Pt}),u=Pe({...o,platforms:void 0,connectionIds:void 0,feedIds:void 0})||o.sortBy!=null&&o.sortBy!=="date"||o.sortOrder!=null&&o.sortOrder!=="desc",d=()=>{s({...Le(t,a.search??{}),...a.pathname.startsWith(`/${t}/events/`)?{}:{to:a.pathname}})};return n.jsxs("div",{className:"space-y-4",children:[n.jsx(Gt,{ownerSlug:t,sourceRead:!0,filters:o,onFiltersChange:i,searchQuery:o.searchQuery??"",onSearchChange:h=>i({searchQuery:h}),onClearFilters:d}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Live activity supports connector, connection and feed filters. Search and other event filters are available for saved activity."}),u?n.jsxs("div",{role:"alert",className:"space-y-2 rounded-md border p-3 text-sm",children:[n.jsx("p",{children:"Some selected filters aren't supported for live activity. Clear them to see results."}),n.jsx(Lt,{variant:"outline",size:"sm",onClick:()=>{const h=Me({platforms:o.platforms,connectionIds:o.connectionIds,feedIds:o.feedIds}),l={...Le(t,a.search??{}).search,...h};s({to:a.pathname,search:l})},children:"Clear unsupported filters"})]}):n.jsx(Ts,{record:e,orgContext:{slug:t},filters:o})]})}function Eo({entity:e,organizationId:t,ownerSlug:a}){const s=e.is_derived?n.jsx(mo,{ownerSlug:a,record:{type:e.entity_type,key:e.slug}}):n.jsx(uo,{organizationId:t,ownerSlug:a,entityId:typeof e.id=="number"?e.id:void 0,hideSourceFilter:!0});return n.jsx($s,{organizationId:t,children:e.entity_type==="$member"?n.jsx(ws,{children:s}):s})}export{uo as E,$s as M,Bt as N,Eo as R,oo as S};
|
|
2
|
-
//# sourceMappingURL=record-activity-BCpNKaUo.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{fr as r,cP as s,cQ as c,cC as l,aa as g,fs as f}from"./index-C2TCKJDP.js";const I=30,_=new Set(["running","pending","claimed"]);function m(n){return"workspace"in n?["workspace"]:"connectionId"in n?["connection",n.connectionId]:"deviceId"in n?["device",n.deviceId]:"connectorKey"in n?["connector",n.connectorKey]:["feed",n.feedId]}function y(n){return"workspace"in n?{}:"connectionId"in n?{connection_ids:[n.connectionId]}:"deviceId"in n?{device_worker_id:n.deviceId}:"connectorKey"in n?{connector_key:n.connectorKey}:{feed_ids:[n.feedId]}}function v(n,e,i){return r({queryKey:["runs-infinite",i??null,n?m(n):null,e.runTypes??null,e.status??null,e.automationIds??null,e.connectionIds??null,e.feedIds??null],queryFn:async({pageParam:t})=>{const a=t;return s("manage_operations",{action:"list_runs",...y(n),...e.runTypes&&e.runTypes.length>0?{run_types:e.runTypes}:{},...e.status?{status:e.status}:{},...e.automationIds?.length?{automation_ids:e.automationIds}:{},...e.connectionIds?.length?{connection_ids:e.connectionIds}:{},...e.feedIds?.length?{feed_ids:e.feedIds}:{},...a?{before_id:a.before_id,before_created_at:a.before_created_at}:{},limit:I},i?{slug:i}:void 0)},initialPageParam:null,getNextPageParam:t=>{if(!t.has_more)return;const a=t.runs[t.runs.length-1];if(a)return{before_id:a.id,before_created_at:a.created_at}},refetchInterval:t=>(t.state.data?.pages??[]).some(d=>d.runs.some(u=>_.has(u.status)))?5e3:!1,enabled:!!n,staleTime:15e3})}function p(n,e){return n.kind==="agent"?n.agentId?`/${n.agentId}/config/pending/${e}`:null:n.agentId&&n.automationId?`/${n.agentId}/automations/${n.automationId}/pending/${e}`:null}function P(n,e){const{slug:i}=c(),t=e!=null?p(n,e):null,a=n.kind==="agent"?["agent",n.agentId]:["automation",n.agentId,n.automationId];return l({queryKey:["pending-proposal",i,...a,e],queryFn:async()=>{const o=await g(f(i,t),{credentials:"include"});if(o.status===404)return{status:"gone"};if(!o.ok)throw new Error(`Failed to fetch pending proposal: ${o.status}`);return{status:"pending",proposal:await o.json()}},enabled:!!i&&!!t&&!!e,staleTime:0,retry:!1})}export{P as a,v as u};
|
|
2
|
-
//# sourceMappingURL=runs-B_iywKWb.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as t,B as k,L as v,da as B,i as h,cH as D,cI as F,cK as M,hJ as A,hK as I,u as K,hL as p,hM as E,b4 as y,ba as w,eA as O,r as x,e3 as N,e4 as b,e7 as C,eE as P,aq as V,ai as z,hN as J,hO as U,hP as _,b5 as q,C as G,dO as H}from"./index-C2TCKJDP.js";import{R as Q,a as W}from"./run-initiator-8vdkq-3o.js";function X(e,s){switch(s.kind){case"connection":return I(e,s.id);case"feed":return A(e,s.id);case"run":return{to:"/$owner/events",params:{owner:e},search:{run_ids:String(s.id)}}}}function Y({ownerSlug:e,scope:s,variant:n="outline",iconOnly:a=!1,label:o,className:c,title:i}){const l=X(e,s),r=i??o??"View in memory",u=t.jsx(k,{asChild:!0,variant:n,size:a?"icon":"sm",className:h(a&&"h-7 w-7",c),children:t.jsxs(v,{to:l.to,params:l.params,search:l.search,children:[t.jsx(B,{className:h("h-3.5 w-3.5",!a&&"mr-1.5")}),!a&&(o??"View in memory")]})});return a?t.jsxs(D,{children:[t.jsx(F,{asChild:!0,children:u}),t.jsx(M,{children:r})]}):u}function Z({status:e}){return e==="completed"?t.jsx(P,{className:"h-4 w-4 text-green-500"}):e==="failed"?t.jsx(V,{className:"h-4 w-4 text-destructive"}):e==="running"?t.jsx(z,{className:"text-blue-500"}):t.jsx(J,{className:"h-4 w-4 text-muted-foreground"})}const ee={completed:"Completed",failed:"Failed",running:"Running",pending:"Queued",claimed:"Starting",timeout:"Timed out",cancelled:"Cancelled"};function $(e){const s=e.split("_").join(" ");return s.charAt(0).toUpperCase()+s.slice(1)}function te({error:e}){const[s,n]=x.useState(!1);return e.length<=80?t.jsx("span",{className:"text-destructive",children:e}):t.jsxs(N,{open:s,onOpenChange:n,children:[t.jsx(b,{asChild:!0,children:t.jsx("button",{type:"button",className:"text-left text-destructive hover:underline",children:e})}),t.jsx(C,{className:"max-h-64 w-96 overflow-auto",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-xs text-destructive",children:e})})]})}function se({checkpoint:e}){return t.jsxs(N,{children:[t.jsx(b,{asChild:!0,children:t.jsx(k,{variant:"ghost",size:"icon",title:"Checkpoint","aria-label":"Checkpoint",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground",children:t.jsx(U,{className:"h-4 w-4","aria-hidden":"true"})})}),t.jsx(C,{className:"max-h-64 w-80 overflow-auto",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-xs",children:JSON.stringify(e,null,2)})})]})}function R(e){if(e.initiator_kind)return{kind:e.initiator_kind,...e.initiator_ref};if(e.automation_id)return{kind:"automation",automation_id:e.automation_id};if(e.created_by_user_id)return{kind:"user",user_id:e.created_by_user_id}}function ne({run:e,ownerSlug:s}){const n=R(e);return n?n.kind==="system"?t.jsx(t.Fragment,{children:"by the system"}):t.jsxs(t.Fragment,{children:["by"," ",t.jsx(Q,{ownerSlug:s,initiator:n,clientName:void 0,fallback:"a person"})]}):null}function ie({parts:e}){return t.jsx(t.Fragment,{children:e.map(([s,n],a)=>t.jsxs(x.Fragment,{children:[a>0?" · ":"",n]},s))})}function j(e,s){return[e.run_type?$(e.run_type):"Run",s.connection?e.connection_display_name:null,s.feed?e.feed_display_name??e.feed_key:null].filter(Boolean).join(" · ")}const ae=3;function g(e,s){const n=p(e.created_at);return e.status==="completed"&&n!=null?`${j(e,s)}|${H(n,"yyyy-MM-dd")}`:null}function re(e,s){const n=new Map;for(const c of e){const i=g(c,s);i&&n.set(i,[...n.get(i)??[],c])}const a=[],o=new Set;for(const c of e){const i=g(c,s),l=i?n.get(i):void 0;!i||!l||l.length<ae?a.push({kind:"run",run:c}):o.has(i)||(o.add(i),a.push({kind:"group",name:j(c,s),runs:l}))}return a}function oe({name:e,runs:s,ownerSlug:n,columns:a}){const[o,c]=x.useState(!1),i=p(s[0].created_at),l=p(s[s.length-1].created_at),r=Date.now(),u=s.reduce((m,T)=>m+(T.items_collected??0),0),d=l!=null?_(l,r):null,f=i!=null?_(i,r):null,S=d&&f&&d!==f?`${d}–${f}`:f;return t.jsxs("div",{children:[t.jsx("button",{type:"button","aria-expanded":o,onClick:()=>c(m=>!m),className:h(w,"rounded-lg transition-colors hover:bg-accent/40"),children:t.jsx(y,{mark:t.jsx(G,{"aria-hidden":"true",className:h("h-4 w-4 text-muted-foreground transition-transform",o&&"rotate-90")}),name:e,details:t.jsx(q,{parts:[`${s.length} runs`,S,"all completed",u>0?`${u} ${u===1?"item":"items"}`:null]}),at:i})}),o?t.jsx("div",{className:"ml-6 border-l pl-2",children:s.map(m=>t.jsx("div",{className:"mb-1",children:t.jsx(L,{run:m,ownerSlug:n,columns:a})},m.id))}):null]})}function L({run:e,ownerSlug:s,columns:n={}}){const a=K(),o=p(e.created_at),c=p(e.completed_at),i=o!=null&&c!=null?Math.round((c-o)/1e3):null,l=j(e,n),r=n.startedBy&&R(e)?t.jsx(ne,{run:e,ownerSlug:s}):null,u=[["status",ee[e.status]??$(e.status)],e.error_message?["error",t.jsx(te,{error:e.error_message},"error")]:null,e.items_collected!=null&&(e.run_type==="sync"||e.items_collected>0)?["items",`${e.items_collected} ${e.items_collected===1?"item":"items"}`]:null,i!=null?["duration",E(i)]:null,r?["by",r]:null,e.connector_version?["version",`v${e.connector_version}`]:null,["id",`#${e.id}`]].filter(d=>d!==null);return t.jsxs("article",{"aria-label":`Run #${e.id}`,title:O(e.created_at),className:"group relative flex items-center rounded-lg transition-colors hover:bg-accent/40",children:[t.jsx("div",{className:h(w,"min-w-0 flex-1"),children:t.jsx(y,{mark:t.jsx(Z,{status:e.status}),name:t.jsx(v,{to:"/$owner/events",params:{owner:s},search:{run_ids:String(e.id)},"aria-label":`${l} · Run #${e.id}`,className:"hover:underline",onClick:d=>{!a||d.button!==0||d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||(d.preventDefault(),a.open({href:e.run_type==="automation"&&e.automation_id!=null?`/${s}/automations/${e.automation_id}?view=activity&run_id=${e.id}`:`/${s}/events?run_ids=${e.id}`,title:`Run #${e.id}`,runId:e.id}))},children:l}),tone:e.status==="failed"||e.status==="timeout"?"destructive":null,details:t.jsx(ie,{parts:u}),at:o,atClassName:"group-hover:invisible group-focus-within:invisible"})}),t.jsxs("div",{className:"absolute top-1/2 right-2 flex -translate-y-1/2 items-center gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",children:[e.checkpoint?t.jsx(se,{checkpoint:e.checkpoint}):null,t.jsx(Y,{ownerSlug:s,scope:{kind:"run",id:e.id},variant:"ghost",iconOnly:!0,title:"View events from this run"})]})]})}function de({runs:e,ownerSlug:s,columns:n={},emptyState:a,hasNextPage:o=!1,isFetching:c=!1,isFetchingNextPage:i=!1,onLoadMore:l=()=>{}}){return t.jsx(W,{items:re(e,n).map(r=>r.kind==="run"?{key:String(r.run.id),occurredAt:r.run.created_at,content:t.jsx(L,{run:r.run,ownerSlug:s,columns:n})}:{key:`group:${r.runs[0].id}`,occurredAt:r.runs[0].created_at,content:t.jsx(oe,{name:r.name,runs:r.runs,ownerSlug:s,columns:n})}),isLoading:!1,emptyState:a,hasNextPage:o,isFetching:c,isFetchingNextPage:i,onLoadMore:l})}export{L as R,Y as V,de as a};
|
|
2
|
-
//# sourceMappingURL=runs-list-CJJFRhTl.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{G as u,cr as l,j as t,bH as c,bT as m,cs as x}from"./index-C2TCKJDP.js";import{E as a}from"./entity-type-page-CouHZbc9.js";function T({slug:r,onClose:s}){const{orgContext:e}=u(),{data:i=[],isLoading:o,isError:y}=l(e);if(r===null)return t.jsx(a,{entityType:null,orgContext:e,onClose:s,compact:!0});if(o)return t.jsx(c,{label:"entity type",variant:"panel"});if(y)return t.jsx(m,{label:"entity type"});const n=i.find(p=>p.slug===r)??null;return n?t.jsx(a,{entityType:n,orgContext:e,hideDelete:x(n),onClose:s,compact:!0}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"Entity type not found."})}export{T as S};
|
|
2
|
-
//# sourceMappingURL=schema-type-editor-panel-C4e8pq1A.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as t,L as m,A as p,n as u,d5 as x,x as f,r as h,dI as v}from"./index-C2TCKJDP.js";import{e as j,f as c,c as g}from"./event-kind-options-fHAIXu24.js";import{o as N,a as y,F}from"./filter-editors-DQ5V4Cvh.js";import{T as E}from"./home-toolbar-CpCcHA6z.js";function b(o,{platforms:e}={}){const{isMember:i}=u(),n=i?o:null,{data:a=[]}=x(n),{data:r=[]}=f(n?{organizationId:n}:void 0);return h.useMemo(()=>g({connectors:a,entityTypes:r,selectedPlatforms:e}),[a,r,e])}function L({owner:o,organizationId:e,activitySearch:i,kinds:n,onKindsChange:a,platforms:r}){const l=n??[],s=l.length>0?{semantic_types:l.join(",")}:{};return t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a?t.jsx(O,{organizationId:e,kinds:l,onKindsChange:a,platforms:r}):t.jsx("span",{className:"flex-1"}),t.jsxs(m,{to:"/$owner/events",params:{owner:o},search:{...i,...s},className:"inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Open in Activity",t.jsx(p,{"aria-hidden":"true",className:"h-3.5 w-3.5"})]})]})}function O({organizationId:o,kinds:e,onKindsChange:i,platforms:n}){const a=b(o,{platforms:n}),r={key:"kind",label:"Event kind",icon:t.jsx(v,{className:"h-4 w-4"}),editor:N({searchPlaceholder:"Search event kinds...",emptyText:"No event kinds found",options:j(a,e).map(s=>({value:s,label:c(s)})),selected:e,multiple:!0,onSelect:s=>i(e.includes(s)?e.filter(d=>d!==s):[...e,s])})},l=e.length>0?[{id:"kind",label:"Kind",value:e.length<=2?e.map(c).join(", "):`${e.length} kinds`,title:e.map(c).join(", "),onRemove:()=>i([])}]:[];return t.jsxs(t.Fragment,{children:[t.jsx(y,{label:"Feed filters",menu:!1,fields:[r],chips:l,className:"flex-1"}),t.jsx(F,{fields:[r],triggerClassName:E})]})}export{L as S};
|
|
2
|
-
//# sourceMappingURL=scoped-feed-bar-CapleZvS.js.map
|