@lobu/runtime-server 24.9.0 → 24.10.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/automations.json +2 -2
- package/dist/catalogs/connectors.json +16 -4
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/postgres.ts +39 -24
- package/dist/connectors/whatsapp-web-adapter.js +41 -10
- package/dist/connectors/whatsapp-web-helpers.ts +12 -2
- package/dist/connectors/whatsapp_web.ts +18 -2
- package/dist/db/migrations/20261112210000_instance_identity.sql +18 -0
- package/dist/dependencies.bun.lock +62 -60
- package/dist/embeddings-server.mjs +38 -5
- package/dist/owletto/dist/assets/_-CYvj1y65.js +3 -0
- package/dist/owletto/dist/assets/_-CeLTSYYY.js +2 -0
- package/dist/owletto/dist/assets/_agentId-BB5E-L6T.js +2 -0
- package/dist/owletto/dist/assets/{_agentId-bna2tPsW.js → _agentId-DN0EwMAC.js} +2 -2
- package/dist/owletto/dist/assets/_automationId-DvUl9CSd.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-CVKfL9AG.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-Cv6FzK1v.js +2 -0
- package/dist/owletto/dist/assets/{_conversationId-zcs-S3dY.js → _conversationId-CPpNySjO.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-DZKicuq6.js +2 -0
- package/dist/owletto/dist/assets/_owner-Dauk3YuD.js +3 -0
- package/dist/owletto/dist/assets/_shape-cKrEID3T.js +2 -0
- package/dist/owletto/dist/assets/_slug-DJx_8fsV.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CPVzVKEf.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CW8gexOQ.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-Dwq1GAnG.js +2 -0
- package/dist/owletto/dist/assets/activity-route-location-C1jcXC7v.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-D78Wj0RH.js +2 -0
- package/dist/owletto/dist/assets/agent-connect-pages-DoI9UR0a.js +4 -0
- package/dist/owletto/dist/assets/{agent-editor-form-Bnc_q5WD.js → agent-editor-form-DlavYg2q.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-xteN-pyK.js → agent-loading-shells-DYqQphN7.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-C1L8IcYR.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-r0O0BVOu.js → agent-skill-context-D1nMrVod.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-C2KpYdu3.js → agent-subpage-shell-2w7vTeXw.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-Bv_chdPy.js → agent-thread-BopD-2k1.js} +3 -3
- package/dist/owletto/dist/assets/{app._appId-BUcNaSMS.js → app._appId-BXeFXW1w.js} +2 -2
- package/dist/owletto/dist/assets/{assist-composer-B1LykXpD.js → assist-composer-CL5x8pNt.js} +2 -2
- package/dist/owletto/dist/assets/automation-run-now-MtxUTfzd.js +2 -0
- package/dist/owletto/dist/assets/{callback-kSLa4n5s.js → callback-BgfwP1Eo.js} +2 -2
- package/dist/owletto/dist/assets/{card-C01y1O-W.js → card-DtLIFq7D.js} +2 -2
- package/dist/owletto/dist/assets/{claim-Dnux9Lqf.js → claim-CT3hYVMF.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-BBIq16tG.js → client-activity-scopes-BPbRX-Pe.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-DGh1O-Fu.js → client-rows-vrNA6FLs.js} +2 -2
- package/dist/owletto/dist/assets/clients-xnzZeEdZ.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-BdRMYojw.js → code-editor-mrKkAfcE.js} +2 -2
- package/dist/owletto/dist/assets/connect-NUCSay8X.js +2 -0
- package/dist/owletto/dist/assets/{connect-menu-D4w-JhJW.js → connect-menu-C6iVtuSo.js} +2 -2
- package/dist/owletto/dist/assets/connect._clientId-Cp-d9Q5b.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId-BsDzltNz.js → connected._clientId-ROfVgp9h.js} +2 -2
- package/dist/owletto/dist/assets/connection-BMz740Wi.js +2 -0
- package/dist/owletto/dist/assets/{connection-feed-detail-CJju0qiw.js → connection-feed-detail-0VAJiZTP.js} +2 -2
- package/dist/owletto/dist/assets/connector-page-shell-BFv21yuv.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-B2C2cjBg.js → connector-provenance-b59RfBtk.js} +2 -2
- package/dist/owletto/dist/assets/connectors-nYS31lO2.js +2 -0
- package/dist/owletto/dist/assets/consent-cPRF9JQv.js +2 -0
- package/dist/owletto/dist/assets/{copy-button-BhXeXLIm.js → copy-button-C3wMMv63.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-CJUp2aNZ.js → core.esm-C9QlSrgK.js} +3 -3
- package/dist/owletto/dist/assets/{create-DUlRsFNn.js → create-ASRN3Obq.js} +2 -2
- package/dist/owletto/dist/assets/create-CBcodaSO.js +2 -0
- package/dist/owletto/dist/assets/create-CGOWfMk4.js +2 -0
- package/dist/owletto/dist/assets/{create-automation-form-D141prEG.js → create-automation-form-CLicoPH5.js} +3 -3
- package/dist/owletto/dist/assets/create._connectorKey-s4xkktTC.js +2 -0
- package/dist/owletto/dist/assets/{custom-guardrail-edits-DuQ28xv3.js → custom-guardrail-edits-BUL7nmuO.js} +2 -2
- package/dist/owletto/dist/assets/{definition-comparison-BUDNuAN_.js → definition-comparison-4UYMI6BK.js} +2 -2
- package/dist/owletto/dist/assets/{detail-page-skeleton-BRHaq5Sj.js → detail-page-skeleton-C8v3rJXK.js} +2 -2
- package/dist/owletto/dist/assets/device-BBwsOi7q.js +2 -0
- package/dist/owletto/dist/assets/{device-pin-tombstone-BIM-ziCH.js → device-pin-tombstone-Bcpe7nAA.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-BnPqTgK1.js → device._deviceId-DLT4jh0Z.js} +2 -2
- package/dist/owletto/dist/assets/{dynamic-schema-form-OkIZImgp.js → dynamic-schema-form-BDT8x0Vg.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-CpeX7iiX.js → entity-options-B9hm9V87.js} +2 -2
- package/dist/owletto/dist/assets/entity-page-DZjzQ2V4.js +2 -0
- package/dist/owletto/dist/assets/entity-pages-BWBpttz3.js +2 -0
- package/dist/owletto/dist/assets/entity-schema-graph-lMMx3HhR.js +2 -0
- package/dist/owletto/dist/assets/{entity-type-page-MgZ7_0oh.js → entity-type-page-CkQm0yEu.js} +2 -2
- package/dist/owletto/dist/assets/{event-detail-D6AH6a2C.js → event-detail-CkzfakTK.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-DmRzikZW.js +2 -0
- package/dist/owletto/dist/assets/{filter-editors-DDTwyYt0.js → filter-editors-CQoSj-20.js} +3 -3
- package/dist/owletto/dist/assets/{full-page-spinner-DWo519BU.js → full-page-spinner-CYyCnKve.js} +2 -2
- package/dist/owletto/dist/assets/index-BE7eb2kE.js +2 -0
- package/dist/owletto/dist/assets/index-BFR0uiKY.js +2 -0
- package/dist/owletto/dist/assets/{index-Cd8jMsz8.js → index-BS5Ty3tf.js} +2 -2
- package/dist/owletto/dist/assets/index-C38OzBpB.js +2 -0
- package/dist/owletto/dist/assets/{index-D1UCJQl1.js → index-C3hz9tzx.js} +2 -2
- package/dist/owletto/dist/assets/index-CDyFQ32o.js +2 -0
- package/dist/owletto/dist/assets/{index-BW7IFKXC.js → index-CUndAH6o.js} +2 -2
- package/dist/owletto/dist/assets/index-CiKysEhV.js +2 -0
- package/dist/owletto/dist/assets/{index-CdDNNAx2.js → index-DByaMzsG.js} +274 -274
- package/dist/owletto/dist/assets/index-DfdinB7B.js +2 -0
- package/dist/owletto/dist/assets/index-DgMM4Zt5.css +1 -0
- package/dist/owletto/dist/assets/index-Xk711gVC.js +2 -0
- package/dist/owletto/dist/assets/{index-DmqnKGqW.js → index-ittfA0k8.js} +2 -2
- package/dist/owletto/dist/assets/{json-diff-C-WQqyIf.js → json-diff-mcDgyct_.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-0B1bTrAK.js → list-skeleton-DsYGUHxi.js} +2 -2
- package/dist/owletto/dist/assets/login-EoLq136v.js +2 -0
- package/dist/owletto/dist/assets/{logout-D474YsYQ.js → logout-gLgEQOiX.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-CH_0jHiM.js → member-scope-gate-vvkgSAb2.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-DvDtwrEI.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-XYmk7Iru.js → model-selector-D3vSMLO2.js} +2 -2
- package/dist/owletto/dist/assets/{needs-you-list-Bd4iiiqm.js → needs-you-list-B5Bgd05M.js} +2 -2
- package/dist/owletto/dist/assets/{new-CJ6TF3Vc.js → new-BPW3V0Y1.js} +2 -2
- package/dist/owletto/dist/assets/new-Bk_flKQO.js +2 -0
- package/dist/owletto/dist/assets/new-C5HtQdM_.js +2 -0
- package/dist/owletto/dist/assets/new-dLXsCHBd.js +2 -0
- package/dist/owletto/dist/assets/organization-DBfgBkzq.js +2 -0
- package/dist/owletto/dist/assets/{peek-pane-content-Cc8YX1oy.js → peek-pane-content-c2PG3TEX.js} +2 -2
- package/dist/owletto/dist/assets/{pending-seed-D7-ld7as.js → pending-seed-CBhx2Ql-.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-BWRJidwb.js → proposal-review-shell-B-jYcKfB.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-D8TijlRY.js +2 -0
- package/dist/owletto/dist/assets/record-activity-DnRVOrG2.js +2 -0
- package/dist/owletto/dist/assets/{record-session-ClKBr1_C.js → record-session-CAmGHMyM.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-DZ0w2k2r.js → renderer-olRv_HMI.js} +3 -3
- package/dist/owletto/dist/assets/reset-password-B9_xi8Pq.js +2 -0
- package/dist/owletto/dist/assets/{run-initiator-B8IRlRd-.js → run-initiator-DhE5v4z0.js} +2 -2
- package/dist/owletto/dist/assets/runs-C8sZQr4o.js +2 -0
- package/dist/owletto/dist/assets/{runs-list-8gUPWjP4.js → runs-list-CwtH-wmk.js} +2 -2
- package/dist/owletto/dist/assets/{schema-value-k19Ata7u.js → schema-value-zTJGE4eh.js} +3 -3
- package/dist/owletto/dist/assets/{scoped-feed-bar-L7h-Ca4u.js → scoped-feed-bar-BKyJSa3_.js} +2 -2
- package/dist/owletto/dist/assets/{settings-BZqntV3E.js → settings-z02cvVS3.js} +2 -2
- package/dist/owletto/dist/assets/source-record-panels-CGmKIJdN.js +2 -0
- package/dist/owletto/dist/assets/{status-variants-BR_iGWN5.js → status-variants-DyRCXBzM.js} +2 -2
- package/dist/owletto/dist/assets/subDays-D8nHthaS.js +2 -0
- package/dist/owletto/dist/assets/{table-C3DMoL4K.js → table-C637cQxG.js} +2 -2
- package/dist/owletto/dist/assets/use-automations-CgWNoYio.js +2 -0
- package/dist/owletto/dist/assets/use-login-redirect-tDdhXTpt.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-CtbixPEE.js → use-mention-search-D-kIKchD.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-CUCj9Df-.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-CvIIxdS_.js → views-access-required-C35Dyt91.js} +2 -2
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +2733 -1795
- package/npm-shrinkwrap.json +238 -221
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +6 -0
- package/vendor/connector-sdk/dist/index.d.ts +1 -0
- package/vendor/connector-sdk/dist/index.js +1 -0
- package/vendor/connector-sdk/dist/ip-reachability.d.ts +1 -1
- package/vendor/connector-sdk/dist/ip-reachability.js +1 -1
- package/vendor/connector-sdk/dist/logger.d.ts +1 -1
- package/vendor/connector-sdk/dist/logger.js +1 -1
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +3 -1
- package/vendor/connector-sdk/dist/retry.d.ts +1 -1
- package/vendor/connector-sdk/dist/retry.js +1 -1
- package/vendor/connector-sdk/dist/source-withheld-error.d.ts +16 -0
- package/vendor/connector-sdk/dist/source-withheld-error.js +19 -0
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/classify-error.d.ts +1 -1
- package/vendor/core/dist/classify-error.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +28 -3
- package/vendor/core/dist/contracts/tools/manage-automations.js +27 -8
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +8 -0
- package/vendor/core/dist/contracts/tools/manage-entity.js +11 -3
- package/vendor/core/dist/contracts/tools/save-memory.d.ts +11 -1
- package/vendor/core/dist/contracts/tools/save-memory.js +25 -3
- package/vendor/core/dist/contracts/tools/search-memory.js +1 -1
- package/vendor/core/dist/credentials.d.ts +12 -0
- package/vendor/core/dist/credentials.js +1 -0
- package/vendor/core/dist/errors.js +2 -2
- package/vendor/core/dist/worker/auth.d.ts +5 -0
- package/vendor/core/dist/worker/auth.js +15 -4
- package/vendor/core/package.json +1 -1
- package/vendor/postgres/cf/src/connection.js +7 -2
- package/vendor/postgres/cjs/src/connection.js +7 -2
- package/vendor/postgres/src/connection.js +7 -2
- package/vendor/views/dist/native.d.ts +33 -1
- package/vendor/views/dist/native.js +3 -0
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-B2C9B2RM.js +0 -2
- package/dist/owletto/dist/assets/_-CjyiGzwB.js +0 -3
- package/dist/owletto/dist/assets/_agentId-DKHXGvS2.js +0 -2
- package/dist/owletto/dist/assets/_automationId-CowRFD4E.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-dE6im18z.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-DqwSv8Zs.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BVOVizs4.js +0 -2
- package/dist/owletto/dist/assets/_owner-DsvIC94q.js +0 -3
- package/dist/owletto/dist/assets/_shape-CWjpzcvv.js +0 -2
- package/dist/owletto/dist/assets/_slug-DuCxYsJk.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-BqVeHB6Z.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DzyOCG5U.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-k1u3zBcn.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-jTBMW7a9.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-D3mVM_q4.js +0 -4
- package/dist/owletto/dist/assets/agent-permissions-matrix-C_ayr0pd.js +0 -2
- package/dist/owletto/dist/assets/automation-run-now-CjkJIkaZ.js +0 -2
- package/dist/owletto/dist/assets/clients-BCvjAJDT.js +0 -2
- package/dist/owletto/dist/assets/connect-DZeFSGIH.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-IZEMQJ64.js +0 -2
- package/dist/owletto/dist/assets/connection-C7glVpPE.js +0 -2
- package/dist/owletto/dist/assets/connector-page-shell-BeuyjiB2.js +0 -2
- package/dist/owletto/dist/assets/connectors-DSQ5AWPf.js +0 -2
- package/dist/owletto/dist/assets/consent-B6Aw_89N.js +0 -2
- package/dist/owletto/dist/assets/create-CWcza8NT.js +0 -2
- package/dist/owletto/dist/assets/create-bGOYifof.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-Ds4tpwHP.js +0 -2
- package/dist/owletto/dist/assets/device-D3fzoIrM.js +0 -2
- package/dist/owletto/dist/assets/entity-page-Cjc8oXA2.js +0 -2
- package/dist/owletto/dist/assets/entity-pages-18xSANrS.js +0 -2
- package/dist/owletto/dist/assets/entity-schema-graph-uwZ-P0t8.js +0 -2
- package/dist/owletto/dist/assets/events-feed-BI7wNRUY.js +0 -2
- package/dist/owletto/dist/assets/index-9tTjJo_J.css +0 -1
- package/dist/owletto/dist/assets/index-BYcFrinP.js +0 -2
- package/dist/owletto/dist/assets/index-BhJsTy-C.js +0 -2
- package/dist/owletto/dist/assets/index-CEcsgXDj.js +0 -2
- package/dist/owletto/dist/assets/index-CPscKk2u.js +0 -2
- package/dist/owletto/dist/assets/index-CfJ2-EpK.js +0 -2
- package/dist/owletto/dist/assets/index-D5DM4g2w.js +0 -2
- package/dist/owletto/dist/assets/index-DznAbTOF.js +0 -2
- package/dist/owletto/dist/assets/login-CH7P2AyR.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-Ba4aYavw.js +0 -74
- package/dist/owletto/dist/assets/new-BOsrRqp8.js +0 -2
- package/dist/owletto/dist/assets/new-DGPOjak2.js +0 -2
- package/dist/owletto/dist/assets/new-Q0XqiZq2.js +0 -2
- package/dist/owletto/dist/assets/organization-hD_Z6TSd.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-CRyAZATw.js +0 -2
- package/dist/owletto/dist/assets/record-activity-9ux6SfCd.js +0 -2
- package/dist/owletto/dist/assets/reset-password-D2RfrEVZ.js +0 -2
- package/dist/owletto/dist/assets/runs-CuC7WMtd.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-C4UItfdk.js +0 -2
- package/dist/owletto/dist/assets/subDays-hOwerOLo.js +0 -2
- package/dist/owletto/dist/assets/use-automations-CdtiVLCv.js +0 -2
- package/dist/owletto/dist/assets/use-login-redirect-CYlVkAhE.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-BdN8OU35.js +0 -2
- /package/vendor/postgres/{.bun-tag-c81dacd34e959a7a → .bun-tag-652f2580b8090d71} +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import{eI as Tt,c6 as Is,c7 as As,g2 as Ps,g3 as Fs,j as s,dy as Ds,cb as Vs,T as Ve,U as se,bT as Bs,B as R,bz as It,g4 as At,g5 as te,g6 as je,g7 as qs,g8 as Us,g9 as Qe,ga as Hs,gb as Ue,gc as He,gd as zs,ge as Gs,gf as Js,dA as Pt,dM as Ne,r as x,dc as Ws,ez as Ys,bR as Qs,eF as Ks,G as Ee,x as Ft,cD as Xs,g0 as Zs,c as ne,u as Dt,fg as en,c2 as tn,bd as Vt,db as Bt,fI as sn,f_ as nn,f0 as an,a2 as ze,i as ie,dP as qt,gg as rn,L as ke,e8 as on,d2 as ln,aF as Ut,aG as Ht,dj as zt,aI as Gt,aJ as cn,aK as dn,aL as un,aM as mn,aN as wt,aR as pn,cY as fn,aP as hn,cT as Jt,a4 as gn,gh as Wt,gi as Yt,ax as yn,gj as xn,M as Qt,z as bn,gk as vn,cl as K,w as Kt,gl as Be,cN as jn,gm as Nn,gn as Sn,dW as Et,go as qe,gp as Cn,gq as wn,da as En,cU as kn,cJ as _n,cK as $n,cj as Ge,dI as Rn,gr as Ln,gs as Je,gt as Mn,gu as On,gv as Tn,bp as In,gw as An,gx as Pn,gy as Fn,a as Dn,gz as Vn,gA as Bn,gB as qn,gC as Un,cS as Hn,ar as zn,aT as Gn}from"./index-CdDNNAx2.js";import{P as Jn}from"./public-shell-ready-CRyAZATw.js";import{D as Wn,c as Yn}from"./dynamic-schema-form-OkIZImgp.js";import{S as Qn,E as Xt,a as Kn,e as Xn,b as Zn,c as ea}from"./entity-pages-18xSANrS.js";import{b as ta,F as sa}from"./filter-editors-DDTwyYt0.js";import{l as na,H as aa,n as ra,G as Zt,c as oa}from"./entity-schema-graph-uwZ-P0t8.js";import{l as ia,p as _e,e as es,a as la,S as ca,J as da}from"./renderer-DZ0w2k2r.js";import{u as ua,a as ma,D as pa,P as fa,b as ts,c as ha,C as ga}from"./core.esm-CJUp2aNZ.js";import{v as ya,V as ss,M as ns,a as as,w as xa,b as ba}from"./view-param-filters-BdN8OU35.js";import{M as va}from"./member-scope-gate-CH_0jHiM.js";function ja({onClose:e,entityTypeSlug:t,orgContext:r,onSuccess:l}){const{data:n,isLoading:d}=Tt(t,r),i=`${r.organizationId??r.slug}:${t}`,a=Is(i,{name:"",customSlug:"",useCustomSlug:!1,metadata:{}},n?.metadata_schema),[u,o]=a.field("name"),[c,m]=a.field("customSlug"),[p,f]=a.field("useCustomSlug"),[y,N]=a.field("metadata"),[v,w]=As(i,null),b=Ps(),C=p?c:Fs(u),j=async L=>{if(L.preventDefault(),!a.canSubmit)return;if(w(null),!u.trim()){w("Name is required");return}const O=Yn(y),X={entityType:t,name:u.trim(),slug:p?c:void 0,metadata:Object.keys(O).length>0?O:void 0};try{const $=await b.mutateAsync(X);if(e(),$.approval_queued||!$.entity){It.info("Create queued for approval");return}typeof $.entity.id=="number"&&l?.($.entity.id)}catch($){w($ instanceof Error?$.message:"Failed to create entity")}},S=n?.name||t,g=a.revision,E=`Create ${S}`,k=`Add a new ${S.toLowerCase()} to your workspace.`;return d?s.jsx(Ds,{rows:6}):s.jsxs("form",{onSubmit:j,children:[s.jsx(Vs,{visible:a.hasConflict,onReload:a.reset}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:E}),s.jsx("p",{className:"text-sm text-muted-foreground",children:k})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsxs(Ve,{htmlFor:"name",children:["Name ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsx(se,{id:"name",value:u,onChange:L=>o(L.target.value),placeholder:`Enter ${S.toLowerCase()} name`,autoFocus:!0})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Ve,{htmlFor:"slug",children:"URL Slug"}),s.jsx("button",{type:"button",onClick:()=>f(!p),className:"text-xs text-muted-foreground hover:text-foreground",children:p?"Auto-generate":"Customize"})]}),p?s.jsx(se,{id:"slug",value:c,onChange:L=>m(L.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:"custom-slug"}):s.jsx("div",{className:"flex h-9 items-center rounded-md border border-input bg-muted px-3 text-sm text-muted-foreground",children:C||"slug-preview"})]}),g&&Object.keys(g).length>0?s.jsxs(s.Fragment,{children:[s.jsx(Qn,{className:"my-2"}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(Ve,{className:"text-sm font-medium",children:"Additional Fields"}),s.jsx(Wn,{schema:a.revision,values:y,onValuesChange:N,orgContext:r})]})]}):null,v&&s.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:v})]}),s.jsx(Bs,{onCancel:e,cancelDisabled:b.isPending,className:"mt-2",children:s.jsx(R,{type:"submit",disabled:!a.canSubmit||b.isPending||!u.trim(),children:b.isPending?"Creating...":`Create ${S}`})})]})}function Na(e){const t=e?.properties??{},r=zs(e);return Object.entries(t).flatMap(([l,n])=>{const d=r.find(m=>m.field===l);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(l)||!n||n.const!==void 0||n["x-table-column"]!==!0&&n["x-facet"]!==!0&&!d)return[];const i=[n,...Array.isArray(n.anyOf)?n.anyOf:[]],a=d?.options??Gs(n),u=a.find(m=>m.value!==null)?.value,o=i.find(m=>["string","number","integer","boolean"].includes(String(m.type)))??(u===void 0?void 0:{type:typeof u});if(!o)return[];const c=n.format==="date-time"||o.format==="date-time"?"datetime-local":n.format==="date"||o.format==="date"?"date":o.type==="number"||o.type==="integer"?"number":o.type==="boolean"?"boolean":"string";return[{field:l,label:String(n["x-table-label"]??n.title??l.replaceAll("_"," ")),type:c,options:c==="boolean"&&!a.some(m=>typeof m.value=="boolean")?[{value:!0,label:"Yes"},{value:!1,label:"No"},...a]:a}]})}const kt={eq:"is",neq:"is not",lt:"<",lte:"≤",gt:">",gte:"≥"};function Sa(e,t){return e.value===null&&e.op==="neq"?{op:kt.eq,value:"set"}:{op:kt[e.op],value:t?.options.find(r=>r.value===e.value)?.label??String(e.value)}}function Ca(e){const t=e?.[He];return t===void 0?{}:Qe(t)}function wa(e,t){return(e.presets??[]).filter(r=>!r.viewer||!!t?.email)}function Ea(e,t,r,l){try{const n=Ca(t),d=wa(n,l),i=e[At],a=i===void 0?void 0:d.find(p=>p.key===i);if(i!==void 0&&!a)throw new Error("This saved filter is unavailable. Choose another filter.");if(a&&!r&&typeof e.segment=="string"&&e.segment)throw new Error("A saved filter and an explicit selection cannot be combined.");const u=a&&e[te]===void 0?{collection:je(a,void 0,l)}:qs(e,r);if(u.error)throw u.error;const o=e[Us],c=o===void 0?a?.table??n.table??{}:Qe({table:typeof o=="string"?JSON.parse(o):o}).table??{},m=!!a&&(_t(u.collection)!==_t(je(a,void 0,l))||Se(c)!==Se(a.table??n.table??{}));return{...u,presentation:n,presets:d,preset:a,table:c,edited:m}}catch(n){return{collection:{},presentation:{},presets:[],table:{},edited:!1,error:n instanceof Error?n:new Error("Invalid collection configuration")}}}function _t(e){return JSON.stringify([e.search??"",e.segment??"",(e.filters??[]).map(Q)])}function Q(e){return JSON.stringify([e.field,e.op,e.value])}function Se(e){return JSON.stringify([e.columns??null,e.sort?.field??null,e.sort?.order??null])}function ka(e,t){return t?{[At]:t,[te]:Ue(e)[te]??"{}"}:Ue(e)}function _a(e,t,r,l,n=new Date,d){let i=t.filters??[],a=e.viewer;if(a){const o=d?.email?Q({field:a.field,op:"eq",value:d.email.toLowerCase()}):void 0;o&&i.some(c=>Q(c)===o)?i=i.filter(c=>Q(c)!==o):a=void 0}let u=e.relativeDate;if(u){const o=(je({...e,viewer:void 0,selection:{}},n).filters??[]).map(Q),c=i.map(Q);o.every(m=>c.includes(m))?i=i.filter(m=>!o.includes(Q(m))):u=void 0}return{key:e.key,label:e.label,selection:{...t.search?{search:t.search}:{},...i.length?{filters:i}:{},...t.segment?{segment:t.segment}:{}},...Se(r)!==Se(l.table??{})?{table:r}:{},...u?{relativeDate:u}:{},...a?{viewer:a}:{}}}function $a(e,t,r){const l=[...e.filters??[]],n=r??(t.length===1&&t[0].op==="eq"?l.findIndex(i=>i.field===t[0].field&&i.op==="eq"):-1),d=n>=0?[...l.slice(0,n),...t,...l.slice(n+1)]:[...l,...t];return{...e,filters:Js({filters:d}).filters}}function Ra(e,t){return{...e,filters:e.filters?.filter((r,l)=>l!==t)}}function La(e,t){return{...typeof e.$preset=="string"?e[te]===void 0?{$preset:e.$preset}:{$preset:e.$preset,[te]:String(Hs(e[te]))}:Ue(t),...e.$table===void 0?{}:{$table:typeof e.$table=="string"?e.$table:JSON.stringify(e.$table)}}}const Ma=[{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 Oa(e){return e.sort&&Ma.some(t=>t.field===e.sort?.field)?e.sort:{field:"created_at",order:"desc"}}function Ta(e,t,r,l,n){const d={...l,filters:l.filters?.filter(i=>i.field!==r)};return Pt({queryKey:["collection-facets",e,t,r,d],enabled:!!t&&!!r,staleTime:3e4,retry:!1,queryFn:async({signal:i})=>{const a=await Ne("query_sdk",{title:`Value counts query for ${r}`,script:`const input = ${JSON.stringify({field:r,collection:d})};
|
|
2
|
-
${t}`},e,{signal:i}),u=a.return_value;if(!a.success||typeof u?.connection!="string"||typeof u.sql!="string")throw new Error(a.error?.message??"Value distribution is unavailable");if(i.aborted)throw new DOMException("Aborted","AbortError");const o=await Ne("query_sql",{title:`Value counts for ${r}`,connection:u.connection,sql:u.sql,limit:51},e,{signal:i});if(o.error)throw new Error(o.error);if(!Array.isArray(o.rows))throw new Error("Source did not return value counts");const c=o.rows.map(m=>{const p=m,f=typeof p.count=="string"&&/^\d+$/.test(p.count)?Number(p.count):p.count;if(!(p.value===null||["string","number","boolean"].includes(typeof p.value))||typeof f!="number"||!Number.isSafeInteger(f)||f<0)throw new Error("Source returned an invalid value distribution");return{value:p.value,count:f}});return{values:c.slice(0,50),truncated:c.length>50||o.truncated===!0}}})}const Ia=300;function Aa({label:e,search:t,onSearch:r,className:l}){const n=t??"",[d,i]=x.useState(n),a=x.useRef({search:t,onSearch:r});a.current={search:t,onSearch:r};const u=x.useRef(void 0);x.useEffect(()=>{const c=()=>{clearTimeout(u.current),i(a.current.search??"")};return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[]);const o=x.useRef(n);return x.useEffect(()=>{n!==o.current&&(o.current=n,i(n))},[n]),x.useEffect(()=>{if(d===(a.current.search??""))return;const c=setTimeout(()=>{const m=a.current.onSearch;o.current=d,m(d||void 0,!0)},Ia);return u.current=c,()=>clearTimeout(c)},[d]),s.jsxs("div",{className:`relative${l?` ${l}`:""}`,children:[s.jsx(Ws,{"aria-hidden":"true",className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),s.jsx(se,{type:"search","aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}...`,maxLength:512,value:d,onChange:c=>i(c.target.value),className:"pl-9"})]})}function Pa({field:e,initial:t,org:r,facetQuery:l,collection:n,onApply:d,close:i}){const[a,u]=x.useState(t?.op??"eq"),[o,c]=x.useState(t?.value==null?"":String(t.value)),[m,p]=x.useState(""),[f,y]=x.useState(!1),[N,v]=x.useState(),w=e.type==="date"||e.type==="datetime-local"||e.type==="number"?e.type:"text",b=Ta(r,l,e.field,n),C=g=>{try{const E=f?[{field:e.field,op:"gte",value:e.type==="number"?Number(o):o},{field:e.field,op:"lte",value:e.type==="number"?Number(m):m}]:[{field:e.field,op:a,value:g}];if(e.type==="datetime-local")for(const O of E)typeof O.value=="string"&&(O.value=new Date(O.value).toISOString());if(E.some(O=>typeof O.value=="number"&&!Number.isFinite(O.value)))throw new Error("Enter a valid number.");const k=E[0].value,L=E[1]?.value;if(f&&k!=null&&L!=null&&k>L)throw new Error("The lower bound must be before the upper bound.");d(E),i()}catch(E){v(E instanceof Error?E.message:"Could not apply filter")}},j=[...e.options];for(const g of b.data?.values??[])j.some(E=>E.value===g.value)||j.push({value:g.value,label:g.value===null?"Not supplied":String(g.value)});const S=Math.max(1,...b.data?.values.map(g=>g.count)??[]);return s.jsxs("div",{className:"min-w-0 space-y-3 p-3",children:[s.jsxs("select",{"aria-label":"Filter operator",className:"h-8 w-full rounded-md border bg-background px-2 text-sm",value:f?"range":a,onChange:g=>{y(g.target.value==="range"),g.target.value!=="range"&&u(g.target.value)},children:[s.jsx("option",{value:"eq",children:"is"}),s.jsx("option",{value:"neq",children:"is not"}),(e.type==="number"||e.type==="date"||e.type==="datetime-local")&&s.jsxs(s.Fragment,{children:[s.jsx("option",{value:"lt",children:"less than / before"}),s.jsx("option",{value:"lte",children:"at most / on or before"}),s.jsx("option",{value:"gt",children:"greater than / after"}),s.jsx("option",{value:"gte",children:"at least / on or after"}),t?null:s.jsx("option",{value:"range",children:"between"})]})]}),e.type!=="boolean"&&s.jsxs("form",{className:"space-y-2",onSubmit:g=>{g.preventDefault(),C(e.type==="number"?Number(o):o)},children:[s.jsx(se,{required:!0,"aria-label":f?"From value":"Filter value",type:w,step:e.type==="number"?"any":void 0,value:o,onChange:g=>c(g.target.value),placeholder:"Enter a value…"}),f&&s.jsx(se,{required:!0,"aria-label":"To value",type:w,step:e.type==="number"?"any":void 0,value:m,onChange:g=>p(g.target.value)}),s.jsx(R,{size:"sm",type:"submit",className:"w-full",children:"Apply filter"})]}),!f&&(a==="eq"||a==="neq")&&s.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto",children:j.filter(g=>!o||g.label.toLowerCase().includes(o.toLowerCase())).map(g=>{const E=b.data?.values.find(k=>k.value===g.value)?.count;return s.jsxs("button",{type:"button","aria-label":g.label,onClick:()=>C(g.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:[E!==void 0&&s.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 bg-primary/10",style:{width:`${E/S*100}%`}}),s.jsx("span",{className:"relative truncate",children:g.label}),s.jsx("span",{className:"relative text-xs tabular-nums text-muted-foreground",children:E?.toLocaleString()})]},JSON.stringify(g.value))})}),l&&b.isFetching&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Loading distribution…"}),b.isError&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"Counts unavailable. You can still enter a value."}),b.data?.truncated&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Top 50 values. Enter any other value above."}),N&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:N})]})}function rs({collection:e,schema:t,label:r,onChange:l,org:n,facetQuery:d,segmentChip:i,viewFilters:a,onClearAll:u}){const o=Na(t),c=(y,N)=>({kind:"custom",className:"w-80",render:v=>s.jsx(Pa,{field:y,initial:N==null?void 0:e.filters?.[N],org:n,facetQuery:d,collection:e,onApply:w=>l($a(e,w,N)),close:v})}),m=o.map(y=>({key:y.field,label:y.label,icon:s.jsx(Ys,{className:"h-4 w-4"}),editor:c(y)})),p=new Map,f=(e.filters??[]).map((y,N)=>{const v=`${y.field}:${y.op}:${JSON.stringify(y.value)}`,w=p.get(v)??0;p.set(v,w+1);const b=o.find(C=>C.field===y.field);return{id:`${v}:${w}`,label:b?.label??y.field,...Sa(y,b),editor:b?c(b,N):void 0,onRemove:()=>l(Ra(e,N))}});if(i&&f.unshift(i),a?.fields.length){for(const y of m)y.group=r;m.push(...a.fields),f.push(...a.chips)}return!m.length&&!f.length?{fields:m,chips:f,clearAll:()=>{}}:{fields:m,chips:f,clearAll:u??(()=>l({...e,filters:[],segment:void 0}))}}function Fa(e){const{fields:t}=rs(e);return t.length?s.jsx(ta,{fields:t}):null}function Da(e){const{chips:t,clearAll:r}=rs(e);return t.length?s.jsx(sa,{label:`${e.label} filters`,fields:[],chips:t,onClearAll:r,className:"mb-4"}):null}const Ce=120,U=12;function $t(e,t){return typeof e.linkId=="number"&&typeof t.linkId=="number"?e.linkId-t.linkId:String(e.linkId).localeCompare(String(t.linkId))}function Va(e){const t=e.records.slice(0,Ce),r=o=>e.types.get(o)??{label:o},l=new Map;for(const o of t)l.set(String(o.id),{source:o.source,entityType:e.typeSlug,slug:o.slug,name:o.name,isFocus:!0,hasMoreLinks:!1});const n=new Map;for(const o of e.links){if(!l.has(String(o.recordId)))continue;const c=n.get(o.recordId)??new Map;c.set(o.linkId,o),n.set(o.recordId,c)}const d=new Map;for(const[o,c]of n){const m=[...c.values()].sort($t),p=l.get(String(o));p&&m.length>U&&(p.hasMoreLinks=!0);for(const f of m.slice(0,U)){d.set(f.linkId,f);const y=String(f.peer.id);l.has(y)||l.set(y,{source:f.peer.source,...f.peer.remote?{remote:f.peer.remote}:{},entityType:f.peer.type,slug:f.peer.slug,name:f.peer.name,isFocus:!1,hasMoreLinks:!1})}}const i=[];for(const[o,c]of l){const m=c.remote?{label:c.entityType}:r(c.entityType),p=c.name||c.slug,f=c.hasMoreLinks?`${m.label} · ${U}+ links`:m.label;i.push({id:o,data:{slug:c.slug,label:p,icon:m.icon,isSystem:!1,metaLabel:f},width:ra(p,f),height:aa})}const a=new Map;for(const o of[...d.values()].sort($t)){const c=String(o.fromId),m=String(o.toId),p=JSON.stringify([c,m]),f=a.get(p)??{source:c,target:m,rels:new Map,symmetric:!0};f.symmetric&&=o.isSymmetric,f.rels.has(o.relSlug)||f.rels.set(o.relSlug,{slug:o.relSlug,label:o.relName,ruleCount:1}),a.set(p,f)}const u=[...a.entries()].map(([o,c])=>({id:`link:${o}`,source:c.source,target:c.target,data:{relationships:[...c.rels.values()],isSymmetric:c.symmetric}}));return{nodes:i,edges:u,records:l,hasMoreRecords:e.hasMore===!0||e.records.length>Ce,listedCount:t.length,focusCount:t.length}}async function Ba(e,t){const r=Va(e);return{...await na({nodes:r.nodes,edges:r.edges},t),records:r.records,hasMoreRecords:r.hasMoreRecords,listedCount:r.listedCount,focusCount:r.focusCount}}const qa=8,Ua=3,Ha=4;function ve(e){return`source:${JSON.stringify([e.type,e.key])}`}function za(e,t){return t.map(r=>{const l={type:e,key:r.slug};return{...r,id:ve(l),source:l}})}function Rt(e){return JSON.stringify([e.relationship_type,e.direction,e.entity_type,e.key])}async function Ga(e,t,r){const l=e.slice(0,qa),n=[];let d=0;return await Promise.all(Array.from({length:Math.min(Ua,l.length)},async()=>{for(;d<l.length;){const i=d++,a=l[i];try{if(r?.aborted)throw r.reason;const u=await t(a),o=new Map(a.links.map(v=>[Rt(v),v]));for(const v of u.record_links){const w=Rt(v),b=o.get(w);(!b||b.occurred_at<v.occurred_at)&&o.set(w,v)}const c=new Map((a.relationships??[]).map(v=>[v.id,v]));for(const v of u.relationships??[])c.set(v.id,v);const m=[...c.values()].slice(0,U+1),p=[...o.values()].slice(0,U+1),f=(a.pagesRead??0)+1,y=!!u.next_cursor&&f>=Ha,N=u.record_failures.length>0||!!u.relationship_failures?.length||y;n[i]={read:{record:a.record,links:p,failed:N,entityId:a.entityId,relationships:m},...!y&&(N||u.next_cursor&&p.length+m.length<=U)?{next:{record:a.record,entityId:a.entityId,relationships:m,pagesRead:f,cursor:u.next_cursor??a.cursor,links:p}}:{}}}catch(u){if(r?.aborted)throw u;n[i]={read:{record:a.record,links:a.links,failed:!0,entityId:a.entityId,relationships:a.relationships},next:{...a,cursor:u instanceof Qs&&u.status===400?null:a.cursor}}}}})),{reads:n.map(i=>i.read),pending:[...n.flatMap(i=>i.next?[i.next]:[]),...e.slice(l.length)]}}function Ja(e,t){const r=new Map;for(const d of e)for(const i of d.reads)r.set(String(i.entityId??ve(i.record)),i);const l=new Map(t.map(d=>[d.slug,d])),n=[];for(const[d,i]of r){for(const a of i.relationships??[]){const u=(v,w,b)=>b?`remote:${b}`:typeof v=="number"?v:ve({type:w,key:v}),o=u(a.from_entity_id,a.from_entity_type,a.from_entity_url),c=u(a.to_entity_id,a.to_entity_type,a.to_entity_url),m=String(o)===d,p=m?c:o,f=m?a.to_entity_id:a.from_entity_id,y=m?a.to_entity_url:a.from_entity_url,N=(m?a.to_entity_type:a.from_entity_type)??"";n.push({recordId:d,linkId:a.id,fromId:o,toId:c,relSlug:a.relationship_type_slug,relName:a.relationship_type_name,isSymmetric:a.is_symmetric,peer:{id:p,name:(m?a.to_entity_name:a.from_entity_name)??String(f),slug:(m?a.to_entity_slug:a.from_entity_slug)??String(f),type:N,...y?{remote:{url:Ks(y)}}:typeof f=="string"?{source:{type:N,key:f}}:{}}})}for(const a of i.links){const u={type:a.entity_type,key:a.key},o=ve(u),c=l.get(a.relationship_type);let m=a.direction==="incoming"?o:d,p=a.direction==="incoming"?d:o;c?.is_symmetric&&m>p&&([m,p]=[p,m]),n.push({recordId:d,linkId:JSON.stringify([m,p,a.relationship_type]),fromId:m,toId:p,relSlug:a.relationship_type,relName:c?.name||a.relationship_type.replaceAll("_"," "),isSymmetric:c?.is_symmetric??!1,peer:{id:o,name:a.name||a.key,slug:a.key,type:a.entity_type,source:u}})}}return{links:n,checked:r.size,failed:[...r.values()].filter(d=>d.failed).length}}function Wa(e,t,r,l,n,d=!1){const{orgContext:i}=Ee(),a=Ft(i),u=Xs(i),o=x.useMemo(()=>d?za(t,r):r,[d,t,r]),c=x.useMemo(()=>o.slice(0,Ce).flatMap(j=>j.source?[{record:j.source,cursor:null,links:[]}]:typeof j.id=="number"?[{entityId:j.id,record:{type:t,key:j.slug},cursor:null,links:[]}]:[]),[o,t]),m=Zs({queryKey:["source-records-graph",i.organizationId,e,t,c.map(j=>[j.record,j.entityId])],enabled:!0,initialPageParam:c,queryFn:({pageParam:j,signal:S})=>Ga(j,async g=>{const E=await Ne("manage_entity",{action:"list_links",...g.entityId===void 0?{record:g.record,cursor:g.cursor}:{entity_id:g.entityId,offset:Number(g.cursor??0)},limit:U+1},e,{signal:S});return{...E,record_links:E.record_links??[],record_failures:E.record_failures??[],next_cursor:g.entityId===void 0?E.next_cursor:E.metadata?.has_more?String(Number(g.cursor??0)+U+1):null}},S),getNextPageParam:j=>j.pending.length?j.pending:void 0,staleTime:3e4,retry:!1}),p=x.useMemo(()=>m.data?Ja(m.data.pages,u.data??[]):void 0,[m.data,u.data]),f=p?.links,y=m.isError,N=JSON.stringify([i.organizationId,e,t,d,o.map(j=>[j.id,j.name,j.slug]),l]),v=x.useMemo(()=>new Map((a.data??[]).map(j=>[j.slug,{label:j.name||j.slug,icon:j.icon}])),[a.data]),[w,b]=x.useState(null);x.useEffect(()=>{if(!f)return;let j=!1;return Ba({typeSlug:t,records:o,hasMore:l,links:f,types:v},{targetAspect:n}).then(S=>{j||b({graph:S,key:N,isError:!1})}).catch(()=>{j||b({graph:null,key:N,isError:!0})}),()=>{j=!0}},[f,t,o,l,v,n,N]);const C=w?.key===N?w:null;return{graph:C?.graph??null,isLoading:!y&&!C,isError:y||C?.isError===!0,sourceProgress:{checked:p?.checked??0,total:Math.min(r.length,Ce),failed:p?.failed??0,hasMore:!!m.hasNextPage,isFetching:m.isFetching,loadMore:()=>{m.isFetching||m.fetchNextPage()}}}}function Ya(e){const t=new Map(e.nodes.map(n=>[n.id,n.data.label])),r=e.nodes.map(n=>({id:n.id,x:n.position.x+n.width/2,y:n.position.y+n.height/2,w:n.width,h:n.height,title:n.data.label,meta:n.data.metaLabel,icon:n.data.icon,muted:e.records.get(n.id)?.isFocus===!1})),l=e.edges.map(n=>{const{relationships:d,isSymmetric:i}=n.data,a=d.map(u=>u.label);return{id:n.id,source:n.source,target:n.target,route:n.route??null,summary:a.length===1?a[0]:`${a.length} relationships`,details:a,directed:!i,ariaLabel:`${t.get(n.source)??n.source} ${i?"and":"to"} ${t.get(n.target)??n.target}: ${a.join(", ")}`}});return{boxes:r,edges:l}}function Qa({ownerSlug:e,typeSlug:t,records:r,hasMore:l,sourceBacked:n=!1}){const d=ne(),i=Dt(),{orgContext:a}=Ee(),{data:u=[]}=Ft(a),o=u.find(S=>S.slug===t)?.name??t,[c,m]=x.useState(),p=x.useRef(null),f=x.useCallback(S=>{if(p.current?.disconnect(),p.current=null,!S||typeof ResizeObserver>"u")return;const g=()=>{if(!S.clientWidth||!S.clientHeight)return;const k=Math.round(S.clientHeight/S.clientWidth*10)/10;m(L=>L===k?L:k)};g();const E=new ResizeObserver(g);E.observe(S),p.current=E},[]),{graph:y,isLoading:N,isError:v,sourceProgress:w}=Wa(e,t,r,l,c,n),b=x.useMemo(()=>y?Ya(y):null,[y]),C=x.useCallback(S=>{const g=y?.records.get(S);if(g){if(g.remote){g.remote.url&&window.open(g.remote.url,"_blank","noopener,noreferrer");return}if(i){i.open(ia({...g.source?{record:g.source}:{entityId:Number(S)},ownerSlug:e,orgContext:a,name:g.name||g.slug}));return}d({to:en(e,[{entity_type:g.entityType,slug:g.slug}])})}},[y,e,a,i,d]);if(v)return s.jsx(tn,{label:`${o} graph`});if(N||!y||!b)return s.jsx(Zt,{label:`Loading ${o} graph`});const j=w?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"text-sm text-muted-foreground",role:"status",children:[s.jsxs("p",{children:["Checked ",w.checked," of ",w.total," records. Up to ",U," relationships per record."]}),w.failed>0?s.jsx("p",{role:"alert",children:"Some sources could not be read. These relationships are incomplete."}):null]}),w.hasMore?s.jsx(R,{variant:"outline",size:"sm",disabled:w.isFetching,onClick:w.loadMore,children:w.isFetching?"Loading…":w.failed>0?"Retry sources":"Load more relationships"}):null]}):null;return y.focusCount===0?s.jsxs("div",{className:"space-y-3",children:[j,s.jsx(Vt,{icon:Bt,title:`No ${o} records match`,description:"Change the search or filters to see records here."})]}):s.jsxs("div",{className:"flex flex-col gap-2",children:[j,s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",y.hasMoreRecords?"the first ":"",y.focusCount," ",o," record",y.focusCount===1?"":"s",". Click a record to see it."]}),s.jsx("div",{ref:f,className:"h-[70vh] min-h-[420px] min-w-0 overflow-hidden",children:s.jsx(oa,{boxes:b.boxes,edges:b.edges,label:`${o} records`,onOpenBox:C,openLabel:S=>`Show ${S.title}`})})]})}function Ka(e){return String(e??"").replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function os(e){return e["x-lobu"]?.role||e["x-lobu-role"]}function Ke(e){const t=e?.properties;if(!t)return null;const n=sn(t).find(([,o])=>os(o)==="workflowState");if(!n)return null;const[d,i]=n,a=i["x-lobu"]?.states,u=Array.isArray(a)&&a.length>0?a:(i.enum??[]).map(o=>({value:o}));return u.length===0||u.some(o=>typeof o.value!="string")?null:{field:d,states:u.map(o=>({...o,label:o.label||nn(i,o.value)||Ka(o.value),terminal:o.terminal??["done","complete","completed","closed","archived"].includes(o.value.toLowerCase())}))}}function Xa(e){const t=e?.properties;if(!t)return null;const r=Object.entries(t),l=r.find(([,i])=>os(i)==="sortRank"),n=r.find(([i])=>["rank","sort_rank","order"].includes(i)),d=l??n;return d?{field:d[0]}:null}function Za(e,{isDerived:t}){const r=e?.["x-lobu"]?.defaultView;return(r==="table"||r==="board")&&!(t&&r!=="table")?r:t?"table":Ke(e)?"board":"table"}const is={version:1,root:{type:"entity-table",props:{state:"{{tableState}}"}}},er={version:1,root:{type:"entity-board",props:{state:"{{boardState}}",onUpdate:"@updateEntity"}}};function tr(e){const{canShowBoard:t,builtinData:r,builtInLabels:l}=e,n=["table",...t?["board"]:[]],d={table:is,board:er};return n.map(i=>({id:i,label:l[i],builtInMode:i,template:d[i],data:r}))}function We(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function we(e,t){if(!t)return e.created_at??String(e.id);const r=_e(e.metadata);return String(r[t.field]??e.created_at??e.id)}function sr(e,t){const r=e?Number(e):Number.NaN,l=t?Number(t):Number.NaN;return Number.isFinite(r)&&Number.isFinite(l)&&r<l?String((r+l)/2):Number.isFinite(r)?String(r+1):Number.isFinite(l)?String(l-1):String(Date.now())}function Ye(e,t){const r=_e(e.metadata);return String(r[t]??"")}function ls(e,t){return[...e].sort((r,l)=>we(r,t).localeCompare(we(l,t)))}function nr(e,t,r,l,n){if(!t.startsWith("card:")||!r)return null;const d=Number(t.slice(5)),i=e.find(b=>b.id===d);if(!i)return null;const a=r.startsWith("column:")?r.slice(7):Ye(e.find(b=>`card:${b.id}`===r)??i,l.field);if(!a)return null;const u=ls(e.filter(b=>b.id!==d&&Ye(b,l.field)===a),n),o=r.startsWith("card:")?u.findIndex(b=>`card:${b.id}`===r):u.length,c=o>=0?o:u.length,m=c>0?u[c-1]:void 0,p=u[c],f=n?sr(m?we(m,n):void 0,p?we(p,n):void 0):void 0,y=_e(i.metadata),N={[l.field]:a,...n&&f?{[n.field]:f}:{}};l.states.find(b=>b.value===a)?.terminal&&!y.completed_at&&(N.completed_at=new Date().toISOString());const w={...y,...N};return{entityId:d,changedMetadata:N,nextMetadata:w}}function Lt(e,t,r){return e.map(l=>l.id===t?{...l,metadata:r}:l)}function ar({id:e,children:t,className:r}){const{setNodeRef:l,isOver:n}=ts({id:`column:${e}`});return s.jsx("div",{ref:l,className:ie("min-h-[220px] rounded-lg bg-card p-2 transition-colors",n?"bg-accent/50":"",r),children:t})}function rr({entity:e,owner:t,statusField:r,entityTypeIcon:l,schema:n,didDragRef:d}){const i=_e(e.metadata),{attributes:a,listeners:u,setNodeRef:o,transform:c,isDragging:m}=ha({id:`card:${e.id}`}),{setNodeRef:p,isOver:f}=ts({id:`card:${e.id}`}),y=qt(t,es(e)),N=v=>{d.current&&(v.preventDefault(),v.stopPropagation())};return s.jsx("div",{ref:v=>{o(v),p(v)},style:{transform:ga.Translate.toString(c)},className:ie(on,"p-3 text-sm text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",m?"opacity-60":"",f?"ring-1 ring-ring":""),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.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}`,...a,...u,children:s.jsx(rn,{className:"h-4 w-4"})}),s.jsx(Xt,{metadata:i,metadataSchema:n,name:e.name,typeIcon:l,className:"mt-0.5 h-6 w-6 shrink-0",initialsFallback:!0}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(ke,{to:y,className:"font-medium text-foreground hover:underline",onClick:N,children:e.name}),s.jsxs("div",{className:"mt-1 flex flex-wrap gap-1.5",children:[typeof i.priority=="string"&&i.priority?s.jsx(ze,{variant:"outline",className:"text-xs",children:We(i.priority)}):null,typeof i[r]=="string"&&i[r]?s.jsx(ze,{variant:"secondary",className:"text-xs",children:We(String(i[r]))}):null]})]})]})})}function or({owner:e,entities:t,totalCount:r,schema:l,entityTypeIcon:n,onUpdate:d}){const i=x.useMemo(()=>Ke(l),[l]),a=x.useMemo(()=>Xa(l),[l]),[u,o]=x.useState(t),[c,m]=x.useState(()=>new Set),p=x.useRef(!1),f=ua(ma(fa,{activationConstraint:{distance:6}})),y=x.useCallback(()=>{window.setTimeout(()=>{p.current=!1},0)},[]);x.useEffect(()=>{o(t)},[t]);const N=x.useMemo(()=>{if(!i)return new Map;const C=new Map(i.states.map(j=>[j.value,[]]));for(const j of u){const S=Ye(j,i.field),g=C.has(S)?S:i.states[0]?.value;g&&C.get(g)?.push(j)}for(const[j,S]of C)C.set(j,ls(S,a));return C},[u,a,i]);if(!i)return null;const v=C=>{m(j=>{const S=new Set(j);return S.has(C)?S.delete(C):S.add(C),S})},w=()=>{p.current=!0},b=C=>{const j=String(C.active.id),S=C.over?String(C.over.id):null,g=nr(u,j,S,i,a);if(!g){y();return}const{entityId:E,changedMetadata:k,nextMetadata:L}=g,X=u.find($=>$.id===E)?.metadata;o($=>Lt($,E,L)),d(E,k).catch(()=>{o($=>Lt($,E,X))}),y()};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-base font-semibold",children:"Board"}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Grouped by ",We(i.field),typeof r=="number"&&r>u.length?s.jsxs(s.Fragment,{children:[" · ",s.jsxs("span",{className:"text-amber-600 dark:text-amber-500",children:["showing first ",u.length," of ",r," — narrow with search"]})]}):null]})]}),s.jsx(pa,{sensors:f,onDragStart:w,onDragEnd:b,children:s.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:i.states.map(C=>{const j=N.get(C.value)??[],S=C.collapsed??C.terminal,g=S&&!c.has(C.value);return s.jsxs(ar,{id:C.value,children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 px-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[C.terminal?s.jsx(an,{className:"h-4 w-4 text-muted-foreground"}):null,s.jsx("h3",{className:"text-sm font-medium",children:C.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(ze,{variant:"secondary",className:"text-xs",children:j.length}),S?s.jsx(R,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>v(C.value),children:g?"Show":"Hide"}):null]})]}),g?s.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:[j.length," hidden ",C.label?.toLowerCase()," item",j.length===1?"":"s"]}):s.jsx("div",{className:"space-y-2",children:j.length>0?j.map(E=>s.jsx(rr,{entity:E,owner:e,statusField:i.field,entityTypeIcon:n,schema:l,didDragRef:p},E.id)):s.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground/60",children:["No ",C.label?.toLowerCase()," items"]})})]},C.value)})})})]})}const ir=x.memo(or);function lr(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t.toString(36)}function cs(e,t){return{queryKey:["metric_series",e,lr(t)],queryFn:()=>Ne("metric_series",{sql:t},{slug:e}),staleTime:6e4}}function ds(e,t){const r=!!e&&!!t,l=cs(e??"",t??"");return Pt({...l,enabled:r})}ds.queryOptions=(e,t)=>cs(e,t);function cr(e,t){if(!e?.columns?.length||!e.rows)return[];const r=e.columns.indexOf(t);return r<0?[]:e.rows.map(l=>Number(l[r])||0)}const Mt=/^[a-z][a-z0-9_]*$/;function dr(e){const t=Object.entries(e);for(const[n,d]of t){if(!Mt.test(n))throw new Error(`lifecycleCumulativeStatsSql: unsafe column name '${n}'`);if(!Mt.test(d))throw new Error(`lifecycleCumulativeStatsSql: unsafe entity_type '${d}'`)}const r=t.flatMap(([n,d])=>[`COUNT(*) FILTER (
|
|
3
|
-
WHERE semantic_type = 'change'
|
|
4
|
-
AND metadata->>'category' = 'lifecycle'
|
|
5
|
-
AND metadata->>'entity_type' = '${d}'
|
|
6
|
-
AND metadata->>'op' = 'created'
|
|
7
|
-
) AS ${n}_added`,`COUNT(*) FILTER (
|
|
8
|
-
WHERE semantic_type = 'change'
|
|
9
|
-
AND metadata->>'category' = 'lifecycle'
|
|
10
|
-
AND metadata->>'entity_type' = '${d}'
|
|
11
|
-
AND metadata->>'op' = 'deleted'
|
|
12
|
-
) AS ${n}_removed`]).join(`,
|
|
13
|
-
`),l=t.map(([n])=>` SUM(COALESCE(b.${n}_added, 0) - COALESCE(b.${n}_removed, 0))
|
|
14
|
-
OVER (ORDER BY d.bucket) AS ${n}`).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
|
-
${r}
|
|
27
|
-
FROM events
|
|
28
|
-
WHERE created_at > now() - interval '14 days'
|
|
29
|
-
GROUP BY 1
|
|
30
|
-
)
|
|
31
|
-
SELECT d.bucket,
|
|
32
|
-
${l}
|
|
33
|
-
FROM days d
|
|
34
|
-
LEFT JOIN buckets b ON b.bucket = d.bucket
|
|
35
|
-
ORDER BY d.bucket
|
|
36
|
-
`}const ur={"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 mr(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(([r,l])=>[r,String(l)]));if(Object.keys(t).length>0)try{return dr(t)}catch{return null}}return typeof e.preset=="string"?ur[e.preset]??null:null}function pr({owner:e,sql:t,lifecycle:r,preset:l,column:n,chart:d,height:i,width:a,color:u,label:o,className:c}){const m=x.useMemo(()=>mr({sql:t,lifecycle:r,preset:l}),[t,r,l]),p=typeof e=="string"&&e?e:null,{data:f}=ds(p,m),y=String(n??""),N=x.useMemo(()=>cr(f,y),[f,y]),v=x.useMemo(()=>!f?.columns?.length||!f.rows?[]:f.rows.map((b,C)=>({label:String(b[0]??"").slice(0,10),value:N[C]??0})),[f,N]);if(!p||!m||!y)return null;const w=d==="line"?s.jsx(la,{data:v,height:typeof i=="number"?i:void 0}):s.jsx(ca,{data:N,height:typeof i=="number"?i:void 0,width:typeof a=="number"?a:void 0,color:typeof u=="string"?u:void 0});return o==null?s.jsx("div",{className:c,children:w}):s.jsxs("div",{className:c,children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:String(o)}),w]})}function fr({metadata:e,metadataSchema:t,name:r,typeIcon:l,initialsFallback:n,className:d}){return s.jsx(Xt,{metadata:e,metadataSchema:t,name:String(r??""),typeIcon:l,initialsFallback:!!n,className:d})}function hr({entity:e,owner:t,className:r,onClick:l,children:n}){const d=e;if(!d)return s.jsx(s.Fragment,{children:n});const i=qt(String(t??""),es(d));return s.jsx(ke,{to:i,className:r,onClick:l,children:n})}function gr({state:e}){return e?s.jsx(Kn,{...e}):null}function yr({state:e,onUpdate:t}){return e?s.jsx(ir,{...e,onUpdate:t}):null}const xr={"entity-avatar":fr,"entity-link":hr,"entity-table":gr,"entity-board":yr,"metric-series":pr};function br({ownerSlug:e,typeSlug:t,title:r,shape:l}){const[n,d]=x.useState(!1),i=ne(),{visible:a,system:u,isTypesLoading:o}=ln(e),c=p=>{d(!1);const f=`/${e}/${Wt(p)}`;i({to:l?`${f}/${Yt}/${l}`:f})},m=p=>s.jsxs(hn,{value:`${p.name} ${p.slug}`,onSelect:()=>c(p.slug),children:[s.jsx(Jt,{icon:p.icon,className:"mr-2 h-4 w-4 shrink-0"}),s.jsx("span",{className:"flex-1 truncate",children:p.name||p.slug}),p.slug===t?s.jsx(gn,{className:"ml-2 h-3.5 w-3.5 shrink-0","aria-label":"Current"}):null,p.entity_count!=null?s.jsx("span",{className:"ml-2 shrink-0 text-xs tabular-nums text-muted-foreground",children:p.entity_count.toLocaleString()}):null]},p.slug);return s.jsxs(Ut,{open:n,onOpenChange:d,children:[s.jsx("h1",{className:"flex min-w-0 items-center text-lg font-semibold tracking-tight @sm:text-2xl",children:s.jsx(Ht,{asChild:!0,children:s.jsxs(R,{type:"button",variant:"ghost",title:r,className:"-ml-2 h-auto min-w-0 gap-1 px-2 py-1 text-lg font-semibold tracking-tight @sm:gap-1.5 @sm:text-2xl",children:[s.jsx("span",{className:"truncate",children:r}),s.jsx(zt,{className:"h-5 w-5 shrink-0 text-muted-foreground"})]})})}),s.jsx(Gt,{align:"start",className:"w-72 p-0",children:s.jsxs(cn,{children:[s.jsx(dn,{autoFocus:!0,placeholder:"Find a type…"}),s.jsxs(un,{children:[s.jsx(mn,{children:o?"Loading types…":"No type matches."}),a.length>0?s.jsx(wt,{heading:"Types",children:a.map(m)}):null,u.length>0?s.jsx(wt,{heading:"System",children:u.map(m)}):null]}),s.jsx(pn,{}),s.jsxs(ke,{to:"/$owner",params:{owner:e},search:{layout:"graph"},onClick:()=>d(!1),className:"flex items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(fn,{className:"h-4 w-4"}),"Data map"]})]})})]})}function vr(e){return Object.entries(e?.metrics_config?.segments??{}).filter(([,t])=>t.on==="entity").map(([t,r])=>({name:t,description:r.description}))}const be={table:{label:"Table",icon:En},board:{label:"Board",icon:wn},graph:{label:"Graph",icon:Bt}},us=(e,t)=>`lobu.record-shape:v1:${e}/${t}`,jr=new Set(["table","board","graph"]);function Nr(e,t){const r=_n(us(e,t));return r&&jr.has(r)?r:void 0}function Sr(e,t,r){$n(us(e,t),r)}const Ot=":records";function Cr({ownerSlug:e,entityTypeSlug:t,create:r,onCreateChange:l,viewKey:n,shape:d}){const{orgContext:i,hasOrgContext:a}=Ee(),u=Tt(t,i),{data:o,isLoading:c,error:m}=u;yn(`/${e}`,i);const p=xn(),[f,y]=x.useState({key:"",page:0}),N=Qt({strict:!1}),v=ne(),w=Dt(),b=`/${e}/${Wt(t)}`,{session:C,isReady:j}=bn(),S=j&&!c&&o?.slug===t,g=C?.user?.email,E=x.useMemo(()=>g?{email:g}:void 0,[g]),{collection:k,error:L,presentation:O,presets:X,preset:$,edited:le,table:I}=x.useMemo(()=>Ea(N,o?.metadata_schema,!!n,E),[N,o?.metadata_schema,n,E]),z=S?L:void 0,G=x.useMemo(()=>La(N,k),[N,k]),[ms,Xe]=x.useState(!1),[$e,ps]=x.useState(0),Re=k.search??"",Z=k.segment,fs=JSON.stringify(k),ae=Z?vr(o).find(h=>h.name===Z)??{name:Z,description:""}:null,hs=h=>void v({to:".",search:_=>({...Ge(_,K(h)),...G}),replace:!0}),J=vn(u.data),Ze=J?I.sort:Oa(I),Le=Ze?.field,et=Ze?.order,W=x.useMemo(()=>Le?[{id:Le,desc:et==="desc"}]:[],[Le,et]),ce=x.useCallback(h=>void v({to:".",search:{...n?K(N):{},...G,$table:JSON.stringify(h)},replace:!0}),[v,n,N,G]),tt=x.useCallback(h=>{const _=typeof h=="function"?h(W):h;_[0]&&ce({...I,sort:{field:_[0].id,order:_[0].desc?"desc":"asc"}})},[W,ce,I]),de=r===!0,st=()=>l(!0),gs=()=>l(!1),ys=W[0]?.id,xs=W[0]?W[0].desc?"desc":"asc":void 0,Me=u.data?.metadata_schema,ue=!!Ke(Me)&&!J,bs=Za(Me,{isDerived:J}),P=Kt(i),vs=Be(P.data??[],t,k),re=(h,_=!1,A=K(N))=>{const T=!n||!P.data||Be(P.data,t,h).some(ye=>ye.key===n);v({to:T?".":b,search:{...T&&n?A:{},...ka(h,$?.key),$table:JSON.stringify(I)},replace:_})},me=h=>{const _=h?je(h,void 0,E):{},A=!n||Be(P.data??[],t,_).some(T=>T.key===n);Xe(!1),ps(T=>T+1),v({to:A?".":b,search:h?{$preset:h.key}:{}})},{isAdmin:js}=jn(i.organizationId),Oe=Nn(i),Ns=js&&!!o&&!u.isPlaceholderData,nt=x.useRef(N);nt.current=N;const Ss=async()=>{if(!$)return;const h=JSON.stringify(N),{data:_}=await u.refetch(),A=_?.metadata_schema,T=A?Qe(A[He]??{}):void 0,ye=T?.presets?.find(xe=>xe.key===$.key);if(!_||!A||!T||!ye){It.error("This saved filter changed. Reload and try again.");return}const De=_a(ye,k,I,T,void 0,E);await Oe.mutateAsync({slug:_.slug,metadata_schema:{...A,[He]:{...T,presets:T.presets?.map(xe=>xe.key===De.key?De:xe)}}}).then(()=>!0,()=>!1)&&(await u.refetch(),JSON.stringify(nt.current)===h&&me(De))},Cs=x.useMemo(()=>Nr(e,t),[e,t]),D=Sn(P.data??[],t,{viewKey:n,shape:d??(n?void 0:Cs)},bs,k),V=D.kind==="builtin"?D.mode==="board"&&!ue?"table":D.mode:null,at=V==="graph";x.useEffect(()=>{d&&S&&V&&Sr(e,t,V)},[d,S,V,e,t]);const rt=["table",...ue?["board"]:[],"graph"],Y=D.kind==="view"?D.view:null,ot=D.kind==="missing"?D.key:null,Te=D.kind==="inapplicable"?D:null,oe=V==="table"?50:200,pe=`${t}?${fs}&sort=${JSON.stringify(I.sort)}&size=${oe}`,fe=f.key===pe?f.page:0,Ie=x.useCallback(h=>y(_=>({key:pe,page:h(_.key===pe?_.page:0)})),[pe]),he=Et(t,i,{limit:oe,offset:fe*oe,search:Re.trim()||void 0,sortBy:ys,sortOrder:xs,segment:Z,filters:k.filters,enabled:S&&!n&&!z}),it=Et(t,i,{limit:1,offset:0,parentId:null,search:Re.trim()||void 0,segment:Z,filters:k.filters,enabled:S&&!n&&!z&&!J}),{data:ge,error:ws}=he,Es=he.isLoading||he.isPending&&he.fetchStatus==="paused",lt=z||m||(n?null:ws),ks=!!n&&P.data===void 0&&P.isError,B=ge?.entities??[],Ae=ge?.metadata?.has_more??!1,F=ge?.metadata?.total_count??0,ct=B.length>0||Re.trim().length>0||fe>0||!!Z||!!k.filters?.length,M=o?.name?.trim()||qe(t),ee=o?.icon||void 0,q=J,H=Me,_s=!z&&(!a||!S||(n?P.data===void 0&&!P.isError:Es||!J&&it.isLoading)),dt=ge?.linked_entities??{},ut=it.data?.metadata?.total_count,mt=F>0&&typeof ut=="number"?ut<F:!1,pt=x.useMemo(()=>o?.measure_columns??[],[o?.measure_columns]),ft=x.useCallback(h=>ce({...I,columns:h}),[ce,I]),ht=x.useMemo(()=>({entities:B,owner:e,schema:H,entityTypeIcon:ee,isDerived:q,measureColumns:pt,linkedEntityLookups:dt,hasAnyParents:mt,sorting:W,onSortingChange:tt,visibleColumns:I.columns,columnChoices:Xn(H,q,B),onVisibleColumnsChange:ft,page:fe,pageSize:oe,totalCount:F,hasMore:Ae,pageTitle:M,onPrevPage:()=>Ie(h=>Math.max(0,h-1)),onNextPage:()=>Ie(h=>h+1)}),[B,e,H,ee,q,pt,dt,mt,W,I.columns,ft,tt,Ie,fe,oe,F,Ae,M]),gt=F>B.length,yt=`showing first ${B.length} of ${F} — narrow with search`,xt=x.useMemo(()=>({owner:e,entityType:o,entities:B,totalCount:F,schema:H,entityTypeIcon:ee}),[e,o,B,F,H,ee]),Pe=x.useMemo(()=>({tableState:ht,boardState:xt,owner:e,schema:H,entityType:o,entityTypeIcon:ee,totalCount:F,isTruncated:gt,truncationNotice:yt,canCreate:!q,addLabel:`Add ${o?.name||qe(t)}`}),[ht,xt,e,H,o,ee,F,gt,yt,q,t]),$s=x.useMemo(()=>tr({canShowBoard:ue,builtinData:Pe,builtInLabels:{table:be.table.label,board:be.board.label}}),[ue,Pe]),bt=V?$s.find(h=>h.id===V)??null:null,Rs=bt?.template??is,Ls=bt?.data??Pe,vt=h=>void v({to:h===Ot?b:`${b}${Je(h)}`,search:G}),Fe=K(N),Ms=ya(Y?.params,Fe,h=>void v({to:".",search:{...K(h),...G}})),Os=()=>re({...k,filters:[],segment:void 0},!1,xa(Y?.params,Fe)),jt={collection:k,schema:H,label:M,org:i??"",facetQuery:O.facetQuery,onChange:re,viewFilters:Ms,onClearAll:Os,segmentChip:ae?{id:"segment",label:"Segment",op:"is",value:qe(ae.name),title:ae.description||void 0,editor:ae.description?{kind:"custom",render:()=>s.jsx("p",{className:"p-3 text-sm text-muted-foreground",children:ae.description})}:void 0,onRemove:()=>re({...k,segment:void 0})}:void 0},Nt=`Moved on ${o?.name||o?.slug||t} board`,St=x.useMemo(()=>(h,_)=>p.mutateAsync({entityId:h,metadata:_,field_note:Nt}),[p,Nt]),Ts=x.useMemo(()=>({updateEntity:St,openCreate:()=>l(!0)}),[St,l]),Ct=h=>w?s.jsx("span",{className:h,children:s.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":"Edit type",title:"Edit type",onClick:()=>w.open({href:Ln(e,t),title:M}),children:s.jsx(Rn,{className:"h-4 w-4"})})}):null;return s.jsx(Zn,{title:s.jsx(br,{ownerSlug:e,typeSlug:t,title:M,shape:n?null:V}),actions:Ct("hidden @sm:contents"),controls:s.jsxs(s.Fragment,{children:[de?s.jsx("div",{className:"max-w-3xl",children:s.jsx(ja,{onClose:gs,entityTypeSlug:t,orgContext:i})}):null,!de&&S&&s.jsxs("nav",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2","aria-label":`${M} views`,children:[Ct("-mr-1 @sm:hidden"),!n&&rt.length>1&&s.jsx("fieldset",{className:"flex items-center rounded-md border p-0.5","aria-label":"Record layout",children:rt.map(h=>{const _=be[h].icon,A=V===h;return s.jsx(R,{type:"button",variant:"ghost",size:"sm","aria-pressed":A,title:be[h].label,"data-testid":`shape-${h}`,className:ie("h-7 px-2",A&&"bg-accent text-accent-foreground"),onClick:()=>void v({to:`${b}/${Yt}/${h}`,search:G,replace:!0}),children:s.jsx(_,{className:"h-4 w-4"})},h)})}),n&&s.jsx(R,{variant:"ghost",onClick:()=>vt(Ot),children:"Records"}),!!X.length&&s.jsxs(Ut,{open:ms,onOpenChange:Xe,children:[s.jsx(Ht,{asChild:!0,children:s.jsxs(R,{variant:"outline",className:ie("gap-2",le&&"border-dashed border-primary"),"data-edited":le||void 0,title:"Choose saved filter",children:[$?.label??(k.filters?.length||k.search?"Custom filter":"All records"),le?s.jsx("span",{className:"text-xs font-normal text-primary",children:"Edited"}):null,s.jsx(zt,{className:"h-4 w-4 text-muted-foreground"})]})}),s.jsxs(Gt,{align:"start",className:"w-60 p-1",children:[s.jsx(R,{variant:$?"ghost":"secondary",className:"w-full justify-start",onClick:()=>me(),children:"All records"}),X.map(h=>s.jsx(R,{variant:$?.key===h.key?"secondary":"ghost",className:"w-full justify-start",onClick:()=>me(h),children:h.label},h.key))]})]}),$&&le?s.jsxs("div",{className:"-ml-2 mr-2 inline-flex items-center gap-1",children:[s.jsx(R,{variant:"ghost",size:"sm",onClick:()=>me($),children:"Reset"}),Ns?s.jsx(R,{size:"sm",disabled:Oe.isPending,onClick:()=>void Ss(),children:Oe.isPending?"Saving…":"Save"}):null]}):null,vs.map(h=>s.jsx(R,{"data-testid":`tab-${h.key}`,variant:n===h.key?"secondary":"ghost","aria-pressed":n===h.key,onClick:()=>vt(h.key),children:h.name},h.key)),!z&&s.jsx(Fa,{...jt},`filters:${t}:${$e}`),s.jsxs("div",{className:"ml-auto flex flex-wrap items-center justify-end gap-x-3 gap-y-2",children:[s.jsx(Aa,{label:M,search:k.search,onSearch:(h,_)=>re({...k,search:h},_),className:"w-64 max-w-full"},`search:${t}:${$e}`),!q&&!n?s.jsxs(R,{size:"sm","aria-label":`Add ${M||"entity"}`,onClick:()=>st(),children:[s.jsx(kn,{className:"mr-2 h-4 w-4"}),"Add"]}):null]})]}),!de&&S&&!z?s.jsx(Da,{...jt},`applied:${t}:${$e}`):null]}),children:de?null:_s?at?s.jsx(Zt,{label:`Loading ${M} graph`}):s.jsx(ea,{}):lt?s.jsxs("div",{role:"alert",className:"rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-6 text-sm text-destructive",children:[lt.message||`Failed to load ${M.toLowerCase()}.`,z&&s.jsx(R,{variant:"outline",size:"sm",className:"ml-3",onClick:()=>re({}),children:"Clear filters"})]}):ks?s.jsx(ss,{onRetry:()=>void P.refetch()}):Te?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center","data-testid":"inapplicable-view",children:[s.jsxs("h2",{className:"text-lg font-semibold",children:["“",Te.view.name,"” doesn’t apply to the current filters"]}),s.jsxs("p",{className:"text-muted-foreground mt-2 text-sm",children:["It appears when the selection includes"," ",Object.entries(Te.when).map(([h,_])=>`${h} is ${_===null?"not supplied":String(_)}`).join(" and "),"."]}),s.jsx(ke,{to:b,search:G,className:"mt-4 text-sm font-medium underline underline-offset-4",children:`Back to ${M}`})]}):ot?s.jsx(ns,{viewKey:ot,backTo:b,backLabel:`Back to ${M}`}):Y?s.jsx(as,{orgSlug:e,viewKey:Y.key,scope:{type:t,collection:k},params:Fe,onParamsChange:hs,paramDecls:Y.params,contentHash:Y.content_hash,title:Y.name,minHeight:320}):at&&ct?s.jsx(Qa,{ownerSlug:e,typeSlug:t,sourceBacked:J,records:B.map(h=>({...h,id:h.id??JSON.stringify([h.entity_type,h.slug])})),hasMore:Ae}):ct?s.jsx(da,{template:Rs,data:Ls,actions:Ts,components:xr}):s.jsx(Vt,{icon:Cn,iconElement:s.jsx(Jt,{icon:o?.icon,className:"mb-4 h-12 w-12 opacity-50"}),title:`No ${M.toLowerCase()} yet`,description:q?"This view has no rows yet. They appear as the underlying data arrives.":`Get started by creating your first ${o?.name?.toLowerCase()||"entity"}.`,actionLabel:q?void 0:`Add ${o?.name||"Entity"}`,onAction:q?void 0:()=>st()})})}function wr(e,t){return ie("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")}const Er=12,kr=50;function _r({navigation:e,views:t,currentKey:r}){const l=ne(),[n,d]=x.useState(""),i=x.useMemo(()=>e.filter(c=>!c.external&&c.href.includes("/-/views/")),[e]),a=Mn(i,t,n,n.trim()?kr:Er),u=On(i,t,n),o=c=>{c.key==="Enter"&&a[0]&&(c.preventDefault(),l({href:a[0].href}))};return s.jsxs("nav",{"aria-label":"Workspace views",className:"flex shrink-0 flex-col gap-2",children:[s.jsx(se,{type:"search","aria-label":"Find a view",placeholder:"Find a view",value:n,onChange:c=>d(c.target.value),onKeyDown:o,className:"h-8 max-w-sm"}),a.length>0?s.jsx("ul",{className:"flex flex-wrap items-center gap-1",children:a.map(c=>{const m=c.key===r;return s.jsx("li",{children:s.jsxs(Tn,{item:{id:c.key,label:c.label,href:c.href,children:[]},active:m,className:wr(m,"min-h-8 max-w-full gap-2 px-3 text-sm break-words"),children:[s.jsx("span",{children:c.label}),c.trail.length>0&&c.trail[0]!=="Views"?s.jsx("span",{className:"ml-1.5 text-xs text-muted-foreground",children:c.trail.join(" › ")}):null]})},c.key)})}):s.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["No view matches “",n.trim(),"”."]}),u>a.length?s.jsxs("p",{role:"status",className:"text-xs text-muted-foreground",children:["Showing ",a.length," of ",u,". Type to narrow the list."]}):null]})}function $r({ownerSlug:e,typeScope:t,create:r,viewKey:l,shape:n}){const d=ne(),i=Qt({strict:!1}),a=t?In(t):void 0,u=a==="$member",o=m=>{if(!a)return;const p=Hn(e,a);d({to:p.to,params:p.params,search:m?{create:!0}:{},replace:!0})},c=a?s.jsx(Cr,{ownerSlug:e,entityTypeSlug:a,create:r,onCreateChange:o,viewKey:l,shape:n}):l?s.jsx(Rr,{ownerSlug:e,viewKey:l,search:i}):null;return s.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:u?s.jsx(va,{children:c}):c})}function Rr({ownerSlug:e,viewKey:t,search:r}){const l=ne(),{orgContext:n}=Ee(),{data:d,isError:i,error:a,refetch:u}=Kt(n),o=An(n),c=Pn(e,`/${e}/data`),m=Fn(d??[],t),p=Dn(),f=Vn(d??[]),y=i?Bn(a,{subject:"Views"}):null;if(d===void 0)return i?s.jsx(ss,{error:a,onRetry:()=>void u()}):null;if(m.kind==="missing")return s.jsx(ns,{viewKey:m.key,backTo:`/${e}`,backLabel:"Back to Home"});const N=qn(o.data??[]),v=f.some(b=>!N.has(`/${e}/data${Je(b.key)}`)),w=f.length>0&&(p||o.data!==void 0&&v);return s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4",children:[w?s.jsx(_r,{navigation:c.navigation,views:c.views,currentKey:Un(`/${e}/data${Je(t)}`,r)}):null,p&&y?s.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:[y.title,"."," ",y.retryable?s.jsx("button",{type:"button",onClick:()=>void u(),className:"underline underline-offset-4",children:"Retry"}):null]}):null,s.jsx(ba,{decls:m.view.params,params:K(r),onParamsChange:b=>void l({to:".",search:C=>Ge(C,b)})}),s.jsx(as,{orgSlug:e,viewKey:m.view.key,scope:{},params:K(r),onParamsChange:b=>void l({to:".",search:C=>Ge(C,b),replace:!0}),paramDecls:m.view.params,contentHash:m.view.content_hash,title:m.view.name,minHeight:400})]})}function qr({ownerSlug:e,typeScope:t,create:r,viewKey:l,shape:n}){return s.jsxs(zn,{inset:l?"flush":"page",className:l?"gap-0 pt-0 pb-0":"gap-6 pt-2.5 pb-8",children:[s.jsx(Jn,{}),s.jsx(Gn,{owner:e,children:d=>s.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:s.jsx($r,{ownerSlug:d.ownerSlug,typeScope:t,create:r,viewKey:l,shape:n})})})]})}export{qr as M};
|
|
74
|
-
//# sourceMappingURL=memory-browse-page-Ba4aYavw.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{dp as s,G as n,c as r,j as t,ar as p,as as i}from"./index-CdDNNAx2.js";import{E as m}from"./entity-type-page-MgZ7_0oh.js";import"./event-kind-options-fHAIXu24.js";import"./code-editor-BdRMYojw.js";import"./index-Vcq4gwWv.js";function y(){const{owner:e}=s.useParams(),{orgContext:a}=n(),o=r();return t.jsx(p,{className:"gap-4 pt-2.5 pb-8",children:t.jsx(i,{children:t.jsx(m,{entityType:null,orgContext:a,onClose:()=>{o({to:"/$owner",params:{owner:e},search:{layout:"graph"}})}})})})}export{y as component};
|
|
2
|
-
//# sourceMappingURL=new-BOsrRqp8.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as R,z as U,Q as F,r,j as e,T as v,U as S,B as L,V as N,W as E}from"./index-CdDNNAx2.js";import{C as T,a as A,b as I,c as k}from"./card-C01y1O-W.js";import{F as B}from"./full-page-spinner-DWo519BU.js";function c(l){return l.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function H(){const l=R(),{session:u,isReady:d}=U(),{slug:n,name:i}=F.useSearch(),[m,y]=r.useState(i||n||""),[g,h]=r.useState(n||(i?c(i):"")),[b,C]=r.useState(!!n),[x,o]=r.useState(null),[f,p]=r.useState(!1),j=r.useRef(!1);if(r.useEffect(()=>{if(!d||u||j.current)return;j.current=!0;const a=new URL("/orgs/new",window.location.origin);n&&a.searchParams.set("slug",n),i&&a.searchParams.set("name",i);const s=new URL("/auth/login",window.location.origin);s.searchParams.set("callbackUrl",`${a.pathname}${a.search}`),window.location.assign(s.toString())},[d,u,n,i]),!d||!u)return e.jsx(B,{});const P=a=>{const s=E(a);if(s.kind==="cross-host"){window.location.assign(s.href);return}l({to:s.to})},z=async a=>{a.preventDefault(),o(null);const s=m.trim(),w=(g.trim()||c(s)).trim();if(!s){o("Name is required");return}if(!w){o("Slug is required");return}p(!0);try{const t=await N.create({name:s,slug:w});if(t.error){o(t.error.message||"Failed to create organization");return}t.data&&(await N.setActive({organizationId:t.data.id}),P(t.data.slug))}catch(t){o(t instanceof Error?t.message:"An error occurred")}finally{p(!1)}};return e.jsx("div",{className:"container mx-auto max-w-md px-4 py-10",children:e.jsxs(T,{children:[e.jsx(A,{children:e.jsx(I,{children:"Create organization"})}),e.jsx(k,{children:e.jsxs("form",{onSubmit:z,className:"space-y-4",children:[x&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-name",children:["Name",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-name",value:m,onChange:a=>{y(a.target.value),b||h(c(a.target.value))},placeholder:"Acme Inc.",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{htmlFor:"org-slug",children:["Slug",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"org-slug",value:g,onChange:a=>{C(!0),h(c(a.target.value))},placeholder:"acme"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Used in URLs and as the org id in ",e.jsx("code",{children:"lobu.toml"}),". Lowercase letters, numbers, and hyphens."]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(L,{type:"submit",disabled:f,children:f?"Creating…":"Create organization"})})]})})]})})}export{H as component};
|
|
2
|
-
//# sourceMappingURL=new-DGPOjak2.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i7 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,dt as L,be as f,dv as C,L as N,dw as S,dy as y,bd as k,c9 as E}from"./index-CdDNNAx2.js";import{A as O}from"./agent-editor-form-Bnc_q5WD.js";import"./definition-comparison-BUDNuAN_.js";import"./json-diff-C-WQqyIf.js";import"./code-editor-BdRMYojw.js";import"./index-Vcq4gwWv.js";import"./schema-value-k19Ata7u.js";import"./model-selector-XYmk7Iru.js";function W(){const{owner:e}=o.useParams(),t=o.useSearch(),r=l(),i=x(),{isAuthenticated:c}=h(),{isMember:m,isLoading:g}=b(),n=c&&m,{data:d=[],isLoading:u}=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&&u?a.jsx(y,{rows:1}):n?a.jsx(O,{mode:{kind:"create"},existingAgentIds:d.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(k,{icon:E,title:"Workspace membership required",description:"Only workspace members can build managed agents."})]})})}export{W as component};
|
|
2
|
-
//# sourceMappingURL=new-Q0XqiZq2.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{ad as ge,r as v,bN as Ie,bO as Be,bP as Ke,bQ as Me,bR as be,j as e,bS as Y,B as N,bT as Ve,bd as Ue,bU as Ge,bV as He,bW as Ye,bX as Je,bY as Ze,bZ as Xe,b_ as es,b$ as ve,bz as ie,c0 as ss,c1 as ts,c2 as ns,c3 as me,c4 as is,c5 as as,c as os,a8 as We,G as rs,c6 as cs,c7 as ne,c8 as ls,T as je,U as Ne,c9 as ds,ca as us,cb as ms,ai as Ce,cc as hs,m as z,V as le,cd as ps,ce as _e,cf as ke,cg as gs,W as xs,ch as Se,ar as fs,as as ys,S as bs,i as vs,ci as js}from"./index-CdDNNAx2.js";import{P as he,a as De,A as Ns}from"./agent-permissions-matrix-C_ayr0pd.js";import{C as we,a as Ae,b as Oe,c as ze}from"./card-C01y1O-W.js";const Pe=["auto","approval","deny"],Cs={matched_rule:"Matching policy rules apply.",default_approval:"No rule matches; approval is required.",unresolved_principal:"The requesting agent or Automation could not be identified.",parent_approval:"Approval is inherited from the parent action.",unavailable_operation:"This action is unavailable on the connection."},Le={read:"Reads",write:"Writes",destructive:"Destructive writes",non_destructive:"Non-destructive writes",unknown:"Unclassified writes"};function pe(s){return{operation_key:s.operation_key??null,connector_key:s.connector_key??null,connection_id:s.connection_id??null,operation_category:s.operation_category??null}}const de=s=>JSON.stringify(pe(s)),$e=s=>({...s,effect:s.effects.execute??"approval"});function F({label:s,value:n,onChange:a,children:c,disabled:h}){return e.jsxs("label",{className:"flex min-w-0 flex-col gap-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),e.jsx("select",{"aria-label":s,value:n,onChange:r=>a(r.target.value),disabled:h,className:"h-9 w-full rounded-lg border bg-background px-2 text-foreground",children:c})]})}function _s(s,n){const a=n.connections?.find(c=>c.id===s.connection_id);return s.connection_id?`Connection: ${a?.display_name||a?.connector_key||"Unavailable"} (#${s.connection_id})`:s.connector_key?`Connector: ${n.connectors?.find(c=>c.key===s.connector_key)?.name||s.connector_key}`:"All connectors"}function ks(s,n){return s.operation_key?n.connector_operations.find(a=>a.operation_key===s.operation_key)?.name||s.operation_key:s.operation_category?Le[s.operation_category]:"All actions"}function ue(s,n){return`${_s(s,n)} · ${ks(s,n)}`}function Ee(s){return s.connection_id?`connection:${s.connection_id}`:s.connector_key?`connector:${s.connector_key}`:"all"}function Te({catalog:s}){return e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"all",children:"All connectors"}),e.jsx("optgroup",{label:"Connectors",children:s.connectors?.map(n=>e.jsx("option",{value:`connector:${n.key}`,children:n.name},n.key))}),e.jsx("optgroup",{label:"Connections",children:s.connections?.map(n=>e.jsxs("option",{value:`connection:${n.id}`,children:[n.display_name||n.connector_key," (#",n.id,")"]},n.id))})]})}function Ss({label:s,ariaLabel:n,disabled:a,onRemove:c}){const[h,r]=v.useState(!1);return h?e.jsxs("div",{className:"flex gap-1",children:[e.jsx(N,{type:"button",variant:"destructive",size:"sm",disabled:a,"aria-label":"Confirm removal",onClick:async()=>{await c()&&r(!1)},children:"Confirm"}),e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx(N,{type:"button",variant:"ghost",size:"sm",disabled:a,"aria-label":n,onClick:()=>r(!0),children:s})}function ws({owner:s,connector:n,connection:a,agent:c}){const h=ge(),[r,y]=v.useState(c??""),C=Ie(s),l=C.data,u=l?.agents.some(t=>t.id===r)?r:"",m=Be(s,u),i=Ke(s,!u),[P,_]=v.useState(a?`connection:${a}`:n?`connector:${n}`:"all"),[M,J]=v.useState(P),[I,W]=v.useState(!1),[k,D]=v.useState(""),[A,V]=v.useState("all"),[Z,E]=v.useState("approval"),[g,S]=v.useState(!1),[L,T]=v.useState(null),[U,X]=v.useState(a?String(a):""),[G,Q]=v.useState(""),R=l?.connections?.some(t=>String(t.id)===U)?U:"",w=Me(s,R?Number(R):void 0,G,u||void 0);async function H(t,f){S(!0),T(null);try{if(u){const d={resource_class:"connector_action",...pe(t)};f?await Ye(s,u,{...d,effects:{execute:f}}):await Je(s,u,d)||T("This rule was already removed. The list has been refreshed.")}else{const d=i.data;if(!d)return;const K=d.rules.filter(qe=>de(qe)!==de(t));f&&K.push({...pe(t),effect:f});const ce=await Ze(s,{revision:d.revision,rules:K});h.setQueryData(Xe(s),ce)}return await Promise.all(["write-permissions","agent-permissions","available-operations","connector-operations","policy-explanation"].map(d=>h.invalidateQueries({queryKey:[d]}))),t}catch(d){d instanceof be&&d.status===409?(T("Policies changed in another session. Review the refreshed rules before saving again."),await i.refetch()):T(d instanceof Error?d.message:"Could not save policy.")}finally{S(!1)}}const q=C.error||(u?m.error:i.error);if(q instanceof be&&q.status===403)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Only organization owners and admins can manage policies."});if(q)return e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not load policies. ",String(q)]});if(!l||(u?!m.data:!i.data))return e.jsx(Y,{label:"policies",rows:2});const b=t=>t==="all"||l.connectors?.some(f=>`connector:${f.key}`===t)||l.connections?.some(f=>`connection:${f.id}`===t)?t:"all",o=b(P),p=b(M),j=l.connections?.find(t=>`connection:${t.id}`===p),$=j?.connector_key??(p.startsWith("connector:")?p.slice(10):void 0),x=t=>p==="all"||Ee(t)==="all"?!0:t.connection_id?j?t.connection_id===j.id:l.connections?.some(f=>f.id===t.connection_id&&f.connector_key===$):t.connector_key===$;function B(t){return u?t.principal_kind==="agent"&&t.principal_id===u:!t.principal_kind}const ee=o.startsWith("connector:")?o.slice(10):o.startsWith("connection:")?l.connections?.find(t=>t.id===Number(o.slice(11)))?.connector_key:void 0,O=l.connector_operations.filter(t=>!ee||t.connector_key===ee),se=l.connections?.find(t=>t.id===Number(R))?.connector_key,ae=l.connector_operations.filter(t=>t.connector_key===se),oe=u?(m.data?.agent??[]).filter(t=>t.resource_class==="connector_action").map($e):i.data?.rules??[],te=(m.data?.floor??[]).filter(t=>t.resource_class==="connector_action"&&x(t)).map($e),Qe={connector_key:o.startsWith("connector:")?o.slice(10):o==="all"&&A==="specific"?O.find(t=>t.operation_key===k)?.connector_key??null:null,connection_id:o.startsWith("connection:")?Number(o.slice(11)):null,operation_key:A==="specific"?k:null,operation_category:A.startsWith("category:")?A.slice(9):null},re=oe.filter(x);function fe(){_(p),V("all"),D(""),E("approval"),W(!0)}const ye=(t,f=!1)=>e.jsx("div",{className:"divide-y rounded-lg border",children:t.map(d=>{const K=!f&&B(d);return e.jsxs(De,{controls:e.jsxs(e.Fragment,{children:[e.jsx(he,{options:Pe,value:d.effect,floor:"auto",compact:!0,disabled:g||!K,ariaLabel:`Policy for ${ue(d,l)}`,onChange:ce=>void H(d,ce)}),K&&e.jsx(Ss,{label:"Remove",disabled:g,ariaLabel:`Remove rule: ${ue(d,l)}`,onRemove:()=>H(d)})]}),children:[e.jsx("p",{className:"text-sm break-words",children:ue(d,l)}),!K&&e.jsx("p",{className:"text-xs text-muted-foreground",children:d.principal_kind==="agent"&&!d.principal_id?"All agents":"Inherited restriction"})]},JSON.stringify([d.principal_kind,d.principal_id,de(d)]))})});return e.jsxs("div",{className:"space-y-4",children:[(p!==M||u!==r)&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"The requested scope is unavailable. Showing organization rules; install the connector or choose an available scope."}),e.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Auto runs immediately. Ask waits for human approval. Block prevents execution and hides the action from agents. Authentication and guardrails still apply."}),e.jsxs("details",{className:"space-y-2",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-foreground",children:"How rules combine"}),e.jsx("p",{children:"A rule overrides another when it is narrower in target or actions and at least as narrow in the other. When rules are narrower in different ways, or use different categories, the stricter choice wins: Block, then Ask, then Auto. With no matching rule, the result is Ask. Impact categories apply only to writes."}),e.jsx("p",{children:"A connection-wide Auto does not override an organization-wide destructive Block. Add a destructive rule for that connection to make an exception."}),e.jsx("p",{children:"Agents and their Automations can only tighten organization policy. Internal browser steps inherit the parent approval; an explicit browser Block still wins."})]})]}),e.jsxs(F,{label:"Policy owner",value:u,onChange:y,disabled:g,children:[e.jsx("option",{value:"",children:"Organization"}),l.agents.map(t=>e.jsxs("option",{value:t.id,children:["Agent: ",t.name]},t.id))]}),u&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Auto adds no restriction for this agent. It inherits organization policy and cannot bypass Ask or Block."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u?"Without a matching restriction, this agent inherits organization policy.":"Without a matching rule, actions require approval (Ask)."}),e.jsx(F,{label:"Show rules for",value:p,onChange:J,disabled:g,children:e.jsx(Te,{catalog:l})}),u&&te.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Inherited organization rules"}),ye(te,!0)]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:u?"Saved restrictions":"Saved rules"}),!I&&re.length>0&&e.jsx(N,{variant:"outline",size:"sm",disabled:g,onClick:fe,children:"Add rule"})]}),I&&e.jsxs("form",{className:"space-y-3 border-t pt-4",onSubmit:t=>{t.preventDefault(),!g&&(A!=="specific"||k)&&H(Qe,Z).then(f=>{f&&(W(!1),J(Ee(f)))})},children:[e.jsx("h3",{className:"text-sm font-medium",children:"Add rule"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(F,{label:"Applies to",value:o,onChange:t=>{_(t),V("all"),D("")},disabled:g,children:e.jsx(Te,{catalog:l})}),e.jsxs(F,{label:"Actions",value:A,onChange:V,disabled:g,children:[e.jsx("option",{value:"all",children:"All actions"}),e.jsx("optgroup",{label:"Categories",children:l.operation_categories?.map(t=>e.jsx("option",{value:`category:${t}`,children:Le[t]},t))}),e.jsx("option",{value:"specific",children:"Specific action"})]})]}),A==="specific"&&e.jsxs(F,{label:"Specific action",value:k,onChange:D,disabled:g,children:[e.jsx("option",{value:"",children:"Choose action"}),O.map(t=>e.jsxs("option",{value:t.operation_key,children:[t.connector_name,": ",t.name]},t.operation_key))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(he,{options:Pe,value:Z,floor:"auto",compact:!0,disabled:g,ariaLabel:"New rule decision",onChange:E}),e.jsx(Ve,{onCancel:()=>W(!1),cancelDisabled:g,children:e.jsx(N,{type:"submit",disabled:g||A==="specific"&&!k,children:g?"Saving…":"Save rule"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saving an existing scope replaces its decision. Removing a rule reveals the next matching rule."})]}),re.length?ye(re):!I&&e.jsx(Ue,{icon:Ge,title:"No saved rules in this scope",description:"Add a rule for all actions, a category, or a specific action.",actionLabel:"Add rule",onAction:fe})]}),L&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:L}),e.jsxs("details",{className:"space-y-3 border-t pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Check an action"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs(F,{label:"Check connection",value:R,onChange:t=>{X(t),Q("")},children:[e.jsx("option",{value:"",children:"Choose connection"}),l.connections?.map(t=>e.jsxs("option",{value:String(t.id),children:[t.display_name||t.connector_key," (#",t.id,")"]},t.id))]}),e.jsxs(F,{label:"Check action",value:G,onChange:Q,disabled:!R,children:[e.jsx("option",{value:"",children:"Choose action"}),ae.map(t=>e.jsx("option",{value:t.operation_key.slice(t.connector_key.length+2),children:t.name},t.operation_key))]})]}),w.error?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check policy. ",String(w.error)]}):e.jsx("p",{"aria-live":"polite",className:"text-sm",children:G?w.isPending?"Checking…":w.data?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:He[w.data.effect]})," ·"," ",Cs[w.data.reason]??"The server evaluated this action.",w.data.rule_ids.length>0?` · Rules ${w.data.rule_ids.map(t=>`#${t}`).join(", ")}`:""]}):"":""})]})]})}const As=[{action:"create_type",label:"Create entity types",description:"Add a new type and its initial fields."},{action:"update_type",label:"Edit entity types",description:"Change fields, write rules, event kinds, or type metadata."},{action:"delete_type",label:"Delete entity types",description:"Remove an entity-type definition."}],Os=[{action:"create_relationship_type",label:"Create relationship types",description:"Add a new kind of link between entity types."},{action:"update_relationship_type",label:"Edit relationship types",description:"Change a definition, or which types it may connect."},{action:"delete_relationship_type",label:"Delete relationship types",description:"Remove a relationship-type definition."}];function xe(s){return s.resource_class==="entity_schema"&&s.principal_kind===null&&s.entity_type_slug===null&&s.operation_key===null&&s.target_agent_id===null}function zs(s){return s.agent.find(xe)}function Ps(s,n){return{...s,agent:[...s.agent.filter(a=>!xe(a)),n]}}function $s(s){return{...s,agent:s.agent.filter(n=>!xe(n))}}function Es({label:s,description:n,action:a,value:c,pending:h,onChange:r}){return e.jsxs(De,{controls:e.jsx(he,{options:as("entity_schema",a),value:c,floor:"auto",disabled:h,compact:!0,ariaLabel:s,onChange:r}),children:[e.jsx("p",{children:s}),e.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:n})]})}function Re({title:s,actions:n,effects:a,pending:c,onChange:h}){return e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:s}),e.jsx("div",{className:"divide-y overflow-hidden rounded-lg border",children:n.map(({action:r,label:y,description:C})=>e.jsx(Es,{action:r,label:y,description:C,value:a[r]??me.entity_schema[r]??"deny",pending:c,onChange:l=>h(r,l)},r))})]})}function Ts({owner:s}){const n=ge(),a=es(s),c=Ie(s),h=ve({mutationFn:m=>ss(s,{resource_class:"entity_schema",effects:m}),onSuccess:m=>{n.setQueryData(a,i=>i&&Ps(i,m)),n.invalidateQueries({queryKey:a})},onError:m=>{ie.error(m instanceof Error?m.message:"Failed to save schema policy")}}),r=ve({mutationFn:()=>ts(s,{resource_class:"entity_schema"}),onSuccess:()=>{n.setQueryData(a,m=>m&&$s(m)),n.invalidateQueries({queryKey:a})},onError:m=>{ie.error(m instanceof Error?m.message:"Failed to reset schema policy")}});if(c.isLoading)return e.jsx(Y,{label:"schema policy",variant:"cards",cards:1});if(c.isError||!c.data)return e.jsx(ns,{label:"schema policy"});const y=zs(c.data),C=y?.effects??me.entity_schema,l=h.isPending||r.isPending,u=(m,i)=>{h.mutate({...y?.effects??me.entity_schema,[m]:i})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:y?"Custom policy":"Workspace defaults"}),y?e.jsxs(N,{type:"button",variant:"outline",size:"sm",disabled:l,onClick:()=>r.mutate(),children:[e.jsx(is,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove custom policy"]}):null]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Re,{title:"Entity types",actions:As,effects:C,pending:l,onChange:u}),e.jsx(Re,{title:"Relationship types",actions:Os,effects:C,pending:l,onChange:u})]})]})}function Fe(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Rs(s,n,a){const c=s.split("/");return c[1]===n?(c[1]=a,c.join("/")||"/"):`/${a}`}function Fs({section:s}){return s==="policies"?e.jsx(Y,{label:"policies",rows:2}):s==="governance"?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx(Y,{label:"agent write defaults",variant:"table",rows:3})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx(Y,{label:"schema governance",rows:3})]})]}):e.jsxs("div",{role:"status","aria-label":"Loading general settings","aria-busy":"true",className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{"aria-hidden":"true",className:"space-y-4",children:[["name","slug"].map(n=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(z,{className:"h-3.5 w-12 rounded-none"}),e.jsx("div",{className:"flex h-9 items-center border border-input bg-background px-3",children:e.jsx(z,{className:"h-4 w-32 rounded-none"})})]},n)),e.jsx(z,{className:"h-3 w-4/5 rounded-none"})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsx("div",{"aria-hidden":"true",className:"grid gap-2 sm:grid-cols-2",children:["private","public"].map(n=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-3",children:[e.jsx(z,{className:"mt-0.5 h-4 w-4 shrink-0 rounded-none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(z,{className:"h-4 w-16 rounded-none"}),e.jsx(z,{className:"h-3 w-full rounded-none"}),e.jsx(z,{className:"h-3 w-2/3 rounded-none"})]})]},n))})]}),e.jsxs("div",{"aria-hidden":"true",className:"flex justify-end gap-2",children:[e.jsx(z,{className:"h-9 w-20 rounded-none"}),e.jsx(z,{className:"h-9 w-28 rounded-none"})]})]})}function Is({owner:s,section:n="general",connector:a,connection:c,agent:h}){const r=os(),y=ge(),{data:C,error:l}=We(),{activeOrg:u,urlOrgSlug:m}=rs(),i=(C??[]).find(o=>o.slug===s&&o.is_member)??null,P=i?.id??s,_=cs(P,{name:i?.name??"",slug:i?.slug??"",visibility:i?.visibility??"private"}),[M,J]=_.field("name"),[I,W]=_.field("slug"),[k,D]=_.field("visibility"),[A,V]=ne(P,!!i),[Z,E]=ne(P,!1),[g,S]=ne(P,null),[L,T]=v.useState(!1),[U,X]=v.useState(!1),[G,Q]=ne(P,!1);if(ls(l)&&C===void 0)return e.jsxs(we,{role:"alert",children:[e.jsx(Ae,{children:e.jsx(Oe,{children:"Couldn't load organizations"})}),e.jsx(ze,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please try again in a moment."})})]});if(C===void 0)return e.jsx(Fs,{section:n});if(!i)return e.jsxs(we,{children:[e.jsx(Ae,{children:e.jsx(Oe,{children:"Organization not found"})}),e.jsx(ze,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You aren't a member of an organization at"," ",e.jsx("span",{className:"font-mono",children:s}),", or it has been deleted."]})})]});if(n==="policies")return e.jsx("div",{className:"space-y-6",children:e.jsxs("section",{id:"policies",className:"scroll-mt-6 space-y-4",children:[e.jsx("div",{className:"space-y-1",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control connector actions across the organization. Changes to existing rules save automatically."})}),e.jsx(ws,{owner:s,connector:a,connection:c,agent:h},`${s}:${h??""}:${a??""}:${c??""}`)]})});if(n==="governance")return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Agent write defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the defaults agents inherit for entities and agents. Changes save automatically; agents can only tighten them."})]}),e.jsx(Ns,{owner:s,variant:"org-floor"})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"Schema governance"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control structural changes by agents and connected AI clients. Changes save automatically."})]}),e.jsx(Ts,{owner:s})]})]});const R=o=>{const p=xs(o);if(p.kind==="cross-host"){window.location.assign(p.href);return}r({to:p.to})},w=o=>{if(o==="public"&&i.visibility!=="public"){E(!0);return}D(o),E(!1)},H=async()=>{if(!_.canSubmit)return;const o=M.trim();if(!o){S("Name is required");return}const p=I.trim()||Fe(o);if(!p){S("Slug is required");return}T(!0),S(null);try{const j=o!==i.name||p!==i.slug,$=k!==i.visibility;let x=i.slug;if(j){const O=await le.update({organizationId:i.id,data:{name:o,slug:p}});if(O.error){S(O.error.message||"Failed to update organization");return}x=O.data?.slug??p}$&&(x=(await ps(x,k)).slug),(j||$)&&(_.accept(_.values,{name:o,slug:x,visibility:k}),await y.invalidateQueries({queryKey:["organizations"]}),ie.success("Organization updated"));const B=u?.id===i.id||m===i.slug,ee=x!==i.slug;if(B&&ee){const O=_e(),se=ke();if(O===i.slug&&se){const oe=gs(window.location.pathname,i.slug)||"/",te=`${window.location.protocol}//${x}.${se}${oe}${window.location.search}${window.location.hash}`;window.location.assign(te);return}const ae=Rs(window.location.pathname,i.slug,x);r({to:`${ae}${window.location.search}${window.location.hash}`});return}}catch(j){S(j instanceof Error?j.message:"Failed to update organization")}finally{T(!1)}},q=async()=>{X(!0),S(null);try{const o=await le.delete({organizationId:i.id});if(o.error){S(o.error.message||"Failed to delete organization");return}await y.invalidateQueries({queryKey:["organizations"]}),ie.success("Organization deleted");const j=(C??[]).filter(x=>x.is_member).find(x=>x.id!==i.id)??null,$=u?.id===i.id||m===i.slug;if($&&j){await le.setActive({organizationId:j.id}),R(j.slug);return}if($){const x=_e(),B=ke();if(x===i.slug&&B){window.location.assign(`${window.location.protocol}//app.${B}/`);return}r({to:"/"});return}r({to:"/"})}catch(o){S(o instanceof Error?o.message:"Failed to delete organization")}finally{X(!1),Q(!1)}},b=L||U;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Identity"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"org-name",children:"Name"}),e.jsx(Ne,{id:"org-name",value:M,onChange:o=>{J(o.target.value),A||W(Fe(o.target.value))},placeholder:"e.g. My Team",disabled:b})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(je,{htmlFor:"org-slug",children:"Slug"}),e.jsx(Ne,{id:"org-slug",value:I,onChange:o=>{V(!0),W(o.target.value)},placeholder:"e.g. my-team",disabled:b}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Changing the slug rewrites this workspace's URL. Existing links to"," ",e.jsxs("span",{className:"font-mono",children:["/",i.slug]})," redirect for a grace period."]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold leading-none",children:"Workspace visibility"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose who can browse this workspace and its public pages."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("button",{type:"button",onClick:()=>w("private"),disabled:b,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${k==="private"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(ds,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Private"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only members can access this workspace."})]})]}),e.jsxs("button",{type:"button",onClick:()=>w("public"),disabled:b,className:`flex items-start gap-3 rounded-lg border p-3 text-left transition-colors ${k==="public"?"border-primary bg-primary/5":"border-border hover:bg-muted/40"}`,children:[e.jsx(us,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Anyone can browse public pages for this workspace."})]})]})]}),Z&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm",children:[e.jsx("p",{className:"text-foreground",children:"Make this workspace public? Catalog-style content may become visible outside the membership."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(N,{type:"button",size:"sm",onClick:()=>{D("public"),E(!1)},disabled:b,children:"Confirm public"}),e.jsx(N,{type:"button",size:"sm",variant:"ghost",onClick:()=>E(!1),disabled:b,children:"Cancel"})]})]})]}),g&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:g}),e.jsx(ms,{visible:_.hasConflict,onReload:_.reset}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{variant:"outline",onClick:()=>void r({to:`/${s}`}),disabled:b,children:"Cancel"}),e.jsxs(N,{onClick:H,disabled:b||!_.canSubmit,children:[L?e.jsx(Ce,{size:"lg",className:"mr-1.5"}):null,L?"Saving...":"Save changes"]})]}),e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:i.is_personal?"Personal workspace":"Delete this organization"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:i.is_personal?"Your personal workspace can't be deleted — your devices and personal connections are bound to it.":"Permanently removes the organization and all members' workspace access. This cannot be undone."}),!i.is_personal&&e.jsx("div",{className:"mt-3",children:G?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(N,{variant:"destructive",size:"sm",onClick:q,disabled:b,children:[U?e.jsx(Ce,{className:"mr-1.5"}):null,"Confirm delete"]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>Q(!1),disabled:b,children:"Cancel"})]}):e.jsxs(N,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>Q(!0),disabled:b,children:[e.jsx(hs,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete organization"]})})]})]})}function Qs(){const{owner:s}=Se.useParams(),n=Se.useSearch(),a=n.section??"general",c={general:"General",policies:"Policies",governance:"Governance"}[a],{data:h}=We(),r=(h??[]).find(y=>y.slug===s&&y.is_member)?.name;return e.jsx(fs,{className:"pt-2.5 pb-8",children:e.jsxs(ys,{className:vs("flex flex-1 flex-col gap-6",js(a)),children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bs,{className:"h-7 w-7"}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:c})]}),r?e.jsx("p",{className:"text-base font-medium text-foreground",children:r}):null]}),e.jsx(Is,{owner:s,...n,section:a})]})})}export{Qs as component};
|
|
2
|
-
//# sourceMappingURL=organization-hD_Z6TSd.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aU as ds,j as e,r as j,c as K,H as te,dN as us,dA as bt,dM as jt,L as ke,a7 as ms,dP as fs,S as kt,dQ as ps,d7 as hs,aN as Ct,aP as T,bp as rt,dR as vs,dS as ys,av as gs,dT as xs,au as bs,d2 as js,dU as ee,cv as ks,dV as St,dW as Cs,ax as Ss,dX as Ns,s as _s,dl as Es,aC as ge,dY as Is,dZ as Ts,n as Nt,cP as _t,d_ as As,cB as ct,d$ as Fs,cT as Rs,cU as Et,e0 as Ps,e1 as ws,cy as Ms,aQ as Ls,dc as $s,U as Os,i as xe,X as Ds,e2 as Bs,e3 as Ks,bU as Gs,e4 as Us,e5 as Vs,e6 as It,br as Qs,bs as Ws,bt as Hs,bu as zs,bv as Ys,e7 as Zs,e8 as Tt,e9 as lt,z as qs,ea as Xs,eb as Re,ec as dt,cQ as Js,ed as en,x as tn,cO as sn,ee as nn,ef as on,t as an,eg as rn,eh as cn,ei as ln,c2 as dn,ej as un,ek as mn,dE as fn,bd as ut,el as mt,em as At,en as Pe,dn as Ft,B as Rt,eo as pn,ep as we}from"./index-CdDNNAx2.js";import{S as D,F as ft,o as X,d as hn,r as vn,f as yn,a as gn}from"./filter-editors-DDTwyYt0.js";import{u as xn}from"./runs-CuC7WMtd.js";import{e as bn,f as Ae,C as Pt,c as jn}from"./event-kind-options-fHAIXu24.js";import{S as kn}from"./source-record-panels-C4UItfdk.js";import{u as Cn}from"./clients-BCvjAJDT.js";import{u as Sn}from"./client-activity-scopes-BBIq16tG.js";import{g as Nn}from"./client-rows-DGh1O-Fu.js";import{E as _n}from"./events-feed-BI7wNRUY.js";import{E as En}from"./run-initiator-B8IRlRd-.js";import{L as In,u as Tn}from"./renderer-DZ0w2k2r.js";import{E as An}from"./agent-loading-shells-xteN-pyK.js";import{M as Fn}from"./member-scope-gate-CH_0jHiM.js";const Oe=j.createContext(null);function Rn({organizationId:t,isWorkspaceLoading:s,children:a}){const{data:n=[],isLoading:o}=ds(t);return e.jsx(Oe.Provider,{value:{groups:n,isLoading:!!s||o},children:a})}function Pn(){const t=j.useContext(Oe);if(!t)throw new Error("useMemoryConnectorGroups must be used within MemoryConnectorGroupsProvider");return t}function wn(){return j.useContext(Oe)}function wt(t){const{parse:s,serialize:a,filterKeys:n,clearClassifications:o=!0,replace:i=!0,merge:l}=t,y=K(),d=te(),r=j.useMemo(()=>{const u=new URLSearchParams;for(const[f,p]of Object.entries(d.search||{}))p!=null&&u.set(f,typeof p=="object"&&!Array.isArray(p)?JSON.stringify(p):String(p));return s(u)},[d.search,s]),c=j.useCallback((u,f)=>{const p=l?l(r,u):{...r,...u},v=a(p),k={};for(const[x,S]of Object.entries(d.search||{}))S!=null&&(k[x]=S);for(const x of n)delete k[x];if(o)for(const x of Object.keys(k))x.startsWith("clf_")&&delete k[x];for(const[x,S]of Object.entries(v))S!==void 0&&(k[x]=S);y({to:d.pathname,search:k,replace:f?.replace??i})},[r,a,n,o,l,y,d,i]),g=j.useCallback(()=>{const u={};for(const[f,p]of Object.entries(d.search||{}))p!=null&&(n.includes(f)||o&&f.startsWith("clf_")||(u[f]=p));y({to:d.pathname,search:u,replace:i})},[y,d.pathname,d.search,n,o,i]);return{filters:r,updateFilters:c,clearFilters:g}}function Mn(t){const{slug:s}=us();return bt({queryKey:["schedules",s,t],queryFn:async()=>((await jt("manage_schedules",{action:"list",action_type:"wake_agent",include_paused:!0})).schedules??[]).filter(n=>n.action_args?.agent_id===t),enabled:!!s&&!!t,staleTime:3e4})}function Ln(t,s){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:s.connector_key,connectionId:String(s.connection_id)},search:{feedId:s.id}}}function $n(t,s){return{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:t,connectorKey:s.connector_key,connectionId:String(s.id)}}}function On(t,s){return{to:"/$owner/agents/connected/$clientId",params:{owner:t,clientId:s}}}function Dn(t,s){return{to:"/$owner/automations/$automationId",params:{owner:t,automationId:s}}}function Bn(t,s,a){return{to:"/$owner/events",params:{owner:t},search:{agent:s,schedule:a}}}function fe({id:t,label:s,value:a,sourceLink:n,details:o,onRemove:i}){return{id:t,label:s,op:"is",value:a,onRemove:i,editor:n||o?{kind:"custom",className:"w-80",render:()=>e.jsxs("div",{className:"flex flex-col gap-2 p-3 text-sm",children:[n?e.jsxs(ke,{to:n.to,params:n.params,search:n.search,className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-foreground hover:underline",children:[e.jsx("span",{className:"truncate",children:a}),e.jsx(ms,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}):e.jsx("span",{className:"font-medium",children:a}),o]})}:void 0}}function Kn({ownerSlug:t,clientIds:s,linkedUser:a,linkedUserEntitySlug:n}){const o=t&&n?fs(t,[{entity_type:"$member",slug:n}]):null;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:s.length===1?"Client ID":"Client IDs"}),s.map(i=>e.jsx("code",{className:"break-all text-foreground",children:i},i))]}),a?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:["Granted by",o?e.jsx(ke,{to:o,className:"font-medium text-foreground hover:underline",children:a}):e.jsx("span",{className:"font-medium text-foreground",children:a})]}):null]})}function Gn(t,s=!0){return bt({queryKey:["automations-list","activity",t],queryFn:async()=>{const a=await Promise.all(["active","archived"].map(n=>jt("manage_automations",{action:"list",status:n,include_details:!1},{slug:t})));return[...new Map(a.flatMap(n=>n.automations).map(n=>[Number(n.automation_id),n])).values()].sort((n,o)=>n.name.localeCompare(o.name))},enabled:s&&!!t,staleTime:3e4})}function J({to:t,params:s,search:a,label:n}){return e.jsx(ke,{to:t,params:s,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 ${n}`,children:e.jsx(kt,{className:"h-3.5 w-3.5"})})}const Me=["produced","analyzed"],be=t=>t==="produced"?"Produced by":"Analyzed by";function Un({enabled:t,...s}){const a=Vn(s,t);if(!t)return{fields:[],chips:[]};const n=Qn(s);return{fields:[a.field,n.field],chips:[...a.chips,...n.chips]}}function Vn({ownerSlug:t,filters:s,onFiltersChange:a},n){const o=Gn(t,n),i=o.data??[],l=c=>c==="produced"?s.producedByAutomationId:s.automationId,y=c=>i.find(g=>Number(g.automation_id)===c)?.name??`#${c}`,d=Me.flatMap(c=>{const g=l(c);return g==null?[]:[{id:`automation-${c}`,field:"automation",label:be(c),value:y(g),onRemove:()=>a(c==="produced"?{producedByAutomationId:null}:{automationId:null})}]}),r={kind:"list",className:"w-80",searchPlaceholder:"Search Automations...",emptyText:o.isLoading?"Loading Automations...":"No Automations found",items:c=>e.jsxs(e.Fragment,{children:[Me.map(g=>{const u=l(g),f=i.map(v=>({id:Number(v.automation_id),label:`${v.name}${v.status==="archived"?" (archived)":""}`}));u!=null&&!f.some(v=>v.id===u)&&f.unshift({id:u,label:`Automation #${u} (selected)`});const p=v=>{a(g==="produced"?{producedByAutomationId:v}:{automationId:v}),c()};return e.jsx(Ct,{heading:be(g),children:f.map(v=>e.jsxs(T,{"aria-label":v.label,value:`${g} ${v.label} ${v.id}`,onSelect:()=>p(v.id),className:"group",children:[e.jsx(D,{selected:u===v.id}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:v.label}),e.jsx(J,{...Dn(t,String(v.id)),label:v.label})]},v.id))},g)}),o.isError?e.jsx(T,{forceMount:!0,onSelect:()=>void o.refetch(),children:"Could not load Automations. Retry"}):null]})};return{chips:d,field:{key:"automation",label:"Automation",group:"Scope",icon:e.jsx(ps,{className:"h-4 w-4"}),editor:r}}}function Qn(t){const{filters:s,onFiltersChange:a}=t,n=[];s.runIds?.length&&n.push({id:"run-produced",field:"run",label:"Produced by run",value:s.runIds.map(i=>`#${i}`).join(", "),onRemove:()=>a({runIds:null})}),s.runId!=null&&n.push({id:"run-analyzed",field:"run",label:"Analyzed by run",value:`#${s.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,l)=>Me.map(y=>e.jsx(Wn,{...t,mode:y,query:l,close:i},y))};return{chips:n,field:{key:"run",label:"Run",group:"Scope",icon:e.jsx(hs,{className:"h-4 w-4"}),editor:o}}}function Wn({ownerSlug:t,filters:s,onFiltersChange:a,mode:n,query:o,close:i}){const l=n==="produced"?s.producedByAutomationId:s.automationId,y=xn({workspace:!0},{automationIds:l==null?void 0:[l],runTypes:n==="analyzed"?["automation"]:void 0,connectionIds:n==="produced"?s.connectionIds??void 0:void 0,feedIds:n==="produced"?s.feedIds??void 0:void 0},t),d=n==="produced"?s.runIds??[]:s.runId==null?[]:[s.runId],r=y.data?.pages.flatMap(f=>f.runs)??[],c=[...new Map(r.map(f=>[f.id,{id:f.id,label:`Run #${f.id} · ${f.feed_display_name??f.operation_key??f.run_type} · ${f.status}`}])).values()];for(const f of d)c.some(p=>p.id===f)||c.unshift({id:f,label:`Run #${f} (selected)`});const g=f=>{if(n==="produced"){const p=d.includes(f)?d.filter(v=>v!==f):[...d,f];a({runIds:p.length?p:null})}else a({runId:f}),i()},u=/^\d+$/.test(o.trim())?Number(o.trim()):0;return e.jsxs(Ct,{heading:be(n),children:[c.map(f=>e.jsxs(T,{value:`${n} ${f.label}`,onSelect:()=>g(f.id),children:[e.jsx(D,{selected:d.includes(f.id)}),e.jsx("span",{className:"truncate",children:f.label})]},f.id)),Number.isSafeInteger(u)&&u>0&&!c.some(f=>f.id===u)?e.jsxs(T,{value:`${n} ${u}`,onSelect:()=>g(u),children:[be(n)," run #",u]}):null,y.isLoading?e.jsx(T,{disabled:!0,forceMount:!0,children:"Loading runs..."}):null,y.isError?e.jsx(T,{forceMount:!0,onSelect:()=>void(y.isFetchNextPageError?y.fetchNextPage():y.refetch()),children:"Could not load runs. Retry"}):null,!y.isLoading&&!y.isError&&!c.length?e.jsx(T,{disabled:!0,forceMount:!0,children:"No runs found"}):null,y.hasNextPage?e.jsx(T,{forceMount:!0,disabled:y.isFetching,onSelect:()=>void y.fetchNextPage(),children:y.isFetchingNextPage?"Loading more runs...":"Load more runs"}):null]})}const De="Scope",Fe="Source",V="h-4 w-4";function se(){return te().search??{}}function Mt(t){const{pathname:s}=te(),a=s.startsWith(`/${t}/events/`),n=gs(s,a?1:0),o=!!(n&&!a&&!xs(n.split("/")[0]));return{pathname:s,embedded:o,recordPath:o?bs(n)?.entityPath:a?n:void 0}}function Lt(t){const s=se(),{recordPath:a,pathname:n,embedded:o}=Mt(t);return i=>{const l=ee(t,s,i,a);return o?{to:n,search:l.search}:l}}const pt=t=>new Set((t??"").split(",").map(s=>s.trim()).filter(Boolean));function Hn({ownerSlug:t,sourceRead:s=!1,filters:a,onFiltersChange:n}){const o=se(),{recordPath:i,embedded:l}=Mt(t),y=i?i.split("/").at(-2):void 0,d=typeof o.type=="string"&&o.type.trim()?o.type.trim():void 0,r=(y?rt(y):void 0)??(d?rt(d):void 0),c=vs(o),g=ys(o),u=typeof o.feed_ids=="string"?o.feed_ids:typeof o.feed_ids=="number"?String(o.feed_ids):void 0,f=zn(t,r,!l),p=Yn(t,r,i,l),v=Zn(t,c,!s),k=Un({ownerSlug:t,filters:a,onFiltersChange:n,enabled:!s}),x=qn(t,g,u);return[f,p,v,k,x].reduce((S,M)=>({fields:[...S.fields,...M.fields],chips:[...S.chips,...M.chips]}),{fields:[],chips:[]})}function zn(t,s,a){const n=K(),o=se(),{visible:i}=js(t);if(!a)return{fields:[],chips:[]};const l=i.find(d=>d.slug===s),y={kind:"list",searchPlaceholder:"Search types...",emptyText:"No entity types",items:d=>e.jsxs(e.Fragment,{children:[i.map(r=>e.jsxs(T,{onSelect:()=>{n(ee(t,o,{entity:void 0,create:void 0,type:r.slug})),d()},className:"group gap-2",children:[e.jsx(D,{selected:r.slug===s}),e.jsx(Rs,{icon:r.icon,className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),typeof r.entity_count=="number"?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:r.entity_count}):null,e.jsx(J,{to:"/$owner/entity-types/$slug",params:{owner:t,slug:r.slug},label:r.name})]},r.id)),e.jsxs(T,{onSelect:()=>{n(Ps(t)),d()},className:"text-muted-foreground",children:[e.jsx(Et,{className:"h-4 w-4 shrink-0"}),"Add entity type"]})]})};return{fields:[{key:"type",label:"Entity type",group:De,icon:e.jsx(ks,{className:V}),editor:y}],chips:s?[{id:"type",label:"Entity type",op:"is",value:l?.name??s,onRemove:()=>void n(ee(t,o,{type:void 0}))}]:[]}}function Yn(t,s,a,n){const o=K(),i=se(),[l,y]=j.useState(""),[d,r]=j.useState(0),c=St(l,250),g={slug:t},{data:u,isLoading:f,isError:p,refetch:v}=Cs(s??"",g,{search:c,offset:d,limit:30,enabled:!n&&!!s}),{data:k}=Ss(a?`/${t}/${a}`:"",g),x=a?k?.entity:void 0,S=x?.name??(a?a.split("/").at(-1):void 0);if(n)return{fields:[],chips:S?[{id:"entity",label:"Entity",op:"is",value:S}]:[]};if(!s)return{fields:[],chips:[]};const M={kind:"list",searchPlaceholder:"Search entities...",emptyText:f?"Loading entities...":"No matching entities",className:"w-80",onQueryChange:F=>{y(F),r(0)},items:F=>e.jsxs(e.Fragment,{children:[p?e.jsx(T,{onSelect:()=>void v(),children:"Could not load entities. Retry"}):u?.entities.map(E=>e.jsxs(T,{value:E.slug,onSelect:()=>{const R=ws([...E.parent_slug&&E.parent_entity_type?[{entity_type:E.parent_entity_type,slug:E.parent_slug}]:[],{entity_type:E.entity_type,slug:E.slug}]);o(ee(t,i,{type:s},R)),F()},children:[e.jsx(D,{selected:x?.slug===E.slug}),E.name]},E.slug)),d>0&&e.jsx(T,{onSelect:()=>r(Math.max(0,d-30)),children:"Previous entities"}),u?.metadata.has_more&&e.jsx(T,{disabled:f,onSelect:()=>r(d+30),children:"More entities"})]})};return{fields:[{key:"entity",label:"Entity",group:De,icon:e.jsx(Ns,{className:V}),editor:M}],chips:S?[{id:"entity",label:"Entity",op:"is",value:S,onRemove:()=>void o(ee(t,i,{type:s}))}]:[]}}function Zn(t,s,a){const n=K(),o=Lt(t),{data:i=[]}=_s(),l=j.useMemo(()=>[...i].sort((r,c)=>r.name.localeCompare(c.name)),[i]);if(!a)return{fields:[],chips:[]};const y=l.find(r=>r.agentId===s),d={kind:"list",searchPlaceholder:"Search agents...",emptyText:"No agents",items:r=>l.map(c=>e.jsxs(T,{onSelect:()=>{n(o({agent:c.agentId,schedule:void 0})),r()},className:"gap-2",children:[e.jsx(D,{selected:c.agentId===s}),e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-medium",children:c.name.trim().charAt(0).toUpperCase()||"?"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.name})]},c.agentId))};return{fields:[{key:"agent",label:"Agent",group:De,icon:e.jsx(Es,{className:V}),editor:d}],chips:s?[{id:"agent",label:"Agent",op:"is",value:y?.name??s,onRemove:()=>void n(o({agent:void 0,schedule:void 0}))}]:[]}}function qn(t,s,a){const n=K(),o=Lt(t),{groups:i}=Pn(),l=se(),y=ge({platforms:String(l.platforms??l.platform??"")}).platforms??[],d=j.useMemo(()=>pt(s),[s]),r=j.useMemo(()=>pt(a),[a]),c=y.length===1?y[0]:Is(i,d),g=i.find(I=>I.connector_key===c),u=d.size===1?Number([...d][0]):void 0,f=Ts(u),{org:p}=Nt(),v=_t(p?.id,{feedIds:[...r].map(Number),enabled:u==null&&r.size>0}),k=u==null?v:f,x=k.data??[],S={platforms:void 0,platform:void 0,connection_ids:void 0,feed_ids:void 0},M={kind:"list",searchPlaceholder:"Search connectors...",emptyText:"No connectors",items:I=>e.jsxs(e.Fragment,{children:[i.map(N=>{const A=N.connector_name??N.connector_key;return e.jsxs(T,{disabled:N.connections.length===0,onSelect:()=>{n(o({...S,platforms:N.connector_key})),I()},className:"group gap-2",children:[e.jsx(D,{selected:N.connector_key===g?.connector_key}),e.jsx(Ls,{plain:!0,name:A,faviconDomain:N.favicon_domain,className:"h-5 w-5 shrink-0 rounded-md text-[10px]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:A}),N.connection_count>0?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:N.connection_count}):null,e.jsx(J,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:N.connector_key},label:A})]},N.connector_key)}),e.jsx(T,{asChild:!0,onSelect:I,className:"text-muted-foreground",children:e.jsxs(ke,{to:"/$owner/connectors/create",params:{owner:t},className:"flex items-center gap-2",children:[e.jsx(Et,{className:"h-4 w-4 shrink-0"}),"Add connector"]})})]})},F=[{key:"connector",label:"Connector",group:Fe,icon:e.jsx(Ms,{className:V}),editor:M}],E=[],R=g?.connector_name??g?.connector_key??(y.join(", ")||(d.size?`Connections ${[...d].join(", ")}`:void 0));if(R&&E.push({id:"connector",label:"Connector",op:"is",value:R,onRemove:()=>void n(o(S))}),g){F.push({key:"connection",label:"Connection",group:Fe,icon:e.jsx(As,{className:V}),editor:Q(g)});const I=d.size===1?g.connections.find(N=>d.has(String(N.id))):void 0;I&&E.push({id:"connection",label:"Connection",op:"is",value:ct({display_name:I.display_name,connector_name:g.connector_name,connector_key:g.connector_key}),onRemove:()=>void n(o({...S,platforms:g.connector_key}))})}if((u||a)&&F.push({key:"feed",label:"Feed",group:Fe,icon:e.jsx(Fs,{className:V}),editor:G()}),r.size>0){const I=r.size===1?x.find(N=>r.has(String(N.id))):void 0;E.push({id:"feed",label:"Feed",op:"is",value:I?pe(I):`#${a}`,onRemove:()=>void n(o({...u!=null?{connection_ids:String(u)}:{},feed_ids:void 0}))})}return{fields:F,chips:E};function Q(I){return{kind:"list",searchPlaceholder:"Search connections...",emptyText:"No connections",items:N=>I.connections.map(A=>{const b=ct({display_name:A.display_name,connector_name:I.connector_name,connector_key:I.connector_key});return e.jsxs(T,{onSelect:()=>{n(o({connection_ids:String(A.id),feed_ids:void 0})),N()},className:"group gap-2",children:[e.jsx(D,{selected:d.has(String(A.id))}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:b}),A.feed_count>0?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:A.feed_count}):null,e.jsx(J,{...$n(t,{id:A.id,connector_key:I.connector_key}),label:b})]},A.id)})}}function G(){return{kind:"list",searchPlaceholder:"Search feeds...",emptyText:k.isLoading?"Loading feeds...":"No feeds",items:I=>x.map(N=>e.jsxs(T,{"aria-label":pe(N),onSelect:()=>{n(o({...u!=null?{connection_ids:String(u)}:{},feed_ids:String(N.id)})),I()},className:"group gap-2",children:[e.jsx(D,{selected:r.has(String(N.id))}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:pe(N)}),e.jsx(J,{...Ln(t,N),label:pe(N)})]},N.id))}}}function pe(t){return t.display_name?.trim()||t.feed_key}const je=[{value:"date-desc",label:"Newest first"},{value:"date-asc",label:"Oldest first"},{value:"score-desc",label:"Highest score"},{value:"score-asc",label:"Lowest score"}];function Xn({value:t,onChange:s}){const a=je.find(n=>n.value===t)?.label??"Newest first";return e.jsxs(Qs,{value:t,onValueChange:s,children:[e.jsxs(Ws,{"aria-label":"Sort",className:"h-8 w-auto shrink-0 gap-2 bg-muted px-2.5",children:[e.jsx(It,{"aria-hidden":"true",className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Hs,{children:a})]}),e.jsx(zs,{align:"end",className:"min-w-40",children:je.map(n=>e.jsx(Ys,{value:n.value,children:n.label},n.value))})]})}const ht=[{value:"user",label:"Manual review"},{value:"system",label:"Auto-classified"},{value:"llm",label:"LLM-classified"}],vt=[{value:"pending",label:"Pending approval"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}],he=0,ve=100,q="Event",U="h-4 w-4";function Jn(t,s,a){const n=t.engagementRange??[he,ve],o=t.reviewStatus,i=t.interactionStatus,l=t.semanticTypes??[],y=[{key:"kind",label:"Event kind",group:q,icon:e.jsx(Bs,{className:U}),editor:X({searchPlaceholder:"Search event kinds...",emptyText:"No event kinds found",options:bn(a,l).map(c=>({value:c,label:Ae(c)})),selected:l,multiple:!0,onSelect:c=>{const g=l.includes(c)?l.filter(u=>u!==c):[...l,c];s({semanticTypes:g.length>0?g:void 0})}})},{key:"date",label:"Date",group:q,icon:e.jsx(Ks,{className:U}),editor:hn({value:t.dateRange??void 0,onApply:c=>s({dateRange:c})})},{key:"approval",label:"Approval",group:q,icon:e.jsx(Gs,{className:U}),editor:X({searchPlaceholder:"Search statuses...",options:[...vt],selected:i?[i]:[],onSelect:c=>s({interactionStatus:c})})},{key:"review",label:"Reviewed by",group:q,icon:e.jsx(Us,{className:U}),editor:X({searchPlaceholder:"Search reviewers...",options:[...ht],selected:o&&o!=="all"?[o]:[],onSelect:c=>s({reviewStatus:c})})},{key:"score",label:"Engagement score",group:q,icon:e.jsx(Vs,{className:U}),editor:vn({value:n,min:he,max:ve,onApply:c=>s({engagementRange:c})})}],d=[],r=t.eventCategory!=null&&l.length===1&&l[0]===Pt;return l.length&&!r&&d.push({id:"kind",label:"Kind",value:l.length<=2?l.map(Ae).join(", "):`${l.length} kinds`,title:l.map(Ae).join(", "),onRemove:()=>s({semanticTypes:void 0})}),t.dateRange&&d.push({id:"date",label:"Date",op:"is",value:yn(t.dateRange),onRemove:()=>s({dateRange:null})}),i&&d.push({id:"approval",label:"Approval",op:"is",value:vt.find(c=>c.value===i)?.label??i,onRemove:()=>s({interactionStatus:null})}),o&&o!=="all"&&d.push({id:"review",label:"Reviewed by",op:"is",value:ht.find(c=>c.value===o)?.label??o,onRemove:()=>s({reviewStatus:void 0})}),(n[0]!==he||n[1]!==ve)&&d.push({id:"score",label:"Engagement score",value:gn(n,he,ve),onRemove:()=>s({engagementRange:void 0})}),{fields:y,chips:d}}function $t({filters:t,onFiltersChange:s,eventKinds:a=[],searchQuery:n,onSearchChange:o,scope:i,extraFields:l=[],drillChips:y=[],sourceRead:d=!1,filterTrailing:r,filterActions:c,quickFilters:g,toolbar:u=!1,onClearFilters:f}){const p=n.trim().length>0,v=d?{fields:[],chips:[]}:Jn(t,s,a),k=`${t.sortBy??"date"}-${t.sortOrder??"desc"}`,x=R=>{const[Q,G]=R.split("-");s({sortBy:Q,sortOrder:G})},S=u&&!d?{fields:[{key:"sort",label:"Order",group:"Order",icon:e.jsx(It,{className:U}),editor:X({searchPlaceholder:"Search orders...",options:[...je],selected:[k],onSelect:x})}],chips:k==="date-desc"?[]:[{id:"sort",label:"Order",value:je.find(R=>R.value===k)?.label??k,onRemove:()=>s({sortBy:"date",sortOrder:"desc"})}]}:{fields:[],chips:[]},M=[...g?.fields??[],...v.fields,...i?.fields??[],...l,...S.fields],F=[...g?.chips??[],...i?.chips??[],...y,...v.chips,...S.chips],E=d?null:e.jsxs("div",{className:xe("relative min-w-0",u?"w-64 max-w-full":"flex-1"),children:[e.jsx($s,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Os,{type:"search","aria-label":"Search events",placeholder:"Search events...",value:n,onChange:R=>o(R.target.value),className:xe("h-8 pl-9",p&&"pr-9")}),p&&e.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:e.jsx(Ds,{className:"h-3.5 w-3.5"})})]});return u?e.jsx(ft,{label:"Event filters",clearAllMin:2,fields:M,chips:F,actions:c,trailing:e.jsxs(e.Fragment,{children:[r,E]}),onClearAll:f,hasClearableState:p,className:"w-full"}):e.jsxs("div",{className:"w-full space-y-2.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[E,!d&&e.jsx(Xn,{value:k,onChange:x})]}),e.jsx(ft,{label:"Event filters",fields:M,chips:F,actions:c,trailing:r,onClearAll:f,hasClearableState:p})]})}function Ot({ownerSlug:t,...s}){const a=Hn({ownerSlug:t,sourceRead:s.sourceRead,filters:s.filters,onFiltersChange:s.onFiltersChange});return e.jsx($t,{...s,scope:a})}const Le=3600*1e3,yt=24*Le;function gt(t){const s=t instanceof Date?t:new Date(String(t));return Number.isNaN(s.getTime())?null:s}function xt(t){return t.toISOString().split("T")[0]}function $e(t){return t.toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"})}function eo(t){const a=t[t.length-1].date.getTime()-t[0].date.getTime()>180*yt,n=new Map;for(const o of t){const i=new Date(o.date);a&&i.setUTCDate(i.getUTCDate()-i.getUTCDay()),n.set(i.getTime(),(n.get(i.getTime())??0)+o.count)}return[...n.entries()].sort(([o],[i])=>o-i).map(([o,i])=>{const l=new Date(o);return{start:l,end:new Date(o+(a?7:1)*yt),count:i,label:`${l.getUTCMonth()+1}/${l.getUTCDate()}`,tooltip:a?`Week of ${$e(l)}`:$e(l)}})}function to(t){const s=l=>{const y=new Date(l);return y.setMinutes(0,0,0),y.getTime()},a=new Map;for(const l of t)a.set(s(l),(a.get(s(l))??0)+1);const n=Math.min(...a.keys()),o=Math.max(...a.keys()),i=[];for(let l=n;l<=o;l+=Le){const y=new Date(l);i.push({start:y,end:new Date(l+Le),count:a.get(l)??0,label:lt(y,"HH:mm"),tooltip:lt(y,"MMM d, HH:mm")})}return i}function so({entityId:t,organizationId:s,ownerSlug:a,eventTimes:n,selectedRange:o,onSelectRange:i}){const{data:l,isLoading:y,error:d}=Zs(s,{entityId:t},{slug:a}),r=j.useMemo(()=>(l??[]).map(p=>{const v=gt(p.date);return v?{date:v,count:p.count}:null}).filter(p=>p!==null).sort((p,v)=>p.date.getTime()-v.date.getTime()),[l]),c=j.useMemo(()=>{if(r.length===0)return[];if(r.length>1)return eo(r);const[p]=r,v=xt(p.date),k=(n??[]).map(gt).filter(x=>x!==null&&xt(x)===v);return k.length===p.count?to(k):[]},[r,n]),g=j.useCallback(p=>{const v=c[p.dataIndex];v&&i&&i(v.start,v.end)},[c,i]),u=j.useCallback(p=>{if(i&&p.startValue!==void 0&&p.endValue!==void 0){const v=new Date(p.startValue),k=new Date(p.endValue);i(v,k)}},[i]),f=j.useMemo(()=>{if(c.length<2)return null;let p;if(o){const[v,k]=o,x=c.filter(S=>S.start<k&&S.end>v);x.length>0&&(p=[[{xAxis:x[0].label},{xAxis:x[x.length-1].label}]])}return{tooltip:{trigger:"axis",axisPointer:{type:"line"},formatter:v=>{const k=v[0];return`${c[k.dataIndex]?.tooltip}: ${k.value} items`}},grid:{left:50,right:20,top:20,bottom:60},xAxis:{type:"category",boundaryGap:!1,data:c.map(v=>v.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 In(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:c.map(v=>v.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}]}},[c,o]);if(y||d)return e.jsx("div",{className:xe(Tt,"p-4"),children:e.jsx("div",{className:"flex h-48 w-full items-center justify-center",children:y?e.jsx(An,{}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load timeline"})})});if(r.length===0)return null;if(!f){const[p]=r;return e.jsxs("p",{className:"text-xs text-muted-foreground",children:[p.count===1?"1 event":`All ${p.count} events`," on"," ",$e(p.date),"."]})}return e.jsx(no,{option:f,onClick:g,onDataZoom:u})}function no({option:t,onClick:s,onDataZoom:a}){const{chartRef:n,setOption:o}=Tn({onClick:s,onDataZoom:a});return j.useEffect(()=>{o(t,!0)},[t,o]),e.jsx("div",{"data-testid":"events-timeline",className:xe(Tt,"p-4 relative"),children:e.jsx("div",{ref:n,className:"h-48 w-full"})})}const ye={config:"Configuration",deployment:"Applies"};function oo({organizationId:t,ownerSlug:s,entityId:a,hideSourceFilter:n=!1,scopedEntityTypes:o,pinned:i,emptyState:l,toolbar:y=!1}){const{isAuthenticated:d,isReady:r}=qs(),{isMember:c,isLoading:g}=Nt(),u=r&&d&&c,f=r&&(!d||!g&&!c),p=K(),v=te(),k=Xs(),{filters:x,updateFilters:S,clearFilters:M}=wt({parse:ge,serialize:Pe,filterKeys:Ft,replace:!1,merge:At}),[F,E]=j.useState(x.searchQuery||""),[R,Q]=j.useState(Re(x)||n&&(a!=null||!!o?.length)),G=F.trim(),I=G.length>=3?G:void 0,N=St(I,1e3),A=j.useRef(!1);j.useEffect(()=>k.history.subscribe(({location:m,action:h})=>{const C=ge(new URLSearchParams(m.search)).searchQuery??"";!(h.type==="BACK"||h.type==="FORWARD"||h.type==="GO")&&A.current&&(C===(x.searchQuery??"")||C===(I??""))||(A.current=!1,E(C))}),[k.history,I,x.searchQuery]);const b=j.useMemo(()=>{const{afterOccurredAt:m,afterId:h,...C}=x;return dt({...C,...o?.length?{entityTypes:o}:{}})},[x,o]),P=S;j.useEffect(()=>{A.current&&(x.searchQuery||void 0)!==N&&S({searchQuery:N})},[N,S,x.searchQuery]);const Be=()=>{A.current=!1,E(""),n&&s?p({...we(s,v.search??{}),...a!==void 0&&!v.pathname.startsWith(`/${s}/events/`)?{to:v.pathname}:{}}):M()},ne=Re(dt(x)),Ce=a===void 0,{data:Dt=[]}=Js(r&&u?t:null),{data:Bt=[]}=en(f?s:null),Ke=u?Dt:Bt,{data:Ge=[]}=tn(u&&t?{organizationId:t}:void 0),oe=wn(),ae=b.connectionIds,Se=(ae?.length??0)>0,{data:Ue=[]}=sn(r&&u?t??"":"",{connectionIds:ae??void 0,enabled:!oe&&r&&u&&Se}),Ve=b.feedIds,Ne=(Ve?.length??0)>0,{data:Qe=[]}=_t(r&&u?t:null,{feedIds:Ve??void 0,enabled:r&&u&&Ne}),We=j.useMemo(()=>oe?oe.groups.flatMap(m=>m.connections.map(h=>({id:h.id,display_name:h.display_name,connector_name:m.connector_name,connector_key:m.connector_key}))):Ue,[Ue,oe]),_e=j.useMemo(()=>{const m=new Set(ae??[]);return[...new Set([...b.platforms??[],...We.filter(h=>m.has(h.id)).map(h=>h.connector_key)])]},[ae,We,b.platforms]),Ee=j.useMemo(()=>Qe.map(m=>({connectorKey:m.connector_key,feedKey:m.feed_key})),[Qe]),Kt=j.useMemo(()=>Se&&_e.length===0||Ne&&Ee.length===0?[]:jn({connectors:Ke,entityTypes:Ge,selectedPlatforms:_e,selectedFeeds:Ee,selectedEntityTypes:b.entityTypes}),[Ke,b.entityTypes,Se,Ne,_e,Ee,Ge]),w=b.clientIds,ie=(w?.length??0)>0,{data:He=[]}=Cn(null,{enabled:r&&u&&ie}),re=j.useMemo(()=>{if(!w)return[];const m=new Set(w);return Nn(He).filter(h=>h.clientIds.some(C=>m.has(C)))},[w,He]),ze=j.useMemo(()=>{if(!ie||!w)return null;const m=re.map(h=>h.title);return m.length>0?m.join(", "):w.length>1?`${w.length} client registrations`:"Client registration"},[re,w,ie]),ce=re.length===1?re[0]:null,Gt=s&&ce?On(s,ce.clientId):void 0,le=b.mcpActivityId??null,{data:Ye=[]}=Sn({enabled:r&&u&&ie&&!!le,clientIds:w??[],limit:100}),Ze=j.useMemo(()=>{if(!le)return null;const m=Ye.find(C=>C.activityId===le);if(!m)return"Selected conversation";const h=m.title?.trim();return h||(m.activityKind==="session"?"MCP session":m.clientId)},[le,Ye]),W=b.agentId,H=b.schedule,{data:qe=[]}=Mn(W??void 0),Xe=j.useMemo(()=>!H||!W?null:qe.find(h=>h.id===H)?.description?.trim()||"Scheduled task",[W,H,qe]),{data:Ut}=nn(r&&u?t:null,a),{data:Vt}=on(f&&!Ce?s:null,a),Je=u?Ut:Vt,de=j.useMemo(()=>{const m=new Map;for(const h of Je||[]){const C=h.automation_name??"__global__";let _=m.get(C);_||(_={automationName:h.automation_name??null,classifiers:[]},m.set(C,_));const $=h.attribute_values||{},L=Object.keys($);let me=null;const z={};for(const[Y,B]of Object.entries($))if(B.parent)for(const[Te,Z]of Object.entries(B.parent))me=Te,z[Z]||(z[Z]=[]),z[Z].push(Y);const O=_.classifiers.find(Y=>Y.slug===h.slug);if(O){const Y=new Set([...O.values,...L]);O.values=[...Y];for(const[B,Te]of Object.entries(z)){O.valuesByParentValue[B]||(O.valuesByParentValue[B]=[]);const Z=new Set([...O.valuesByParentValue[B],...Te]);O.valuesByParentValue[B]=[...Z]}me&&(O.parentSlug=me)}else _.classifiers.push({slug:h.slug,name:h.name,values:L,parentSlug:me,valuesByParentValue:z})}for(const h of m.values())h.classifiers.sort((C,_)=>C.parentSlug===null&&_.parentSlug!==null?-1:C.parentSlug!==null&&_.parentSlug===null?1:0);return[...m.values()]},[Je]),Qt=an(r&&u?t:null,a,b,s),Wt=rn(f?s:null,a,b),Ht=f?Wt:Qt,{data:Ie,isLoading:zt,error:Yt}=Ht,Zt=j.useMemo(()=>Ie?.pages.flatMap(m=>m.content.map(h=>h.occurred_at)),[Ie]),et=Ie?.pages[0],qt=(et?.content.length??0)>0,tt=de.some(m=>m.classifiers.length>0),Xt=cn(r&&u&&tt?t:null,a,b,s),Jt=ln(f&&tt?s:null,a,b),es=(f?Jt:Xt).data?.classification_stats,ts=j.useCallback(()=>{P({beforeOccurredAt:void 0,beforeId:void 0,afterOccurredAt:void 0,afterId:void 0}),window.scrollTo({top:0,behavior:"smooth"})},[P]),ss=(m,h)=>{P({dateRange:[m,h]})},st=(m,h)=>{const C={...b.classificationFilters||{}};if(h.length>0)C[m]=h;else{delete C[m];for(const _ of de)for(const $ of _.classifiers)$.parentSlug===m&&delete C[$.slug]}P({classificationFilters:C})},ns=(m,h)=>{const C=b.classificationFilters?.[m]||[];st(m,C.includes(h)?C.filter(_=>_!==h):[...C,h])},os=m=>st(m,[]);if(Yt)return e.jsx(dn,{label:"knowledge"});const nt=!r||d&&g||u&&!t||zt,ue={fields:[],chips:[]};for(const m of de)for(const h of m.classifiers){const C=b.classificationFilters?.[h.slug]??[],_=h.parentSlug?b.classificationFilters?.[h.parentSlug]??[]:void 0,$=_?[...new Set(_.flatMap(L=>h.valuesByParentValue[L]??[]))]:h.values;$.length>0&&ue.fields.push({key:`clf:${h.slug}`,label:h.name,group:m.automationName??"Classifiers",icon:e.jsx(un,{className:"h-4 w-4"}),editor:X({searchPlaceholder:`Search ${h.name.toLowerCase()}...`,options:$.map(L=>({value:L,label:L,count:es?.[h.slug]?.[L]})),selected:C,multiple:!0,onSelect:L=>ns(h.slug,L)})})}for(const[m,h]of Object.entries(b.classificationFilters??{})){if(h.length===0)continue;const C=de.flatMap(_=>_.classifiers).find(_=>_.slug===m);ue.chips.push({id:`clf:${m}`,field:`clf:${m}`,label:C?.name??m,op:h.length>1?"is any of":"is",value:h.join(", "),onRemove:()=>os(m)})}const as=[b.contentIds?.length?fe({id:"contentIds",label:b.contentIds.length>1?"Events":"Event",value:`#${b.contentIds.join(", #")}`,onRemove:()=>P({contentIds:void 0})}):null,Ze?fe({id:"mcpActivityId",label:"Conversation",value:Ze,onRemove:()=>P({mcpActivityId:void 0})}):null,ze?fe({id:"clientIds",label:"Connected app",value:ze,sourceLink:Gt,details:w&&w.length>0?e.jsx(Kn,{ownerSlug:s,clientIds:w,linkedUser:ce?.linkedUser,linkedUserEntitySlug:ce?.linkedUserEntitySlug}):void 0,onRemove:()=>P({clientIds:void 0})}):null,Xe?fe({id:"schedule",label:"Schedule",value:Xe,sourceLink:s&&W&&H?Bn(s,W,H):void 0,onRemove:()=>P({schedule:void 0,runIds:void 0})}):null,...b.eventCategory?[ye[b.eventCategory]?{id:"event-category",label:ye[b.eventCategory],value:"",onRemove:()=>P({eventCategory:void 0,semanticTypes:void 0})}:{id:"event-category",label:"Category",op:"is",value:b.eventCategory,onRemove:()=>P({eventCategory:void 0})}]:[],...b.resourceKind||b.resourceId?[{id:"resource",label:"Resource",op:"is",value:`${b.resourceKind}: ${b.resourceId}`,onRemove:()=>P({resourceKind:void 0,resourceId:void 0})}]:[],...ue.chips].filter(m=>m!=null),is=!!(u&&a&&t),rs=ne?null:i?.rows,ot={fields:[],chips:[]};if(Ce&&u)for(const[m,h,C]of[["config",ye.config,kt],["deployment",ye.deployment,mn]]){const _=x.eventCategory===m;ot.fields.push({key:`category:${m}`,label:h,icon:e.jsx(C,{className:"h-4 w-4"}),editor:{kind:"toggle",checked:_,onToggle:()=>P({eventCategory:_?void 0:m,semanticTypes:_?void 0:[Pt],resourceKind:void 0,resourceId:void 0})}})}const at={quickFilters:ot,toolbar:y,filterTrailing:is?e.jsxs(Rt,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground","aria-pressed":R,onClick:()=>Q(m=>!m),children:[e.jsx(pn,{className:"mr-1.5 h-3.5 w-3.5"}),"Timeline"]}):void 0,onClearFilters:Be,filters:b,onFiltersChange:P,eventKinds:Kt,searchQuery:F,onSearchChange:m=>{A.current=!0,E(m)},extraFields:ue.fields,drillChips:as},cs=!nt&&!!et&&!qt&&!ne,ls=d?u?"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",it=!!(u&&s);return e.jsx(fn,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:n?"sticky top-0 z-10 -mx-4 bg-background px-4 pb-2 lg:-mx-6 lg:px-6":void 0,children:n&&s?e.jsx(Ot,{...at,ownerSlug:s}):e.jsx($t,{...at})}),R&&u&&a&&t&&e.jsx(so,{entityId:a,organizationId:t,ownerSlug:s||"",eventTimes:Zt,selectedRange:b.dateRange||void 0,onSelectRange:ss}),i?.needsYou,rs,nt?e.jsx(En,{}):cs?l??e.jsx(ut,{icon:mt,title:"No activity yet",description:ls,actionLabel:it?"Add a connector":void 0,onAction:it&&s?()=>void p({to:"/$owner/connectors/create",params:{owner:s}}):void 0}):e.jsx(_n,{organizationId:t,ownerSlug:s,entityId:a,filters:b,showEntityLinks:Ce,groupStretches:!0,onGoToLatest:b.beforeOccurredAt?ts:void 0,hiddenPinned:i?.hidden,emptyState:e.jsx(ut,{icon:mt,title:"No results found",description:"Try adjusting your filters to find what you are looking for",actionLabel:ne?"Clear filters":void 0,onAction:ne?Be:void 0})})]})})}function ao({record:t,ownerSlug:s}){const a=te(),n=K(),{filters:o,updateFilters:i}=wt({parse:ge,serialize:Pe,filterKeys:Ft,replace:!1,merge:At}),l=Re({...o,platforms:void 0,connectionIds:void 0,feedIds:void 0})||o.sortBy!=null&&o.sortBy!=="date"||o.sortOrder!=null&&o.sortOrder!=="desc",y=()=>{n({...we(s,a.search??{}),...a.pathname.startsWith(`/${s}/events/`)?{}:{to:a.pathname}})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ot,{ownerSlug:s,sourceRead:!0,filters:o,onFiltersChange:i,searchQuery:o.searchQuery??"",onSearchChange:d=>i({searchQuery:d}),onClearFilters:y}),e.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."}),l?e.jsxs("div",{role:"alert",className:"space-y-2 rounded-md border p-3 text-sm",children:[e.jsx("p",{children:"Some selected filters aren't supported for live activity. Clear them to see results."}),e.jsx(Rt,{variant:"outline",size:"sm",onClick:()=>{const d=Pe({platforms:o.platforms,connectionIds:o.connectionIds,feedIds:o.feedIds}),r={...we(s,a.search??{}).search,...d};n({to:a.pathname,search:r})},children:"Clear unsupported filters"})]}):e.jsx(kn,{record:t,orgContext:{slug:s},filters:o})]})}function ko({entity:t,organizationId:s,ownerSlug:a}){const n=t.is_derived?e.jsx(ao,{ownerSlug:a,record:{type:t.entity_type,key:t.slug}}):e.jsx(oo,{organizationId:s,ownerSlug:a,entityId:typeof t.id=="number"?t.id:void 0,hideSourceFilter:!0});return e.jsx(Rn,{organizationId:s,children:t.entity_type==="$member"?e.jsx(Fn,{children:n}):n})}export{oo as E,Rn as M,ko as R};
|
|
2
|
-
//# sourceMappingURL=record-activity-9ux6SfCd.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a9 as v,r as a,j as e,L as h,aa as j,$ as y,ab as N}from"./index-CdDNNAx2.js";import{C as k,a as C,b as S,c as L}from"./card-C01y1O-W.js";function R(){const{token:n,error:x}=v.useSearch(),[o,p]=a.useState(""),[i,f]=a.useState(""),[d,s]=a.useState(null),[l,c]=a.useState(!1),[u,g]=a.useState(!1),w=async t=>{if(t.preventDefault(),!n){s("This reset link is invalid or expired.");return}if(o.length<8){s("Password must be at least 8 characters.");return}if(o!==i){s("Passwords do not match.");return}c(!0),s(null);try{const r=await j(`${y}/api/auth/reset-password`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:n,newPassword:o})});if(!r.ok)throw await N(r);g(!0)}catch(r){s(r instanceof Error?r.message:"Failed to reset password")}finally{c(!1)}},b=!n||x==="INVALID_TOKEN",m={callbackUrl:void 0,mode:void 0,error:void 0,errorDescription:void 0,loginHint:void 0,invitationOrg:void 0,intent:void 0};return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-md p-8",children:[e.jsx("img",{src:"/lobu-logo.svg",alt:"Lobu",className:"mx-auto mb-6 h-8 w-auto"}),e.jsxs(k,{children:[e.jsx(C,{children:e.jsx(S,{asChild:!0,children:e.jsx("h1",{className:"text-center text-2xl",children:"Reset your password"})})}),e.jsx(L,{children:b&&!u?e.jsxs("div",{className:"mt-6 space-y-4 text-center",children:[e.jsx("p",{className:"text-sm text-destructive",children:"This reset link is invalid or expired."}),e.jsx(h,{to:"/auth/login",search:m,className:"text-sm text-primary hover:underline",children:"Back to sign in"})]}):u?e.jsxs("div",{className:"mt-6 space-y-4 text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your password has been reset successfully."}),e.jsx(h,{to:"/auth/login",search:m,className:"text-sm text-primary hover:underline",children:"Continue to sign in"})]}):e.jsxs("form",{onSubmit:w,className:"mt-6 space-y-4",children:[d&&e.jsx("div",{className:"p-3 text-sm text-destructive bg-destructive/10 rounded-lg",children:d}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"new-password",className:"block text-sm font-medium",children:"New password"}),e.jsx("input",{id:"new-password",type:"password",value:o,onChange:t=>p(t.target.value),minLength:8,required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium",children:"Confirm new password"}),e.jsx("input",{id:"confirm-password",type:"password",value:i,onChange:t=>f(t.target.value),minLength:8,required:!0,className:"mt-1 block h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsx("button",{type:"submit",disabled:l,className:"flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50",children:l?"Resetting password...":"Reset password"})]})})]})]})})}export{R as component};
|
|
2
|
-
//# sourceMappingURL=reset-password-D2RfrEVZ.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{g0 as l,dM as r,dA as d,dN as g,aa as f,g1 as I}from"./index-CdDNNAx2.js";const m=30,s=new Set(["running","pending","claimed"]);function y(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 _(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 T(n,e,t){return l({queryKey:["runs-infinite",t??null,n?y(n):null,e.runTypes??null,e.status??null,e.automationIds??null,e.connectionIds??null,e.feedIds??null],queryFn:async({pageParam:a})=>{const i=a;return r("manage_operations",{action:"list_runs",..._(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}:{},...i?{before_id:i.before_id,before_created_at:i.before_created_at}:{},limit:m},t?{slug:t}:void 0)},initialPageParam:null,getNextPageParam:a=>{if(!a.has_more)return;const i=a.runs[a.runs.length-1];if(i)return{before_id:i.id,before_created_at:i.created_at}},refetchInterval:a=>(a.state.data?.pages??[]).some(u=>u.runs.some(c=>s.has(c.status)))?5e3:!1,enabled:!!n,staleTime:15e3})}function h(n){return s.has(n??"")}function b(n,e){return d({queryKey:["run-outcome",n,e],queryFn:async()=>{const t=await r("manage_operations",{action:"get_run",run_id:e},{slug:n});if(!t.run)throw new Error(t.error||"Run not found");return t.run},enabled:n!=="me",staleTime:15e3,refetchInterval:t=>h(t.state.data?.status)?5e3:!1})}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 K(n,e){const{slug:t}=g(),a=e!=null?p(n,e):null,i=n.kind==="agent"?["agent",n.agentId]:["automation",n.agentId,n.automationId];return d({queryKey:["pending-proposal",t,...i,e],queryFn:async()=>{const o=await f(I(t,a),{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:!!t&&!!a&&!!e,staleTime:0,retry:!1})}export{b as a,K as b,h as i,T as u};
|
|
2
|
-
//# sourceMappingURL=runs-CuC7WMtd.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{G as y,dA as b,fP as R,j as e,B as j,fQ as v,m as _,bR as C,L,fg as F,I as E}from"./index-CdDNNAx2.js";import{a as P,R as $,b as A}from"./events-feed-BI7wNRUY.js";import{a as S}from"./run-initiator-B8IRlRd-.js";function f({failures:o,onRetry:c,isError:l=!1,isFetching:d=!1}){return o.length===0&&!l?null:e.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-3 rounded-md border border-destructive/40 px-3 py-2 text-xs",children:[e.jsxs("span",{children:[o.length<=1?"A source":`${o.length} sources`," could not be read, so some items may be missing."]}),e.jsx(j,{size:"sm",variant:"outline",className:"h-7",onClick:c,disabled:d,children:"Retry"})]})}function z({record:o,orgContext:c,filters:l}){const{orgContext:d}=y(),t=c??d,{data:p}=b({queryKey:["connector-definitions","source-record",t.organizationId,t.slug],queryFn:()=>E(t),enabled:!!(t.organizationId||t.slug),staleTime:6e4}),{data:i,isLoading:u,isError:n,refetch:x,fetchNextPage:a,hasNextPage:h,isFetching:g,isFetchingNextPage:s}=R(o,t,l),N=i?.pages.flatMap(r=>r.events)??[],m=i?.pages.flatMap(r=>r.failures)??[];return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(f,{failures:m,isError:n,isFetching:g,onRetry:()=>void x()}),e.jsx(S,{isLoading:u,hasNextPage:!!h&&!n,autoLoadMore:m.length===0,isFetching:g,isFetchingNextPage:s,onLoadMore:()=>void a(),emptyState:n||m.length>0||h?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"No activity for this record in its connected sources."}),items:N.map(r=>({key:`${r.feed_id}:${r.origin_id}`,occurredAt:r.occurred_at,content:e.jsx("div",{className:"p-3",children:e.jsx(P,{ownerSlug:t.slug,connectorDefinitions:p,content:{...r,title:r.title||r.origin_type||r.origin_id,text_content:r.payload_text??""}})})}))})]})}function B({record:o,ownerSlug:c,orgContext:l}){const{orgContext:d}=y(),{data:t,isLoading:p,isError:i,refetch:u,hasNextPage:n,fetchNextPage:x,isFetching:a,isFetchNextPageError:h,error:g}=v(o,l??d);return p?e.jsx(_,{className:"h-12 w-full rounded-lg"}):t?e.jsxs("div",{className:"space-y-2",children:[e.jsx($,{count:t.relationshipFailures?.length??0,onRetry:()=>void u()}),e.jsx(f,{failures:t.failures,isError:i,isFetching:a,onRetry:()=>{if(a)return;const s=g instanceof C&&g.status===400;h&&!s||!i&&n?x():u()}}),t.links.length===0&&(t.relationships?.length??0)===0&&t.failures.length===0&&(t.relationshipFailures?.length??0)===0&&!n&&!i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this record in its connected sources."}),t.links.length===0&&(t.relationships?.length??0)===0&&n&&!i&&t.failures.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"More source records remain to check for relationships."}),e.jsxs("ul",{className:"space-y-1",children:[(t.relationships??[]).map(s=>e.jsx("li",{className:"rounded-lg border px-3 py-2",children:e.jsx(A,{row:s,entityId:o.key,entityType:o.type,ownerSlug:c,orgContext:l??d})},`authored:${s.id}`)),t.links.map(s=>e.jsx("li",{children:e.jsx(L,{to:F(c,[{entity_type:s.entity_type,slug:s.key}]),className:"flex items-center justify-between rounded-lg border px-3 py-2 text-sm hover:bg-muted/50",children:e.jsxs("span",{children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.relationship_type.replaceAll("_"," "),s.direction==="incoming"?" (from)":""," ·"," ",s.entity_type," ·"," "]}),s.name]})})},`${s.relationship_type}:${s.direction}:${s.entity_type}:${s.key}`))]}),n&&!i&&t.failures.length===0&&e.jsx(j,{variant:"outline",size:"sm",disabled:a,onClick:()=>void x(),children:a?"Loading…":"Load more"})]}):e.jsx(f,{failures:[],isError:!0,isFetching:a,onRetry:()=>void u()})}export{z as S,B as a};
|
|
2
|
-
//# sourceMappingURL=source-record-panels-C4UItfdk.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{dA as u,dK as c,dL as s,ad as r,b$ as l,dM as o}from"./index-CdDNNAx2.js";function y(){return u({queryKey:["automation-catalog"],queryFn:async()=>(await o("manage_catalog",{action:"list_catalog",kinds:["automations"]})).catalogs?.automations?.entries??[],staleTime:6e4})}function g(t,a,i){return u({queryKey:["automations-list",t,a,i?.includeDetails??!0],queryFn:async()=>(await o("manage_automations",{action:"list",entity_id:a,status:"active",include_details:i?.includeDetails??!0})).automations||[],enabled:!!t,staleTime:3e4})}function _(t,a,i,e={}){const n=c(e.ownerSlug);return u({queryKey:["automation-detail",n,t,a,e.includeVersions??!1],queryFn:async()=>await o("get_automation",{automation_id:t,entity_id:a,page_size:1,include_versions:e.includeVersions??!1},{slug:n},{timeoutMs:3e4}),enabled:!!n&&!!t&&!!(e.ownerSlug||i),staleTime:3e4})}const A=s({tool:"manage_automations",body:t=>({action:"update",...t}),invalidateKeys:["automations-list","automation-detail","automations"],checkError:!1,successMessage:"Automation updated",errorMessage:"Failed to update Automation"}),q=s({tool:"manage_automations",body:t=>({action:"trigger",automation_id:t}),invalidateKeys:["automations-list","automation-detail","automations","runs-infinite"],errorMessage:"Failed to run Automation"}),v=s({tool:"manage_automations",body:t=>({action:"delete",automation_ids:[t]}),invalidateKeys:["automations-list","automation-detail","automations","agent-threads"],checkError:!1,successMessage:"Automation deleted",errorMessage:"Failed to delete Automation"}),K=s({tool:"manage_automations",body:t=>({action:"create",...t}),invalidateKeys:["automations-list","automations"],successMessage:"Automation created",errorMessage:"Failed to create Automation"});function f(){const t=r();return l({mutationFn:async a=>o("manage_automations",{action:"create_version",...a}),onSuccess:()=>{t.invalidateQueries({queryKey:["automations-list"]}),t.invalidateQueries({queryKey:["automation-detail"]}),t.invalidateQueries({queryKey:["automations"]})}})}function M(){const t=r();return l({mutationFn:async a=>o("manage_automations",{action:"set_reaction_script",...a}),onSuccess:()=>{t.invalidateQueries({queryKey:["automations-list"]}),t.invalidateQueries({queryKey:["automation-detail"]}),t.invalidateQueries({queryKey:["automations"]})}})}export{_ as a,v as b,K as c,f as d,M as e,A as f,y as g,q as h,g as u};
|
|
2
|
-
//# sourceMappingURL=use-automations-CdtiVLCv.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as d,j as e,a2 as U,i as R,a3 as D,B as W,a4 as B,a5 as I,a6 as T,a7 as V,W as q,a8 as G}from"./index-CdDNNAx2.js";import{C as K,a as J,b as Q,d as X,c as Y}from"./card-C01y1O-W.js";function z(s){if(!s)return null;try{const t=new URL(s);return t.protocol==="https:"&&t.hostname?t.toString():null}catch{return null}}function _(s){const t=z(s);if(!t)return null;const a=new URL(t).hostname.toLowerCase();return a.length>0&&a.length<=253&&/^[a-z0-9.-]+$/.test(a)?a:null}function Z({clientName:s,logoUri:t=null,clientUri:a=null}){const[r,i]=d.useState(!1),[o,p]=d.useState(!1),g=r?null:z(t),j=o?null:_(a)??_(t);return g?e.jsx("img",{src:g,alt:"",referrerPolicy:"no-referrer",onError:()=>i(!0),className:"h-10 w-10 shrink-0 rounded-md object-contain"}):j?e.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${encodeURIComponent(j)}&sz=64`,alt:"",referrerPolicy:"no-referrer",onError:()=>p(!0),className:"h-10 w-10 shrink-0 rounded-md bg-secondary object-contain"}):e.jsx("div",{"aria-hidden":"true",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-secondary text-base font-bold text-secondary-foreground",children:(s??"?").charAt(0).toUpperCase()||"?"})}const H=["mcp:read","mcp:write","mcp:admin"],ee=[{value:"read",title:"Read only",description:"Search and view authorized workspace data."},{value:"write",title:"Read and make changes",description:"Includes read access. Create and update authorized workspace data."},{value:"admin",title:"Administer workspaces",description:"Includes read and write access. Manage administrator-only settings.",risk:"high"}],L={read:0,write:1,admin:2};function F(s){return s.includes("mcp:admin")?"admin":s.includes("mcp:write")?"write":s.includes("mcp:read")?"read":null}function se(s,t){const a=s.filter(i=>!H.includes(i));if(!t)return a;const r=F(s);return!r||L[t]>L[r]?a:["mcp:read",...t==="write"||t==="admin"?["mcp:write"]:[],...t==="admin"?["mcp:admin"]:[],...a]}function ie({idPrefix:s,clientName:t,clientNote:a,requestedScopes:r,accessLevel:i,onAccessLevelChange:o,allowNoAccess:p=!1,disabled:g=!1,resource:j=null,logoUri:w=null,clientUri:h=null}){const y=F(r),x=r.includes("profile:read"),m=r.filter(c=>!H.includes(c)&&c!=="profile:read"&&c!=="device_worker:run"&&c!=="connections:token");return e.jsxs("div",{className:"space-y-5",children:[e.jsx("section",{"aria-label":"Application",className:"space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Z,{clientName:t,logoUri:w,clientUri:h}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:t||"Unnamed application"}),a?e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a}):null,j&&e.jsxs("div",{className:"mt-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5",children:[e.jsx("p",{children:"Requesting access to"}),r.length>0&&e.jsx("p",{className:"flex flex-wrap gap-1.5",children:r.map(c=>e.jsx("span",{className:"px-1 py-0.5 font-mono text-[11px] text-foreground",children:c},c))})]}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:e.jsxs("p",{children:["on"," ",e.jsx("code",{className:"break-all rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:j})]})})]})]})]})}),x&&e.jsxs("section",{"aria-labelledby":`${s}-profile`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-profile`,className:"text-sm font-medium",children:"Account information"}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:["Basic profile",e.jsx(U,{variant:"secondary",children:"Always included"})]}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"See your basic Lobu identity and the names and slugs of workspaces you belong to. This is separate from the workspace data access below."})]})]}),y&&e.jsxs("fieldset",{className:"space-y-2",disabled:g,children:[e.jsx("legend",{className:"text-sm font-medium",children:"What should this client have access to?"}),e.jsxs("div",{className:"space-y-2",children:[p?e.jsxs("label",{htmlFor:`${s}-access-none`,className:R("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",i===null&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:`${s}-access-none`,type:"radio",name:`${s}-access-level`,value:"none",checked:i===null,onChange:()=>o(null),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsx("span",{className:"block text-sm font-medium text-foreground",children:"No workspace data access"}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:"Pair the device only. It won't read or write workspace data."})]})]}):null,ee.filter(c=>L[c.value]<=L[y]).map(c=>{const f=`${s}-access-${c.value}`,b=i===c.value;return e.jsxs("label",{htmlFor:f,className:R("flex cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors",b&&"border-primary bg-primary/5"),children:[e.jsx("input",{id:f,type:"radio",name:`${s}-access-level`,value:c.value,checked:b,onChange:()=>o(c.value),className:"mt-1 h-4 w-4 accent-primary"}),e.jsxs("span",{className:"min-w-0 space-y-0.5",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-2 text-sm font-medium text-foreground",children:[c.title,c.risk==="high"&&e.jsx(D,{"aria-label":"High risk",className:"h-3.5 w-3.5 shrink-0 text-destructive",children:e.jsx("title",{children:"High risk"})})]}),e.jsx("span",{className:"block text-sm text-muted-foreground",children:c.description})]})]},c.value)})]})]}),m.length>0&&e.jsxs("section",{"aria-labelledby":`${s}-additional`,className:"space-y-2",children:[e.jsx("p",{id:`${s}-additional`,className:"text-sm font-medium",children:"Additional permissions"}),e.jsx("ul",{className:"space-y-2",children:m.map(c=>e.jsx("li",{className:"rounded-md border p-3 font-mono text-xs text-foreground",children:c},c))})]})]})}function oe({summary:s,children:t,className:a}){return e.jsxs("div",{className:R("flex flex-wrap items-center gap-3 border-t pt-4",s?"justify-between":"justify-end",a),children:[s?e.jsx("p",{className:"text-sm text-muted-foreground",children:s}):null,e.jsx("div",{className:"ml-auto flex items-center gap-3",children:t})]})}function de({busy:s,approveLabel:t="Approve",approveDisabled:a=!1,denyDisabled:r=!1,onApprove:i,onDeny:o}){return e.jsxs(e.Fragment,{children:[e.jsx(W,{type:"button",variant:"outline",onClick:o,disabled:r,children:s==="deny"?"Denying...":"Deny"}),e.jsx(W,{type:"button",onClick:i,disabled:a,children:s==="approve"?"Approving...":t})]})}function me({title:s,description:t,busy:a=!1,error:r=null,review:i,aside:o,below:p,notice:g,footer:j,live:w=!1}){return e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(K,{className:R("w-full",o?"max-w-4xl":"max-w-lg"),role:w?"status":void 0,"aria-live":w?"polite":void 0,children:[e.jsxs(J,{children:[e.jsx(Q,{asChild:!0,children:e.jsx("h1",{children:s})}),t?e.jsx(X,{children:t}):null]}),e.jsxs(Y,{className:"space-y-5","aria-busy":a,children:[o?e.jsxs("div",{className:"grid gap-6 md:grid-cols-[minmax(0,1fr)_300px]",children:[e.jsx("div",{className:"min-w-0",children:i}),e.jsx("div",{className:"min-w-0",children:o})]}):i,p,g,r?e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:r}):null,j]})]})})}function ue({resourceOrg:s,accessLevel:t}){return e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-2",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",s]}),e.jsxs("ul",{className:"space-y-1 text-muted-foreground",children:[e.jsx("li",{children:"If this workspace is public, the app can read public data immediately after approval."}),t==="write"?e.jsx("li",{children:"If you are not already a member, this connection will stay read-only. Ask an organization admin to grant write access, then reconnect the MCP client."}):null,t==="admin"?e.jsx("li",{children:"If you are not already an admin or owner, elevated actions will stay blocked. Ask an organization owner to grant the required role, then reconnect the MCP client."}):null,t==="read"?e.jsx("li",{children:"Public read access does not require membership."}):null]})]})}function te(s){const t=q(s);return t.kind==="cross-host"?t.href:t.to}function pe({idPrefix:s,heading:t,orgList:a,selectedOrgIds:r,onWorkspaceAccessChange:i,onSelectedOrgChange:o,orgsLoading:p,orgsError:g,onRetry:j,disabled:w=!1,includedOrgId:h=null,allowMultiple:y}){const x=`${s}-workspace-access-legend`,m=`${s}-workspace-search`,[c,f]=d.useState(""),b=t??"Workspace access",N=h?a.find(n=>n.id===h)??null:null,k=a.filter(n=>n.id!==h),$=r.filter(n=>n!==h).length,A=h?$:r.length,E=k.length>0&&k.every(n=>r.includes(n.id));if(p)return e.jsxs("section",{"aria-labelledby":x,className:"space-y-2",children:[e.jsx("p",{id:x,className:"text-sm font-medium",children:b}),e.jsx("p",{role:"status","aria-live":"polite",className:"text-sm text-muted-foreground",children:"Loading your workspaces..."})]});if(g)return e.jsxs("section",{"aria-labelledby":x,className:"space-y-2",children:[e.jsx("p",{id:x,className:"text-sm font-medium",children:b}),e.jsxs("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(W,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:j,children:"Retry"})]})]});if(a.length===0)return e.jsxs("section",{"aria-labelledby":x,className:"space-y-2",children:[e.jsx("p",{id:x,className:"text-sm font-medium",children:b}),e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:"No member workspaces are available for this connection."})]});const M=()=>{if(E)for(const n of k)o(n.id,!1);else i("all_current")},S=c.trim().toLowerCase(),l=S?k.filter(n=>n.name.toLowerCase().includes(S)||n.slug.toLowerCase().includes(S)):k;return e.jsxs("fieldset",{className:"min-w-0 space-y-3",disabled:w,children:[e.jsx("legend",{id:x,className:"sr-only",children:b}),e.jsxs("p",{className:"text-sm font-medium",children:[b," ",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",A," selected"]})]}),e.jsxs("div",{className:"flex min-w-0 flex-col overflow-hidden rounded-md border bg-card",children:[e.jsxs("div",{className:"border-b bg-card p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Workspaces"}),y&&k.length>0&&e.jsx("button",{type:"button",onClick:M,className:"shrink-0 cursor-pointer bg-none p-0 text-xs font-semibold text-foreground underline underline-offset-4",children:E?"Clear all":`Select all ${k.length}`})]}),!h&&e.jsx("p",{className:"mt-0.5 whitespace-nowrap text-sm text-muted-foreground",children:y?"Choose workspaces for this app.":"Choose one workspace this application can access."}),e.jsx("input",{id:m,type:"search",value:c,onChange:n=>f(n.target.value),placeholder:"Filter workspaces…","aria-label":"Filter workspaces",className:"mt-2 flex h-9 w-full rounded-md border border-input bg-background px-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring"})]}),e.jsxs("div",{className:"max-h-80 space-y-1.5 overflow-auto p-2",children:[N?e.jsxs("div",{className:"flex items-center gap-2.5 rounded-md bg-muted px-2.5 py-2",children:[e.jsx(B,{"aria-hidden":"true",className:"h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 truncate",children:N.name}),N.isPersonal&&e.jsx(I,{"aria-label":"Personal workspace",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",children:e.jsx("title",{children:"Personal workspace"})}),e.jsx(U,{variant:"secondary",className:"shrink-0",children:"Device home"})]})}),e.jsx("span",{className:"sr-only",children:"Included"})]}):null,l.map(n=>{const u=`${s}-workspace-${n.id}`,v=r.includes(n.id);return e.jsxs("div",{className:R("flex items-center gap-2.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted/60",v&&"bg-primary/5 hover:bg-primary/5"),children:[e.jsx(T,{id:u,checked:v,disabled:w,onCheckedChange:C=>o(n.id,C===!0)}),e.jsx("label",{htmlFor:u,className:"min-w-0 flex-1 cursor-pointer truncate text-sm font-medium text-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"min-w-0 truncate",children:n.name}),n.isPersonal&&e.jsx(I,{"aria-label":"Personal workspace",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",children:e.jsx("title",{children:"Personal workspace"})})]})}),e.jsx("a",{href:te(n.slug),target:"_blank",rel:"noopener noreferrer",onClick:C=>C.stopPropagation(),"aria-label":`Open ${n.name} workspace`,title:`Open ${n.name} workspace`,className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(V,{className:"h-3.5 w-3.5"})})]},n.id)}),l.length===0&&!N&&e.jsx("p",{className:"px-2 py-3 text-[13px] text-muted-foreground",children:"No workspaces match."})]}),e.jsx("div",{className:"border-t bg-card px-3 py-2 text-xs text-muted-foreground",children:e.jsx("p",{"aria-live":"polite",children:h?`${$} additional workspace${$===1?"":"s"} selected.`:`${r.length} of ${a.length} workspaces selected.`})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Workspaces you join later are not added automatically."}),r.length===0&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"Choose at least one workspace."})]})}function ne(s,t){return s.length===t.length&&s.every((a,r)=>a===t[r])}function re(s={}){const{requireDeviceHome:t=!1,deviceHomeOrgId:a=null,allowMultiple:r=!0}=s,{data:i,error:o,isPending:p,refetch:g}=G(),[j,w]=d.useState("selected"),[h,y]=d.useState([]),x=d.useRef(!1),m=d.useMemo(()=>i?i.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,slug:l.slug,isPersonal:l.is_personal===!0})):[],[i]),c=m.find(l=>l.isPersonal)?.id??null,f=t?a&&m.some(l=>l.id===a)?a:c:null,b=d.useRef(m);b.current=m;const N=o instanceof Error?o.message:o?"Unable to load workspaces":null;d.useEffect(()=>{if(p||N)return;const l=m.map(u=>u.id),n=new Set(l);y(u=>{const v=x.current?u.filter(C=>n.has(C)):[c??l[0]].filter(C=>!!C);return x.current=!0,ne(u,v)?u:v})},[m,N,p,c]);const k=d.useCallback(l=>{if(l==="all_current"){if(!r)return;y(b.current.map(n=>n.id))}w(l)},[r]),$=d.useCallback((l,n)=>{b.current.some(u=>u.id===l)&&(t&&(l===f||!r)||(w("selected"),y(u=>n?r?u.includes(l)?u:[...u,l]:[l]:u.filter(v=>v!==l))))},[r,f,t]),A=d.useMemo(()=>{if(t&&f&&!r)return[f];const l=new Set(h);return t&&f&&l.add(f),m.filter(n=>l.has(n.id)).map(n=>n.id)},[r,h,f,m,t]),E=d.useCallback(()=>{const l=b.current,n=l.find(u=>u.isPersonal)?.id??l[0]?.id;x.current=l.length>0,w("selected"),y(n?[n]:[])},[]),M=!p&&!N&&m.length>0&&A.length>0&&(r||A.length===1)&&(!t||f!==null&&A.includes(f)),S=d.useCallback(()=>{g()},[g]);return{orgList:m,workspaceAccess:j,setWorkspaceAccess:k,selectedOrgIds:A,toggleSelectedOrgId:$,resetWorkspaceSelection:E,personalOrgId:c,deviceHomeOrgId:f,orgsLoading:p,orgsError:N,retryOrgs:S,workspaceSelectionReady:M}}function ae(s){if(!s)return null;try{return new URL(s).pathname.match(/^\/mcp\/([^/]+)$/)?.[1]?.trim()||null}catch{return null}}function he({requestedScopes:s,resource:t=null,allowMultiple:a,requireDeviceHome:r=!1,deviceHomeOrgId:i=null}){const o=F(s),[p,g]=d.useState(o);d.useEffect(()=>{g(F(s))},[s]);const j=d.useMemo(()=>se(s,p),[s,p]),w=d.useMemo(()=>ae(t),[t]),h=j.some(m=>m.startsWith("mcp:")),y=h&&!w,x=re({allowMultiple:a,requireDeviceHome:r,deviceHomeOrgId:i});return{accessLevel:p,setAccessLevel:g,selectedScopes:j,resourceOrg:w,hasMcpScopes:h,requiresWorkspaceAccess:y,...x}}function P(s){return typeof s=="string"&&s.length>0?s:null}function xe(s,t){return P(s?.error_description)??P(s?.message)??P(s?.error)??t}function O(s=window.location.href){const t=new URL("/auth/login",window.location.origin);return t.searchParams.set("callbackUrl",s),t.toString()}function fe(){window.location.href=O()}function ge(s,t){d.useEffect(()=>{t||s||(window.location.href=O())},[s,t])}export{ie as A,me as C,ue as R,pe as W,ge as a,oe as b,de as c,F as g,xe as o,fe as r,he as u};
|
|
2
|
-
//# sourceMappingURL=use-login-redirect-CYlVkAhE.js.map
|